Class ActiveJmsResourceAdapter
- java.lang.Object
-
- com.sun.enterprise.connectors.ActiveResourceAdapterImpl
-
- com.sun.enterprise.connectors.ActiveOutboundResourceAdapter
-
- com.sun.enterprise.connectors.inbound.ActiveInboundResourceAdapterImpl
-
- com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter
-
- All Implemented Interfaces:
ActiveResourceAdapter,ActiveInboundResourceAdapter,org.glassfish.hk2.api.PostConstruct,LazyServiceInitializer
@Service @Singleton @Named("mq-service") public class ActiveJmsResourceAdapter extends ActiveInboundResourceAdapterImpl implements LazyServiceInitializer, org.glassfish.hk2.api.PostConstructRepresents an active JMS resource adapter. This does additional configuration to ManagedConnectionFactory and ResourceAdapter java beans. XXX: For code management reasons, think about splitting this to a preHawk and postHawk RA (with postHawk RA extending preHawk RA).- Author:
- Satish Kumar
-
-
Field Summary
Fields Modifier and Type Field Description static StringADDRESSLISTstatic StringADMINPASSWORDstatic StringADMINUSERNAMEstatic StringBROKERTYPEstatic StringCONNECTION_URLstatic StringDESTINATIONstatic StringDESTINATION_TYPEstatic StringDIRECTstatic StringDISABLEDstatic StringEMBEDDEDstatic StringGRIZZLY_PROXY_PREFIXstatic StringJMS_SERVICEstatic StringLOCALstatic StringMQ_DIR_NAMEstatic StringPHYSICAL_DESTINATIONstatic StringREMOTE-
Fields inherited from class com.sun.enterprise.connectors.ActiveOutboundResourceAdapter
bootStrapContextImpl, resourceadapter_
-
Fields inherited from class com.sun.enterprise.connectors.ActiveResourceAdapterImpl
connectionDefs_, connectorRuntime_, desc_, jcl_, moduleName_
-
-
Constructor Summary
Constructors Constructor Description ActiveJmsResourceAdapter()Constructor for an active Jms Adapter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJmsHost(JmsHost host)Adds the JmsHost to the MQAddressList of the resource adapter.jakarta.resource.spi.ManagedConnectionFactory[]createManagedConnectionFactories(ConnectorConnectionPool cpr, ClassLoader loader)This is a temporay solution for obtaining all the MCFs corresponding to a JMS RA pool, this is to facilitate the recovery process where the XA resources of all RMs in the broker cluster are required.jakarta.resource.spi.ManagedConnectionFactorycreateManagedConnectionFactory(ConnectorConnectionPool cpr, ClassLoader loader)Creates ManagedConnection Factory instance.voiddeleteJmsHost(JmsHost host)Removes the JmsHost from the MQAddressList of the resource adapter.voiddestroy()Destroys default pools and resources.intgetAddressListCount()static StringgetBrokerInstanceName(JmsService js)booleangetDoBind()Whether JMS should bind to a portSet<String>getGrizzlyListeners()protected JmsHostgetJmsHost()voidhandleRequest(SelectableChannel selectableChannel)Upon successful ACCEPT of every request on this port, the service is called upon to handle the request.booleanhandles(ConnectorDescriptor cd, String moduleName)Indicates whether a particular implementation of ActiveRA can handle the RAR in question.voidinitializeLazyListener(JmsService jmsService)Start Grizzly based JMS lazy listener, which is going to initialize JMS container on first request.booleaninitializeService()Upon accepting the first request on the port (to which this listener is bound), the listener will select the appropriate provider and call this method to let the actual service initialize itself.protected jakarta.resource.spi.ManagedConnectionFactoryinstantiateMCF(String mcfClass, ClassLoader loader)protected voidloadRAConfiguration()Loads RA configuration for MQ Resource adapter.protected SetmergeRAConfiguration(ResourceAdapterConfig raConfig, List<Property> raConfigProps)This is a HACK to remove the connection URL in the case of PE LOCAL/EMBEDDED before setting the properties to the RA.voidpostConstruct()protected voidpostRAConfiguration()Method to perform any post RA configuration action by derivative subclasses.voidreloadRA(JmsService js)Recreates the ResourceAdapter using new values from JmsSerice.protected voidsetClusterBrokerList(String brokerList)voidsetMasterBroker(String newMasterBroker)voidsetup()Does the necessary initial setup.protected voidstartResourceAdapter(jakarta.resource.spi.BootstrapContext bootstrapContext)called by connector runtime to start the resource-adapter java beanvoidupdateJmsHost(JmsHost host)Updates the JmsHost information in the MQAddressList of the resource adapter.voidupdateMDBRuntimeInfo(EjbMessageBeanDescriptor descriptor_, BeanPoolDescriptor poolDescriptor)This is the most appropriate time (??) to update the runtime info of a 1.3 MDB into 1.4 MDB.voidvalidateActivationSpec(jakarta.resource.spi.ActivationSpec spec)validate the activation-spec-
Methods inherited from class com.sun.enterprise.connectors.inbound.ActiveInboundResourceAdapterImpl
addEndpointFactoryInfo, getAllEndpointFactories, getAllEndpointFactoryInfo, getEndpointFactoryInfo, init, removeEndpointFactoryInfo
-
Methods inherited from class com.sun.enterprise.connectors.ActiveOutboundResourceAdapter
addAdminObject, getBootStrapContext, getResourceAdapter
-
Methods inherited from class com.sun.enterprise.connectors.ActiveResourceAdapterImpl
createAllConnectorResources, createDefaultConnectorConnectionPools, createDefaultConnectorResources, deleteDefaultConnectorConnectionPools, deleteDefaultConnectorResources, destroyAllConnectorResources, getClassLoader, getDescriptor, getModuleName, isServer, isSystemRar
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sun.enterprise.connectors.ActiveResourceAdapter
getClassLoader, getDescriptor, getModuleName, getResourceAdapter
-
-
-
-
Field Detail
-
CONNECTION_URL
public static final String CONNECTION_URL
- See Also:
- Constant Field Values
-
BROKERTYPE
public static final String BROKERTYPE
- See Also:
- Constant Field Values
-
ADMINUSERNAME
public static final String ADMINUSERNAME
- See Also:
- Constant Field Values
-
ADMINPASSWORD
public static final String ADMINPASSWORD
- See Also:
- Constant Field Values
-
DESTINATION
public static final String DESTINATION
- See Also:
- Constant Field Values
-
DESTINATION_TYPE
public static final String DESTINATION_TYPE
- See Also:
- Constant Field Values
-
PHYSICAL_DESTINATION
public static final String PHYSICAL_DESTINATION
- See Also:
- Constant Field Values
-
ADDRESSLIST
public static final String ADDRESSLIST
- See Also:
- Constant Field Values
-
JMS_SERVICE
public static final String JMS_SERVICE
- See Also:
- Constant Field Values
-
EMBEDDED
public static final String EMBEDDED
- See Also:
- Constant Field Values
-
LOCAL
public static final String LOCAL
- See Also:
- Constant Field Values
-
REMOTE
public static final String REMOTE
- See Also:
- Constant Field Values
-
DIRECT
public static final String DIRECT
- See Also:
- Constant Field Values
-
DISABLED
public static final String DISABLED
- See Also:
- Constant Field Values
-
MQ_DIR_NAME
public static final String MQ_DIR_NAME
- See Also:
- Constant Field Values
-
GRIZZLY_PROXY_PREFIX
public static final String GRIZZLY_PROXY_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
postConstruct
public void postConstruct()
- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
loadRAConfiguration
protected void loadRAConfiguration() throws ConnectorRuntimeExceptionLoads RA configuration for MQ Resource adapter.- Overrides:
loadRAConfigurationin classActiveOutboundResourceAdapter- Throws:
ConnectorRuntimeException- in case of an exception.
-
destroy
public void destroy()
Description copied from class:ActiveInboundResourceAdapterImplDestroys default pools and resources. Stops the Resource adapter java bean.- Specified by:
destroyin interfaceActiveResourceAdapter- Overrides:
destroyin classActiveInboundResourceAdapterImpl
-
initializeLazyListener
public void initializeLazyListener(JmsService jmsService) throws JmsInitialisationException
Start Grizzly based JMS lazy listener, which is going to initialize JMS container on first request.- Parameters:
jmsService-- Throws:
JmsInitialisationException
-
startResourceAdapter
protected void startResourceAdapter(jakarta.resource.spi.BootstrapContext bootstrapContext) throws jakarta.resource.spi.ResourceAdapterInternalExceptionDescription copied from class:ActiveOutboundResourceAdaptercalled by connector runtime to start the resource-adapter java bean- Overrides:
startResourceAdapterin classActiveOutboundResourceAdapter- Parameters:
bootstrapContext- BootstrapContext- Throws:
jakarta.resource.spi.ResourceAdapterInternalException
-
mergeRAConfiguration
protected Set mergeRAConfiguration(ResourceAdapterConfig raConfig, List<Property> raConfigProps)
This is a HACK to remove the connection URL in the case of PE LOCAL/EMBEDDED before setting the properties to the RA. If this was not done, MQ RA incorrectly assumed that the passed in connection URL is one additional URL, apart from the default URL derived from brokerhost:brokerport and reported a PE connection url limitation.- Overrides:
mergeRAConfigurationin classActiveOutboundResourceAdapter- Parameters:
raConfig- resource-adapter-configraConfigProps- resource-adapter bean configuration- Returns:
-
setup
public void setup() throws ConnectorRuntimeExceptionDescription copied from class:ActiveOutboundResourceAdapterDoes the necessary initial setup. Creates the default pool and resource.- Specified by:
setupin interfaceActiveResourceAdapter- Overrides:
setupin classActiveOutboundResourceAdapter- Throws:
ConnectorRuntimeException- If there is a failure
-
postRAConfiguration
protected void postRAConfiguration() throws ConnectorRuntimeExceptionMethod to perform any post RA configuration action by derivative subclasses. For example, this method is used byActiveJMSResourceAdapterto set unsupported javabean property types on its RA JavaBean runtime instance.- Throws:
ConnectorRuntimeException
-
getBrokerInstanceName
public static String getBrokerInstanceName(JmsService js)
-
handles
public boolean handles(ConnectorDescriptor cd, String moduleName)
Description copied from class:ActiveInboundResourceAdapterImplIndicates whether a particular implementation of ActiveRA can handle the RAR in question.- Specified by:
handlesin interfaceActiveResourceAdapter- Overrides:
handlesin classActiveInboundResourceAdapterImpl- Parameters:
cd- ConnectorDescriptormoduleName- resource adapter name- Returns:
- boolean indiating whether a ActiveRA can handle the RAR
-
validateActivationSpec
public void validateActivationSpec(jakarta.resource.spi.ActivationSpec spec)
Description copied from interface:ActiveInboundResourceAdaptervalidate the activation-spec- Specified by:
validateActivationSpecin interfaceActiveInboundResourceAdapter- Overrides:
validateActivationSpecin classActiveInboundResourceAdapterImpl- Parameters:
spec- activation-spec
-
reloadRA
public void reloadRA(JmsService js) throws ConnectorRuntimeException
Recreates the ResourceAdapter using new values from JmsSerice.- Parameters:
js- JmsService element of the domain.xml- Throws:
ConnectorRuntimeException- in case of any backend error.
-
addJmsHost
public void addJmsHost(JmsHost host) throws ConnectorRuntimeException
Adds the JmsHost to the MQAddressList of the resource adapter.- Parameters:
host- JmsHost element in the domain.xml- Throws:
ConnectorRuntimeException- in case of any backend error.
-
deleteJmsHost
public void deleteJmsHost(JmsHost host) throws ConnectorRuntimeException
Removes the JmsHost from the MQAddressList of the resource adapter.- Parameters:
host- JmsHost element in the domain.xml- Throws:
ConnectorRuntimeException- in case of any backend error.
-
getJmsHost
protected JmsHost getJmsHost()
-
updateJmsHost
public void updateJmsHost(JmsHost host) throws ConnectorRuntimeException
Updates the JmsHost information in the MQAddressList of the resource adapter.- Parameters:
host- JmsHost element in the domain.xml- Throws:
ConnectorRuntimeException- in case of any backend error.
-
getDoBind
public boolean getDoBind()
Whether JMS should bind to a port- Returns:
- false in embedded mode, true otherwise
-
createManagedConnectionFactories
public jakarta.resource.spi.ManagedConnectionFactory[] createManagedConnectionFactories(ConnectorConnectionPool cpr, ClassLoader loader)
This is a temporay solution for obtaining all the MCFs corresponding to a JMS RA pool, this is to facilitate the recovery process where the XA resources of all RMs in the broker cluster are required. Should be removed when a permanent solutuion is available from the broker.- Specified by:
createManagedConnectionFactoriesin interfaceActiveResourceAdapter- Overrides:
createManagedConnectionFactoriesin classActiveResourceAdapterImpl- Parameters:
cpr-ConnectorConnectionPoolobjectloader- Class Loader.- Returns:
-
instantiateMCF
protected jakarta.resource.spi.ManagedConnectionFactory instantiateMCF(String mcfClass, ClassLoader loader) throws Exception
- Overrides:
instantiateMCFin classActiveResourceAdapterImpl- Throws:
Exception
-
createManagedConnectionFactory
public jakarta.resource.spi.ManagedConnectionFactory createManagedConnectionFactory(ConnectorConnectionPool cpr, ClassLoader loader)
Creates ManagedConnection Factory instance. For any property that is for supporting AS7 imq properties, resource adapter has a set method setProperty(String,String). All as7 properties starts with "imq". MQ Adapter supports this only for backward compatibility.- Specified by:
createManagedConnectionFactoryin interfaceActiveResourceAdapter- Overrides:
createManagedConnectionFactoryin classActiveOutboundResourceAdapter- Parameters:
cpr-ConnectorConnectionPoolobjectloader- Class Loader.- Returns:
-
updateMDBRuntimeInfo
public void updateMDBRuntimeInfo(EjbMessageBeanDescriptor descriptor_, BeanPoolDescriptor poolDescriptor) throws ConnectorRuntimeException
This is the most appropriate time (??) to update the runtime info of a 1.3 MDB into 1.4 MDB.Assumptions :
0. Assume it is a 1.3 MDB if no RA mid is specified. 1. Use the default system JMS resource adapter.
2. The ActivationSpec of the default JMS RA will provide the setDestination, setDestinationType, setSubscriptionName methods. 3. The jndi-name of the 1.3 MDB is the value for the Destination property for the ActivationSpec. 4. The ActivationSpec provides setter methods for the properties defined in the CF that corresponds to the mdb-connection-factory JNDI name.
- Specified by:
updateMDBRuntimeInfoin interfaceActiveInboundResourceAdapter- Overrides:
updateMDBRuntimeInfoin classActiveInboundResourceAdapterImpl- Parameters:
descriptor_-poolDescriptor-- Throws:
ConnectorRuntimeException
-
getAddressListCount
public int getAddressListCount()
-
initializeService
public boolean initializeService()
Description copied from interface:LazyServiceInitializerUpon accepting the first request on the port (to which this listener is bound), the listener will select the appropriate provider and call this method to let the actual service initialize itself. All further accept requests on this port will wait while the service is initialized. Upon successful completion of service initialization, all pending requests are passed to the service using the handleRequest method- Specified by:
initializeServicein interfaceLazyServiceInitializer- Returns:
- Return true if service initialization went through fine; false otherwise
-
handleRequest
public void handleRequest(SelectableChannel selectableChannel)
Description copied from interface:LazyServiceInitializerUpon successful ACCEPT of every request on this port, the service is called upon to handle the request. The service is provided the channel itself. The service can setup connection, its characteristics, decide on blocking/non-blocking modes etc. The service is expected to return control back to the listener ASAP without consuming this thread for processing the requst completely.- Specified by:
handleRequestin interfaceLazyServiceInitializer- Parameters:
selectableChannel- where the incoming request was accepted.
-
setMasterBroker
public void setMasterBroker(String newMasterBroker)
-
setClusterBrokerList
protected void setClusterBrokerList(String brokerList)
-
-