public class CoreInstance extends Object implements Serializable
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>
Modifier and Type | Class and Description |
---|---|
static class |
CoreInstance.RegistrationInfo |
Modifier and Type | Method and Description |
---|---|
void |
close(CoreSession client) |
CoreSessionFactory |
getFactory() |
static CoreInstance |
getInstance()
Gets the CoreInstance singleton.
|
int |
getNumberOfSessions()
Returns the number of registered sessions.
|
Collection<CoreInstance.RegistrationInfo> |
getRegistrationInfos() |
CoreSession |
getSession(String sid)
Gets the client bound to the given session.
|
CoreInstance.RegistrationInfo |
getSessionRegistrationInfo(String sid) |
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) |
public static CoreInstance getInstance()
public CoreSession open(String repositoryName, Map<String,Serializable> context) throws ClientException
ClientException
public void registerSession(String sid, CoreSession session)
public CoreSession unregisterSession(String sid)
public void close(CoreSession client)
public boolean isSessionStarted(String sid)
public int getNumberOfSessions()
public CoreSession[] getSessions()
public Collection<CoreInstance.RegistrationInfo> getRegistrationInfos()
public CoreSession getSession(String sid)
sid
- the session idpublic CoreInstance.RegistrationInfo getSessionRegistrationInfo(String sid)
public void initialize(CoreSessionFactory factory)
public CoreSessionFactory getFactory()
Copyright © 2011 Nuxeo SA. All Rights Reserved.