[jboss-cvs] JBossAS SVN: r77034 - in trunk: testsuite/src/resources/test-configs/binding-manager1/deploy/messaging and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 13 16:52:31 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-08-13 16:52:31 -0400 (Wed, 13 Aug 2008)
New Revision: 77034

Added:
   trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java
   trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java
Modified:
   trunk/server/src/etc/conf/default/bindings.xml
   trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/remoting-bisocket-service.xml
   trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/remoting-bisocket-service.xml
Log:
[JBAS-5192] Support conversion of SBM values into system properties

Modified: trunk/server/src/etc/conf/default/bindings.xml
===================================================================
--- trunk/server/src/etc/conf/default/bindings.xml	2008-08-13 20:03:16 UTC (rev 77033)
+++ trunk/server/src/etc/conf/default/bindings.xml	2008-08-13 20:52:31 UTC (rev 77034)
@@ -326,6 +326,29 @@
          <parameter>${jboss.bind.address}</parameter>
       </constructor>
    </bean>
+   
+   
+   <!-- Conversion of selected bindings into system properties -->
+   <bean name="SystemPropertyBinder" class="org.jboss.services.binding.SystemPropertyBinder">
+   
+      <constructor>
+         <parameter>
+            <set>
+               <!-- JBM's remoting connector -->
+               <bean class="org.jboss.services.binding.SystemPropertyBinding">
+                  <constructor>
+                     <parameter>jboss.messaging.connector.bisocket.port</parameter>
+                     <parameter class="int">
+                        <value-factory bean="ServiceBindingManager" method="getIntBinding"
+                                       parameter="jboss.messaging:service=Connector,transport=bisocket"/>
+                     </parameter>
+                  </constructor>
+               </bean>
+            </set>
+         </parameter>
+      </constructor>
+   
+   </bean>
 
    <!-- XSL Transform to apply to server.xml -->
    <bean name="JBossWebConnectorXSLTConfig" 

Modified: 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	2008-08-13 20:03:16 UTC (rev 77033)
+++ trunk/testsuite/src/resources/test-configs/binding-manager1/deploy/messaging/remoting-bisocket-service.xml	2008-08-13 20:52:31 UTC (rev 77034)
@@ -15,9 +15,6 @@
           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">
             
@@ -27,8 +24,8 @@
                <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="serverBindAddress">${jboss.bind.address}</attribute>
+               <attribute name="serverBindPort">${jboss.messaging.connector.bisocket.port:4457}</attribute>
                <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
                <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
            
@@ -66,9 +63,6 @@
                <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
             </handlers>
          </config>
-         ]]>
-            </parameter>
-         </value-factory>
       </attribute>
    </mbean>
 

Modified: 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	2008-08-13 20:03:16 UTC (rev 77033)
+++ trunk/testsuite/src/resources/test-configs/binding-manager2/deploy/messaging/remoting-bisocket-service.xml	2008-08-13 20:52:31 UTC (rev 77034)
@@ -15,9 +15,6 @@
           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">
             
@@ -27,8 +24,8 @@
                <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="serverBindAddress">${jboss.bind.address}</attribute>
+               <attribute name="serverBindPort">${jboss.messaging.connector.bisocket.port:4457}</attribute>
                <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute>
                <attribute name="serverSocketClass">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute>
            
@@ -66,9 +63,6 @@
                <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>
             </handlers>
          </config>
-         ]]>
-            </parameter>
-         </value-factory>
       </attribute>
    </mbean>
 

Added: trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinder.java	2008-08-13 20:52:31 UTC (rev 77034)
@@ -0,0 +1,102 @@
+/*
+ * 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.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Set;
+
+/**
+ * Defines system properties for a given set of {@link SystemPropertyBinding}s
+ * in its {@link #start()} phase, and clears them in its {@link #stop()} phase.
+ * <p>
+ * Intent is this service would be used as a utility to convert 
+ * {@link ServiceBindingManager} values into system properties so other
+ * services could consume them without being aware of 
+ * <code>ServiceBindingManager</code>. 
+ * <p/>
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SystemPropertyBinder
+{
+   private final Set<SystemPropertyBinding> bindings;
+   
+   public SystemPropertyBinder(Set<SystemPropertyBinding> bindings)
+   {
+      this.bindings = bindings;
+   }
+   
+   public void start()
+   {
+      for (SystemPropertyBinding binding : bindings)
+      {
+         final String property = binding.getProperty();
+         final String value = binding.getValue();
+         
+         if (System.getSecurityManager() == null)
+         {
+            System.setProperty(property, value);
+         }
+         else
+         {
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+               public Object run()
+               {
+                  System.setProperty(property, value);
+                  return null;
+               }
+               
+            });
+         }
+      }
+      
+   }
+   
+   public void stop()
+   {
+      for (SystemPropertyBinding binding : bindings)
+      {
+         final String property = binding.getProperty();
+         
+         if (System.getSecurityManager() == null)
+         {
+            System.clearProperty(property);
+         }
+         else
+         {
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+               public Object run()
+               {
+                  System.clearProperty(property);
+                  return null;
+               }
+               
+            });
+         }
+      }
+   }
+}

Added: trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java	                        (rev 0)
+++ trunk/varia/src/main/org/jboss/services/binding/SystemPropertyBinding.java	2008-08-13 20:52:31 UTC (rev 77034)
@@ -0,0 +1,73 @@
+/*
+ * 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;
+import java.net.URL;
+
+/**
+ * Encapsulates the key and value for a system property. Basic function is to
+ * perform type conversions in its constructor for values returned by
+ * {@link ServiceBindingManager} so {@link SystemPropertyBinder} can bind the
+ * values. 
+ * 
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public class SystemPropertyBinding
+{
+   private final String property;
+   private final String value;
+   
+   public SystemPropertyBinding(String property, int value)
+   {
+      this(property, String.valueOf(value));
+   }
+   
+   public SystemPropertyBinding(String property, InetAddress value)
+   {
+      this(property, value.getHostAddress());
+   }
+   
+   public SystemPropertyBinding(String property, URL value)
+   {
+      this(property, value.toExternalForm());
+   }
+   
+   public SystemPropertyBinding(String property, String value)
+   {
+      this.property = property;
+      this.value = value;
+   }
+   
+   public String getProperty()
+   {
+      return property;
+   }
+   public String getValue()
+   {
+      return value;
+   }
+   
+   
+}




More information about the jboss-cvs-commits mailing list