FileDocCategorySizeDatePackage
ActiveRAFactory.javaAPI DocGlassfish v2 API6375Fri May 04 22:34:22 BST 2007com.sun.enterprise.connectors

ActiveRAFactory

public class ActiveRAFactory extends Object
Factory creating Active Resource adapters.
author
Binod P.G

Fields Summary
static Logger
_logger
Constructors Summary
Methods Summary
public static ActiveResourceAdaptercreateActiveResourceAdapter(com.sun.enterprise.deployment.ConnectorDescriptor cd, java.lang.String moduleName, java.lang.ClassLoader loader)
Creates an active resource adapter.

param
cd Deployment descriptor object for connectors.
param
moduleName Module name of the resource adapter.
param
loader Class Loader,
param
writeSunDescriptor Boolean indicating whether sundescriptor need to be written or not.
return
An instance of ActiveResourceAdapter object.
throws
ConnectorRuntimeException.

     

                                                              
       
              
         

        ActiveResourceAdapter activeResourceAdapter = null;
        int environment = ConnectorRuntime.getRuntime().getEnviron();
        ResourceAdapter ra = null;
        String raClass = cd.getResourceAdapterClass();

        try {

            // If raClass is available, load it...
            if (raClass != null && !raClass.equals("")) {
                if(environment == ConnectorRuntime.SERVER) {
                    ra = (ResourceAdapter) 
                          loader.loadClass(raClass).newInstance();
                } else {
                    ra = (ResourceAdapter)Class.forName(raClass).newInstance();
                }

            }

            /*
             * If any special handling is required for the system resource 
             * adapter, then ActiveResourceAdapter implementation for that
             * RA should implement additional functionality by extending
             * ActiveInboundResourceAdapter or ActiveOutboundResourceAdapter.
             *
             * For example ActiveJmsResourceAdapter extends 
             * ActiveInboundResourceAdapter.
             */
            if (moduleName.equals(ConnectorConstants.DEFAULT_JMS_ADAPTER)) {
                // Upgrade jms resource adapter, if necessary before starting 
                // the RA.
		try {
                	JmsRaUtil raUtil = new JmsRaUtil();
                	raUtil.upgradeIfNecessary();
		}
		catch (Throwable t) {
            	_logger.log(Level.FINE,"Cannot upgrade jmsra"+ t.getMessage());
		}

                activeResourceAdapter = new ActiveJmsResourceAdapter(
                                                 ra,cd,moduleName,loader);
            } else if (raClass.equals(""))  {
                activeResourceAdapter = new ActiveOutboundResourceAdapter(
                                 cd,moduleName,loader);
            } else {
                activeResourceAdapter = new ActiveInboundResourceAdapter(
                                                 ra,cd,moduleName,loader);
            }
	     
        } catch (ClassNotFoundException Ex) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(
                                             "Error in creating active RAR");
            cre.initCause(Ex);
            _logger.log(Level.SEVERE,"rardeployment.class_not_found",raClass);
            _logger.log(Level.SEVERE,"",cre);
            throw cre; 
        } catch (InstantiationException Ex) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(
                                             "Error in creating active RAR");
            cre.initCause(Ex);
            _logger.log(Level.SEVERE,"rardeployment.class_instantiation_error",
                                    raClass);
            _logger.log(Level.SEVERE,"",cre);
            throw cre; 
        } catch (IllegalAccessException Ex) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(
                                             "Error in creating active RAR");
            cre.initCause(Ex);
            _logger.log(Level.SEVERE,"rardeployment.illegalaccess_error",
                         raClass);
            _logger.log(Level.SEVERE,"",cre);
            throw cre; 
        } 

        return activeResourceAdapter;