[jboss-svn-commits] JBL Code SVN: r21527 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions: monitoring and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 14 01:51:41 EDT 2008
Author: tcunning
Date: 2008-08-14 01:51:41 -0400 (Thu, 14 Aug 2008)
New Revision: 21527
Added:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitor.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitorMBean.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitoringAction.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringEventBean.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringPatternBean.java
Log:
bug:JBESB-1677
Commit MVEL expression monitoring action.
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitor.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitor.java 2008-08-14 05:51:41 UTC (rev 21527)
@@ -0,0 +1,112 @@
+/*
+ * 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.actions.monitoring;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Monitor store for any message that matches the MVEL pattern expression. An ArrayList of
+ * MonitoringPatternBeans is stored, which can be reset.
+ *
+ * @author tcunning
+ * @since Version 4.4
+ */
+public class MVELMonitor implements MVELMonitorMBean {
+ public ArrayList <MonitoringPatternBean> monitoredEvents;
+ private ConfigTree m_config;
+
+ public MVELMonitor(ConfigTree config) {
+ monitoredEvents = new ArrayList();
+ m_config = config;
+ }
+
+ public ArrayList getMonitoredEvents() {
+ return (ArrayList) monitoredEvents;
+ }
+
+ public void reset() {
+ monitoredEvents = new ArrayList();
+ }
+
+ public void addEvent(Message message, MonitoringPatternBean mpb) {
+ mpb.setMessageString(message.toString());
+ monitoredEvents.add(mpb);
+ }
+
+ protected void registerMBean() throws InstanceAlreadyExistsException,
+ InstanceNotFoundException, MBeanRegistrationException, MBeanRegistrationException,
+ MalformedObjectNameException, NotCompliantMBeanException {
+ MBeanServer mbeanServer = null;
+ try {
+ mbeanServer = MBeanServerLocator.locateJBoss();
+ } catch (IllegalStateException ise) {
+ // If we can't find a JBoss MBeanServer, just return
+ // Needed for unit tests
+ return;
+ }
+
+ ObjectName listObjectName = getObjectName();
+
+ if (mbeanServer.isRegistered(listObjectName)) {
+ mbeanServer.unregisterMBean(listObjectName);
+ }
+
+ mbeanServer.registerMBean(this, listObjectName);
+ }
+
+ protected ObjectName getObjectName() throws MalformedObjectNameException {
+ ObjectName listObjectName = null;
+
+ String deploymentName = m_config.getParent().getParent().getAttribute(ListenerTagNames.DEPLOYMENT_NAME_TAG);
+ String serviceName = m_config.getParent().getAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+
+ StringBuffer objectName = new StringBuffer("category=MVELMonitor");
+ if (deploymentName != null) {
+ objectName.append(",").append(ListenerTagNames.DEPLOYMENT_NAME_TAG).append("=").append(deploymentName);
+ }
+
+ if (serviceName != null) {
+ if (objectName.length() > 0) {
+ objectName.append(",");
+ }
+ objectName.append(ListenerTagNames.SERVICE_NAME_TAG).append("=").append(serviceName);
+ }
+
+ listObjectName = new ObjectName("jboss.esb:" + objectName.toString());
+
+ return listObjectName;
+ }
+}
\ No newline at end of file
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitorMBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitorMBean.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitorMBean.java 2008-08-14 05:51:41 UTC (rev 21527)
@@ -0,0 +1,36 @@
+/*
+ * 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.actions.monitoring;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * Interface for the MVEL Monitoring MBean.
+ *
+ * @author tcunning
+ * @since Version 4.4
+ */
+public interface MVELMonitorMBean {
+ public ArrayList getMonitoredEvents();
+ public void reset();
+}
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitoringAction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitoringAction.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MVELMonitoringAction.java 2008-08-14 05:51:41 UTC (rev 21527)
@@ -0,0 +1,125 @@
+/*
+ * 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.actions.monitoring;
+
+import java.util.ArrayList;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.scripting.ScriptingAction;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+
+import bsh.EvalError;
+import bsh.Interpreter;
+
+/**
+ * Action that monitors messages and has the ability to store information found at a particular MVEL pattern.
+ * Uses beanshell evaluation to decide whether to store the message information.
+ *
+ * @author tcunning
+ * @since Version 4.4
+ */
+public class MVELMonitoringAction extends AbstractActionPipelineProcessor {
+
+ public static final String MONITOR_VALUE = "monitor-value";
+ public static final String MVEL_PATTERN = "mvel-pattern";
+ public static final String PATTERN_NAME = "pattern-name";
+ public static final String PATTERN_CONDITIONAL = "pattern-conditional";
+
+ private static final String BEANSHELL_VARIABLE = "beanshellVar";
+
+ private ObjectMapper objectMapper;
+ private MVELMonitor mvelMonitor;
+
+ ArrayList <MonitoringPatternBean> list = null;
+
+ private static Logger logger = Logger.getLogger(ScriptingAction.class);
+ protected ConfigTree _config;
+
+ /**
+ * Constructor that forms
+ * @param config ConfigTree
+ */
+ public MVELMonitoringAction(ConfigTree config) {
+ this._config = config;
+
+ ConfigTree[] configTree = _config.getChildren(MONITOR_VALUE);
+ if (null == configTree || configTree.length < 1)
+ {
+ logger.warn("Missing or empty destination list - This action class won't have any effect");
+ return;
+ }
+
+ list = new ArrayList<MonitoringPatternBean>();
+
+ for (ConfigTree curr : configTree)
+ {
+ try
+ {
+ String pattern = curr.getAttribute(MVEL_PATTERN, "");
+ String name = curr.getAttribute(PATTERN_NAME, "");
+ String conditional = curr.getAttribute(PATTERN_CONDITIONAL, "");
+ list.add(new MonitoringPatternBean(pattern, name, conditional));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ mvelMonitor = new MVELMonitor(config);
+ try {
+ mvelMonitor.registerMBean();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Message process(Message message) throws ActionProcessingException {
+ objectMapper = new ObjectMapper();
+ if (list != null) {
+ for (int i = 0; i<list.size(); i++) {
+ MonitoringPatternBean mpb = list.get(i);
+ String object = null;
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ object = (String) mapper.getObjectFromMessage(message, mpb.getPattern());
+ Interpreter inter = new Interpreter();
+ inter.eval(BEANSHELL_VARIABLE + " = " + object + mpb.getConditional());
+ Boolean b = (Boolean)inter.get(BEANSHELL_VARIABLE);
+ if (b.booleanValue()) {
+ mvelMonitor.addEvent(message, mpb);
+ }
+ } catch (ObjectMappingException e1) {
+ throw new ActionProcessingException(e1);
+ } catch (EvalError e) {
+ throw new ActionProcessingException(e);
+ }
+ }
+ }
+ return message;
+ }
+}
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringEventBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringEventBean.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringEventBean.java 2008-08-14 05:51:41 UTC (rev 21527)
@@ -0,0 +1,64 @@
+/*
+ * 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.actions.monitoring;
+
+import java.util.Date;
+
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Bean for storing event and message information.
+ *
+ * @author tcunning
+ * @since Version 4.4
+ */
+public class MonitoringEventBean {
+ private String pattern;
+ private String name;
+ private String conditional;
+ private Message message;
+
+ public MonitoringEventBean(Message message, MonitoringPatternBean mpb, String data) {
+ this.pattern = mpb.getPattern();
+ this.name = mpb.getName();
+ this.conditional = mpb.getConditional();
+ this.message = message;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public String getConditional() {
+ return conditional;
+ }
+
+ public String toString() {
+ return "Pattern [" + pattern + "] "
+ + "Name [" + name + "] "
+ + "Conditional [" + conditional + "] matched " + message.toString();
+ }
+}
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringPatternBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringPatternBean.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/monitoring/MonitoringPatternBean.java 2008-08-14 05:51:41 UTC (rev 21527)
@@ -0,0 +1,68 @@
+/*
+ * 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.actions.monitoring;
+
+/**
+ * Bean for storing pattern information.
+ *
+ * @author tcunning
+ * @since Version 4.4
+ */
+public class MonitoringPatternBean {
+ private String pattern;
+ private String name;
+ private String conditional;
+ private String messageString;
+
+ public MonitoringPatternBean(String name, String pattern, String conditional) {
+ this.pattern = pattern;
+ this.name = name;
+ this.conditional = conditional;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public String getConditional() {
+ return conditional;
+ }
+
+ public String getMessageString() {
+ return messageString;
+ }
+
+ public void setMessageString(String f_messageString) {
+ messageString = f_messageString;
+ }
+
+ public String toString() {
+ return "Pattern [" + pattern + "] "
+ + "Name [" + name + "] "
+ + "Conditional [" + conditional + "]"
+ + "Message [" + messageString + "]";
+ }
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list