Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api
Class CoreInstance

java.lang.Object
  extended by org.nuxeo.ecm.core.api.CoreInstance
All Implemented Interfaces:
Serializable

public class CoreInstance
extends Object
implements Serializable

The CoreInstance is the main access point to a repository server.

A server instance is a singleton object that exists on each client JVM but also on the server JVM. The instance on the server JVM is used to access the server locally while those on client JVMs are used to access the server remotely.

A server instance uses a CoreSessionFactory to create CoreSession instances. CoreSessionFactory objects are implementation-dependent and may be registered using extension points. See CoreSessionFactory for more details.

Thus you can use a different implementation for the local ServerConnector than the one for the remote ServerConnector.

When clients need to perform a connection to a repository, they simply open a new session using the open(String, Map) method.

When the client has done its work it must close its session by calling close(CoreSession).

This ensures correctly freeing all the resources held by the client session.

So a client session looks something like this:

 <code>
 CoreInstance server = CoreInstance.getInstance();
 CoreSession client = server.open("demo", null);
 DocumentModel root = client.getRootDocument();
 // ... do something in that session ...
 // close the client -> this is closing the core session
 server.close(client);
 </code>
 

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Method Summary
 void close(CoreSession client)
           
 CoreSessionFactory getFactory()
           
static CoreInstance getInstance()
          Gets the CoreInstance singleton.
 int getNumberOfSessions()
          Returns the number of registered sessions.
 CoreSession getSession(String sid)
          Gets the client bound to the given session.
 CoreSession[] getSessions()
           
 void initialize(CoreSessionFactory factory)
           
 boolean isSessionStarted(String sid)
           
 CoreSession open(String repositoryName, Map<String,Serializable> context)
           
 void registerSession(String sid, CoreSession session)
           
 CoreSession unregisterSession(String sid)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CoreInstance getInstance()
Gets the CoreInstance singleton.

Returns:
the server instance

open

public CoreSession open(String repositoryName,
                        Map<String,Serializable> context)
                 throws ClientException
Throws:
ClientException

registerSession

public void registerSession(String sid,
                            CoreSession session)

unregisterSession

public CoreSession unregisterSession(String sid)

close

public void close(CoreSession client)

isSessionStarted

public boolean isSessionStarted(String sid)

getNumberOfSessions

public int getNumberOfSessions()
Returns the number of registered sessions.

Since:
5.4.2

getSessions

public CoreSession[] getSessions()

getSession

public CoreSession getSession(String sid)
Gets the client bound to the given session.

Parameters:
sid - the session id
Returns:
the client

initialize

public void initialize(CoreSessionFactory factory)

getFactory

public CoreSessionFactory getFactory()

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.