Class NonActivatableServiceDescriptor
- All Implemented Interfaces:
ServiceDescriptor,Serializable
create(Configuration config) to launch the service in the invoking object's VM. This class provides separation of the import codebase (where the service implementation classes are loaded from) from the export codebase (where service clients should load classes from, for example stubs). as well as providing an independent security policy file for each service object. This functionality allows multiple service objects to be placed in the same VM, with each object maintaining distinct export codebase and security policy settings.
Services need to implement the following "non-activatable
constructor":
where, <impl>(String[] args,
LifeCycle lc)
A service implementation can return its service proxy (via the
LifeCycle reference. proxy field of the Created object returned by create) in the following order of precedence:
-
if the service class implements
ServiceProxyAccessorthen return value ofgetServiceProxywill be used as the service proxy. - if the service class implements
ProxyAccessorthen the return value ofgetProxywill be used as the service proxy. - Otherwise
nullwill be returned as the service proxy.
Configuring NonActivatableServiceDescriptor
information for details. This implementation obtains its configuration entries from the
Configuration object passed into the create method. The following configuration entries use
the component prefix "com.sun.jini.start":
| • |
servicePreparer | |
|---|---|---|
|   | Type: | ProxyPreparer |
|   | Default: | new
|
|   | Description: | The default proxy
preparer used to prepare the service proxy. This value should not be
null. This entry is obtained during the invocation of create and is used to prepare the service proxy returned
by the service implementation (see service proxy section for
details). This entry is superseded by explicitly passing a ProxyPreparer to
one of the constructors that accept a proxy preparer argument.
|
Loggers and Logging Levels
This implementation uses theLogger, named
com.sun.jini.start.service.starter. The following table describes the type of
information logged as well as the levels of information logged.
| Level | Description |
|---|---|
SEVERE | for significant service creation problems |
FINER | for high level service operation tracing |
FINEST | for low level service operation tracing |
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classObject returned byNonActivatableServiceDescriptor.create()method that returns the proxy and implementation references for the created service. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag indicating when create() has been calledprotected ObjectLock object fordescCreatedflag -
Constructor Summary
ConstructorsConstructorDescriptionNonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs) Convenience constructor.NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs, LifeCycle lifeCycle) Convenience constructor.NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs, LifeCycle lifeCycle, ProxyPreparer preparer) Main constructor.NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs, ProxyPreparer preparer) Convenience constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreate(Configuration config) Attempts to create a service instance based on the service description information provided via constructor parameters.final StringCodebase accessor method.static AggregatePolicyProviderfinal StringImplementation class accessor method.final StringClasspath accessor method.final LifeCycleLifeCycleaccessor method.final StringPolicy accessor method.final String[]Service configuration arguments accessor method.final ProxyPreparerProxyPrepareraccessor method.final voidSets theLifeCycleobject for this descriptor.final voidsetServicePreparer(ProxyPreparer serviceProxyPreparer) Sets theProxyPreparerfor this descriptor.toString()Prints out a field summary
-
Field Details
-
descCreated
protected transient boolean descCreatedFlag indicating when create() has been called -
descCreatedLock
Lock object fordescCreatedflag
-
-
Constructor Details
-
NonActivatableServiceDescriptor
public NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs, LifeCycle lifeCycle, ProxyPreparer preparer) Main constructor. Simply assigns given parameters to their associated, internal fields unless otherwise noted.- Parameters:
exportCodebase- location where clients can download required service-related classes (for example, stubs, proxies, etc.). Codebase components must be separated by spaces in which each component is inURLformat.policy- server policy filename or URLimportCodebase- location where server implementation classes can be found. ThisStringassumed (in order) to be either 1) a space delimited set ofURL(s) representing a codebase or 2) aFile.pathSeparatordelimited set of class paths.implClassName- name of server implementation classserverConfigArgs- service configuration arguments. This parameter is passed as theString[]argument to the implementation's constructor.lifeCycle-LifeCyclereference for hosting environment. This parameter is passed as theLifeCycleargument to the implementation's constructor. If this argument is null, then a default, no-opLifeCycleobject will be assigned.preparer-ProxyPreparerreference. This object will be used to prepare the service's proxy object, if any (see service proxy section for details). If this argument is null, then the default service preparer will be used.
-
NonActivatableServiceDescriptor
public NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs, LifeCycle lifeCycle) Convenience constructor. Equivalent to calling thiscontructorwithnullfor thepreparerreference. -
NonActivatableServiceDescriptor
public NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs) Convenience constructor. Equivalent to calling thiscontructorwithnullfor thelifeCycleandpreparerreferences. -
NonActivatableServiceDescriptor
public NonActivatableServiceDescriptor(String exportCodebase, String policy, String importCodebase, String implClassName, String[] serverConfigArgs, ProxyPreparer preparer) Convenience constructor. Equivalent to calling thiscontructorwithnullfor thelifeCyclereference.
-
-
Method Details
-
getGlobalPolicy
-
getExportCodebase
Codebase accessor method.- Returns:
- the export codebase string associated with this service descriptor.
-
getPolicy
Policy accessor method.- Returns:
- the policy string associated with this service descriptor.
-
getImportCodebase
Classpath accessor method.- Returns:
- the import codebase string associated with this service descriptor.
-
getImplClassName
Implementation class accessor method.- Returns:
- the implementation class string associated with this service descriptor.
-
getServerConfigArgs
Service configuration arguments accessor method.- Returns:
- the service configuration arguments associated with this service descriptor.
-
getLifeCycle
LifeCycleaccessor method.- Returns:
- the
LifeCycleobject associated with this service descriptor.
-
setLifeCycle
Sets theLifeCycleobject for this descriptor. This needs to be called on the service descriptor prior to callingcreate(). Useful for (re-)setting the the associatedLifeCycleupon deserialization of this descriptor.- Parameters:
lc- TheLifeCycleobject to be associated with this service descriptor.- Throws:
IllegalStateException- if called aftercreate()is invoked
-
getServicePreparer
ProxyPrepareraccessor method.- Returns:
- the
ProxyPreparerobject associated with this service descriptor.
-
setServicePreparer
Sets theProxyPreparerfor this descriptor. This needs to be called on the service descriptor prior to callingcreate(). Useful for (re-)setting the the associatedProxyPreparerupon deserialization of this descriptor.- Parameters:
serviceProxyPreparer- TheProxyPreparerobject to be associated with this service descriptor.- Throws:
IllegalStateException- if called aftercreate()is invoked
-
create
Attempts to create a service instance based on the service description information provided via constructor parameters.This method:
- installs an
RMISecurityManagerif no security manager is already in place - installs an
AggregatePolicyProvideras the VM-global policy object (upon the first invocation of this method) - creates an
ActivateWrapper.ExportClassLoaderwith the associated service's import codebase, export codebase and the current thread's context class loader as its arguments -
associates the newly created
ExportClassLoaderand the associated service's policy file with theAggregatePolicyProvider - sets the
newly created
ExportClassLoaderas the current thread's context class loader - loads the service object's class and calls a constructor with the following signature:
<impl>(String[], LifeCycle)
- obtains the service proxy by calling
ServiceProxyAccessor.getServiceProxy()orProxyAccessor.getProxy(), respectively, on the implementation instance. If neither interface is supported, the proxy reference is set tonull - resets the context class loader to the context classloader in effect when the method was called
- Specified by:
createin interfaceServiceDescriptor- Parameters:
config- TheConfigurationobject used to configure the creation of the returned object.- Returns:
- a
Createdinstance with the service's proxy and implementation references. - Throws:
Exception- Thrown if there was any problem creating the object.
- installs an
-
toString
Prints out a field summary
-