[jboss-svn-commits] JBL Code SVN: r29808 - in labs/jbosstm/trunk: ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/recovery and 8 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 26 09:21:17 EDT 2009


Author: jhalliday
Date: 2009-10-26 09:21:16 -0400 (Mon, 26 Oct 2009)
New Revision: 29808

Removed:
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/common/LocalSetup.java
Modified:
   labs/jbosstm/trunk/ArjunaJTS/jbossts-properties-arjunajts.xml
   labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/recovery/RecoveryInit.java
   labs/jbosstm/trunk/ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/orbsetup/ORBSetupTest.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/ORB.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBean.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBeanMBean.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/opPropertyManager.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/event/EventManager.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/utils/InitLoader.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PostSetTest.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest2.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest4.java
   labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/propertyservice/BeanPopulator.java
Log:
Refactor orb portability properties, especialayl orb init, for bean based usage. JBTM-628


Modified: labs/jbosstm/trunk/ArjunaJTS/jbossts-properties-arjunajts.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jbossts-properties-arjunajts.xml	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/jbossts-properties-arjunajts.xml	2009-10-26 13:21:16 UTC (rev 29808)
@@ -151,36 +151,18 @@
 
     <entry key="OrbPortabilityEnvironmentBean.bindMechanism">CONFIGURATION_FILE</entry>
 
-    <!--
-      This class handles context propagation issues, and should never
-      be commented out or removed.
-    -->
-    <entry key="com.arjuna.orbportability.orb.PreInit1">com.arjuna.ats.internal.jts.context.ContextPropagationManager</entry>
+    <entry key="OrbPortabilityEnvironmentBean.orbInitializationProperties">
+        <!-- This class handles context propagation issues, and should never be commented out or removed. -->
+        com.arjuna.orbportability.orb.PreInit1=com.arjuna.ats.internal.jts.context.ContextPropagationManager
+        <!-- This property ensures the JTS knows which ORB to use and should never be commented out or removed -->
+        com.arjuna.orbportability.orb.PostInit=com.arjuna.ats.jts.utils.ORBSetup
+        <!-- This property ensures the crash recovery is initialised correctly and should never be commented out or removed -->
+        com.arjuna.orbportability.orb.PostInit2=com.arjuna.ats.internal.jts.recovery.RecoveryInit
+        <!-- This property ensures the JTS knows which ORB to use and should never be commented out or removed -->
+        com.arjuna.orbportability.orb.PostSet1=com.arjuna.ats.jts.utils.ORBSetup
+    </entry>
 
     <!--
-      This property ensures the JTS knows which ORB to use and should never
-      be commented out or removed
-    -->
-    <entry key="com.arjuna.orbportability.orb.PostInit1">com.arjuna.ats.jts.utils.ORBSetup</entry>
-    <!--
-      This property ensures the crash recovery is initialised correctly and
-      should never be commented out or removed
-    -->
-    <entry key="com.arjuna.orbportability.orb.PostInit2">com.arjuna.ats.internal.jts.recovery.RecoveryInit</entry>
-
-    <!--
-      This property ensures the JTS knows which ORB to use and should never
-      be commented out or removed
-    -->
-    <entry key="com.arjuna.orbportability.orb.PostSet1">com.arjuna.ats.jts.utils.ORBSetup</entry>
-
-    <!--
-      This property ensures the JTS knows which ORB to use and should never
-      be commented out or removed
-    -->
-    <entry key="com.arjuna.orbportability.orb.PostSet2">com.arjuna.ats.internal.jts.recovery.RecoveryInit</entry>
-
-    <!--
       This property controls the port on which the Recovery ORB listens
     -->
     <entry key="JTSEnvironmentBean.recoveryManagerPort">4711</entry>

Modified: labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/recovery/RecoveryInit.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/recovery/RecoveryInit.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/recovery/RecoveryInit.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -35,7 +35,6 @@
 import com.arjuna.common.util.logging.*;
 
 import com.arjuna.orbportability.common.opPropertyManager;
-import com.arjuna.orbportability.common.Environment;
 import com.arjuna.orbportability.*;
 
 import com.arjuna.ats.arjuna.logging.FacilityCode;

Modified: labs/jbosstm/trunk/ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/orbsetup/ORBSetupTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/orbsetup/ORBSetupTest.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/orbsetup/ORBSetupTest.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -35,11 +35,15 @@
 import com.arjuna.orbportability.ORB;
 import com.arjuna.orbportability.RootOA;
 import com.arjuna.orbportability.OA;
+import com.arjuna.orbportability.common.opPropertyManager;
 import com.arjuna.ats.arjuna.exceptions.FatalError;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
 
+import java.util.Properties;
+import java.util.Map;
+
 public class ORBSetupTest
 {
     private final static String ORB_NAME = "testorb";
@@ -51,8 +55,12 @@
         ORB myORB = null;
         RootOA myOA = null;
 
-        System.setProperty( PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_NAME), "com.arjuna.ats.jts.utils.ORBSetup");
+        Map<String, String> properties = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
 
+        properties.put( PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_NAME), "com.arjuna.ats.jts.utils.ORBSetup");
+
+        opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(properties);
+
         try
         {
             myORB = ORB.getInstance(ORB_NAME);

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/ORB.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/ORB.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/ORB.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -36,7 +36,7 @@
 import com.arjuna.orbportability.logging.opLogger;
 
 import com.arjuna.orbportability.internal.utils.*;
-import com.arjuna.orbportability.internal.common.LocalSetup;
+//import com.arjuna.orbportability.internal.common.LocalSetup;
 
 import com.arjuna.orbportability.logging.*;
 import com.arjuna.common.util.logging.VisibilityLevel;
@@ -82,7 +82,7 @@
 
 	if (!_orb.initialised())
 	{
-	    loadProperties(null);
+	    // null op - just skip it loadProperties(null);
 
             /**
              * Perform pre-initialisation classes for all ORBs
@@ -358,11 +358,11 @@
 	_orb.destroy();
     }
 
-protected ORB (String orbName)
+    protected ORB (String orbName)
     {
         _orbName = orbName;
 
-	addAttribute(new LocalSetup());
+        //addAttribute(new LocalSetup());
     }
 
 private void loadProperties (Properties p)
@@ -389,7 +389,11 @@
                                               "Adding property '"+o+"' to the ORB portability properties" );
                     }
 
-                    opPropertyManager.getPropertyManager().setProperty( o, p.getProperty(o) );
+                    synchronized (ORB.class) {
+                        Map<String, String> globalProperties = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
+                        globalProperties.put(o, p.getProperty(o));
+                        opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(globalProperties);
+                    }
                 }
             }
         }

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBean.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBean.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -23,10 +23,7 @@
 import com.arjuna.common.internal.util.propertyservice.PropertyPrefix;
 import com.arjuna.common.internal.util.propertyservice.ConcatenationPrefix;
 
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 
 /**
  * A JavaBean containing assorted configuration properties for the Orb Portability layer.
@@ -36,7 +33,6 @@
 @PropertyPrefix(prefix = "com.arjuna.orbportability.")
 public class OrbPortabilityEnvironmentBean implements OrbPortabilityEnvironmentBeanMBean
 {
-    private volatile String corbaDiagnostics = null; // key only
     private volatile String initialReferencesRoot = com.arjuna.orbportability.common.Configuration.configFileRoot();
     private volatile String initialReferencesFile = "CosServices.cfg";
     private volatile String fileDir = null;
@@ -49,34 +45,10 @@
     private volatile String oaImplementation = null;
     private volatile String bindMechanism = "CONFIGURATION_FILE";
 
-    private volatile Properties orbInitializationProperties = new Properties(); 
+    private volatile Map<String,String> orbInitializationProperties = new HashMap<String, String>();
 
 
     /**
-     * Unused.
-     *
-     * Default: null
-     * Equivalent deprecated property: com.arjuna.orbportability.corbaDiagnostics
-     *
-     * @deprecated I'm not used - remove me
-     * @return unused.
-     */
-    public String getCorbaDiagnostics()
-    {
-        return corbaDiagnostics;
-    }
-
-    /**
-     * Unused.
-     *
-     * @param corbaDiagnostics unused.
-     */
-    public void setCorbaDiagnostics(String corbaDiagnostics)
-    {
-        this.corbaDiagnostics = corbaDiagnostics;
-    }
-
-    /**
      * Returns the name of the directory in which the initial reference file is stored.
      *
      * Default: "."
@@ -268,32 +240,32 @@
     }
 
     /**
-     * Returns the Properties used for the orb initialization parameters. As there are potentially
+     * Returns the Map used for the orb initialization parameters. As there are potentially
      * an arbitrary number of ORBs, each with an arbitrary set of initialization classes, it's not
      * well suited to bean based properties :-(
-     * The returned object is a clone. May return an empty Properties, will not return null.
+     * The returned object is a clone. May return an empty Map, will not return null.
      *
-     * Default: empty Properties.
+     * Default: empty Map.
      *
-     * @return a Properties object containing ORB initialization information.
+     * @return a Map containing ORB initialization information.
      */
-    public Properties getOrbInitializationProperties()
+    public Map<String, String> getOrbInitializationProperties()
     {
-        return (Properties)orbInitializationProperties.clone();
+        return new HashMap<String, String>(orbInitializationProperties);
     }
 
     /**
-     * Sets the Properties used for ORB initialization.
-     * The provided Properties will be cloned, not retained.
+     * Sets the Map of properties used for ORB initialization.
+     * The provided Map will be copied, not retained.
      *
-     * @param orbInitializationProperties a Properties object containing ORB initialization information.
+     * @param orbInitializationProperties a Map containing ORB initialization information.
      */
-    public void setOrbInitializationProperties(Properties orbInitializationProperties)
+    public void setOrbInitializationProperties(Map<String, String> orbInitializationProperties)
     {
         if(orbInitializationProperties == null) {
-            this.orbInitializationProperties = new Properties();
+            this.orbInitializationProperties = new HashMap<String, String>();
         } else {
-            this.orbInitializationProperties = (Properties)orbInitializationProperties.clone();
+            this.orbInitializationProperties = new HashMap<String, String>(orbInitializationProperties);
         }
     }
 }

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBeanMBean.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/OrbPortabilityEnvironmentBeanMBean.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -21,7 +21,7 @@
 package com.arjuna.orbportability.common;
 
 import java.util.List;
-import java.util.Properties;
+import java.util.Map;
 
 /**
  * A JMX MBean interface containing assorted configuration for the Orb Portability layer.
@@ -30,10 +30,6 @@
  */
 public interface OrbPortabilityEnvironmentBeanMBean
 {
-    String getCorbaDiagnostics();
-
-    void setCorbaDiagnostics(String corbaDiagnostics);
-
     String getInitialReferencesRoot();
 
     void setInitialReferencesRoot(String initialReferencesRoot);
@@ -66,7 +62,7 @@
 
     void setBindMechanism(String bindMechanism);
 
-    public Properties getOrbInitializationProperties();
+    public Map<String, String> getOrbInitializationProperties();
 
-    public void setOrbInitializationProperties(Properties orbInitializationProperties);
+    public void setOrbInitializationProperties(Map<String, String> orbInitializationProperties);
 }

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/opPropertyManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/opPropertyManager.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/common/opPropertyManager.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -44,6 +44,10 @@
  */
 public class opPropertyManager
 {
+    /**
+     * @deprecated use the bean instead.
+     * @return
+     */
     public static PropertyManager getPropertyManager()
     {
         return PropertyManagerFactory.getPropertyManagerForModule("orbportability", Environment.PROPERTIES_FILE);

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/event/EventManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/event/EventManager.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/event/EventManager.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -31,7 +31,6 @@
 
 package com.arjuna.orbportability.event;
 
-import com.arjuna.orbportability.common.Environment;
 import com.arjuna.orbportability.common.opPropertyManager;
 import com.arjuna.orbportability.logging.opLogger;
 

Deleted: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/common/LocalSetup.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/common/LocalSetup.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/common/LocalSetup.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -1,126 +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) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.  
- *
- * $Id: LocalSetup.java 2342 2006-03-30 13:06:17Z  $
- */
-
-package com.arjuna.orbportability.internal.common;
-
-import com.arjuna.orbportability.common.Environment;
-import com.arjuna.orbportability.common.opPropertyManager;
-import com.arjuna.orbportability.logging.*;
-import com.arjuna.common.util.logging.VisibilityLevel;
-import com.arjuna.common.util.logging.DebugLevel;
-
-public class LocalSetup extends com.arjuna.orbportability.orb.Attribute
-{
-
-    /**
-     * @message com.arjuna.orbportability.internal.common.LocalSetup.invalidoption {0} - Invalid debug option {1}
-     */
-public void initialise (String[] params)
-    {
-        if (opLogger.logger.isDebugEnabled())
-        {
-            opLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
-				  FacilityCode.FAC_ORB_PORTABILITY, "LocalSetup.initialise(String[] params)");
-	}
-
-	if (params == null)
-	    return;
-	
-	for (int i = 0; i < params.length; i++)
-	{
-            if (opLogger.logger.isDebugEnabled())
-            {
-                opLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
-				      FacilityCode.FAC_ORB_PORTABILITY, "Searching "+params[i]);
-	    }
-
-	    if (params[i].startsWith(LocalSetup.prefix))
-	    {
-		String propertyName = params[i].substring(LocalSetup.prefix.length());
-
-                if (opLogger.logger.isDebugEnabled())
-                {
-                    opLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
-				          FacilityCode.FAC_ORB_PORTABILITY, "Got "+propertyName);
-		}
-
-                if (opLogger.logger.isDebugEnabled())
-                {
-                    opLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
-					  FacilityCode.FAC_ORB_PORTABILITY, "Setting property: "+propertyName+" with value: "+params[i+1]);
-		}
-
-		opPropertyManager.getPropertyManager().setProperty(propertyName, params[i+1]);
-		i++;
-
-		if (propertyName.compareTo(Environment.CORBA_DIAGNOSTICS) == 0)
-		{
-		    try
-		    {
-			/*
-			 * Strip out any 0x extension as Java can't handle it!
-			 */
-
-			String toUse = null;
-
-			if (params[i+1].startsWith(LocalSetup.hexStart))
-			    toUse = params[i+1].substring(LocalSetup.hexStart.length());
-			else
-			    toUse = params[i+1];
-
-			Integer level = Integer.valueOf(toUse, 16);
-			opLogger.logger.setDebugLevel(level.intValue());
-
-			level = null;
-			toUse = null;
-		    }
-		    catch (Exception e)
-		    {
-                        if ( opLogger.loggerI18N.isWarnEnabled() )
-                        {
-                            opLogger.loggerI18N.warn( "com.arjuna.orbportability.internal.common.LocalSetup.invalidoption",
-                                                        new Object[] { "LocalSetup.initialisse", params[i+1] } );
-                        }
-		    }
-		    
-		    i++;
-		}
-		
-		propertyName = null;
-	    }
-	}
-    }
-
-public static final String prefix = "-HP_";
-
-private static final String hexStart = "0x";
-
-}

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/utils/InitLoader.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/utils/InitLoader.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/internal/utils/InitLoader.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -37,6 +37,7 @@
 
 import java.util.Properties;
 import java.util.Enumeration;
+import java.util.Map;
 
 import java.lang.ClassNotFoundException;
 import java.lang.IllegalAccessException;
@@ -57,22 +58,17 @@
         initObj = obj;
     }
 
-protected void initialise ()
+    protected void initialise()
     {
-	Properties properties = opPropertyManager.getPropertyManager().getProperties();
+        Map<String, String> properties = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
 
-	if (properties != null)
-	{
-	    Enumeration names = properties.propertyNames();
-	    
-	    while (names.hasMoreElements())
-	    {
-		String attrName = (String) names.nextElement();
-
-		if (attrName.indexOf(propertyName) != -1)
-		    createInstance(attrName, properties.getProperty(attrName));
-	    }
-	}
+        for(String attrName : properties.keySet())
+        {
+            if (attrName.indexOf(propertyName) != -1)
+            {
+                createInstance(attrName, properties.get(attrName));
+            }
+        }
     }
 
     /**

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PostSetTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PostSetTest.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PostSetTest.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -33,10 +33,11 @@
 
 import com.arjuna.orbportability.internal.utils.PostSetLoader;
 import com.arjuna.orbportability.ORB;
+import com.arjuna.orbportability.common.opPropertyManager;
 import com.hp.mwtests.orbportability.initialisation.postset.AllPostSet;
 import com.hp.mwtests.orbportability.initialisation.postset.SinglePostSetUsingInterface;
 
-import java.util.Properties;
+import java.util.Map;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
@@ -49,14 +50,14 @@
     @Test
     public void test()
     {
-        Properties testProps = System.getProperties();
+        Map<String, String> testProps = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
 
-        testProps.setProperty(PostSetLoader.generateORBPropertyName("com.arjuna.orbportability.orb"),
+        testProps.put(PostSetLoader.generateORBPropertyName("com.arjuna.orbportability.orb"),
                 "com.hp.mwtests.orbportability.initialisation.postset.AllPostSet");
-        testProps.setProperty(PostSetLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME2),
+        testProps.put(PostSetLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME2),
                 "com.hp.mwtests.orbportability.initialisation.postset.SinglePostSetUsingInterface");
 
-        System.setProperties(testProps);
+        opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(testProps);
 
         ORB orb = null;
         ORB orb2 = null;

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest2.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest2.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -34,10 +34,11 @@
 import com.arjuna.orbportability.ORB;
 import com.arjuna.orbportability.OA;
 import com.arjuna.orbportability.RootOA;
+import com.arjuna.orbportability.common.opPropertyManager;
 import com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation;
 import com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation2;
 
-import java.util.Properties;
+import java.util.Map;
 
 import org.omg.PortableServer.ImplicitActivationPolicyValue;
 import org.omg.CORBA.Policy;
@@ -56,7 +57,7 @@
         int numberOfORBs = 1;
         int numberOfOAsPerORB = 3;
 
-        Properties testProps = System.getProperties();
+        Map<String, String> testProps = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
 
         /**
          * Setup pre-initialisation classes for all ORBs and all OAs
@@ -64,7 +65,7 @@
         for (int orbCount=0;orbCount<numberOfORBs;orbCount++)
         {
             System.out.println("Registering pre-initialisation property '"+PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb",ORB_INSTANCE_NAME+orbCount)+"'");
-            testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb",ORB_INSTANCE_NAME+orbCount, "preinitmyorb"),
+            testProps.put(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb",ORB_INSTANCE_NAME+orbCount, "preinitmyorb"),
                                   "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation");
 
             for (int oaCount=0;oaCount<numberOfOAsPerORB;oaCount++)
@@ -72,14 +73,14 @@
                 System.out.println("Registering pre-initialisation property '"+PreInitLoader.generateOAPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME+orbCount, OA_INSTANCE_NAME+oaCount)+"'");
                 System.out.println("Registering pre-initialisation property '"+PreInitLoader.generateOAPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME+orbCount, OA_INSTANCE_NAME+oaCount, "mypoainit")+"'");
 
-                testProps.setProperty(PreInitLoader.generateOAPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME+orbCount, OA_INSTANCE_NAME+oaCount),
+                testProps.put(PreInitLoader.generateOAPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME+orbCount, OA_INSTANCE_NAME+oaCount),
                                       "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation");
-                testProps.setProperty(PreInitLoader.generateOAPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME+orbCount, OA_INSTANCE_NAME+oaCount, "mypoainit"),
+                testProps.put(PreInitLoader.generateOAPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME+orbCount, OA_INSTANCE_NAME+oaCount, "mypoainit"),
                                       "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation2");
             }
         }
 
-        System.setProperties(testProps);
+        opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(testProps);
 
         try
         {

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest4.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest4.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/tests/classes/com/hp/mwtests/orbportability/initialisation/PropertyInitTest4.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -34,13 +34,14 @@
 import com.arjuna.orbportability.internal.utils.PreInitLoader;
 import com.arjuna.orbportability.internal.utils.PostInitLoader;
 import com.arjuna.orbportability.ORB;
+import com.arjuna.orbportability.common.opPropertyManager;
 import com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisationUsingInterface;
 import com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisationUsingInterface;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
 
-import java.util.Properties;
+import java.util.Map;
 
 public class PropertyInitTest4
 {
@@ -52,17 +53,19 @@
     {
         ORB orb = null,
             orb2 = null;
-        Properties testProps = System.getProperties();
+        Map<String, String> testProps = opPropertyManager.getOrbPortabilityEnvironmentBean().getOrbInitializationProperties();
 
-        testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"),
+        testProps.put(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"),
                         "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisationUsingInterface");
-        testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"),
+        testProps.put(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"),
                         "com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisationUsingInterface");
-        testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2),
+        testProps.put(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2),
                         "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisationUsingInterface");
-        testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2),
+        testProps.put(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2),
                         "com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisationUsingInterface");
 
+        opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(testProps);
+
         try
         {
             orb = ORB.getInstance(ORB_INSTANCE_NAME);

Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/propertyservice/BeanPopulator.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/propertyservice/BeanPopulator.java	2009-10-26 12:34:06 UTC (rev 29807)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/propertyservice/BeanPopulator.java	2009-10-26 13:21:16 UTC (rev 29808)
@@ -73,9 +73,9 @@
      *   the short name of the bean followed by the field name, and finally the bean classes' PropertyPrefix annotation
      *   value followed by the name of the field, the last being except in cases where the field has a FullPropertyName
      *   annotation, in which case its value is used instead.
-     * For vector (in the math sense - the type is actually normally List) properties, a single property key matched
-     *   according to the prior rules will be treated as having a compund vlaue which will be tokenized into list
-     *   elements based on whitespace and inserted into the list in token order.
+     * For vector (in the math sense - the type is actually normally List/Map) properties, a single property key matched
+     *   according to the prior rules will be treated as having a compound value which will be tokenized into
+     *   elements based on whitespace and inserted into the list in token order or further tokenised on = for Map key/value.
      * If no such key is found, the value of the field's ConcatenationPrefix annotation
      * is treated as a name prefix and the list elements are assembled from the values of any properties having
      * key values starting with the prefix. These are inserted into the list in order of the key's name sort position.
@@ -118,7 +118,7 @@
                 getter = bean.getClass().getMethod(getterMethodName, new Class[] {});
             }
 
-            if(field.isAnnotationPresent(ConcatenationPrefix.class)) {
+            if(field.isAnnotationPresent(ConcatenationPrefix.class) || field.getType().getName().startsWith("java.util")) {
                 handleGroupProperty(bean, properties, field, setter, getter);
             } else {
                 handleSimpleProperty(bean, properties, field, setter, getter);
@@ -140,7 +140,7 @@
     private static void handleGroupProperty(Object bean, Properties properties, Field field, Method setter, Method getter)
         throws Exception
     {
-        List<String> values = new LinkedList<String>();
+        List<String> lines = new LinkedList<String>();
 
         String valueFromProperties = getValueFromProperties(bean, properties, field, bean.getClass().getSimpleName());
 
@@ -150,22 +150,23 @@
 
             String[] tokens = valueFromProperties.split("\\s+");
 
-            // the order we want them in is the order they appear in the string, so we can just add in sequence:
+            // for lists, the order we want them in is the order they appear in the string, so we can just add in sequence:
             for(String token : tokens) {
-                values.add(token);
+                lines.add(token);
             }
         }
         else
         {
             // it's set of values that need gathering together
-            // the order we want them in is the lex sort order of the keys, so we need to buffer and sort them:
+            // for lists, the order we want them in is the lex sort order of the keys, so we need to buffer and sort them:
 
             List<String> listOfMatchingPropertyNames = new LinkedList<String>();
             Enumeration propertyNamesEnumeration = properties.propertyNames();
 
-            if (propertyNamesEnumeration != null)
+            ConcatenationPrefix concatenationPrefix = field.getAnnotation(ConcatenationPrefix.class);
+            if (propertyNamesEnumeration != null && concatenationPrefix != null)
             {
-                String prefix = field.getAnnotation(ConcatenationPrefix.class).prefix();
+                String prefix = concatenationPrefix.prefix();
 
                 while (propertyNamesEnumeration.hasMoreElements())
                 {
@@ -182,14 +183,33 @@
 
             for(String name : listOfMatchingPropertyNames) {
                 String value = properties.getProperty(name);
-                values.add(value);
+                lines.add(value);
             }            
         }
-        
+
+        System.out.println(bean.getClass()+" "+field.getName());
+
+        Object replacementValue = null;
+
+        if(java.util.Map.class.isAssignableFrom(field.getType())) {
+            // we have a list but need a map. split eash element into key/value pair.
+            Map<String, String> map = new HashMap<String, String>();
+            for(String element : lines) {
+                String[] tokens = element.split("=");
+                map.put(tokens[0], tokens[1]);
+            }
+            replacementValue = map;
+        } else {
+             // it stays as a list.
+            replacementValue = lines;
+        }
+
+        System.out.println(replacementValue.getClass().getName()+": "+replacementValue);
+
         Object valueFromBean = getter.invoke(bean, new Object[] {});
 
-        if(!valueFromBean.equals(values)) {
-            setter.invoke(bean, new Object[] {values});
+        if(!valueFromBean.equals(replacementValue)) {
+            setter.invoke(bean, new Object[] {replacementValue});
         }
     }
 



More information about the jboss-svn-commits mailing list