[jboss-svn-commits] JBL Code SVN: r5262 - labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 24 14:09:59 EDT 2006


Author: estebanschifman
Date: 2006-07-24 14:09:57 -0400 (Mon, 24 Jul 2006)
New Revision: 5262

Modified:
   labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java
   labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java
Log:
Fixed bugs for example scenario

Modified: labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java
===================================================================
--- labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java	2006-07-24 18:08:51 UTC (rev 5261)
+++ labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbAbstractProcessor.java	2006-07-24 18:09:57 UTC (rev 5262)
@@ -49,7 +49,7 @@
   private static final String POSTPRC_ELEMENT= "postProcess";
   private static final String POSTPRC_CLASS  = "actionClass";
 
-  private static final String CTX_PREFIX    = "@@ctx@@";
+  public static final String CTX_PREFIX    = "@@ctx@@";
   public static final String CTX_BATCH_UID  = CTX_PREFIX+"batchUid";
   public static final String CTX_BATCH_NUM  = CTX_PREFIX+"batchNum";
   public static final String CTX_INPUT_FILE = CTX_PREFIX+"inputFile";
@@ -58,12 +58,11 @@
   private static final String[] s_saMacros =
       {CTX_BATCH_UID, CTX_BATCH_NUM ,CTX_INPUT_FILE, CTX_POST_FILE };
 
-  private Map         m_oContext = new Hashtable();
+  protected Map <String,Object> m_oContext = new HashMap<String,Object>();
   public void clearContext () { m_oContext.clear(); }
   public Object rmvContextObj (String p_sKey) { return m_oContext.remove(p_sKey); }
   public Object getContextObj (String p_sKey) { return m_oContext.get(p_sKey); }
-  @SuppressWarnings("unchecked")
-public Object setContextObj (String p_sKey, Object p_oVal)
+  public Object setContextObj (String p_sKey, Object p_oVal)
     { return m_oContext.put(p_sKey,p_oVal); }
 
   protected DomElement  m_oParms    ,m_oInstP;

Modified: labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java
===================================================================
--- labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java	2006-07-24 18:08:51 UTC (rev 5261)
+++ labs/jbossesb/trunk/product/core/processors/src/org/jboss/soa/esb/processors/EsbMsgProcessor.java	2006-07-24 18:09:57 UTC (rev 5262)
@@ -1,78 +1,89 @@
-/*
-* 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.
-*/
-package org.jboss.soa.esb.processors;
-
-import java.lang.reflect.Constructor;
-
-import javax.jms.Message;
-import javax.jms.TextMessage;
-
-import org.jboss.soa.esb.helpers.*;
-
-public class EsbMsgProcessor extends EsbAbstractProcessor
-{
-  public EsbMsgProcessor(DomElement p_oP) throws Exception
-  { super(p_oP,false);
-  } //__________________________________
-
-  protected void checkParms() throws Exception {}
-  public void execute() throws Exception {}
-
-  public void processMessage(Message p_oMsg) throws Exception
-  {
-    String sPrc = this.getClass().getName();
-    sPrc = sPrc.substring(1+sPrc.lastIndexOf("."));
-
-    StringBuffer sb = new StringBuffer("Message ");
-    if (p_oMsg instanceof TextMessage)
-      sb.append("<").append(((TextMessage)p_oMsg).getText()).append("> ");
-    String sNotifMsg = sb.toString();
-
-    sb.setLength(0);
-    try
-    {
-      try
-      { Class oCls =  Class.forName(m_oParms.getAttr("actionClass"));
-        Constructor oCns = oCls.getConstructor(new Class[] {Message.class,EsbAbstractProcessor.class});
-        oCns.newInstance(new Object[] {p_oMsg,this});
-
-        super.postProcess();
-
-        sb.append(sPrc).append(" processed ").append(sNotifMsg).append(" successfully");
-        super.notifyOK(sb.toString());
-      }
-      catch (Exception e)
-      { m_oLogger.fatal("Message processor FAILED",e);
-        throw e;
-      }
-      finally { super.release(); }
-    }
-
-    catch (Exception eGen)    
-    {
-        System.out.println("test catch for rollback here..");
-        super.notifyError(eGen," " + sPrc+" PROBLEMS processing "+sNotifMsg);
-        throw eGen;
-    }
- }//_________________________
-
-} //____________________________________________________________________________
+/*
+* 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.
+*/
+package org.jboss.soa.esb.processors;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import org.jboss.soa.esb.helpers.*;
+
+public class EsbMsgProcessor extends EsbAbstractProcessor
+{
+  public EsbMsgProcessor(DomElement p_oP) throws Exception
+  { super(p_oP,false);
+  } //__________________________________
+
+  protected void checkParms() throws Exception {}
+  public void execute() throws Exception {}
+
+  public void processMessage(Message p_oMsg) throws Exception
+  {
+    StringBuilder sb = new StringBuilder();
+    if (p_oMsg instanceof TextMessage)
+      sb.append("TextMessage<")
+      	.append(((TextMessage)p_oMsg).getText())
+      	.append("> ");
+    else
+      sb.append(p_oMsg.toString());
+    System.out.println(sb.toString());
+  }//_________________________
+  
+  private static final SimpleDateFormat s_oDF
+  	= new SimpleDateFormat("MMMM dd, yyyy ");
+  
+  protected String messagePfx()
+  {
+	return
+ 	s_oDF.format(new Date(System.currentTimeMillis()))
+  	+" " +this.getClass().getSimpleName()
+  	+ " : ";
+  }//_________________________
+
+  /**
+   * Override this method in your derived class
+   * <p />Listeners will call this method to request
+   * the object that has to be sent to the 'ok' 
+   * notification list
+   * @return  Object - The Rosetta notification framework
+   * will use the toString() method of the returned Object 
+   */
+  public Object getOkNotification()
+  {
+	  return messagePfx()+" Normal completion";
+  }
+  /**
+   * Override this method in your derived class
+   * <p />Listeners will call this method to request
+   * the object that has to be sent to the 'error' 
+   * notification list
+   * @return  Object - The Rosetta notification framework
+   * will use the toString() method of the returned Object 
+   */
+  public Object getErrorNotification()
+  {
+	  return messagePfx()+" Abnormal end";
+  }
+
+} //____________________________________________________________________________




More information about the jboss-svn-commits mailing list