com.bea.adapter.spi
Class AbstractWLIResourceAdapter

java.lang.Object
  extended bycom.bea.adapter.spi.AbstractWLIResourceAdapter
All Implemented Interfaces:
ResourceAdapter, WLIResourceAdapter

public abstract class AbstractWLIResourceAdapter
extends Object
implements WLIResourceAdapter

Abstract Resource Adapter class that encapsulates the generic functionality across all adapters


Constructor Summary
protected AbstractWLIResourceAdapter()
          Constructs a resource adapter instance.
 
Method Summary
 void addAdapterStatusListener(AdapterStatusListener listener)
          Add a new AdapterStatusListener.
 void addConnectionFactory(String name, javax.resource.cci.ConnectionFactory factory)
          Add a ConnectionFactory with the given name into this ResourceAdapter
protected  void checkAndPutProperty(String name, Object value)
           
 void endpointActivation(MessageEndpointFactory mef, ActivationSpec as)
          Add a new subscription for inbound messages to this adapter instance.
 void endpointDeactivation(MessageEndpointFactory mef, ActivationSpec as)
          Remove a subscription for inbound messages that was previously given to this adapter instance.
 String getAdapterDescription()
          The description for the adapter.
 String getAdapterEisType()
          The type name of the EIS this adapter was built to communicate with.
 String getAdapterName()
          The display name for the adapter.
 String getAdapterVendorName()
          The vendor name for the adapter Basic adapter metadata; these come from a resource bundle, or the subclass implementation.
 String getAdapterVersion()
          The version for the adapter Basic adapter metadata; these come from a resource bundle, or the subclass implementation.
 String getAdditionalLogContext()
           
 javax.resource.cci.ConnectionFactory getConnectionFactory(String name)
          Get the ConnectionFactory instance with the given name, which is being managed for this ResourceAdapter instance.
 Status getConnectionFactoryStatus(String name)
          Get the status of a ConnectionFactory with the given name being managed by this adapter instance.
 String getCountryCode()
           
 String getEventGeneratorClassName()
           
 String getGUID()
          Gets the ID of this adapter instance, or null if none has been given.
 String[] getInboundMessagingInstanceIDs()
          Get the array of logical inbound messaging instance identifiers for this adapter instance, or null if none have been set.
 Status getInboundMessagingStatus()
          Get the status of the inbound section of this adapter instance.
 String getLanguageCode()
           
 String getLogConfigFile()
           
protected  LogContext getLogContext()
          Retrieves an object that determines the logging configuration for this instance in the logging framework.
protected  ILogger getLogger()
          Retrieves an object used to log information to.
 String getLogLevel()
           
 String getMessageBundleBase()
           
 String getName()
          Gets the name of this adapter instance, or null if none has been given.
 String getRootLogContext()
           
 XAResource[] getXAResources(ActivationSpec[] specs)
           
protected  void initAdapterMetaData(ResourceBundle resourceBundle)
          Retrieves metadata about the resource adapter from a message bundle.
protected  void initializeLogResources()
          Initializes resources needed by this instance to support localized logging after all base member variables have been initialized correctly by the application server.
protected  void internalValidate()
          Internal validation routine to sanity check the current properties/config of this object.
 boolean isInboundMessagingEnabled()
          Indicates if this adapter instance is configured to handle inbound messaging.
 boolean isValidState()
          Indicates whether this WLIResourceAdapter instance has been configured with valid property information and has successfully executed the validate() method.
 Iterator listConnectionFactoryNames()
          List the names of the ConnectionFactories being managed for this ResourceAdapter instance.
protected  void logInfo()
          Writes information about 'this' instance to the underlying logger as a info message.
 void refreshInboundMessaging()
          Set, after a call to start, whether this adapter instance should have its inbound messaging section active or not.
 void removeAdapterStatusListener(AdapterStatusListener listener)
          Remove an existing AdapterStatusListener
 javax.resource.cci.ConnectionFactory removeConnectionFactory(String name)
          Remove a ConnectionFactory with the given name from this ResourceAdapter.
 void resumeInboundMessaging()
          Resume inbound messaging.
protected  void setAdapterDescription(String desc)
          Set the adapter description (should be what you would use for description in wli-ra.xml).
protected  void setAdapterEisType(String type)
          Set the adapter EIS type (should be what you would use for eis-type in wli-ra.xml)
protected  void setAdapterName(String name)
          Set adapter name (should be what you would use for display-name in wli-ra.xml).
protected  void setAdapterVendorName(String vendor)
          Set the adapter vendor name (should be what you would use for vendor-name in wli-ra.xml)
protected  void setAdapterVersion(String version)
          Set the adapter version (should be what you would use for resourceadapter-version in wli-ra.xml)
 void setAdditionalLogContext(String strAdditionalLogContext)
          Sets additional context information for identifying logging configuration.
 void setCountryCode(String countryCode)
           
 void setEventGeneratorClassName(String eventGeneratorClassName)
           
 void setGUID(String guid)
          Sets the globally unique ID of this adapter instance.
 void setInboundMessagingEnabled(boolean newValue)
          Set whether this adapter instance is configured to handle inbound messaging or not.
 void setInboundMessagingInstanceIDs(String[] instanceIDs)
          Set an array of logical inbound messaging instance identifiers for this adapter instance.
 void setInboundMessagingStatus(Status status)
          Change this adapter's status.
 void setLanguageCode(String languageCode)
           
 void setLogConfigFile(String logConfigFile)
           
 void setLogLevel(String strLogLevel)
          Sets the log priority level for 'this' instance.
 void setMessageBundleBase(String messageBundleBase)
           
 void setName(String name)
          Sets the logical name of this adapter instance.
protected  void setResourceAdapterProperties()
          Add standard properties required for all resource adapters
 void setRootLogContext(String strRootLogContext)
          Sets the root log context for this factory.
protected  void setStandardResourceAdapterProperties()
           
 void start(BootstrapContext bc)
          Starts a resource adapter instance.
protected  void startInboundMessaging()
          Start the inbound messaging section of this adapter instance.
 void stop()
          Stops a resource adapter instance.
protected  void stopInboundMessaging()
          Stop the inbound messaging section of this adapter instance.
 boolean supportsSuspendInboundMessaging()
          Indicate whether this ResourceAdapter can suspend its inbound messaging section.
 void suspendInboundMessaging()
          Suspend the inbound messaging section for this ResourceAdapter instance.
 void validate()
          Called by the client that is configuring an instance of this WLIResourceAdapter class after all the JavaBeans properties have been set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractWLIResourceAdapter

protected AbstractWLIResourceAdapter()
                              throws javax.resource.ResourceException
Constructs a resource adapter instance. Adapter developers should subclass this class and do the following:

Throws:
javax.resource.ResourceException - - an exceptional condition was encountered while attempting to initialize the resource adapter possibly due to an invalid license, or missing class file.
Method Detail

setName

public void setName(String name)
Sets the logical name of this adapter instance. This name represents the set of configuration that defines the adapter instance. This adapter instance can actually be instantiated on multiple servers, and each would share the same name.

Specified by:
setName in interface WLIResourceAdapter

getName

public String getName()
Gets the name of this adapter instance, or null if none has been given.

Specified by:
getName in interface WLIResourceAdapter

setGUID

public void setGUID(String guid)
Sets the globally unique ID of this adapter instance.

Specified by:
setGUID in interface WLIResourceAdapter

getGUID

public String getGUID()
Gets the ID of this adapter instance, or null if none has been given.

Specified by:
getGUID in interface WLIResourceAdapter

getAdapterName

public String getAdapterName()
The display name for the adapter. Basic adapter metadata; these come from a resource bundle, or the subclass implementation.


setAdapterName

protected void setAdapterName(String name)
Set adapter name (should be what you would use for display-name in wli-ra.xml).


getAdapterDescription

public String getAdapterDescription()
The description for the adapter. Basic adapter metadata; these come from a resource bundle, or the subclass implementation.


setAdapterDescription

protected void setAdapterDescription(String desc)
Set the adapter description (should be what you would use for description in wli-ra.xml).


getAdapterVendorName

public String getAdapterVendorName()
The vendor name for the adapter Basic adapter metadata; these come from a resource bundle, or the subclass implementation.


setAdapterVendorName

protected void setAdapterVendorName(String vendor)
Set the adapter vendor name (should be what you would use for vendor-name in wli-ra.xml)


getAdapterVersion

public String getAdapterVersion()
The version for the adapter Basic adapter metadata; these come from a resource bundle, or the subclass implementation.


setAdapterVersion

protected void setAdapterVersion(String version)
Set the adapter version (should be what you would use for resourceadapter-version in wli-ra.xml)


getAdapterEisType

public String getAdapterEisType()
The type name of the EIS this adapter was built to communicate with. Basic adapter metadata; these come from a resource bundle, or the subclass implementation.


setAdapterEisType

protected void setAdapterEisType(String type)
Set the adapter EIS type (should be what you would use for eis-type in wli-ra.xml)


setInboundMessagingInstanceIDs

public void setInboundMessagingInstanceIDs(String[] instanceIDs)
Set an array of logical inbound messaging instance identifiers for this adapter instance. The use or definition of these identifiers is adapter specific. However, these are intended to identify a logical instance for inbound messages. This instance can be moved around between servers. For example, a single adapter instance might have n inbound messaging instance IDs, and in a nominal cluster configuration each is assigned to a single adapter instance on a single server in the cluster. In failure situations, however, the instance IDs for the failed server could be associated with a different adapter instance on a different (live) server to cause inbound messages destined for the instance id to be processed on the live server.

Specified by:
setInboundMessagingInstanceIDs in interface WLIResourceAdapter

getInboundMessagingInstanceIDs

public String[] getInboundMessagingInstanceIDs()
Get the array of logical inbound messaging instance identifiers for this adapter instance, or null if none have been set.

Specified by:
getInboundMessagingInstanceIDs in interface WLIResourceAdapter

validate

public void validate()
              throws javax.resource.ResourceException
Called by the client that is configuring an instance of this WLIResourceAdapter class after all the JavaBeans properties have been set. This method provides an opportunity to control the procedural initialization of a WLIResourceAdapter instance with knowledge that the full property set has been set on the instance.
The ADK implementation of this method has effect only on the first call, and thereafter simply returns if a successful call to validate has already been made. This method calls internalValidate which can be overridden by subclasses to provide adapter-specific property checking. It then populates the property bundle with all properties set on the adapter instance to this point.

Specified by:
validate in interface WLIResourceAdapter
Throws:
javax.resource.ResourceException

isValidState

public boolean isValidState()
Indicates whether this WLIResourceAdapter instance has been configured with valid property information and has successfully executed the validate() method. Note that if this method returns false, it is not safe to call anything other than a property setter/getter method. In particular it is not safe to call any of the logging methods on this object.


internalValidate

protected void internalValidate()
                         throws javax.resource.ResourceException
Internal validation routine to sanity check the current properties/config of this object. Subclasses may override this method to perform their own property checking logic. The ADK implementation of this method does nothing.

Throws:
javax.resource.ResourceException

start

public void start(BootstrapContext bc)
           throws javax.resource.spi.ResourceAdapterInternalException
Starts a resource adapter instance. This method ensures there is a valid license in the runtime environment. If the isInboundMessagingEnabled() method returns true, this call will also start the inbound messaging section of this adapter instance.

Specified by:
start in interface ResourceAdapter
Throws:
javax.resource.spi.ResourceAdapterInternalException - - an exceptional condition was encountered while attempting to start the resource adapter instance;

startInboundMessaging

protected void startInboundMessaging()
                              throws javax.resource.spi.ResourceAdapterInternalException
Start the inbound messaging section of this adapter instance. This is only called when isInboundMessagingEnabled() returns true.

Throws:
javax.resource.spi.ResourceAdapterInternalException

stopInboundMessaging

protected void stopInboundMessaging()
                             throws javax.resource.spi.ResourceAdapterInternalException
Stop the inbound messaging section of this adapter instance.

Throws:
javax.resource.spi.ResourceAdapterInternalException

stop

public void stop()
          throws javax.resource.ResourceException
Stops a resource adapter instance.

Specified by:
stop in interface ResourceAdapter
Throws:
javax.resource.ResourceException

endpointActivation

public void endpointActivation(MessageEndpointFactory mef,
                               ActivationSpec as)
                        throws javax.resource.NotSupportedException
Add a new subscription for inbound messages to this adapter instance. If isInboundMessaging() returns false, this method will throw NotSupportedException.

Specified by:
endpointActivation in interface ResourceAdapter
Throws:
javax.resource.NotSupportedException

endpointDeactivation

public void endpointDeactivation(MessageEndpointFactory mef,
                                 ActivationSpec as)
Remove a subscription for inbound messages that was previously given to this adapter instance.

Specified by:
endpointDeactivation in interface ResourceAdapter

getXAResources

public XAResource[] getXAResources(ActivationSpec[] specs)
                            throws javax.resource.ResourceException
Specified by:
getXAResources in interface ResourceAdapter
Throws:
javax.resource.ResourceException

getConnectionFactory

public javax.resource.cci.ConnectionFactory getConnectionFactory(String name)
Get the ConnectionFactory instance with the given name, which is being managed for this ResourceAdapter instance. If no ConnectionFactory instance with the given name was created from within the current ResourceAdapter instance, this method returns null.

Specified by:
getConnectionFactory in interface WLIResourceAdapter

addConnectionFactory

public void addConnectionFactory(String name,
                                 javax.resource.cci.ConnectionFactory factory)
Add a ConnectionFactory with the given name into this ResourceAdapter

Specified by:
addConnectionFactory in interface WLIResourceAdapter

removeConnectionFactory

public javax.resource.cci.ConnectionFactory removeConnectionFactory(String name)
Remove a ConnectionFactory with the given name from this ResourceAdapter.

Specified by:
removeConnectionFactory in interface WLIResourceAdapter

listConnectionFactoryNames

public Iterator listConnectionFactoryNames()
List the names of the ConnectionFactories being managed for this ResourceAdapter instance.

Specified by:
listConnectionFactoryNames in interface WLIResourceAdapter

isInboundMessagingEnabled

public boolean isInboundMessagingEnabled()
Indicates if this adapter instance is configured to handle inbound messaging. Not all instances will be given the configuration needed to do this, so inbound messaging will be initialized only for those adapter instances that return true from this method.

Specified by:
isInboundMessagingEnabled in interface WLIResourceAdapter

setInboundMessagingEnabled

public void setInboundMessagingEnabled(boolean newValue)
Set whether this adapter instance is configured to handle inbound messaging or not. Not all instances will be given the configuration needed to do this, so inbound messaging should be enabled only for those adapter instances that are given the proper configuration. Note, a call to this method has no immediate effect for a WLIResourceAdapter that has already had its 'start()' method called. The caller must also call refreshInboundMessaging() in this case.

Specified by:
setInboundMessagingEnabled in interface WLIResourceAdapter

refreshInboundMessaging

public void refreshInboundMessaging()
                             throws javax.resource.ResourceException
Set, after a call to start, whether this adapter instance should have its inbound messaging section active or not. This call can result in the inbound messaging changing state to match the desired state.

Specified by:
refreshInboundMessaging in interface WLIResourceAdapter
Throws:
javax.resource.ResourceException

supportsSuspendInboundMessaging

public boolean supportsSuspendInboundMessaging()
Indicate whether this ResourceAdapter can suspend its inbound messaging section. This means that when suspended, the ResourceAdapter will store any inbound messages (either on the EIS or internally) reliably until it is resumed.

Specified by:
supportsSuspendInboundMessaging in interface WLIResourceAdapter

suspendInboundMessaging

public void suspendInboundMessaging()
                             throws javax.resource.NotSupportedException,
                                    javax.resource.ResourceException
Suspend the inbound messaging section for this ResourceAdapter instance. All inbound messages must be reliably stored (either on the EIS or internally) until this instance is resumed.

Specified by:
suspendInboundMessaging in interface WLIResourceAdapter
Throws:
javax.resource.NotSupportedException
javax.resource.ResourceException

resumeInboundMessaging

public void resumeInboundMessaging()
                            throws javax.resource.NotSupportedException,
                                   javax.resource.ResourceException
Resume inbound messaging. Any messages that were accepted by this ResourceAdapter instance (either on the EIS or internally) should now be delivered to endpoints.

Specified by:
resumeInboundMessaging in interface WLIResourceAdapter
Throws:
javax.resource.NotSupportedException
javax.resource.ResourceException

getInboundMessagingStatus

public Status getInboundMessagingStatus()
Get the status of the inbound section of this adapter instance.

Specified by:
getInboundMessagingStatus in interface WLIResourceAdapter

getConnectionFactoryStatus

public Status getConnectionFactoryStatus(String name)
Get the status of a ConnectionFactory with the given name being managed by this adapter instance.

Specified by:
getConnectionFactoryStatus in interface WLIResourceAdapter

addAdapterStatusListener

public void addAdapterStatusListener(AdapterStatusListener listener)
Add a new AdapterStatusListener.

Specified by:
addAdapterStatusListener in interface WLIResourceAdapter

removeAdapterStatusListener

public void removeAdapterStatusListener(AdapterStatusListener listener)
Remove an existing AdapterStatusListener

Specified by:
removeAdapterStatusListener in interface WLIResourceAdapter

setInboundMessagingStatus

public void setInboundMessagingStatus(Status status)
Change this adapter's status.


initializeLogResources

protected void initializeLogResources()
                               throws javax.resource.ResourceException
Initializes resources needed by this instance to support localized logging after all base member variables have been initialized correctly by the application server. We have to support post-constructor initialization because of the JavaBeans approach to initializing instances of this class.

Throws:
javax.resource.ResourceException - if this method fails to initialize the logging framework or message bundle for this instance.

logInfo

protected void logInfo()
Writes information about 'this' instance to the underlying logger as a info message.


initAdapterMetaData

protected void initAdapterMetaData(ResourceBundle resourceBundle)
Retrieves metadata about the resource adapter from a message bundle.

Parameters:
resourceBundle - - provides internationalized and localized versions of adapter metadata.

getLogger

protected ILogger getLogger()
                     throws IllegalStateException
Retrieves an object used to log information to. This method uses the RootLogContext, AdditionalLogContext, LanguageCode, and CountryCode properties to determine its logger. Adapter developers can override this method to return a logger that is not based solely on the supplied logging context.

Returns:
an object used to log information to.
Throws:
IllegalStateException - if the log context is null

getLogContext

protected LogContext getLogContext()
                            throws IllegalStateException
Retrieves an object that determines the logging configuration for this instance in the logging framework.

Returns:
an object that determines the logging configuration for this instance.
Throws:
IllegalStateException - if the log context is null, i.e. this object has not been initialized correctly.

setLogLevel

public void setLogLevel(String strLogLevel)
                 throws javax.resource.ResourceException
Sets the log priority level for 'this' instance. The log priority determines which messages are actually sent to the log at runtime. By default, this value is "WARN" - all messages with severity of WARN or greater are sent to the log.

Throws:
javax.resource.ResourceException

getLogLevel

public String getLogLevel()
Returns:
the log level for this instance. The log level determines whether a message is printed to the log.

setRootLogContext

public void setRootLogContext(String strRootLogContext)
                       throws javax.resource.ResourceException
Sets the root log context for this factory. The root log context facilitates the categorization of log messages. In other words, all messages generated by this instance and the other objects it creates, i.e. connection factory and managed connection instances will log under this category.

Parameters:
strRootLogContext - - the root context from which all log messages generated will be associated. This helps identify log messages according to resource adapter type. Typically, this is related to the adapter/EIS type, etc.
Throws:
javax.resource.ResourceException - - an exceptional condition was encountered while attempting to set the root log context; the argument cannot be null or "".

getRootLogContext

public String getRootLogContext()
Returns:
the root log context for this factory

setResourceAdapterProperties

protected void setResourceAdapterProperties()
                                     throws javax.resource.ResourceException
Add standard properties required for all resource adapters

Throws:
javax.resource.ResourceException

setStandardResourceAdapterProperties

protected void setStandardResourceAdapterProperties()
                                             throws javax.resource.ResourceException
Throws:
javax.resource.ResourceException

checkAndPutProperty

protected void checkAndPutProperty(String name,
                                   Object value)

setAdditionalLogContext

public void setAdditionalLogContext(String strAdditionalLogContext)
                             throws javax.resource.ResourceException
Sets additional context information for identifying logging configuration. For example, if this managed connection factory is associated with an order processing application in SAP R/3, the additional log context could be "OrderProcessing" and the root log context could be "SAPR3".

Parameters:
strAdditionalLogContext - - a value that provides additional context information for this instance.
Throws:
javax.resource.ResourceException - - an exceptional condition was encountered while attempting to set the additional context; the argument cannot be null or "".

getAdditionalLogContext

public String getAdditionalLogContext()

getLogConfigFile

public String getLogConfigFile()

setLogConfigFile

public void setLogConfigFile(String logConfigFile)

getMessageBundleBase

public String getMessageBundleBase()

setMessageBundleBase

public void setMessageBundleBase(String messageBundleBase)

getLanguageCode

public String getLanguageCode()

setLanguageCode

public void setLanguageCode(String languageCode)

getCountryCode

public String getCountryCode()

setCountryCode

public void setCountryCode(String countryCode)

setEventGeneratorClassName

public void setEventGeneratorClassName(String eventGeneratorClassName)
                                throws javax.resource.ResourceException
Throws:
javax.resource.ResourceException

getEventGeneratorClassName

public String getEventGeneratorClassName()