[jboss-cvs] JBossAS SVN: r76997 - in trunk: cluster/src/etc and 45 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 12 18:29:20 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-08-12 18:29:19 -0400 (Tue, 12 Aug 2008)
New Revision: 76997

Added:
   trunk/server/src/etc/conf/default/bindings.xml
   trunk/server/src/etc/conf/default/bootstrap-minimal.xml
   trunk/testsuite/src/resources/test-configs/binding-manager1/
   trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/
   trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/
   trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/remoting-bisocket-service.xml
   trunk/testsuite/src/resources/test-configs/binding-manager2/
   trunk/testsuite/src/resources/test-configs/binding-manager2/conf/
   trunk/testsuite/src/resources/test-configs/binding-manager2/conf/jbossjta-properties.xml
   trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/
   trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/
   trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/remoting-bisocket-service.xml
   trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java
   trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java
   trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java
   trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java
   trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java
   trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java
   trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java
   trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java
   trunk/varia/src/main/org/jboss/services/binding/impl/
   trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java
   trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java
   trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java
   trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java
   trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java
   trunk/varia/src/main/org/jboss/services/binding/impl/Util.java
   trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java
   trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java
   trunk/varia/src/resources/tests/
   trunk/varia/src/resources/tests/org/
   trunk/varia/src/resources/tests/org/jboss/
   trunk/varia/src/resources/tests/org/jboss/test/
   trunk/varia/src/resources/tests/org/jboss/test/services/
   trunk/varia/src/resources/tests/org/jboss/test/services/binding/
   trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/
   trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/alt_input.xml
   trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/input.xml
   trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt.xml
   trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt_input.xml
   trunk/varia/src/tests/
   trunk/varia/src/tests/org/
   trunk/varia/src/tests/org/jboss/
   trunk/varia/src/tests/org/jboss/test/
   trunk/varia/src/tests/org/jboss/test/services/
   trunk/varia/src/tests/org/jboss/test/services/binding/
   trunk/varia/src/tests/org/jboss/test/services/binding/test/
   trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
   trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
Removed:
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/configure/binding/
   trunk/varia/src/main/org/jboss/services/binding/AttributeMappingDelegate.java
   trunk/varia/src/main/org/jboss/services/binding/ServiceConfig.java
   trunk/varia/src/main/org/jboss/services/binding/ServicesConfigDelegate.java
   trunk/varia/src/main/org/jboss/services/binding/ServicesStore.java
   trunk/varia/src/main/org/jboss/services/binding/ServicesStoreFactory.java
   trunk/varia/src/main/org/jboss/services/binding/XMLServicesStore.java
   trunk/varia/src/main/org/jboss/services/binding/XMLServicesStoreFactory.java
   trunk/varia/src/main/org/jboss/services/binding/XSLTConfigDelegate.java
   trunk/varia/src/main/org/jboss/services/binding/XSLTFileDelegate.java
Modified:
   trunk/build/build-distr.xml
   trunk/build/build.xml
   trunk/cluster/src/etc/ha-legacy-service.xml
   trunk/cluster/src/etc/hajndi-service.xml
   trunk/connector/src/etc/example-config/hsqldb-ds.xml
   trunk/ejb3/build.xml
   trunk/iiop/src/etc/iiop-service.xml
   trunk/jbossas/jmx-remoting/src/etc/jboss-service.xml
   trunk/jbossmq/src/etc/server/default/deploy/uil2-service.xml
   trunk/server/src/etc/conf/default/bootstrap-repo.xml
   trunk/server/src/etc/conf/default/bootstrap.xml
   trunk/server/src/etc/conf/default/jboss-service.xml
   trunk/server/src/etc/deploy/remoting-service.xml
   trunk/system-jmx/src/main/org/jboss/system/ServiceConfigurator.java
   trunk/system-jmx/src/main/org/jboss/system/ServiceController.java
   trunk/system-jmx/src/main/org/jboss/system/ServiceControllerMBean.java
   trunk/system-jmx/src/main/org/jboss/system/microcontainer/ConfigureAction.java
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java
   trunk/testsuite/build.xml
   trunk/testsuite/imports/server-config.xml
   trunk/tomcat/src/resources/war-deployers-jboss-beans.xml
   trunk/varia/.classpath
   trunk/varia/build.xml
   trunk/varia/src/main/org/jboss/services/binding/DuplicateServiceException.java
   trunk/varia/src/main/org/jboss/services/binding/ServiceBinding.java
   trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManager.java
   trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManagerMBean.java
   trunk/varia/src/resources/services/invoker/http/jboss-service.xml
   trunk/varia/src/resources/services/invoker/httpha/jboss-service.xml
   trunk/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml
Log:
[JBAS-5192] MC-based ServiceBindingManager

Modified: trunk/build/build-distr.xml
===================================================================
--- trunk/build/build-distr.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/build/build-distr.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -142,7 +142,7 @@
       <fileset dir="${_module.output}/lib">
         <include name="ejb3-interceptors-aop.xml"/>
         <include name="ejb3-timer-service.xml"/>
-        <include name="ejb3-connectors-service.xml"/>
+      	<include name="ejb3-connectors-service.xml"/>
       </fileset>
     </copy>
 
@@ -749,7 +749,7 @@
         </fileset>
         <fileset dir="${jboss.messaging.resources}/">
             <include name="connection-factories-service.xml"/>
-            <include name="remoting-bisocket-service.xml"/>
+        	<include name="remoting-bisocket-service.xml"/>
         </fileset>
      </copy>
   	
@@ -1061,7 +1061,7 @@
         <include name="hsqldb-plugin.jar"/>
         <include name="autonumber-plugin.jar"/>
         <include name="properties-plugin.jar"/>
-        <include name="bindingservice-plugin.jar"/>
+        <include name="jboss-bindingservice.jar"/>
         <include name="jboss-monitoring.jar"/>
         <include name="jboss-srp.jar"/>
       </fileset>
@@ -1070,9 +1070,11 @@
     <!-- Copy to docs/examples -->
     <mkdir dir="${install.examples.varia}"/>
     <copy todir="${install.examples.varia}" filtering="no">
+      <!--
       <fileset dir="${project.root}/testsuite/src/etc/cluster-test">
         <include name="jboss-bindings.xml"/>
       </fileset>
+      -->
       <fileset dir="${_module.output}/lib">
         <include name="derby-plugin.jar"/>
         <include name="threaddump.war"/>
@@ -1194,12 +1196,14 @@
     <!-- copy the jboss-monitoring JAR -->
     <copy file="${project.root}/varia/output/lib/jboss-monitoring.jar" todir="${install.server}/all/lib"/>
 
-    <!-- copy the binding-manager sample file and JAR -->
+    <!-- copy the binding-manager sample file and JAR
     <copy file="${project.root}/varia/output/lib/bindingservice-plugin.jar" todir="${install.server}/all/lib"/>
-
+    -->
+  	<!--
     <mkdir dir="${install.examples.binding-manager}"/>
     <copy file="${project.root}/varia/src/resources/services/binding/sample-bindings.xml" todir="${install.examples.binding-manager}"/>
-
+    -->
+  	
     <!-- the bean deployer : obsolete in jboss5
     <mkdir dir="${install.all.deploy}/jboss-bean.deployer"/>
     <copy todir="${install.all.deploy}/jboss-bean.deployer" filtering="no">

Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/build/build.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -236,7 +236,7 @@
     <property name="install.examples.jms" value="${install.docs}/examples/jms"/>
     <property name="install.examples.jbossweb" value="${install.examples}/jbossweb"/>
     <property name="install.examples.netboot" value="${install.examples}/netboot"/>
-    <property name="install.examples.binding-manager" value="${install.examples}/binding-manager"/>
+    <!--<property name="install.examples.binding-manager" value="${install.examples}/binding-manager"/>-->
     <property name="install.examples.varia" value="${install.examples}/varia"/>
     <property name="install.dtd" value="${install.docs}/dtd"/>
     <property name="install.schema" value="${install.docs}/schema"/>
@@ -741,7 +741,8 @@
       <fileset dir="${install.default.conf}">
         <include name="jndi.properties" />
         <include name="jboss-log4j.xml" />
-        <include name="bootstrap.xml" />
+        <!-- Use bootstrap-minimal.xml until we get rid of bindings.xml -->
+        <!--<include name="bootstrap.xml" />-->
         <include name="aop.xml" />
         <include name="classloader.xml" />
         <include name="deployers.xml" />
@@ -751,6 +752,8 @@
         <include name="xmdesc/NamingService-xmbean.xml" />
       </fileset>
     </copy>
+    <copy file="${install.default.conf}/bootstrap-minimal.xml"
+          tofile="${install.minimal.conf}/bootstrap.xml"/>
     <copy file="${install.default.conf}/jboss-minimal.xml"
           tofile="${install.minimal.conf}/jboss-service.xml"/>
     <copy todir="${install.minimal.lib}">

Modified: trunk/cluster/src/etc/ha-legacy-service.xml
===================================================================
--- trunk/cluster/src/etc/ha-legacy-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/cluster/src/etc/ha-legacy-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -19,7 +19,11 @@
       <depends>HAPartition</depends>
       
       <attribute name="ServerAddress">${jboss.bind.address}</attribute>
-      <attribute name="RMIObjectPort">4447</attribute>
+      <attribute name="RMIObjectPort">
+          <!-- Get the port from the ServiceBindingManager -->
+         <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+            parameter="jboss:service=invoker,type=jrmpha"/>
+      </attribute>
       
       <!--
       <attribute name="RMIObjectPort">0</attribute>
@@ -43,7 +47,11 @@
       <attribute name="ClientMaxPoolSize">300</attribute>
       <attribute name="SocketTimeout">60000</attribute>
       <attribute name="ServerBindAddress">${jboss.bind.address}</attribute>
-      <attribute name="ServerBindPort">4448</attribute>
+      <attribute name="ServerBindPort">
+         <!-- Get the port from the ServiceBindingManager -->
+         <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+            parameter="jboss:service=invoker,type=pooledha"/>
+      </attribute>
       <attribute name="ClientConnectAddress">${jboss.bind.address}</attribute>
       <attribute name="ClientConnectPort">0</attribute>
       <attribute name="EnableTcpNoDelay">false</attribute>

Modified: trunk/cluster/src/etc/hajndi-service.xml
===================================================================
--- trunk/cluster/src/etc/hajndi-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/cluster/src/etc/hajndi-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -21,11 +21,26 @@
       <!-- Bind address of bootstrap endpoint -->
       <attribute name="BindAddress">${jboss.bind.address}</attribute>
       <!-- Port on which the HA-JNDI stub is made available -->
-      <attribute name="Port">1100</attribute>
+      <attribute name="Port">
+         <!-- Get the port from the ServiceBindingManager -->
+         <value-factory bean="ServiceBindingManager" method="getIntBinding">
+            <parameter>jboss:service=HAJNDI</parameter>
+            <parameter>Port</parameter>
+         </value-factory>
+      </attribute>
+      
       <!-- Bind address of the HA-JNDI RMI endpoint -->
       <attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
+      
       <!-- RmiPort to be used by the HA-JNDI service once bound. 0 => auto. -->
-      <attribute name="RmiPort">1101</attribute>
+      <attribute name="RmiPort">
+         <!-- Get the port from the ServiceBindingManager -->
+         <value-factory bean="ServiceBindingManager" method="getIntBinding">
+            <parameter>jboss:service=HAJNDI</parameter>
+            <parameter>RmiPort</parameter>
+         </value-factory>
+      </attribute>
+      
       <!-- Accept backlog of the bootstrap socket -->
       <attribute name="Backlog">50</attribute>
 

Modified: trunk/connector/src/etc/example-config/hsqldb-ds.xml
===================================================================
--- trunk/connector/src/etc/example-config/hsqldb-ds.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/connector/src/etc/example-config/hsqldb-ds.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -94,7 +94,10 @@
    <!-- Uncomment if you want hsqldb accessed over tcp (server mode)
    <mbean code="org.jboss.jdbc.HypersonicDatabase" 
      name="jboss:service=Hypersonic">
-     <attribute name="Port">1701</attribute>
+     <attribute name="Port">        
+        <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+           parameter="jboss:service=Hypersonic"/>
+      </attribute>
      <attribute name="BindAddress">${jboss.bind.address}</attribute>     
      <attribute name="Silent">true</attribute>
      <attribute name="Database">default</attribute>

Modified: trunk/ejb3/build.xml
===================================================================
--- trunk/ejb3/build.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/ejb3/build.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -320,6 +320,8 @@
 	<unjar src="../thirdparty/jboss/jboss-ejb3-core/lib/jboss-ejb3-core.jar" dest="output/resources">
         <patternset>
           <include name="*.xml" />
+          <!-- Skip this one until it supports ServiceBindingManager, we get it locally -->
+          <exclude name="ejb3-connectors-service.xml" />
           <exclude name="META-INF/*.xml" />
           <include name="META-INF/*.properties" />
         </patternset>
@@ -345,6 +347,11 @@
             <include name="ejb3-connectors-service.xml"/>
             <include name="ejb3-interceptors-aop.xml"/>
          </fileset>
+      	<!-- We use our local copy of this one until the EJB3 project one 
+      	     supports ServiceBindingManager --> 
+        <fileset dir="${resources}">
+           <include name="ejb3-connectors-service.xml"/>
+        </fileset>
       </copy>
   </target>
 

Modified: trunk/iiop/src/etc/iiop-service.xml
===================================================================
--- trunk/iiop/src/etc/iiop-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/iiop/src/etc/iiop-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -50,6 +50,11 @@
     <attribute name="ORBSingletonDelegate">org.jacorb.orb.ORBSingleton</attribute>
     <attribute name="ORBPropertiesFileName">jacorb.properties</attribute>
     <attribute name="OTSContextPropagationEnabled">true</attribute>
+    <attribute name="Port">
+       <!-- Get the port from the ServiceBindingManager -->
+      <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+         parameter="jboss:service=CorbaORB"/>
+    </attribute>
     <!-- uncomment the attribute below to interoperate with IONA's ASP 6.0
     <attribute name="SendSASAcceptWithExceptionEnabled">false</attribute>
     -->

Modified: trunk/jbossas/jmx-remoting/src/etc/jboss-service.xml
===================================================================
--- trunk/jbossas/jmx-remoting/src/etc/jboss-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/jbossas/jmx-remoting/src/etc/jboss-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -11,7 +11,11 @@
        	   <attribute name="BindAddress">${jboss.bind.address}</attribute>
             <!-- if comment this out, will use 1099 as default and will conflict -->
             <!-- with default JNP (JNDI) port. -->
-            <attribute name="RegistryPort">1090</attribute>
+            <attribute name="RegistryPort">
+               <!-- Get the port from the ServiceBindingManager -->
+               <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+                  parameter="jboss.remoting:service=JMXConnectorServer,protocol=rmi"/>
+            </attribute>
             <!-- the path to which will be bound in rmi registry -->
             <!-- the commented value below is the default. -->
             <!-- <attribute name="JndiPath ">/jmxconnector</attribute> -->

Modified: trunk/jbossmq/src/etc/server/default/deploy/uil2-service.xml
===================================================================
--- trunk/jbossmq/src/etc/server/default/deploy/uil2-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/jbossmq/src/etc/server/default/deploy/uil2-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -19,7 +19,11 @@
     <!-- The bind address -->
     <attribute name="BindAddress">${jboss.bind.address}</attribute>
     <!-- The bind port -->
-    <attribute name="ServerBindPort">8093</attribute>
+    <attribute name="ServerBindPort">
+       <!-- Get the port from the ServiceBindingManager -->
+       <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+            parameter="jboss.mq:service=InvocationLayer,type=UIL2"/>
+    </attribute>
     <!-- The ping period in millis -->
     <attribute name="PingPeriod">60000</attribute>
     <!-- Whether tcp/ip does not wait for buffer fills -->

Added: trunk/server/src/etc/conf/default/bindings.xml
===================================================================
--- trunk/server/src/etc/conf/default/bindings.xml	                        (rev 0)
+++ trunk/server/src/etc/conf/default/bindings.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,385 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <classloader><inject bean="bindings-classloader:0.0.0"/></classloader>
+
+   <classloader name="bindings-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
+      <root>${jboss.server.lib.url}/jboss-bindingservice.jar</root>
+   </classloader>
+
+   <bean name="ServiceBindingManager" class="org.jboss.services.binding.ServiceBindingManager">
+      
+      <constructor>
+         <!-- The set of bindings to use for this server -->
+         <parameter>${jboss.service.binding.set:ports-default}</parameter>
+
+         <!-- The named sets of bindings -->
+         <parameter>           
+            <bean name="ServiceBindingStore" class="org.jboss.services.binding.impl.PojoServiceBindingStore">
+
+               <constructor>
+                  <parameter>
+                     <map keyClass="java.lang.String" valueClass="java.util.Set">
+                        <entry>
+                            <key>ports-default</key>
+                            <value><inject bean="PortsDefaultBindings"/></value>
+                        </entry>
+                        <entry>
+                            <key>ports-01</key>
+                            <value><inject bean="Ports01Bindings"/></value>
+                        </entry>
+                        <entry>
+                            <key>ports-02</key>
+                            <value><inject bean="Ports02Bindings"/></value>
+                        </entry>
+                     </map>
+                  </parameter>
+               </constructor>
+            </bean>
+         </parameter>
+      </constructor>
+
+   </bean>
+
+   <!-- The default bindings -->
+   <bean name="PortsDefaultBindings"  class="org.jboss.services.binding.impl.ServiceBindingSet">
+
+      <constructor>
+         <parameter>
+            <set>
+            <!-- ********************* conf/jboss-service.xml ****************** -->
+
+            <!-- Naming Service -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=Naming</parameter>
+                  <parameter>Port</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1099</parameter>
+               </constructor>
+            </bean>
+
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=Naming</parameter>
+                  <parameter>RmiPort</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1098</parameter>
+               </constructor>
+            </bean>
+            
+            <!-- Remote classloading service -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=WebService</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>8083</parameter>
+               </constructor>
+            </bean>
+
+            <!-- Remoting Connector -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.remoting:service=Connector,transport=socket</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4446</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/remoting-service.xml ****************** -->
+ 
+            <!-- RMI/JRMP invoker -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=invoker,type=jrmp</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4444</parameter>
+               </constructor>
+            </bean>
+
+            <!-- Pooled invoker -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=invoker,type=pooled</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4445</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/cluster/hajndi-service.xml ****************** -->
+
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=HAJNDI</parameter>
+                  <parameter>Port</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1100</parameter>
+               </constructor>
+            </bean>
+
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=HAJNDI</parameter>
+                  <parameter>RmiPort</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1101</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/cluster/ha-legacy-service.xml ****************** -->
+ 
+            <!-- HA RMI/JRMP invoker -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=invoker,type=jrmpha</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4447</parameter>
+               </constructor>
+            </bean>
+
+            <!-- HA Pooled invoker -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=invoker,type=pooledha</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4448</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/iiop-service.xml ****************** -->
+
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=CorbaORB</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>3528</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/snmp-adaptor.sar **************** -->
+
+            <!-- Trap receiver that acts as an SNMP Manager -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.jmx:name=SnmpAgent,service=trapd,type=logger</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1162</parameter>
+               </constructor>
+            </bean>
+
+            <!-- The SNMP adaptor MBean -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1161</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/jmx-remoting.sar **************** -->
+
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.remoting:service=JMXConnectorServer,protocol=rmi</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1090</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/ejb3-connectors-service.xml **************** -->
+
+            <!-- EJB3 wants to have the service create its own ServiceBinding object
+                 dynamically.  See the value-factory usage in deploy/ejb3-connectors-service.xml -->
+                 
+
+            <!-- ********************* deploy/jbossweb.sar **************** -->
+            <!-- ********************* deploy/httpha-invoker.sar **************** -->
+
+            <!--
+                JBoss Web server.xml configuration. 
+
+                Same binding config can be used by the following services, or really
+                anything else that needs to point to the JBoss Web HTTP connector
+                but doesn't need an XSL Transform
+                
+                jboss:service=invoker,type=http
+                jboss:service=invoker,type=http,target=Naming
+                jboss:service=invoker,type=http,target=Naming,readonly=true
+                jboss:service=invoker,type=httpHA
+                jboss:service=invoker,type=http,target=HAJNDI
+                jboss.ws:service=ServiceEndpointManager
+            -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.web:service=WebServer</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>8080</parameter>
+               </constructor>
+               
+               <!-- 
+                   Inject a XSLT transform configuration (see below) that describes
+                   how to transform server.xml 
+                   If the binding value request doesn't require an XSL Transform, this config
+                   will be ignored.
+               -->
+               <property name="serviceBindingValueSourceConfig"><inject bean="JBossWebConnectorXSLTConfig"/></property>
+            </bean>
+
+            <!-- For services like those listed above that need to know the
+                 port of the HTTPS connector -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.web:service=WebServer</parameter>
+                  <parameter>HttpsConnector</parameter>
+                  <!-- The address/port of the JBoss Web HTTPS Connector below -->
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>8443</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/messaging/remoting-bisocket-service.xml ********************** -->
+
+            <!-- Standard JBM bisocket connector -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.messaging:service=Connector,transport=bisocket</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4457</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/transaction-jboss-beans.xml ********************** -->
+
+            <!-- JBossTS Recovery Manager -->
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>TransactionManager</parameter>                  
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>4712</parameter>
+               </constructor>
+            </bean>
+
+            <!-- ********************* deploy/hsqldb-ds.xml **************** -->
+
+            <!-- Commented out as tcp/ip access to Hypersonic is not enabled by default -->
+            <!--
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss:service=Hypersonic</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>1701</parameter>
+               </constructor>
+            </bean>
+            -->
+
+            <!-- ********************* JBoss MQ **************** -->
+            
+            <!-- Commented out as JBoss MQ is not installed by default
+                 If you uncomment this and also use jboss.mq:service=InvocationLayer,type=HTTP, 
+                 configure the http invocation layer using the jboss.web:service=WebServer binding above
+             -->
+            <!--
+            <bean class="org.jboss.services.binding.ServiceBinding">
+               <constructor>
+                  <parameter>jboss.mq:service=InvocationLayer,type=UIL2</parameter>
+                  <parameter>${jboss.bind.address}</parameter>
+                  <parameter>8093</parameter>
+               </constructor>
+            </bean>
+            -->
+         </set>
+         </parameter>
+         
+         <!-- The port offset -->
+         <parameter>0</parameter>
+         <!-- Default host name -->
+         <parameter>${jboss.bind.address}</parameter>
+      </constructor>
+   
+   </bean>
+
+   <!-- The ports-01 bindings are obtained by taking ports-default and adding 100 to each port value -->
+   <bean name="Ports01Bindings" class="org.jboss.services.binding.impl.ServiceBindingSet">
+
+      <constructor>
+         <parameter><inject bean="PortsDefaultBindings"/></parameter>
+         <!-- The port offset -->
+         <parameter>100</parameter>
+         <!-- Set of bindings to which the "offset by 100" approach can't be applied -->
+         <parameter><null/></parameter>
+         <!-- Default host name -->
+         <parameter>${jboss.bind.address}</parameter>
+      </constructor>
+   </bean>
+
+   <!-- The ports-02 bindings are obtained by taking ports-default and adding 200 to each port value -->
+   <bean name="Ports02Bindings" class="org.jboss.services.binding.impl.ServiceBindingSet">
+
+      <constructor>
+         <parameter><inject bean="PortsDefaultBindings"/></parameter>
+         <!-- The port offset -->
+         <parameter>200</parameter>
+         <!-- Set of bindings to which the "offset by 200" approach can't be applied -->
+         <parameter><null/></parameter>
+         <!-- Default host name -->
+         <parameter>${jboss.bind.address}</parameter>
+      </constructor>
+   </bean>
+
+   <!-- XSL Transform to apply to server.xml -->
+   <bean name="JBossWebConnectorXSLTConfig" 
+         class="org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig">
+
+      <constructor>
+          <parameter><![CDATA[
+   <xsl:stylesheet
+         xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+     <xsl:output method="xml" />
+     <xsl:param name="port"/>
+
+     <xsl:variable name="portAJP" select="$port - 71"/>
+     <xsl:variable name="portHttps" select="$port + 363"/>
+
+     <xsl:template match="/">
+       <xsl:apply-templates/>
+     </xsl:template>
+
+      <xsl:template match = "Connector">
+         <Connector>
+            <xsl:for-each select="@*">
+            <xsl:choose>
+               <xsl:when test="(name() = 'port' and . = '8080')">
+                  <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
+               </xsl:when>
+               <xsl:when test="(name() = 'port' and . = '8009')">
+                  <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
+               </xsl:when>
+               <xsl:when test="(name() = 'redirectPort')">
+                  <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
+               </xsl:when>
+               <xsl:when test="(name() = 'port' and . = '8443')">
+                  <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
+               </xsl:when>
+               <xsl:otherwise>
+                  <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
+               </xsl:otherwise>
+            </xsl:choose>
+            </xsl:for-each>
+            <xsl:apply-templates/>
+         </Connector>
+      </xsl:template>
+
+     <xsl:template match="*|@*">
+       <xsl:copy>
+         <xsl:apply-templates select="@*|node()"/>
+       </xsl:copy>
+     </xsl:template>
+   </xsl:stylesheet>
+   ]]>
+          </parameter>
+      </constructor>
+   </bean>
+
+</deployment>

Added: trunk/server/src/etc/conf/default/bootstrap-minimal.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-minimal.xml	                        (rev 0)
+++ trunk/server/src/etc/conf/default/bootstrap-minimal.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   The list of configurations used to bootstrap the server
+   using hot deployment for the profile service
+-->
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+   <url>classloader.xml</url>
+   <url>aop.xml</url>
+   <url>jmx.xml</url>
+   <url>deployers.xml</url>
+   <url>profile.xml</url>
+
+</bootstrap>

Modified: trunk/server/src/etc/conf/default/bootstrap-repo.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-repo.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/server/src/etc/conf/default/bootstrap-repo.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -10,6 +10,7 @@
    <url>aop.xml</url>
    <url>jmx.xml</url>
    <url>deployers.xml</url>
+   <url>bindings.xml</url>
    <url>profile-repository.xml</url>
 
 </bootstrap>

Modified: trunk/server/src/etc/conf/default/bootstrap.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/server/src/etc/conf/default/bootstrap.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -10,6 +10,7 @@
    <url>aop.xml</url>
    <url>jmx.xml</url>
    <url>deployers.xml</url>
+   <url>bindings.xml</url>
    <url>profile.xml</url>
 
 </bootstrap>

Modified: trunk/server/src/etc/conf/default/jboss-service.xml
===================================================================
--- trunk/server/src/etc/conf/default/jboss-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/server/src/etc/conf/default/jboss-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -162,39 +162,6 @@
    </mbean>
 
    <!-- ==================================================================== -->
-   <!-- Service Binding                                                      -->
-   <!-- ==================================================================== -->
-
-   <!-- Automatically activated when generatting the clustering environment -->
-   <!-- @TESTSUITE_CLUSTER_CONFIG@ -->
-
-   <!--
-      | Binding service manager for port/host mapping. This is a sample
-      | config that demonstrates a JBoss instances with a server name 'jboss1'
-      | loading its bindings from an XML file using the ServicesStoreFactory
-      | implementation returned by the XMLServicesStoreFactory.
-      |
-      | ServerName: The unique name assigned to a JBoss server instance for
-      | lookup purposes. This allows a single ServicesStore to handle mulitiple
-      | JBoss servers.
-      |
-      | StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore
-      | during initialization that specifies how to connect to the bindings store.
-      | StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface
-      | implementation to create to obtain the ServicesStore instance.
-
-   <mbean code="org.jboss.services.binding.ServiceBindingManager"
-     name="jboss.system:service=ServiceBindingManager">
-     <attribute name="ServerName">ports-01</attribute>
-     <attribute name="StoreURL">../docs/examples/binding-manager/sample-bindings.xml</attribute>
-     <attribute name="StoreFactoryClassName">
-       org.jboss.services.binding.XMLServicesStoreFactory
-     </attribute>
-   </mbean>
-
-   -->
-
-   <!-- ==================================================================== -->
    <!-- Class Loading                                                        -->
    <!-- ==================================================================== -->
 
@@ -203,7 +170,10 @@
       name="jboss:service=WebService">
       <!-- The Bind address and Port -->
       <attribute name="BindAddress">${jboss.bind.address}</attribute>      
-      <attribute name="Port">8083</attribute>
+      <attribute name="Port">
+         <!-- Get the port to use from ServiceBindingManager. -->
+         <value-factory bean="ServiceBindingManager" method="getIntBinding" parameter="jboss:service=WebService"/>
+      </attribute>
       <!--  The address to use for the host portion of the RMI codebase URL -->
       <attribute name="Host">${java.rmi.server.hostname}</attribute>
       <!-- Should non-EJB .class files be downloadable -->
@@ -241,16 +211,28 @@
          the caller's TCL, false if in VM lookups return the value by reference.
       -->
       <attribute name="CallByValue">false</attribute>
+      
       <!-- The listening port for the bootstrap JNP service. Set this to -1
          to run the NamingService without the JNP invoker listening port.
       -->
-      <attribute name="Port">1099</attribute>
+      <attribute name="Port">
+         <value-factory bean="ServiceBindingManager" method="getIntBinding">
+            <parameter>jboss:service=Naming</parameter>
+            <parameter>Port</parameter>
+         </value-factory>
+      </attribute>
+      
       <!-- The bootstrap JNP server bind address. This also sets the default
          RMI service bind address. Empty == all addresses
       -->
       <attribute name="BindAddress">${jboss.bind.address}</attribute>
       <!-- The port of the RMI naming service, 0 == anonymous -->
-      <attribute name="RmiPort">1098</attribute>
+      <attribute name="RmiPort">
+         <value-factory bean="ServiceBindingManager" method="getIntBinding">
+            <parameter>jboss:service=Naming</parameter>
+            <parameter>RmiPort</parameter>
+         </value-factory>
+      </attribute>
       <!-- The RMI service bind address. Empty == all addresses
       -->
       <attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
@@ -339,11 +321,22 @@
 
        <!-- Remember that if you do use more than one param on the uri, will have to include as a CDATA, -->
        <!-- otherwise, parser will complain. -->
-       <!-- <attribute name="InvokerLocator"><![CDATA[socket://${jboss.bind.address}:4446/?datatype=invocation]]></attribute> -->
+       <!-- 
+       <attribute name="InvokerLocator">
+          <value-factory bean="ServiceBindingManager" method="getStringBinding">
+             <parameter>jboss.remoting:service=Connector,transport=socket</parameter>
+             <parameter><![CDATA[socket://${host}:${port}/?datatype=invocation]]></parameter>
+          </value-factory>
+       </attribute>
+       -->
 
       <attribute name="Configuration">
          <!-- Using the following <invoker> element instead of the InvokerLocator above because specific attributes needed. -->
          <!-- If wanted to use any of the parameters below, can just add them as parameters to the url above if wanted use the InvokerLocator attribute. -->
+         
+         <value-factory bean="ServiceBindingManager" method="getElementBinding">
+             <parameter>jboss.remoting:service=Connector,transport=socket</parameter>
+             <parameter><![CDATA[
          <config>
             <!-- Other than transport type and handler, none of these configurations are required (will just use defaults). -->
             <invoker transport="socket">
@@ -357,8 +350,8 @@
                <!-- <attribute name="maxPoolSize">303</attribute>-->
                <!-- <attribute name="clientMaxPoolSize" isParam="true">304</attribute>-->
                <attribute name="socketTimeout" isParam="true">600000</attribute>
-               <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
-               <attribute name="serverBindPort">4446</attribute>
+               <attribute name="serverBindAddress">${host}</attribute>
+               <attribute name="serverBindPort">${port}</attribute>
                <!-- <attribute name="clientConnectAddress">216.23.33.2</attribute> -->
                <!-- <attribute name="clientConnectPort">7777</attribute> -->
                <attribute name="enableTcpNoDelay" isParam="true">true</attribute>
@@ -389,6 +382,9 @@
                <handler subsystem="JSR88">org.jboss.deployment.remoting.DeployHandler</handler>
             </handlers>
          </config>
+         ]]>
+            </parameter>
+         </value-factory>
       </attribute>
       <depends>jboss.remoting:service=NetworkRegistry</depends>
    </mbean>

Modified: trunk/server/src/etc/deploy/remoting-service.xml
===================================================================
--- trunk/server/src/etc/deploy/remoting-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/server/src/etc/deploy/remoting-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -31,7 +31,9 @@
    <!-- RMI/JRMP invoker -->
    <mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker"
       name="jboss:service=invoker,type=jrmp">
-      <attribute name="RMIObjectPort">4444</attribute>
+      <attribute name="RMIObjectPort">
+         <value-factory bean="ServiceBindingManager" method="getIntBinding" parameter="jboss:service=invoker,type=jrmp"/>
+      </attribute>
       <attribute name="ServerAddress">${jboss.bind.address}</attribute>
       <!--
       <attribute name="RMIClientSocketFactory">custom</attribute>
@@ -55,7 +57,9 @@
       <attribute name="ClientMaxPoolSize">300</attribute>
       <attribute name="SocketTimeout">300000</attribute>
       <attribute name="ServerBindAddress">${jboss.bind.address}</attribute>
-      <attribute name="ServerBindPort">4445</attribute>
+      <attribute name="ServerBindPort">
+         <value-factory bean="ServiceBindingManager" method="getIntBinding" parameter="jboss:service=invoker,type=pooled"/>
+      </attribute>
       <attribute name="ClientConnectAddress">${jboss.bind.address}</attribute>
       <attribute name="ClientConnectPort">0</attribute>
       <attribute name="ClientRetryCount">1</attribute>

Modified: trunk/system-jmx/src/main/org/jboss/system/ServiceConfigurator.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/ServiceConfigurator.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/main/org/jboss/system/ServiceConfigurator.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -78,9 +78,6 @@
    
    /** The ServiceCreator */
    private final ServiceCreator serviceCreator;
-   
-   /** The ServiceBinding plugin policy */
-   private ServiceBinding serviceBinding;
 
    /** Instance logger. */
    private static final Logger log = Logger.getLogger(ServiceConfigurator.class);
@@ -171,29 +168,6 @@
       
       throw new IllegalArgumentException("Either the server or controller must be passed");
    }
-   
-   /**
-    * Apply any service binding overrides
-    *
-    * @review why isn't the MBeanServer part of this api?
-    * @param server the server
-    * @param objectName the object name
-    * @param serviceBinding the service binding
-    * @throws Exception for any error
-    */
-   public static void applyServiceConfig(MBeanServer server, ObjectName objectName, ServiceBinding serviceBinding) throws Exception
-   {
-      try
-      {
-         serviceBinding.applyServiceConfig(objectName);
-      }
-      catch (Throwable e)
-      {
-         // serviceBinding is most probably a dynamic mbean proxy
-         Throwable t = JMXExceptionDecoder.decode(e);            
-         log.warn("Failed to apply service binding override for " + objectName, t);         
-      }
-   }
 
    /**
     * Get an attribute map for the MBean
@@ -250,22 +224,9 @@
       this.server = server;
       this.serviceController = serviceController;
       this.serviceCreator = serviceCreator;
-      if (serviceController != null)
-         this.serviceBinding = serviceController.getServiceBinding();
    }
    
    /**
-    * Dynamically plug-in a ServiceBinding policy
-    * to possibly override the configuration of a service.
-    * 
-    * @param serviceBinding policy
-    */   
-   public void setServiceBinding(ServiceBinding serviceBinding)
-   {
-      this.serviceBinding = serviceBinding;
-   }
-   
-   /**
     * The <code>install</code> method iterates through the mbean tags in the
     * supplied xml configuration and creates and configures the mbeans shown.
     * The mbean configuration can be nested.
@@ -297,8 +258,6 @@
             ServiceCreator.install(server, objectName, metaData, null);
             result.add(objectName);
             configure(server, null, objectName, loaderName, attrs);
-            if (serviceBinding != null)
-               applyServiceConfig(server, objectName, serviceBinding);
          }
          catch (Throwable t)
          {

Modified: trunk/system-jmx/src/main/org/jboss/system/ServiceController.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/ServiceController.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/main/org/jboss/system/ServiceController.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -94,9 +94,6 @@
 
    /** A callback to the JMX MBeanServer */
    protected MBeanServer server;
-   
-   /** The service binding */
-   protected ServiceBinding serviceBinding;
 
    /** The contexts */
    protected Map<ObjectName, ServiceControllerContext> installed = new ConcurrentHashMap<ObjectName, ServiceControllerContext>(); 
@@ -154,26 +151,6 @@
    {
       this.kernel = kernel;
    }
-
-   /**
-    * Get the serviceBinding.
-    * 
-    * @return the serviceBinding.
-    */
-   public ServiceBinding getServiceBinding()
-   {
-      return serviceBinding;
-   }
-
-   /**
-    * Plugin a ServiceBinding policy
-    * 
-    * @param serviceBinding policy
-    */   
-   public void setServiceBinding(ServiceBinding serviceBinding)
-   {
-      this.serviceBinding = serviceBinding;
-   }
    
    public List<ServiceContext> listDeployed()
    {

Modified: trunk/system-jmx/src/main/org/jboss/system/ServiceControllerMBean.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/ServiceControllerMBean.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/main/org/jboss/system/ServiceControllerMBean.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -43,13 +43,6 @@
    ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=ServiceController");
    
    /**
-    * Plugin a ServiceBinding policy
-    * 
-    * @param serviceBinding policy
-    */
-   void setServiceBinding(ServiceBinding serviceBinding);
-   
-   /**
     * Lists the ServiceContexts of deployed mbeans
     * 
     * @return the list of ServiceContexts for mbeans deployed through ServiceController.

Modified: trunk/system-jmx/src/main/org/jboss/system/microcontainer/ConfigureAction.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/ConfigureAction.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/ConfigureAction.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -58,11 +58,6 @@
             ServiceConfigurator.configure(null, controller, objectName, classLoaderName, attrs);
          }
       }
-
-      // If a ServiceBinding policy is plugged-in, check for overriden attributes
-      ServiceBinding serviceBinding = context.getServiceController().getServiceBinding();
-      if (serviceBinding != null)
-         ServiceConfigurator.applyServiceConfig(server, objectName, serviceBinding);
       
       context.getServiceContext().state = ServiceContext.CONFIGURED;
    }

Modified: trunk/system-jmx/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -31,8 +31,6 @@
 import org.jboss.test.system.controller.configure.attribute.test.DependsAttributeOldUnitTestCase;
 import org.jboss.test.system.controller.configure.attribute.test.DependsListAttributeNewUnitTestCase;
 import org.jboss.test.system.controller.configure.attribute.test.DependsListAttributeOldUnitTestCase;
-import org.jboss.test.system.controller.configure.binding.test.ServiceBindingNewUnitTestCase;
-import org.jboss.test.system.controller.configure.binding.test.ServiceBindingOldUnitTestCase;
 import org.jboss.test.system.controller.configure.value.ControllerConfigureValueTestSuite;
 
 /**
@@ -58,8 +56,6 @@
       suite.addTest(DependsAttributeNewUnitTestCase.suite());
       suite.addTest(DependsListAttributeOldUnitTestCase.suite());
       suite.addTest(DependsListAttributeNewUnitTestCase.suite());
-      suite.addTest(ServiceBindingOldUnitTestCase.suite());
-      suite.addTest(ServiceBindingNewUnitTestCase.suite());
       suite.addTest(ControllerConfigureValueTestSuite.suite());
       suite.addTest(ConfigureRedeployAfterErrorOldUnitTestCase.suite());
       suite.addTest(ConfigureRedeployAfterErrorNewUnitTestCase.suite());

Modified: trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -55,7 +55,6 @@
 import org.jboss.mx.util.MBeanProxyExt;
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.ConfigurationException;
-import org.jboss.system.ServiceBinding;
 import org.jboss.system.ServiceContext;
 import org.jboss.util.Classes;
 import org.jboss.util.StringPropertyReplacer;
@@ -103,8 +102,6 @@
    /** The ServiceCreator */
    private final OldServiceCreator serviceCreator;
    
-   /** The ServiceBinding plugin policy */
-   private ServiceBinding serviceBinding;
 
    /**
     * The instance logger.
@@ -126,23 +123,11 @@
       this.server = server;
       this.serviceController = serviceController;
       this.serviceCreator = serviceCreator;
-      this.serviceBinding = null;
    }
 
    // Public --------------------------------------------------------
    
    /**
-    * Dynamically plug-in a ServiceBinding policy
-    * to possibly override the configuration of a service.
-    * 
-    * @param serviceBinding policy
-    */   
-   public void setServiceBinding(ServiceBinding serviceBinding)
-   {
-      this.serviceBinding = serviceBinding;
-   }
-   
-   /**
     * The <code>install</code> method iterates through the mbean tags in the
     * supplied xml configuration and creates and configures the mbeans shown.
     * The mbean configuration can be nested.
@@ -433,21 +418,6 @@
             } // end of if ()
          }//end of depends-list
       }
-
-      // If a ServiceBinding policy is plugged-in, check for overriden attributes
-      if (serviceBinding != null)
-      {
-         try
-         {
-            serviceBinding.applyServiceConfig(objectName);
-         }
-         catch (Exception e)
-         {
-            // serviceBinding is most probably a dynamic mbean proxy
-            Throwable t = JMXExceptionDecoder.decode(e);            
-            log.warn("Failed to apply service binding override", t);         
-         }
-      }
    }
 
    // Private -------------------------------------------------------

Modified: trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -51,7 +51,6 @@
 import org.jboss.mx.util.JMXExceptionDecoder;
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.Service;
-import org.jboss.system.ServiceBinding;
 import org.jboss.system.ServiceContext;
 import org.jboss.system.ServiceFactory;
 import org.jboss.system.ServiceMBean;
@@ -99,19 +98,6 @@
    /** A linked list of services in the order they were created **/
    protected List<ServiceContext> installedServices = new LinkedList<ServiceContext>();
 
-   /**
-    * Plugin a ServiceBinding policy
-    * 
-    * @param serviceBinding policy
-    */   
-   public void setServiceBinding(ServiceBinding serviceBinding)
-   {
-      if (configurator != null)
-      {
-         configurator.setServiceBinding(serviceBinding);
-      }
-   }
-   
    public List<ServiceContext> listDeployed()
    {
       return new ArrayList<ServiceContext>(installedServices);

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/testsuite/build.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1142,8 +1142,8 @@
    <target name="tests-binding-manager"
      description="Test for clean startup with service binding manager">
    	
-     <create-binding-manager-node conf="binding-manager1" recovery-port="4712"/>
-     <create-binding-manager-node conf="binding-manager2" recovery-port="4812"/>
+     <create-cluster-node conf="binding-manager1"/>
+     <create-cluster-node conf="binding-manager2"/>
      <server:start name="binding-manager1"/>
      <server:start name="binding-manager2"/>
 
@@ -3238,8 +3238,8 @@
       <server:stop name="tomcat-webctx"/>
 
       <!-- Test the example binding configuration -->
-      <create-binding-manager-node conf="binding-manager1" recovery-port="4712"/>
-      <create-binding-manager-node conf="binding-manager2" recovery-port="4812"/>
+      <create-cluster-node conf="binding-manager1"/>
+      <create-cluster-node conf="binding-manager2"/>
       <server:start name="binding-manager1"/>
       <server:start name="binding-manager2"/>
 

Modified: trunk/testsuite/imports/server-config.xml
===================================================================
--- trunk/testsuite/imports/server-config.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/testsuite/imports/server-config.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -829,34 +829,6 @@
       </sequential>
    </macrodef>
 
-   <!-- A macro for creating a test cluster config that uses the ServiceBindingManager.
-        Once the transaction manager supports SBM, this can be removed and 
-        replaced with a simple call to create-cluster-node.
-   -->	
-   <macrodef name="create-binding-manager-node"
-      description="Create a full cluster configuration">
-      <attribute name="conf"/>
-      <attribute name="recovery-port"/>
-      <sequential>
-         <delete dir="${jboss.dist}/server/@{conf}" failonerror="false"/>
-         <echo message="creating @{conf} config, jboss.dist=${jboss.dist}"/>
-         <copy todir="${jboss.dist}/server/@{conf}">
-            <fileset dir="${jboss.dist}/server/all">
-               <include name="conf/**"/>
-               <include name="lib/**"/>
-               <include name="deploy/**"/>
-               <include name="deployers/**"/>
-               <include name="deploy-hasingleton/**"/>
-            </fileset>
-         </copy>
-      	 <!-- Modify the transaction manager config that SBM can't handle -->
-         <replace file="${jboss.dist}/server/@{conf}/conf/jbossjta-properties.xml">
-            <replacetoken>4712</replacetoken>
-            <replacevalue>@{recovery-port}</replacevalue>
-         </replace>
-      </sequential>
-   </macrodef>
-
    <macrodef name="create-profileservice-config"
       description="Create a configuration with the full features profile service">
       <attribute name="conf"/>

Added: trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/remoting-bisocket-service.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/remoting-bisocket-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/remoting-bisocket-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+     Standard bisocket-based Remoting service deployment descriptor.
+
+     $Id: remoting-bisocket-service.xml 4010 2008-04-04 15:52:47Z clebert.suconic at jboss.com $
+ -->
+
+<server>
+
+   <!-- Standard bisocket connector - the bisocket transport only opens connection from client->server
+        so can be used with firewalls where only outgoing connections are allowed.
+        For examples of HTTP and SSL transports see docs/examples -->
+   <mbean code="org.jboss.remoting.transport.Connector"
+          name="jboss.messaging:service=Connector,transport=bisocket"
+          display-name="Bisocket Transport Connector">
+      <attribute name="Configuration">
+         <value-factory bean="ServiceBindingManager" method="getElementBinding">
+             <parameter>jboss.messaging:service=Connector,transport=bisocket</parameter>
+             <parameter><![CDATA[
+         <config>
+            <invoker transport="bisocket">
+            
+               <!-- There should be no reason to change these parameters - warning!
+                    Changing them may stop JBoss Messaging working correctly -->            
+               <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+               <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+               <attribute name="dataType" isParam="true">jms</attribute>
+               <attribute name="socket.check_connection" isParam="true">false</attribute>               
+               <attribute name="serverBindAddress">${host}</attribute>
+               <attribute name="serverBindPort">${port}</attribute>
+               <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+               <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+           
+               <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+               <attribute name="pingFrequency" isParam="true">214748364</attribute>
+               <attribute name="pingWindowFactor" isParam="true">10</attribute>
+               <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+               <!-- End immutable parameters -->
+           
+               <attribute name="stopLeaseOnFailure" isParam="true">true</attribute>
+               
+               <!-- Periodicity of client pings. Server window by default is twice this figure -->                               
+               <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+                   
+               <attribute name="timeout" isParam="true">0</attribute>
+
+               <!-- Number of seconds to wait for a connection in the client pool to become free -->
+               <attribute name="numberOfRetries" isParam="true">10</attribute>
+
+               <!-- Max Number of connections in client pool. This should be significantly higher than
+                    the max number of sessions/consumers you expect -->
+               <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+               
+                 <!-- The maximum time to wait before timing out on trying to write a message to socket for delivery -->
+               <attribute name="callbackTimeout">10000</attribute> 
+                                             
+               <!-- Use these parameters to specify values for binding and connecting control connections to 
+                    work with your firewall/NAT configuration
+               <attribute name="secondaryBindPort">xyz</attribute>                           
+               <attribute name="secondaryConnectPort">abc</attribute>               
+               -->
+                          
+            </invoker>
+            <handlers>
+               <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+            </handlers>
+         </config>
+         ]]>
+            </parameter>
+         </value-factory>
+      </attribute>
+   </mbean>
+
+</server>

Added: trunk/testsuite/src/resources/test-configs/binding-manager2/conf/jbossjta-properties.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/binding-manager2/conf/jbossjta-properties.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/test-configs/binding-manager2/conf/jbossjta-properties.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<transaction-service>
+    <properties depends="common" name="arjuna">
+        <!--
+        Transaction Reaper Timeout (default is 120000 ms).
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.coordinator.txReaperTimeout" value="120000"/>
+        <!--
+        Transaction Reaper Mode, can be: NORMAL or DYNAMIC
+        (default is NORMAL but DYNAMIC is recommended for most usage).
+      -->
+        <property name="com.arjuna.ats.arjuna.coordinator.txReaperMode" value="DYNAMIC"/>
+        <!--
+        Transaction Reaper Cancel Wait Period (default is 500 ms, min is 10 msecs).
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.coordinator.txReaperCancelWaitPeriod" value="500"/>
+        <!--
+        Transaction Reaper Cancel Fail Wait Period (default is 500 ms, min is 10 msecs).
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.coordinator.txReaperCancelFailWaitPeriod" value="500"/>
+        <!--
+        Transaction Reaper Zombie Max (default is 8).
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.coordinator.txReaperZombieMax" value="8"/>
+        <!--
+        (default is NO)
+      -->
+        <property name="com.arjuna.ats.arjuna.coordinator.asyncCommit" value="NO"/>
+        <!--
+        (default is NO)
+      -->
+        <property name="com.arjuna.ats.arjuna.coordinator.asyncPrepare" value="NO"/>
+        <!--
+        (default is YES)
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.coordinator.commitOnePhase" value="YES"/>
+        <!--
+        (default is defaultStore)
+      -->
+        <property name="com.arjuna.ats.arjuna.objectstore.localOSRoot" value="defaultStore"/>
+        <!--
+        default is under user.home - must be writeable!)
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.objectstore.objectStoreDir" value="PutObjectStoreDirHere"/>
+        <!--
+        (default is ON)
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.objectstore.objectStoreSync" value="ON"/>
+        <!--
+        (default is ShadowNoFileLockStore)
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.objectstore.objectStoreType" value="ShadowNoFileLockStore"/>
+        <!--
+        (default is 255)
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.objectstore.hashedDirectories" value="255"/>
+        <!--
+        (default is ON)
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.objectstore.transactionSync" value="ON"/>
+        <!--
+        (Must be unique across all Arjuna instances.)
+      -->
+        <property name="com.arjuna.ats.arjuna.xa.nodeIdentifier" value="1"/>
+        <!--
+        Base port number for determining a unique number to associate with an instance of the transaction service
+        (which is needed in order to support multiple instances on the same machine).
+        Use the value 0 to allow the system to select the first available port number.
+        If the port number is non-zero and the port is in use then the value will be incremented until either a successful binding
+        to the loopback address is created or until the the maximum number of ports (specified by the
+        com.arjuna.ats.internal.arjuna.utils.SocketProcessIdMaxPorts property) have been tried or until the port number
+        reaches the maximum possible port number.
+      -->
+        <property
+            name="com.arjuna.ats.internal.arjuna.utils.SocketProcessIdPort" value="0"/>
+        <!--
+        The maximum number of ports to try starting from the value specified by the property
+        com.arjuna.ats.internal.arjuna.utils.SocketProcessIdPort. Any non-numeric or value less than 1 will
+        defautl to 1.
+      -->
+        <property
+            name="com.arjuna.ats.internal.arjuna.utils.SocketProcessIdMaxPorts" value="1"/>
+        <!-- property
+        name="com.arjuna.ats.arjuna.coordinator.actionStore"
+		value="HashedActionStore"
+		value="JDBCActionStore"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.objectstore.jdbcTxDbAccess"
+		value="JDBCAccess"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.objectstore.objectStoreType"
+		value="ShadowNoFileLockStore"
+		value="JDBCStore"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.objectstore.jdbcUserDbAccess"
+		value="JDBCAccess"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.objectstore.jdbcPoolSizeInitial"
+		value="1"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.objectstore.jdbcPoolSizeMaximum"
+		value="1"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.objectstore.jdbcPoolPutConnections"
+		value="false"
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.internal.arjuna.objectstore.cacheStore.size"
+		value=""
+      -->
+        <!-- property
+        name="com.arjuna.ats.arjuna.internal.arjuna.objectstore.cacheStore.period"
+		value=""
+      -->
+        <!--
+        The location for creating temporary files, e.g., Uids.
+        Default is under user.home.
+        IMPORTANT: make sure the directory is lockable, e.g., /tmp on Unix
+        may not be!
+      -->
+        <!--
+        <property
+          name="com.arjuna.ats.arjuna.common.varDir"
+          value="var"/>
+      -->
+    </properties>
+    <properties name="common">
+        <!-- CLF 2.0 properties -->
+        <property name="com.arjuna.common.util.logging.DebugLevel"
+            type="System" value="0x00000000"/>
+        <property name="com.arjuna.common.util.logging.FacilityLevel"
+            type="System" value="0xffffffff"/>
+        <property name="com.arjuna.common.util.logging.VisibilityLevel"
+            type="System" value="0xffffffff"/>
+        <property name="com.arjuna.common.util.logger" type="System" value="log4j"/>
+    </properties>
+    <properties depends="arjuna" name="txoj">
+        <!--
+        (default is LockStore of installation - must be writeable!)
+      -->
+        <!--
+        <property
+          name="com.arjuna.ats.txoj.lockstore.lockStoreDir"
+          value="LockStore"/>
+      -->
+        <!--
+        (default is BasicLockStore)
+      -->
+        <property name="com.arjuna.ats.txoj.lockstore.lockStoreType" value="BasicLockStore"/>
+        <!--
+        (default is NO)
+      -->
+        <property name="com.arjuna.ats.txoj.lockstore.multipleLockStore" value="NO"/>
+        <!--
+        (default is YES)
+      -->
+        <property name="com.arjuna.ats.txoj.lockstore.singleLockStore" value="YES"/>
+        <!--
+        (default is YES)
+      -->
+        <property
+            name="com.arjuna.ats.txoj.lockstore.allowNestedLocking" value="YES"/>
+    </properties>
+    <properties depends="arjuna" name="jta">
+        <!--
+        Support subtransactions in the JTA layer?
+        Default is NO.
+      -->
+        <property name="com.arjuna.ats.jta.supportSubtransactions" value="NO"/>
+        <property name="com.arjuna.ats.jta.jtaTMImplementation" value="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple"/>
+        <!--
+			com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple
+			-->
+        <property name="com.arjuna.ats.jta.jtaUTImplementation" value="com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple"/>
+        <!--
+			com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple
+			-->
+    </properties>
+    <properties depends="arjuna,txoj,jta" name="recoverymanager">
+        <!--
+        Properties used only by the RecoveryManager.
+      -->
+        <!--
+        Periodic recovery settings.
+        Time values in this section are in seconds.
+      -->
+        <!--
+        Interval in seconds between initiating the periodic recovery modules.
+        Default is 120 seconds.
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.periodicRecoveryPeriod" value="120"/>
+        <!--
+        Interval in seconds between first and second pass of periodic recovery.
+        Default is 10 seconds.
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.recoveryBackoffPeriod" value="10"/>
+        <!--
+        The port number on which the recovery manager listens.
+      -->
+        <property name="com.arjuna.ats.arjuna.recovery.recoveryPort" value="4812"/>
+        <!--
+        The address on which the recovery manager listens.
+        If running within an AS then the address the AS is bound to (jboss.bind.address) takes precedence
+      -->
+        <property name="com.arjuna.ats.arjuna.recovery.recoveryAddress" value=""/>
+        <!--
+        Periodic recovery modules to use.  Invoked in sort-order of names.
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.recoveryExtension1" value="com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule"/>
+        <property
+            name="com.arjuna.ats.arjuna.recovery.recoveryExtension2" value="com.arjuna.ats.internal.txoj.recovery.TORecoveryModule"/>
+        <property
+            name="com.arjuna.ats.arjuna.recovery.recoveryExtension3" value="com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule"/>
+        <!--
+        Expired entry removal
+      -->
+        <!--
+        Expiry scanners to use (order of invocation is random).
+        Names must begin with "com.arjuna.ats.arjuna.recovery.expiryScanner"
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.expiryScannerTransactionStatusManager" value="com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner"/>
+        <!--
+        Interval, in hours, between running the expiry scanners.
+        This can be quite long. The absolute value determines the interval -
+        if the value is negative, the scan will NOT be run until after one
+        interval has elapsed. If positive the first scan will be immediately
+        after startup. Zero will prevent any scanning.
+        Default  = 12 = run immediately, then every 12 hours.
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.expiryScanInterval" value="12"/>
+        <!--
+        Age, in hours, for removal of transaction status manager item.
+        This should be longer than any ts-using process will remain running.
+        Zero = Never removed.  Default is 12.
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.transactionStatusManagerExpiryTime" value="12"/>
+        <!--
+        Use this to fix the port on which the TransactionStatusManager listens,
+        The default behaviour is to use any free port.
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.transactionStatusManagerPort" value="0"/>
+        <!--
+        Use this to fix the address on which the TransactionStatusManager binds,
+        The default behaviour is to use the loopback address (ie localhost).
+        If running within an AS then the address the AS is bound to (jboss.bind.address) takes precedence
+      -->
+        <property
+            name="com.arjuna.ats.arjuna.recovery.transactionStatusManagerAddress" value=""/>
+    </properties>
+    <properties depends="jta" name="jdbc">
+        <!--
+           property name="com.arjuna.ats.jdbc.isolationLevel" value="TRANSACTION_SERIALIZABLE"/>
+        -->
+    </properties>
+</transaction-service>

Added: trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/remoting-bisocket-service.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/remoting-bisocket-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/remoting-bisocket-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+     Standard bisocket-based Remoting service deployment descriptor.
+
+     $Id: remoting-bisocket-service.xml 4010 2008-04-04 15:52:47Z clebert.suconic at jboss.com $
+ -->
+
+<server>
+
+   <!-- Standard bisocket connector - the bisocket transport only opens connection from client->server
+        so can be used with firewalls where only outgoing connections are allowed.
+        For examples of HTTP and SSL transports see docs/examples -->
+   <mbean code="org.jboss.remoting.transport.Connector"
+          name="jboss.messaging:service=Connector,transport=bisocket"
+          display-name="Bisocket Transport Connector">
+      <attribute name="Configuration">
+         <value-factory bean="ServiceBindingManager" method="getElementBinding">
+             <parameter>jboss.messaging:service=Connector,transport=bisocket</parameter>
+             <parameter><![CDATA[
+         <config>
+            <invoker transport="bisocket">
+            
+               <!-- There should be no reason to change these parameters - warning!
+                    Changing them may stop JBoss Messaging working correctly -->            
+               <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+               <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute>
+               <attribute name="dataType" isParam="true">jms</attribute>
+               <attribute name="socket.check_connection" isParam="true">false</attribute>               
+               <attribute name="serverBindAddress">${host}</attribute>
+               <attribute name="serverBindPort">${port}</attribute>
+               <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
+               <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
+           
+               <attribute name="numberOfCallRetries" isParam="true">1</attribute>
+               <attribute name="pingFrequency" isParam="true">214748364</attribute>
+               <attribute name="pingWindowFactor" isParam="true">10</attribute>
+               <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute>
+               <!-- End immutable parameters -->
+           
+               <attribute name="stopLeaseOnFailure" isParam="true">true</attribute>
+               
+               <!-- Periodicity of client pings. Server window by default is twice this figure -->                               
+               <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
+                   
+               <attribute name="timeout" isParam="true">0</attribute>
+
+               <!-- Number of seconds to wait for a connection in the client pool to become free -->
+               <attribute name="numberOfRetries" isParam="true">10</attribute>
+
+               <!-- Max Number of connections in client pool. This should be significantly higher than
+                    the max number of sessions/consumers you expect -->
+               <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute>
+               
+                 <!-- The maximum time to wait before timing out on trying to write a message to socket for delivery -->
+               <attribute name="callbackTimeout">10000</attribute> 
+                                             
+               <!-- Use these parameters to specify values for binding and connecting control connections to 
+                    work with your firewall/NAT configuration
+               <attribute name="secondaryBindPort">xyz</attribute>                           
+               <attribute name="secondaryConnectPort">abc</attribute>               
+               -->
+                          
+            </invoker>
+            <handlers>
+               <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
+            </handlers>
+         </config>
+         ]]>
+            </parameter>
+         </value-factory>
+      </attribute>
+   </mbean>
+
+</server>

Modified: trunk/tomcat/src/resources/war-deployers-jboss-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-jboss-beans.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/tomcat/src/resources/war-deployers-jboss-beans.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -147,7 +147,16 @@
       <!-- Inject the MainDeployer for resolving cross deployment refs -->
       <property name="mainDeployer"><inject bean="MainDeployer" /></property>
 
-      <property name="relativeOrder">2003</property>
+      <property name="relativeOrder">2003</property>
+      
+      <!-- FIXME Get this moved to TomcatService in deploy -->
+      <property name="configFile">
+         <value-factory bean="ServiceBindingManager" method="getResourceBinding">
+            <parameter>jboss.web:service=WebServer</parameter>
+            <parameter>${jboss.server.home.url}${/}deploy${/}jbossweb.sar${/}server.xml</parameter>
+         </value-factory>
+      </property>
+      
       <!-- You can configure a set of authenticators keyed by http-auth method
       used. This will apply the same set of authenticators across all web
       applications. You can override the set of authenticators at the web

Modified: trunk/varia/.classpath
===================================================================
--- trunk/varia/.classpath	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/.classpath	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry excluding="org/jboss/jaxr/|org/jboss/jdo/castor/|org/jboss/tm/plugins/tyrex/|org/jboss/varia/stats/DataSourceInterceptorJDK6.java" kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/tests"/>
+	<classpathentry kind="src" path="src/resources/tests"/>
 	<classpathentry exported="true" kind="src" path="/cluster"/>
 	<classpathentry kind="src" path="/jbossmq"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
@@ -19,5 +21,6 @@
 	<classpathentry kind="lib" path="/thirdparty/juddi/lib/juddi.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/beanshell/lib/bsh.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client.jar" sourcepath="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar" sourcepath="/thirdparty/junit/lib/junit-src.zip"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: trunk/varia/build.xml
===================================================================
--- trunk/varia/build.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/build.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -451,8 +451,8 @@
       <fileset dir="${build.resources}/jmx/examples/mbean-configurator-service"/>
     </jar>
 
-    <!-- bindingservice-plugin.jar -->
-    <jar jarfile="${build.lib}/bindingservice-plugin.jar"
+    <!-- jboss-bindingservice.jar -->
+    <jar jarfile="${build.lib}/jboss-bindingservice.jar"
       manifest="${build.etc}/default.mf">
       <fileset dir="${build.classes}">
         <include name="org/jboss/services/binding/**"/>

Deleted: trunk/varia/src/main/org/jboss/services/binding/AttributeMappingDelegate.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/AttributeMappingDelegate.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/AttributeMappingDelegate.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,225 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-import java.util.HashMap;
-import java.beans.PropertyEditorManager;
-import java.beans.PropertyEditor;
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.MBeanInfo;
-import javax.management.MBeanAttributeInfo;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.MetaData;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.util.Classes;
-import org.jboss.deployment.DeploymentException;
-
-/** An implementation of the ServicesConfigDelegate that expects a delegate-config
- element of the form:
-    <delegate-config portName="portAttrName" hostName="hostAttrName">
-      <attribute name="mbeanAttrName">host-port-expr</attribute>
-      ...
-    </delegate-config>
- where the portAttrName is the attribute name of the mbean service
- to which the (int port) value should be applied and the hostAttrName
- is the attribute name of the mbean service to which the (String virtualHost)
- value should be applied.
-
- Any mbeanAttrName attribute reference has the corresponding value replaced
- with any ${host} and ${port} references with the associated host and port
- bindings.
-
- @author Scott.Stark at jboss.org
- @version $Revision$
- */
-public class AttributeMappingDelegate
-   implements ServicesConfigDelegate
-{
-   private static Logger log = Logger.getLogger(AttributeMappingDelegate.class);
-
-   /** Take the given config and map it onto the service specified in the
-    config using JMX via the given server.
-    @param config, the service name and its config bindings
-    @param server, the JMX server to use to apply the config
-    */
-   public void applyConfig(ServiceConfig config, MBeanServer server)
-      throws Exception
-   {
-      Element delegateConfig = (Element) config.getServiceConfigDelegateConfig();
-      if( delegateConfig == null )
-         throw new IllegalArgumentException("ServiceConfig.ServiceConfigDelegateConfig is null");
-      // Check for a port and host name
-      String portAttrName = delegateConfig.getAttribute("portName");
-      if( portAttrName.length() == 0 )
-         portAttrName = null;
-      String hostAttrName = delegateConfig.getAttribute("hostName");
-      if( hostAttrName.length() == 0 )
-         hostAttrName = null;
-
-      // Check for any arbitrary attributes
-      NodeList attributes = delegateConfig.getElementsByTagName("attribute");
-
-      // Only the first binding is used as only one (host,port) pair is mapped
-      ServiceBinding[] bindings = config.getBindings();
-      if( bindings != null && bindings.length > 0 )
-      {
-         // Build a mapping of the attribute names to their type name
-         ObjectName serviceName = new ObjectName(config.getServiceName());
-         MBeanInfo info = server.getMBeanInfo(serviceName);
-         MBeanAttributeInfo[] attrInfo = info.getAttributes();
-         HashMap attrTypeMap = new HashMap();
-         for(int a = 0; a < attrInfo.length; a ++)
-         {
-            MBeanAttributeInfo attr = attrInfo[a];
-            attrTypeMap.put(attr.getName(), attr.getType());
-         }
-
-         int port = bindings[0].getPort();
-         String host = bindings[0].getHostName();
-         // Apply the port setting override if the port name was given
-         if( portAttrName != null )
-         {
-            Attribute portAttr = new Attribute(portAttrName, new Integer(port));
-            log.debug("setPort, name='"+portAttrName+"' value="+port);
-            server.setAttribute(serviceName, portAttr);
-         }
-         // Apply the host setting override if the port name was given
-         if( hostAttrName != null )
-         {
-            Attribute hostAttr = createAtribute(port, host, attrTypeMap,
-               hostAttrName, host);
-            log.debug("setHost, name='"+hostAttrName+"' value="+host);
-            server.setAttribute(serviceName, hostAttr);
-         }
-
-         /* Apply any other host/port based attributes with replacement of
-          the ${host} and ${port} strings.
-         */
-         for(int a = 0; a < attributes.getLength(); a ++)
-         {
-            Element attr = (Element) attributes.item(a);
-            String name = attr.getAttribute("name");
-            if( name.length() == 0 )
-               throw new IllegalArgumentException("attribute element #"+a+" has no name attribute");
-            String attrExp = MetaData.getElementContent(attr);
-            Attribute theAttr = createAtribute(port, host, attrTypeMap,
-               name, attrExp);
-            server.setAttribute(serviceName, theAttr);
-         }
-      }
-      else
-      {
-         /**
-          * Apply attributes even if not using port or host
-          */
-         for(int a = 0; a < attributes.getLength(); a ++)
-         {
-            Element attr = (Element) attributes.item(a);
-            String name = attr.getAttribute("name");
-            if( name.length() == 0 )
-               throw new IllegalArgumentException("attribute element #"+a+" has no name attribute");
-            String attrExp = MetaData.getElementContent(attr);
-            Attribute attribute = new Attribute(name, attrExp);
-            ObjectName serviceName = new ObjectName(config.getServiceName());
-            server.setAttribute(serviceName, attribute);
-         }
-      }
-   }
-
-   /** Create a JMX Attribute with the correct type value object. This
-    * converts the given attrExp into an Attribute for attrName with
-    * replacement of any ${host} ${port} references in the attrExp
-    * replaced with the given port/host values.
-    * @param port The binding port value
-    * @param host The binding host value
-    * @param attrTypeMap the name to type map for the service attributes
-    * @param attrName the name of the attribute to create
-    * @param attrExp the string exp for the attribute value
-    * @return the JMX attribute instance
-    * @throws Exception thrown on an invalid attribute name or inability
-    *    to find a valid property editor
-    */
-   private Attribute createAtribute(int port, String host,
-      HashMap attrTypeMap, String attrName, String attrExp)
-      throws Exception
-   {
-      String attrText = replaceHostAndPort(attrExp, host, ""+port);
-      String typeName = (String) attrTypeMap.get(attrName);
-      if( typeName == null )
-      {
-         throw new DeploymentException("No such attribute: " + attrName);
-      }
-      // Convert the type
-      Class attrType = Classes.loadClass(typeName);
-      PropertyEditor editor = PropertyEditorManager.findEditor(attrType);
-      if( editor == null )
-      {
-         String msg = "No property editor for attribute: " + attrName +
-            "; type=" + typeName;
-         throw new DeploymentException(msg);
-      }
-      editor.setAsText(attrText);
-      Object attrValue = editor.getValue();
-      log.debug("setAttribute, name='"+attrName+"', text="+attrText
-         +", value="+attrValue);
-      Attribute theAttr = new Attribute(attrName, attrValue);
-      return theAttr;
-   }
-
-   /** Loop over text and replace any ${host} and ${port} strings. If there are
-    * any ${x} system property references in the resulting replacement string
-    * these will be replaced with the corresponding System.getProperty("x")
-    * value if one exists.
-    * @param text the text exp with optional ${host} ${port} references
-    * @param host the binding host value
-    * @param port the binding port value
-    */
-   private String replaceHostAndPort(String text, String host, String port)
-   {
-      if( text == null )
-         return null;
-
-      StringBuffer replacement = new StringBuffer(text);
-      if( host == null )
-         host = "localhost";
-      // Simple looping should be replaced with regex package
-      String test = replacement.toString();
-      int index;
-      while( (index = test.indexOf("${host}")) >= 0 )
-      {
-         replacement.replace(index, index+7, host);
-         test = replacement.toString();
-      }
-      while( (index = test.indexOf("${port}")) >= 0 )
-      {
-         replacement.replace(index, index+7, port);
-         test = replacement.toString();
-      }
-      return StringPropertyReplacer.replaceProperties(replacement.toString());
-   }
-}

Modified: trunk/varia/src/main/org/jboss/services/binding/DuplicateServiceException.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/DuplicateServiceException.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/DuplicateServiceException.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -35,8 +35,20 @@
 public class DuplicateServiceException 
    extends java.lang.Exception 
 {
+    /** The serialVersionUID */
+   private static final long serialVersionUID = -4583185555225307385L;
 
-    /**
+   public DuplicateServiceException(String serverName, ServiceBinding binding)
+   {
+      this(serverName, binding.getServiceName(), binding.getBindingName());
+   }
+
+   public DuplicateServiceException(String serverName, String serviceName, String bindingName)
+   {
+      this("No binding " + bindingName + " found for service " + serviceName + " in set " + serverName);
+   }
+
+   /**
      * Constructs an instance of <code>DuplicateServiceException</code> with the specified detail message.
      * @param msg the detail message.
      */

Added: trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import org.w3c.dom.Element;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns an Element.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface ElementServiceBindingValueSource extends ServiceBindingValueSource
+{
+   /**
+    * Returns the String to use for the binding value.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @return an String to use as the binding value. May return <code>null</code>.
+    */
+   Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception;
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/ElementServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import java.net.InetAddress;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns an InetAddress. Typically used as 
+ * a source for a host binding value.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface InetAddressServiceBindingValueSource extends ServiceBindingValueSource
+{
+   /**
+    * Returns the InetAddress to use for the binding value.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @return an InetAddress to use as the binding value. May return <code>null</code>.
+    */
+   InetAddress getInetAddressServiceBindingValue(ServiceBinding binding) throws Exception;
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/InetAddressServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns an int. Typically used as 
+ * a source for a port binding value.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface IntServiceBindingValueSource extends ServiceBindingValueSource
+{
+   /**
+    * Returns the int to use for the binding value.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @return an int to use as the binding value
+    */
+   int getIntServiceBindingValue(ServiceBinding binding) throws Exception;
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/IntServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+/**
+ * Exception thrown by {@link ServiceBindingManager} when no binding 
+ * can be found that matches a binding request.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class NoSuchBindingException extends Exception
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -9055052272112983527L;
+
+   public NoSuchBindingException(String serverName, String serviceName, String bindingName)
+   {
+      this("No binding " + bindingName + " found for service " + serviceName + " in set " + serverName);
+   }
+   
+   public NoSuchBindingException(String msg)
+   {
+      super(msg);
+   }
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/NoSuchBindingException.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/varia/src/main/org/jboss/services/binding/ServiceBinding.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBinding.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBinding.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -24,6 +24,9 @@
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
 /** A ServiceBinding is a {name,virtualHost,port,interfaceAddress}
  * quad specifying a named binding for a service.
  *
@@ -31,104 +34,170 @@
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public class ServiceBinding implements Cloneable
+public class ServiceBinding
 {
-   /** The name of the binding. A null or empty name implies the default
-     binding for a service.
+   /**
+    * Checks if <code>serviceName</code> can be converted into an
+    * ObjectName; if it can, converts it and returns its canonical form.
+    * 
+    * @param serviceName the service name
+    * @return the canonicalized form, or <code>serviceName</code> if it
+    *         cannot be converted into an ObjectName.
     */
-   private String name = null;
+   public static String canonicalizeServiceName(String serviceName)
+   {      
+      // If the serviceName looks like an object name, canonicalize it
+      try
+      {
+         ObjectName oname = new ObjectName(serviceName);
+         return oname.getCanonicalName();
+      }
+      catch (MalformedObjectNameException e)
+      {
+         return serviceName;
+      }      
+   }
+   
+   // ----------------------------------------------------------------- Fields
+   
+   /**
+    * The name of the service to which the binding applies.
+    */
+   private final String serviceName;
+   
+   /** 
+    * The name of the binding. A null or empty name implies the default
+    * binding for a service.
+    */
+   private final String bindingName;
+   
    /** The virtual host name. This is the interface name used to
     construct the bindAddress value. A null value implies bind on any
     interface.
     */
-   private String hostName = null;
+   private final String hostName;
+   
    /** The port the service should listen on. A 0 value implies an
     anonymous port.
     */
-   private int port = 0;
+   private final int port;
+   
    /** The interface on which the service should bind its listening port. A
     null address implies bind on any interface.
     */
-   private InetAddress bindAddress = null;
+   private final InetAddress bindAddress;
+   
+   /** The ServiceBindingValueSource implementation class
+    */
+   private String serviceBindingValueSourceClassName;
+   
+   /** The ServiceBindingValueSource 
+    */
+   private ServiceBindingValueSource serviceBindingValueSource;
+   
+   /** An aribtrary object used to configure the behavior of
+    the ServiceBindingValueSource. An example would be an XML Element.
+    */
+   private Object serviceBindingValueSourceConfig;
 
-   /** Make a copy of the ServiceBinding
+   // -----------------------------------------------------------  Constructors
+
+   /**
+    * Creates a new instance of ServiceBinding
+    *
+    * @param bindingName The name of the binding. A null or empty name
+    * implies that default binding for a service.
+    * @param port The port the service should listen on. A 0 value implies an
+    * anonymous port.
+    *
+    * @exception UnknownHostException
     */
-   public Object clone()
+   public ServiceBinding(String serviceName, int port)
+      throws UnknownHostException
    {
-      Object copy = null;
-      try
-      {
-         copy = super.clone();
-      }
-      catch(CloneNotSupportedException cantHappend)
-      {
-      }
-      return copy;
-   }
+      this(serviceName, null, port);
+   }   
 
    /**
-    * Creates a new instance of ServiceDescriptor
+    * Creates a new instance of ServiceBinding
     *
-    * @param name The name of the binding. A null or empty name
+    * @param bindingName The name of the binding. A null or empty name
     * implies that default binding for a service.
-    * @param hostName The virtual host name. This is the interface name used to
-    * construct the bindAddress value. A null value implies bind on any
-    * interface.
     * @param port The port the service should listen on. A 0 value implies an
     * anonymous port.
     *
-    * @exception UnknownHostException If hostName is not resolvable.
+    * @exception UnknownHostException
     */
-   public ServiceBinding(String name, String hostName, int port)
+   public ServiceBinding(String serviceName, String hostName, int port)
       throws UnknownHostException
    {
-      this.setName(name);
-      this.setHostName(hostName);
-      this.setBindAddress(hostName);
-      this.setPort(port);
+      this(serviceName, null, hostName, port);
    }
 
    /**
-    * Getter for property name.
+    * Creates a new instance of ServiceBinding
     *
-    * @return The name of the binding
+    * @param config the ServiceConfig associated with this binding. May be
+    *               <code>null</code>, in which case {@link #setServiceConfig(ServiceConfig)}
+    *               should be promptly called.
+    * @param bindingName The name of the binding. A null or empty name
+    * implies the default binding for a service.
+    * @param hostName The virtual host name. This is the interface name used to
+    * construct the bindAddress value. A null value implies bind on the loopback interface.
+    * @param port The port the service should listen on. A 0 value implies an
+    * anonymous port.
+    *
+    * @exception UnknownHostException If hostName is not resolvable.
     */
-   public String getName()
+   public ServiceBinding(String serviceName, String bindingName, String hostName, int port)
+      throws UnknownHostException
    {
-      return this.name;
+      if (serviceName == null)
+         throw new IllegalArgumentException("serviceName is null");
+      
+      // If the serviceName looks like an object name, canonicalize it      
+      this.serviceName = canonicalizeServiceName(serviceName);
+      this.bindingName = bindingName;
+      this.port = port;
+      this.hostName = hostName;
+      this.bindAddress = InetAddress.getByName(hostName);
+   } 
+
+   // -------------------------------------------------------------  Properties
+   
+   public String getServiceName()
+   {
+      return serviceName;
    }
 
    /**
-    * Setter for property name.
+    * Getter for property name.
     *
-    * @param name the name of the binding
+    * @return The name of the binding
     */
-   public void setName(String name)
+   public String getBindingName()
    {
-      this.name = name;
+      return this.bindingName;
    }
 
    /**
-    * Sets the bindAddress attribute of the ServiceDescriptor object
+    * Returns host name
     *
-    * @param  pInetAddr  The new bindAddress value
+    * @return the hostname or address
     */
-   public void setBindAddress(InetAddress bindAddress)
+   public String getHostName()
    {
-      this.bindAddress = bindAddress;
+      return this.hostName;
    }
-   
+
    /**
-    * Sets the bindAddress, given a hostname
+    * Gets the port attribute of the ServiceDescriptor object
     *
-    * @param pHostName The hostname with which to create an InetAddress
-    *
-    * @exception UnknownHostException Hostname is not resolvable
+    * @return The listen port number
     */
-   public void setBindAddress(String hostName)
-      throws UnknownHostException
+   public int getPort()
    {
-      this.bindAddress = InetAddress.getByName(hostName);
+      return this.port;
    }
 
    /**
@@ -141,44 +210,95 @@
       return this.bindAddress;
    }
 
-   /**
-    * Sets the port attribute of the ServiceDescriptor object
-    *
-    * @param  pPort  The new listen port number
+   public synchronized ServiceBindingValueSource getServiceBindingValueSource() 
+      throws ClassNotFoundException, InstantiationException, IllegalAccessException
+   {
+      if (this.serviceBindingValueSource == null && this.serviceBindingValueSourceClassName != null)
+      {
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         Class<?> delegateClass = loader.loadClass(serviceBindingValueSourceClassName);
+         this.serviceBindingValueSource = (ServiceBindingValueSource) delegateClass.newInstance();
+      }
+      return this.serviceBindingValueSource;
+   }
+
+   public void setServiceBindingValueSource(ServiceBindingValueSource serviceBindingValueSource)
+   {
+      this.serviceBindingValueSource = serviceBindingValueSource;
+      if (serviceBindingValueSource != null)
+      {
+         setServiceBindingValueSourceClassName(serviceBindingValueSource.getClass().getName());
+      }
+   }
+
+   /** 
+    * Getter for property serviceBindingValueSourceClassName.
     */
-   public void setPort(int port)
+   public String getServiceBindingValueSourceClassName()
    {
-      this.port = port;
+      return serviceBindingValueSourceClassName;
    }
 
-   /**
-    * Gets the port attribute of the ServiceDescriptor object
-    *
-    * @return The listen port number
+   public void setServiceBindingValueSourceClassName(String serviceBindingValueSourceClassName)
+   {
+      this.serviceBindingValueSourceClassName = serviceBindingValueSourceClassName;
+   }
+
+   /** 
+    * Getter for property serviceBindingValueSourceConfig.
     */
-   public int getPort()
+   public Object getServiceBindingValueSourceConfig()
    {
-      return this.port;
+      return serviceBindingValueSourceConfig;
    }
+   
+   public void setServiceBindingValueSourceConfig(Object serviceBindingValueSourceConfig)
+   {
+      this.serviceBindingValueSourceConfig = serviceBindingValueSourceConfig;
+   }
 
+   // ----------------------------------------------------------------   Public
+   
+   public ServiceBinding getOffsetBinding(int offset) throws UnknownHostException
+   {
+      ServiceBinding result = new ServiceBinding(serviceName, bindingName, hostName, port + offset);
+      result.setServiceBindingValueSourceClassName(serviceBindingValueSourceClassName);
+      result.setServiceBindingValueSource(serviceBindingValueSource);
+      result.setServiceBindingValueSourceConfig(serviceBindingValueSourceConfig);
+      return result;
+   }
+
+   // --------------------------------------------------------------  Overrides
+   
    /**
-    * Returns host name
-    *
-    * @return the hostname or address
+    * Equality is based on our ServiceConfig's serviceName and our bindingName.
     */
-   public String getHostName()
+   @Override
+   public boolean equals(Object obj)
    {
-      return this.hostName;
+      if (this == obj)
+         return true;
+      
+      if (obj instanceof ServiceBinding)
+      {
+         ServiceBinding other = (ServiceBinding) obj;
+         return (this.serviceName.equals(other.serviceName)
+                 && safeEquals(this.bindingName, other.bindingName));
+      }
+      
+      return false;
    }
 
    /**
-    * Sets the host name
-    *
-    * @param hostName, the hostname or address
+    * Hashcode is based on our ServiceConfig's serviceName and our bindingName.
     */
-   public void setHostName(String hostName)
+   @Override
+   public int hashCode()
    {
-      this.hostName = hostName;
+      int result = 19;
+      result += 29 * this.serviceName.hashCode();
+      result += 29 * (this.bindingName == null ? 0 : this.bindingName.hashCode());
+      return result;
    }
 
    /**
@@ -188,16 +308,18 @@
     */
    public String toString()
    {
-      StringBuffer sBuf = new StringBuffer("ServiceBinding [name=");
+      StringBuffer sBuf = new StringBuffer("ServiceBinding [serviceName=");
+      sBuf.append(this.serviceName);
+      sBuf.append(";bindingName=");
+
+      sBuf.append(this.getBindingName());
+      sBuf.append(";hostName=");
       String host = getHostName();
 
       if (hostName == null)
       {
          host = "<ANY>";
       }
-
-      sBuf.append(this.getName());
-      sBuf.append(";hostName=");
       sBuf.append(host);
       sBuf.append(";bindAddress=");
       sBuf.append(this.getBindAddress().toString());
@@ -206,4 +328,11 @@
       sBuf.append("]");
       return sBuf.toString();
    }
+
+   // ----------------------------------------------------------------  Private
+   
+   private boolean safeEquals(Object a, Object b)
+   {
+      return (a == b || (a != null && a.equals(b)));
+   }
 }

Modified: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManager.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManager.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManager.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -21,71 +21,117 @@
 */
 package org.jboss.services.binding;
 
+
+import java.net.InetAddress;
 import java.net.URL;
+import java.net.UnknownHostException;
 
-import javax.management.Attribute;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.jboss.services.binding.impl.Util;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+import org.w3c.dom.Element;
 
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.JMXExceptionDecoder;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.system.ServiceControllerMBean;
-import org.jboss.system.server.ServerConfigLocator;
-
-/** The services configuration binding manager mbean implementation.
+/** 
+ * The services configuration binding manager implementation.
  *
  * <p>The ServiceBindingManager enables the centralized management
  * of ports, by service. The port configuration store is abstracted out
- * using the ServicesStore and ServicesStoreFactory interfaces. Note that
- * this class does not implement the JBoss services lifecycle methods
- * and hook its behavior off of those because this service is used to
- * configure other services before any of the lifecycle methods are invoked.
+ * using the ServiceBindingStore interface.
  *
  * @version $Revision$
  * @author  <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>
  * @author Scott.Stark at jboss.org
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author Brian Stansberry
  *
  * @jmx:mbean
  */
 public class ServiceBindingManager
-   implements MBeanRegistration, ServiceBindingManagerMBean
-{
-   private static Logger log = Logger.getLogger(ServiceBindingManager.class);
-
-   /** The MBeanServer we are registered
-    */
-   private MBeanServer server;
+   implements ServiceBindingManagerMBean
+{  
+   // -----------------------------------------------------------------  Static
    
-   /** The ObjectName of this MBean
-    */
-   private ObjectName serviceName;
+   /** Enumeration of types of binding requests */
+   public enum BindingType { INT, INETADDRESS, STRING, ELEMENT, URL, RESOURCE, GENERIC };
    
-   /** The name of the server this manager is associated with. This is a
-    logical name used to lookup ServiceConfigs from the ServicesStore.
+   /**
+    * Algorithm for obtaining a ServiceBindingValueSource given a particular
+    * binding and binding type.
+    * 
+    * @param binding the binding
+    * @param bindingType the binding type
+    * @return the appropriate ServiceBindingValueSource. Will not return <code>null</code>.
+    * 
+    * @throws ClassNotFoundException if any {@link ServiceBinding#getServiceBindingValueSourceClassName()} cannot be found
+    * @throws InstantiationException if any {@link ServiceBinding#getServiceBindingValueSourceClassName()} cannot be instantiated
+    * @throws IllegalAccessException if any {@link ServiceBinding#getServiceBindingValueSourceClassName()} is not public
+    * @throws IllegalStateException if no appropriate ServiceBindingValueSource can be identified
     */
-   private String serverName;
+   public static ServiceBindingValueSource getServiceBindingValueSource(ServiceBinding binding, BindingType bindingType)
+         throws ClassNotFoundException, InstantiationException, IllegalAccessException
+   {
+      ServiceBindingValueSource source = binding.getServiceBindingValueSource();
+      if (source == null)
+      {
+         switch (bindingType)
+         {
+            case INT:
+            case INETADDRESS:
+               source = new SimpleServiceBindingValueSourceImpl();
+               break;
+            case STRING:
+               source = new StringReplacementServiceBindingValueSourceImpl();
+               break;
+            case ELEMENT:
+            case URL:
+            case RESOURCE:
+               Object config = binding.getServiceBindingValueSourceConfig();
+               if (config instanceof XSLTServiceBindingValueSourceConfig)
+               {
+                  source = new XSLTServiceBindingValueSourceImpl();
+               }
+               else
+               {
+                  source = new StringReplacementServiceBindingValueSourceImpl();
+               }
+               break;
+            default:
+               throw new IllegalStateException("No ServiceBindingValueSource configured for " + 
+                                               binding + " and no default source available for binding of type " +
+                                               bindingType);
+         }         
+      }
+      return source;
+   }
+
+   // ----------------------------------------------------------------  Fields
    
-   /** The name of the class implementation for the ServicesStoreFactory. The
-    default value is org.jboss.services.binding.XMLServicesStoreFactory
+   /** 
+    * The name of the config set this manager is associated with. This is a
+    * logical name used to lookup ServiceConfigs from the ServiceBindingStore.
     */
-   private String storeFactoryClassName = "org.jboss.services.binding.XMLServicesStoreFactory";
+   private final String serverName;
    
-   /** The ObjectName of the ServiceController we'll be registering at
-    */
-   private ObjectName serviceController;
-   
    /** The ServiceConfig store instance
     */
-   private ServicesStore store;
+   private final ServiceBindingStore store;
+
+   // -----------------------------------------------------------  Constructors
    
-   /** The URL of the configuration store
-    */
-   private URL storeURL;
+   public ServiceBindingManager(String serverName, ServiceBindingStore store)
+   {
+      if (serverName == null)
+         throw new IllegalArgumentException("serverName is null");
+      if (store == null)
+         throw new IllegalArgumentException("store is null");
+      
+      this.serverName = serverName;
+      this.store = store;
+   }
 
-   // Attributes ----------------------------------------------------
+   // -------------------------------------------------------------  Properties
    
    /**
     * @jmx:managed-attribute
@@ -95,254 +141,227 @@
       return this.serverName;
    }
 
-   /**
-    * @jmx:managed-attribute
-    */
-   public void setServerName(String serverName)
+   // ----------------------------------------------------------------- Public
+   
+   public int getIntBinding(String serviceName) throws Exception
    {
-      this.serverName = serverName;
+      return getIntBinding(serviceName, null);
    }
-
-   /**
-    * @jmx:managed-attribute
-    */
-   public String getStoreFactoryClassName()
+   
+   public int getIntBinding(String serviceName, String bindingName) throws Exception
    {
-      return this.storeFactoryClassName;
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.INT);
+      if (source instanceof IntServiceBindingValueSource)
+      {
+         return ((IntServiceBindingValueSource) source).getIntServiceBindingValue(binding);
+      }
+      else
+      {
+         return Util.getBindingValue(source, binding, Number.class).intValue();             
+      }
    }
-
-   /**
-    * @jmx:managed-attribute
-    */
-   public void setStoreFactoryClassName(String storeFactoryClassName)
+   
+   public int getIntBinding(String serviceName, String bindingName, String hostName, int basePort) throws Exception
    {
-      this.storeFactoryClassName = storeFactoryClassName;
+      try
+      {
+         return getIntBinding(serviceName, bindingName);
+      }
+      catch (NoSuchBindingException e)
+      {
+         createBindingFromDefaults(serviceName, bindingName, hostName, basePort);
+         return getIntBinding(serviceName, bindingName);
+      }
    }
 
-   /**
-    * @jmx:managed-attribute
-    */
-   public URL getStoreURL()
+   private void createBindingFromDefaults(String serviceName, String bindingName, String hostName, int basePort)
+         throws UnknownHostException, DuplicateServiceException
    {
-      return storeURL;
+      ServiceBinding sb = new ServiceBinding(serviceName, bindingName, hostName, basePort);
+      store.addServiceBinding(sb);
    }
-
-   /** Set the string representation of the store URL
-    * @jmx:managed-attribute
-    */
-   public void setStoreURL(URL storeURL)
+   
+   public InetAddress getInetAddressBinding(String serviceName) throws Exception
    {
-      this.storeURL = storeURL;
+      return getInetAddressBinding(serviceName, null);
    }
-
-   /**
-    * Get the ObjectName of the ServiceController
-    * @jmx:managed-attribute
-    */
-   public ObjectName getServiceController()
+   
+   public InetAddress getInetAddressBinding(String serviceName, String bindingName) throws Exception
    {
-      return serviceController;
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.INETADDRESS);
+      if (source instanceof InetAddressServiceBindingValueSource)
+      {
+         return ((InetAddressServiceBindingValueSource) source).getInetAddressServiceBindingValue(binding);
+      }
+      else
+      {
+         return Util.getBindingValue(source, binding, InetAddress.class);
+      }
    }
    
-   /**
-    * Set the ObjectName of the ServiceController.
-    * 
-    * @jmx:managed-attribute
-    * 
-    * @param serviceController the name of the controller to register to
-    * @throws Exception if there is a problem registering with the controller
-    */
-   public void setServiceController(ObjectName serviceController) throws Exception
+   public InetAddress getInetAddressBinding(String serviceName, String bindingName, String hostName, int basePort) throws Exception
    {
-      this.serviceController = serviceController;
-      
-      // try to register a proxy with the controller
-      registerProxy();
+      try
+      {
+         return getInetAddressBinding(serviceName, bindingName);
+      }
+      catch (NoSuchBindingException e)
+      {
+         createBindingFromDefaults(serviceName, bindingName, hostName, basePort);
+         return getInetAddressBinding(serviceName, bindingName);
+      }
    }
    
-   // MBeanRegistration overrides -----------------------------------
+   public String getStringBinding(String serviceName, String input) throws Exception
+   {
+      return getStringBinding(serviceName, null, input);
+   }
    
-   public ObjectName preRegister(MBeanServer server, ObjectName name)
-      throws Exception
+   public String getStringBinding(String serviceName, String bindingName, String input) throws Exception
    {
-      this.server = server;
-      this.serviceName = name;
-      
-      return name;
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.STRING);
+      if (source instanceof StringServiceBindingValueSource)
+      {
+         return ((StringServiceBindingValueSource) source).getStringServiceBindingValue(binding, input);
+      }
+      else
+      {
+         return Util.getBindingValueWithInput(source, binding, input, String.class);             
+      }
    }
    
-   public void postRegister(Boolean registrationDone)
+   public String getStringBinding(String serviceName, String bindingName, String input, String hostName, int basePort) throws Exception
    {
-      if (registrationDone.booleanValue())
+      try
       {
-         // Register with the default ServiceController
-         try
-         {
-            setServiceController(ServiceControllerMBean.OBJECT_NAME);
-         }
-         catch (Exception ignore)
-         {
-            // Ignore any exception at this point; the user
-            // might expicitly set the controller objectname
-         }
+         return getStringBinding(serviceName, bindingName, input);
       }
+      catch (NoSuchBindingException e)
+      {
+         createBindingFromDefaults(serviceName, bindingName, hostName, basePort);
+         return getStringBinding(serviceName, bindingName, input);
+      }
    }
    
-   public void preDeregister()
-      throws Exception
+   public Element getElementBinding(String serviceName, Element input) throws Exception
    {
-      // unregister with ServiceController
-      this.unregisterProxy();
-      
-      // shutdown store
-      if (store != null)
+      return getElementBinding(serviceName, null, input);
+   }
+   
+   public Element getElementBinding(String serviceName, String bindingName, Element input) throws Exception
+   {
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.ELEMENT);
+      if (source instanceof ElementServiceBindingValueSource)
       {
-         store.store(storeURL);
+         return ((ElementServiceBindingValueSource) source).getElementServiceBindingValue(binding, input);
       }
+      else
+      {
+         return Util.getBindingValueWithInput(source, binding, input, Element.class);              
+      }
    }
    
-   public void postDeregister()
+   public Element getElementBinding(String serviceName, String bindingName, Element input, String hostName, int basePort) throws Exception
    {
-      // empty
+      try
+      {
+         return getElementBinding(serviceName, bindingName, input);
+      }
+      catch (NoSuchBindingException e)
+      {
+         createBindingFromDefaults(serviceName, bindingName, hostName, basePort);
+         return getElementBinding(serviceName, bindingName, input);
+      }
    }
-
-   // Operations ----------------------------------------------------
    
-   /**
-    * Looks up the service config for the given service using the
-    * server name bound to this mbean.
-    *
-    * @jmx:managed-operation
-    *
-    * @param  serviceName  the JMX ObjectName of the service
-    * @return ServiceConfig instance if found, null otherwise
-    */
-   public ServiceConfig getServiceConfig(ObjectName serviceName)
-      throws Exception
+   public URL getURLBinding(String serviceName, URL input) throws Exception
    {
-      log.debug("getServiceConfig, server:" + serverName + ", serviceName:" + serviceName);      
-      
-      if (store == null)
+      return getURLBinding(serviceName, null, input);
+   }
+   
+   public URL getURLBinding(String serviceName, String bindingName, URL input) throws Exception
+   {
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.URL);
+      if (source instanceof URLServiceBindingValueSource)
       {
-         initStore();
+         return ((URLServiceBindingValueSource) source).getURLServiceBindingValue(binding, input);
       }
-
-      // Look up the service config
-      ServiceConfig svcConfig = store.getService(serverName, serviceName);
-      ServiceConfig configCopy = null;
-      if (svcConfig != null)
+      else
       {
-         configCopy = (ServiceConfig) svcConfig.clone();
+         return Util.getBindingValueWithInput(source, binding, input, URL.class);                 
       }
-      return configCopy;
    }
-
-   /**
-    * Looks up the service config for the requested service using the
-    * server name bound to this mbean and invokes the configuration delegate
-    * to apply the bindings to the service. If no config if found then this
-    * method is a noop.
-    *
-    * @jmx:managed-operation
-    *
-    * @param  serviceName  the JMX ObjectName of the service
-    * @exception Exception, thrown on failure to apply an existing configuration
-    */
-   public void applyServiceConfig(ObjectName serviceName)
-      throws Exception
+   
+   public URL getURLBinding(String serviceName, String bindingName, URL input, String hostName, int basePort) throws Exception
    {
-      if (store == null)
+      try
       {
-         initStore();
+         return getURLBinding(serviceName, bindingName, input);
       }
-      // Look up the service config
-      ServiceConfig svcConfig = store.getService(serverName, serviceName);
-      if (svcConfig != null)
+      catch (NoSuchBindingException e)
       {
-         log.debug("applyServiceConfig, server:" + serverName + ", serviceName:" + serviceName + ", config=" + svcConfig);
-
-         ClassLoader loader = Thread.currentThread().getContextClassLoader();
-         String delegateName = svcConfig.getServiceConfigDelegateClassName();
-         if (delegateName != null)
-         {
-            Class delegateClass = loader.loadClass(delegateName);
-            ServicesConfigDelegate delegate = (ServicesConfigDelegate) delegateClass.newInstance();
-            delegate.applyConfig(svcConfig, server);
-         }
+         createBindingFromDefaults(serviceName, bindingName, hostName, basePort);
+         return getURLBinding(serviceName, bindingName, input);
       }
    }
-
-   // Private -------------------------------------------------------
    
-   /**
-    * Register a dynamic proxy of myself with the ServiceController
-    */
-   private void registerProxy() throws Exception
+   public String getResourceBinding(String serviceName, String input) throws Exception
    {
-      if (serviceController != null)
+      return getResourceBinding(serviceName, null, input);
+   }
+   
+   public String getResourceBinding(String serviceName, String bindingName, String input) throws Exception
+   {
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.RESOURCE);
+      if (source instanceof URLServiceBindingValueSource)
       {
-         log.debug("Registering with ServiceController: " + serviceController);
-         
-         // Create a dynamic proxy pointing to me, over the MBeanServer
-         org.jboss.system.ServiceBinding proxy = (org.jboss.system.ServiceBinding)
-            MBeanProxyExt.create(org.jboss.system.ServiceBinding.class, serviceName, server);
-         
-         try
-         {
-            server.setAttribute(serviceController, new Attribute("ServiceBinding", proxy));
-         }
-         catch (Exception e)
-         {
-            // Log a debug message indicating we couldn't register and rethrow
-            Throwable t = JMXExceptionDecoder.decode(e);
-            log.debug("Failed to register with ServiceController: " + serviceController + ", reason: " + t.getMessage());
-            throw (Exception)t;
-         }
+         return ((URLServiceBindingValueSource) source).getResourceServiceBindingValue(binding, input);
       }
+      else
+      {
+         return Util.getBindingValueWithInput(source, binding, input, String.class);             
+      }
    }
    
-   /**
-    * Unregister with ServiceController
-    * by setting ServiceBinding to null
-    */
-   private void unregisterProxy()
+   public String getResourceBinding(String serviceName, String bindingName, String input, String hostName, int basePort) throws Exception
    {
-      if (serviceController != null)
+      try
       {
-         log.debug("Unregistering with ServiceController: " + serviceController);
-         try
-         {
-            server.setAttribute(serviceController, new Attribute("ServiceBinding", null));
-         }
-         catch (Exception e)
-         {
-            // Log a debug message indicating we couldn't unregister
-            Throwable t = JMXExceptionDecoder.decode(e);
-            log.debug("Failed to unregister with ServiceController: " + serviceController + ", reason: " + t.getMessage());         
-         }
+         return getResourceBinding(serviceName, bindingName, input);
       }
+      catch (NoSuchBindingException e)
+      {
+         createBindingFromDefaults(serviceName, bindingName, hostName, basePort);
+         return getResourceBinding(serviceName, bindingName, input);
+      }
    }
    
+   public Object getGenericBinding(String serviceName, Object ... params) throws Exception
+   {
+      return getGenericBinding(serviceName, null, params);
+   }
+   
    /**
-    * Create and load the services store
+    * Generic extension point, allowing arbitrary return types based
+    * on arbitrary sets of parameters.
+    * 
+    * @param serviceName
+    * @param bindingName
+    * @param params
+    * @return
+    * @throws Exception
     */
-   private void initStore() throws Exception
+   public Object getGenericBinding(String serviceName, String bindingName, Object ... params) throws Exception
    {
-      log.info("Initializing store");
-      
-      // If no store url identified, use the ServerConfigURL
-      if (this.storeURL == null)
-      {
-         this.storeURL = ServerConfigLocator.locate().getServerConfigURL();
-      }
-      log.info("Using StoreURL: "+storeURL);
-
-      ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      Class factoryClass = loader.loadClass(storeFactoryClassName);
-      ServicesStoreFactory storeFactory = (ServicesStoreFactory) factoryClass.newInstance();
-
-      // Create and load the store
-      store = storeFactory.newInstance();
-      store.load(storeURL);
-   }
+      ServiceBinding binding = store.getServiceBinding(serverName, serviceName, bindingName);      
+      ServiceBindingValueSource source = getServiceBindingValueSource(binding, BindingType.GENERIC);
+      return source.getServiceBindingValue(binding, params); 
+   }   
+   
 }

Modified: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManagerMBean.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManagerMBean.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBindingManagerMBean.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -21,63 +21,25 @@
 */
 package org.jboss.services.binding;
 
-import java.net.URL;
 
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-
 /**
  * ServiceBindingManager MBean interface
  * 
  * @author <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>
  * @author Scott.Stark at jboss.org
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author Brian Stansberry
+ * 
  * @version $Revision$
  */
-public interface ServiceBindingManagerMBean extends org.jboss.system.ServiceBinding
+public interface ServiceBindingManagerMBean
 {
-   /** Default ObjectName */
-   static final ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=ServiceBindingManager");
-   
    // Attributes ----------------------------------------------------
 
    /**
     * The name of the server this manager is associated with. This is a
-    * logical name used to lookup ServiceConfigs from the ServicesStore.
-    */   
-   void setServerName(String serverName);
+    * logical name used to lookup ServiceConfigs from the ServiceBindingStore.
+    */
    String getServerName();
 
-   /**
-    * The name of the class implementation of the ServicesStoreFatory. The
-    * default value is org.jboss.services.binding.XMLServicesStoreFactory.
-    */
-   void setStoreFactoryClassName(String storeFactoryClassName);
-   String getStoreFactoryClassName();
-   
-   /**
-    * The URL of the configuration store.
-    */
-   void setStoreURL(URL storeURL);   
-   URL getStoreURL();
-
-   /**
-    * The ObjectName of the ServiceController,
-    * defaults to ServiceControllerMBean.OBJECT_NAME
-    */
-   void setServiceController(ObjectName serviceController) throws Exception;
-   ObjectName getServiceController();
-   
-   // Operations ----------------------------------------------------
-
-   /**
-    * Looks up the service config for the given service,
-    * using the server name bound to this mbean.
-    * 
-    * @param serviceName the JMX ObjectName of the service
-    * @return ServiceConfig instance if found, null otherwise 
-    */
-   ServiceConfig getServiceConfig(ObjectName serviceName) throws Exception;
-
 }

Added: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,145 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY 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 along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.services.binding;
+
+import java.net.InetAddress;
+
+
+/** Interface for API to persist, read, and look up service configs
+ *
+ * @version $Revision: 37459 $
+ * @author <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>.
+ * @author Scott.Stark at jboss.org
+ * @author Brian Stansberry
+ */
+public interface ServiceBindingStore 
+{
+   /** Obtain a ServiceBinding object for the given server instance, target
+    * service and binidng name. This is called by the JBoss service configuration
+    * layer to obtain service attribute binding overrides.
+    *
+    * @param serverName the name identifying the JBoss server instance in
+    *    which the service is running.
+    * @param serviceName the name of the service
+    * @param bindingName the name of the binding, or <code>null</code> to indicate
+    *                    the default binding.
+    * @return the ServiceBinding if one exists for the <serverName, serviceName, bindingName>
+    *         tuple.
+    *         
+    * @throws NoSuchBindingException if no matching binding exists
+    */
+   ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName) 
+      throws NoSuchBindingException;
+
+   /** 
+    * Add a ServiceBinding to the store. This is an optional method not used
+    * by the JBoss service configuration layer.
+    *
+    * @param serverName the name identifying the JBoss server instance in
+    *    which the service is running.
+    * @param serviceName the JMX ObjectName of the service
+    * @param serviceConfig the configuration to add
+    * 
+    * @throws DuplicateServiceException thrown if a configuration for the
+    *    <serverName, serviceName> pair already exists.
+    */
+   void addServiceBinding(String serverName, ServiceBinding binding)
+      throws DuplicateServiceException;
+
+   /** 
+    * Remove a service configuration from the store. This is an optonal method
+    * not used by the JBoss service configuration layer.
+    *
+    * @param serverName the name identifying the JBoss server instance in
+    *    which the service is running.
+    * @param serviceBinding the binding
+    */
+   void removeServiceBinding(String serverName, ServiceBinding binding);
+
+   /** 
+    * Remove a service configuration from the store. This is an optonal method
+    * not used by the JBoss service configuration layer.
+    *
+    * @param serverName the name identifying the JBoss server instance in
+    *    which the service is running.
+    * @param serviceBinding the binding
+    */
+   void removeServiceBinding(String serverName, String serviceName, String bindingName);
+
+   /** 
+    * Add a ServiceBinding to all binding sets in the store. For each binding 
+    * set, a new ServiceBinding is added whose serviceName and bindingName
+    * properties match the passed binding. The new binding's hostName matches
+    * the target set's {@link #getDefaultHostName(String) default host name}.
+    * The new binding's port is derived by taking the port from the passed 
+    * binding and incrementing it by the target set's 
+    * {@link #getDefaultPortOffset(String) default port offset}.
+    *
+    * @param serviceName the JMX ObjectName of the service
+    * @param serviceConfig the configuration to add
+    * 
+    * @throws DuplicateServiceException thrown if a configuration for the
+    *    <serverName, serviceName> pair already exists.
+    */
+   void addServiceBinding(ServiceBinding binding)
+      throws DuplicateServiceException;
+
+   /** 
+    * Remove a service configuration from all binding sets in the store.
+    *
+    * @param serviceBinding the binding
+    */
+   void removeServiceBinding(ServiceBinding binding);
+
+   /** 
+    * Remove a service configuration from all binding sets in the store.
+    *
+    * @param serviceBinding the binding
+    */
+   void removeServiceBinding(String serviceName, String bindingName);
+   
+   /**
+    * Gets the offset from a base value that by default should be added to
+    * port values for a given serverName.
+    * 
+    * @param serverName the name of the binding set
+    * @return the offset
+    */
+   int getDefaultPortOffset(String serverName);
+   
+   /**
+    * Gets the default value to use as the host name for the given serverName.
+    * 
+    * @param serverName the name of the binding set
+    * @return the host name
+    */
+   String getDefaultHostName(String serverName);
+   
+   /**
+    * Value of <code>InetAddress.getByHost({@link #getDefaultHostName(String) getDefaultHost(serverName)})</code>.
+    * 
+    * @param serverName the name of the binding set
+    * @return the host name
+    */
+   InetAddress getDefaultBindAddress(String serverName);
+   
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingStore.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY 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 along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.services.binding;
+
+
+/** 
+ * Source for a service binding value.
+ * 
+ * @author Brian Stansberry
+ */
+public interface ServiceBindingValueSource 
+{
+   /**
+    * Returns a detyped binding value based on the provided binding
+    * and detyped array of parameters.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @param params  the parameters, or <code>null</code>
+    * 
+    * @return the binding value. May return <code>null</code>
+    * 
+    * @throws IllegalArgumentException if content of <code>params</code> is 
+    *                                  not understood
+    * @throws Exception if another exception occurs
+    */
+   public Object getServiceBindingValue(ServiceBinding binding, Object ... params) throws Exception;
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/ServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/varia/src/main/org/jboss/services/binding/ServiceConfig.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServiceConfig.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServiceConfig.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,173 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-/** A ServiceConfig is a mapping from an mbean service name to its
- * ServiceBindings.
- *
- * @author <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>.
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ServiceConfig implements Cloneable
-{
-   /** The javax.management.ObjectName string of the service the config
-    applies to.
-    */
-   private String serviceName;
-   /** The ServicesConfigDelegate implementation class
-    */
-   private String serviceConfigDelegateClassName;
-   /** An aribtrary object used to configure the behavior of
-    the ServicesConfigDelegate. An example would be an XML Element.
-    */
-   private Object serviceConfigDelegateConfig;
-   /** The bindings associated with the service
-    */
-   private ServiceBinding[] bindings;
-
-   /** Creates a new instance of ServiceConfig */
-   public ServiceConfig()
-   {
-   }
-
-   /** Make a deep copy of the ServiceConfig bindings
-    */
-   public Object clone()
-   {
-      ServiceConfig copy = new ServiceConfig();
-      // Immutable so no reason to copy
-      copy.serviceName = serviceName;
-      copy.serviceConfigDelegateClassName = serviceConfigDelegateClassName;
-      int length = bindings != null ? bindings.length : 0;
-      copy.bindings = new ServiceBinding[length];
-      for(int b = 0; b < length; b ++)
-      {
-         copy.bindings[b] = (ServiceBinding) bindings[b].clone();
-      }
-      return copy;
-   }
-
-   /** Getter for property serviceName.
-    * @return Value of property serviceName.
-    */
-   public String getServiceName()
-   {
-      return this.serviceName;
-   }
-
-   /** Setter for property serviceName.
-    * @param serviceName New value of property serviceName.
-    */
-   public void setServiceName(String serviceName)
-   {
-      this.serviceName = serviceName;
-   }
-
-   /** Getter for property port.
-    * @return Value of property port.
-    */
-   public ServiceBinding[] getBindings()
-   {
-      return this.bindings;
-   }
-
-   /** Setter for property port.
-    * @param port New value of property port.
-    */
-   public void setBindings(ServiceBinding[] bindings)
-   {
-      this.bindings = bindings;
-   }
-
-   /** Getter for property serviceConfigDelegateClassName.
-    * @return Value of property serviceConfigDelegateClassName.
-    */
-   public String getServiceConfigDelegateClassName()
-   {
-      return serviceConfigDelegateClassName;
-   }
-
-   /** Setter for property serviceConfigDelegateClassName.
-    * @param serviceConfigDelegateClassName New value of property serviceConfigDelegateClassName.
-    */
-   public void setServiceConfigDelegateClassName(String serviceConfigDelegateClassName)
-   {
-      this.serviceConfigDelegateClassName = serviceConfigDelegateClassName;
-   }
-
-   /** Getter for property serviceConfigDelegateConfig.
-    * @return Value of property serviceConfigDelegateConfig.
-    */
-   public Object getServiceConfigDelegateConfig()
-   {
-      return serviceConfigDelegateConfig;
-   }
-
-   /** Setter for property serviceConfigDelegateConfig.
-    * @param serviceConfigDelegateConfig New value of property serviceConfigDelegateConfig.
-    */
-   public void setServiceConfigDelegateConfig(Object serviceConfigDelegateConfig)
-   {
-      this.serviceConfigDelegateConfig = serviceConfigDelegateConfig;
-   }
-
-   /** Equality is based on the serviceName string
-    */
-   public boolean equals(Object obj)
-   {
-      boolean equals = false;
-      if( obj instanceof ServiceConfig )
-      {
-         ServiceConfig sc = (ServiceConfig) obj;
-         equals = this.serviceName.equals(sc.serviceName);
-      }
-      else
-      {
-         equals = super.equals(obj);
-      }
-      return equals;
-   }
-
-   /** The hash code is based on the serviceName string hashCode.
-    */
-   public int hashCode()
-   {
-      int hashCode = serviceName == null ? 0 : serviceName.hashCode();
-      return hashCode;
-   }
-
-   public String toString()
-   {
-      StringBuffer buffer = new StringBuffer("ServiceConfig(name=");
-      buffer.append(serviceName);
-      buffer.append("), bindings=<");
-      int length = bindings != null ? bindings.length : 0;
-      for(int b = 0; b < length; b ++)
-      {
-         buffer.append(bindings[b].toString());
-      }
-      buffer.append(">");
-      return buffer.toString();
-   }
-   
-}

Deleted: trunk/varia/src/main/org/jboss/services/binding/ServicesConfigDelegate.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServicesConfigDelegate.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServicesConfigDelegate.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,41 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-import javax.management.MBeanServer;
-
-/** Interface for delegates capabable of taking a ServiceConfig and mapping
- * it onto an mbean service via JMX
- *
- * @version $Revision$
- * @author Scott.Stark at jboss.org
- */
-public interface ServicesConfigDelegate 
-{
-   /** Take the given config and map it onto the service specified in the
-    config using JMX via the given server.
-    @param config, the service name and its config bindings
-    @param server, the JMX server to use to apply the config
-    */
-   public void applyConfig(ServiceConfig config, MBeanServer server) throws Exception;
-
-}

Deleted: trunk/varia/src/main/org/jboss/services/binding/ServicesStore.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServicesStore.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServicesStore.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,80 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-import java.net.URL;
-import javax.management.ObjectName;
-
-/** Interface for API to persist, read, and look up service configs
- *
- * @version $Revision$
- * @author <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>.
- * @author Scott.Stark at jboss.org
- */
-public interface ServicesStore 
-{
-   /** Load the contents of a store.
-    * @param storeURL the URL representing the location of the store
-    * @exception Exception thrown on any failure to load the store
-    */
-   public void load(URL storeURL) throws Exception;
-   /** Save the current store contents
-    * @param storeURL the URL representing the location of the store
-    * @exception Exception thrown on any failure to save the store
-    */
-   public void store(URL storeURL) throws Exception;
-
-   /** Obtain a ServiceConfig object for the given server instance and target
-    * service JMX ObjectName. This is called by the JBoss service configuration
-    * layer to obtain service attribute binding overrides.
-    *
-    * @param serverName the name identifying the JBoss server instance in
-    *    which the service is running.
-    * @param serviceName the JMX ObjectName of the service
-    * @return The ServiceConfig if one exists for the <serverName, serviceName>
-    *    pair, null otherwise.
-    */
-   public ServiceConfig getService(String serverName, ObjectName serviceName);
-
-   /** Add a ServiceConfig to the store. This is an optional method not used
-    * by the JBoss service configuration layer.
-    *
-    * @param serverName the name identifying the JBoss server instance in
-    *    which the service is running.
-    * @param serviceName the JMX ObjectName of the service
-    * @param serviceConfig the configuration to add
-    * @throws DuplicateServiceException thrown if a configuration for the
-    *    <serverName, serviceName> pair already exists.
-    */
-   public void addService(String serverName, ObjectName serviceName,
-      ServiceConfig serviceConfig)
-      throws DuplicateServiceException;
-
-   /** Remove a service configuration from the store. This is an optonal method
-    * not used by the JBoss service configuration layer.
-    *
-    * @param serverName the name identifying the JBoss server instance in
-    *    which the service is running.
-    * @param serviceName the JMX ObjectName of the service
-    */
-   public void removeService(String serverName, ObjectName serviceName);
-}

Deleted: trunk/varia/src/main/org/jboss/services/binding/ServicesStoreFactory.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/ServicesStoreFactory.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/ServicesStoreFactory.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,34 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-/** A factory interface for obtaining ServicesStore instances
- *
- * @version $Revision$
- * @author Scott.Stark at jboss.org
- */
-public interface ServicesStoreFactory 
-{
-   /** Load the contents of a store.
-    */
-   public ServicesStore newInstance();
-}

Added: trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+
+/**
+ * A {@link ServiceBindingValueSource} that returns a String.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface StringServiceBindingValueSource extends ServiceBindingValueSource
+{
+   /**
+    * Returns the String to use for the binding value.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @param originalValue an unprocessed value to which transformation can be applied
+    * 
+    * @return an String to use as the binding value. May return <code>null</code>.
+    */
+   String getStringServiceBindingValue(ServiceBinding binding, String input) throws Exception;
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/StringServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding;
+
+import java.net.URL;
+
+/**
+ * A {@link ServiceBindingValueSource} that returns a URL or a String
+ * representation of one.
+ * <p>
+ * Typical usage is in file transformation operations, where a given
+ * the content of a given <code>input</code> URL or classpath resource is read,
+ * transformed, written to a temp file, and the URL of the temp file returned.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface URLServiceBindingValueSource extends ServiceBindingValueSource
+{
+   /**
+    * Returns the URL to use for the binding value.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @param input the URL to use as input data
+    *  
+    * @return a URL to use as the binding value. Will not return <code>null</code>.
+    */
+   URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception;
+   
+   /**
+    * Returns a String representation of a URL path to use for the binding value.
+    * 
+    * @param binding the binding. Cannot be <code>null</code>
+    * @param input either a String representation of a URL or a value that
+    *              can be passed to {@link ClassLoader#getResourceAsStream(String)}
+    *              
+    * @return a filesystem path to use as the binding value. May return <code>null</code>.
+    */
+   String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception;
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/URLServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/varia/src/main/org/jboss/services/binding/XMLServicesStore.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/XMLServicesStore.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/XMLServicesStore.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,223 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import javax.management.ObjectName;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.logging.Logger;
-
-/**
- * XML implementation of ServicesStore.
- *
- * <p>Reads/writes/manages the XML config file for the ServiceBinding Manager module
- *
- * @author  <a href="mailto:bitpushr at rochester.rr.com">Mike Finn</a>.
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class XMLServicesStore implements ServicesStore
-{
-   private final Logger log = Logger.getLogger(getClass());
-
-   /** A thread-safe map of Map<ObjectName,ServiceConfig> keyed by server name.
-    */
-   private Map servers = Collections.synchronizedMap(new HashMap());
-
-   /** This method is not usable in this implementation as XMLServiceStore is read-only
-    *
-    * @param serverName
-    * @param serviceName
-    * @param config
-    * @exception DuplicateServiceException never thrown
-    * @exception UnsupportedOperationException("XMLServiceStore is read-only") always thrown
-    */
-   public void addService(String serverName, ObjectName serviceName, ServiceConfig config)
-      throws DuplicateServiceException
-   {
-      throw new UnsupportedOperationException("XMLServiceStore is read-only");
-   }
-
-   /**
-    *  Looks up a service, by server name and service name.
-    *  If the server or service does not exist, a null object is returned.
-    *
-    *  @param serverName The name of the server in the config file
-    *  @param serviceName The name of the service (i.e. the JMX object name)
-    *
-    *  @returns ServiceConfig object. Null if server or service is not found.
-    */
-   public ServiceConfig getService(String serverName, ObjectName serviceName)
-   {
-      Map serverMap = (Map) this.servers.get(serverName);
-      ServiceConfig config = null;
-      if( serverMap != null )
-      {
-         config = (ServiceConfig) serverMap.get(serviceName);
-      }
-      return config;
-   }
-
-   /** This method is not usable in this implementation as XMLServiceStore is read-only
-    *
-    * @param serverName
-    * @param serviceName
-    * @exception UnsupportedOperationException("XMLServiceStore is read-only") always thrown
-    */
-   public void removeService(String serverName, ObjectName serviceName)
-   {
-      throw new UnsupportedOperationException("XMLServiceStore is read-only");
-   }
-
-   /** Loads XML config file into memory and parses it into ServiceConfig
-    * objects.
-    *
-    * @throws Exception on any parse error
-    */
-   public void load(URL cfgURL)
-      throws Exception
-   {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder parser = factory.newDocumentBuilder();
-      InputStream cfgIS = cfgURL.openStream();
-      Document configDoc = parser.parse(cfgIS, cfgURL.toString());
-      Element serviceBindings = configDoc.getDocumentElement();
-      NodeList servers = serviceBindings.getElementsByTagName("server");
-      int length = servers.getLength();
-      for(int s = 0; s < length; s ++)
-      {
-         Element server = (Element) servers.item(s);
-         parseServer(server);
-      }
-   }
-
-   /** Store is a noop as this is a read-only store
-    */
-   public void store(URL cfgURL)
-      throws Exception
-   {
-   }
-
-   /** Parse /service-bindings/server/service-config element into
-    a Map<ObjectName,ServiceConfig> objects that are stored in the servers
-    map keyed by server.name.
-    */
-   private void parseServer(Element server)
-      throws Exception
-   {
-      String serverName = server.getAttribute("name");
-      HashMap serverConfigurations = new HashMap();
-      NodeList serviceConfigs = server.getElementsByTagName("service-config");
-      int length = serviceConfigs.getLength();
-      for(int c = 0; c < length; c ++)
-      {
-         Element config = (Element) serviceConfigs.item(c);
-         ServiceConfig serviceConfig = new ServiceConfig();
-         ObjectName serviceObjectName = parseConfig(config, serviceConfig);
-         serverConfigurations.put(serviceObjectName, serviceConfig);
-      }
-      this.servers.put(serverName, serverConfigurations);
-   }
-
-   /** Parse /service-bindings/server/service-config element into
-    the given ServiceConfig object.
-    */
-   private ObjectName parseConfig(Element config, ServiceConfig serviceConfig)
-      throws Exception
-   {
-      String serviceName = config.getAttribute("name");
-      ObjectName serviceObjectName = new ObjectName(serviceName);
-      serviceConfig.setServiceName(serviceName);
-
-      // Parse the delegate info
-      String delegateClass = config.getAttribute("delegateClass");
-      if( delegateClass.length() == 0 )
-         delegateClass = "org.jboss.services.binding.AttributeMappingDelegate";
-      Element delegateConfig = null;
-      NodeList delegateConfigs = config.getElementsByTagName("delegate-config");
-      if( delegateConfigs.getLength() > 0 )
-         delegateConfig = (Element) delegateConfigs.item(0);
-      serviceConfig.setServiceConfigDelegateClassName(delegateClass);
-      serviceConfig.setServiceConfigDelegateConfig(delegateConfig);
-
-      // Parse the service bindings
-      ArrayList bindingsArray = new ArrayList();
-      NodeList bindings = config.getElementsByTagName("binding");
-      int length = bindings.getLength();
-      for(int b = 0; b < length; b ++)
-      {
-         Element binding = (Element) bindings.item(b);
-         ServiceBinding sb = parseBinding(binding);
-         bindingsArray.add(sb);
-      }
-      ServiceBinding[] tmp = new ServiceBinding[bindingsArray.size()];
-      bindingsArray.toArray(tmp);
-      serviceConfig.setBindings(tmp);
-      return serviceObjectName;
-   }
-
-   /** Parse /service-bindings/server/service-config/binding element into
-    a ServiceBinding object. Any attributes whose value contains a system
-    property reference of the form ${x} will be replaced with the correcsponding
-    System.getProperty("x") value if one exists.
-    */
-   private ServiceBinding parseBinding(Element binding)
-      throws Exception
-   {
-      String name = binding.getAttribute("name");
-      if (name != null)
-      {
-         name = StringPropertyReplacer.replaceProperties(name);
-      }
-      String hostName = binding.getAttribute("host");
-      if (hostName != null)
-      {
-         hostName = StringPropertyReplacer.replaceProperties(hostName);
-      }
-      if (hostName.length() == 0)
-         hostName = null;
-      String portStr = binding.getAttribute("port");
-      if (portStr != null)
-      {
-         portStr = StringPropertyReplacer.replaceProperties(portStr);
-      }
-      if (portStr.length() == 0)
-         portStr = "0";
-      log.debug("parseBinding, name='" + name + "', host='" + hostName + "'"
-         + ", port='" + portStr + "'");
-      int port = Integer.parseInt(portStr);
-      ServiceBinding sb = new ServiceBinding(name, hostName, port);
-      return sb;
-   }
-}

Deleted: trunk/varia/src/main/org/jboss/services/binding/XMLServicesStoreFactory.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/XMLServicesStoreFactory.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/XMLServicesStoreFactory.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,37 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-/** A factory interface for obtaining XMLServicesStore instances
- *
- * @version $Revision$
- * @author Scott.Stark at jboss.org
- */
-public class XMLServicesStoreFactory implements ServicesStoreFactory
-{
-   /** Load the contents of a store.
-    */
-   public ServicesStore newInstance()
-   {
-      return new XMLServicesStore();
-   }
-}

Deleted: trunk/varia/src/main/org/jboss/services/binding/XSLTConfigDelegate.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/XSLTConfigDelegate.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/XSLTConfigDelegate.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,146 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-import java.io.StringReader;
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.MetaData;
-import org.jboss.util.StringPropertyReplacer;
-
-/** An implementation of the ServicesConfigDelegate that expects a delegate-config
- element of the form:
-    <delegate-config portName="portAttrName" hostName="hostAttrName">
-      <xslt-config configName="ConfigurationElement"><![CDATA[
- XSL document contents...
-]]>
-      </xslt-config>
-      <xslt-param name="p1">value1</xslt-param>
-    </delegate-config>
- The portAttrName and hostAttrName are currently unused. Perhaps these should
- be used as the names of the host and port parameters in the XSL script. Currently
- the host and port bindings are passed into the XSL script as the 'host' and
- 'port' global parameters.
-
- The xslt-param elements specify arbitrary XSL script parameter name/value pairs
- that will be set on the Transformer.
-
- at version $Revision$
- at author Scott.Stark at jboss.org
- */
-public class XSLTConfigDelegate implements ServicesConfigDelegate
-{
-   private static Logger log = Logger.getLogger(XSLTConfigDelegate.class);
-
-   /** Take the given config and map it onto the service specified in the
-    config using JMX via the given server.
-    @param config, the service name and its config bindings
-    @param server, the JMX server to use to apply the config
-    */
-   public void applyConfig(ServiceConfig config, MBeanServer server) throws Exception
-   {
-      Element delegateConfig = (Element) config.getServiceConfigDelegateConfig();
-      if( delegateConfig == null )
-         throw new IllegalArgumentException("ServiceConfig.ServiceConfigDelegateConfig is null");
-
-      // Get the XSL doc
-      Element xslConfigElement = (Element) delegateConfig.getElementsByTagName("xslt-config").item(0);
-      String configName = xslConfigElement.getAttribute("configName");
-      Node xslContent = xslConfigElement.getFirstChild();
-      if( configName.length() == 0 )
-         throw new IllegalArgumentException("No valid configName attribute found");
-
-      // Get the DOM config from the configName attribute
-      ObjectName serviceName = new ObjectName(config.getServiceName());
-      Element mbeanConfig = (Element) server.getAttribute(serviceName, configName);
-      if( mbeanConfig == null )
-      {
-         log.debug("No value found for config attribute: "+configName);
-         return;
-      }
-
-      // Create the XSL transformer
-      String xslText = xslContent.getNodeValue();
-      log.trace("XSL text:"+xslText);
-      StreamSource xslSource = new StreamSource(new StringReader(xslText));
-      TransformerFactory factory = TransformerFactory.newInstance();
-      Transformer transformer = factory.newTransformer(xslSource);
-
-      // Only the first binding is used as only one (host,port) pair is mapped
-      ServiceBinding[] bindings = config.getBindings();
-      if( bindings != null && bindings.length > 0 )
-      {
-         int port = bindings[0].getPort();
-         String host = bindings[0].getHostName();
-         // Set the host an port params to that binding values
-         if( host != null )
-         {
-            transformer.setParameter("host", host);
-            log.debug("set host parameter to:"+host);
-         }
-         transformer.setParameter("port", new Integer(port));
-         log.debug("set port parameter to:"+port);
-
-         // Check for any arbitrary attributes
-         NodeList attributes = delegateConfig.getElementsByTagName("xslt-param");
-         // xslt-param are transform parameters
-         for(int a = 0; a < attributes.getLength(); a ++)
-         {
-            Element attr = (Element) attributes.item(a);
-            String name = attr.getAttribute("name");
-            if( name.length() == 0 )
-               throw new IllegalArgumentException("attribute element #"
-                            +a+" has no name attribute");
-            String attrExp = MetaData.getElementContent(attr);
-            String attrValue = StringPropertyReplacer.replaceProperties(attrExp);
-            transformer.setParameter(name, attrValue);
-
-            log.debug("set "+name+" parameter to:"+attrValue);
-         }
-
-         // Transform the current config element
-         DOMSource src = new DOMSource(mbeanConfig);
-         DOMResult result = new DOMResult();
-         transformer.transform(src, result);
-         // Write the transformed config back to the mbean
-         Document newMbeanDoc = (Document) result.getNode();
-         Element newMbeanConfig = newMbeanDoc.getDocumentElement();
-         log.debug("Updating DOM attribute to: "+newMbeanConfig);
-         Attribute mbeanConfigAttr = new Attribute(configName, newMbeanConfig);
-         server.setAttribute(serviceName, mbeanConfigAttr);
-      }
-   }
-
-}

Deleted: trunk/varia/src/main/org/jboss/services/binding/XSLTFileDelegate.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/XSLTFileDelegate.java	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/main/org/jboss/services/binding/XSLTFileDelegate.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -1,178 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY 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 along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.services.binding;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.StringReader;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.jboss.logging.Logger;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.metadata.MetaData;
-import org.jboss.util.StringPropertyReplacer;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * An implementation of the ServicesConfigDelegate
- * that transforms an xml file used by a service.
- *
- * It retrieves the file location from the service, 
- * tranforms the file and saves it on a temporary location,
- * which will be then applied to the service.
- *  
- * It excpects a delegate-config element of the following form: 
- *  
- * <delegate-config>
- *   <xslt-config configName="jmx_filename_attribute"><![CDATA[
- *     XSL document contents...
- *   ]]></xslt-config>
- * </delegate-config>
- * 
- * The configName attribute specifies the JMX attribute,
- * which defines the XML file to be transformed.
- *
- * @author wonne.keysers at realsoftware.be
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class XSLTFileDelegate implements ServicesConfigDelegate
-{
-   private static Logger log = Logger.getLogger(XSLTFileDelegate.class);
-
-   /** Transform the file specified in the given config, 
-    * transform it, temporarily save the result and apply it onto the service
-    * specified in the config using JMX via the given server.
-    @param config, the service name and its config bindings
-    @param server, the JMX server to use to apply the config
-    */
-   public void applyConfig(ServiceConfig config, MBeanServer server)
-      throws Exception
-   {
-      Element delegateConfig =
-         (Element) config.getServiceConfigDelegateConfig();
-      if (delegateConfig == null)
-      {
-         throw new IllegalArgumentException("ServiceConfig.ServiceConfigDelegateConfig is null");
-      }
-
-      Element xslConfigElement =
-         (Element) delegateConfig.getElementsByTagName("xslt-config").item(0);
-      if (xslConfigElement == null)
-      {
-         throw new IllegalArgumentException("No valid xslt config found");
-      }
-
-      String configName = xslConfigElement.getAttribute("configName");
-      log.debug("configName = " + configName);
-
-      if (configName.length() == 0)
-      {
-         throw new IllegalArgumentException("No valid configName attribute found");
-      }
-
-      ObjectName serviceName = new ObjectName(config.getServiceName());
-      log.debug("serviceName = " + serviceName);
-
-      String oldValue = (String) server.getAttribute(serviceName, configName);
-      log.debug("oldValue = " + oldValue);
-
-      String tmpName = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
-      File tempDirectory = new File(tmpName);
-      File targetFile = File.createTempFile("server", ".xml", tempDirectory);
-      targetFile.deleteOnExit();
-      log.debug("targetFile: " + targetFile.getCanonicalPath());
-
-      ServiceBinding[] bindings = config.getBindings();
-      if (bindings == null || bindings.length == 0)
-      {
-         throw new IllegalArgumentException("No port binding specified");
-      }
-
-      int port = bindings[0].getPort();
-      String host = bindings[0].getHostName();
-
-      try
-      {
-         String xslText = xslConfigElement.getFirstChild().getNodeValue();
-         log.trace("XSL text:" + xslText);
-         Source xslSource = new StreamSource(new StringReader(xslText));
-
-         Source xmlSource =
-            new StreamSource(getClass().getClassLoader().getResourceAsStream(oldValue));
-
-         Result xmlResult =
-            new StreamResult(new FileOutputStream(targetFile));
-
-         TransformerFactory factory = TransformerFactory.newInstance();
-         Transformer transformer = factory.newTransformer(xslSource);
-
-         transformer.setParameter("port", new Integer(port));
-         log.debug("set port parameter to:"+port);
-         if (host != null)
-         {
-            transformer.setParameter("host", host);
-            log.debug("set host parameter to:"+host);
-         }
-
-         // Check for any arbitrary attributes
-         NodeList attributes = delegateConfig.getElementsByTagName("xslt-param");
-         // xslt-param are transform parameters
-         for(int a = 0; a < attributes.getLength(); a ++)
-         {
-            Element attr = (Element) attributes.item(a);
-            String name = attr.getAttribute("name");
-            if( name.length() == 0 )
-               throw new IllegalArgumentException("attribute element #"
-                            +a+" has no name attribute");
-            String attrExp = MetaData.getElementContent(attr);
-            String attrValue = StringPropertyReplacer.replaceProperties(attrExp);
-            transformer.setParameter(name, attrValue);
-
-            log.debug("set "+name+" parameter to:"+attrValue);
-         }
-
-         transformer.transform(xmlSource, xmlResult);
-
-         Attribute mbeanConfigAttr =
-            new Attribute(configName, targetFile.getCanonicalPath());
-
-         server.setAttribute(serviceName, mbeanConfigAttr);
-      }
-      catch (Exception ex)
-      {
-         log.error("Error while transforming xml", ex);
-      }
-
-   }
-
-}

Added: trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.services.binding.DuplicateServiceException;
+import org.jboss.services.binding.NoSuchBindingException;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingStore;
+
+/**
+ * A PojoServiceBindingStore.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class PojoServiceBindingStore implements ServiceBindingStore
+{
+   private static final Object VALUE = new Object();
+   
+   private final ConcurrentMap<ServiceBindingKey, ServiceBinding> bindings = 
+      new ConcurrentHashMap<ServiceBindingKey, ServiceBinding>(16, (float) .75, 4);
+   
+   private final ConcurrentMap<String, Object> bindingSetNames = 
+      new ConcurrentHashMap<String, Object>(16, (float) .75, 4);
+   
+   private final Map<String, String> defaultHostNames = new HashMap<String, String>();
+   
+   private final Map<String, InetAddress> defaultBindAddresses = new HashMap<String, InetAddress>();
+   
+   private final Map<String, Integer> defaultPortOffsets = new HashMap<String, Integer>();
+   
+   public PojoServiceBindingStore(Map<String, ServiceBindingSet> configSets)
+     throws DuplicateServiceException
+   {
+      if (configSets == null)
+         throw new IllegalArgumentException("configSets is null");
+      
+      for (Map.Entry<String, ServiceBindingSet> entry : configSets.entrySet())
+      {
+         String serverName = entry.getKey();
+         
+         bindingSetNames.put(serverName, VALUE);
+         
+         ServiceBindingSet bindingSet = entry.getValue();
+         
+         defaultHostNames.put(serverName, bindingSet.getDefaultHostName());
+         defaultBindAddresses.put(serverName, bindingSet.getDefaultBindAddress());
+         defaultPortOffsets.put(serverName, bindingSet.getPortOffset());
+         
+         for (ServiceBinding binding : bindingSet)
+         {
+            addServiceBinding(serverName, binding);
+         }
+      }
+   }
+   
+   public void addServiceBinding(String serverName, ServiceBinding binding) throws DuplicateServiceException
+   {      
+      validateServerName(serverName);
+      Object oldBinding = bindings.putIfAbsent(new ServiceBindingKey(serverName, binding), binding);
+      if (oldBinding != null)
+      {
+         throw new DuplicateServiceException(serverName, binding);
+      }
+   }
+
+   public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
+         throws NoSuchBindingException
+   {
+      ServiceBinding binding = bindings.get(new ServiceBindingKey(serverName, serviceName, bindingName));
+      if (binding == null)
+      {
+         throw new NoSuchBindingException(serverName, serviceName, bindingName);
+      }
+      return binding;
+   }
+
+   public void removeServiceBinding(String serverName, ServiceBinding binding)
+   {
+      validateServerName(serverName);
+      bindings.remove(new ServiceBindingKey(serverName, binding));
+   }
+
+   public void removeServiceBinding(String serverName, String serviceName, String bindingName)
+   {
+      validateServerName(serverName);
+      bindings.remove(new ServiceBindingKey(serverName, serviceName, bindingName));
+   }
+   
+   public void addServiceBinding(ServiceBinding binding) throws DuplicateServiceException
+   {
+      for (String serverName : bindingSetNames.keySet())
+      {
+         int port = binding.getPort() + getDefaultPortOffset(serverName);
+         String hostName = binding.getHostName();
+         if (hostName == null)
+            hostName = getDefaultHostName(serverName);
+         
+         try
+         {
+            addServiceBinding(serverName, new ServiceBinding(binding.getServiceName(), binding.getBindingName(), hostName, port));
+         }
+         catch (UnknownHostException e)
+         {
+            throw new IllegalStateException("Cannot convert " + hostName + " into an InetAddress");
+         }
+      }
+   }
+
+   public void removeServiceBinding(ServiceBinding binding)
+   {
+      for (String serverName : bindingSetNames.keySet())
+      {
+         removeServiceBinding(serverName, binding);
+      }
+   }
+
+   public void removeServiceBinding(String serviceName, String bindingName)
+   {
+      for (String serverName : bindingSetNames.keySet())
+      {
+         removeServiceBinding(serverName, serviceName, bindingName);
+      }
+   }
+
+   public InetAddress getDefaultBindAddress(String serverName)
+   {
+      validateServerName(serverName);
+      return defaultBindAddresses.get(serverName);
+   }
+
+   public String getDefaultHostName(String serverName)
+   {
+      validateServerName(serverName);
+      return defaultHostNames.get(serverName);
+   }
+
+   public int getDefaultPortOffset(String serverName)
+   {
+      validateServerName(serverName);
+      return defaultPortOffsets.get(serverName).intValue();
+   }
+
+   private void validateServerName(String serverName)
+   {
+      if (bindingSetNames.containsKey(serverName) == false)
+         throw new IllegalArgumentException("unknown serverName " +serverName);
+   }
+
+   private static class ServiceBindingKey
+   {
+      private final String serverName;
+      private final String serviceName;
+      private final String bindingName;
+      
+      private ServiceBindingKey(String serverName, ServiceBinding binding)
+      {
+         this(serverName, binding.getServiceName(), binding.getBindingName());
+      }
+      
+      private ServiceBindingKey(String serverName, String serviceName, String bindingName)
+      {
+         assert serverName != null : "serverName is null";
+         assert serviceName != null : "serviceName is null";
+         
+         this.serverName  = serverName;
+         this.serviceName = ServiceBinding.canonicalizeServiceName(serviceName);
+         this.bindingName = bindingName;
+      }
+
+      @Override
+      public boolean equals(Object obj)
+      {
+         if (obj instanceof ServiceBindingKey)
+         {
+            ServiceBindingKey other = (ServiceBindingKey) obj;
+            return (this.serverName.equals(other.serverName)
+                    && this.serviceName.equals(other.serviceName)
+                    && safeEquals(this.bindingName, other.bindingName));
+         }
+         return false;
+      }
+
+      @Override
+      public int hashCode()
+      {
+         int result = 17;
+         result += 23 * this.serverName.hashCode();
+         result += 23 * this.serviceName.hashCode();
+         result += 23 * (this.bindingName == null ? 0 : this.bindingName.hashCode());
+         return result;
+      }
+      
+      private boolean safeEquals(Object a, Object b)
+      {
+         return (a == b || (a != null && a.equals(b)));
+      }
+      
+   }
+
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/PojoServiceBindingStore.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.services.binding.ServiceBinding;
+
+/**
+ * Set<ServiceBinding> that populates itself by taking a base set
+ * and duplicating its binding with a fixed offset to each port value.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class ServiceBindingSet extends HashSet<ServiceBinding>
+{   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 765380451233486038L;
+
+   private final String defaultHostName;
+   private final InetAddress defaultBindAddress;
+   private final int portOffset;
+   
+   public ServiceBindingSet(Set<ServiceBinding> base) throws UnknownHostException
+   {
+      this(base, 0, null, null);
+   }
+
+   public ServiceBindingSet(Set<ServiceBinding> base, int offset) throws UnknownHostException
+   {
+      this(base, offset, null, null);
+   }
+
+   public ServiceBindingSet(Set<ServiceBinding> base, int offset, String defaultHostName) throws UnknownHostException
+   {
+      this(base, offset, null, defaultHostName);
+   }
+   
+   public ServiceBindingSet(Set<ServiceBinding> base, int offset, Set<ServiceBinding> overrides, String defaultHostName) throws UnknownHostException
+   {
+      super(getOffsetBindings(base, offset));
+      if (overrides != null)
+      {
+         // HashSet.add() is not a replace operation, so must remove first
+         for (ServiceBinding binding : overrides)
+         {
+            remove(binding);
+            add(binding);
+         }
+      }
+      
+      this.defaultHostName = defaultHostName;
+      this.defaultBindAddress = defaultHostName == null ? null : InetAddress.getByName(defaultHostName);
+      this.portOffset = offset;
+   }
+   
+   private static Set<ServiceBinding> getOffsetBindings(Set<ServiceBinding> base, int offset) throws UnknownHostException
+   {
+      Set<ServiceBinding> altered = new HashSet<ServiceBinding>(base.size());
+      for (ServiceBinding binding : base)
+      {
+         altered.add(binding.getOffsetBinding(offset));
+      }
+      return altered;
+   }
+
+   public String getDefaultHostName()
+   {
+      return defaultHostName;
+   }
+
+   public InetAddress getDefaultBindAddress()
+   {
+      return defaultBindAddress;
+   }
+
+   public int getPortOffset()
+   {
+      return portOffset;
+   }
+   
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/ServiceBindingSet.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.net.InetAddress;
+
+import org.jboss.services.binding.InetAddressServiceBindingValueSource;
+import org.jboss.services.binding.IntServiceBindingValueSource;
+import org.jboss.services.binding.ServiceBinding;
+
+/**
+ * ServiceBindingValueSource that returns the given binding's
+ * {@link ServiceBinding#getBindAddress() bind address} and 
+ * {@link ServiceBinding#getPort() port}.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SimpleServiceBindingValueSourceImpl
+      implements
+         IntServiceBindingValueSource,
+         InetAddressServiceBindingValueSource
+{
+
+   /**
+    * @return <code>binding.{@link ServiceBinding#getPort() getPort()}</code>
+    */
+   public int getIntServiceBindingValue(ServiceBinding binding)
+   {
+      return binding.getPort();
+   }
+
+   /**
+    * @return <code>binding.{@link ServiceBinding#getBindAddress() getBindAddress()}</code>
+    */
+   public InetAddress getInetAddressServiceBindingValue(ServiceBinding binding)
+   {
+      return binding.getBindAddress();
+   }
+
+   /**
+    * @return <code>new Integer(binding.{@link ServiceBinding#getPort() getPort()})</code>
+    */
+   public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+   {
+      if (params != null && params.length > 0)
+         throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() does not accept argument 'params'");
+      
+      return new Integer(getIntServiceBindingValue(binding));
+   }
+
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/SimpleServiceBindingValueSourceImpl.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+
+/**
+ * A StringReplacementServiceBindingValueSourceConfig.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class StringReplacementServiceBindingValueSourceConfig
+{
+   public static final String DEFAULT_HOST_MARKER = "${host}";
+   public static final String DEFAULT_PORT_MARKER = "${port}";
+   
+   private String portMarker;
+   private String hostMarker;
+   
+   public StringReplacementServiceBindingValueSourceConfig()
+   {
+      this(DEFAULT_HOST_MARKER, DEFAULT_PORT_MARKER);
+   }
+   
+   public StringReplacementServiceBindingValueSourceConfig(String hostMarker, String portMarker)
+   {
+      this.hostMarker = (hostMarker == null ? DEFAULT_HOST_MARKER : hostMarker);
+      this.portMarker = (portMarker == null ? DEFAULT_PORT_MARKER : portMarker);
+   }
+
+   public String getPortMarker()
+   {
+      return portMarker;
+   }
+
+   public String getHostMarker()
+   {
+      return hostMarker;
+   }
+   
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceConfig.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.net.URL;
+
+import org.jboss.services.binding.ElementServiceBindingValueSource;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.StringServiceBindingValueSource;
+import org.jboss.services.binding.URLServiceBindingValueSource;
+import org.w3c.dom.Element;
+
+/**
+ * A StringReplacementServiceBindingValueSourceImpl.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class StringReplacementServiceBindingValueSourceImpl 
+   implements StringServiceBindingValueSource, ElementServiceBindingValueSource, URLServiceBindingValueSource
+{
+   
+   public String getStringServiceBindingValue(ServiceBinding binding, String input) throws Exception
+   {
+      if (input == null)
+      {
+         return binding.getHostName();
+      }
+      
+      StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
+      return replaceHostAndPort(input, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+   }  
+      
+
+   public Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception
+   {
+      if (input == null)
+         throw new IllegalArgumentException("input cannot be null");
+      
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      if (editor == null)
+         throw new IllegalStateException("Cannot find PropertyEditor for type Element");
+      
+      StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);
+      
+      editor.setValue(input);
+      String text = editor.getAsText();
+      text = replaceHostAndPort(text, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+      editor.setAsText(text);
+      return (Element) editor.getValue();
+   }
+
+   public String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception
+   {
+      if (input == null)
+         throw new IllegalArgumentException("input cannot be null");
+      
+      StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);      
+      
+      String content = Util.getContentAsString(input);
+      String transformed = replaceHostAndPort(content, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+      return Util.writeToTempFile(transformed).getAbsolutePath();
+   }
+
+
+   public URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception
+   {
+      if (input == null)
+         throw new IllegalArgumentException("input cannot be null");
+      
+      StringReplacementServiceBindingValueSourceConfig config = getConfig(binding);      
+      
+      String content = Util.getContentAsString(input);
+      String transformed = replaceHostAndPort(content, binding.getHostName(), binding.getPort(), config.getHostMarker(), config.getPortMarker());
+      return Util.writeToTempFile(transformed).toURL();
+   }
+
+   public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+   {
+      if (params == null)
+      {
+         return getStringServiceBindingValue(binding, null);
+      }
+      
+      if (params.length != 1)
+      {
+        throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params'");
+      }
+      
+      if (params[0] instanceof String)
+      {   
+         return getStringServiceBindingValue(binding, (String) params[0]);
+      }
+      else if (params[0] instanceof Element)
+      {   
+         return getElementServiceBindingValue(binding, (Element) params[0]);
+      }
+      else if (params[0] instanceof URL)
+      {   
+         return getURLServiceBindingValue(binding, (URL) params[0]);
+      }
+      
+      throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params' of type String, Element or URL");
+   }
+   
+   
+   
+   // ----------------------------------------------------------------  Private
+
+
+   private StringReplacementServiceBindingValueSourceConfig getConfig(ServiceBinding binding)
+   {
+      Object configSource = binding.getServiceBindingValueSourceConfig();
+      if (configSource instanceof StringReplacementServiceBindingValueSourceConfig)
+      {
+         return (StringReplacementServiceBindingValueSourceConfig) configSource;
+      }
+      else
+      {
+         return new StringReplacementServiceBindingValueSourceConfig();
+      }
+   }
+   
+   private String replaceHostAndPort(String text, String host, int port, String hostMarker, String portMarker)
+   {
+      if( text == null )
+         return null;
+      
+      if( host == null )
+         host = "localhost";
+      String portStr = String.valueOf(port);
+
+      text = text.replace(hostMarker, host);
+      return text.replace(portMarker, portStr);
+   }
+
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/StringReplacementServiceBindingValueSourceImpl.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/Util.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/Util.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/Util.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingValueSource;
+import org.jboss.system.server.ServerConfig;
+
+/**
+ * Utilities used by service binding manager components.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class Util
+{  
+   
+   public static InputStream getInputStream(URL url) throws IOException
+   {
+      URLConnection conn = url.openConnection();
+      conn.connect();
+      return conn.getInputStream();      
+   }
+   
+   public static InputStream getInputStream(String resource) throws IOException
+   {
+      try
+      {
+         URL url = new URL(resource);
+         return getInputStream(url);
+      }
+      catch (MalformedURLException mue)
+      {
+         ClassLoader cl = Thread.currentThread().getContextClassLoader();
+         return cl.getResourceAsStream(resource);
+      }
+   }
+   
+   public static InputStreamReader getInputStreamReader(URL url) throws IOException
+   {
+      return new InputStreamReader(getInputStream(url));
+   }
+   
+   public static InputStreamReader getInputStreamReader(String resource) throws IOException
+   {
+      try
+      {
+         URL url = new URL(resource);
+         return getInputStreamReader(url);
+      }
+      catch (MalformedURLException mue)
+      {
+         ClassLoader cl = Thread.currentThread().getContextClassLoader();
+         InputStream is = cl.getResourceAsStream(resource);
+         if (is == null)
+            throw new IllegalArgumentException("No resource " + resource + " found");
+         return new InputStreamReader(is);
+      }
+   }
+   
+   public static String getContentAsString(URL url) throws IOException
+   {
+      InputStreamReader isr = getInputStreamReader(url);
+      return getContentAsString(isr);
+   }
+   
+   public static String getContentAsString(String resource) throws IOException
+   {
+      InputStreamReader isr = getInputStreamReader(resource);
+      return getContentAsString(isr);
+   }
+   
+   public static File writeToTempFile(String content) throws IOException
+   {
+      File targetFile = Util.createTempFile();
+      OutputStreamWriter osw = null;
+      try
+      {
+         osw = new OutputStreamWriter(new FileOutputStream(targetFile));
+         osw.write(content);
+         
+         return targetFile;
+      }
+      finally
+      {
+         if (osw != null)
+            osw.close();
+      }
+   }
+   
+   private static String getContentAsString(InputStreamReader isr) throws IOException
+   {
+      try
+      {
+         StringWriter writer = new StringWriter();
+         char[] buf = new char[1024];
+         int read;
+         while((read = isr.read(buf, 0, buf.length)) != -1)
+         {
+            writer.write(buf, 0, read);
+         }
+         return writer.toString();
+      }
+      finally
+      {
+         isr.close();
+      }
+   }
+   
+   public static File createTempFile() throws IOException
+   {
+      String tmpName = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
+      File tempDirectory = new File(tmpName);
+      File targetFile = File.createTempFile("service-binding", ".tmp", tempDirectory);
+      targetFile.deleteOnExit();
+      
+      return targetFile;
+   }
+   
+   public static <T> T getBindingValue(ServiceBindingValueSource source, ServiceBinding binding, Class<T> expectedType) throws Exception
+   {
+      Object[] params = null;
+      Object obj = source.getServiceBindingValue(binding, params);
+      if (expectedType.isAssignableFrom(obj.getClass()))
+      {
+         return expectedType.cast(obj);
+      }
+      else
+      {
+         throw new IllegalStateException("Incompatible value source for " + binding + " -- must return " + expectedType.getSimpleName());
+      } 
+   }
+   
+   public static <T> T getBindingValueWithInput(ServiceBindingValueSource source, ServiceBinding binding, Object input, Class<T> expectedType) throws Exception
+   {
+      Object obj = source.getServiceBindingValue(binding, input);
+      if (expectedType.isAssignableFrom(obj.getClass()))
+      {
+         return expectedType.cast(obj);
+      }
+      else
+      {
+         throw new IllegalStateException("Incompatible value source for " + binding + " -- must return " + expectedType.getSimpleName());
+      } 
+   }
+   
+   /** Prevent instantiation */
+   private Util() {}
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/Util.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Configuration object for a ServiceBindingValueSource that uses
+ * XSL Transformation.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class XSLTServiceBindingValueSourceConfig
+{
+   private final String xslt;
+   private final HashMap<String, String> additionalAttributes = new HashMap<String, String>();
+   
+   public XSLTServiceBindingValueSourceConfig(String xslt)
+   {
+      this(xslt, null);      
+   }
+   
+   public XSLTServiceBindingValueSourceConfig(String xslt, Map<String, String> additionalAttributes)
+   {
+      if (xslt == null)
+         throw new IllegalArgumentException("xslt is null");
+      this.xslt = xslt;     
+      
+      if (additionalAttributes != null)
+         this.additionalAttributes.putAll(additionalAttributes);
+   }
+
+   public String getXslt()
+   {
+      return xslt;
+   }
+   
+   public Map<String, String> getAdditionalAttributes()
+   {
+      return Collections.unmodifiableMap(additionalAttributes);
+   }
+   
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceConfig.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.services.binding.impl;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.services.binding.ElementServiceBindingValueSource;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.URLServiceBindingValueSource;
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Element;
+
+/**
+ * A XSLTServiceBindingValueSourceImpl.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class XSLTServiceBindingValueSourceImpl implements URLServiceBindingValueSource, ElementServiceBindingValueSource
+{
+
+   public String getResourceServiceBindingValue(ServiceBinding binding, String input) throws Exception
+   {
+      if (input == null)
+         throw new IllegalArgumentException("input cannot be null");
+      
+      XSLTServiceBindingValueSourceConfig config = getConfig(binding);
+      
+      Reader reader = null;
+      Writer writer = null;
+      try
+      {
+         reader = Util.getInputStreamReader(input);
+
+         File targetFile = Util.createTempFile();
+         writer = new OutputStreamWriter(new FileOutputStream(targetFile));
+         
+         doXslTransform(binding, config, reader, writer);
+
+         return targetFile.getAbsolutePath();
+      }
+      finally
+      {
+         if (reader != null)
+            reader.close();
+         if (writer != null)
+            writer.close();
+      }
+   }
+
+   public URL getURLServiceBindingValue(ServiceBinding binding, URL input) throws Exception
+   {
+      if (input == null)
+         throw new IllegalArgumentException("input cannot be null");
+      
+      XSLTServiceBindingValueSourceConfig config = getConfig(binding);
+      
+      Reader reader = null;
+      Writer writer = null;
+      try
+      {
+         reader = Util.getInputStreamReader(input);
+
+         File targetFile = Util.createTempFile();
+         writer = new OutputStreamWriter(new FileOutputStream(targetFile));
+         
+         doXslTransform(binding, config, reader, writer);
+
+         return targetFile.toURL();
+      }
+      finally
+      {
+         if (reader != null)
+            reader.close();
+         if (writer != null)
+            writer.close();
+      }
+   }
+
+   public Element getElementServiceBindingValue(ServiceBinding binding, Element input) throws Exception
+   {
+      if (input == null)
+         throw new IllegalArgumentException("input cannot be null");
+      
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      if (editor == null)
+         throw new IllegalStateException("Cannot find PropertyEditor for type Element");
+      
+      editor.setValue(input);      
+      Reader reader = new StringReader(editor.getAsText());
+      Writer writer = new StringWriter();
+      
+      doXslTransform(binding, getConfig(binding), reader, writer);
+      
+      editor.setAsText(writer.toString());
+      return (Element) editor.getValue();
+   }
+
+   public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+   {
+      if (params == null || params.length != 1)
+      {
+        throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params'");
+      }
+      
+      if (params[0] instanceof String)
+      {   
+         return getResourceServiceBindingValue(binding, (String) params[0]);
+      }
+      else if (params[0] instanceof Element)
+      {   
+         return getElementServiceBindingValue(binding, (Element) params[0]);
+      }
+      else if (params[0] instanceof URL)
+      {   
+         return getURLServiceBindingValue(binding, (URL) params[0]);
+      }
+      
+      throw new IllegalArgumentException(getClass().getSimpleName() + ".getServiceBindingValue() requires a single-value 'params' of type String, Element or URL");
+   }
+   
+   private XSLTServiceBindingValueSourceConfig getConfig(ServiceBinding binding)
+   {
+      Object config = binding.getServiceBindingValueSourceConfig();
+      if (config instanceof XSLTServiceBindingValueSourceConfig)
+      {
+         return (XSLTServiceBindingValueSourceConfig) config;
+      }
+      else if (config == null)
+      {
+         throw new IllegalStateException("No config object bound to " + binding);
+      }
+      throw new IllegalStateException("Incompatible config object of type " + 
+                                       config.getClass() + " bound to " + binding +
+                                       " -- must use " + XSLTServiceBindingValueSourceConfig.class.getName());
+   }
+
+   private void doXslTransform(ServiceBinding binding, XSLTServiceBindingValueSourceConfig config, 
+         Reader reader, Writer writer) throws TransformerException
+   {
+      Source xmlSource = new StreamSource(reader);
+      Result xmlResult = new StreamResult(writer);         
+      Source xslSource = new StreamSource(new StringReader(config.getXslt()));
+      
+      TransformerFactory factory = TransformerFactory.newInstance();
+      Transformer transformer = factory.newTransformer(xslSource);
+
+      transformer.setParameter("port", new Integer(binding.getPort()));
+      String host = binding.getHostName();
+      if (host != null)
+      {
+         transformer.setParameter("host", host);
+      }
+
+      // Check for any arbitrary attributes
+      Map<String, String> attributes = config.getAdditionalAttributes();
+      for(Map.Entry<String, String> entry : attributes.entrySet())
+      {
+         String attrValue = StringPropertyReplacer.replaceProperties(entry.getValue());
+         transformer.setParameter(entry.getKey(), attrValue);
+      }
+
+      transformer.transform(xmlSource, xmlResult);
+   }
+
+}


Property changes on: trunk/varia/src/main/org/jboss/services/binding/impl/XSLTServiceBindingValueSourceImpl.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/varia/src/resources/services/invoker/http/jboss-service.xml
===================================================================
--- trunk/varia/src/resources/services/invoker/http/jboss-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/resources/services/invoker/http/jboss-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -13,7 +13,14 @@
       is running.
       -->
      <attribute name="InvokerURLPrefix">http://</attribute>
-     <attribute name="InvokerURLSuffix">:8080/invoker/EJBInvokerServlet</attribute>
+     <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/EJBInvokerServlet</parameter>
+        </value-factory>
+     </attribute>
      <attribute name="UseHostName">true</attribute>
   </mbean>
 
@@ -24,7 +31,14 @@
       <attribute name="InvokerName">jboss:service=Naming</attribute>
       <!-- Compose the invoker URL from the cluster node address -->
       <attribute name="InvokerURLPrefix">http://</attribute>
-      <attribute name="InvokerURLSuffix">:8080/invoker/JMXInvokerServlet</attribute>
+      <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/JMXInvokerServlet</parameter>
+        </value-factory>
+      </attribute>
       <attribute name="UseHostName">true</attribute>
       <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
       <attribute name="JndiName"></attribute>
@@ -45,7 +59,14 @@
       name="jboss:service=invoker,type=http,target=Naming,readonly=true">
       <attribute name="InvokerName">jboss:service=Naming</attribute>
       <attribute name="InvokerURLPrefix">http://</attribute>
-      <attribute name="InvokerURLSuffix">:8080/invoker/readonly/JMXInvokerServlet</attribute>
+      <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/readonly/JMXInvokerServlet</parameter>
+        </value-factory>
+      </attribute>
       <attribute name="UseHostName">true</attribute>
       <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
       <attribute name="JndiName"></attribute>

Modified: trunk/varia/src/resources/services/invoker/httpha/jboss-service.xml
===================================================================
--- trunk/varia/src/resources/services/invoker/httpha/jboss-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/resources/services/invoker/httpha/jboss-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -13,7 +13,14 @@
       is running.
       -->
      <attribute name="InvokerURLPrefix">http://</attribute>
-     <attribute name="InvokerURLSuffix">:8080/invoker/EJBInvokerServlet</attribute>
+     <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/EJBInvokerServlet</parameter>
+        </value-factory>
+     </attribute>
      <attribute name="UseHostName">true</attribute>
   </mbean>
 
@@ -24,7 +31,14 @@
       is running.
       -->
      <attribute name="InvokerURLPrefix">http://</attribute>
-     <attribute name="InvokerURLSuffix">:8080/invoker/EJBInvokerHAServlet</attribute>
+     <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/EJBInvokerHAServlet</parameter>
+        </value-factory>
+     </attribute>
      <attribute name="UseHostName">true</attribute>
   </mbean>
 
@@ -35,7 +49,14 @@
       <attribute name="InvokerName">jboss:service=Naming</attribute>
       <!-- Compose the invoker URL from the cluster node address -->
       <attribute name="InvokerURLPrefix">http://</attribute>
-      <attribute name="InvokerURLSuffix">:8080/invoker/JMXInvokerServlet</attribute>
+      <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/JMXInvokerServlet</parameter>
+        </value-factory>
+      </attribute>
       <attribute name="UseHostName">true</attribute>
       <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
       <attribute name="JndiName"></attribute>
@@ -56,7 +77,14 @@
       name="jboss:service=invoker,type=http,target=Naming,readonly=true">
       <attribute name="InvokerName">jboss:service=Naming</attribute>
       <attribute name="InvokerURLPrefix">http://</attribute>
-      <attribute name="InvokerURLSuffix">:8080/invoker/readonly/JMXInvokerServlet</attribute>
+      <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/readonly/JMXInvokerServlet</parameter>
+        </value-factory>
+      </attribute>
       <attribute name="UseHostName">true</attribute>
       <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
       <attribute name="JndiName"></attribute>
@@ -77,7 +105,14 @@
       <attribute name="InvokerName">jboss:service=HAJNDI</attribute>
       <!-- Compose the invoker URL from the cluster node address -->
       <attribute name="InvokerURLPrefix">http://</attribute>
-      <attribute name="InvokerURLSuffix">:8080/invoker/JMXInvokerHAServlet</attribute>
+      <attribute name="InvokerURLSuffix">
+        <!-- To get value, ask the ServiceBindingManager to do a string 
+             replacement operation using the HTTP connector port -->
+        <value-factory bean="ServiceBindingManager" method="getStringBinding">
+           <parameter>jboss.web:service=WebServer</parameter>
+           <parameter>:${port}/invoker/JMXInvokerHAServlet</parameter>
+        </value-factory>
+      </attribute>
       <attribute name="UseHostName">true</attribute>
       <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
       <attribute name="JndiName"></attribute>

Modified: trunk/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml
===================================================================
--- trunk/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml	2008-08-12 20:51:05 UTC (rev 76996)
+++ trunk/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -72,7 +72,9 @@
   <mbean code="org.jboss.jmx.adaptor.snmp.trapd.TrapdService"
          name="jboss.jmx:name=SnmpAgent,service=trapd,type=logger">
            
-    <attribute name="Port">1162</attribute>
+    <attribute name="Port">
+       <value-factory bean="ServiceBindingManager" method="getIntBinding" parameter="jboss.jmx:name=SnmpAgent,service=trapd,type=logger"/>
+    </attribute>
   </mbean>
   
   <!-- The SNMP adaptor MBean -->
@@ -85,7 +87,11 @@
     <attribute name="NotificationMapResName">/notifications.xml</attribute>
     <attribute name="ManagersResName">/managers.xml</attribute>
     <attribute name="HeartBeatPeriod">0</attribute>
-    <attribute name="Port">1161</attribute>
+    <attribute name="Port">
+       <!-- Get the port from the ServiceBindingManager -->
+       <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+          parameter="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor"/>
+    </attribute>
     <attribute name="DynamicSubscriptions">false</attribute>
     <attribute name="WriteCommunity">private</attribute>
     

Added: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/alt_input.xml
===================================================================
--- trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/alt_input.xml	                        (rev 0)
+++ trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/alt_input.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<element host="${alt.host}">${alt.port}</element>
\ No newline at end of file

Added: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/input.xml
===================================================================
--- trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/input.xml	                        (rev 0)
+++ trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/input.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<element host="${host}">${port}</element>
\ No newline at end of file

Added: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt.xml
===================================================================
--- trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt.xml	                        (rev 0)
+++ trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xslt><![CDATA[
+<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+     <xsl:output method="xml" />
+     
+     <xsl:param name="host"/>
+     <xsl:param name="port"/>
+     <xsl:param name="other"/>
+
+     <xsl:template match="/">
+       <xsl:apply-templates/>       
+     </xsl:template>
+
+     <xsl:template match="attribute[@name='host']">
+        <attribute type="java.lang.String" name="host"><xsl:value-of select='$host'/></attribute>
+     </xsl:template>
+
+     <xsl:template match="attribute[@name='port']">
+         <attribute type="java.lang.String" name="port"><xsl:value-of select='$port'/></attribute>
+     </xsl:template>
+
+     <xsl:template match="attribute[@name='other']">
+         <attribute type="java.lang.String" name="other"><xsl:value-of select='$other'/></attribute>
+     </xsl:template>
+
+     <xsl:template match="*|@*">
+       <xsl:copy>
+         <xsl:apply-templates select="@*|node()"/>
+       </xsl:copy>
+     </xsl:template>
+     
+</xsl:stylesheet>
+   ]]>
+</xslt>
\ No newline at end of file

Added: trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt_input.xml
===================================================================
--- trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt_input.xml	                        (rev 0)
+++ trunk/varia/src/resources/tests/org/jboss/test/services/binding/test/xslt_input.xml	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Connector>
+  <attribute name="host">123</attribute>
+  <attribute name="other">456</attribute>
+  <attribute name="port">789</attribute>
+</Connector>
\ No newline at end of file

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,121 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import org.jboss.services.binding.ServiceBindingManager;
+import org.jboss.services.binding.ServiceBindingManager.BindingType;
+import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+
+/**
+ * Tests of {@link ServiceBindingManager#getServiceBindingValueSource(org.jboss.bindings.ServiceBinding, BindingType)}
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class DefaultServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{
+   /**
+    * Create a new DefaultServiceBindingValueSourceUnitTestCase.
+    * 
+    * @param arg0
+    */
+   public DefaultServiceBindingValueSourceUnitTestCase(String arg0)
+   {
+      super(arg0);
+   }
+   
+   public void testInjectedSource() throws Exception
+   {
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource("test");
+      binding.setServiceBindingValueSource(source);
+      assertEquals(source, ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC));
+   }
+   
+   public void testInjectedSourceClassName() throws Exception
+   {
+      binding.setServiceBindingValueSourceClassName(MockServiceBindingValueSource.class.getName());
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC) instanceof MockServiceBindingValueSource);
+   }
+   
+   public void testInt() throws Exception
+   {
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INT) instanceof SimpleServiceBindingValueSourceImpl);
+   }
+   
+   public void testInetAddress() throws Exception
+   {
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INETADDRESS) instanceof SimpleServiceBindingValueSourceImpl);
+   }
+   
+   public void testString() throws Exception
+   {
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.STRING) instanceof StringReplacementServiceBindingValueSourceImpl);
+   }
+   
+   public void testElement() throws Exception
+   {
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof StringReplacementServiceBindingValueSourceImpl);
+   }
+   
+   public void testResource() throws Exception
+   {
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof StringReplacementServiceBindingValueSourceImpl);
+   }
+   
+   public void testURL() throws Exception
+   {
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof StringReplacementServiceBindingValueSourceImpl);
+   }
+   
+   public void testElementXSLT() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof XSLTServiceBindingValueSourceImpl);
+   }
+   
+   public void testResourceXSLT() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof XSLTServiceBindingValueSourceImpl);
+   }
+   
+   public void testURLXSLT() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+      assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof XSLTServiceBindingValueSourceImpl);
+   }
+   
+   public void testGeneric() throws Exception
+   {
+      try
+      {
+         ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC);
+         fail("unknown generic should fail");
+      }
+      catch(IllegalStateException good) {}
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.jboss.services.binding.DuplicateServiceException;
+import org.jboss.services.binding.NoSuchBindingException;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingStore;
+
+/**
+ * Mock implementation of ServiceBindingStore.  Stores a single ServiceBinding.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class MockServiceBindingStore implements ServiceBindingStore
+{
+   public static final String HOSTNAME = "192.168.1.10";
+   
+   private final String serverName;
+   private ServiceBinding binding;
+   
+   public MockServiceBindingStore(ServiceBinding binding, String serverName)
+   {
+      this.binding = binding;
+      this.serverName = serverName;
+   }
+
+   public void addServiceBinding(String serverName, ServiceBinding binding) throws DuplicateServiceException
+   {
+      throw new UnsupportedOperationException("unimplemented");
+   }
+
+   public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
+         throws NoSuchBindingException
+   {
+      if (this.binding == null 
+            || this.serverName.equals(serverName) == false
+            || this.binding.getServiceName().equals(serviceName) == false
+            || safeEquals(this.binding.getBindingName(), bindingName) == false)
+      {
+         throw new NoSuchBindingException(serverName, serviceName, bindingName);
+      }
+      
+      return binding;
+   }
+
+   public void removeServiceBinding(String serverName, ServiceBinding binding)
+   {
+      throw new UnsupportedOperationException("unimplemented");
+   }
+
+   public void removeServiceBinding(String serverName, String serviceName, String bindingName)
+   {
+      throw new UnsupportedOperationException("unimplemented");
+   }
+
+   public void addServiceBinding(ServiceBinding binding) throws DuplicateServiceException
+   {
+      if (this.binding != null)
+         throw new IllegalStateException("MockServiceBindingStore already has a binding");
+      this.binding = binding;
+   }
+
+   public InetAddress getDefaultBindAddress(String serverName)
+   {      
+      try
+      {
+         return InetAddress.getByName(HOSTNAME);
+      }
+      catch (UnknownHostException e)
+      {
+         throw new IllegalStateException("Can't create InetAddress for " + HOSTNAME, e);
+      }
+   }
+
+   public String getDefaultHostName(String serverName)
+   {      
+      return HOSTNAME;
+   }
+
+   public int getDefaultPortOffset(String serverName)
+   {
+      return 1000;
+   }
+
+   public void removeServiceBinding(ServiceBinding binding)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void removeServiceBinding(String serviceName, String bindingName)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   /**
+    * Set the binding.
+    * 
+    * @param binding The binding to set.
+    */
+   public void setBinding(ServiceBinding binding)
+   {
+      this.binding = binding;
+   }
+   
+   private boolean safeEquals(Object a, Object b)
+   {
+      return (a == b || (a != null && a.equals(b)));
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingValueSource;
+
+/**
+ * Mock implementation of ServiceBindingValueSource. Returms an injected return
+ * value; keeps a reference to passed in params so the test driver can analyze them.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class MockServiceBindingValueSource implements ServiceBindingValueSource
+{
+   private final Object returnValue;
+   private Object[] params;
+   
+   public MockServiceBindingValueSource()
+   {
+      this.returnValue = null;
+   }
+   
+   public MockServiceBindingValueSource(Object returnValue)
+   {
+      this.returnValue = returnValue;
+   }
+
+   public Object getServiceBindingValue(ServiceBinding binding, Object... params) throws Exception
+   {
+      this.params = params;
+      return returnValue;
+   }
+
+   public Object[] getParams()
+   {
+      return params;
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,372 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.DuplicateServiceException;
+import org.jboss.services.binding.NoSuchBindingException;
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.PojoServiceBindingStore;
+import org.jboss.services.binding.impl.ServiceBindingSet;
+
+/**
+ * Tests of PojoServiceBindingStore.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class PojoServiceBindingStoreUnitTestCase extends TestCase
+{
+   private static final String A = "A";
+   private static final String B = "B";
+   private static final String C = "C";
+   private static final String D = "D";
+   
+   private static ServiceBinding AA;
+   private static ServiceBinding AB;
+   private static ServiceBinding Anull;
+   
+   private Map<String, ServiceBindingSet> bindings = new HashMap<String, ServiceBindingSet>();
+   
+   /**
+    * Create a new PojoServiceBindingStoreUnitTestCase.
+    * 
+    * @param name
+    */
+   public PojoServiceBindingStoreUnitTestCase(String name)
+   {
+      super(name);
+   }
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      AA = new ServiceBinding(A, A, "localhost", 1);
+      AB = new ServiceBinding(A, B, "localhost", 1);
+      Anull = new ServiceBinding(A, null, "localhost", 1);
+      
+      Set<ServiceBinding> set = new HashSet<ServiceBinding>();
+      set.addAll(Arrays.asList(AA, AB, Anull));
+      ServiceBindingSet sbs = new ServiceBindingSet(set);
+      bindings.put(A, sbs);
+      bindings.put(B, sbs);
+      bindings.put(C, sbs);
+   }
+   
+   public void testGetServiceBinding() throws Exception
+   {
+      PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+      
+      assertEquals(AA, store.getServiceBinding(A, A, A));      
+      assertEquals(AA, store.getServiceBinding(B, A, A));     
+      assertEquals(AA, store.getServiceBinding(C, A, A));
+      
+      assertEquals(AB, store.getServiceBinding(A, A, B));      
+      assertEquals(AB, store.getServiceBinding(B, A, B));     
+      assertEquals(AB, store.getServiceBinding(C, A, B));
+      
+      assertEquals(Anull, store.getServiceBinding(A, A, null));      
+      assertEquals(Anull, store.getServiceBinding(B, A, null));     
+      assertEquals(Anull, store.getServiceBinding(C, A, null));
+      
+      try
+      {
+         store.getServiceBinding(D, A, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      try
+      {
+         store.getServiceBinding(A, B, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      try
+      {
+         store.getServiceBinding(A, B, null);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+   }
+   
+   public void testAddServiceBinding() throws Exception
+   {
+      PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+      
+      ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
+      store.addServiceBinding(A, new1);
+      store.addServiceBinding(B, new1);
+      store.addServiceBinding(C, new1);
+      
+      assertEquals(new1, store.getServiceBinding(A, B, A));      
+      assertEquals(new1, store.getServiceBinding(B, B, A));      
+      assertEquals(new1, store.getServiceBinding(C, B, A));
+      
+      ServiceBinding new2 = new ServiceBinding(B, A, "localhost", 2);
+      try
+      {
+         store.addServiceBinding(D, new2);      
+         fail("add for unknown binding set succeeded");
+      }
+      catch (IllegalArgumentException good) {}
+      
+      try
+      {
+         store.addServiceBinding(A, new2); 
+         fail("duplicate add succeeded");
+      }
+      catch (DuplicateServiceException good) {}
+   }
+   
+   public void testRemoveServiceBinding() throws Exception
+   {
+      PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+      
+      store.removeServiceBinding(A, AA);
+      
+      try
+      {
+         store.getServiceBinding(A, A, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      store.removeServiceBinding(B, A, A);
+      
+      try
+      {
+         store.getServiceBinding(B, A, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      store.removeServiceBinding(A, Anull);
+      
+      try
+      {
+         store.getServiceBinding(A, A, null);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      store.removeServiceBinding(B, A, null);
+      
+      try
+      {
+         store.getServiceBinding(B, A, null);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
+      store.removeServiceBinding(A, new1);
+      store.removeServiceBinding(A, B, A);
+   }
+   
+   
+   public void testAddServiceBindingToAll() throws Exception
+   {
+      Set<ServiceBinding> set = new HashSet<ServiceBinding>();
+      set.addAll(Arrays.asList(AA, AB, Anull));
+      
+      ServiceBindingSet sbs = new ServiceBindingSet(set, 10, null); 
+      Map<String, ServiceBindingSet> map = new HashMap<String, ServiceBindingSet>();
+      map.put(A, sbs);
+      
+      sbs = new ServiceBindingSet(set, 20, "localhost"); 
+      map.put(B, sbs);
+      
+      sbs = new ServiceBindingSet(set, 30, "192.168.0.10"); 
+      map.put(C, sbs);
+      
+      PojoServiceBindingStore store = new PojoServiceBindingStore(map);
+      
+      ServiceBinding new1 = new ServiceBinding(B, A, "192.168.0.22", 1);
+      store.addServiceBinding(new1);
+      
+      InetAddress address = InetAddress.getByName("192.168.0.22");
+      
+      ServiceBinding got = store.getServiceBinding(A, B, A);
+      assertEquals(new1, got);    
+      assertEquals(11, got.getPort());
+      assertEquals("192.168.0.22", got.getHostName());
+      assertEquals(address, got.getBindAddress());
+      
+      got = store.getServiceBinding(B, B, A);
+      assertEquals(new1, got);    
+      assertEquals(21, got.getPort());
+      assertEquals("192.168.0.22", got.getHostName());
+      assertEquals(address, got.getBindAddress());
+      
+      got = store.getServiceBinding(C, B, A);
+      assertEquals(new1, got);    
+      assertEquals(31, got.getPort());
+      assertEquals("192.168.0.22", got.getHostName());
+      assertEquals(address, got.getBindAddress());
+      
+      ServiceBinding new2 = new ServiceBinding(B, A, "localhost", 2);
+      try
+      {
+         store.addServiceBinding(new2); 
+         fail("duplicate add succeeded");
+      }
+      catch (DuplicateServiceException good) {}
+      
+      ServiceBinding new3 = new ServiceBinding(C, C, null, 3);
+      store.addServiceBinding(new3);
+      
+      got = store.getServiceBinding(A, C, C);
+      assertEquals(new3, got);    
+      assertEquals(13, got.getPort());
+      assertNull(got.getHostName());
+      assertEquals(InetAddress.getByName(null), got.getBindAddress());
+      
+      got = store.getServiceBinding(B, C, C);
+      assertEquals(new3, got);    
+      assertEquals(23, got.getPort());
+      assertEquals("localhost", got.getHostName());
+      assertEquals(InetAddress.getByName("localhost"), got.getBindAddress());
+      
+      got = store.getServiceBinding(C, C, C);
+      assertEquals(new3, got);    
+      assertEquals(33, got.getPort());
+      assertEquals("192.168.0.10", got.getHostName());
+      assertEquals(InetAddress.getByName("192.168.0.10"), got.getBindAddress());
+      
+   }
+   
+   public void testRemoveServiceBindingFromAll() throws Exception
+   {
+      PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+      
+      store.removeServiceBinding(AA);
+      
+      try
+      {
+         store.getServiceBinding(A, A, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      store.removeServiceBinding(B, A, A);
+      
+      try
+      {
+         store.getServiceBinding(B, A, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      try
+      {
+         store.getServiceBinding(C, A, A);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      String nullA = null;
+      store.removeServiceBinding(A, nullA);
+      
+      try
+      {
+         store.getServiceBinding(A, A, null);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      try
+      {
+         store.getServiceBinding(B, A, null);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      try
+      {
+         store.getServiceBinding(C, A, null);
+         fail("invalid");
+      }
+      catch (NoSuchBindingException e) {}
+      
+      ServiceBinding new1 = new ServiceBinding(B, A, "localhost", 1);
+      store.removeServiceBinding(new1);
+      store.removeServiceBinding(B, A);
+   }
+   
+   public void testDefaultDefaults() throws Exception
+   {
+      PojoServiceBindingStore store = new PojoServiceBindingStore(bindings);
+      
+      String[] names = {A, B, C};
+      
+      for (String name :names)
+      {
+         assertNull(store.getDefaultHostName(name));
+         assertNull(store.getDefaultBindAddress(name));
+         assertEquals(0, store.getDefaultPortOffset(name));
+      }
+   }
+   
+   public void testDefaults() throws Exception
+   {
+      Set<ServiceBinding> set = new HashSet<ServiceBinding>();
+      set.addAll(Arrays.asList(AA, AB, Anull));
+      
+      ServiceBindingSet sbs = new ServiceBindingSet(set, 10, null); 
+      Map<String, ServiceBindingSet> map = new HashMap<String, ServiceBindingSet>();
+      map.put(A, sbs);
+      
+      sbs = new ServiceBindingSet(set, 20, "localhost"); 
+      map.put(B, sbs);
+      
+      sbs = new ServiceBindingSet(set, 30, "192.168.0.10"); 
+      map.put(C, sbs);
+      
+      PojoServiceBindingStore store = new PojoServiceBindingStore(map);
+      
+      assertNull(store.getDefaultHostName(A));
+      assertNull(store.getDefaultBindAddress(A));
+      assertEquals(10, store.getDefaultPortOffset(A));
+      
+      assertEquals("localhost", store.getDefaultHostName(B));
+      assertEquals(InetAddress.getByName("localhost"), store.getDefaultBindAddress(B));
+      assertEquals(20, store.getDefaultPortOffset(B));
+      
+      assertEquals("192.168.0.10", store.getDefaultHostName(C));
+      assertEquals(InetAddress.getByName("192.168.0.10"), store.getDefaultBindAddress(C));
+      assertEquals(30, store.getDefaultPortOffset(C));
+   }
+   
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,415 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.File;
+import java.net.InetAddress;
+import java.net.URL;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingManager;
+import org.w3c.dom.Element;
+
+/**
+ * Tests of ServiceBindingManager.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class ServiceBindingManagerUnitTestCase extends ServiceBindingTestBase
+{
+   private static final String SERVER = "server";
+   private static final String INPUT = "${host}";
+   
+   private ServiceBindingManager testee;
+   private ServiceBinding noNameBinding;
+   private MockServiceBindingStore mockStore;
+   private InetAddress address;
+   
+   /**
+    * Create a new ServiceBindingManagerUnitTestCase.
+    * 
+    * @param arg0
+    */
+   public ServiceBindingManagerUnitTestCase(String arg0)
+   {
+      super(arg0);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      mockStore = new MockServiceBindingStore(binding, SERVER);
+      testee = new ServiceBindingManager(SERVER, mockStore);
+      noNameBinding = new ServiceBinding(SVC_NAME, null, HOST, PORT);
+      address = InetAddress.getByName(HOST);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String)}.
+    * @throws Exception 
+    */
+   public void testGetIntBindingString() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      assertEquals(PORT, testee.getIntBinding(SVC_NAME));
+   }
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String, java.lang.String)}.
+    */
+   public void testGetIntBindingStringString() throws Exception
+   {
+      assertEquals(PORT, testee.getIntBinding(SVC_NAME, BINDING_NAME));
+   }
+   
+   public void testGetIntBindingViaGeneric() throws Exception
+   {
+      Integer result = new Integer(5);
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(5, testee.getIntBinding(SVC_NAME, BINDING_NAME));
+      Object[] params = source.getParams();
+      assertNull(params);
+   }
+   
+   public void testGetIntBindingNoBinding() throws Exception
+   {
+      mockStore.setBinding(null);
+      assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
+      mockStore.setBinding(null);
+      assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
+   }
+
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String)}.
+    */
+   public void testGetInetAddressBindingString() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      assertEquals(address, testee.getInetAddressBinding(SVC_NAME));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String, java.lang.String)}.
+    */
+   public void testGetInetAddressBindingStringString() throws Exception
+   {
+      assertEquals(address, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
+   }
+   
+   public void testGetInetAddressBindingViaGeneric() throws Exception
+   {
+      InetAddress result = InetAddress.getByName("localhost");
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(result, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
+      Object[] params = source.getParams();
+      assertNull(params);
+   }
+   
+   public void testGetInetAddressBindingNoBinding() throws Exception
+   {
+      mockStore.setBinding(null);
+      assertEquals(binding.getBindAddress(), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
+      mockStore.setBinding(null);
+      assertEquals(InetAddress.getByName(null), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String)}.
+    */
+   public void testGetStringBindingStringString() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      assertEquals(HOST, testee.getStringBinding(SVC_NAME, INPUT));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String, java.lang.String)}.
+    */
+   public void testGetStringBindingStringStringString() throws Exception
+   {
+      assertEquals(HOST, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
+   }
+   
+   public void testGetStringBindingViaGeneric() throws Exception
+   {
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(SVC_NAME, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
+      Object[] params = source.getParams();
+      assertNotNull(params);
+      assertEquals(1, params.length);
+      assertEquals(INPUT, params[0]);
+   }
+   
+   public void testGetStringBindingNoBinding() throws Exception
+   {
+      mockStore.setBinding(null);
+      assertEquals(binding.getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, binding.getHostName(), binding.getPort()));
+      mockStore.setBinding(null);
+      assertEquals(InetAddress.getByName(null).getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, null, binding.getPort()));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, org.w3c.dom.Element)}.
+    */
+   public void testGetElementBindingStringElement() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      editor.setAsText(ELEMENT_INPUT);
+      Element input = (Element) editor.getValue();
+      Element output = testee.getElementBinding(SVC_NAME, input);
+      validateOutputElement(output);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, java.lang.String, org.w3c.dom.Element)}.
+    */
+   public void testGetElementBindingStringStringElement() throws Exception
+   {
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      editor.setAsText(ELEMENT_INPUT);
+      Element input = (Element) editor.getValue();
+      Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
+      validateOutputElement(output);
+   }
+   
+   public void testGetElementBindingViaGeneric() throws Exception
+   {
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      editor.setAsText(ELEMENT_INPUT);
+      Element result = (Element) editor.getValue();
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(result, testee.getElementBinding(SVC_NAME, BINDING_NAME, result));
+      Object[] params = source.getParams();
+      assertNotNull(params);
+      assertEquals(1, params.length);
+      assertEquals(result, params[0]);      
+   }
+   
+   public void testGetElementBindingViaXSLT() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(getXSLTConfig());
+      
+      Element input = getDocumentElementFromClasspath(XSL_INPUT);
+      Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
+      validateXSLTOutputElement(output);
+   }
+   
+   public void testGetElementBindingNoBinding() throws Exception
+   {
+      mockStore.setBinding(null);
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      editor.setAsText(ELEMENT_INPUT);
+      Element input = (Element) editor.getValue();
+      Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
+      validateOutputElement(output);
+      mockStore.setBinding(null);
+      output =  testee.getElementBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
+
+      assertNotNull(output);
+      assertEquals("localhost", output.getAttribute("host"));
+      assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.net.URL)}.
+    */
+   public void testGetURLBindingStringURL() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      String resource = getFullyQualifiedResourceName("input.xml");
+      URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+      URL output = testee.getURLBinding(SVC_NAME, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);      
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.lang.String, java.net.URL)}.
+    */
+   public void testGetURLBindingStringStringURL() throws Exception
+   {
+      String resource = getFullyQualifiedResourceName("input.xml");
+      URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+      URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);     
+   }
+   
+   public void testGetURLBindingViaGeneric() throws Exception
+   {
+      URL result = new File(getFullyQualifiedResourceName("input.xml")).toURL();
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(result, testee.getURLBinding(SVC_NAME, BINDING_NAME, result));
+      Object[] params = source.getParams();
+      assertNotNull(params);
+      assertEquals(1, params.length);
+      assertEquals(result, params[0]);
+   }
+   
+   public void testGetURLBindingViaXSLT() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(getXSLTConfig());
+      
+      URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
+      URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateXSLTOutputElement(element); 
+   }
+   
+   public void testGetURLBindingNoBinding() throws Exception
+   {
+      mockStore.setBinding(null);
+      String resource = getFullyQualifiedResourceName("input.xml");
+      URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+      URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);     
+      
+      mockStore.setBinding(null);
+      output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
+
+      assertNotNull(output);
+      element = getDocumentElement(output);
+      assertEquals("localhost", element.getAttribute("host"));
+      assertEquals(String.valueOf(PORT), element.getFirstChild().getNodeValue());
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String)}.
+    */
+   public void testGetResourceBindingStringString() throws Exception
+   {
+      String input = getFullyQualifiedResourceName("input.xml");
+      String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);      
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String, java.lang.String)}.
+    */
+   public void testGetResourceBindingStringStringString() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      String input = getFullyQualifiedResourceName("input.xml");
+      String output = testee.getResourceBinding(SVC_NAME, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element); 
+   }
+   
+   public void testGetResourceBindingViaGeneric() throws Exception
+   {
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(SVC_NAME, testee.getResourceBinding(SVC_NAME, BINDING_NAME, INPUT));
+      Object[] params = source.getParams();
+      assertNotNull(params);
+      assertEquals(1, params.length);
+      assertEquals(INPUT, params[0]);
+   }
+   
+   public void testGetResourceBindingViaXSLT() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(getXSLTConfig());
+      
+      String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, XSL_INPUT);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateXSLTOutputElement(element);
+   }
+   
+   public void testGetResourceBindingNoBinding() throws Exception
+   {
+      mockStore.setBinding(null);
+      String input = getFullyQualifiedResourceName("input.xml");
+      String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);     
+      
+      mockStore.setBinding(null);
+      output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
+
+      assertNotNull(output);
+      element = getDocumentElement(output);
+      assertEquals("localhost", element.getAttribute("host"));
+      assertEquals(String.valueOf(PORT), element.getFirstChild().getNodeValue());
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.Object[])}.
+    */
+   public void testGetGenericBindingStringObjectArray() throws Exception
+   {
+      mockStore.setBinding(noNameBinding);
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+      noNameBinding.setServiceBindingValueSource(source);
+      assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, null, INPUT));
+      Object[] params = source.getParams();
+      assertNotNull(params);
+      assertEquals(1, params.length);
+      assertEquals(INPUT, params[0]);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.String, java.lang.Object[])}.
+    */
+   public void testGetGenericBindingStringStringObjectArray() throws Exception
+   {
+      MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
+      binding.setServiceBindingValueSource(source);
+      assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, BINDING_NAME, INPUT));
+      Object[] params = source.getParams();
+      assertNotNull(params);
+      assertEquals(1, params.length);
+      assertEquals(INPUT, params[0]);
+   }
+   
+   public void testGetGenericBindingNoValueSource() throws Exception
+   {
+      try
+      {
+         Object[] params = null;
+         testee.getGenericBinding(SVC_NAME, BINDING_NAME, params);
+         fail("should not succeed without value source");         
+      }
+      catch (IllegalStateException good) {}
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.ServiceBindingSet;
+
+/**
+ * A ServiceBindingSetUnitTestCase.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class ServiceBindingSetUnitTestCase extends TestCase
+{
+   private static final String A = "A";
+   private static final String B = "B";
+   
+   private static ServiceBinding AA;
+   private static ServiceBinding AB;
+   private static ServiceBinding Anull;
+
+   private Set<ServiceBinding> bindings = new HashSet<ServiceBinding>();
+   
+   /**
+    * Create a new ServiceBindingSetUnitTestCase.
+    * 
+    * @param name
+    */
+   public ServiceBindingSetUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      AA = new ServiceBinding(A, A, "localhost", 1);
+      AB = new ServiceBinding(A, B, "localhost", 1);
+      Anull = new ServiceBinding(A, null, "localhost", 1);
+      
+      bindings.addAll(Arrays.asList(AA, AB, Anull));
+   }
+   
+   public void testBasicConstructor() throws UnknownHostException
+   {
+      ServiceBindingSet set = new ServiceBindingSet(bindings);
+      for (ServiceBinding binding : set)
+      {
+         assertEquals(1, binding.getPort());
+         assertTrue(bindings.remove(binding));
+      }
+      
+      assertEquals(0, bindings.size());
+      
+      assertNull(set.getDefaultHostName());
+      assertNull(set.getDefaultBindAddress());
+      assertEquals(0, set.getPortOffset());
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int)}.
+    * @throws UnknownHostException 
+    */
+   public void testOffsetConstructor() throws UnknownHostException
+   {
+      ServiceBindingSet set = new ServiceBindingSet(bindings, 5);
+      for (ServiceBinding binding : set)
+      {
+         assertEquals(6, binding.getPort());
+         assertTrue(bindings.remove(binding));
+      }
+      
+      assertEquals(0, bindings.size());
+      
+      assertNull(set.getDefaultHostName());
+      assertNull(set.getDefaultBindAddress());
+      assertEquals(5, set.getPortOffset());
+   }
+   
+   public void testOffsetConstructorWithDefaultHost() throws UnknownHostException
+   {
+      ServiceBindingSet set = new ServiceBindingSet(bindings, 5, "192.168.0.10");
+      for (ServiceBinding binding : set)
+      {
+         assertEquals(6, binding.getPort());
+         assertTrue(bindings.remove(binding));
+      }
+      
+      assertEquals(0, bindings.size());
+      
+      assertEquals("192.168.0.10", set.getDefaultHostName());
+      assertEquals(InetAddress.getByName("192.168.0.10"), set.getDefaultBindAddress());
+      assertEquals(5, set.getPortOffset());
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int, java.util.Set)}.
+    * @throws UnknownHostException 
+    */
+   public void testOverrideConstructor() throws UnknownHostException
+   {
+      ServiceBinding bb = new ServiceBinding(B, B, "localhost", 1);
+      Set<ServiceBinding> overrides = new HashSet<ServiceBinding>();
+      overrides.add(bb);
+      overrides.add(AA);
+      
+      ServiceBindingSet set = new ServiceBindingSet(bindings, 10, overrides, "192.168.0.10");
+      for (ServiceBinding binding : set)
+      {         
+         boolean override = overrides.remove(binding);
+         assertEquals(override ? 1 : 11, binding.getPort());
+         assertTrue(bindings.remove(binding) || override);
+         
+      }
+      
+      assertEquals(0, overrides.size());
+      assertEquals(0, bindings.size());
+      
+      assertEquals("192.168.0.10", set.getDefaultHostName());
+      assertEquals(InetAddress.getByName("192.168.0.10"), set.getDefaultBindAddress());
+      assertEquals(10, set.getPortOffset());
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,184 @@
+package org.jboss.test.services.binding.test;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.system.server.ServerConfig;
+import org.jboss.util.propertyeditor.ElementEditor;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Base class for service binding manager related test classes.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public abstract class ServiceBindingTestBase extends TestCase
+{
+   protected static final String SVC_NAME = "SVC";
+   protected static final String BINDING_NAME = "BIND"; 
+   protected static final String HOST = "192.168.0.10";
+   protected static final int PORT = 999;
+   protected static final String HOST_MARKER = "${host}";
+   protected static final String PORT_MARKER = "${port}";   
+   protected static final String ELEMENT_INPUT = "<element host=\"" + HOST_MARKER + "\">" + PORT_MARKER + "</element>";
+
+   protected static final String OTHER_PARAM = "other";
+   protected static final String OTHER_VALUE = "ABC";
+   protected static final String XSL_INPUT = getFullyQualifiedResourceName("xslt_input.xml");
+   
+   protected ServiceBinding binding;
+   
+   private PropertyEditor existingElementEditor;
+   private String serverTempDir;
+
+   public ServiceBindingTestBase()
+   {
+      super();
+   }
+
+   public ServiceBindingTestBase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      existingElementEditor = PropertyEditorManager.findEditor(Element.class);
+      if (existingElementEditor == null)
+         PropertyEditorManager.registerEditor(Element.class, ElementEditor.class);
+      
+      serverTempDir = System.getProperty(ServerConfig.SERVER_TEMP_DIR);
+      if (serverTempDir == null)
+         System.setProperty(ServerConfig.SERVER_TEMP_DIR, System.getProperty("java.io.tmpdir"));
+      
+      binding = new ServiceBinding(SVC_NAME, BINDING_NAME, HOST, PORT);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {      
+      if (existingElementEditor == null)
+         PropertyEditorManager.registerEditor(Element.class, null);
+      if (serverTempDir == null)
+         System.clearProperty(ServerConfig.SERVER_TEMP_DIR);
+      
+      super.tearDown();
+   }
+   
+   public static String getFullyQualifiedResourceName(String unqualified)
+   {
+      String base = ServiceBindingTestBase.class.getPackage().getName();
+      base = base.replace('.', '/');
+      return base + "/" + unqualified;
+   }
+
+   protected void validateOutputElement(Element output)
+   {
+      assertNotNull(output);
+      assertEquals(HOST, output.getAttribute("host"));
+      assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
+   }
+
+   protected void validateXSLTOutputElement(Element output)
+   {
+      assertNotNull(output);
+      NodeList children = output.getElementsByTagName("attribute");
+      assertEquals(3, children.getLength());
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         Element e = (Element) children.item(i);
+         String name = e.getAttribute("name");         
+         if ("host".equals(name))
+            assertEquals(HOST, e.getFirstChild().getNodeValue());
+         else if ("port".equals(name))
+            assertEquals(String.valueOf(PORT), e.getFirstChild().getNodeValue());
+         else if ("other".equals(name))
+            assertEquals(OTHER_VALUE, e.getFirstChild().getNodeValue());
+         else
+            fail("Unknown attribute name " + name);
+      }
+   }
+   
+   public static Element getDocumentElement(String filename) throws Exception
+   {
+      File f = new File(filename);
+      Assert.assertTrue(f.exists());
+      Assert.assertFalse(f.isDirectory());
+      InputStreamReader reader = new InputStreamReader(new FileInputStream(f));
+      return getDocumentElement(reader);
+   }
+   
+   public static Element getDocumentElementFromClasspath(String resourcename) throws Exception
+   {      
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      InputStreamReader reader = new InputStreamReader(cl.getResourceAsStream(resourcename));
+      return getDocumentElement(reader);
+   }
+   
+   public static Element getDocumentElement(URL url) throws Exception
+   {
+      URLConnection conn = url.openConnection();
+      conn.connect();
+      InputStreamReader reader = new InputStreamReader(url.openStream());
+      return getDocumentElement(reader);
+   }
+   
+   public static Element getDocumentElement(Reader reader) throws Exception
+   {
+      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+      DocumentBuilder parser = factory.newDocumentBuilder();
+      try
+      {
+         
+         InputSource is = new InputSource(reader);
+//         is.setSystemId(url.toString());
+         parser.setEntityResolver(new JBossEntityResolver());
+   
+         Document document = parser.parse(is);
+         return document.getDocumentElement();
+      }
+      finally
+      {
+         reader.close();
+      }
+      
+   }
+   
+   public static XSLTServiceBindingValueSourceConfig getXSLTConfig() throws Exception
+   {
+      Element element = getDocumentElementFromClasspath(getFullyQualifiedResourceName("xslt.xml"));
+      String xslt = element.getFirstChild().getNodeValue();
+      
+      Map<String, String> addlParams = new HashMap<String, String>();
+      addlParams.put(OTHER_PARAM, OTHER_VALUE);
+      
+      return new XSLTServiceBindingValueSourceConfig(xslt, addlParams);
+   }
+   
+   
+
+}
\ No newline at end of file


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests of ServiceBinding.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class ServiceBindingUnitTestCase extends TestCase
+{
+
+   /**
+    * Create a new ServiceBindingUnitTestCase.
+    * 
+    * @param name
+    */
+   public ServiceBindingUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testNullServiceName() throws Exception
+   {
+      try
+      {
+         new ServiceBinding(null, 1);
+         fail("null serviceName should fail");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBinding#getServiceBindingValueSource()}.
+    */
+   public void testServiceBindingValueSourceClassName() throws Exception
+   {
+      ServiceBinding binding = new ServiceBinding("test", 1);
+      String className = XSLTServiceBindingValueSourceImpl.class.getName();
+      binding.setServiceBindingValueSourceClassName(className);
+      assertEquals(className, binding.getServiceBindingValueSourceClassName());
+      assertTrue(binding.getServiceBindingValueSource() instanceof XSLTServiceBindingValueSourceImpl);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBinding#getOffsetBinding(int)}.
+    */
+   public void testGetOffsetBinding() throws Exception
+   {
+      ServiceBinding binding = new ServiceBinding("svc", "binding", "192.168.0.2", 1);
+      String className = XSLTServiceBindingValueSourceImpl.class.getName();
+      binding.setServiceBindingValueSourceClassName(className);
+      
+      ServiceBinding binding2 = binding.getOffsetBinding(10);
+      assertEquals(binding.getServiceName(), binding2.getServiceName());
+      assertEquals(binding.getBindingName(), binding2.getBindingName());
+      assertEquals(binding.getHostName(), binding2.getHostName());
+      assertEquals(binding.getBindAddress(), binding2.getBindAddress());
+      
+      assertEquals(1, binding.getPort());
+      assertEquals(11, binding2.getPort());
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBinding#equals(java.lang.Object)}.
+    */
+   public void testEquals() throws Exception
+   {
+      ServiceBinding bindingAA0 = new ServiceBinding("A", "A", "192.168.0.2", 1);
+      ServiceBinding bindingAA1 = new ServiceBinding("A", "A", "192.168.0.2", 2);
+      ServiceBinding bindingAA2 = new ServiceBinding("A", "A", "192.168.0.1", 1);
+      ServiceBinding bindingAB = new ServiceBinding("A", "B", "192.168.0.2", 1);
+      ServiceBinding bindingBA = new ServiceBinding("B", "A", "192.168.0.2", 1);
+      ServiceBinding bindingAnull = new ServiceBinding("A", null, "192.168.0.2", 1);
+      ServiceBinding bindingBnull = new ServiceBinding("B", null, "192.168.0.2", 1);
+      ServiceBinding bindingBnull1 = new ServiceBinding("B", null, "192.168.0.2", 2);
+      
+      assertEquals(bindingAA0, bindingAA1);
+      assertEquals(bindingAA0, bindingAA2);
+      assertFalse(bindingAA0.equals(bindingAB));
+      assertFalse(bindingAA0.equals(bindingBA));
+      assertFalse(bindingAB.equals(bindingBA));
+      assertFalse(bindingAA0.equals(bindingAnull));
+      assertFalse(bindingBA.equals(bindingBnull));
+      assertFalse(bindingAnull.equals(bindingBnull));
+      assertEquals(bindingBnull, bindingBnull1);
+      
+      assertFalse(bindingAA0.equals(new Object()));
+      
+      assertFalse(bindingAA0.equals(null));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.ServiceBinding#hashCode()}.
+    */
+   public void testHashCode() throws Exception
+   {
+      ServiceBinding bindingAA0 = new ServiceBinding("A", "A", "192.168.0.2", 1);
+      ServiceBinding bindingAA1 = new ServiceBinding("A", "A", "192.168.0.2", 2);
+      ServiceBinding bindingAA2 = new ServiceBinding("A", "A", "192.168.0.1", 1);
+      ServiceBinding bindingAB = new ServiceBinding("A", "B", "192.168.0.2", 1);
+      ServiceBinding bindingBA = new ServiceBinding("B", "A", "192.168.0.2", 1);
+      ServiceBinding bindingAnull = new ServiceBinding("A", null, "192.168.0.2", 1);
+      ServiceBinding bindingBnull = new ServiceBinding("B", null, "192.168.0.2", 1);
+      ServiceBinding bindingBnull1 = new ServiceBinding("B", null, "192.168.0.2", 2);
+      
+      assertEquals(bindingAA0.hashCode(), bindingAA1.hashCode());
+      assertEquals(bindingAA0.hashCode(), bindingAA2.hashCode());
+      assertFalse(bindingAA0.hashCode() == bindingAB.hashCode());
+      assertFalse(bindingAA0.hashCode() == bindingBA.hashCode());
+      
+      // A quirk of the values means these have same hashcode 
+      assertEquals(bindingAB.hashCode(), bindingBA.hashCode());
+      
+      assertFalse(bindingAA0.hashCode() == bindingAnull.hashCode());
+      assertFalse(bindingBA.hashCode() == bindingBnull.hashCode());
+      assertFalse(bindingAnull.hashCode() == bindingBnull.hashCode());
+      assertEquals(bindingBnull.hashCode(), bindingBnull1.hashCode());
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,99 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.InetAddress;
+
+import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
+
+/**
+ * Unit tests of {@link SimpleServiceBindingValueSourceImpl}.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class SimpleServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{ 
+   private SimpleServiceBindingValueSourceImpl testee;
+   private InetAddress address;
+
+   /**
+    * Create a new SimpleServiceBindingValueSourceUnitTestCase.
+    * 
+    * @param name   name of the test
+    */
+   public SimpleServiceBindingValueSourceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      testee = new SimpleServiceBindingValueSourceImpl();
+      address = InetAddress.getByName(HOST);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getIntServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
+    */
+   public void testGetIntServiceBindingValue()
+   {
+      assertEquals(PORT, testee.getIntServiceBindingValue(binding));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getInetAddressServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
+    */
+   public void testGetInetAddressServiceBindingValue()
+   {
+      assertEquals(address, testee.getInetAddressServiceBindingValue(binding));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.Object[])}.
+    * @throws Exception 
+    */
+   public void testGetServiceBindingValue() throws Exception
+   {
+      Object[] params = null;
+      assertEquals("Correct generic value", new Integer(PORT), testee.getServiceBindingValue(binding, params));
+   }
+   
+   public void testGetServiceBindingValueBadParam() throws Exception
+   {
+      try
+      {
+         testee.getServiceBindingValue(binding, new Object());
+         fail("Should fail passing a param");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testUnknownConfigObject() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(new Object());
+      assertEquals(PORT, testee.getIntServiceBindingValue(binding));
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,241 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.net.URL;
+
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Tests of {@link StringReplacementServiceBindingValueSourceImpl}.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class StringReplacementServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{
+   private static final String INPUT = HOST_MARKER + ":" + PORT_MARKER;
+   private static final String ALT_HOST_MARKER = "${alt.host}";
+   private static final String ALT_PORT_MARKER = "${alt.port}";
+   private static final String ALT_INPUT = ALT_HOST_MARKER + ":" + ALT_PORT_MARKER;
+   private static final String OUTPUT = HOST + ":" + PORT;
+   private static final String ALT_ELEMENT_INPUT = "<element host=\"" + ALT_HOST_MARKER + "\">" + ALT_PORT_MARKER + "</element>";
+   
+   private StringReplacementServiceBindingValueSourceImpl testee;
+   private StringReplacementServiceBindingValueSourceConfig config;
+   
+   public StringReplacementServiceBindingValueSourceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      testee = new StringReplacementServiceBindingValueSourceImpl();
+      config = new StringReplacementServiceBindingValueSourceConfig(ALT_HOST_MARKER, ALT_PORT_MARKER);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+    */
+   public void testGetStringServiceBindingValue() throws Exception
+   {
+      assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, INPUT));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+    */
+   public void testGetStringServiceBindingValueNullInput() throws Exception
+   {
+      assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+    */
+   public void testGetStringServiceBindingValueOverrideMarkers() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(config);
+      assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, ALT_INPUT));
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
+    */
+   public void testGetElementServiceBindingValue() throws Exception
+   {
+      elementBindingTest(ELEMENT_INPUT);
+   }
+   
+   public void testGetElementServiceBindingValueNullInput() throws Exception
+   {
+      try
+      {
+         testee.getResourceServiceBindingValue(binding, null);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testGetElementServiceBindingValueOverrideMarkers() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(config);
+      elementBindingTest(ALT_ELEMENT_INPUT);
+   }
+   
+   private void elementBindingTest(String inputText) throws Exception
+   {
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      editor.setAsText(inputText);
+      Element input = (Element) editor.getValue();
+      Element output = testee.getElementServiceBindingValue(binding, input);
+      validateOutputElement(output);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+    */
+   public void testGetResourceServiceBindingValue() throws Exception
+   {
+      resourceBindingTest("input.xml");
+   }
+   
+   public void testGetResourceServiceBindingValueNullInput() throws Exception
+   {
+      try
+      {
+         testee.getResourceServiceBindingValue(binding, null);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testGetResourceServiceBindingValueOverrideMarkers() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(config);
+      resourceBindingTest("alt_input.xml");
+   }
+   
+   private void resourceBindingTest(String inputText) throws Exception
+   {
+      String input = getFullyQualifiedResourceName(inputText);
+      String output = testee.getResourceServiceBindingValue(binding, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);      
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
+    */
+   public void testGetURLServiceBindingValue() throws Exception
+   {
+      urlBindingTest("input.xml");
+   }
+   
+   public void testGetURLServiceBindingValueNullInput() throws Exception
+   {
+      try
+      {
+         testee.getURLServiceBindingValue(binding, null);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testGetURLServiceBindingValueOverrideMarkers() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(config);
+      urlBindingTest("alt_input.xml");
+   }
+   
+   private void urlBindingTest(String inputText) throws Exception
+   {
+      String resource = getFullyQualifiedResourceName(inputText);
+      URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+      URL output = testee.getURLServiceBindingValue(binding, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);      
+   }
+
+   public void testGetServiceBindingValueNullInput() throws Exception
+   {
+      Object[] params = null;
+      assertEquals(HOST, testee.getServiceBindingValue(binding, params));
+   }
+   
+   public void testGetServiceBindingValueBadInput() throws Exception
+   {
+      try
+      {
+         testee.getServiceBindingValue(binding, new Object());
+         fail("Should fail passing an unknown input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testGetServiceBindingValueStringInput() throws Exception
+   {
+      assertEquals(OUTPUT, testee.getServiceBindingValue(binding, INPUT));
+   }
+   
+   public void testGetServiceBindingValueElementInput() throws Exception
+   {
+      PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+      editor.setAsText(ELEMENT_INPUT);
+      Element input = (Element) editor.getValue();
+      Element output = (Element) testee.getServiceBindingValue(binding, input);
+      validateOutputElement(output);
+   }
+   
+   public void testGetServiceBindingValueURLInput() throws Exception
+   {
+      String resource = getFullyQualifiedResourceName("input.xml");
+      URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
+      URL output = (URL) testee.getServiceBindingValue(binding, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateOutputElement(element);      
+   }
+   
+   public void testGetServiceBindingValueOverrideMarkers() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(config);
+      assertEquals(OUTPUT, testee.getServiceBindingValue(binding, ALT_INPUT));
+   }
+   
+   public void testUnknownConfigObject() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(new Object());
+      assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,70 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+
+/**
+ * Tests of {@link XSLTServiceBindingValueSourceConfig}.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class XSLTServiceBindingValueSourceConfigUnitTestCase extends TestCase
+{
+
+   /**
+    * Create a new XSLTServiceBindingValueSourceConfigUnitTestCase.
+    * 
+    * @param arg0
+    */
+   public XSLTServiceBindingValueSourceConfigUnitTestCase(String arg0)
+   {
+      super(arg0);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig#getAdditionalAttributes()}.
+    */
+   public void testGetAdditionalAttributes()
+   {
+      XSLTServiceBindingValueSourceConfig config = new XSLTServiceBindingValueSourceConfig("test");
+      Map<String, String> addl = config.getAdditionalAttributes();
+      assertNotNull(addl);
+      assertEquals(0, addl.size());
+      
+      addl = new HashMap<String, String>();
+      addl.put("a", "a");
+      
+      config = new XSLTServiceBindingValueSourceConfig("test", addl);
+      Map<String, String> addl1 = config.getAdditionalAttributes();
+      assertEquals(addl, addl1);
+      
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java	                        (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java	2008-08-12 22:29:19 UTC (rev 76997)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.services.binding.test;
+
+import java.net.URL;
+
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Tests of {@link XSLTServiceBindingValueSourceImpl}.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class XSLTServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
+{  
+   private XSLTServiceBindingValueSourceImpl testee;
+   private XSLTServiceBindingValueSourceConfig xsltConfig;
+   
+   /**
+    * Create a new XSLTServiceBindingValueSourceUnitTestCase.
+    * 
+    * @param name
+    */
+   public XSLTServiceBindingValueSourceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      testee = new XSLTServiceBindingValueSourceImpl();      
+      xsltConfig = getXSLTConfig();
+      binding.setServiceBindingValueSourceConfig(xsltConfig);
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
+    */
+   public void testGetElementServiceBindingValue() throws Exception
+   {
+      Element input = getDocumentElementFromClasspath(XSL_INPUT);
+      Element output = testee.getElementServiceBindingValue(binding, input);
+      validateXSLTOutputElement(output);
+   }
+   
+   public void testGetElementServiceBindingValueNullInput() throws Exception
+   {
+      try
+      {
+         testee.getResourceServiceBindingValue(binding, null);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
+    */
+   public void testGetResourceServiceBindingValue() throws Exception
+   {
+      String output = testee.getResourceServiceBindingValue(binding, XSL_INPUT);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateXSLTOutputElement(element);
+   }
+   
+   public void testGetResourceServiceBindingValueNullInput() throws Exception
+   {
+      try
+      {
+         testee.getResourceServiceBindingValue(binding, null);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+
+   /**
+    * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
+    */
+   public void testGetURLServiceBindingValue() throws Exception
+   {
+      URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
+      URL output = testee.getURLServiceBindingValue(binding, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateXSLTOutputElement(element); 
+   }
+   
+   public void testGetURLServiceBindingValueNullInput() throws Exception
+   {
+      try
+      {
+         testee.getURLServiceBindingValue(binding, null);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+
+   public void testGetServiceBindingValueNullInput() throws Exception
+   {
+      Object[] params = null;
+      try
+      {
+         testee.getServiceBindingValue(binding, params);
+         fail("Should fail passing a null input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testGetServiceBindingValueBadInput() throws Exception
+   {
+      try
+      {
+         testee.getServiceBindingValue(binding, new Object());
+         fail("Should fail passing an unknown input");
+      }
+      catch (IllegalArgumentException good) {}
+   }
+   
+   public void testGetServiceBindingValueStringInput() throws Exception
+   {
+      String output = (String) testee.getServiceBindingValue(binding, XSL_INPUT);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateXSLTOutputElement(element);
+   }
+   
+   public void testGetServiceBindingValueElementInput() throws Exception
+   {
+      Element input = getDocumentElementFromClasspath(XSL_INPUT);
+      Element output = (Element) testee.getServiceBindingValue(binding, input);
+      validateXSLTOutputElement(output);
+   }
+   
+   public void testGetServiceBindingValueURLInput() throws Exception
+   {
+      URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
+      URL output = (URL) testee.getServiceBindingValue(binding, input);
+      assertNotNull(output);
+      Element element = getDocumentElement(output);
+      validateXSLTOutputElement(element);      
+   }
+   
+   public void testNullConfigObject() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(null);
+      String input = getFullyQualifiedResourceName("xlst_input.xml");
+      try
+      {
+         testee.getResourceServiceBindingValue(binding, input);
+         fail("Should fail using an unknown xsltConfig");
+      }
+      catch (IllegalStateException good) {}
+   }
+   
+   public void testUnknownConfigObject() throws Exception
+   {
+      binding.setServiceBindingValueSourceConfig(new Object());
+      String input = getFullyQualifiedResourceName("xlst_input.xml");
+      try
+      {
+         testee.getResourceServiceBindingValue(binding, input);
+         fail("Should fail using an unknown xsltConfig");
+      }
+      catch (IllegalStateException good) {}
+   }
+
+}


Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list