Search in sources :

Example 1 with WSCFEnvironmentBean

use of org.jboss.jbossts.xts.environment.WSCFEnvironmentBean in project narayana by jbosstm.

the class ProtocolManager method initialise.

/*
	 * install all registered protocol implementations which should be either context factories
	 * or high level services
	 */
public final synchronized void initialise() {
    if (_initialised)
        return;
    else
        _initialised = true;
    WSCFEnvironmentBean wscfEnvironmentBean = XTSPropertyManager.getWSCFEnvironmentBean();
    List<String> protocolImplementations = wscfEnvironmentBean.getProtocolImplementations();
    if (protocolImplementations == null) {
        wscfLogger.i18NLogger.info_protocols_ProtocolManager_1();
        return;
    }
    ListIterator<String> iterator = protocolImplementations.listIterator();
    List<Class<?>> contextProviderClasses = new ArrayList<Class<?>>();
    List<Class<?>> hlsProviderClasses = new ArrayList<Class<?>>();
    while (iterator.hasNext()) {
        String className = (String) iterator.next();
        Class<?> clazz = null;
        try {
            clazz = this.getClass().getClassLoader().loadClass(className);
            ContextProvider contextProvider = clazz.getAnnotation(ContextProvider.class);
            if (contextProvider != null) {
                contextProviderClasses.add(clazz);
            } else {
                HLSProvider hlsProvider = clazz.getAnnotation(HLSProvider.class);
                if (hlsProvider != null) {
                    hlsProviderClasses.add(clazz);
                } else {
                    wscfLogger.i18NLogger.error_protocols_ProtocolManager_2(className);
                }
            }
        } catch (ClassNotFoundException cnfe) {
            wscfLogger.i18NLogger.error_protocols_ProtocolManager_3(className, cnfe);
        }
    }
    for (Class<?> clazz : hlsProviderClasses) {
        String className = clazz.getName();
        try {
            HLSProvider hlsProvider = clazz.getAnnotation(HLSProvider.class);
            String serviceType = hlsProvider.serviceType();
            wscfLogger.i18NLogger.info_protocols_ProtocolManager_4(className, serviceType);
            Object object = clazz.newInstance();
            _protocols.put(serviceType, object);
        } catch (InstantiationException ie) {
            wscfLogger.i18NLogger.error_protocols_ProtocolManager_5(className, ie);
        } catch (IllegalAccessException iae) {
            wscfLogger.i18NLogger.error_protocols_ProtocolManager_5(className, iae);
        }
    }
    for (Class<?> clazz : contextProviderClasses) {
        String className = clazz.getName();
        try {
            ContextProvider contextProvider = clazz.getAnnotation(ContextProvider.class);
            if (contextProvider != null) {
                String coordinationType = contextProvider.coordinationType();
                wscfLogger.i18NLogger.info_protocols_ProtocolManager_4(className, coordinationType);
                Object object = clazz.newInstance();
                _protocols.put(coordinationType, object);
            }
        } catch (InstantiationException ie) {
            wscfLogger.i18NLogger.error_protocols_ProtocolManager_5(className, ie);
            // To change body of catch statement use File | Settings | File Templates.
            ie.printStackTrace();
        } catch (IllegalAccessException iae) {
            wscfLogger.i18NLogger.error_protocols_ProtocolManager_5(className, iae);
            // To change body of catch statement use File | Settings | File Templates.
            iae.printStackTrace();
        }
    }
}
Also used : WSCFEnvironmentBean(org.jboss.jbossts.xts.environment.WSCFEnvironmentBean) ContextProvider(com.arjuna.mwlabs.wscf.utils.ContextProvider) HLSProvider(com.arjuna.mwlabs.wscf.utils.HLSProvider)

Aggregations

ContextProvider (com.arjuna.mwlabs.wscf.utils.ContextProvider)1 HLSProvider (com.arjuna.mwlabs.wscf.utils.HLSProvider)1 WSCFEnvironmentBean (org.jboss.jbossts.xts.environment.WSCFEnvironmentBean)1