[jboss-svn-commits] JBL Code SVN: r6840 - labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/persistence/format

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 16 17:16:09 EDT 2006


Author: daniel.brum at jboss.com
Date: 2006-10-16 17:16:08 -0400 (Mon, 16 Oct 2006)
New Revision: 6840

Added:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactoryImpl.java
Log:
Message Store

Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactoryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactoryImpl.java	2006-10-16 21:15:27 UTC (rev 6839)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactoryImpl.java	2006-10-16 21:16:08 UTC (rev 6840)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author daniel.brum at jboss.com
+ */
+
+
+package org.jboss.internal.soa.esb.persistence.format;
+
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+
+import org.jboss.internal.soa.esb.persistence.format.db.DBMessageStorePlugin;
+import org.jboss.soa.esb.persistence.MessageStore;
+import org.jboss.soa.esb.persistence.MessageStoreFactory;
+import org.jboss.soa.esb.persistence.format.MessageStorePlugin;
+import org.jboss.soa.esb.persistence.format.MessageStoreType;
+
+public class MessageStoreFactoryImpl extends MessageStoreFactory {
+	
+	private final Hashtable<URI, MessageStorePlugin> messageStoreFormats = new Hashtable<URI, MessageStorePlugin>();
+
+	
+	public MessageStoreFactoryImpl() {
+		reset();
+	}
+	
+	public MessageStore getMessageStore() {
+		return ((MessageStorePlugin) messageStoreFormats.get(MessageStoreType.DEFAULT_TYPE)).getMessageStore();
+	}
+	
+	public MessageStore getMessageStore(URI type) {
+		if (type == null)
+			throw new IllegalArgumentException();
+
+		MessageStorePlugin plugin = messageStoreFormats.get(type);
+
+		if (plugin != null)
+			return plugin.getMessageStore();
+		else
+			return null;
+	}
+	
+	public void reset ()
+	{
+		messageStoreFormats.clear();
+		/*
+		 * Go through the properties loaded from the property file. Anything
+		 * starting with MessageStorePlugin.MESSAGE_STORE_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(MessageStorePlugin. MESSAGE_STORE_PLUGIN))
+				{
+					try
+					{
+						String pluginName = properties.getProperty(attrName);
+						Class c = Class.forName(pluginName);
+						MessageStorePlugin thePlugin = (MessageStorePlugin) c.newInstance();
+
+						messageStoreFormats.put(thePlugin.getType(), thePlugin);
+					}
+					catch (ClassNotFoundException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (IllegalAccessException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (InstantiationException ex)
+					{
+						ex.printStackTrace();
+					}
+				}
+			}
+		}
+	         
+		/*
+		 * Now add the default(s).
+		 */		
+		messageStoreFormats.put(MessageStoreType.DATABASE, new DBMessageStorePlugin());		
+	}
+
+}




More information about the jboss-svn-commits mailing list