[jboss-cvs] JBossAS SVN: r109373 - in projects/cluster/ha-server-core/trunk: src/main/java/org/jboss/ha/core/channelfactory and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 18 15:41:53 EST 2010


Author: smarlow at redhat.com
Date: 2010-11-18 15:41:53 -0500 (Thu, 18 Nov 2010)
New Revision: 109373

Modified:
   projects/cluster/ha-server-core/trunk/pom.xml
   projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ChannelInfo.java
   projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/JChannelFactory.java
   projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackConfigInfo.java
   projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackUtil.java
Log:
JBCLUSTER-289 upgrade to JGroups 2.11.0.GA from 2.10.1.GA

Modified: projects/cluster/ha-server-core/trunk/pom.xml
===================================================================
--- projects/cluster/ha-server-core/trunk/pom.xml	2010-11-18 20:20:16 UTC (rev 109372)
+++ projects/cluster/ha-server-core/trunk/pom.xml	2010-11-18 20:41:53 UTC (rev 109373)
@@ -31,7 +31,7 @@
   
   <properties>
     <version.jboss.ha.server.api>2.0.0.CR1</version.jboss.ha.server.api>
-    <version.jgroups>2.10.1.GA</version.jgroups>
+    <version.jgroups>2.11.0.GA</version.jgroups>
     <version.junit>4.8.2</version.junit>
   </properties>
   

Modified: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ChannelInfo.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ChannelInfo.java	2010-11-18 20:20:16 UTC (rev 109372)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ChannelInfo.java	2010-11-18 20:41:53 UTC (rev 109373)
@@ -29,7 +29,6 @@
 import org.jgroups.Address;
 import org.jgroups.Channel;
 import org.jgroups.View;
-import org.jgroups.conf.ProtocolData;
 
 /**
  * Information describing an open JGroups Channel.

Modified: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/JChannelFactory.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/JChannelFactory.java	2010-11-18 20:20:16 UTC (rev 109372)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/JChannelFactory.java	2010-11-18 20:41:53 UTC (rev 109373)
@@ -52,9 +52,6 @@
 import org.jgroups.Global;
 import org.jgroups.JChannel;
 import org.jgroups.conf.ConfiguratorFactory;
-import org.jgroups.conf.ProtocolData;
-import org.jgroups.conf.ProtocolParameter;
-import org.jgroups.conf.ProtocolStackConfigurator;
 import org.jgroups.jmx.JmxConfigurator;
 import org.jgroups.protocols.TP;
 import org.jgroups.stack.Protocol;
@@ -82,7 +79,6 @@
  * <li>Configures the channel's thread pools and thread factories to ensure
  * that application thread context classloaders don't leak to the channel
  * threads.</li>
- * <li>Exposes a ProfileService ManagementView interface.</li>
  * </ul>
  * </p>
  * 
@@ -148,7 +144,7 @@
    private ChannelCloseListener closeListener = new ChannelCloseListener();
 
    /**
-    * Map<String,ProtocolStackConfigurator>. Hashmap which maps stack names to JGroups
+    * Map<String,ProtocolStackConfigurInfo>. Hashmap which maps stack names to JGroups
     * configurations. Keys are stack names, values are plain JGroups stack
     * configs. This is (re-)populated whenever a setMultiplexerConfig() method
     * is called
@@ -210,15 +206,11 @@
    {
       checkStarted();
 
-      if (properties == null)
-         properties = JChannel.DEFAULT_PROTOCOL_STACK;
+      ProtocolData[] config = null;
 
-      ProtocolStackConfigurator config = null;
-
       try
       {
-         ProtocolStackConfigurator c = ConfiguratorFactory.getStackConfigurator(properties);
-         config = c;
+         config = ProtocolStackUtil.getProtocolData(properties);
       }
       catch (Exception x)
       {
@@ -229,7 +221,7 @@
 
       try
       {
-         registerChannel(channel, null, null, ProtocolStackUtil.getProtocolData(config));
+         registerChannel(channel, null, null, config);
       }
       catch (ChannelException ce)
       {
@@ -851,7 +843,7 @@
       ProtocolStackConfigInfo cfg = stacks.get(stack_name);
       if (cfg == null)
          throw new Exception("stack \"" + stack_name + "\" not found in " + stacks.keySet());
-      return cfg.getConfigurator().getProtocolStackString();
+      return cfg.getProtocolStackString();
    }
 
    /**
@@ -863,7 +855,7 @@
       StringBuilder sb = new StringBuilder();
       for (Map.Entry<String, ProtocolStackConfigInfo> entry : stacks.entrySet())
       {
-         sb.append(entry.getKey()).append(": ").append(entry.getValue().getConfigurator().getProtocolStackString()).append("\n");
+         sb.append(entry.getKey()).append(": ").append(entry.getValue().getProtocolStackString()).append("\n");
       }
       return sb.toString();
    }
@@ -1224,11 +1216,11 @@
       
       if (config == null)
          throw new IllegalArgumentException("Unknown stack_name " + stack_name);
+      ProtocolData[] protocols = config.getConfiguration();
+      JChannel channel = initializeChannel(protocols, stack_name, forceSingletonStack);
       
-      JChannel channel = initializeChannel(config.getConfigurator(), stack_name, forceSingletonStack);
+      registerChannel(channel, id, stack_name, protocols);      
       
-      registerChannel(channel, id, stack_name, ProtocolStackUtil.getProtocolData(config.getConfigurator()));      
-      
       return channel;
    }
 
@@ -1242,7 +1234,7 @@
     * 
     * @throws ChannelException
     */
-   private JChannel initializeChannel(ProtocolStackConfigurator config, String stack_name,
+   private JChannel initializeChannel(ProtocolData[] config, String stack_name,
          boolean forceSingletonStack) throws ChannelException
    {  
       Map<String, String> tpProps = getTransportProperties(config);
@@ -1258,7 +1250,6 @@
                       ". You should configure a singleton_name for this stack.");
             
             config = addSingletonName(config, singletonName);
-            log.debug("Stack config after adding singleton_name is " + config.getProtocolStackString());
             tpProps = getTransportProperties(config);                       
          }
          else if (forceSingletonStack)
@@ -1267,7 +1258,9 @@
                       "singleton_name and MuxChannels are not supported.");
          }
       }
-      JChannel channel = new MuxChannel(config);
+      String stackString = ProtocolStackUtil.getProtocolStackString(config);
+      log.debugf("Stack config after adding singleton_name is %s", stackString);
+      JChannel channel = new MuxChannel(stackString);
       
       if (manageNewThreadClassLoader || manageReleasedThreadClassLoader)
       {
@@ -1396,12 +1389,10 @@
       return address;
    }
    
-   private Map<String, String> getTransportProperties(ProtocolStackConfigurator config)
+   private Map<String, String> getTransportProperties(ProtocolData[] protocols)
    {
       Map<String, String> tpProps = null;
-      ProtocolData[] protocols= ProtocolStackUtil.getProtocolData(config);
       ProtocolData transport=protocols[0];
-      @SuppressWarnings("unchecked")
       Map<String,ProtocolParameter> tmp=transport.getParameters();
       tpProps = new HashMap<String,String>();
       for(Map.Entry<String,ProtocolParameter> entry: tmp.entrySet())
@@ -1412,33 +1403,14 @@
       return tpProps;
    }
   
-   private ProtocolStackConfigurator addSingletonName(ProtocolStackConfigurator orig, String singletonName)
+   private ProtocolData[] addSingletonName(ProtocolData[] orig, String singletonName)
       throws ChannelException
    {
-      ProtocolStackConfigurator result = null;
-      try
-      {
-         ProtocolData[] protocols=orig.getProtocolStack();
-         ProtocolData transport=protocols[0];
-         ProtocolParameter singletonParam = new ProtocolParameter(Global.SINGLETON_NAME, singletonName);
-         transport.override(new ProtocolParameter[]{ singletonParam});
-         result = orig;
-      }
-      catch (UnsupportedOperationException uoe)
-      {
-         // JGroups version hasn't implemented ProtocolStackConfigurator.getProtocolStack()
-         // So we do things manually via string manipulation         
-         String config = orig.getProtocolStackString();
-         int idx = config.indexOf('(') + 1;
-         StringBuilder builder = new StringBuilder(config.substring(0, idx));
-         builder.append(Global.SINGLETON_NAME);
-         builder.append('=');
-         builder.append(singletonName);
-         builder.append(';');
-         builder.append(config.substring(idx));
-         
-         result = ConfiguratorFactory.getStackConfigurator(builder.toString());
-      }
+      ProtocolData[] result = null;
+      ProtocolData transport=orig[0];
+      ProtocolParameter singletonParam = new ProtocolParameter(Global.SINGLETON_NAME, singletonName);
+      transport.override(new ProtocolParameter[]{ singletonParam});
+      result = orig;
       
       return result;
    }

Modified: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackConfigInfo.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackConfigInfo.java	2010-11-18 20:20:16 UTC (rev 109372)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackConfigInfo.java	2010-11-18 20:41:53 UTC (rev 109373)
@@ -22,12 +22,10 @@
 
 package org.jboss.ha.core.channelfactory;
 
-import org.jgroups.conf.ProtocolData;
-import org.jgroups.conf.ProtocolStackConfigurator;
 
 /**
+ * Data object representing a JGroups protocol stack configuration.
  *
- *
  * @author Brian Stansberry
  * 
  * @version $Revision: $
@@ -36,21 +34,21 @@
 {
    private final String name;
    private final String description;
-   private final ProtocolStackConfigurator configurator;
+   private final ProtocolData[] configuration;
    
-   public ProtocolStackConfigInfo(String name, String description, ProtocolStackConfigurator configurator)
+   public ProtocolStackConfigInfo(String name, String description, ProtocolData[] configuration)
    {
       if (name == null)
       {
          throw new IllegalArgumentException("null name");
       }
-      if (configurator == null)
+      if (configuration == null)
       {
-         throw new IllegalArgumentException("null configurator");
+         throw new IllegalArgumentException("null configuration");
       }
       this.name = name;
       this.description = description;
-      this.configurator = configurator;
+      this.configuration = configuration;      
    }
 
    public String getName()
@@ -63,13 +61,13 @@
       return description;
    }
 
-   ProtocolStackConfigurator getConfigurator()
+   public ProtocolData[] getConfiguration()
    {
-      return configurator;
+      return configuration;
    }
-
-   public ProtocolData[] getConfiguration()
+   
+   public String getProtocolStackString()
    {
-      return ProtocolStackUtil.getProtocolData(configurator);
+      return ProtocolStackUtil.getProtocolStackString(configuration);
    }
 }

Modified: projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackUtil.java
===================================================================
--- projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackUtil.java	2010-11-18 20:20:16 UTC (rev 109372)
+++ projects/cluster/ha-server-core/trunk/src/main/java/org/jboss/ha/core/channelfactory/ProtocolStackUtil.java	2010-11-18 20:41:53 UTC (rev 109373)
@@ -22,20 +22,29 @@
 
 package org.jboss.ha.core.channelfactory;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PushbackReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.jboss.logging.Logger;
+import org.jboss.util.StringPropertyReplacer;
+import org.jgroups.JChannel;
 import org.jgroups.conf.ConfiguratorFactory;
-import org.jgroups.conf.ProtocolData;
-import org.jgroups.conf.ProtocolParameter;
-import org.jgroups.conf.ProtocolStackConfigurator;
-import org.jgroups.conf.XmlConfigurator;
+import org.jgroups.util.Util;
+import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -43,7 +52,10 @@
 import org.w3c.dom.NodeList;
 
 /**
- * Utilities related to JGroups protocol stack manipulation.
+ * Utilities related to JGroups protocol stack manipulation. This duplicates
+ * a lot of things in JGroups, but does so in order to eliminate usage of
+ * classes that JGroups considers to be internal JGroups implementation details
+ * that are subject to change at any time.
  *
  * @author Brian Stansberry
  * 
@@ -83,7 +95,7 @@
       DocumentBuilder builder=factory.newDocumentBuilder();
       Document document=builder.parse(input);
 
-      // The root element of the document should be the "config" element,
+      // The root element of the document should be the "protocol_stacks" element,
       // but the parser(Element) method checks this so a check is not
       // needed here.
       Element configElement = document.getDocumentElement();
@@ -156,57 +168,376 @@
                      CONFIG + "\" element under \"" + STACK + "\"");
             }
 
-            XmlConfigurator conf = XmlConfigurator.getInstance(cfg);
-            // fixes http://jira.jboss.com/jira/browse/JGRP-290
-            ConfiguratorFactory.substituteVariables(conf); // replace vars with system props
+            ProtocolData[] protocolData = parseConfig(cfg);
+            // replace vars with system props
+            substituteVariables(protocolData); 
 
-            result.put(st_name, new ProtocolStackConfigInfo(st_name, stack_descr, conf));
+            result.put(st_name, new ProtocolStackConfigInfo(st_name, stack_descr, protocolData));
          }
       }
 
       return result;
+   }   
+   
+   public static ProtocolData[] parseSingleConfig(InputStream input) throws Exception 
+   {
+      if (input == null)
+      {
+         throw new IllegalArgumentException("null input");
+      }
+      
+      DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
+      factory.setValidating(false); //for now
+      DocumentBuilder builder=factory.newDocumentBuilder();
+      Document document=builder.parse(input);
+
+      // The root element of the document should be the "config" element,
+      // but the parser(Element) method checks this so a check is not
+      // needed here.
+      Element configElement = document.getDocumentElement();
+      return parseConfig(configElement);
    }
    
-   public static ProtocolData[] getProtocolData(ProtocolStackConfigurator config)
+   public static ProtocolData[] parseConfig(Element root_element) throws java.io.IOException
    {
-      ProtocolData[] result = null;
+
+      /** LinkedList<ProtocolData> */
+      List<ProtocolData> prot_data = new LinkedList<ProtocolData>();
+
+      /**
+       * CAUTION: crappy code ahead ! I (bela) am not an XML expert, so the
+       * code below is pretty amateurish... But it seems to work, and it is
+       * executed only on startup, so no perf loss on the critical path. If
+       * somebody wants to improve this, please be my guest.
+       */
       try
       {
-         result = config.getProtocolStack();
+         String root_name = root_element.getNodeName();
+         if (!"config".equals(root_name.trim().toLowerCase()))
+         {
+            log.fatal("XML protocol stack configuration does not start with a '<config>' element; "
+                  + "maybe the XML configuration needs to be converted to the new format ?\n"
+                  + "use 'java org.jgroups.conf.XmlConfigurator <old XML file> -new_format' to do so");
+            throw new IOException("invalid XML configuration");
+         }
+
+         NodeList prots = root_element.getChildNodes();
+         for (int i = 0; i < prots.getLength(); i++)
+         {
+            Node node = prots.item(i);
+            if (node.getNodeType() != Node.ELEMENT_NODE)
+               continue;
+
+            Element tag = (Element) node;
+            String protocol = tag.getTagName();
+            // System.out.println("protocol: " + protocol);
+            LinkedList<ProtocolParameter> params = new LinkedList<ProtocolParameter>();
+
+            NamedNodeMap attrs = tag.getAttributes();
+            int attrLength = attrs.getLength();
+            for (int a = 0; a < attrLength; a++)
+            {
+               Attr attr = (Attr) attrs.item(a);
+               String name = attr.getName();
+               String value = attr.getValue();
+               // System.out.println("    name=" + name + ", value=" + value);
+               params.add(new ProtocolParameter(name, value));
+            }
+            ProtocolData data = new ProtocolData(protocol, protocol, params);
+            prot_data.add(data);
+         }
+
+         return prot_data.toArray(new ProtocolData[prot_data.size()]);
       }
-      catch (UnsupportedOperationException e)
+      catch (Exception x)
       {
-         String s = config.getProtocolStackString();
-         String[] prots = s.split(":");
-         result = new ProtocolData[prots.length];
-         for (int i = 0; i < prots.length; i++)
+         if (x instanceof java.io.IOException)
+            throw (java.io.IOException) x;
+         else
          {
-            ProtocolParameter[] params = null;
-            int paren = prots[i].indexOf('(');
-            String name = paren > - 1 ? prots[i].substring(0, paren) : prots[1];
-            if (paren > -1 && paren < prots[1].length() - 2)
+            throw new IOException(x);
+         }
+      }
+   }
+
+   public static void substituteVariables(ProtocolData[] protocols)
+   {
+      for (ProtocolData data : protocols)
+      {
+         if (data != null)
+         {
+            for (ProtocolParameter param : data.getParametersAsArray())
             {
-               String unsplit = prots[i].substring(paren + 1, prots[i].length() -1);
-               String[] split = unsplit.split(";");
-                params = new ProtocolParameter[split.length];
-               for (int j = 0; j < split.length; j++)
+               String val = param.getValue();
+               // We use jboss-common-core here so we get the richer feature set
+               // of that versus JGroups system property replacement
+               String replacement = StringPropertyReplacer.replaceProperties(val);
+               if (!replacement.equals(val))
                {
-                  String[] keyVal = split[j].split("=");
-                  params[j] = new ProtocolParameter(keyVal[0], keyVal[1]);
+                  param.setValue(replacement);
                }
             }
-            else
+         }
+      }
+   }
+
+   public static String getProtocolStackString(ProtocolData[] protocolData)
+   {
+      StringBuilder buf = new StringBuilder();
+      for (int i = 0; i < protocolData.length; i++)
+      {
+         ProtocolData pd = protocolData[i];
+         buf.append(pd.getProtocolString());
+         if (i < protocolData.length - 1)
+         {
+            buf.append(':');
+         }
+      }
+      return buf.toString();
+   }
+
+   private static List<String> parseProtocols(String config_str) throws IOException
+   {
+      List<String> retval = new LinkedList<String>();
+      PushbackReader reader = new PushbackReader(new StringReader(config_str));
+      int ch;
+      StringBuilder sb;
+      boolean running = true;
+
+      while (running)
+      {
+         String protocol_name = readWord(reader);
+         sb = new StringBuilder();
+         sb.append(protocol_name);
+
+         ch = read(reader);
+         if (ch == -1)
+         {
+            retval.add(sb.toString());
+            break;
+         }
+
+         if (ch == ':')
+         { // no attrs defined
+            retval.add(sb.toString());
+            continue;
+         }
+
+         if (ch == '(')
+         { // more attrs defined
+            reader.unread(ch);
+            String attrs = readUntil(reader, ')');
+            sb.append(attrs);
+            retval.add(sb.toString());
+         }
+         else
+         {
+            retval.add(sb.toString());
+         }
+
+         while (true)
+         {
+            ch = read(reader);
+            if (ch == ':')
             {
-               params = new ProtocolParameter[0];
+               break;
             }
-            
-            result[i] = new ProtocolData(name, name, params);
+            if (ch == -1)
+            {
+               running = false;
+               break;
+            }
          }
       }
-      
-      return result == null ? new ProtocolData[0] : result;
-   }   
+      reader.close();
+
+      return retval;
+   }
+
+   private static int read(Reader reader) throws IOException
+   {
+      int ch = -1;
+      while ((ch = reader.read()) != -1)
+      {
+         if (!Character.isWhitespace(ch))
+            return ch;
+      }
+      return ch;
+   }
+
+   private static String readUntil(Reader reader, char c) throws IOException
+   {
+      StringBuilder sb = new StringBuilder();
+      int ch;
+      while ((ch = read(reader)) != -1)
+      {
+         sb.append((char) ch);
+         if (ch == c)
+            break;
+      }
+      return sb.toString();
+   }
+
+   private static String readWord(PushbackReader reader) throws IOException
+   {
+      StringBuilder sb = new StringBuilder();
+      int ch;
+
+      while ((ch = read(reader)) != -1)
+      {
+         if (Character.isLetterOrDigit(ch) || ch == '_' || ch == '.' || ch == '$')
+         {
+            sb.append((char) ch);
+         }
+         else
+         {
+            reader.unread(ch);
+            break;
+         }
+      }
+
+      return sb.toString();
+   }
+
+   private static ProtocolData parseProtocol(String protocolConfig) throws Exception
+   {
+      String protocol_name = null;
+      String properties_str = null;
+      int index = protocolConfig.indexOf('('); // e.g. "UDP(in_port=3333)"
+      int end_index = protocolConfig.lastIndexOf(')');
+
+      if (index == -1)
+      {
+         protocol_name = protocolConfig;
+         properties_str = "";
+      }
+      else
+      {
+         if (end_index == -1)
+         {
+            throw new Exception("Configurator.ProtocolConfiguration(): closing ')' " + "not found in " + protocolConfig
+                  + ": properties cannot be set !");
+         }
+         else
+         {
+            properties_str = protocolConfig.substring(index + 1, end_index);
+            protocol_name = protocolConfig.substring(0, index);
+         }
+      }
+      List<ProtocolParameter> params = parsePropertiesString(protocol_name, properties_str);
+
+      return new ProtocolData(protocol_name, protocol_name, params);
+   }
+
+   private static List<ProtocolParameter> parsePropertiesString(String protocol_name, String properties_str)
+         throws Exception
+   {
+      List<ProtocolParameter> params = new ArrayList<ProtocolParameter>();
+      int index = 0;
+
+      /* "in_port=5555;out_port=6666" */
+      if (properties_str.length() > 0)
+      {
+         String[] components = properties_str.split(";");
+         for (String property : components)
+         {
+            String name, value;
+            index = property.indexOf('=');
+            if (index == -1)
+            {
+               throw new Exception("'=' not found in " + property + " of " + protocol_name);
+            }
+            name = property.substring(0, index);
+            value = property.substring(index + 1, property.length());
+            params.add(new ProtocolParameter(name, value));
+         }
+      }
+      return params;
+   }    
    
+   
+   public static ProtocolData[] getProtocolData(Object properties) throws Exception {
+      InputStream input=null;
+
+      // added by bela: for null String props we use the default properties
+      if(properties == null)
+          properties=JChannel.DEFAULT_PROTOCOL_STACK;
+
+      if(properties instanceof URL) {
+          try {
+              input=((URL)properties).openStream();
+          }
+          catch(Throwable t) {
+          }
+      }
+
+      // if it is a string, then it could be a plain string or a url
+      if(input == null && properties instanceof String) {
+          try {
+              input=new URL((String)properties).openStream();
+          }
+          catch(Exception ignore) {
+              // if we get here this means we don't have a URL
+          }
+
+          // another try - maybe it is a resource, e.g. udp.xml
+          if(input == null && ((String)properties).endsWith("xml")) {
+              try {
+                  input=Util.getResourceAsStream((String)properties, ConfiguratorFactory.class);
+              }
+              catch(Throwable ignore) {
+              }
+          }
+
+          // try a regular file name
+          //
+          // This code was moved from the parent block (below) because of the
+          // possibility of causing a ClassCastException.
+
+          if(input == null) {
+              try {
+                  input=new FileInputStream((String)properties);
+              }
+              catch(Throwable t) {
+              }
+          }
+      }
+
+      // try a regular file
+      if(input == null && properties instanceof File) {
+          try {
+              input=new FileInputStream((File)properties);
+          }
+          catch(Throwable t) {
+          }
+      }
+
+      if(input != null) {
+          return parseSingleConfig(input);
+      }
+
+      if(properties instanceof Element) {
+          return parseConfig((Element)properties);
+      }
+
+      return parseProtocolStackString((String)properties);
+  }
+
+   private static ProtocolData[] parseProtocolStackString(String configuration) throws Exception
+   {
+      List<ProtocolData> retval = new ArrayList<ProtocolData>();
+      List<String> protocol_string = parseProtocols(configuration);
+
+      if (protocol_string == null)
+         return null;
+
+      for (String component_string : protocol_string)
+      {
+         retval.add(parseProtocol(component_string));
+      }
+      return retval.toArray(new ProtocolData[retval.size()]);
+   }
+   
    /**
     * Prevent instantiation.
     */



More information about the jboss-cvs-commits mailing list