org.apache.jackrabbit.rmi.server
Class ServerAdapterFactory

java.lang.Object
  extended by org.apache.jackrabbit.rmi.server.ServerAdapterFactory
All Implemented Interfaces:
RemoteAdapterFactory

public class ServerAdapterFactory
extends Object
implements RemoteAdapterFactory

Default implementation of the RemoteAdapterFactory interface. This factory uses the server adapters defined in this package as the default adapter implementations. Subclasses can override or extend the default adapters by implementing the corresponding factory methods.

The bufferSize property can be used to configure the size of the buffer used by iterators to speed up iterator traversal over the network.


Constructor Summary
ServerAdapterFactory()
           
 
Method Summary
 int getBufferSize()
          Returns the iterator buffer size.
 int getPortNumber()
          Returns the port number for server objects.
 RemoteAccessControlEntry getRemoteAccessControlEntry(AccessControlEntry local)
          Returns a remote adapter for the given local access control manager.
 RemoteAccessControlEntry[] getRemoteAccessControlEntry(AccessControlEntry[] local)
          Returns a remote adapter for the given local access control manager.
 RemoteAccessControlManager getRemoteAccessControlManager(AccessControlManager acm)
          Creates a ServerAccessControlManager instance.
 RemoteAccessControlPolicy getRemoteAccessControlPolicy(AccessControlPolicy local)
          Returns a remote adapter for the given local access control manager.
 RemoteAccessControlPolicy[] getRemoteAccessControlPolicy(AccessControlPolicy[] local)
          Returns a remote adapter for the given local access control manager.
 RemoteIterator getRemoteAccessControlPolicyIterator(AccessControlPolicyIterator iterator)
          Creates a ServerNodeIterator instance.
 RemoteEventCollection getRemoteEvent(long listenerId, EventIterator events)
          Creates a ServerEventCollection instances.
 RemoteItem getRemoteItem(Item item)
          Creates a ServerItem instance.
 RemoteItemDefinition getRemoteItemDefinition(ItemDefinition def)
          Creates a ServerItemDefinition instance.
 RemoteLock getRemoteLock(Lock lock)
          Creates a ServerLock instance.
 RemoteLockManager getRemoteLockManager(LockManager lockManager)
           
 RemoteNamespaceRegistry getRemoteNamespaceRegistry(NamespaceRegistry registry)
          Creates a ServerNamespaceRegistry instance.
 RemoteNode getRemoteNode(Node node)
          Creates a ServerNode instance.
 RemoteNodeDefinition getRemoteNodeDefinition(NodeDefinition def)
          Creates a ServerNodeDefinition instance.
 RemoteIterator getRemoteNodeIterator(NodeIterator iterator)
          Creates a ServerNodeIterator instance.
 RemoteNodeType getRemoteNodeType(NodeType type)
          Creates a ServerNodeType instance.
 RemoteIterator getRemoteNodeTypeIterator(NodeTypeIterator iterator)
          Creates a ServerNodeTypeIterator instance.
 RemoteNodeTypeManager getRemoteNodeTypeManager(NodeTypeManager manager)
          Creates a ServerNodeTypeManager instance.
 RemoteObservationManager getRemoteObservationManager(ObservationManager observationManager)
          Creates a ServerObservationManager instance.
 RemotePrincipal getRemotePrincipal(Principal principal)
          Returns a remote adapter for the given local access control manager.
 RemoteIterator getRemotePrincipalIterator(Iterator<Principal> principals)
          Returns a remote adapter for the given local access control manager.
 RemotePrivilege getRemotePrivilege(Privilege local)
          Returns a remote adapter for the given local access control manager.
 RemotePrivilege[] getRemotePrivilege(Privilege[] local)
          Returns a remote adapter for the given local access control manager.
 RemoteProperty getRemoteProperty(Property property)
          Creates a ServerProperty instance.
 RemotePropertyDefinition getRemotePropertyDefinition(PropertyDefinition def)
          Creates a ServerPropertyDefinition instance.
 RemoteIterator getRemotePropertyIterator(PropertyIterator iterator)
          Creates a ServerPropertyIterator instance.
 RemoteQuery getRemoteQuery(Query query)
          Creates a ServerQuery instance.
 RemoteQueryManager getRemoteQueryManager(Session session, QueryManager manager)
          Creates a ServerQueryManager instance.
 RemoteQueryResult getRemoteQueryResult(QueryResult result)
          Creates a ServerQueryResult instance.
 RemoteRepository getRemoteRepository(Repository repository)
          Creates a ServerRepository instance.
 RemoteRow getRemoteRow(Row row)
          Creates a ServerQueryResult instance.
 RemoteIterator getRemoteRowIterator(RowIterator iterator)
          Creates a ServerRowIterator instance.
 RemoteSession getRemoteSession(Session session)
          Creates a ServerSession instance.
 RemoteVersion getRemoteVersion(Version version)
          Creates a ServerVersion instance.
 RemoteVersionHistory getRemoteVersionHistory(VersionHistory versionHistory)
          Creates a ServerVersionHistory instance.
 RemoteIterator getRemoteVersionIterator(VersionIterator iterator)
          Creates a ServerVersionIterator instance.
 RemoteVersionManager getRemoteVersionManager(VersionManager versionManager)
           
 RemoteWorkspace getRemoteWorkspace(Workspace workspace)
          Creates a ServerWorkspace instance.
protected  RemoteIterator optimizeIterator(RemoteIterator remote)
          Optimizes the given remote iterator for transmission across the network.
 void setBufferSize(int bufferSize)
          Sets the iterator buffer size.
 void setPortNumber(int portNumber)
          Sets the port number for server objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerAdapterFactory

public ServerAdapterFactory()
Method Detail

getBufferSize

public int getBufferSize()
Returns the iterator buffer size.

Returns:
iterator buffer size

setBufferSize

public void setBufferSize(int bufferSize)
Sets the iterator buffer size.

Parameters:
bufferSize - iterator buffer size

getPortNumber

public int getPortNumber()
Returns the port number for server objects.

Specified by:
getPortNumber in interface RemoteAdapterFactory
Returns:
port number, or 0 for the default

setPortNumber

public void setPortNumber(int portNumber)
Sets the port number for server objects.

Parameters:
portNumber - port number, or 0 for the default

getRemoteRepository

public RemoteRepository getRemoteRepository(Repository repository)
                                     throws RemoteException
Creates a ServerRepository instance. Returns a remote adapter for the given local repository.

Specified by:
getRemoteRepository in interface RemoteAdapterFactory
Parameters:
repository - local repository
Returns:
remote repository adapter
Throws:
RemoteException - on RMI errors

getRemoteSession

public RemoteSession getRemoteSession(Session session)
                               throws RemoteException
Creates a ServerSession instance. In case the underlying session is transaction enabled, the remote interface is will be transaction enabled too through the ServerXASession. Returns a remote adapter for the given local session.

Specified by:
getRemoteSession in interface RemoteAdapterFactory
Parameters:
session - local session
Returns:
remote session adapter
Throws:
RemoteException - on RMI errors

getRemoteWorkspace

public RemoteWorkspace getRemoteWorkspace(Workspace workspace)
                                   throws RemoteException
Creates a ServerWorkspace instance. Returns a remote adapter for the given local workspace.

Specified by:
getRemoteWorkspace in interface RemoteAdapterFactory
Parameters:
workspace - local workspace
Returns:
remote workspace adapter
Throws:
RemoteException - on RMI errors

getRemoteObservationManager

public RemoteObservationManager getRemoteObservationManager(ObservationManager observationManager)
                                                     throws RemoteException
Creates a ServerObservationManager instance. Returns a remote adapter for the given local observation manager.

Specified by:
getRemoteObservationManager in interface RemoteAdapterFactory
Parameters:
observationManager - local observation manager
Returns:
remote observation manager adapter
Throws:
RemoteException - on RMI errors

getRemoteNamespaceRegistry

public RemoteNamespaceRegistry getRemoteNamespaceRegistry(NamespaceRegistry registry)
                                                   throws RemoteException
Creates a ServerNamespaceRegistry instance. Returns a remote adapter for the given local namespace registry.

Specified by:
getRemoteNamespaceRegistry in interface RemoteAdapterFactory
Parameters:
registry - local namespace registry
Returns:
remote namespace registry adapter
Throws:
RemoteException - on RMI errors

getRemoteNodeTypeManager

public RemoteNodeTypeManager getRemoteNodeTypeManager(NodeTypeManager manager)
                                               throws RemoteException
Creates a ServerNodeTypeManager instance. Returns a remote adapter for the given local node type manager.

Specified by:
getRemoteNodeTypeManager in interface RemoteAdapterFactory
Parameters:
manager - local node type manager
Returns:
remote node type manager adapter
Throws:
RemoteException - on RMI errors

getRemoteItem

public RemoteItem getRemoteItem(Item item)
                         throws RemoteException
Creates a ServerItem instance. Returns a remote adapter for the given local item. This method will return an adapter that implements only the Item interface. The caller may want to introspect the local item to determine whether to use either the getRemoteNode or the getRemoteProperty method instead.

Specified by:
getRemoteItem in interface RemoteAdapterFactory
Parameters:
item - local item
Returns:
remote item adapter
Throws:
RemoteException - on RMI errors

getRemoteProperty

public RemoteProperty getRemoteProperty(Property property)
                                 throws RemoteException
Creates a ServerProperty instance. Returns a remote adapter for the given local property.

Specified by:
getRemoteProperty in interface RemoteAdapterFactory
Parameters:
property - local property
Returns:
remote property adapter
Throws:
RemoteException - on RMI errors

getRemoteNode

public RemoteNode getRemoteNode(Node node)
                         throws RemoteException
Creates a ServerNode instance. Returns a remote adapter for the given local node.

Specified by:
getRemoteNode in interface RemoteAdapterFactory
Parameters:
node - local node
Returns:
remote node adapter
Throws:
RemoteException - on RMI errors

getRemoteVersion

public RemoteVersion getRemoteVersion(Version version)
                               throws RemoteException
Creates a ServerVersion instance. Returns a remote adapter for the given local version.

Specified by:
getRemoteVersion in interface RemoteAdapterFactory
Parameters:
version - local version
Returns:
remote version adapter
Throws:
RemoteException - on RMI errors

getRemoteVersionHistory

public RemoteVersionHistory getRemoteVersionHistory(VersionHistory versionHistory)
                                             throws RemoteException
Creates a ServerVersionHistory instance. Returns a remote adapter for the given local version history.

Specified by:
getRemoteVersionHistory in interface RemoteAdapterFactory
Parameters:
versionHistory - local version history
Returns:
remote version history adapter
Throws:
RemoteException - on RMI errors

getRemoteNodeType

public RemoteNodeType getRemoteNodeType(NodeType type)
                                 throws RemoteException
Creates a ServerNodeType instance. Returns a remote adapter for the given local node type.

Specified by:
getRemoteNodeType in interface RemoteAdapterFactory
Parameters:
type - local node type
Returns:
remote node type adapter
Throws:
RemoteException - on RMI errors

getRemoteItemDefinition

public RemoteItemDefinition getRemoteItemDefinition(ItemDefinition def)
                                             throws RemoteException
Creates a ServerItemDefinition instance. Returns a remote adapter for the given local item definition. This method will return an adapter that implements only the ItemDefinition interface. The caller may want to introspect the local item definition to determine whether to use either the getRemoteNodeDef or the getRemotePropertyDef method instead.

Specified by:
getRemoteItemDefinition in interface RemoteAdapterFactory
Parameters:
def - local item definition
Returns:
remote item definition adapter
Throws:
RemoteException - on RMI errors

getRemoteNodeDefinition

public RemoteNodeDefinition getRemoteNodeDefinition(NodeDefinition def)
                                             throws RemoteException
Creates a ServerNodeDefinition instance. Returns a remote adapter for the given local node definition.

Specified by:
getRemoteNodeDefinition in interface RemoteAdapterFactory
Parameters:
def - local node definition
Returns:
remote node definition adapter
Throws:
RemoteException - on RMI errors

getRemotePropertyDefinition

public RemotePropertyDefinition getRemotePropertyDefinition(PropertyDefinition def)
                                                     throws RemoteException
Creates a ServerPropertyDefinition instance. Returns a remote adapter for the given local property definition.

Specified by:
getRemotePropertyDefinition in interface RemoteAdapterFactory
Parameters:
def - local property definition
Returns:
remote property definition adapter
Throws:
RemoteException - on RMI errors

getRemoteLock

public RemoteLock getRemoteLock(Lock lock)
                         throws RemoteException
Creates a ServerLock instance. Returns a remote adapter for the given local lock.

Specified by:
getRemoteLock in interface RemoteAdapterFactory
Parameters:
lock - local lock
Returns:
remote lock adapter
Throws:
RemoteException - on RMI errors

getRemoteQueryManager

public RemoteQueryManager getRemoteQueryManager(Session session,
                                                QueryManager manager)
                                         throws RemoteException
Creates a ServerQueryManager instance. Returns a remote adapter for the given local query manager.

Specified by:
getRemoteQueryManager in interface RemoteAdapterFactory
Parameters:
session - current session
manager - local query manager
Returns:
remote query manager adapter
Throws:
RemoteException - on RMI errors

getRemoteQuery

public RemoteQuery getRemoteQuery(Query query)
                           throws RemoteException
Creates a ServerQuery instance. Returns a remote adapter for the given local query.

Specified by:
getRemoteQuery in interface RemoteAdapterFactory
Parameters:
query - local query
Returns:
remote query adapter
Throws:
RemoteException - on RMI errors

getRemoteQueryResult

public RemoteQueryResult getRemoteQueryResult(QueryResult result)
                                       throws RemoteException
Creates a ServerQueryResult instance. Returns a remote adapter for the given local query result.

Specified by:
getRemoteQueryResult in interface RemoteAdapterFactory
Parameters:
result - local query result
Returns:
remote query result adapter
Throws:
RemoteException - on RMI errors

getRemoteRow

public RemoteRow getRemoteRow(Row row)
                       throws RemoteException
Creates a ServerQueryResult instance. Returns a remote adapter for the given local query row.

Specified by:
getRemoteRow in interface RemoteAdapterFactory
Parameters:
row - local query row
Returns:
remote query row adapter
Throws:
RemoteException - on RMI errors

getRemoteEvent

public RemoteEventCollection getRemoteEvent(long listenerId,
                                            EventIterator events)
                                     throws RemoteException
Creates a ServerEventCollection instances. Returns a remote adapter for the given local events.

Specified by:
getRemoteEvent in interface RemoteAdapterFactory
Parameters:
listenerId - The listener identifier to which the events are to be dispatched.
events - the local events
Returns:
remote event iterator adapter
Throws:
RemoteException - on RMI errors

optimizeIterator

protected RemoteIterator optimizeIterator(RemoteIterator remote)
                                   throws RemoteException
Optimizes the given remote iterator for transmission across the network. This method retrieves the first set of elements from the iterator by calling RemoteIterator.nextObjects() and then asks for the total size of the iterator. If the size is unkown or greater than the length of the retrieved array, then the elements, the size, and the remote iterator reference are wrapped into a BufferIterator instance that gets passed over the network. If the retrieved array of elements contains all the elements in the iterator, then the iterator instance is discarded and just the elements are wrapped into a ArrayIterator instance to be passed to the client.

Subclasses can override this method to provide alternative optimizations.

Parameters:
remote - remote iterator
Returns:
optimized remote iterator
Throws:
RemoteException - on RMI errors

getRemoteNodeIterator

public RemoteIterator getRemoteNodeIterator(NodeIterator iterator)
                                     throws RemoteException
Creates a ServerNodeIterator instance. Returns a remote adapter for the given local node iterator.

Specified by:
getRemoteNodeIterator in interface RemoteAdapterFactory
Parameters:
iterator - local node iterator
Returns:
remote iterator adapter
Throws:
RemoteException - on RMI errors

getRemotePropertyIterator

public RemoteIterator getRemotePropertyIterator(PropertyIterator iterator)
                                         throws RemoteException
Creates a ServerPropertyIterator instance. Returns a remote adapter for the given local property iterator.

Specified by:
getRemotePropertyIterator in interface RemoteAdapterFactory
Parameters:
iterator - local property iterator
Returns:
remote iterator adapter
Throws:
RemoteException - on RMI errors

getRemoteVersionIterator

public RemoteIterator getRemoteVersionIterator(VersionIterator iterator)
                                        throws RemoteException
Creates a ServerVersionIterator instance. Returns a remote adapter for the given local version iterator.

Specified by:
getRemoteVersionIterator in interface RemoteAdapterFactory
Parameters:
iterator - local version iterator
Returns:
remote iterator adapter
Throws:
RemoteException - on RMI errors

getRemoteNodeTypeIterator

public RemoteIterator getRemoteNodeTypeIterator(NodeTypeIterator iterator)
                                         throws RemoteException
Creates a ServerNodeTypeIterator instance. Returns a remote adapter for the given local node type iterator.

Specified by:
getRemoteNodeTypeIterator in interface RemoteAdapterFactory
Parameters:
iterator - local node type iterator
Returns:
remote iterator adapter
Throws:
RemoteException - on RMI errors

getRemoteRowIterator

public RemoteIterator getRemoteRowIterator(RowIterator iterator)
                                    throws RemoteException
Creates a ServerRowIterator instance. Returns a remote adapter for the given local row iterator.

Specified by:
getRemoteRowIterator in interface RemoteAdapterFactory
Parameters:
iterator - local row iterator
Returns:
remote iterator adapter
Throws:
RemoteException - on RMI errors

getRemoteLockManager

public RemoteLockManager getRemoteLockManager(LockManager lockManager)
                                       throws RemoteException
Specified by:
getRemoteLockManager in interface RemoteAdapterFactory
Throws:
RemoteException

getRemoteVersionManager

public RemoteVersionManager getRemoteVersionManager(VersionManager versionManager)
                                             throws RemoteException
Specified by:
getRemoteVersionManager in interface RemoteAdapterFactory
Throws:
RemoteException

getRemoteAccessControlManager

public RemoteAccessControlManager getRemoteAccessControlManager(AccessControlManager acm)
                                                         throws RemoteException
Creates a ServerAccessControlManager instance. Returns a remote adapter for the given local access control manager.

Specified by:
getRemoteAccessControlManager in interface RemoteAdapterFactory
Parameters:
acm - local access control manager
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemotePrivilege

public RemotePrivilege getRemotePrivilege(Privilege local)
                                   throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemotePrivilege in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemotePrivilege

public RemotePrivilege[] getRemotePrivilege(Privilege[] local)
                                     throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemotePrivilege in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemoteAccessControlPolicy

public RemoteAccessControlPolicy getRemoteAccessControlPolicy(AccessControlPolicy local)
                                                       throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemoteAccessControlPolicy in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemoteAccessControlPolicy

public RemoteAccessControlPolicy[] getRemoteAccessControlPolicy(AccessControlPolicy[] local)
                                                         throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemoteAccessControlPolicy in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemoteAccessControlPolicyIterator

public RemoteIterator getRemoteAccessControlPolicyIterator(AccessControlPolicyIterator iterator)
                                                    throws RemoteException
Creates a ServerNodeIterator instance. Returns a remote adapter for the given local access control manager.

Specified by:
getRemoteAccessControlPolicyIterator in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemoteAccessControlEntry

public RemoteAccessControlEntry getRemoteAccessControlEntry(AccessControlEntry local)
                                                     throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemoteAccessControlEntry in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemoteAccessControlEntry

public RemoteAccessControlEntry[] getRemoteAccessControlEntry(AccessControlEntry[] local)
                                                       throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemoteAccessControlEntry in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemotePrincipal

public RemotePrincipal getRemotePrincipal(Principal principal)
                                   throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemotePrincipal in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors

getRemotePrincipalIterator

public RemoteIterator getRemotePrincipalIterator(Iterator<Principal> principals)
                                          throws RemoteException
Description copied from interface: RemoteAdapterFactory
Returns a remote adapter for the given local access control manager.

Specified by:
getRemotePrincipalIterator in interface RemoteAdapterFactory
Returns:
remote access control manager
Throws:
RemoteException - on RMI errors


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.