[jboss-svn-commits] JBL Code SVN: r12338 - in labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb: actions and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jun 5 13:22:26 EDT 2007


Author: kurt.stam at jboss.com
Date: 2007-06-05 13:22:26 -0400 (Tue, 05 Jun 2007)
New Revision: 12338

Added:
   labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/
   labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java
Log:
JBESB-500 moving the message-store to jbossesb.esb

Added: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java	2007-06-05 17:22:26 UTC (rev 12338)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.
+ */
+
+/**
+ * Routes the Message argument to a fixed list of services ([category,name]) 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @since Version 4.0
+ */
+package org.jboss.soa.esb.actions;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.MessageStoreException;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+
+public class MessagePersister extends AbstractActionPipelineProcessor
+{
+    public final static String SERVICE_CATEGORY = "JBossESB-Internal";
+    public final static String SERVICE_NAME = "DeadLetterService";
+    public final static String MESSAGE_STORE_CLASS = "message-store-class";
+    public final static String CLASSIFICATION_ATTR = "classfication";
+    
+    protected ConfigTree config;
+    protected MessageStore messageStore;
+    private String classification;
+	private Logger log = Logger.getLogger(this.getClass());
+
+	public MessagePersister(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
+	{
+        this.config = config;
+	}
+	/** 
+     * Persists the message to the MessageStore
+	 */
+	public Message process(Message message) throws ActionProcessingException
+	{
+        try {
+            messageStore.addMessage(message, classification);
+        } catch (MessageStoreException mse) {
+            log.error("Could not store undeliverable message.", mse);
+        }
+		return message;
+	}
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionLifecycle#initialise()
+     */
+    public void initialise() throws ActionLifecycleException {
+        //Reading the config
+        String messageStoreClass = config.getAttribute(MESSAGE_STORE_CLASS);
+        String classificationValue   = config.getAttribute(CLASSIFICATION_ATTR);
+        if (classificationValue!=null) {
+            classification = classificationValue;
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("MessagePersister started with classification=" + classification 
+                + " and message-store-class=" + messageStore);
+        }
+        messageStore = MessageStoreFactory.getInstance().getMessageStore(messageStoreClass);
+    }
+    /* (non-Javadoc)
+     * @see org.jboss.soa.esb.actions.ActionLifecycle#destroy()
+     */
+    public void destroy() throws ActionLifecycleException {
+       classification=null;
+    }
+    
+    
+}


Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list