[jboss-svn-commits] JBL Code SVN: r6270 - labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 18 10:05:50 EDT 2006


Author: mark.little at jboss.com
Date: 2006-09-18 10:05:48 -0400 (Mon, 18 Sep 2006)
New Revision: 6270

Modified:
   labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
Log:
added in factory support.

Modified: labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	2006-09-18 13:40:02 UTC (rev 6269)
+++ labs/jbossesb/workspace/rearchitecture/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	2006-09-18 14:05:48 UTC (rev 6270)
@@ -4,11 +4,15 @@
 import org.jboss.soa.esb.message.format.MessageFactory;
 import org.jboss.soa.esb.message.format.MessageType;
 
+import org.jboss.soa.esb.message.format.MessagePlugin;
+
 import org.jboss.internal.soa.esb.message.format.xml.XMLMessagePlugin;
 
 import java.net.URI;
 import java.security.InvalidParameterException;
+import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Properties;
 
 /*
  * JBoss, Home of Professional Open Source
@@ -40,43 +44,81 @@
 
 public class MessageFactoryImpl extends MessageFactory
 {
-	
+
 	public MessageFactoryImpl ()
 	{
 		/*
-		 * Go through the properties loaded from the property file.
-		 * Anything starting with MessagePlugin.MESSAGE_PLUGIN is assumed to be
-		 * a plugin that we load and add to the list.
+		 * Go through the properties loaded from the property file. Anything
+		 * starting with MessagePlugin.MESSAGE_PLUGIN is assumed to be a plugin
+		 * that we load and add to the list.
 		 */
 		
+		Properties properties = System.getProperties();
+		
+		if (properties != null)
+		{
+			Enumeration names = properties.propertyNames();
+
+			while (names.hasMoreElements())
+			{
+				String attrName = (String) names.nextElement();
+
+				if (attrName.startsWith(MessagePlugin.MESSAGE_PLUGIN))
+				{
+					try
+					{
+						String pluginName = properties.getProperty(attrName);
+						Class c = Class.forName(pluginName);
+						MessagePlugin thePlugin = (MessagePlugin) c.newInstance();
+						
+						messageFormats.put(thePlugin.getType(), thePlugin);
+					}
+					catch (ClassNotFoundException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (IllegalAccessException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (InstantiationException ex)
+					{
+						ex.printStackTrace();
+					}
+				}
+			}
+		}
+	         
 		/*
 		 * Now add the default(s).
 		 */
 		
-		messageFormats.put(new XMLMessagePlugin(), MessageType.JBOSS_XML);
+		messageFormats.put(MessageType.JBOSS_XML, new XMLMessagePlugin());
 	}
-	
-	public Message getMessage () // returns some default implementation.
+
+	public Message getMessage() // returns some default implementation.
 	{
-		return (Message) messageFormats.get(MessageType.DEFAULT_TYPE);
+		return ((MessagePlugin) messageFormats.get(MessageType.DEFAULT_TYPE)).getMessage();
 	}
-	
-	public Message getMessage (URI type)  // returns a message of a specific type.
+
+	public Message getMessage(URI type) // returns a message of a specific type.
 	{
 		if (type == null)
 			throw new InvalidParameterException();
-		
-		return (Message) messageFormats.get(type);
+
+		return ((MessagePlugin) messageFormats.get(type)).getMessage();
 	}
-	
-	public Message getMessage (Message msg, URI type)  // convert a message from one form to another.
+
+	public Message getMessage(Message msg, URI type) // convert a message
+	// from one form to
+	// another.
 	{
 		if ((msg == null) || (type == null))
 			throw new InvalidParameterException();
-		
+
 		return null;
 	}
 
-	private final Hashtable messageFormats = new Hashtable();
-	
+	private final Hashtable<URI, MessagePlugin> messageFormats = new Hashtable<URI, MessagePlugin>();
+
 }




More information about the jboss-svn-commits mailing list