@Version("3.1.0")
Package org.apache.jackrabbit.rmi.server
This package contains the default server implementation of the transparent JCR-RMI layer. The classes in this package can be used to make a local JCR repository available as an RMI service. In addition, this package offers a straightforward mechanism for extending or modifying the behaviour of the server layer.
The contents of this package is designed using two design patterns, Factory and Adapter. All the remotely accessible ServerObject subclasses implement the Adapter pattern to adapt a local JCR interface to the corresponding remote JCR-RMI interface. The Factory pattern is used to centralize the creation and configuration of all adapter instances.
Setting up a JCR-RMI server
Setting up the server part of the JCR-RMI layer is quite straightforward. After instantiating a local JCR repository you need to wrap it into a remote adapter and create an RMI binding for the repository. A variation of the following code is usually all that is needed in addition to the standard RMI setup (starting rmiregistry, etc.):
Repository repository = ...; // The local repository String name = ...; // The RMI URL for the repository RemoteAdapterFactory factory = new ServerAdapterFactory(); RemoteRepository remote = factory.getRemoteRepository(repository); Naming.bind(name, remote); // Make the RMI binding using java.rmi.Naming
Extending the JCR-RMI server
The Factory pattern used by this package makes it easy to extend the behaviour of the JCR-RMI server. Such changes in behaviour or policy can be implemented by modifying or replacing the default ServerAdapterFactory used in the example above.
The following example code adds transparent logging of all session logins and logouts:
Repository repository = ...; // The local repository String name = ...; // The RMI URL for the repository RemoteAdapterFactory factory = new ServerAdapterFactory() { public RemoteSession getRemoteSession(Session session) throws RemoteException { System.out.println("LOGIN: " + session.getUserId()); return new ServerSession(session, this) { public void logout() { System.out.println("LOGOUT: " + session.getUserId()); super.logout(); } }; } }; RemoteRepository remote = factory.getRemoteRepository(repository); Naming.bind(name, remote); // Make the RMI binding using java.rmi.Naming
-
Interface Summary Interface Description RemoteAdapterFactory Factory interface for creating remote adapters for local resources. -
Class Summary Class Description ServerAdapterFactory Default implementation of theRemoteAdapterFactory
interface.ServerEventCollection TheServerEventCollection
class implements theRemoteEventCollection
event to actually sent the server-side event to the client.ServerEventCollection.ServerEvent Server side implementation of theRemoteEventCollection.RemoteEvent
interface.ServerItem Remote adapter for the JCRItem
interface.ServerItemDefinition Remote adapter for the JCRItemDefinition
interface.ServerLock Remote adapter for the JCRLock
interface.ServerLockManager ServerNamespaceRegistry Remote adapter for the JCRNamespaceRegistry
interface.ServerNode Remote adapter for the JCRNode
interface.ServerNodeDefinition Remote adapter for the JCRNodeDefinition
interface.ServerNodeType Remote adapter for the JCRNodeType
interface.ServerNodeTypeManager Remote adapter for the JCRNodeTypeManager
interface.ServerObject Base class for remote adapters.ServerObservationManager Remote adapter for the JCRObservationManager
interface.ServerProperty Remote adapter for the JCRProperty
interface.ServerPropertyDefinition Remote adapter for the JCRPropertyDefinition
interface.ServerQuery Remote adapter for the JCRQuery
interface.ServerQueryManager Remote adapter for the JCRQueryManager
interface.ServerQueryResult Remote adapter for the JCRQueryResult
interface.ServerRepository Remote adapter for the JCRRepository
interface.ServerRow Remote adapter for the JCRRow
interface.ServerSession Remote adapter for the JCRSession
interface.ServerVersion Remote adapter for the JCRVersion
interface.ServerVersionHistory Remote adapter for the JCRVersionHistory
interface.ServerVersionManager ServerWorkspace Remote adapter for the JCRWorkspace
interface.ServerXASession Remote adapter for XA-enabled sessions.