You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/12/05 22:46:50 UTC
svn commit: r482795 [1/2] - in
/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix:
jbi/container/ jbi/event/ jbi/framework/ jbi/jmx/ jbi/management/stats/
jbi/messaging/ jbi/monitoring/ jbi/monitoring/stats/ jbi/nmr/fl...
Author: gnodet
Date: Tue Dec 5 13:46:47 2006
New Revision: 482795
URL: http://svn.apache.org/viewvc?view=rev&rev=482795
Log:
SM-767: Statistics should be available at the endpoint level
Put all statistics related package in its own package, so that the whole statistic service become optional.
Add a onExchangeAccepted method on the ExchangeListener.
Add a onComponentInitialized event on the ComponentListener.
Add a service property on the JBIContainer so that it can register listeners on components and endpoints and
still receive all the events.
Add some javadocs to the event package.
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/StatisticsService.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/StatisticsServiceMBean.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/stats/
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/stats/CountStatisticImpl.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/stats/Resettable.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/stats/StatisticImpl.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/stats/StatsImpl.java (with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/stats/TimeStatisticImpl.java (with props)
Removed:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStats.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStatsMBean.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/stats/
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessagingStats.java
Modified:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentAdapter.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentListener.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointAdapter.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointEvent.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeEvent.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeListener.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyAdapter.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyEvent.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitAdapter.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitEvent.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBean.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/st/STFlow.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/view/DotViewEndpointListener.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/view/DotViewFlowListener.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/tck/ExchangeCompletedListener.java
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ComponentEnvironment.java Tue Dec 5 13:46:47 2006
@@ -17,14 +17,8 @@
package org.apache.servicemix.jbi.container;
import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
-import org.apache.servicemix.jbi.messaging.MessagingStats;
/**
* Holder for environment infomation
@@ -33,14 +27,10 @@
*/
public class ComponentEnvironment {
- private static final Log log = LogFactory.getLog(ComponentEnvironment.class);
-
private File installRoot;
private File workspaceRoot;
private File componentRoot;
private File stateFile;
- private File statsFile;
- private PrintWriter statsWriter;
private ComponentMBeanImpl localConnector;
/**
@@ -113,52 +103,4 @@
this.stateFile = stateFile;
}
- /**
- * close this environment
- */
- public synchronized void close() {
- if (statsWriter != null) {
- statsWriter.close();
- }
- }
-
- /**
- * dump stats
- */
- public synchronized void dumpStats() {
- if (componentRoot != null && componentRoot.exists()) {
- try {
- if (statsWriter == null && statsFile != null) {
- FileOutputStream fileOut = new FileOutputStream(statsFile);
- statsWriter = new PrintWriter(fileOut, true);
- statsWriter.println(localConnector.getComponentNameSpace().getName() + ":");
- statsWriter.println("inboundExchanges,inboundExchangeRate,outboundExchanges,outboundExchangeRate");
- }
- MessagingStats stats = localConnector.getMessagingStats();
- long inbound = stats.getInboundExchanges().getCount();
- double inboundRate = stats.getInboundExchangeRate().getAveragePerSecond();
- long outbound = stats.getOutboundExchanges().getCount();
- double outboundRate = stats.getOutboundExchangeRate().getAveragePerSecond();
- statsWriter.println(inbound + "," + inboundRate + "," + outbound + "," + outboundRate);
- }
- catch (IOException e) {
- log.warn("Failed to dump stats", e);
- }
- }
- }
-
- /**
- * @return Returns the statsFile.
- */
- public File getStatsFile() {
- return statsFile;
- }
-
- /**
- * @param statsFile The statsFile to set.
- */
- public void setStatsFile(File statsFile) {
- this.statsFile = statsFile;
- }
-
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java Tue Dec 5 13:46:47 2006
@@ -18,19 +18,13 @@
import java.io.File;
import java.io.IOException;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
import javax.jbi.JBIException;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
-import org.apache.servicemix.jbi.management.AttributeInfoHelper;
import org.apache.servicemix.jbi.management.BaseSystemService;
import org.apache.servicemix.jbi.util.FileUtil;
import org.apache.servicemix.jbi.util.FileVersionUtil;
@@ -64,12 +58,8 @@
private File sharedLibDir;
private File serviceAssembliesDir;
private File tmpDir;
- private int statsInterval = 5;
private Map envMap = new ConcurrentHashMap();
private AtomicBoolean started = new AtomicBoolean(false);
- private boolean dumpStats = false;
- private Timer statsTimer;
- private TimerTask timerTask;
/**
@@ -179,9 +169,8 @@
* @exception javax.jbi.JBIException if the item fails to start.
*/
public void start() throws javax.jbi.JBIException {
- super.start();
if (started.compareAndSet(false, true)) {
- scheduleStatsTimer();
+ super.start();
}
}
@@ -193,9 +182,6 @@
public void stop() throws javax.jbi.JBIException {
if (started.compareAndSet(true, false)) {
super.stop();
- if (timerTask != null) {
- timerTask.cancel();
- }
}
}
@@ -206,68 +192,11 @@
*/
public void shutDown() throws javax.jbi.JBIException {
super.shutDown();
- for (Iterator i = envMap.values().iterator();i.hasNext();) {
- ComponentEnvironment ce = (ComponentEnvironment) i.next();
- ce.close();
- }
- if (timerTask != null) {
- timerTask.cancel();
- }
- if (statsTimer != null) {
- statsTimer.cancel();
- }
envMap.clear();
container.getManagementContext().unregisterMBean(this);
}
/**
- * @return Returns the statsInterval (in secs).
- */
- public int getStatsInterval() {
- return statsInterval;
- }
-
- /**
- * @param statsInterval The statsInterval to set (in secs).
- */
- public void setStatsInterval(int statsInterval) {
- this.statsInterval = statsInterval;
- scheduleStatsTimer();
- }
-
- /**
- * @return Returns the dumpStats.
- */
- public boolean isDumpStats() {
- return dumpStats;
- }
-
- /**
- * @param value The dumpStats to set.
- */
- public void setDumpStats(boolean value) {
- if (dumpStats && !value) {
- if (timerTask != null) {
- timerTask.cancel();
- }
- }
- else if (!dumpStats && value) {
- dumpStats = value;//scheduleStatsTimer relies on dumpStats value
- scheduleStatsTimer();
- }
- dumpStats = value;
- }
-
- protected void doDumpStats() {
- if (isDumpStats()) {
- for (Iterator i = envMap.values().iterator();i.hasNext();) {
- ComponentEnvironment ce = (ComponentEnvironment) i.next();
- ce.dumpStats();
- }
- }
- }
-
- /**
* register the ComponentConnector
*
* @param connector
@@ -314,10 +243,6 @@
throw new JBIException(e);
}
}
- if (result.getStatsFile() == null) {
- File statsFile = FileUtil.getDirectoryPath(result.getComponentRoot(), "stats.cvs");
- result.setStatsFile(statsFile);
- }
result.setLocalConnector(connector);
envMap.put(connector, result);
return result;
@@ -386,13 +311,11 @@
File instDir = FileVersionUtil.getNewVersionDirectory(rootDir);
File workDir = FileUtil.getDirectoryPath(rootDir, "workspace");
File stateFile = FileUtil.getDirectoryPath(rootDir, "state.xml");
- File statsFile = FileUtil.getDirectoryPath(rootDir, "stats.csv");
ComponentEnvironment env = new ComponentEnvironment();
env.setComponentRoot(rootDir);
env.setInstallRoot(instDir);
env.setWorkspaceRoot(workDir);
env.setStateFile(stateFile);
- env.setStatsFile(statsFile);
return env;
}
@@ -401,13 +324,11 @@
File instDir = FileVersionUtil.getLatestVersionDirectory(rootDir);
File workDir = FileUtil.getDirectoryPath(rootDir, "workspace");
File stateFile = FileUtil.getDirectoryPath(rootDir, "state.xml");
- File statsFile = FileUtil.getDirectoryPath(rootDir, "stats.csv");
ComponentEnvironment env = new ComponentEnvironment();
env.setComponentRoot(rootDir);
env.setInstallRoot(instDir);
env.setWorkspaceRoot(workDir);
env.setStateFile(stateFile);
- env.setStatsFile(statsFile);
return env;
}
@@ -460,10 +381,6 @@
* @param doDelete true if component is to be deleted
*/
public void unreregister(ComponentMBeanImpl connector) {
- ComponentEnvironment ce = (ComponentEnvironment) envMap.remove(connector);
- if (ce != null) {
- ce.close();
- }
}
/**
@@ -546,40 +463,6 @@
}
}
- private void scheduleStatsTimer() {
- if (isDumpStats()) {
- if (statsTimer == null) {
- statsTimer = new Timer(true);
- }
- if (timerTask != null) {
- timerTask.cancel();
- }
- timerTask = new TimerTask() {
- public void run() {
- doDumpStats();
- }
- };
- long interval = statsInterval * 1000;
- statsTimer.scheduleAtFixedRate(timerTask, interval, interval);
- }
- }
-
-
-
-
-
- /**
- * Get an array of MBeanAttributeInfo
- *
- * @return array of AttributeInfos
- * @throws JMException
- */
- public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
- AttributeInfoHelper helper = new AttributeInfoHelper();
- helper.addAttribute(getObjectToManage(), "dumpStats", "Periodically dump Component statistics");
- helper.addAttribute(getObjectToManage(), "statsInterval", "Interval (secs) before dumping statistics");
- return AttributeInfoHelper.join(super.getAttributeInfos(), helper.getAttributeInfos());
- }
public File getJbiRootDir() {
return jbiRootDir;
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java Tue Dec 5 13:46:47 2006
@@ -55,6 +55,7 @@
import org.apache.servicemix.executors.impl.ExecutorFactoryImpl;
import org.apache.servicemix.id.IdGenerator;
import org.apache.servicemix.jbi.event.ComponentListener;
+import org.apache.servicemix.jbi.event.ContainerAware;
import org.apache.servicemix.jbi.event.EndpointListener;
import org.apache.servicemix.jbi.event.ExchangeEvent;
import org.apache.servicemix.jbi.event.ExchangeListener;
@@ -70,6 +71,7 @@
import org.apache.servicemix.jbi.framework.InstallationService;
import org.apache.servicemix.jbi.framework.Registry;
import org.apache.servicemix.jbi.management.BaseLifeCycle;
+import org.apache.servicemix.jbi.management.BaseSystemService;
import org.apache.servicemix.jbi.management.ManagementContext;
import org.apache.servicemix.jbi.messaging.MessageExchangeImpl;
import org.apache.servicemix.jbi.nmr.Broker;
@@ -106,6 +108,7 @@
protected DeploymentService deploymentService = new DeploymentService();
protected AutoDeploymentService autoDeployService = new AutoDeploymentService();
protected AdminCommandsService adminCommandsService = new AdminCommandsService();
+ protected BaseSystemService[] services;
protected ClientFactory clientFactory = new ClientFactory();
protected Registry registry = new Registry();
protected boolean autoEnlistInTransaction = false;
@@ -251,6 +254,20 @@
}
/**
+ * @return the services
+ */
+ public BaseSystemService[] getServices() {
+ return services;
+ }
+
+ /**
+ * @param services the services to set
+ */
+ public void setServices(BaseSystemService[] services) {
+ this.services = services;
+ }
+
+ /**
* Get the ManagementContext
*
* @return the ManagementContext
@@ -407,20 +424,6 @@
}
/**
- * @return Returns the statsInterval (in secs).
- */
- public int getStatsInterval() {
- return environmentContext.getStatsInterval();
- }
-
- /**
- * @param statsInterval The statsInterval to set (in secs).
- */
- public void setStatsInterval(int statsInterval) {
- environmentContext.setStatsInterval(statsInterval);
- }
-
- /**
* @return Returns the monitorInterval (in secs).
*/
public int getMonitorInterval() {
@@ -435,20 +438,6 @@
}
/**
- * @return Returns the dumpStats.
- */
- public boolean isDumpStats() {
- return environmentContext.isDumpStats();
- }
-
- /**
- * @param value The dumpStats to set.
- */
- public void setDumpStats(boolean value) {
- environmentContext.setDumpStats(value);
- }
-
- /**
* Install an component from a url
*
* @param url
@@ -549,6 +538,11 @@
mbeanServer = this.managementContext.getMBeanServer();// just in case ManagementContext creates it
environmentContext.init(this, rootDir);
clientFactory.init(this);
+ if (services != null) {
+ for (int i = 0; i < services.length; i++) {
+ services[i].init(this);
+ }
+ }
registry.init(this);
broker.init(this);
installationService.init(this);
@@ -586,6 +580,11 @@
managementContext.start();
environmentContext.start();
clientFactory.start();
+ if (services != null) {
+ for (int i = 0; i < services.length; i++) {
+ services[i].start();
+ }
+ }
broker.start();
registry.start();
installationService.start();
@@ -612,6 +611,11 @@
installationService.stop();
registry.stop();
broker.stop();
+ if (services != null) {
+ for (int i = services.length - 1; i >= 0; i--) {
+ services[i].stop();
+ }
+ }
clientFactory.stop();
environmentContext.stop();
managementContext.stop();
@@ -635,6 +639,11 @@
// lots of messages when components and endpoints are stopped.
broker.shutDown();
registry.shutDown();
+ if (services != null) {
+ for (int i = services.length - 1; i >= 0; i--) {
+ services[i].shutDown();
+ }
+ }
clientFactory.shutDown();
environmentContext.shutDown();
// shutdown the management context last, because it will close the mbean server
@@ -1245,18 +1254,6 @@
configuredListeners = listeners;
}
- public void callListeners(MessageExchange exchange) {
- ExchangeListener[] l = (ExchangeListener[]) listeners.getListeners(ExchangeListener.class);
- ExchangeEvent event = new ExchangeEvent(exchange);
- for (int i = 0; i < l.length; i++) {
- try {
- l[i].exchangeSent(event);
- } catch (Exception e) {
- log.warn("Error calling listener: " + e.getMessage(), e);
- }
- }
- }
-
public void resendExchange(MessageExchange exchange) throws JBIException {
if (exchange instanceof MessageExchangeImpl == false) {
throw new IllegalArgumentException("exchange should be a MessageExchangeImpl");
@@ -1268,7 +1265,15 @@
me.getPacket().setError(null);
me.getPacket().setStatus(ExchangeStatus.ACTIVE);
me.getPacket().setProperty(JbiConstants.DATESTAMP_PROPERTY_NAME, Calendar.getInstance());
- callListeners(me);
+ ExchangeListener[] l = (ExchangeListener[]) listeners.getListeners(ExchangeListener.class);
+ ExchangeEvent event = new ExchangeEvent(me, ExchangeEvent.EXCHANGE_SENT);
+ for (int i = 0; i < l.length; i++) {
+ try {
+ l[i].exchangeSent(event);
+ } catch (Exception e) {
+ log.warn("Error calling listener: " + e.getMessage(), e);
+ }
+ }
me.handleSend(false);
sendExchange(me.getMirror());
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentAdapter.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentAdapter.java Tue Dec 5 13:46:47 2006
@@ -16,9 +16,22 @@
*/
package org.apache.servicemix.jbi.event;
+/**
+ * An abstract adapter class for receiving component events.
+ * The methods in this class are empty. This class exists as a
+ * convenience for creating listener objects.
+ *
+ * @see ComponentEvent
+ * @see ComponentListener
+ *
+ * @author gnodet
+ */
public abstract class ComponentAdapter implements ComponentListener {
public void componentInstalled(ComponentEvent event) {
+ }
+
+ public void componentInitialized(ComponentEvent event) {
}
public void componentStarted(ComponentEvent event) {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentEvent.java Tue Dec 5 13:46:47 2006
@@ -20,15 +20,21 @@
import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
+/**
+ * Event sent for components lifecycle.
+ *
+ * @author gnodet
+ */
public class ComponentEvent extends EventObject {
private static final long serialVersionUID = -4075242868959881673L;
public static final int COMPONENT_INSTALLED = 0;
- public static final int COMPONENT_STARTED = 1;
- public static final int COMPONENT_STOPPED = 2;
- public static final int COMPONENT_SHUTDOWN = 3;
- public static final int COMPONENT_UNINSTALLED = 4;
+ public static final int COMPONENT_INITIALIZED = 1;
+ public static final int COMPONENT_STARTED = 2;
+ public static final int COMPONENT_STOPPED = 3;
+ public static final int COMPONENT_SHUTDOWN = 4;
+ public static final int COMPONENT_UNINSTALLED = 5;
private ComponentMBeanImpl component;
private int type;
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentListener.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentListener.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentListener.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ComponentListener.java Tue Dec 5 13:46:47 2006
@@ -21,6 +21,8 @@
public interface ComponentListener extends EventListener {
public void componentInstalled(ComponentEvent event);
+
+ public void componentInitialized(ComponentEvent event);
public void componentStarted(ComponentEvent event);
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.event;
+
+import org.apache.servicemix.jbi.container.JBIContainer;
+
+/**
+ * An interface for listeners which are aware of the container to which they are attached.
+ *
+ * @version $Revision$
+ */
+public interface ContainerAware {
+
+ /**
+ * This method is called when the listener is registered
+ * on the JBI container.
+ *
+ * @param container the container where this listener is registered
+ */
+ public void setContainer(JBIContainer container);
+
+}
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ContainerAware.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointAdapter.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointAdapter.java Tue Dec 5 13:46:47 2006
@@ -16,6 +16,16 @@
*/
package org.apache.servicemix.jbi.event;
+/**
+ * An abstract adapter class for receiving endpoint events.
+ * The methods in this class are empty. This class exists as a
+ * convenience for creating listener objects.
+ *
+ * @see EndpointEvent
+ * @see EndpointListener
+ *
+ * @author gnodet
+ */
public class EndpointAdapter implements EndpointListener {
public void internalEndpointRegistered(EndpointEvent event) {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointEvent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointEvent.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointEvent.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/EndpointEvent.java Tue Dec 5 13:46:47 2006
@@ -20,6 +20,11 @@
import javax.jbi.servicedesc.ServiceEndpoint;
+/**
+ * Event sent for endpoint lifeycle.
+ *
+ * @author gnodet
+ */
public class EndpointEvent extends EventObject {
private static final long serialVersionUID = -4480619483039133388L;
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.event;
+
+/**
+ * An abstract adapter class for receiving exchange events.
+ * The methods in this class are empty. This class exists as a
+ * convenience for creating listener objects.
+ *
+ * @see ExchangeEvent
+ * @see ExchangeListener
+ *
+ * @author gnodet
+ */
+public class ExchangeAdapter implements ExchangeListener {
+
+ public void exchangeAccepted(ExchangeEvent event) {
+ }
+
+ public void exchangeSent(ExchangeEvent event) {
+ }
+
+}
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeEvent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeEvent.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeEvent.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeEvent.java Tue Dec 5 13:46:47 2006
@@ -23,26 +23,40 @@
import javax.jbi.messaging.MessageExchange;
+/**
+ * Event sent when an exchange is received or accepted by a component.
+ *
+ * @author gnodet
+ */
public class ExchangeEvent extends EventObject {
private static final long serialVersionUID = -8349785806912334977L;
- public ExchangeEvent(MessageExchange exchange) {
+ public static final int EXCHANGE_SENT = 0;
+ public static final int EXCHANGE_ACCEPTED = 1;
+
+ private MessageExchange exchange;
+ private int type;
+
+ public ExchangeEvent(MessageExchange exchange, int type) {
super(exchange);
+ this.exchange = exchange;
+ this.type = type;
}
public MessageExchange getExchange() {
- return (MessageExchange) getSource();
+ return exchange;
+ }
+
+ public int getType() {
+ return type;
}
/**
* Returns the source context which created the message exchange
*/
public ComponentContextImpl getExchangeSourceContext() {
- return getExchangeImpl().getSourceContext();
- }
-
- protected MessageExchangeImpl getExchangeImpl() {
- return (MessageExchangeImpl) getSource();
+ return ((MessageExchangeImpl) exchange).getSourceContext();
}
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeListener.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeListener.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeListener.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ExchangeListener.java Tue Dec 5 13:46:47 2006
@@ -22,4 +22,6 @@
public void exchangeSent(ExchangeEvent event);
+ public void exchangeAccepted(ExchangeEvent event);
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyAdapter.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyAdapter.java Tue Dec 5 13:46:47 2006
@@ -16,6 +16,16 @@
*/
package org.apache.servicemix.jbi.event;
+/**
+ * An abstract adapter class for receiving service assemblies events.
+ * The methods in this class are empty. This class exists as a
+ * convenience for creating listener objects.
+ *
+ * @see ServiceAssemblyEvent
+ * @see ServiceAssemblyListener
+ *
+ * @author gnodet
+ */
public class ServiceAssemblyAdapter implements ServiceAssemblyListener {
public void assemblyDeployed(ServiceAssemblyEvent event) {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyEvent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyEvent.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyEvent.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceAssemblyEvent.java Tue Dec 5 13:46:47 2006
@@ -20,6 +20,11 @@
import org.apache.servicemix.jbi.framework.ServiceAssemblyLifeCycle;
+/**
+ * Event sent for service assembly lifecycle.
+ *
+ * @author gnodet
+ */
public class ServiceAssemblyEvent extends EventObject {
private static final long serialVersionUID = 8441830155548563543L;
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitAdapter.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitAdapter.java Tue Dec 5 13:46:47 2006
@@ -16,6 +16,16 @@
*/
package org.apache.servicemix.jbi.event;
+/**
+ * An abstract adapter class for receiving service units events.
+ * The methods in this class are empty. This class exists as a
+ * convenience for creating listener objects.
+ *
+ * @see ServiceUnitEvent
+ * @see ServiceUnitListener
+ *
+ * @author gnodet
+ */
public class ServiceUnitAdapter implements ServiceUnitListener {
public void unitDeployed(ServiceUnitEvent event) {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitEvent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitEvent.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitEvent.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/ServiceUnitEvent.java Tue Dec 5 13:46:47 2006
@@ -20,6 +20,11 @@
import org.apache.servicemix.jbi.framework.ServiceUnitLifeCycle;
+/**
+ * Event sent for service unit lifecycle.
+ *
+ * @author gnodet
+ */
public class ServiceUnitEvent extends EventObject {
private static final long serialVersionUID = 7825652001472392923L;
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html Tue Dec 5 13:46:47 2006
@@ -0,0 +1,27 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+<head>
+</head>
+<body>
+
+Event and listeners definitions that can be registered in the JBI container.
+
+</body>
+</html>
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/event/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBean.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBean.java Tue Dec 5 13:46:47 2006
@@ -17,7 +17,6 @@
package org.apache.servicemix.jbi.framework;
import javax.jbi.management.ComponentLifeCycleMBean;
-import javax.management.ObjectName;
/**
* Defines basic operations on the Compomnent
@@ -72,11 +71,6 @@
* @param value
*/
public void setThrottlingInterval(int value);
-
- /**
- * @return the ObjectName for the stats MBean for this Component - or null if it doesn't exist
- */
- public ObjectName getStatsMBeanName();
/**
* @return the component type (service-engine, binding-component)
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java Tue Dec 5 13:46:47 2006
@@ -42,7 +42,6 @@
import org.apache.servicemix.jbi.management.ManagementContext;
import org.apache.servicemix.jbi.management.OperationInfoHelper;
import org.apache.servicemix.jbi.messaging.DeliveryChannelImpl;
-import org.apache.servicemix.jbi.messaging.MessagingStats;
import org.apache.servicemix.jbi.util.XmlPersistenceSupport;
/**
@@ -62,10 +61,7 @@
private ComponentContextImpl context;
private ActivationSpec activationSpec;
private ObjectName mBeanName;
- private ComponentStats componentStatsMBean;
- private ObjectName componentStatsMBeanName;
private JBIContainer container;
- private MessagingStats messagingStats;
private ComponentNameSpace componentName;
private String description = "POJO Component";
private int queueCapacity = 1024;
@@ -98,8 +94,6 @@
this.description = description;
this.binding = binding;
this.service = service;
- this.componentStatsMBean = new ComponentStats(this);
- this.messagingStats = new MessagingStats(name.getName());
this.sharedLibraries = sharedLibraries;
}
@@ -113,8 +107,6 @@
try{
mBeanName = context.createObjectName(this);
context.registerMBean(mBeanName, this, ComponentMBean.class);
- componentStatsMBeanName = context.createObjectName(componentStatsMBean);
- context.registerMBean(componentStatsMBeanName, componentStatsMBean, ComponentStatsMBean.class);
return mBeanName;
}catch(Exception e){
String errorStr="Failed to register MBeans";
@@ -130,7 +122,6 @@
*/
public void unregisterMbeans(ManagementContext context) throws JBIException{
context.unregisterMBean(mBeanName);
- context.unregisterMBean(componentStatsMBeanName);
}
/**
@@ -191,6 +182,8 @@
DeliveryChannelImpl channel = new DeliveryChannelImpl(this);
channel.setContext(context);
context.setDeliveryChannel(channel);
+ super.init();
+ fireEvent(ComponentEvent.COMPONENT_INITIALIZED);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getLifeCycle().getClass().getClassLoader());
@@ -199,7 +192,6 @@
Thread.currentThread().setContextClassLoader(loader);
}
}
- super.init();
}
/**
@@ -512,12 +504,6 @@
}
/**
- * @return the ObjectName for the stats MBean for this Component - or null if it doesn't exist
- */
- public ObjectName getStatsMBeanName(){
- return componentStatsMBeanName;
- }
- /**
* Get an array of MBeanAttributeInfo
*
* @return array of AttributeInfos
@@ -531,7 +517,6 @@
helper.addAttribute(getObjectToManage(), "throttlingTimeout", "timeout for throttling");
helper.addAttribute(getObjectToManage(), "throttlingInterval", "exchange intervals before throttling");
helper.addAttribute(getObjectToManage(), "extensionMBeanName", "extension mbean name");
- helper.addAttribute(getObjectToManage(), "statsMBeanName", "Statistics mbean name");
return AttributeInfoHelper.join(super.getAttributeInfos(), helper.getAttributeInfos());
}
@@ -593,6 +578,9 @@
ComponentListener[] listeners = (ComponentListener[]) getContainer().getListeners(ComponentListener.class);
for (int i = 0; i < listeners.length; i++) {
switch (type) {
+ case ComponentEvent.COMPONENT_INITIALIZED:
+ listeners[i].componentInitialized(event);
+ break;
case ComponentEvent.COMPONENT_STARTED:
listeners[i].componentStarted(event);
break;
@@ -623,13 +611,6 @@
public JBIContainer getContainer() {
return container;
- }
-
- /**
- * @return Returns the messagingStats.
- */
- public MessagingStats getMessagingStats() {
- return messagingStats;
}
public Component getComponent() {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java Tue Dec 5 13:46:47 2006
@@ -45,6 +45,26 @@
*/
public class ConnectorServerFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
+ /**
+ * Constant indicating that registration should fail when
+ * attempting to register an MBean under a name that already exists.
+ * <p>This is the default registration behavior.
+ */
+ public static final int REGISTRATION_FAIL_ON_EXISTING = 0;
+
+ /**
+ * Constant indicating that registration should ignore the affected MBean
+ * when attempting to register an MBean under a name that already exists.
+ */
+ public static final int REGISTRATION_IGNORE_EXISTING = 1;
+
+ /**
+ * Constant indicating that registration should replace the affected MBean
+ * when attempting to register an MBean under a name that already exists.
+ */
+ public static final int REGISTRATION_REPLACE_EXISTING = 2;
+
+
private Log log = LogFactory.getLog(ConnectorServerFactoryBean.class);
private org.springframework.jmx.support.ConnectorServerFactoryBean csfb = new org.springframework.jmx.support.ConnectorServerFactoryBean();
private String serviceUrl = org.springframework.jmx.support.ConnectorServerFactoryBean.DEFAULT_SERVICE_URL;
@@ -52,9 +72,9 @@
private boolean threaded = false;
private Map environment;
private String objectName;
- private int registrationBehavior;
+ private int registrationBehavior = REGISTRATION_FAIL_ON_EXISTING;
private MBeanServer server;
- private static final Constants constants = new Constants(MBeanRegistrationSupport.class);
+ private static final Constants constants = new Constants(ConnectorServerFactoryBean.class);
/**
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?view=diff&rev=482795&r1=482794&r2=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java Tue Dec 5 13:46:47 2006
@@ -43,6 +43,8 @@
import org.apache.servicemix.jbi.ExchangeTimeoutException;
import org.apache.servicemix.jbi.container.ActivationSpec;
import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.event.ExchangeEvent;
+import org.apache.servicemix.jbi.event.ExchangeListener;
import org.apache.servicemix.jbi.framework.ComponentContextImpl;
import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
@@ -68,8 +70,6 @@
private IdGenerator idGenerator = new IdGenerator();
private MessageExchangeFactory inboundFactory;
private int intervalCount = 0;
- private long lastSendTime = System.currentTimeMillis();
- private long lastReceiveTime = System.currentTimeMillis();
private AtomicBoolean closed = new AtomicBoolean(false);
private Map waiters = new ConcurrentHashMap();
@@ -288,6 +288,18 @@
}
}
}
+ if (me != null) {
+ // Call input listeners
+ ExchangeListener[] l = (ExchangeListener[]) container.getListeners(ExchangeListener.class);
+ ExchangeEvent event = new ExchangeEvent(me, ExchangeEvent.EXCHANGE_ACCEPTED);
+ for (int i = 0; i < l.length; i++) {
+ try {
+ l[i].exchangeAccepted(event);
+ } catch (Exception e) {
+ log.warn("Error calling listener: " + e.getMessage(), e);
+ }
+ }
+ }
return me;
}
catch (InterruptedException e) {
@@ -339,14 +351,22 @@
autoSetPersistent(me);
// Throttle if needed
throttle();
- // Update stats
- incrementOutboundStats();
// Store the consumer component
if (me.getRole() == Role.CONSUMER) {
me.setSourceId(component.getComponentNameSpace());
}
// Call the listeners before the ownership changes
- container.callListeners(me);
+ // Call input listeners
+ ExchangeListener[] l = (ExchangeListener[]) container.getListeners(ExchangeListener.class);
+ ExchangeEvent event = new ExchangeEvent(me, ExchangeEvent.EXCHANGE_SENT);
+ for (int i = 0; i < l.length; i++) {
+ try {
+ l[i].exchangeSent(event);
+ } catch (Exception e) {
+ log.warn("Error calling listener: " + e.getMessage(), e);
+ }
+ }
+ // Change ownership
me.handleSend(sync);
mirror.setTxState(MessageExchangeImpl.TX_STATE_NONE);
// If this is the DONE or ERROR status from a synchronous transactional exchange,
@@ -510,50 +530,6 @@
this.context = context;
}
- protected void incrementInboundStats() {
- MessagingStats messagingStats = component.getMessagingStats();
- long currentTime = System.currentTimeMillis();
- if (container.isNotifyStatistics()) {
- long oldCount = messagingStats.getInboundExchanges().getCount();
- messagingStats.getInboundExchanges().increment();
- component.firePropertyChanged(
- "inboundExchangeCount",
- new Long(oldCount),
- new Long(messagingStats.getInboundExchanges().getCount()));
- double oldRate = messagingStats.getInboundExchangeRate().getAverageTime();
- messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime);
- component.firePropertyChanged("inboundExchangeRate",
- new Double(oldRate),
- new Double(messagingStats.getInboundExchangeRate().getAverageTime()));
- } else {
- messagingStats.getInboundExchanges().increment();
- messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime);
- }
- lastReceiveTime = currentTime;
- }
-
- protected void incrementOutboundStats() {
- MessagingStats messagingStats = component.getMessagingStats();
- long currentTime = System.currentTimeMillis();
- if (container.isNotifyStatistics()) {
- long oldCount = messagingStats.getOutboundExchanges().getCount();
- messagingStats.getOutboundExchanges().increment();
- component.firePropertyChanged(
- "outboundExchangeCount",
- new Long(oldCount),
- new Long(messagingStats.getOutboundExchanges().getCount()));
- double oldRate = messagingStats.getOutboundExchangeRate().getAverageTime();
- messagingStats.getOutboundExchangeRate().addTime(currentTime - lastSendTime);
- component.firePropertyChanged("outboundExchangeRate",
- new Double(oldRate),
- new Double(messagingStats.getOutboundExchangeRate().getAverageTime()));
- } else {
- messagingStats.getOutboundExchanges().increment();
- messagingStats.getOutboundExchangeRate().addTime(currentTime - lastSendTime);
- }
- lastSendTime = currentTime;
- }
-
/**
* Used internally for passing in a MessageExchange
*
@@ -566,9 +542,6 @@
}
// Check if the delivery channel has been closed
checkNotClosed();
- // Update stats
- incrementInboundStats();
-
// Retrieve the original exchange sent
MessageExchangeImpl original = (MessageExchangeImpl) exchangesById.get(getKeyForExchange(me));
if (original != null && me != original) {
@@ -599,6 +572,16 @@
me.handleAccept();
if (log.isTraceEnabled()) {
log.trace("Received: " + me);
+ }
+ // Call input listeners
+ ExchangeListener[] l = (ExchangeListener[]) container.getListeners(ExchangeListener.class);
+ ExchangeEvent event = new ExchangeEvent(me, ExchangeEvent.EXCHANGE_ACCEPTED);
+ for (int i = 0; i < l.length; i++) {
+ try {
+ l[i].exchangeAccepted(event);
+ } catch (Exception e) {
+ log.warn("Error calling listener: " + e.getMessage(), e);
+ }
}
// Set the flag the the exchange was delivered using push mode
// This is important for transaction boundaries
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.monitoring;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
+import org.apache.servicemix.jbi.management.AttributeInfoHelper;
+import org.apache.servicemix.jbi.management.BaseLifeCycle;
+import org.apache.servicemix.jbi.management.OperationInfoHelper;
+
+/**
+ * Defines basic statistics on the Component
+ */
+public class ComponentStats extends BaseLifeCycle implements ComponentStatsMBean {
+
+ private static final Log log = LogFactory.getLog(ComponentStats.class);
+
+ public static final String STATS_FILE = "stats.csv";
+
+ private ComponentMBeanImpl component;
+ private MessagingStats stats;
+ private File statsFile;
+ private PrintWriter statsWriter;
+
+ /**
+ * Constructor
+ *
+ * @param lcc
+ */
+ public ComponentStats(ComponentMBeanImpl component) {
+ this.component = component;
+ this.stats = new MessagingStats(component.getName());
+ if (component.getContext() != null && component.getContext().getEnvironment() != null) {
+ File componentRoot = component.getContext().getEnvironment().getComponentRoot();
+ if (componentRoot != null && componentRoot.exists()) {
+ this.statsFile = new File(componentRoot, STATS_FILE);
+ }
+ }
+ }
+
+ MessagingStats getMessagingStats() {
+ return stats;
+ }
+
+ void dumpStats() {
+ if (statsFile != null) {
+ try {
+ if (statsWriter == null) {
+ FileOutputStream fileOut = new FileOutputStream(statsFile);
+ statsWriter = new PrintWriter(fileOut, true);
+ statsWriter.println(component.getComponentNameSpace().getName() + ":");
+ statsWriter.println("inboundExchanges,inboundExchangeRate,outboundExchanges,outboundExchangeRate");
+ }
+ long inbound = stats.getInboundExchanges().getCount();
+ double inboundRate = stats.getInboundExchangeRate().getAveragePerSecond();
+ long outbound = stats.getOutboundExchanges().getCount();
+ double outboundRate = stats.getOutboundExchangeRate().getAveragePerSecond();
+ statsWriter.println(inbound + "," + inboundRate + "," + outbound + "," + outboundRate);
+ }
+ catch (IOException e) {
+ log.warn("Failed to dump stats", e);
+ }
+ }
+ }
+
+ void close() {
+ if (statsWriter != null) {
+ statsWriter.close();
+ statsWriter = null;
+ }
+ }
+
+ void incrementInbound() {
+ /*
+ if (component.getContainer().isNotifyStatistics()) {
+ long oldCount = stats.getInboundExchanges().getCount();
+ stats.getInboundExchanges().increment();
+ component.firePropertyChanged(
+ "inboundExchangeCount",
+ new Long(oldCount),
+ new Long(stats.getInboundExchanges().getCount()));
+ double oldRate = stats.getInboundExchangeRate().getAverageTime();
+ stats.getInboundExchangeRate().addTime();
+ component.firePropertyChanged("inboundExchangeRate",
+ new Double(oldRate),
+ new Double(stats.getInboundExchangeRate().getAverageTime()));
+ } else {
+ stats.getInboundExchanges().increment();
+ stats.getInboundExchangeRate().addTime();
+ }
+ */
+ stats.getInboundExchanges().increment();
+ stats.getInboundExchangeRate().addTime();
+ }
+
+ void incrementOutbound() {
+ /*
+ if (component.getContainer().isNotifyStatistics()) {
+ long oldCount = stats.getInboundExchanges().getCount();
+ stats.getOutboundExchanges().increment();
+ component.firePropertyChanged(
+ "outboundExchangeCount",
+ new Long(oldCount),
+ new Long(stats.getInboundExchanges().getCount()));
+ double oldRate = stats.getInboundExchangeRate().getAverageTime();
+ stats.getOutboundExchangeRate().addTime();
+ component.firePropertyChanged("outboundExchangeRate",
+ new Double(oldRate),
+ new Double(stats.getInboundExchangeRate().getAverageTime()));
+ } else {
+ stats.getOutboundExchanges().increment();
+ stats.getOutboundExchangeRate().addTime();
+ }
+ */
+ stats.getOutboundExchanges().increment();
+ stats.getOutboundExchangeRate().addTime();
+ }
+
+ /**
+ * Get the type of the item
+ * @return the type
+ */
+ public String getType() {
+ return "Statistics";
+ }
+
+ public String getSubType() {
+ return "Component";
+ }
+
+ /**
+ * Get the name of the item
+ * @return the name
+ */
+ public String getName() {
+ return component.getName();
+ }
+
+ /**
+ * Get the Description of the item
+ * @return the description
+ */
+ public String getDescription() {
+ return "Statistics for component " + component.getDescription();
+ }
+
+ /**
+ * Get the Inbound MessageExchange count
+ *
+ * @return inbound count
+ */
+ public long getInboundExchangeCount() {
+ return stats.getInboundExchanges().getCount();
+ }
+
+ /**
+ * Get the Inbound MessageExchange rate (number/sec)
+ *
+ * @return the inbound exchange rate
+ */
+ public double getInboundExchangeRate() {
+ return stats.getInboundExchangeRate().getAveragePerSecond();
+ }
+
+ /**
+ * Get the Outbound MessageExchange count
+ *
+ * @return outbound count
+ */
+ public long getOutboundExchangeCount() {
+ return stats.getOutboundExchanges().getCount();
+ }
+
+ /**
+ * Get the Outbound MessageExchange rate (number/sec)
+ *
+ * @return the outbound exchange rate
+ */
+ public double getOutboundExchangeRate() {
+ return stats.getOutboundExchangeRate().getAveragePerSecond();
+ }
+
+ /**
+ * @return size of the inbound Queue
+ */
+ public int getInboundQueueSize() {
+ if (component.getDeliveryChannel() != null) {
+ return component.getDeliveryChannel().getQueueSize();
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Reset all stats counters
+ */
+ public void reset() {
+ stats.reset();
+ }
+
+ /**
+ * Get an array of MBeanAttributeInfo
+ *
+ * @return array of AttributeInfos
+ * @throws JMException
+ */
+ public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
+ AttributeInfoHelper helper = new AttributeInfoHelper();
+ helper.addAttribute(getObjectToManage(), "inboundQueueSize", "size of the inbound queue");
+ helper.addAttribute(getObjectToManage(), "inboundExchangeCount", "count of inbound exchanges");
+ helper.addAttribute(getObjectToManage(), "outboundExchangeCount", "count of outbound exchanges");
+ helper.addAttribute(getObjectToManage(), "inboundExchangeRate", "rate of inbound exchanges/sec");
+ helper.addAttribute(getObjectToManage(), "outboundExchangeRate", "rate of outbound exchanges/sec");
+ return helper.getAttributeInfos();
+ }
+
+ /**
+ * Get an array of MBeanOperationInfo
+ *
+ * @return array of OperationInfos
+ */
+ public MBeanOperationInfo[] getOperationInfos() {
+ OperationInfoHelper helper = new OperationInfoHelper();
+ helper.addOperation(getObjectToManage(), "reset", "reset statistic counters");
+ return helper.getOperationInfos();
+ }
+
+}
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStats.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.monitoring;
+
+
+/**
+ * Defines basic operations on the Compomnent
+ */
+public interface ComponentStatsMBean {
+
+
+ /**
+ * Get the Inbound MessageExchange count
+ *
+ * @return inbound count
+ */
+ public long getInboundExchangeCount();
+
+ /**
+ * Get the Inbound MessageExchange rate (number/sec)
+ *
+ * @return the inbound exchange rate
+ */
+ public double getInboundExchangeRate();
+
+ /**
+ * Get the Outbound MessageExchange count
+ *
+ * @return outbound count
+ */
+ public long getOutboundExchangeCount();
+
+ /**
+ * Get the Outbound MessageExchange rate (number/sec)
+ *
+ * @return the outbound exchange rate
+ */
+ public double getOutboundExchangeRate();
+
+ /**
+ * @return size of the inbound Queue
+ */
+ public int getInboundQueueSize();
+
+ /**
+ * reset all stats counters
+ */
+ public void reset();
+}
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/ComponentStatsMBean.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.monitoring;
+
+import javax.management.JMException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+
+import org.apache.servicemix.jbi.management.AttributeInfoHelper;
+import org.apache.servicemix.jbi.management.BaseLifeCycle;
+import org.apache.servicemix.jbi.management.OperationInfoHelper;
+import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint;
+import org.apache.servicemix.jbi.servicedesc.EndpointSupport;
+
+public class EndpointStats extends BaseLifeCycle implements EndpointStatsMBean {
+
+ private AbstractServiceEndpoint endpoint;
+ private MessagingStats stats;
+
+ public EndpointStats(AbstractServiceEndpoint endpoint, MessagingStats componentStats) {
+ this.endpoint = endpoint;
+ this.stats = new MessagingStats(EndpointSupport.getUniqueKey(endpoint), componentStats);
+ }
+
+ MessagingStats getMessagingStats() {
+ return stats;
+ }
+
+ void incrementInbound() {
+ stats.getInboundExchanges().increment();
+ stats.getInboundExchangeRate().addTime();
+ }
+
+ void incrementOutbound() {
+ stats.getOutboundExchanges().increment();
+ stats.getOutboundExchangeRate().addTime();
+ }
+
+ /**
+ * Get the type of the item
+ * @return the type
+ */
+ public String getType() {
+ return "Statistics";
+ }
+
+ public String getSubType() {
+ return "Endpoint";
+ }
+
+ /**
+ * Get the name of the item
+ * @return the name
+ */
+ public String getName() {
+ return EndpointSupport.getUniqueKey(endpoint);
+ }
+
+ /**
+ * Get the Description of the item
+ * @return the description
+ */
+ public String getDescription() {
+ return "Statistics for endpoint " + EndpointSupport.getUniqueKey(endpoint);
+ }
+
+ public long getInboundExchangeCount() {
+ return stats.getInboundExchanges().getCount();
+ }
+
+ public double getInboundExchangeRate() {
+ return stats.getInboundExchangeRate().getAveragePerSecond();
+ }
+
+ public long getOutboundExchangeCount() {
+ return stats.getOutboundExchanges().getCount();
+ }
+
+ public double getOutboundExchangeRate() {
+ return stats.getOutboundExchangeRate().getAveragePerSecond();
+ }
+
+ /**
+ * Reset all stats counters
+ */
+ public void reset() {
+ stats.reset();
+ }
+
+ /**
+ * Get an array of MBeanAttributeInfo
+ *
+ * @return array of AttributeInfos
+ * @throws JMException
+ */
+ public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
+ AttributeInfoHelper helper = new AttributeInfoHelper();
+ helper.addAttribute(getObjectToManage(), "inboundExchangeCount", "count of inbound exchanges");
+ helper.addAttribute(getObjectToManage(), "outboundExchangeCount", "count of outbound exchanges");
+ helper.addAttribute(getObjectToManage(), "inboundExchangeRate", "rate of inbound exchanges/sec");
+ helper.addAttribute(getObjectToManage(), "outboundExchangeRate", "rate of outbound exchanges/sec");
+ return helper.getAttributeInfos();
+ }
+
+ /**
+ * Get an array of MBeanOperationInfo
+ *
+ * @return array of OperationInfos
+ */
+ public MBeanOperationInfo[] getOperationInfos() {
+ OperationInfoHelper helper = new OperationInfoHelper();
+ helper.addOperation(getObjectToManage(), "reset", "reset statistic counters");
+ return helper.getOperationInfos();
+ }
+
+}
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStats.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.monitoring;
+
+public interface EndpointStatsMBean {
+
+ /**
+ * Get the Inbound MessageExchange count
+ *
+ * @return inbound count
+ */
+ public long getInboundExchangeCount();
+
+ /**
+ * Get the Inbound MessageExchange rate (number/sec)
+ *
+ * @return the inbound exchange rate
+ */
+ public double getInboundExchangeRate();
+
+ /**
+ * Get the Outbound MessageExchange count
+ *
+ * @return outbound count
+ */
+ public long getOutboundExchangeCount();
+
+ /**
+ * Get the Outbound MessageExchange rate (number/sec)
+ *
+ * @return the outbound exchange rate
+ */
+ public double getOutboundExchangeRate();
+
+ /**
+ * reset all stats counters
+ */
+ public void reset();
+}
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/EndpointStatsMBean.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java?view=auto&rev=482795
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java (added)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java Tue Dec 5 13:46:47 2006
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.monitoring;
+
+import org.apache.servicemix.jbi.monitoring.stats.CountStatisticImpl;
+import org.apache.servicemix.jbi.monitoring.stats.StatsImpl;
+import org.apache.servicemix.jbi.monitoring.stats.TimeStatisticImpl;
+import org.apache.servicemix.jbi.util.IndentPrinter;
+
+
+/**
+ * Basic J2EE stats for the messaging in the NMR
+ *
+ * @version $Revision$
+ */
+public class MessagingStats extends StatsImpl {
+ private String name;
+ protected CountStatisticImpl inboundExchanges;
+ protected CountStatisticImpl outboundExchanges;
+ protected TimeStatisticImpl inboundExchangeRate;
+ protected TimeStatisticImpl outboundExchangeRate;
+
+ /**
+ * Default Constructor
+ * @param name
+ */
+ public MessagingStats(String name) {
+ this.name = name;
+ inboundExchanges = new CountStatisticImpl("inboundExchanges", "Number of Inbound MessageExchanges");
+ outboundExchanges = new CountStatisticImpl("outboundExchanges", "Number of Outbound MessageExchanges");
+ inboundExchangeRate = new TimeStatisticImpl("inboundExchangeRate", "time taken to process an Exchange");
+ outboundExchangeRate = new TimeStatisticImpl("outboundExchangeRate", "time taken to send an Exchange");
+ addStatistic("inboundExchanges", inboundExchanges);
+ addStatistic("outboundExchanges", outboundExchanges);
+ addStatistic("inboundExchangeRate", inboundExchangeRate);
+ addStatistic("outboundExchangeRate", outboundExchangeRate);
+ }
+
+ /**
+ * Default Constructor
+ * @param name
+ */
+ public MessagingStats(String name, MessagingStats parent) {
+ this.name = name;
+ inboundExchanges = new CountStatisticImpl(parent.inboundExchanges, "inboundExchanges", "Number of Inbound MessageExchanges");
+ outboundExchanges = new CountStatisticImpl(parent.outboundExchanges, "outboundExchanges", "Number of Outbound MessageExchanges");
+ inboundExchangeRate = new TimeStatisticImpl(parent.inboundExchangeRate, "inboundExchangeRate", "time taken to process an Exchange");
+ outboundExchangeRate = new TimeStatisticImpl(parent.outboundExchangeRate, "outboundExchangeRate", "time taken to send an Exchange");
+ addStatistic("inboundExchanges", inboundExchanges);
+ addStatistic("outboundExchanges", outboundExchanges);
+ addStatistic("inboundExchangeRate", inboundExchangeRate);
+ addStatistic("outboundExchangeRate", outboundExchangeRate);
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @return Returns the inboundExchangeRate.
+ */
+ public TimeStatisticImpl getInboundExchangeRate() {
+ return inboundExchangeRate;
+ }
+ /**
+ * @return Returns the inboundExchanges.
+ */
+ public CountStatisticImpl getInboundExchanges() {
+ return inboundExchanges;
+ }
+ /**
+ * @return Returns the outboundExchangeRate.
+ */
+ public TimeStatisticImpl getOutboundExchangeRate() {
+ return outboundExchangeRate;
+ }
+ /**
+ * @return Returns the outboundExchanges.
+ */
+ public CountStatisticImpl getOutboundExchanges() {
+ return outboundExchanges;
+ }
+
+ /**
+ * reset the Stats
+ */
+ public synchronized void reset() {
+ super.reset();
+ inboundExchanges.reset();
+ outboundExchanges.reset();
+ inboundExchangeRate.reset();
+ outboundExchangeRate.reset();
+ }
+
+ /**
+ * @return pretty print
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Statistics: ");
+ buffer.append(name);
+ buffer.append(" { ");
+ buffer.append(inboundExchanges);
+ buffer.append(" ");
+ buffer.append(inboundExchangeRate);
+ buffer.append(" ");
+ buffer.append(outboundExchanges);
+ buffer.append(" ");
+ buffer.append(outboundExchangeRate);
+ buffer.append(" }");
+ return buffer.toString();
+ }
+
+ /**
+ * Dump out to an IndentPrinter
+ *
+ * @param out
+ */
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.println("Statistics: ");
+ out.print(name);
+ out.println(" {");
+ out.incrementIndent();
+ out.println(inboundExchanges);
+ out.printIndent();
+ out.println(inboundExchangeRate);
+ out.printIndent();
+ out.println(outboundExchanges);
+ out.printIndent();
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ }
+
+}
\ No newline at end of file
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/monitoring/MessagingStats.java
------------------------------------------------------------------------------
svn:mime-type = text/plain