[jboss-svn-commits] JBL Code SVN: r34620 - in labs/jbosstm/trunk/XTS: WS-C/dev/src10/com/arjuna/wsc and 39 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 10 08:03:22 EDT 2010


Author: adinn
Date: 2010-08-10 08:03:17 -0400 (Tue, 10 Aug 2010)
New Revision: 34620

Added:
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/common/Environment.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolManager.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolRegistry.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/ContextProvider.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/HLSProvider.java
   labs/jbosstm/trunk/XTS/xts.properties
Removed:
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/protocols/
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/common/
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/protocols/
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wsc/ContextFactoryMapperImple.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/protocols/
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/common/
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/protocols/
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wsc11/
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/protocols/
Modified:
   labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/ContextFactoryMapper.java
   labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/messaging/ActivationCoordinatorProcessorImpl.java
   labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/ContextFactoryMapper.java
   labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/messaging/ActivationCoordinatorProcessorImpl.java
   labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc/tests/TestInitialisation.java
   labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/TestInitialisation.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wsc/deploy/WSCFInitialisation.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/CoordinatorManagerFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/UserCoordinatorFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/CoordinatorManagerFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/UserCoordinatorFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/SagasHLSImple.java
   labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/TwoPhaseHLSImple.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wsc11/deploy/WSCFInitialisation.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/CoordinatorManagerFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/UserCoordinatorFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/CoordinatorManagerFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/UserCoordinatorFactory.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/sagas/arjunacore/SagasHLSImple.java
   labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/twophase/arjunacore/TwoPhaseHLSImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mw/wst/deploy/WSTXInitialisation.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/ContextFactoryImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/SubordinateImporter.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/context/ArjunaContextImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/ContextFactoryImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/context/ArjunaContextImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mw/wst11/deploy/WSTXInitialisation.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/SubordinateImporter.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/context/ArjunaContextImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/ContextFactoryImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/SubordinateImporter.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/context/ArjunaContextImple.java
   labs/jbosstm/trunk/XTS/bridge/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java
   labs/jbosstm/trunk/XTS/build.xml
   labs/jbosstm/trunk/XTS/sar/build.xml
   labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/XTSService.java
Log:
partial changes towards completion of JBTM-741 and JBTM-678

modified WSAS so activities have a service type and only activate high
level services of that type thereby removing some redundant code and
paving the way for simplifying property based config and introducing
bean based config.

modified WSCF and WSTX so that configuration is read from a single
property file rather than multiple xml config files thereby allowing
some of the config code to be deleted and other bits to be simplified.

removed the XML protocol specification documents associated with the
HLS and Context/ContextFactory implementations configured in the
properties file because this indirection did not actually avoid
hard-wiring of the configuration. replaced this XML configuration with
annotations attached to the protocol implementation classes and
modified initalisation code to process these annotations duing
startup. This removes the need for a lot of the remaining
initialisation to be performed.

Modified: labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/ContextFactoryMapper.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/ContextFactoryMapper.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/ContextFactoryMapper.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -38,28 +38,20 @@
     /**
      * The factory singleton.
      */
-    private static final ContextFactoryMapper FACTORY = new ContextFactoryMapper() ;
+    private static final ContextFactoryMapper theMapper = new ContextFactoryMapper() ;
     
     /**
      * The context factory map.
      */
     private final Map contextFactoryMap = new HashMap() ;
+
     /**
-     * The subordinate context factory mapper.
-     */
-    private ContextFactoryMapper subordinateContextFactoryMapper ;
-    /**
-     * The default context factory.
-     */
-    private ContextFactory defaultContextFactory ;
-    
-    /**
      * Get the context factory mapper singleton.
      * @return The context factory mapper singleton.
      */
-    public static ContextFactoryMapper getFactory()
+    public static ContextFactoryMapper getMapper()
     {
-        return FACTORY ;
+        return theMapper;
     }
     
     /**
@@ -90,24 +82,10 @@
      */
     public ContextFactory getContextFactory(final String coordinationTypeURI)
     {
-        final Object localContextFactory ;
         synchronized(contextFactoryMap)
         {
-            localContextFactory = contextFactoryMap.get(coordinationTypeURI) ;
+            return (ContextFactory)contextFactoryMap.get(coordinationTypeURI) ;
         }
-        if (localContextFactory != null)
-        {
-            return (ContextFactory)localContextFactory ;
-        }
-        if (subordinateContextFactoryMapper != null)
-        {
-            final ContextFactory subordinateContextFactory = subordinateContextFactoryMapper.getContextFactory(coordinationTypeURI) ;
-            if (subordinateContextFactory != null)
-            {
-                return subordinateContextFactory ;
-            }
-        }
-        return defaultContextFactory ;
     }
 
     /**
@@ -126,40 +104,4 @@
             ((ContextFactory)localContextFactory).uninstall(coordinationTypeURI) ;
         }
     }
-
-    /**
-     * Get the subordinate coordination factory mapper.
-     * @return The subordinate coordination factory mapper.
-     */
-    public ContextFactoryMapper getSubordinateContextFactoryMapper()
-    {
-        return subordinateContextFactoryMapper ;
-    }
-
-    /**
-     * Set a subordinate coordination factory mapper.
-     * @param subordinateContextFactoryMapper The subordinate coordination factory mapper.
-     */
-    public void setSubordinateContextFactoryMapper(final ContextFactoryMapper subordinateContextFactoryMapper)
-    {
-        this.subordinateContextFactoryMapper = subordinateContextFactoryMapper ;
-    }
-
-    /**
-     * Get the default coordination factory.
-     * @return The default coordination factory.
-     */
-    public ContextFactory getDefaultContextFactory()
-    {
-        return defaultContextFactory ;
-    }
-
-    /**
-     * Set the default coordination factory.
-     * @param defaultContextFactory The default coordination factory.
-     */
-    public void setDefaultContextFactory(final ContextFactory defaultContextFactory)
-    {
-        this.defaultContextFactory = defaultContextFactory ;
-    }
 }

Modified: labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/messaging/ActivationCoordinatorProcessorImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/messaging/ActivationCoordinatorProcessorImpl.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WS-C/dev/src10/com/arjuna/wsc/messaging/ActivationCoordinatorProcessorImpl.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -49,7 +49,7 @@
     public void createCoordinationContext(final CreateCoordinationContextType createCoordinationContext,
         final AddressingContext addressingContext)
     {
-        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getFactory() ;
+        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper() ;
         try
         {
             final String coordinationType = createCoordinationContext.getCoordinationType().getValue() ;

Modified: labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/ContextFactoryMapper.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/ContextFactoryMapper.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/ContextFactoryMapper.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -12,28 +12,19 @@
     /**
      * The factory singleton.
      */
-    private static final ContextFactoryMapper FACTORY = new ContextFactoryMapper() ;
+    private static final ContextFactoryMapper theMapper = new ContextFactoryMapper() ;
 
     /**
      * The context factory map.
      */
     private final Map contextFactoryMap = new HashMap() ;
     /**
-     * The subordinate context factory mapper.
-     */
-    private ContextFactoryMapper subordinateContextFactoryMapper ;
-    /**
-     * The default context factory.
-     */
-    private ContextFactory defaultContextFactory ;
-
-    /**
      * Get the context factory mapper singleton.
      * @return The context factory mapper singleton.
      */
-    public static ContextFactoryMapper getFactory()
+    public static ContextFactoryMapper getMapper()
     {
-        return FACTORY;
+        return theMapper;
     }
 
     /**
@@ -64,24 +55,10 @@
      */
     public ContextFactory getContextFactory(final String coordinationTypeURI)
     {
-        final Object localContextFactory ;
         synchronized(contextFactoryMap)
         {
-            localContextFactory = contextFactoryMap.get(coordinationTypeURI) ;
+            return (ContextFactory)contextFactoryMap.get(coordinationTypeURI) ;
         }
-        if (localContextFactory != null)
-        {
-            return (ContextFactory)localContextFactory ;
-        }
-        if (subordinateContextFactoryMapper != null)
-        {
-            final ContextFactory subordinateContextFactory = subordinateContextFactoryMapper.getContextFactory(coordinationTypeURI) ;
-            if (subordinateContextFactory != null)
-            {
-                return subordinateContextFactory ;
-            }
-        }
-        return defaultContextFactory ;
     }
 
     /**
@@ -100,40 +77,4 @@
             ((ContextFactory)localContextFactory).uninstall(coordinationTypeURI) ;
         }
     }
-
-    /**
-     * Get the subordinate coordination factory mapper.
-     * @return The subordinate coordination factory mapper.
-     */
-    public ContextFactoryMapper getSubordinateContextFactoryMapper()
-    {
-        return subordinateContextFactoryMapper ;
-    }
-
-    /**
-     * Set a subordinate coordination factory mapper.
-     * @param subordinateContextFactoryMapper The subordinate coordination factory mapper.
-     */
-    public void setSubordinateContextFactoryMapper(final ContextFactoryMapper subordinateContextFactoryMapper)
-    {
-        this.subordinateContextFactoryMapper = subordinateContextFactoryMapper ;
-    }
-
-    /**
-     * Get the default coordination factory.
-     * @return The default coordination factory.
-     */
-    public ContextFactory getDefaultContextFactory()
-    {
-        return defaultContextFactory ;
-    }
-
-    /**
-     * Set the default coordination factory.
-     * @param defaultContextFactory The default coordination factory.
-     */
-    public void setDefaultContextFactory(final ContextFactory defaultContextFactory)
-    {
-        this.defaultContextFactory = defaultContextFactory ;
-    }
 }

Modified: labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/messaging/ActivationCoordinatorProcessorImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/messaging/ActivationCoordinatorProcessorImpl.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WS-C/dev/src11/com/arjuna/wsc11/messaging/ActivationCoordinatorProcessorImpl.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -52,7 +52,7 @@
                                   final MAP map,
                                   final boolean isSecure)
     {
-        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getFactory() ;
+        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper() ;
         try
         {
             final String coordinationType = createCoordinationContext.getCoordinationType() ;

Modified: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc/tests/TestInitialisation.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc/tests/TestInitialisation.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc/tests/TestInitialisation.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -38,7 +38,7 @@
      */
     public void contextInitialized(final ServletContextEvent servletContextEvent)
     {
-        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getFactory() ;
+        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper() ;
         final TestContextFactory testContextFactory = new TestContextFactory(TestUtil.COORDINATION_TYPE) ;
 
         contextFactoryMapper.addContextFactory(TestUtil.COORDINATION_TYPE, testContextFactory) ;
@@ -60,7 +60,7 @@
      */
     public void contextDestroyed(final ServletContextEvent servletContextEvent)
     {
-        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getFactory() ;
+        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper() ;
         contextFactoryMapper.removeContextFactory(TestUtil.COORDINATION_TYPE);
         contextFactoryMapper.removeContextFactory(TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE);
         

Modified: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/TestInitialisation.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/TestInitialisation.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/TestInitialisation.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -25,9 +25,7 @@
 
 import com.arjuna.wsc11.ContextFactoryMapper;
 import com.arjuna.wsc11.RegistrarMapper;
-import com.arjuna.wsc11.tests.TestContextFactory;
 import com.arjuna.wsc.tests.TestUtil;
-import com.arjuna.wsc11.tests.TestRegistrar;
 
 /**
  * Initialise the test.
@@ -41,7 +39,7 @@
      */
     public void contextInitialized(final ServletContextEvent servletContextEvent)
     {
-        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getFactory() ;
+        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper() ;
         final TestContextFactory testContextFactory = new TestContextFactory(TestUtil.COORDINATION_TYPE) ;
 
         contextFactoryMapper.addContextFactory(TestUtil.COORDINATION_TYPE, testContextFactory) ;
@@ -63,7 +61,7 @@
      */
     public void contextDestroyed(final ServletContextEvent servletContextEvent)
     {
-        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getFactory() ;
+        final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper() ;
         contextFactoryMapper.removeContextFactory(TestUtil.COORDINATION_TYPE);
         contextFactoryMapper.removeContextFactory(TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE);
 

Copied: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/common/Environment.java (from rev 34520, labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/common/Environment.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/common/Environment.java	                        (rev 0)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/common/Environment.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. 
+ * See the copyright.txt in the distribution for a full listing 
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: Environment.java,v 1.6 2004/03/15 13:25:01 nmcl Exp $
+ */
+
+package com.arjuna.mw.wscf.common;
+
+/**
+ *
+ * @author Mark Little (mark.little at arjuna.com)
+ * @version $Id: Environment.java,v 1.6 2004/03/15 13:25:01 nmcl Exp $
+ * @since 1.0.
+ */
+
+public class Environment
+{
+
+    public static final String PROTOCOL_IMPLEMENTATION = "org.jboss.jbossts.xts.protocolImplementation";
+    
+}

Added: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolManager.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolManager.java	                        (rev 0)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolManager.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -0,0 +1,308 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat and individual contributors
+ * as indicated by the @author tags. 
+ * See the copyright.txt in the distribution for a full listing 
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2010,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: ProtocolManager.java,v 1.13 2005/05/19 12:13:28 nmcl Exp $
+ */
+
+package com.arjuna.mw.wscf.protocols;
+
+import com.arjuna.mw.wscf.common.Environment;
+import com.arjuna.mw.wscf.exceptions.ProtocolAlreadyRegisteredException;
+import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
+import com.arjuna.mw.wscf.logging.wscfLogger;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
+import com.arjuna.mwlabs.wscf.utils.HLSProvider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.util.*;
+
+/**
+ * The ProtocolManager is the way in which protocol implementations may be
+ * registered with the system.
+ *
+ * @author Mark Little (mark.little at arjuna.com)
+ * @version $Id:$
+ * @since 1.0.
+ */
+
+public class ProtocolManager
+{
+
+	/**
+	 * Add a specific protocol implementation to the factory.
+	 *
+	 * @param     protocolName The name of the protocol.
+	 * @param     protocolImplementor The class that implements the protocol.
+	 *
+	 * @exception com.arjuna.mw.wscf.exceptions.ProtocolAlreadyRegisteredException
+	 *                Thrown if the exact same protocol definition has already
+	 *                been registered.
+	 * @exception IllegalArgumentException
+	 *                Thrown if either of the parameters is invalid.
+	 */
+
+	public void addProtocol (String protocolName, Object protocolImplementor)
+			throws ProtocolAlreadyRegisteredException,
+			IllegalArgumentException
+	{
+        synchronized(this) {
+            if ((protocolName == null) || (protocolImplementor == null))
+            {
+                throw new IllegalArgumentException();
+            }
+
+            if (_protocols.get(protocolName) != null) {
+                throw new ProtocolAlreadyRegisteredException();
+            } else {
+                _protocols.put(protocolName, protocolImplementor);
+            }
+        }
+	}
+
+	/**
+	 * Replace a specific protocol implementation in the factory.
+	 *
+	 * @param     protocolName The name of the protocol.
+	 * @param     protocolImplementor The class that implements the protocol.
+	 *
+	 * @exception com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException
+	 *                Thrown if the protocol to be removed has not been
+	 *                registered.
+	 * @exception IllegalArgumentException
+	 *                Thrown if either of the parameters is invalid.
+	 */
+
+	public void replaceProtocol (String protocolName, Object protocolImplementor)
+			throws ProtocolNotRegisteredException, IllegalArgumentException
+	{
+		synchronized (this)
+		{
+            if ((protocolName == null) || (protocolImplementor == null))
+            {
+                throw new IllegalArgumentException();
+            }
+
+            if (_protocols.get(protocolName) == null) {
+                throw new ProtocolNotRegisteredException();
+            } else {
+                _protocols.put(protocolName, protocolImplementor);
+            }
+		}
+	}
+
+	/**
+     * @param     protocolName The name of the protocol.
+	 *
+	 * @exception com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException
+	 *                Thrown if the requested coordination protocol has not been
+	 *                registered.
+	 * @exception IllegalArgumentException
+	 *                Thrown if the parameter is invalid.
+	 *
+	 * @return The class that implements the specified coordination protocol.
+	 *
+	 */
+
+	public Object getProtocolImplementation (String protocolName)
+			throws ProtocolNotRegisteredException, IllegalArgumentException
+	{
+        synchronized (this)
+        {
+            if (protocolName == null)
+            {
+                throw new IllegalArgumentException();
+            }
+
+            Object object = _protocols.get(protocolName);
+
+            if (object == null) {
+                throw new ProtocolNotRegisteredException(wscfLogger.i18NLogger.get_mw_wscf11_protocols_ProtocolManager_1()
+                        + protocolName);
+            }
+            return object;
+        }
+	}
+
+	/**
+	 * Remove the specified protocol definition from the factory.
+	 *
+     * @param     protocolName The name of the protocol.
+	 *
+	 * @exception com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException
+	 *                Thrown if the protocol to be removed has not been
+	 *                registered.
+	 * @exception IllegalArgumentException
+	 *                Thrown if the paramater is invalid (e.g., null).
+	 *
+	 * @return the protocol implementation removed.
+	 */
+
+	public Object removeProtocol (String protocolName)
+			throws ProtocolNotRegisteredException, IllegalArgumentException
+	{
+        synchronized (this)
+        {
+            if (protocolName == null)
+            {
+                throw new IllegalArgumentException();
+            }
+
+            Object object = _protocols.remove(protocolName);
+
+            if (object == null) {
+                throw new ProtocolNotRegisteredException(wscfLogger.i18NLogger.get_mw_wscf11_protocols_ProtocolManager_1()
+                        + protocolName);
+            }
+
+            return object;
+        }
+	}
+
+	/*
+	 * install all registered protocol implementations which should be either context factories
+	 * or high level services
+	 */
+
+	public synchronized final void initialise ()
+	{
+		if (_initialised)
+			return;
+		else
+			_initialised = true;
+
+        // TODO
+        // load properties file and add to environment -- eventually this will be autorun by
+        // the XTS configuration bean
+
+        InputStream is = ProtocolManager.class.getResourceAsStream("/xts.properties");
+        if (is != null) {
+            Properties props = new Properties();
+            try {
+                props.load(is);
+                Enumeration names = props.propertyNames();
+                while (names.hasMoreElements()) {
+                    String name = (String) names.nextElement();
+                    if (name.startsWith("org.jboss.jbossts.xts") ||
+                            name.startsWith(("com.arjuna.mw.wscf"))) {
+                        System.setProperty(name, props.getProperty(name));
+                    }
+                }
+            } catch(IOException ioe) {
+                System.out.println("cannot read xts.properties : " + ioe);
+                ioe.printStackTrace();
+            }
+        }
+
+		Properties props = System.getProperties();
+		Enumeration names = props.propertyNames();
+        List<Class<?>> contextProviderClasses =  new ArrayList<Class<?>>();
+        List<Class<?>> hlsProviderClasses =  new ArrayList<Class<?>>();
+
+        // look for protocol implementations
+        
+		while (names.hasMoreElements())
+		{
+			String name = (String) names.nextElement();
+
+
+			if (name.startsWith(Environment.PROTOCOL_IMPLEMENTATION))
+			{
+                String className = props.getProperty(name);
+                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 {
+                            System.out.println("ProtocolManager : Unknown protocol implementation : " + className);
+                        }
+                    }
+                } catch (ClassNotFoundException cnfe) {
+                    // TODO -- proper log message
+                    System.out.println("ProtocolManager : Unable to load protocol implementation class : " + className);
+                    cnfe.printStackTrace();
+                }
+            }
+        }
+
+        // we need to create the high level services before context factories since the latter need to
+        // cross-reference the former
+        
+        for (Class<?> clazz : hlsProviderClasses) {
+            String className = clazz.getName();
+            try
+            {
+                HLSProvider hlsProvider = clazz.getAnnotation(HLSProvider.class);
+                String serviceType = hlsProvider.serviceType();
+                System.out.println("ProtocolManager : Installing implementation class : " + className + " for service type " + serviceType);
+                Object object = clazz.newInstance();
+                _protocols.put(serviceType, object);
+            } catch (InstantiationException ie) {
+                // TODO -- proper log message
+                System.out.println("ProtocolManager : Unable to instantiate protocol implementation class : " + className);
+                ie.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            } catch (IllegalAccessException iae) {
+                // TODO -- proper log message
+                System.out.println("ProtocolManager : Unable to instantiate protocol implementation class : " + className);
+                iae.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+		}
+
+        for (Class<?> clazz : contextProviderClasses) {
+            String className = clazz.getName();
+            try
+            {
+                ContextProvider contextProvider = clazz.getAnnotation(ContextProvider.class);
+                if (contextProvider !=  null) {
+                    String coordinationType = contextProvider.coordinationType();
+                    System.out.println("ProtocolManager : Installing implementation class : " + className + " for coordination type " + coordinationType);
+                    Object object = clazz.newInstance();
+                    _protocols.put(coordinationType, object);
+                }
+            } catch (InstantiationException ie) {
+                // TODO -- proper log message
+                System.out.println("ProtocolManager : Unable to instantiate protocol implementation class : " + className);
+                ie.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            } catch (IllegalAccessException iae) {
+                // TODO -- proper log message
+                System.out.println("ProtocolManager : Unable to instantiate protocol implementation class : " + className);
+                iae.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+		}
+	}
+
+	private HashMap _protocols = new HashMap();
+	private boolean _initialised = false;
+}
\ No newline at end of file

Copied: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolRegistry.java (from rev 34546, labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/protocols/ProtocolRegistry.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolRegistry.java	                        (rev 0)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/protocols/ProtocolRegistry.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. 
+ * See the copyright.txt in the distribution for a full listing 
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id:$
+ */
+
+package com.arjuna.mw.wscf.protocols;
+
+import com.arjuna.mw.wscf.protocols.ProtocolManager;
+
+/**
+ * @author Mark Little (mark.little at arjuna.com)
+ * @version $Id: ProtocolRegistry.java,v 1.2 2003/03/04 12:55:56 nmcl Exp $
+ * @since 1.0.
+ */
+
+// TODO we need a separate instance for WSTX
+
+public class ProtocolRegistry
+{
+
+    public static ProtocolManager sharedManager ()
+    {
+	return _shared;
+    }
+
+    public static ProtocolManager createManager ()
+    {
+	return new ProtocolManager();
+    }
+
+    private static ProtocolManager _shared = new ProtocolManager();
+
+}
\ No newline at end of file

Added: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/ContextProvider.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/ContextProvider.java	                        (rev 0)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/ContextProvider.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -0,0 +1,16 @@
+package com.arjuna.mwlabs.wscf.utils;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation used to identify a ContextFactory and specify the protocol it supports and the type of high
+ * level service it expects to be able to use it
+ */
+ at Target({ElementType.TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ContextProvider
+{
+    public String coordinationType();
+    public String serviceType();
+    public Class contextImplementation();
+}

Added: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/HLSProvider.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/HLSProvider.java	                        (rev 0)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/utils/HLSProvider.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -0,0 +1,16 @@
+package com.arjuna.mwlabs.wscf.utils;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/** 
+ * Annotation used to tag HLS providers and identify the type of service they implement
+ */
+ at Target({ElementType.TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface HLSProvider
+{
+    String serviceType();
+}

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wsc/deploy/WSCFInitialisation.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wsc/deploy/WSCFInitialisation.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wsc/deploy/WSCFInitialisation.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -25,8 +25,6 @@
 
 import com.arjuna.mw.wsas.utils.Configuration;
 import com.arjuna.mw.wscf.logging.wscfLogger;
-import com.arjuna.mwlabs.wsc.ContextFactoryMapperImple;
-import com.arjuna.wsc.ContextFactoryMapper;
 import com.arjuna.services.framework.startup.Sequencer;
 
 /**
@@ -42,26 +40,8 @@
      */
     public void contextInitialized(final ServletContextEvent servletContextEvent)
     {
-        Sequencer.Callback callback = new Sequencer.Callback(Sequencer.SEQUENCE_WSCOOR10, Sequencer.WEBAPP_WSCF10) {
-           public void run() {
-               try
-               {
-                   Configuration.initialise("/wscf.xml");
+        // there is no WSCF initialization required so close the list
 
-                   final ContextFactoryMapper wscfImpl = ContextFactoryMapper.getFactory() ;
-
-                   wscfImpl.setSubordinateContextFactoryMapper(new ContextFactoryMapperImple());
-               }
-               catch (Exception exception) {
-                   wscfLogger.i18NLogger.error_mw_wsc_deploy_WSCFI_1(exception);
-               }
-               catch (Error error) {
-                   wscfLogger.i18NLogger.error_mw_wsc_deploy_WSCFI_1(error);
-               }
-           }
-        };
-        // this is the last WSCF callback to be initialised so close the list
-
         Sequencer.close(Sequencer.SEQUENCE_WSCOOR10, Sequencer.WEBAPP_WSCF10);
     }
 

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/CoordinatorManagerFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/CoordinatorManagerFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/CoordinatorManagerFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -31,26 +31,17 @@
 
 package com.arjuna.mw.wscf.model.sagas;
 
-import com.arjuna.mw.wscf.logging.wscfLogger;
-
 import com.arjuna.mw.wscf.model.sagas.hls.SagasHLS;
 import com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager;
 
 import com.arjuna.mw.wsas.exceptions.SystemException;
 
-import com.arjuna.mwlabs.wscf.utils.ProtocolLocator;
-
-import com.arjuna.mw.wscf.common.CoordinatorXSD;
-
 import com.arjuna.mw.wscf.protocols.*;
-import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
 
 import java.util.HashMap;
 
-import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.SagasHLSImple;
-
 /**
  * The factory to return the specific CoordinatorManager implementation.
  *
@@ -75,25 +66,7 @@
 
     public static CoordinatorManager coordinatorManager () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(SagasHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-	    
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_model_sagas_CMF_1(SagasHLSImple.className());
-        }
-	    else
-		return coordinatorManager(doc);
-	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
-
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
+        return coordinatorManager("SagasHLS");
     }
 
     /**
@@ -114,43 +87,34 @@
      * can be passed to the implementation in the same way ObjectName was.
      */
 
-    public static CoordinatorManager coordinatorManager (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static CoordinatorManager coordinatorManager (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		SagasHLS coordHLS = (SagasHLS) _implementations.get(protocolType);
-	
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
+        try
+        {
+            SagasHLS coordHLS;
 
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+            synchronized (_implementations)
+            {
+                coordHLS = (SagasHLS) _implementations.get(protocol);
 
-			coordHLS = (SagasHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (SagasHLS) implementation;
+                if (coordHLS == null) {
+	
+                    coordHLS = (SagasHLS)_protocolManager.getProtocolImplementation(protocol);
 
-		    _implementations.put(protocolType, coordHLS);
-		}
-	    
-		return coordHLS.coordinatorManager();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+                    _implementations.put(protocol, coordHLS);
+                }
+            }
+
+            return coordHLS.coordinatorManager();
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/UserCoordinatorFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/UserCoordinatorFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/sagas/UserCoordinatorFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -31,26 +31,17 @@
 
 package com.arjuna.mw.wscf.model.sagas;
 
-import com.arjuna.mw.wscf.logging.wscfLogger;
-
 import com.arjuna.mw.wscf.model.sagas.hls.SagasHLS;
 import com.arjuna.mw.wscf.model.sagas.api.UserCoordinator;
 
 import com.arjuna.mw.wsas.exceptions.SystemException;
 
-import com.arjuna.mwlabs.wscf.utils.ProtocolLocator;
-
-import com.arjuna.mw.wscf.common.CoordinatorXSD;
-
 import com.arjuna.mw.wscf.protocols.*;
-import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
 
 import java.util.HashMap;
 
-import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.SagasHLSImple;
-
 /**
  * The factory which returns the UserCoordinator implementation to use.
  *
@@ -74,27 +65,9 @@
 
     public static UserCoordinator userCoordinator () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(SagasHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-	    
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_model_sagas_UCF_1(SagasHLSImple.className());
-        }
-	    else
-		return userCoordinator(doc);
+		return userCoordinator("SagasHLS");
 	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
 
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
-    }
-
     /**
      * Obtain a reference to a coordinator that implements the specified
      * protocol.
@@ -108,48 +81,34 @@
      * @return the CoordinatorManager implementation to use.
      */
     
-    /*
-     * Have the type specified in XML. More data may be specified, which
-     * can be passed to the implementation in the same way ObjectName was.
-     */
-
-    public static UserCoordinator userCoordinator (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static UserCoordinator userCoordinator (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		SagasHLS coordHLS = (SagasHLS) _implementations.get(protocolType);
+        try
+        {
+            SagasHLS coordHLS;
+            
+            synchronized (_implementations)
+            {
+                coordHLS = (SagasHLS) _implementations.get(protocol);
 	
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
-		
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+                if (coordHLS == null)
+                {
+                    coordHLS = (SagasHLS) _protocolManager.getProtocolImplementation(protocol);
 
-			coordHLS = (SagasHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (SagasHLS) implementation;
+                    _implementations.put(protocol, coordHLS);
+                }
+            }
 
-		    _implementations.put(protocolType, coordHLS);
-		}
-	    
-		return coordHLS.userCoordinator();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+            return coordHLS.userCoordinator();
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/CoordinatorManagerFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/CoordinatorManagerFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/CoordinatorManagerFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -31,26 +31,17 @@
 
 package com.arjuna.mw.wscf.model.twophase;
 
-import com.arjuna.mw.wscf.logging.wscfLogger;
-
 import com.arjuna.mw.wscf.model.twophase.hls.TwoPhaseHLS;
 import com.arjuna.mw.wscf.model.twophase.api.CoordinatorManager;
 
 import com.arjuna.mw.wsas.exceptions.SystemException;
 
-import com.arjuna.mwlabs.wscf.utils.ProtocolLocator;
-
-import com.arjuna.mw.wscf.common.CoordinatorXSD;
-
 import com.arjuna.mw.wscf.protocols.*;
-import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
 
 import java.util.HashMap;
 
-import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.TwoPhaseHLSImple;
-
 /**
  * The factory to return the specific CoordinatorManager implementation.
  *
@@ -74,27 +65,9 @@
 
     public static CoordinatorManager coordinatorManager () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(TwoPhaseHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-	    
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_model_twophase_CMF_1(TwoPhaseHLSImple.className());
-        }
-	    else
-		return coordinatorManager(doc);
+		return coordinatorManager("TwoPhaseHLS");
 	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
 
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
-    }
-
     /**
      * Obtain a reference to a coordinator that implements the specified
      * protocol.
@@ -113,43 +86,34 @@
      * can be passed to the implementation in the same way ObjectName was.
      */
 
-    public static CoordinatorManager coordinatorManager (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static CoordinatorManager coordinatorManager (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		TwoPhaseHLS coordHLS = (TwoPhaseHLS) _implementations.get(protocolType);
+        try
+        {
+            TwoPhaseHLS coordHLS;
+            
+            synchronized (_implementations)
+            {
+                coordHLS = (TwoPhaseHLS) _implementations.get(protocol);
 	
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
+                if (coordHLS == null)
+                {
+                    coordHLS = (TwoPhaseHLS) _protocolManager.getProtocolImplementation(protocol);
 
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
-
-			coordHLS = (TwoPhaseHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (TwoPhaseHLS) implementation;
-
-		    _implementations.put(protocolType, coordHLS);
-		}
+                    _implementations.put(protocol, coordHLS);
+                }
 	    
-		return coordHLS.coordinatorManager();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+                return coordHLS.coordinatorManager();
+            }
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/UserCoordinatorFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/UserCoordinatorFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mw/wscf/model/twophase/UserCoordinatorFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -31,26 +31,17 @@
 
 package com.arjuna.mw.wscf.model.twophase;
 
-import com.arjuna.mw.wscf.logging.wscfLogger;
-
 import com.arjuna.mw.wscf.model.twophase.hls.TwoPhaseHLS;
 import com.arjuna.mw.wscf.model.twophase.api.UserCoordinator;
 
 import com.arjuna.mw.wsas.exceptions.SystemException;
 
-import com.arjuna.mwlabs.wscf.utils.ProtocolLocator;
-
-import com.arjuna.mw.wscf.common.CoordinatorXSD;
-
 import com.arjuna.mw.wscf.protocols.*;
-import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
 
 import java.util.HashMap;
 
-import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.TwoPhaseHLSImple;
-
 /**
  * The factory which returns the UserCoordinator implementation to use.
  *
@@ -74,27 +65,9 @@
 
     public static UserCoordinator userCoordinator () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(TwoPhaseHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-	    
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_model_twophase_UCF_1(TwoPhaseHLSImple.className());
-        }
-	    else
-		return userCoordinator(doc);
+		return userCoordinator("TwoPhaseHLS");
 	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
 
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
-    }
-
     /**
      * Obtain a reference to a coordinator that implements the specified
      * protocol.
@@ -108,48 +81,34 @@
      * @return the CoordinatorManager implementation to use.
      */
     
-    /*
-     * Have the type specified in XML. More data may be specified, which
-     * can be passed to the implementation in the same way ObjectName was.
-     */
-
-    public static UserCoordinator userCoordinator (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static UserCoordinator userCoordinator (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		TwoPhaseHLS coordHLS = (TwoPhaseHLS) _implementations.get(protocolType);
+        try
+        {
+            TwoPhaseHLS coordHLS;
+
+            synchronized (_implementations)
+            {
+                coordHLS = (TwoPhaseHLS) _implementations.get(protocol);
 	
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
-		
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+                if (coordHLS == null)
+                {
+                    coordHLS = (TwoPhaseHLS) _protocolManager.getProtocolImplementation(protocol);
 
-			coordHLS = (TwoPhaseHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (TwoPhaseHLS) implementation;
-
-		    _implementations.put(protocolType, coordHLS);
-		}
+                    _implementations.put(protocol, coordHLS);
+                }
+            }
 	    
-		return coordHLS.userCoordinator();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+            return coordHLS.userCoordinator();
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Deleted: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wsc/ContextFactoryMapperImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wsc/ContextFactoryMapperImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wsc/ContextFactoryMapperImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -1,180 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a full listing 
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2002,
- *
- * Arjuna Technologies Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: ContextFactoryMapperImple.java,v 1.12.4.1 2005/11/22 10:34:09 kconner Exp $
- */
-
-package com.arjuna.mwlabs.wsc;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import com.arjuna.mw.wscf.common.CoordinatorXSD;
-import com.arjuna.mw.wscf.protocols.ProtocolManager;
-import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
-import com.arjuna.wsc.ContextFactory;
-import com.arjuna.wsc.ContextFactoryMapper;
-
-/**
- * @author Mark Little (mark.little at arjuna.com)
- * @version $Id: ContextFactoryMapperImple.java,v 1.11 2004/08/10 15:10:27
- *          kconner Exp $
- * @since 1.0.
- */
-
-public class ContextFactoryMapperImple extends ContextFactoryMapper
-{
-
-	public ContextFactoryMapperImple()
-	{
-		_protocols = ProtocolRegistry.createManager();
-	}
-                                                      
-	public void addContextFactory (String coordinationTypeURI, ContextFactory contextFactory)
-	{
-		try
-		{
-			_protocols.addProtocol(convert(coordinationTypeURI), contextFactory);
-
-			contextFactory.install(coordinationTypeURI);
-		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-		}
-	}
-
-	public void removeContextFactory (String coordinationTypeURI)
-	{
-		try
-		{
-			ContextFactory contextFactory = (ContextFactory) _protocols.removeProtocol(convert(coordinationTypeURI));
-
-			contextFactory.uninstall(coordinationTypeURI);
-		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-		}
-	}
-
-	/*
-	 * The factory implementation must initialise the activity service with the
-	 * correct HLS.
-	 */
-
-	public ContextFactory getContextFactory (String coordinationTypeURI)
-	{
-		try
-		{
-			org.w3c.dom.Document doc = convert(coordinationTypeURI);
-            // get and replace have to happen atomically
-            synchronized (_protocols) {
-                Object type = _protocols.getProtocolImplementation(convert(coordinationTypeURI));
-
-                if (type instanceof String)
-                {
-                    Class c = Class.forName((String) type);
-
-                    ContextFactory factory = (ContextFactory) c.newInstance();
-
-                    _protocols.replaceProtocol(doc, factory);
-
-                    return factory;
-                }
-                else
-                {
-                    return (ContextFactory) type;
-                }
-            }
-		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-		}
-
-		return null;
-	}
-
-	public void setSubordinateContextFactoryMapper (ContextFactoryMapper subordinateContextFactoryMapper)
-	{
-	}
-
-	public ContextFactoryMapper getSubordinateContextFactoryMapper ()
-	{
-		return null;
-	}
-
-	public void setDefaultContextFactory (ContextFactory defaultContextFactory)
-	{
-	}
-
-	public ContextFactory getDefaultContextFactory ()
-	{
-		return null;
-	}
-
-	private org.w3c.dom.Document convert (String coordinationTypeURI)
-			throws Exception
-	{
-		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-		DocumentBuilder builder = factory.newDocumentBuilder();
-		org.w3c.dom.Document doc = builder.newDocument();
-		org.w3c.dom.Element rootElement = doc.createElement(_wscRootElement);
-		org.w3c.dom.Element elem = doc.createElement(CoordinatorXSD.coordinatorType);
-
-		elem.appendChild(doc.createTextNode(coordinationTypeURI));
-
-		rootElement.appendChild(elem);
-
-		doc.appendChild(rootElement);
-
-		return doc;
-	}
-
-	private void writeObject (java.io.ObjectOutputStream objectOutputStream)
-			throws java.io.IOException
-	{
-	}
-
-	private void readObject (java.io.ObjectInputStream objectInputStream)
-			throws java.io.IOException, ClassNotFoundException
-	{
-	}
-
-	public static final String localName ()
-	{
-		// return "com/arjuna/mwlabs/wsc/contextfactorymapper";
-		return "comarjunamwlabswsccontextfactorymapper";
-	}
-
-	private ProtocolManager _protocols;
-
-	private static final String _wscRootElement = "WS-C";
-
-}

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/SagasHLSImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/SagasHLSImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/SagasHLSImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -34,8 +34,6 @@
 import com.arjuna.mw.wscf.model.sagas.api.*;
 import com.arjuna.mw.wscf.model.sagas.hls.SagasHLS;
 
-import com.arjuna.mw.wscf.common.Environment;
-
 import com.arjuna.mw.wsas.context.soap.SOAPContext;
 
 import com.arjuna.mw.wscf.common.Qualifier;
@@ -58,7 +56,12 @@
 import com.arjuna.mw.wsas.exceptions.HLSError;
 
 import com.arjuna.mw.wscf.exceptions.*;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
+import com.arjuna.mwlabs.wscf.utils.HLSProvider;
 
+import java.lang.annotation.Annotation;
+
 /**
  * The ArjunaCore coordination service implementation.
  *
@@ -67,8 +70,11 @@
  * @since 1.0.
  */
 
+ at HLSProvider(serviceType = SagasHLSImple.serviceType)
 public class SagasHLSImple implements SagasHLS, UserCoordinatorService
 {
+    public final static String serviceType = "SagasHLS";
+    public final static String coordinationType = "http://schemas.xmlsoap.org/ws/2004/10/wsba/AtomicOutcome";
 
     public SagasHLSImple ()
     {
@@ -157,7 +163,7 @@
 
     public String identity () throws SystemException
     {
-	return "SagasHLS";
+	return serviceType;
     }
 
     /**
@@ -196,26 +202,49 @@
 
     public Context context () throws SystemException
     {
-        if (CONTEXT_IMPLE_NAME != null) {
-            if (CONTEXT_IMPLE_CLASS != null) {
-                try {
-                    SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
+        ensureContextInitialised();
+        if (CONTEXT_IMPLE_CLASS != null) {
+            try {
+                SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
 
-                    ctx.initialiseContext(_coordManager.currentCoordinator());
+                ctx.initialiseContext(_coordManager.currentCoordinator());
 
-                    return ctx;
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                    throw new SystemException(ex.toString());
-                }
-            } else {
-                throw new SystemException("Unable to create SOAPContext for SAGAS context implementation from class" + CONTEXT_IMPLE_NAME);
+                return ctx;
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                throw new SystemException(ex.toString());
             }
         } else {
-            throw new SystemException("SAGAS context implementation must be specified by setting environment property " + Environment.SAGAS_CONTEXT);
+            throw new SystemException("Unable to create SOAPContext for SAGAS service");
         }
     }
 
+    private void ensureContextInitialised() throws SystemException
+    {
+        if (!initialised) {
+            synchronized(this) {
+                if (!initialised) {
+                    // we  only do this once no matter what happens
+                    initialised = true;
+                    try {
+                        Class<?> factoryClass = ProtocolRegistry.sharedManager().getProtocolImplementation(coordinationType).getClass();
+                        ContextProvider contextProvider = factoryClass.getAnnotation(ContextProvider.class);
+                        String providerServiceType = contextProvider.serviceType();
+                        if (!providerServiceType.equals(serviceType)) {
+                            throw new SystemException("Invalid serviceType for SOAPContext factory registered for SAGAS service expecting " + serviceType + " got " + providerServiceType);
+                        }
+                        Class contextClass = contextProvider.contextImplementation();
+                        if (!SOAPContext.class.isAssignableFrom(contextClass)) {
+                            throw new SystemException("SOAPContext factory registered for SAGAS service provides invalid context implementation");
+                        }
+                        CONTEXT_IMPLE_CLASS = contextClass;
+                    } catch (ProtocolNotRegisteredException pnre) {
+                        throw new SystemException("No SOAPContext factory registered for SAGAS service");
+                    }
+                }
+            }
+        }
+    }
     /**
      * If the application requires and if the coordination protocol supports
      * it, then this method can be used to execute a coordination protocol on
@@ -287,17 +316,8 @@
 	return SagasHLSImple.class.getName();
     }
 
-    private final static String  CONTEXT_IMPLE_NAME = System.getProperty(Environment.SAGAS_CONTEXT);
-    private final static Class<?> CONTEXT_IMPLE_CLASS;
-    static {
-        Class<?> tmp;
-        try {
-            tmp = Class.forName(CONTEXT_IMPLE_NAME);
-        } catch (Exception ex) {
-            tmp = null;
-        }
-        CONTEXT_IMPLE_CLASS = tmp;
-    }
+    private static Class<?> CONTEXT_IMPLE_CLASS = null;
+    private static boolean initialised = false;
 
     private CoordinatorControl      _coordManager;
     private CoordinatorServiceImple _coordinatorService;

Modified: labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/TwoPhaseHLSImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/TwoPhaseHLSImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes10/com/arjuna/mwlabs/wscf/model/twophase/arjunacore/TwoPhaseHLSImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -34,8 +34,6 @@
 import com.arjuna.mw.wscf.model.twophase.api.*;
 import com.arjuna.mw.wscf.model.twophase.hls.TwoPhaseHLS;
 
-import com.arjuna.mw.wscf.common.Environment;
-
 import com.arjuna.mw.wsas.context.soap.SOAPContext;
 
 import com.arjuna.mw.wscf.common.Qualifier;
@@ -58,6 +56,9 @@
 import com.arjuna.mw.wsas.exceptions.HLSError;
 
 import com.arjuna.mw.wscf.exceptions.*;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
+import com.arjuna.mwlabs.wscf.utils.HLSProvider;
 
 /**
  * The ArjunaCore coordination service implementation.
@@ -67,8 +68,11 @@
  * @since 1.0.
  */
 
+ at HLSProvider(serviceType = TwoPhaseHLSImple.serviceType)
 public class TwoPhaseHLSImple implements TwoPhaseHLS, UserCoordinatorService
 {
+    public final static String serviceType = "TwoPhaseHLS";
+    public final static String coordinationType = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
 
 	public TwoPhaseHLSImple ()
 	{
@@ -156,7 +160,7 @@
 
 	public String identity () throws SystemException
 	{
-		return "TwoPhaseHLS";
+		return serviceType;
 	}
 
 	/**
@@ -184,27 +188,51 @@
 
     public Context context () throws SystemException
     {
-        if (CONTEXT_IMPLE_NAME != null) {
-            if (CONTEXT_IMPLE_CLASS != null) {
-                try {
-                    SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
+        ensureContextInitialised();
+        if (CONTEXT_IMPLE_CLASS != null) {
+            try {
+                SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
 
-                    ctx.initialiseContext(_coordManager.currentCoordinator());
+                ctx.initialiseContext(_coordManager.currentCoordinator());
 
-                    return ctx;
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                    throw new SystemException(ex.toString());
-                }
-            } else {
-                throw new SystemException("Unable to create SOAPContext for Two Phase 1.1 implementation from class" + CONTEXT_IMPLE_NAME);
+                return ctx;
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                throw new SystemException(ex.toString());
             }
         } else {
-            throw new SystemException("Two Phase 1.1 context implementation must be specified by setting environment property " + Environment.TWO_PHASE_CONTEXT);
+            throw new SystemException("Unable to create SOAPContext for Two Phase service");
         }
     }
 
+    private void ensureContextInitialised() throws SystemException
+    {
+        if (!initialised) {
+            synchronized(this) {
+                if  (!initialised) {
+                    // we  only do this once no matter what happens
+                    initialised = true;
+                    try {
+                        Class<?> factoryClass = ProtocolRegistry.sharedManager().getProtocolImplementation(coordinationType).getClass();
+                        ContextProvider contextProvider = factoryClass.getAnnotation(ContextProvider.class);
+                        String providerServiceType = contextProvider.serviceType();
+                        if (!providerServiceType.equals(serviceType)) {
+                            throw new SystemException("Invalid serviceType for SOAPContext factory registered for Two Phase service expecting " + serviceType + " got " + providerServiceType);
+                        }
+                        Class contextClass = contextProvider.contextImplementation();
+                        if (!SOAPContext.class.isAssignableFrom(contextClass)) {
+                            throw new SystemException("SOAPContext factory registered for Two Phase service provides invalid context implementation");
+                        }
+                        CONTEXT_IMPLE_CLASS = contextClass;
+                    } catch (ProtocolNotRegisteredException pnre) {
+                        throw new SystemException("No SOAPContext factory registered for Two Phase service");
+                    }
+                }
+            }
+        }
+    }
 
+
 	/**
 	 * If the application requires and if the coordination protocol supports it,
 	 * then this method can be used to execute a coordination protocol on the
@@ -284,17 +312,8 @@
 		return TwoPhaseHLSImple.class.getName();
 	}
 
-    private final static String  CONTEXT_IMPLE_NAME = System.getProperty(Environment.TWO_PHASE_CONTEXT);
-    private final static Class<?> CONTEXT_IMPLE_CLASS;
-    static {
-        Class<?> tmp;
-        try {
-            tmp = Class.forName(CONTEXT_IMPLE_NAME);
-        } catch (Exception ex) {
-            tmp = null;
-        }
-        CONTEXT_IMPLE_CLASS = tmp;
-    }
+    private static Class<?> CONTEXT_IMPLE_CLASS = null;
+    private static boolean initialised = false;
 
 	private CoordinatorControl _coordManager;
 	private CoordinatorServiceImple _coordinatorService;

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wsc11/deploy/WSCFInitialisation.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wsc11/deploy/WSCFInitialisation.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wsc11/deploy/WSCFInitialisation.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -22,9 +22,7 @@
 
 import com.arjuna.mw.wsas.utils.Configuration;
 import com.arjuna.mw.wscf.logging.wscfLogger;
-import com.arjuna.mwlabs.wsc11.ContextFactoryMapperImple;
 import com.arjuna.services.framework.startup.Sequencer;
-import com.arjuna.wsc11.ContextFactoryMapper;
 
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
@@ -42,26 +40,8 @@
      */
     public void contextInitialized(final ServletContextEvent servletContextEvent)
     {
-        Sequencer.Callback callback = new Sequencer.Callback(Sequencer.SEQUENCE_WSCOOR11, Sequencer.WEBAPP_WSCF11) {
-           public void run() {
-               try
-               {
-                   Configuration.initialise("/wscf11.xml");
+        // there is no WSCF initialization required so close the list
 
-                   final ContextFactoryMapper WSCFImpl = ContextFactoryMapper.getFactory() ;
-
-                   WSCFImpl.setSubordinateContextFactoryMapper(new ContextFactoryMapperImple());
-               }
-               catch (Exception exception) {
-                   wscfLogger.i18NLogger.error_mw_wsc11_deploy_WSCFI_1(exception);
-               }
-               catch (Error error)
-               {
-                   wscfLogger.i18NLogger.error_mw_wsc11_deploy_WSCFI_1(error);
-               }
-           }
-        };
-        // this is the last WSCF callback to be initialised so close the list
         Sequencer.close(Sequencer.SEQUENCE_WSCOOR11, Sequencer.WEBAPP_WSCF11);
 
     }

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/CoordinatorManagerFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/CoordinatorManagerFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/CoordinatorManagerFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -45,8 +45,8 @@
 import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
-import com.arjuna.mw.wscf11.protocols.ProtocolManager;
-import com.arjuna.mw.wscf11.protocols.ProtocolRegistry;
+import com.arjuna.mw.wscf.protocols.ProtocolManager;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 
 import java.util.HashMap;
 
@@ -76,25 +76,7 @@
 
     public static CoordinatorManager coordinatorManager () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(SagasHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_mw_wscf11_model_sagas_CMF_1(SagasHLSImple.className());
-        }
-	    else
-		return coordinatorManager(doc);
-	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
-
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
+        return coordinatorManager("Sagas11HLS");
     }
 
     /**
@@ -115,43 +97,35 @@
      * can be passed to the implementation in the same way ObjectName was.
      */
 
-    public static CoordinatorManager coordinatorManager (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static CoordinatorManager coordinatorManager (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		SagasHLS coordHLS = (SagasHLS) _implementations.get(protocolType);
+        try
+        {
+            SagasHLS coordHLS;
 
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
+            synchronized (_implementations)
+            {
+                coordHLS = (SagasHLS) _implementations.get(protocol);
 
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+                if (coordHLS == null)
+                {
+                    coordHLS = (SagasHLS) _protocolManager.getProtocolImplementation(protocol);
+                    
+                    _implementations.put(protocol, coordHLS);
+                }
+            }
 
-			coordHLS = (SagasHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (SagasHLS) implementation;
+            return coordHLS.coordinatorManager();
 
-		    _implementations.put(protocolType, coordHLS);
-		}
-
-		return coordHLS.coordinatorManager();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/UserCoordinatorFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/UserCoordinatorFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/sagas/UserCoordinatorFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -45,8 +45,8 @@
 import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
-import com.arjuna.mw.wscf11.protocols.ProtocolManager;
-import com.arjuna.mw.wscf11.protocols.ProtocolRegistry;
+import com.arjuna.mw.wscf.protocols.ProtocolManager;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 
 import java.util.HashMap;
 
@@ -75,27 +75,9 @@
 
     public static UserCoordinator userCoordinator () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(SagasHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_mw_wscf11_model_sagas_UCF_1(SagasHLSImple.className());
-        }
-	    else
-		return userCoordinator(doc);
+		return userCoordinator("Sagas11HLS");
 	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
 
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
-    }
-
     /**
      * Obtain a reference to a coordinator that implements the specified
      * protocol.
@@ -109,48 +91,34 @@
      * @return the CoordinatorManager implementation to use.
      */
 
-    /*
-     * Have the type specified in XML. More data may be specified, which
-     * can be passed to the implementation in the same way ObjectName was.
-     */
-
-    public static UserCoordinator userCoordinator (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static UserCoordinator userCoordinator (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		SagasHLS coordHLS = (SagasHLS) _implementations.get(protocolType);
+        try
+        {
+            SagasHLS coordHLS;
 
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
+            synchronized (_implementations)
+            {
+                coordHLS = (SagasHLS) _implementations.get(protocol);
 
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+                if (coordHLS == null)
+                {
+                    coordHLS = (SagasHLS) _protocolManager.getProtocolImplementation(protocol);
 
-			coordHLS = (SagasHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (SagasHLS) implementation;
+                    _implementations.put(protocol, coordHLS);
+                }
 
-		    _implementations.put(protocolType, coordHLS);
-		}
-
-		return coordHLS.userCoordinator();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+                return coordHLS.userCoordinator();
+            }
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/CoordinatorManagerFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/CoordinatorManagerFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/CoordinatorManagerFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -45,8 +45,8 @@
 import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
-import com.arjuna.mw.wscf11.protocols.ProtocolManager;
-import com.arjuna.mw.wscf11.protocols.ProtocolRegistry;
+import com.arjuna.mw.wscf.protocols.ProtocolManager;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 
 import java.util.HashMap;
 
@@ -75,27 +75,9 @@
 
     public static CoordinatorManager coordinatorManager () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(TwoPhaseHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_mw_wscf11_model_twophase_CMF_1(TwoPhaseHLSImple.className());
-        }
-	    else
-		return coordinatorManager(doc);
+		return coordinatorManager("TwoPhase11HLS");
 	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
 
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
-    }
-
     /**
      * Obtain a reference to a coordinator that implements the specified
      * protocol.
@@ -114,43 +96,33 @@
      * can be passed to the implementation in the same way ObjectName was.
      */
 
-    public static CoordinatorManager coordinatorManager (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static CoordinatorManager coordinatorManager (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		TwoPhaseHLS coordHLS = (TwoPhaseHLS) _implementations.get(protocolType);
+        try
+        {
+            TwoPhaseHLS coordHLS;
+            synchronized (_implementations)
+            {
+                coordHLS = (TwoPhaseHLS) _implementations.get(protocol);
 
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
+                if (coordHLS == null)
+                {
+                    coordHLS = (TwoPhaseHLS) _protocolManager.getProtocolImplementation(protocol);
 
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+                    _implementations.put(protocol, coordHLS);
+                }
 
-			coordHLS = (TwoPhaseHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (TwoPhaseHLS) implementation;
-
-		    _implementations.put(protocolType, coordHLS);
-		}
-
-		return coordHLS.coordinatorManager();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+                return coordHLS.coordinatorManager();
+            }
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/UserCoordinatorFactory.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/UserCoordinatorFactory.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mw/wscf11/model/twophase/UserCoordinatorFactory.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -45,8 +45,8 @@
 import com.arjuna.mw.wscf.utils.*;
 
 import com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException;
-import com.arjuna.mw.wscf11.protocols.ProtocolManager;
-import com.arjuna.mw.wscf11.protocols.ProtocolRegistry;
+import com.arjuna.mw.wscf.protocols.ProtocolManager;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 
 import java.util.HashMap;
 
@@ -75,25 +75,7 @@
 
     public static UserCoordinator userCoordinator () throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    ProtocolLocator pl = new ProtocolLocator(TwoPhaseHLSImple.class);
-	    org.w3c.dom.Document doc = pl.getProtocol();
-
-	    if (doc == null) {
-            wscfLogger.i18NLogger.warn_mw_wscf11_model_twophase_UCF_1(TwoPhaseHLSImple.className());
-        }
-	    else
-		return userCoordinator(doc);
-	}
-	catch (Exception ex)
-	{
-	    ex.printStackTrace();
-
-	    throw new SystemException(ex.toString());
-	}
-
-	return null;
+        return userCoordinator("TwoPhase11HLS");
     }
 
     /**
@@ -109,48 +91,34 @@
      * @return the CoordinatorManager implementation to use.
      */
 
-    /*
-     * Have the type specified in XML. More data may be specified, which
-     * can be passed to the implementation in the same way ObjectName was.
-     */
-
-    public static UserCoordinator userCoordinator (org.w3c.dom.Document protocol) throws ProtocolNotRegisteredException, SystemException
+    public static UserCoordinator userCoordinator (String protocol) throws ProtocolNotRegisteredException, SystemException
     {
-	try
-	{
-	    synchronized (_implementations)
-	    {
-		org.w3c.dom.Text child = DomUtil.getTextNode(protocol, CoordinatorXSD.coordinatorType);
-		String protocolType = child.getNodeValue();
-		TwoPhaseHLS coordHLS = (TwoPhaseHLS) _implementations.get(protocolType);
+        try
+        {
+            TwoPhaseHLS coordHLS;
 
-		if (coordHLS == null)
-		{
-		    Object implementation = _protocolManager.getProtocolImplementation(protocol);
+            synchronized (_implementations)
+            {
+                coordHLS = (TwoPhaseHLS) _implementations.get(protocol);
 
-		    if (implementation instanceof String)
-		    {
-			Class c = Class.forName((String) implementation);
+                if (coordHLS == null)
+                {
+                    coordHLS = (TwoPhaseHLS) _protocolManager.getProtocolImplementation(protocol);
 
-			coordHLS = (TwoPhaseHLS) c.newInstance();
-		    }
-		    else
-			coordHLS = (TwoPhaseHLS) implementation;
+                    _implementations.put(protocol, coordHLS);
+                }
 
-		    _implementations.put(protocolType, coordHLS);
-		}
-
-		return coordHLS.userCoordinator();
-	    }
-	}
-	catch (ProtocolNotRegisteredException ex)
-	{
-	    throw ex;
-	}
-	catch (Exception ex)
-	{
-	    throw new SystemException(ex.toString());
-	}
+                return coordHLS.userCoordinator();
+            }
+        }
+        catch (ProtocolNotRegisteredException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new SystemException(ex.toString());
+        }
     }
 
     private static ProtocolManager _protocolManager = ProtocolRegistry.sharedManager();

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/sagas/arjunacore/SagasHLSImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/sagas/arjunacore/SagasHLSImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/sagas/arjunacore/SagasHLSImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -34,7 +34,7 @@
 import com.arjuna.mw.wscf.model.sagas.api.*;
 import com.arjuna.mw.wscf.model.sagas.hls.SagasHLS;
 
-import com.arjuna.mw.wscf11.common.Environment;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 
 import com.arjuna.mw.wsas.context.soap.SOAPContext;
 
@@ -60,6 +60,8 @@
 import com.arjuna.mw.wscf.exceptions.*;
 import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.CoordinatorServiceImple;
 import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.CoordinatorControl;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
+import com.arjuna.mwlabs.wscf.utils.HLSProvider;
 
 /**
  * The ArjunaCore coordination service implementation.
@@ -69,8 +71,11 @@
  * @since 1.0.
  */
 
+ at HLSProvider(serviceType = SagasHLSImple.serviceType)
 public class SagasHLSImple implements SagasHLS, UserCoordinatorService
 {
+    public final static String serviceType = "Sagas11HLS";
+    public final static String coordinationType = "http://docs.oasis-open.org/ws-tx/wsba/2006/06/AtomicOutcome";
 
     public SagasHLSImple()
     {
@@ -159,7 +164,7 @@
 
     public String identity () throws SystemException
     {
-        return "Sagas11HLS";
+        return serviceType;
     }
 
     /**
@@ -187,26 +192,49 @@
 
     public Context context () throws SystemException
     {
-        if (CONTEXT_IMPLE_NAME != null) {
-            if (CONTEXT_IMPLE_CLASS != null) {
-                try {
-                    SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
+        ensureContextInitialised();
+        if (CONTEXT_IMPLE_CLASS != null) {
+            try {
+                SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
 
-                    ctx.initialiseContext(_coordManager.currentCoordinator());
+                ctx.initialiseContext(_coordManager.currentCoordinator());
 
-                    return ctx;
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                    throw new SystemException(ex.toString());
-                }
-            } else {
-                throw new SystemException("Unable to create SOAPContext for SAGAS 1.1 context implementation from class" + CONTEXT_IMPLE_NAME);
+                return ctx;
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                throw new SystemException(ex.toString());
             }
         } else {
-            throw new SystemException("SAGAS 1.1 context implementation must be specified by setting environment property " + Environment.SAGAS_CONTEXT);
+            throw new SystemException("Unable to create SOAPContext for SAGAS 1.1 service");
         }
     }
 
+    private void ensureContextInitialised() throws SystemException
+    {
+        if (!initialised) {
+            synchronized(this) {
+                if (!initialised) {
+                    // we  only do this once no matter what happens
+                    initialised = true;
+                    try {
+                        Class<?> factoryClass = ProtocolRegistry.sharedManager().getProtocolImplementation(coordinationType).getClass();
+                        ContextProvider contextProvider = factoryClass.getAnnotation(ContextProvider.class);
+                        String providerServiceType = contextProvider.serviceType();
+                        if (!providerServiceType.equals(serviceType)) {
+                            throw new SystemException("Invalid serviceType for SOAPContext factory registered for SAGAS 1.1 service expecting " + serviceType + " got " + providerServiceType);
+                        }
+                        Class contextClass = contextProvider.contextImplementation();
+                        if (!SOAPContext.class.isAssignableFrom(contextClass)) {
+                            throw new SystemException("SOAPContext factory registered for SAGAS 1.1 service provides invalid context implementation");
+                        }
+                        CONTEXT_IMPLE_CLASS = contextClass;
+                    } catch (ProtocolNotRegisteredException pnre) {
+                        throw new SystemException("No SOAPContext factory registered for SAGAS 1.1 service");
+                    }
+                }
+            }
+        }
+    }
     /**
      * If the application requires and if the coordination protocol supports
      * it, then this method can be used to execute a coordination protocol on
@@ -278,17 +306,8 @@
     	return SagasHLSImple.class.getName();
     }
 
-    private final static String  CONTEXT_IMPLE_NAME = System.getProperty(Environment.SAGAS_CONTEXT);
-    private final static Class<?> CONTEXT_IMPLE_CLASS;
-    static {
-        Class<?> tmp;
-        try {
-            tmp = Class.forName(CONTEXT_IMPLE_NAME);
-        } catch (Exception ex) {
-            tmp = null;
-        }
-        CONTEXT_IMPLE_CLASS = tmp;
-    }
+    private static Class<?> CONTEXT_IMPLE_CLASS = null;
+    private static boolean initialised = false;
 
     private CoordinatorControl      _coordManager;
     private CoordinatorServiceImple _coordinatorService;

Modified: labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/twophase/arjunacore/TwoPhaseHLSImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/twophase/arjunacore/TwoPhaseHLSImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSCF/classes11/com/arjuna/mwlabs/wscf11/model/twophase/arjunacore/TwoPhaseHLSImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -34,7 +34,7 @@
 import com.arjuna.mw.wscf.model.twophase.api.*;
 import com.arjuna.mw.wscf.model.twophase.hls.TwoPhaseHLS;
 
-import com.arjuna.mw.wscf11.common.Environment;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 
 import com.arjuna.mw.wsas.context.soap.SOAPContext;
 
@@ -60,6 +60,8 @@
 import com.arjuna.mw.wscf.exceptions.*;
 import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorServiceImple;
 import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorControl;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
+import com.arjuna.mwlabs.wscf.utils.HLSProvider;
 
 /**
  * The ArjunaCore coordination service implementation.
@@ -69,8 +71,11 @@
  * @since 1.0.
  */
 
+ at HLSProvider(serviceType = TwoPhaseHLSImple.serviceType)
 public class TwoPhaseHLSImple implements TwoPhaseHLS, UserCoordinatorService
 {
+    public final static String serviceType = "TwoPhase11HLS";
+    public final static String coordinationType = "http://docs.oasis-open.org/ws-tx/wsat/2006/06";
 
 	public TwoPhaseHLSImple()
 	{
@@ -158,7 +163,7 @@
 
 	public String identity () throws SystemException
 	{
-		return "TwoPhase11HLS";
+		return serviceType;
 	}
 
 	/**
@@ -186,26 +191,50 @@
 
     public Context context () throws SystemException
     {
-        if (CONTEXT_IMPLE_NAME != null) {
-            if (CONTEXT_IMPLE_CLASS != null) {
-                try {
-                    SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
+        ensureContextInitialised();
+        if (CONTEXT_IMPLE_CLASS != null) {
+            try {
+                SOAPContext ctx = (SOAPContext) CONTEXT_IMPLE_CLASS.newInstance();
 
-                    ctx.initialiseContext(_coordManager.currentCoordinator());
+                ctx.initialiseContext(_coordManager.currentCoordinator());
 
-                    return ctx;
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                    throw new SystemException(ex.toString());
-                }
-            } else {
-                throw new SystemException("Unable to create SOAPContext for Two Phase 1.1 implementation from class" + CONTEXT_IMPLE_NAME);
+                return ctx;
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                throw new SystemException(ex.toString());
             }
         } else {
-            throw new SystemException("Two Phase 1.1 context implementation must be specified by setting environment property " + Environment.TWO_PHASE_CONTEXT);
+            throw new SystemException("Unable to create SOAPContext for Two Phase 1.1 service");
         }
     }
 
+    private void ensureContextInitialised() throws SystemException
+    {
+        if (!initialised) {
+            synchronized(this) {
+                if (!initialised) {
+                    // we  only do this once no matter what happens
+                    initialised = true;
+                    try {
+                        Class<?> factoryClass = ProtocolRegistry.sharedManager().getProtocolImplementation(coordinationType).getClass();
+                        ContextProvider contextProvider = factoryClass.getAnnotation(ContextProvider.class);
+                        String providerServiceType = contextProvider.serviceType();
+                        if (!providerServiceType.equals(serviceType)) {
+                            throw new SystemException("Invalid serviceType for SOAPContext factory registered for Two Phase 1.1 service expecting " + serviceType + " got " + providerServiceType);
+                        }
+                        Class contextClass = contextProvider.contextImplementation();
+                        if (!SOAPContext.class.isAssignableFrom(contextClass)) {
+                            throw new SystemException("SOAPContext factory registered for Two Phase 1.1 service provides invalid context implementation");
+                        }
+                        CONTEXT_IMPLE_CLASS = contextClass;
+                    } catch (ProtocolNotRegisteredException pnre) {
+                        throw new SystemException("No SOAPContext factory registered for Two Phase 1.1 service");
+                    }
+                }
+            }
+        }
+    }
+
 	/**
 	 * If the application requires and if the coordination protocol supports it,
 	 * then this method can be used to execute a coordination protocol on the
@@ -285,17 +314,8 @@
 		return TwoPhaseHLSImple.class.getName();
 	}
 
-    private final static String  CONTEXT_IMPLE_NAME = System.getProperty(Environment.TWO_PHASE_CONTEXT);
-    private final static Class<?> CONTEXT_IMPLE_CLASS;
-    static {
-        Class<?> tmp;
-        try {
-            tmp = Class.forName(CONTEXT_IMPLE_NAME);
-        } catch (Exception ex) {
-            tmp = null;
-        }
-        CONTEXT_IMPLE_CLASS = tmp;
-    }
+    private static Class<?> CONTEXT_IMPLE_CLASS = null;
+    private static boolean initialised = false;
 
 	private CoordinatorControl _coordManager;
 	private CoordinatorServiceImple _coordinatorService;

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mw/wst/deploy/WSTXInitialisation.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mw/wst/deploy/WSTXInitialisation.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mw/wst/deploy/WSTXInitialisation.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -47,11 +47,6 @@
 public class WSTXInitialisation implements ServletContextListener
 {
     /**
-     * The name of the WS-T configuration.
-     */
-    private static final String WS_T_CONFIG = "/wst.xml" ;
-    
-    /**
      * The context has been initialized.
      * @param servletContextEvent The servlet context event.
      * 
@@ -64,8 +59,6 @@
            public void run() {
                try
                {
-                   Configuration.initialise("/wstx.xml");
-
                    // ok, if we just loaded a coordinator URL and one was already defined on
                    // the command line then reinstate the command line version
                    String commandLineCoordinatrURL  = System.getProperty(com.arjuna.wsc.common.Environment.XTS_COMMAND_LINE_COORDINATOR_URL);
@@ -100,28 +93,11 @@
         throws Exception
     {
         // mostly original JNDI binder code.  Should be tidied up.
-        final InputStream is = ClassLoaderHelper.getResourceAsStream(getClass(), WS_T_CONFIG) ;
+        final String userTx = System.getProperty("org.jboss.jbossts.xts.wsat.UserTransaction");
+        final String txManager = System.getProperty("org.jboss.jbossts.xts.wsat.TransactionManager") ;
+        final String userBa = System.getProperty("org.jboss.jbossts.xts.wsba.UserBusinessActivity") ;
+        final String baManager = System.getProperty("org.jboss.jbossts.xts.wsba.BusinessActivityManager") ;
 
-        if (is == null)
-        {
-            throw new FileNotFoundException(wstxLogger.i18NLogger.get_mw_wst_deploy_WSTXI_21(WS_T_CONFIG));
-        }
-        
-        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;
-        final DocumentBuilder builder = factory.newDocumentBuilder() ;
-        final Document doc = builder.parse(is);
-
-        if (doc == null)
-        {
-            throw new FileNotFoundException(wstxLogger.i18NLogger.get_mw_wst_deploy_WSTXI_22(WS_T_CONFIG));
-        }
-
-        final Element docElem = doc.getDocumentElement() ;
-        final String userTx = getService(docElem, "UserTransaction") ;
-        final String txManager = getService(docElem, "TransactionManager") ;
-        final String userBa = getService(docElem, "UserBusinessActivity") ;
-        final String baManager = getService(docElem, "BusinessActivityManager") ;
-
         if ((userTx == null) || (txManager == null) || (userBa == null) || (baManager == null))
         {
             throw new FileNotFoundException(wstxLogger.i18NLogger.get_mw_wst_deploy_WSTXI_23());

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/ContextFactoryImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/ContextFactoryImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/ContextFactoryImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -43,6 +43,7 @@
 import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator;
 import com.arjuna.mwlabs.wst.at.context.ArjunaContextImple;
 import com.arjuna.mwlabs.wst.at.participants.CleanupSynchronization;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
 import com.arjuna.webservices.SoapRegistry;
 import com.arjuna.webservices.stax.URI;
 import com.arjuna.webservices.wsaddr.AttributedURIType;
@@ -53,10 +54,7 @@
 import com.arjuna.webservices.wscoor.AttributedUnsignedIntType;
 import com.arjuna.webservices.wscoor.CoordinationConstants;
 import com.arjuna.webservices.wscoor.CoordinationContextType;
-import com.arjuna.wsc.ContextFactory;
-import com.arjuna.wsc.InvalidCreateParametersException;
-import com.arjuna.wsc.InvalidProtocolException;
-import com.arjuna.wsc.RegistrationCoordinator;
+import com.arjuna.wsc.*;
 import com.arjuna.wsc.messaging.MessageId;
 import com.arjuna.wst.Volatile2PCParticipant;
 import com.arjuna.wst.Durable2PCParticipant;
@@ -64,6 +62,9 @@
 import com.arjuna.wst.stub.SubordinateDurable2PCStub;
 import com.arjuna.wst.messaging.engines.ParticipantEngine;
 
+ at ContextProvider(coordinationType = ArjunaContextImple.coordinationType,
+        serviceType = ArjunaContextImple.serviceType,
+        contextImplementation = ArjunaContextImple.class)
 public class ContextFactoryImple implements ContextFactory, LocalFactory
 {
 	public ContextFactoryImple ()
@@ -73,6 +74,10 @@
 			_coordManager = CoordinatorManagerFactory.coordinatorManager();
 
             _theRegistrar = new RegistrarImple();
+
+            // install the factory for the mapper to locate
+
+            ContextFactoryMapper.getMapper().addContextFactory(ArjunaContextImple.coordinationType, this);
 		}
 		catch (Exception ex)
 		{
@@ -134,7 +139,7 @@
                     timeout = (timeoutVal > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)timeoutVal) ;
                 }
 
-				_coordManager.begin("TwoPhaseHLS", timeout);
+				_coordManager.begin(ArjunaContextImple.serviceType, timeout);
 				
                 final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext() ;
                 final SoapRegistry soapRegistry = SoapRegistry.getRegistry() ;
@@ -315,5 +320,4 @@
 
 	private CoordinatorManager _coordManager;
 	private RegistrarImple _theRegistrar;
-
 }

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/SubordinateImporter.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/SubordinateImporter.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/SubordinateImporter.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -21,7 +21,7 @@
     /**
      * handle on the local 1.1 context factory implementation
      */
-    private static ContextFactoryImple atContextFactory = (ContextFactoryImple) ContextFactoryMapper.getFactory().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
+    private static ContextFactoryImple atContextFactory = (ContextFactoryImple) ContextFactoryMapper.getMapper().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
 
     public static TxContext importContext(CoordinationContextType cc)
     {

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/context/ArjunaContextImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/context/ArjunaContextImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/at/context/ArjunaContextImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -58,6 +58,8 @@
 
 public class ArjunaContextImple implements SOAPContext
 {
+    public static final String serviceType = "TwoPhaseHLS";
+    public static final String coordinationType = AtomicTransactionConstants.WSAT_PROTOCOL;
 
 	public ArjunaContextImple ()
 	{
@@ -219,7 +221,7 @@
     public static ArjunaContextImple getContext()
     {
         ContextManager cxman = new ContextManager();
-        Context context = cxman.context("TwoPhaseHLS");
+        Context context = cxman.context(serviceType);
 
         if (context instanceof ArjunaContextImple)
         {

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/ContextFactoryImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/ContextFactoryImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/ContextFactoryImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -35,6 +35,7 @@
 import com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager;
 import com.arjuna.mw.wstx.logging.wstxLogger;
 import com.arjuna.mwlabs.wst.ba.context.ArjunaContextImple;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
 import com.arjuna.webservices.SoapRegistry;
 import com.arjuna.webservices.stax.URI;
 import com.arjuna.webservices.wsaddr.AttributedURIType;
@@ -46,11 +47,14 @@
 import com.arjuna.webservices.wscoor.CoordinationConstants;
 import com.arjuna.webservices.wscoor.CoordinationContextType;
 import com.arjuna.wsc.ContextFactory;
+import com.arjuna.wsc.ContextFactoryMapper;
 import com.arjuna.wsc.InvalidCreateParametersException;
 
+ at ContextProvider(coordinationType = ArjunaContextImple.coordinationType,
+        serviceType = ArjunaContextImple.serviceType,
+        contextImplementation = ArjunaContextImple.class)
 public class ContextFactoryImple implements ContextFactory
 {
-
     public ContextFactoryImple ()
     {
         try
@@ -58,6 +62,10 @@
             _coordManager = CoordinatorManagerFactory.coordinatorManager();
 
             _theRegistrar = new RegistrarImple();
+
+            // install the factory for the mapper to locate
+
+            ContextFactoryMapper.getMapper().addContextFactory(ArjunaContextImple.coordinationType, this);
         }
         catch (Exception ex)
         {
@@ -121,7 +129,7 @@
                 timeout = (longTimeout > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)longTimeout) ;
             }
     		
-    		_coordManager.begin("SagasHLS", timeout);
+    		_coordManager.begin(ArjunaContextImple.serviceType, timeout);
     
             final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext() ;
             final SoapRegistry soapRegistry = SoapRegistry.getRegistry() ;
@@ -199,5 +207,4 @@
 
     private CoordinatorManager                   _coordManager;
     private RegistrarImple                       _theRegistrar;
-    
 }

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/context/ArjunaContextImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/context/ArjunaContextImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/context/ArjunaContextImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -58,6 +58,8 @@
 
 public class ArjunaContextImple implements SOAPContext
 {
+    public static final String serviceType = "SagasHLS";
+    public static final String coordinationType = BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME;
 
     public ArjunaContextImple ()
     {
@@ -218,7 +220,7 @@
     public static ArjunaContextImple getContext()
     {
         ContextManager cxman = new ContextManager();
-        Context context = cxman.context("SagasHLS");
+        Context context = cxman.context(serviceType);
 
         if (context instanceof ArjunaContextImple)
         {

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mw/wst11/deploy/WSTXInitialisation.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mw/wst11/deploy/WSTXInitialisation.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mw/wst11/deploy/WSTXInitialisation.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -45,11 +45,6 @@
 public class WSTXInitialisation implements ServletContextListener
 {
     /**
-     * The name of the WS-T configuration.
-     */
-    private static final String WS_T11_CONFIG = "/wst11.xml" ;
-
-    /**
      * The context has been initialized.
      * @param servletContextEvent The servlet context event.
      *
@@ -62,8 +57,6 @@
            public void run() {
                try
                {
-                   Configuration.initialise("/wstx11.xml");
-
                    fixCoordinatorURL();
 
                    listener.configure();
@@ -90,29 +83,11 @@
     private void configure()
         throws Exception
     {
-        // mostly original JNDI binder code.  Should be tidied up.
-        final InputStream is = ClassLoaderHelper.getResourceAsStream(getClass(), WS_T11_CONFIG) ;
+        final String userTx = System.getProperty("org.jboss.jbossts.xts.wsat11.UserTransaction");
+        final String txManager = System.getProperty("org.jboss.jbossts.xts.wsat11.TransactionManager") ;
+        final String userBa = System.getProperty("org.jboss.jbossts.xts.wsba11.UserBusinessActivity") ;
+        final String baManager = System.getProperty("org.jboss.jbossts.xts.wsba11.BusinessActivityManager") ;
 
-        if (is == null)
-        {
-            throw new FileNotFoundException(wstxLogger.i18NLogger.get_mw_wst11_deploy_WSTXI_21(WS_T11_CONFIG));
-        }
-
-        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;
-        final DocumentBuilder builder = factory.newDocumentBuilder() ;
-        final Document doc = builder.parse(is);
-
-        if (doc == null)
-        {
-            throw new FileNotFoundException(wstxLogger.i18NLogger.get_mw_wst11_deploy_WSTXI_22(WS_T11_CONFIG));
-        }
-
-        final Element docElem = doc.getDocumentElement() ;
-        final String userTx = getService(docElem, "UserTransaction") ;
-        final String txManager = getService(docElem, "TransactionManager") ;
-        final String userBa = getService(docElem, "UserBusinessActivity") ;
-        final String baManager = getService(docElem, "BusinessActivityManager") ;
-
         if ((userTx == null) || (txManager == null) || (userBa == null) || (baManager == null))
         {
             throw new FileNotFoundException(wstxLogger.i18NLogger.get_mw_wst11_deploy_WSTXI_23());

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -41,6 +41,7 @@
 import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorControl;
 import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorServiceImple;
 import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
 import com.arjuna.mwlabs.wst11.at.context.ArjunaContextImple;
 import com.arjuna.mwlabs.wst11.at.participants.CleanupSynchronization;
 import com.arjuna.webservices11.wsat.AtomicTransactionConstants;
@@ -49,6 +50,7 @@
 import com.arjuna.webservices11.wscoor.CoordinationConstants;
 import com.arjuna.webservices11.ServiceRegistry;
 import com.arjuna.wsc11.ContextFactory;
+import com.arjuna.wsc11.ContextFactoryMapper;
 import com.arjuna.wsc11.RegistrationCoordinator;
 import com.arjuna.wsc11.messaging.MessageId;
 import com.arjuna.wsc.InvalidCreateParametersException;
@@ -66,6 +68,9 @@
 import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
 import javax.xml.namespace.QName;
 
+ at ContextProvider(coordinationType = ArjunaContextImple.coordinationType,
+        serviceType = ArjunaContextImple.serviceType,
+        contextImplementation = ArjunaContextImple.class)
 public class ContextFactoryImple implements ContextFactory, LocalFactory
 {
 	public ContextFactoryImple()
@@ -75,7 +80,11 @@
 			_coordManager = CoordinatorManagerFactory.coordinatorManager();
 
             _theRegistrar = new RegistrarImple();
-		}
+
+            // install the factory for the mapper to locate
+
+            ContextFactoryMapper.getMapper().addContextFactory(ArjunaContextImple.coordinationType, this);
+        }
 		catch (Exception ex)
 		{
 			ex.printStackTrace();
@@ -136,7 +145,7 @@
                     timeout = (timeoutVal > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)timeoutVal) ;
                 }
 
-				_coordManager.begin("TwoPhase11HLS", timeout);
+				_coordManager.begin(ArjunaContextImple.serviceType, timeout);
 
                 final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext() ;
                 final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry() ;
@@ -422,4 +431,5 @@
 
 	private CoordinatorManager _coordManager;
 	private RegistrarImple _theRegistrar;
-}
\ No newline at end of file
+
+}

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/SubordinateImporter.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/SubordinateImporter.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/SubordinateImporter.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -22,7 +22,7 @@
     /**
      * handle on the local 1.1 context factory implementation
      */
-    private static ContextFactoryImple atContextFactory = (ContextFactoryImple) ContextFactoryMapper.getFactory().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
+    private static ContextFactoryImple atContextFactory = (ContextFactoryImple) ContextFactoryMapper.getMapper().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
 
     public static TxContext importContext(CoordinationContextType cc)
     {

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/context/ArjunaContextImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/context/ArjunaContextImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/context/ArjunaContextImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -57,6 +57,8 @@
 
 public class ArjunaContextImple implements SOAPContext
 {
+    public static final String serviceType = "TwoPhase11HLS";
+    public static final String coordinationType = AtomicTransactionConstants.WSAT_PROTOCOL;
 
 	public ArjunaContextImple()
 	{
@@ -221,7 +223,7 @@
     public static ArjunaContextImple getContext()
     {
         ContextManager cxman = new ContextManager();
-        Context context = cxman.context("TwoPhase11HLS");
+        Context context = cxman.context(serviceType);
 
         if (context instanceof ArjunaContextImple)
         {

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/ContextFactoryImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/ContextFactoryImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/ContextFactoryImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -36,6 +36,7 @@
 import com.arjuna.mw.wstx.logging.wstxLogger;
 import com.arjuna.mw.wsas.exceptions.NoActivityException;
 import com.arjuna.mw.wsas.exceptions.SystemException;
+import com.arjuna.mwlabs.wscf.utils.ContextProvider;
 import com.arjuna.mwlabs.wst11.ba.context.ArjunaContextImple;
 import com.arjuna.mwlabs.wst11.ba.participants.CleanupSynchronization;
 import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator;
@@ -48,6 +49,7 @@
 import com.arjuna.webservices11.wsba.processors.CoordinatorCompletionParticipantProcessor;
 import com.arjuna.webservices11.ServiceRegistry;
 import com.arjuna.wsc11.ContextFactory;
+import com.arjuna.wsc11.ContextFactoryMapper;
 import com.arjuna.wsc11.RegistrationCoordinator;
 import com.arjuna.wsc11.messaging.MessageId;
 import com.arjuna.wsc.InvalidCreateParametersException;
@@ -65,9 +67,11 @@
 import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
 import javax.xml.namespace.QName;
 
+ at ContextProvider(coordinationType = ArjunaContextImple.coordinationType,
+        serviceType = ArjunaContextImple.serviceType,
+        contextImplementation = ArjunaContextImple.class)
 public class ContextFactoryImple implements ContextFactory
 {
-
     public ContextFactoryImple()
     {
         try
@@ -75,6 +79,10 @@
             _coordManager = CoordinatorManagerFactory.coordinatorManager();
 
             _theRegistrar = new RegistrarImple();
+
+            // install the factory for the mapper to locate
+
+            ContextFactoryMapper.getMapper().addContextFactory(ArjunaContextImple.coordinationType, this);
         }
         catch (Exception ex)
         {
@@ -139,7 +147,7 @@
                 timeout = (longTimeout > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)longTimeout) ;
             }
 
-    		_coordManager.begin("Sagas11HLS", timeout);
+    		_coordManager.begin(ArjunaContextImple.serviceType, timeout);
 
             final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext() ;
             final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry() ;
@@ -399,5 +407,4 @@
 
     private CoordinatorManager                   _coordManager;
     private RegistrarImple _theRegistrar;
-
 }
\ No newline at end of file

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/SubordinateImporter.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/SubordinateImporter.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/SubordinateImporter.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -2,7 +2,6 @@
 
 import com.arjuna.mw.wst.TxContext;
 import com.arjuna.mwlabs.wst11.ba.context.TxContextImple;
-import com.arjuna.mwlabs.wst11.ba.ContextFactoryImple;
 import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator;
 import com.arjuna.webservices11.wsba.BusinessActivityConstants;
 import com.arjuna.wsc11.ContextFactoryMapper;
@@ -23,7 +22,7 @@
     /**
      * handle on the local 1.1 context factory implementation
      */
-    private static ContextFactoryImple baContextFactory = (ContextFactoryImple) ContextFactoryMapper.getFactory().getContextFactory(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME);
+    private static ContextFactoryImple baContextFactory = (ContextFactoryImple) ContextFactoryMapper.getMapper().getContextFactory(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME);
 
     public static TxContext importContext(CoordinationContextType cc)
     {

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/context/ArjunaContextImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/context/ArjunaContextImple.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/context/ArjunaContextImple.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -58,6 +58,8 @@
 
 public class ArjunaContextImple implements SOAPContext
 {
+    public static final String serviceType = "Sagas11HLS";
+    public static final String coordinationType = BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME;
 
     public ArjunaContextImple()
     {
@@ -221,7 +223,7 @@
     public static ArjunaContextImple getContext()
     {
         ContextManager cxman = new ContextManager();
-        Context context = cxman.context("Sagas11HLS");
+        Context context = cxman.context(serviceType);
 
         if (context instanceof ArjunaContextImple)
         {

Modified: labs/jbosstm/trunk/XTS/bridge/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java
===================================================================
--- labs/jbosstm/trunk/XTS/bridge/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/bridge/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -26,7 +26,7 @@
      * transactions
      */
     private static ContextFactoryImple contextFactory =
-            (ContextFactoryImple)ContextFactoryMapper.getFactory().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
+            (ContextFactoryImple)ContextFactoryMapper.getMapper().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
 
     /**
      * this class handles all creation of bridged transactions 

Modified: labs/jbosstm/trunk/XTS/build.xml
===================================================================
--- labs/jbosstm/trunk/XTS/build.xml	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/build.xml	2010-08-10 12:03:17 UTC (rev 34620)
@@ -149,8 +149,11 @@
         <echo message="Installing configuration"/>
         <mkdir dir="${xts.installationdirectory}/conf"/>
         <copy todir="${xts.installationdirectory}/conf">
+            <!--
             <fileset dir="WSCF/config"/>
             <fileset dir="WSTX/config" includes="*.xml"/>
+            -->
+            <fileset  dir="." includes="xts.properties"/>
         </copy>
 
 		<echo message="Installing htdocs"/>

Modified: labs/jbosstm/trunk/XTS/sar/build.xml
===================================================================
--- labs/jbosstm/trunk/XTS/sar/build.xml	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/sar/build.xml	2010-08-10 12:03:17 UTC (rev 34620)
@@ -153,7 +153,10 @@
         <filter token="coordinator.hostname" value="${coordinator.hostname}"/>
         <filter token="coordinator.port" value="${coordinator.port}"/>
         <copy todir="${build.conf.dir}" filtering="true">
+            <!--
             <fileset dir="${conf.dir}" includes="*.xml"/>
+            -->
+            <fileset dir="${conf.dir}" includes="xts.properties"/>
         </copy>
         <jar jarfile="${build.dir}/config.jar">
             <fileset dir="${build.conf.dir}"/>
@@ -198,7 +201,10 @@
         <filter token="coordinator.hostname" value="${coordinator.hostname}"/>
         <filter token="coordinator.port" value="${coordinator.port}"/>
         <copy todir="${build.conf.dir}" filtering="true">
+            <!--
             <fileset dir="${conf.dir}" includes="*11.xml"/>
+            -->
+            <fileset dir="${conf.dir}" includes="xts.properties"/>
         </copy>
         <jar jarfile="${build.dir}/config.jar">
             <fileset dir="${build.conf.dir}"/>

Modified: labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/XTSService.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/XTSService.java	2010-08-10 06:43:35 UTC (rev 34619)
+++ labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/XTSService.java	2010-08-10 12:03:17 UTC (rev 34620)
@@ -20,6 +20,8 @@
  */
 package org.jboss.jbossts;
 
+import com.arjuna.mw.wscf.protocols.ProtocolManager;
+import com.arjuna.mw.wscf.protocols.ProtocolRegistry;
 import org.jboss.logging.Logger;
 import org.jboss.jbossts.xts.recovery.coordinator.at.ATCoordinatorRecoveryModule;
 import org.jboss.jbossts.xts.recovery.coordinator.at.SubordinateATCoordinatorRecoveryModule;
@@ -141,6 +143,9 @@
         // read unified properties file (replaces wscf.xml and wstx.xml)
         // Configuration.initialise("/jbossxts.xml");
 
+        // install protocol implementation classes declared by config file
+        ProtocolRegistry.sharedManager().initialise();
+
         // before we can allow the services to start up we need to identify the server
         // bind address and the web service port so they services register themselves
         // in the registry using the correct URL
@@ -246,6 +251,7 @@
                 System.setProperty(com.arjuna.mw.wst.common.Environment.COORDINATOR11_URL, coordinatorURL);
             }
         }
+
         // now it is safe to let the Sequencer class run any intiialisation routines it needs
 
         Sequencer.unlatch();

Added: labs/jbosstm/trunk/XTS/xts.properties
===================================================================
--- labs/jbosstm/trunk/XTS/xts.properties	                        (rev 0)
+++ labs/jbosstm/trunk/XTS/xts.properties	2010-08-10 12:03:17 UTC (rev 34620)
@@ -0,0 +1,145 @@
+# JBoss, Home of Professional Open Source
+# Copyright 2010, Red Hat and individual contributors
+# as indicated by the @author tags.
+# See the copyright.txt in the distribution for a full listing
+# of individual contributors.
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU Lesser General Public License, v. 2.1.
+# This program is distributed in the hope that it will be useful, but WITHOUT A
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+# You should have received a copy of the GNU Lesser General Public License,
+# v.2.1 along with this distribution; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.
+#
+# @author JBoss Inc.
+
+
+# XTS property file
+#
+# This property file is used to configure some XTS properties which are
+# not normally editable without also modifying the XTS build and/or
+# source code. It also provides a means of specifying values for some
+# editable configuration properties when using XTS outside of JBoss AS.
+# If you intend to use XTS inside JBoss AS then you should configure
+# these properties in file META-INF/jboss-beans.xml in the deployable
+# XTS sar.
+#
+# bind address/ports - these are used to construct the URLS handed out
+# to provide references to XTS services. These URLs can refer to services
+# deployed in the client, coordinator or participant web service container.
+#
+# in JBoss AS these properties will be injected by the microcontainer
+# using values derived from service JBoss Web as specified in file
+# jboss-beans.xml
+#
+org.jboss.jbossts.xts11.bind.address=localhost
+org.jboss.jbossts.xts11.bind.port=8080
+org.jboss.jbossts.xts11.bind.port.secure=8443
+
+org.jboss.jbossts.xts.bind.address=localhost
+org.jboss.jbossts.xts.bind.port=8080
+org.jboss.jbossts.xts.bind.port.secure=8080
+
+# coordinator url - these are used in the client container only to
+# construct the url used to address the coordinator contacted under a
+# WSAT or WSBA begin call. if these are not set the 1.1 URL defaults to
+# http://<bind.address>:<bind.port>/ws-c11/ActivationService
+# using the properties defined above to fill in the address and port
+# the 1.0 url defaults to
+# http://<bind.address>:<bind.port>/ws-c/soap/ActivationCoordinator
+# if the coordinatorURL property is not set then a URL is constructed
+# using whichever of the componnet values have been set and defaulting
+# the remaining components. the bind properties above are used to
+# default the address and port. the scheme defaults to http. the
+# path values will only need to be reset if using a non-JBoss
+# coordinator or if the XTS coordinator is deployed in a container
+# other than JBoss AS which maps the coordinator service endpoints
+# using a different path.
+
+# in JBoss AS these properties will be injected by the microcontainer
+# using values specified in file jboss-beans.xml
+
+# properties for 1.1 implementation
+# org.jboss.jbossts.xts11.coordinatorURL=http://localhost:8080/ws-c11/ActivationService
+# org.jboss.jbossts.xts11.coordinator.scheme=http
+# org.jboss.jbossts.xts11.coordinator.host=localhost
+# org.jboss.jbossts.xts11.coordinator.port=8080
+# org.jboss.jbossts.xts11.coordinator.path=ws-c11/ActivationService
+
+
+# properties for 1.0 implementation
+# org.jboss.jbossts.xts.coordinatorURL=http://localhost:8080/ws-c10/soap/ActivationCoordinator
+# org.jboss.jbossts.xts.coordinator.scheme=http
+# org.jboss.jbossts.xts.coordinator.host=localhost
+# org.jboss.jbossts.xts.coordinator.port=8080
+# org.jboss.jbossts.xts.coordinator.path=ws-c10/soap/ActivationCoordinator
+
+# user transaction and transaction manager implementation mappings
+# these are used in the client container only to identify the classes
+# used to implement the WSAT and WSBA client APIs. they will not
+# normally be reconfigured since doing so requires modifing the
+# implementation to include new versions of these classes.
+
+# mappings for the 1.1 implementation
+#
+
+org.jboss.jbossts.xts.wsat11.UserTransaction=com.arjuna.mwlabs.wst11.at.remote.UserTransactionImple
+org.jboss.jbossts.xts.wsba11.UserBusinessActivity=com.arjuna.mwlabs.wst11.ba.remote.UserBusinessActivityImple
+org.jboss.jbossts.xts.wsat11.TransactionManager=com.arjuna.mwlabs.wst11.at.remote.TransactionManagerImple
+org.jboss.jbossts.xts.wsba11.BusinessActivityManager=com.arjuna.mwlabs.wst11.ba.remote.BusinessActivityManagerImple
+
+# mappings for the 1.0 implementation
+#
+# these should only be defined if the 1.0 implementation
+# is deployed
+#
+
+org.jboss.jbossts.xts.wsat.UserTransaction=com.arjuna.mwlabs.wst.at.remote.UserTransactionImple
+org.jboss.jbossts.xts.wsba.UserBusinessActivity=com.arjuna.mwlabs.wst.ba.remote.UserBusinessActivityImple
+org.jboss.jbossts.xts.wsat.TransactionManager=com.arjuna.mwlabs.wst.at.remote.TransactionManagerImple
+org.jboss.jbossts.xts.wsba.BusinessActivityManager=com.arjuna.mwlabs.wst.ba.remote.BusinessActivityManagerImple
+
+# protocol mappings - these will not normally be reconfigured as they
+# are used to establish mappings from coordination service types to
+# their implementation classes and from coordination types to
+# coordination context factories.
+#
+# coordination service implementation classes must be tagged with an
+# HLSProvider annotation identifying the implemented service type.
+# the annotation must also declare the coordination type of the
+# coordination protocol supported by the service.
+#
+# context factory classes must be tagged with a ContextProvider
+# annotation identifying the coordination type and implementation
+# class of the contexts created by the factory. the annotation must
+# also declare the service type for which the context is appropriate.
+#
+
+# protocol definitions for 1.1 implementation
+#
+org.jboss.jbossts.xts.protocolImplementation1=com.arjuna.mwlabs.wscf11.model.twophase.arjunacore.TwoPhaseHLSImple
+org.jboss.jbossts.xts.protocolImplementation2=com.arjuna.mwlabs.wscf11.model.sagas.arjunacore.SagasHLSImple
+
+# these identify the context factory implementation classes
+#
+org.jboss.jbossts.xts.protocolImplementation3=com.arjuna.mwlabs.wst11.at.ContextFactoryImple
+org.jboss.jbossts.xts.protocolImplementation4=com.arjuna.mwlabs.wst11.ba.ContextFactoryImple
+
+# protocol definitions for 1.0 implementation
+#
+# these should only be defined if the 1.0 implementation
+# is deployed
+#
+# these identify the HLS implementation classes
+#
+org.jboss.jbossts.xts.protocolImplementation5=com.arjuna.mwlabs.wscf.model.twophase.arjunacore.TwoPhaseHLSImple
+org.jboss.jbossts.xts.protocolImplementation6=com.arjuna.mwlabs.wscf.model.sagas.arjunacore.SagasHLSImple
+
+# these identify the context factory implementation classes
+#
+org.jboss.jbossts.xts.protocolImplementation7=com.arjuna.mwlabs.wst.at.ContextFactoryImple
+org.jboss.jbossts.xts.protocolImplementation8=com.arjuna.mwlabs.wst.ba.ContextFactoryImple
+



More information about the jboss-svn-commits mailing list