Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jini.rio.bean
Class BeanAdapter

    java.lang.Object
      org.jini.rio.resources.servicecore.ServiceProvider
          org.jini.rio.jsb.ServiceBeanAdapter
              org.jini.rio.bean.BeanAdapter

All Implemented Interfaces:
  ServiceProxyAccessor, Remote, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, Administrable, ProxyAccessor, ServerProxyTrust, ServiceBean, MonitorableService, EventProducer, ServiceBeanAdapterMBean, Service, Watchable

    public class BeanAdapter

extends ServiceBeanAdapter

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 preInitialize();
     public void postInitialize();
     public void preStart();
     public void postStart();
     public void preAdvertise();
     public void postAdvertise();
     public void preDestroy();

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 methids must be declared to have the respctive properties injected into the bean:

     public void setParameters(Map parameters);
     public void setConfiguration(Configuration config);
     public void setServiceBeanContext(ServiceBeanContext context);
     public void setServiceBean(Object serviceBean);

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 decared, 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

See Also:
  `ServiceBean`, `ServiceBeanAdapter`

Nested Class Summary

Nested classes/interfaces inherited from class org.jini.rio.jsb.ServiceBeanAdapter
`ServiceBeanAdapter.SnapshotThread`

Field Summary

Fields inherited from class org.jini.rio.jsb.ServiceBeanAdapter
`activationID, admin, computeResource, computeResourceObserver, context, contextMgr, joiner, jsbState, logDirName, mbeanNoticationInfoList, mbeanServer, objectName, proxy, serviceBeanComponent, serviceID, slaThresholdEventAdapter, snapshotter, state, store, uuid`

Fields inherited from class org.jini.rio.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
`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()` or a `postInitialize()` method declared.
`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.jini.rio.jsb.ServiceBeanAdapter
`addAttribute, addAttributes, addNotificationListener, cleanJMX, createObjectName, destroy, destroyWatches, getAdmin, getAdminExporter, getAssociationManagement, getAssociations, getComputeResourceObserver, getDiscoveryManager, getExportedProxy, getJoinManager, getLookupGroups, getNotificationBroadcasterSupport, getNotificationInfo, getProxy, getProxyVerifier, getServiceBeanContext, getServiceBeanInstantiatorUuid, getServiceProxy, getSLAEventHandler, getStarted, getStartTime, getUuid, getWatchUI, initialize, initializeJMX, monitor, ping, postDeregister, postRegister, preDeregister, preRegister, removeNotificationListener, removeNotificationListener, setLookupGroups, startHeartbeat, stop`

Methods inherited from class org.jini.rio.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

### BeanAdapter

    public BeanAdapter(Object bean)

  Create an instance of the BeanAdapter

  Parameters:
    `bean` - The bean, must not be null

Method Detail

### registerMBean

    protected void registerMBean(ObjectName oName,
                                 MBeanServer mbeanServer)
                          throws NotCompliantMBeanException,
                                 MBeanRegistrationException,
                                 InstanceAlreadyExistsException

  Description copied from class: `ServiceBeanAdapter`
  Register the service using the ObjectName to the MBeanServer

  Overrides:
    `registerMBean` in class `ServiceBeanAdapter`
  Parameters:
    `oName` - The ObjectNae to register
    `mbeanServer` - The MBeanServer to use
  Throws:
    `NotCompliantMBeanException` - If the bean is not compliant
    `MBeanRegistrationException` - If the bean is already registered
    `InstanceAlreadyExistsException` - If the instance already exists

### start

    public Object start(ServiceBeanContext context)
                 throws Exception

  Override the start method to create a delegating proxy required to navigate between the ServiceBean and the bean.

  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.

  Specified by:
    `start` in interface `ServiceBean`
  Overrides:
    `start` in class `ServiceBeanAdapter`
  Parameters:
    `context` - The ServiceBeanContext
  Returns:
    A remoted proxy used to communicate to the bean
  Throws:
    `Exception` - if starting the bean fails

### initialize

    public void initialize(ServiceBeanContext context)
                    throws Exception

  Override the initialize method to check if the wrapped bean has a `preInitialize()` or a `postInitialize()` 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(Object 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.

  Specified by:
    `initialize` in interface `ServiceBean`
  Overrides:
    `initialize` in class `ServiceBeanAdapter`
  Parameters:
    `context` - The ServiceBeanContext to intialize the ServiceBean with
  Throws:
    `Exception` - if the initialization process fails

### advertise

    public void advertise()
                   throws IOException

  Override the advertise method to check if the wrapped bean has a `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.

  Specified by:
    `advertise` in interface `ServiceBean`
  Specified by:
    `advertise` in interface `ServiceBeanAdapterMBean`
  Overrides:
    `advertise` in class `ServiceBeanAdapter`
  Throws:
    `IOException` - If errors occur access underlying communication mechanisms
  See Also:
    `ServiceBeanAdapterMBean.advertise()`

### unadvertise

    public void unadvertise()

  Override the unadvertise method to check if the wrapped bean has a `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.

  Specified by:
    `unadvertise` in interface `ServiceBean`
  Specified by:
    `unadvertise` in interface `ServiceBeanAdapterMBean`
  Overrides:
    `unadvertise` in class `ServiceBeanAdapter`
  See Also:
    `ServiceBeanAdapterMBean.unadvertise()`

### destroy

    public void destroy()

  Override the destroy method to check if the wrapped bean has a `preDestroy()` method declared. If the wrapped bean does have an accessible `preDestroy()` declared, it will be called prior to destroying the bean.

  Specified by:
    `destroy` in interface `ServiceBeanAdapterMBean`
  Overrides:
    `destroy` in class `ServiceBeanAdapter`
  See Also:
    `ServiceBeanAdapterMBean.destroy()`

### createDelegatingProxy

    protected Remote createDelegatingProxy()

  Create the delegating proxy

  Returns:
    The proxy that will handle the delegation between the ServiceBean and the Bean (POJO)
  Throws:
    `RuntimeException`

### exportDo

    protected Remote exportDo(Exporter exporter)
                       throws Exception

  Override exportDo, using our delegating proxy to handle invocations

  Overrides:
    `exportDo` in class `ServiceBeanAdapter`
  Parameters:
    `exporter` - The Exporter to use, must not be null
  Returns:
    Remote The remote object used to accept incoming calls
  Throws:
    `Exception` - If errors occur

### getExporter

    protected Exporter getExporter(Configuration config)
                            throws Exception

  Override getExporter, creating a BeanInvocationLayerFactory for the Exporter instead of of the BasicILFactory

  Overrides:
    `getExporter` in class `ServiceBeanAdapter`
  Parameters:
    `config` - The configuration to obtain
  Returns:
    An Exporter which can be used to export the service. If no Exporter has been configured, a new BasicJeriExporter with
    - A TcpServerEndpoint created on a random port,
    - a BasicILFactory,
    - distributed garbage collection turned off,
    - keep alive on.
    If activatable, the same default will be used but wrapped in an ActivationExporter and created with the service's ActivationID
  Throws:
    `Exception` - If there are errors getting the Exporter

### createProxy

    protected Object createProxy()

  Description copied from class: `ServiceBeanAdapter`
  Create the Object (the proxy) to communicate with the ServiceBean. This method is called by the getServiceProxy() method if the proxy is `null` 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

  Overrides:
    `createProxy` in class `ServiceBeanAdapter`
  Returns:
    The proxy to use

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Project Rio.