net.jini.jeri
Class BasicILFactory

java.lang.Object
  extended by net.jini.jeri.AbstractILFactory
      extended by net.jini.jeri.BasicILFactory
All Implemented Interfaces:
InvocationLayerFactory
Direct Known Subclasses:
AccessILFactory, ProxyTrustILFactory, SystemAccessILFactory

public class BasicILFactory
extends AbstractILFactory

A basic implementation of an InvocationLayerFactory. This factory is used to create a Proxy instance with a BasicInvocationHandler and to create a BasicInvocationDispatcher for a remote object being exported. This factory is used in conjunction with the BasicJeriExporter class.

Since:
2.0
Author:
Sun Microsystems, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.jini.jeri.InvocationLayerFactory
InvocationLayerFactory.Instances
 
Constructor Summary
BasicILFactory()
          Creates a BasicILFactory instance with no server constraints, no permission class, and a null class loader.
BasicILFactory(MethodConstraints serverConstraints, Class permissionClass)
          Creates a BasicILFactory with the specified server constraints, permission class, and a null class loader.
BasicILFactory(MethodConstraints serverConstraints, Class permissionClass, ClassLoader loader)
          Creates a BasicILFactory with the specified server constraints, permission class, and class loader.
 
Method Summary
protected  InvocationDispatcher createInvocationDispatcher(Collection methods, Remote impl, ServerCapabilities caps)
          Returns an invocation dispatcher to receive incoming remote calls for the specified methods to the specified remote object, for a server and transport with the specified capabilities.
protected  InvocationHandler createInvocationHandler(Class[] interfaces, Remote impl, ObjectEndpoint oe)
          Returns an invocation handler to use with a Proxy instance implementing the specified interfaces, communicating with the specified remote object using the specified object endpoint.
 boolean equals(Object obj)
          Compares the specified object with this invocation layer factory for equality.
protected  Class[] getExtraProxyInterfaces(Remote impl)
          Returns a new array containing any additional interfaces that the proxy should implement, beyond the interfaces obtained by passing impl to the getRemoteInterfaces method.
 Class getPermissionClass()
          Returns the permission class, if any.
 MethodConstraints getServerConstraints()
          Returns the server constraints, if any.
 int hashCode()
          Returns a hash code value for this factory.
 String toString()
          Returns a string representation of this factory.
 
Methods inherited from class net.jini.jeri.AbstractILFactory
createInstances, getClassLoader, getInvocationDispatcherMethods, getProxyInterfaces, getRemoteInterfaces
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicILFactory

public BasicILFactory()
Creates a BasicILFactory instance with no server constraints, no permission class, and a null class loader.


BasicILFactory

public BasicILFactory(MethodConstraints serverConstraints,
                      Class permissionClass)
Creates a BasicILFactory with the specified server constraints, permission class, and a null class loader.

Parameters:
serverConstraints - the server constraints, or null
permissionClass - the permission class, or null
Throws:
IllegalArgumentException - if the permission class is abstract, is not a subclass of Permission, or does not have a public constructor that has either one String parameter or one Method parameter and has no declared exceptions

BasicILFactory

public BasicILFactory(MethodConstraints serverConstraints,
                      Class permissionClass,
                      ClassLoader loader)
Creates a BasicILFactory with the specified server constraints, permission class, and class loader. The server constraints, if not null, are used to enforce minimum constraints for remote calls. The permission class, if not null, is used to perform server-side access control on incoming remote calls. The class loader, which may be null, is passed to the superclass constructor and is used by the createInstances method.

Parameters:
serverConstraints - the server constraints, or null
permissionClass - the permission class, or null
loader - the class loader, or null
Throws:
IllegalArgumentException - if the permission class is abstract, is not a subclass of Permission, or does not have a public constructor that has either one String parameter or one Method parameter and has no declared exceptions
Method Detail

createInvocationHandler

protected InvocationHandler createInvocationHandler(Class[] interfaces,
                                                    Remote impl,
                                                    ObjectEndpoint oe)
                                             throws ExportException
Returns an invocation handler to use with a Proxy instance implementing the specified interfaces, communicating with the specified remote object using the specified object endpoint.

BasicILFactory implements this method to return a BasicInvocationHandler constructed with the specified object endpoint and this factory's server constraints.

Specified by:
createInvocationHandler in class AbstractILFactory
Parameters:
interfaces - an array of proxy interfaces
impl - a remote object this invocation handler is being created for
oe - an object endpoint used to communicate with the remote object
Returns:
the invocation handler for the remote object's proxy
Throws:
NullPointerException - if any argument is null, or if interfaces contains a null element
ExportException - if there is a problem creating the invocation handler

getExtraProxyInterfaces

protected Class[] getExtraProxyInterfaces(Remote impl)
Returns a new array containing any additional interfaces that the proxy should implement, beyond the interfaces obtained by passing impl to the getRemoteInterfaces method.

BasicILFactory implements this method to return a new array containing the RemoteMethodControl and TrustEquivalence interfaces, in that order.

Overrides:
getExtraProxyInterfaces in class AbstractILFactory
Parameters:
impl - the remote object
Returns:
the extra proxy interfaces
Throws:
NullPointerException - if impl is null

createInvocationDispatcher

protected InvocationDispatcher createInvocationDispatcher(Collection methods,
                                                          Remote impl,
                                                          ServerCapabilities caps)
                                                   throws ExportException
Returns an invocation dispatcher to receive incoming remote calls for the specified methods to the specified remote object, for a server and transport with the specified capabilities.

BasicILFactory implements this method to return a BasicInvocationDispatcher instance constructed with the specified methods, server capabilities, and this factory's server constraints, permission class, and class loader specified at construction.

Specified by:
createInvocationDispatcher in class AbstractILFactory
Parameters:
methods - a collection of Method instances for the remote methods
impl - a remote object that the dispatcher is being created for
caps - the transport capabilities of the server
Returns:
the invocation dispatcher for the remote object
Throws:
NullPointerException - if any argument is null, or if methods contains a null element
IllegalArgumentException - if methods contains an element that is not a Method instance
ExportException - if there is a problem creating the dispatcher

getServerConstraints

public final MethodConstraints getServerConstraints()
Returns the server constraints, if any.

Returns:
the server constraints, or null

getPermissionClass

public final Class getPermissionClass()
Returns the permission class, if any.

Returns:
the permission class, or null

hashCode

public int hashCode()
Returns a hash code value for this factory.

Overrides:
hashCode in class AbstractILFactory

equals

public boolean equals(Object obj)
Compares the specified object with this invocation layer factory for equality.

BasicILFactory implements this method to return true if and only if invoking the superclass's equals method passing the specified object returns true, the specified object has the same class as this object, and the server constraints and permission class are equal to the ones in this object.

Overrides:
equals in class AbstractILFactory

toString

public String toString()
Returns a string representation of this factory.

Overrides:
toString in class AbstractILFactory


Copyright 2007, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.