|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rioproject.resources.servicecore.ServiceProvider
org.rioproject.jsb.ServiceBeanAdapter
org.rioproject.bean.BeanAdapter
public class BeanAdapter
The BeanAdapter provides a basic concrete implementation of a ServiceBean, and provides the support to delegate to a component, a bean (a Plain Old Java Object : POJO), making the bean remotable as Jini technology service using the dynamic service architecture provided by Rio.
Lifecycle Support
The BeanAdapter will invoke lifecycle methods on the bean if
the bean has the following methods defined:
public void preAdvertise(); public void postAdvertise(); public void preUnAdvertise(); public void postUnAdvertise(); public void preDestroy();
Alternatively, the bean can use the Initialized, Started,
PreAdvertise, PostAdvertise, PreUnAdvertise,
PostUnAdvertise, and PreDestroy annotations to be notified of
each respective lifecycle event.
Note: ServiceBean initialization is invoked by the start method to initialize the ServiceBean. This method is called only once during the lifecycle of a ServiceBean
Properties and Context
Properties, the Configuration, the
ServiceBeanContext and the service bean itself
can be injected into the bean as well. The following methods must be
declared to have the respective properties injected into the bean:
public void setParameters(Mapparameters); public void setConfiguration(Configuration config); public void setServiceBeanContext(ServiceBeanContext context); public void setServiceBean(ServiceBean serviceBean);
Alternatively, the bean can use the SetConfiguration, SetParameters,
and SetServiceBeanContext annotations as well.
This property injection will be completed during the initialization of the
ServiceBean.
Proxy support
The bean may also define a smart proxy. In order for the BeanAdapter to obtain
the smart proxy the following method signatures must be defined:
public Object createProxy(Using the createProxy method, the method passes a remote reference to the exported back end implementation. This parameter can be declared to be the interface type your proxy implements, or a Object, which can then be narrowed to the interface type the bean implements. The method must return the bean's smart proxy, using the reference provided.);
public void setProxy(Object);If the bean has the setProxy method declared, this method will be invoked with the proxy that has been created for the bean.
Alternatively, the bean can use the CreateProxy
and SetProxy annotations
ServiceBean,
ServiceBeanAdapter| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.rioproject.jsb.ServiceBeanAdapter |
|---|
ServiceBeanAdapter.SnapshotThread |
| Field Summary |
|---|
| Fields inherited from class org.rioproject.jsb.ServiceBeanAdapter |
|---|
activationID, admin, computeResource, computeResourceObserver, context, contextMgr, joiner, jsbState, mbeanNoticationInfoList, mbeanServer, objectName, proxy, serviceBeanComponent, serviceID, slaThresholdEventAdapter, snapshotter, state, store, uuid |
| Fields inherited from class org.rioproject.resources.servicecore.ServiceProvider |
|---|
eventTable, watchRegistry |
| Constructor Summary | |
|---|---|
BeanAdapter(Object bean)
Create an instance of the BeanAdapter |
|
| Method Summary | |
|---|---|
void |
advertise()
Override the advertise method to check if the wrapped bean has a preAdvertise() or a postAdvertise() method
declared. |
protected Remote |
createDelegatingProxy()
Create the delegating proxy |
protected Object |
createProxy()
Create the Object (the proxy) to communicate with the ServiceBean. |
void |
destroy()
Override the destroy method to check if the wrapped bean has a preDestroy() method declared. |
protected Remote |
exportDo(Exporter exporter)
Override exportDo, using our delegating proxy to handle invocations |
static Object |
getCustomProxy(Object bean,
Remote remoteRef)
|
protected Exporter |
getExporter(Configuration config)
Override getExporter, creating a BeanInvocationLayerFactory for the Exporter instead of of the BasicILFactory |
void |
initialize(ServiceBeanContext context)
Override the initialize method to check if the wrapped bean has a preInitialize() method declared. |
static void |
invokeLifecycleInjectors(Object bean,
ServiceBeanContext context)
If the provided bean has the following method signatures defined, the corresponding properties will be injected into the bean: public void setParameters(Map parameters); public void setConfiguration(Configuration config); public void setServiceBeanContext(ServiceBeanContext context); Alternatively, the bean can use the SetConfiguration,
SetParameters, and SetServiceBeanContext annotations as
well. |
protected void |
registerMBean(ObjectName oName,
MBeanServer mbeanServer)
Register the service using the ObjectName to the MBeanServer |
Object |
start(ServiceBeanContext context)
Override the start method to create a delegating proxy required to navigate between the ServiceBean and the bean. |
void |
unadvertise()
Override the unadvertise method to check if the wrapped bean has a preUnAdvertise() or a postUnAdvertise() method
declared. |
| Methods inherited from class org.rioproject.resources.servicecore.ServiceProvider |
|---|
fetch, fetch, getConfiguration, getEventTable, getWatchRegistry, register, setConfiguration, setEventTable, setWatchRegistry |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BeanAdapter(Object bean)
bean - The bean, must not be null| Method Detail |
|---|
protected void registerMBean(ObjectName oName,
MBeanServer mbeanServer)
throws NotCompliantMBeanException,
MBeanRegistrationException,
InstanceAlreadyExistsException
ServiceBeanAdapter
registerMBean in class ServiceBeanAdapteroName - The ObjectName to registermbeanServer - The MBeanServer to use
NotCompliantMBeanException - If the bean is not compliant
MBeanRegistrationException - If the bean is already registered
InstanceAlreadyExistsException - If the instance already exists
public Object start(ServiceBeanContext context)
throws Exception
This method will also check if the wrapped bean has a
preStart() or a postStart() method declared.
If the wrapped bean does have an accessible preAdvertise()
declared, it will be called prior to starting the bean.
Once the bean has been started, the wrapped bean will be checked
for postStart() method declaration. If the wrapped bean
does have an accessible postStart() declared, it will be
called following the parent's start method.
start in interface ServiceBeanstart in class ServiceBeanAdaptercontext - The ServiceBeanContext
Exception - if starting the bean fails
public static void invokeLifecycleInjectors(Object bean,
ServiceBeanContext context)
public void setParameters(Map parameters); public void setConfiguration(Configuration config); public void setServiceBeanContext(ServiceBeanContext context);
Alternatively, the bean can use the SetConfiguration,
SetParameters, and SetServiceBeanContext annotations as
well.
bean - The bean to check for property injectioncontext - The ServiceBeanContext
IllegalArgumentException - if either of the parameters are null
public void initialize(ServiceBeanContext context)
throws Exception
preInitialize() method declared. If the wrapped bean
does have an accessible preInitialize() declared, it
will be called prior to initializing the bean.
Once the parent's initialize method has been invoked, if the wrapped bean has the following method signatures defined, the corresponding properties will be injected into the bean:
public void setParameters(Map parameters); public void setConfiguration(Configuration config); public void setServiceBeanContext(ServiceBeanContext context); public void setServiceBean(ServiceBean serviceBean);
Once bean initialization has been processed,
the wrapped bean will be checked for postInitialize()
method declaration. If the wrapped bean does have an accessible
postInitialize() declared, it will be called following
the parent's initialize method.
initialize in interface ServiceBeaninitialize in class ServiceBeanAdaptercontext - The ServiceBeanContext to initialize the ServiceBean with
Exception - if the initialization process fails
public void advertise()
throws IOException
preAdvertise() or a postAdvertise() method
declared. If the wrapped bean does have an accessible
preAdvertise() declared, it will be called prior to
advertising the bean.
Once bean advertisement has been processed,
the wrapped bean will be checked for postAdvertise()
method declaration. If the wrapped bean does have an accessible
postAdvertise() declared, it will be called following
the parent's advertise method.
advertise in interface ServiceBeanadvertise in interface ServiceBeanAdapterMBeanadvertise in class ServiceBeanAdapterIOException - If errors occur access underlying communication
mechanismsServiceBeanAdapterMBean.advertise()public void unadvertise()
preUnAdvertise() or a postUnAdvertise() method
declared. If the wrapped bean does have an accessible
preUnadvertise() declared, it will be called prior to
unadvertising the bean.
Once bean unadvertisement has been processed,
the wrapped bean will be checked for postUnAdvertise()
method declaration. If the wrapped bean does have an accessible
postUnAdvertise() declared, it will be called following
the parent's unadvertise method.
unadvertise in interface ServiceBeanunadvertise in interface ServiceBeanAdapterMBeanunadvertise in class ServiceBeanAdapterServiceBeanAdapterMBean.unadvertise()public void destroy()
preDestroy() method declared. If the wrapped bean does
have an accessible preDestroy() declared, it will be
called prior to destroying the bean.
destroy in interface ServiceBeanAdapterMBeandestroy in class ServiceBeanAdapterServiceBeanAdapterMBean.destroy()protected Remote createDelegatingProxy()
RuntimeException
protected Remote exportDo(Exporter exporter)
throws Exception
exportDo in class ServiceBeanAdapterexporter - The Exporter to use, must not be null
Exception - If errors occur
protected Exporter getExporter(Configuration config)
throws Exception
getExporter in class ServiceBeanAdapterconfig - The configuration to obtain
Exception - If there are errors getting the Exporterprotected Object createProxy()
ServiceBeanAdapternull or the ServiceBean has not been started. The default
semantic is to return the Remote Object created by the exporter.
If a different Object (proxy) is required, concrete implementations of
the ServiceBeanAdapter must override this method and set the desired
Object, or declare the CreateProxy
annotation or declare the "createProxy(arg)" method
createProxy in class ServiceBeanAdapter
public static Object getCustomProxy(Object bean,
Remote remoteRef)
|
Copyright © Rio Project. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||