Author: davsclaus
Date: Sun Jul 31 19:33:46 2011
New Revision: 1152620
URL: http://svn.apache.org/viewvc?rev=1152620&view=rev
Log:
CAMEL-4250: Removed depdendency of commons-management.
Added:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultStatistic.java
camel/trunk/camel-core/src/main/java/org/apache/camel/management/Statistic.java
Modified:
camel/trunk/apache-camel/pom.xml
camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
camel/trunk/camel-core/pom.xml
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java
camel/trunk/parent/pom.xml
camel/trunk/platforms/karaf/features/pom.xml
camel/trunk/platforms/karaf/features/src/main/resources/features.xml
Modified: camel/trunk/apache-camel/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Sun Jul 31 19:33:46 2011
@@ -528,10 +528,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.fusesource.commonman</groupId>
- <artifactId>commons-management</artifactId>
- </dependency>
<dependency>
<groupId>org.springframework</groupId>
Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Sun Jul 31
19:33:46 2011
@@ -136,9 +136,8 @@
<include>org.apache.camel:camel-xmpp</include>
<include>org.apache.camel:camel-xstream</include>
<include>org.apache.camel.karaf:camel-karaf-commands</include>
- <!-- these two jars are mandatory -->
+ <!-- this jar is mandatory -->
<include>org.slf4j:slf4j-api</include>
- <include>org.fusesource.commonman:commons-management</include>
</includes>
</dependencySet>
<dependencySet>
Modified: camel/trunk/camel-core/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/pom.xml?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
--- camel/trunk/camel-core/pom.xml (original)
+++ camel/trunk/camel-core/pom.xml Sun Jul 31 19:33:46 2011
@@ -64,12 +64,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>
- <!-- required dependencies by camel-core -->
- <dependency>
- <groupId>org.fusesource.commonman</groupId>
- <artifactId>commons-management</artifactId>
- </dependency>
-
<!-- to allow Spring annotations to be used for management -->
<dependency>
<groupId>org.springframework</groupId>
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
Sun Jul 31 19:33:46 2011
@@ -31,7 +31,6 @@ import org.apache.camel.spi.ManagementNa
import org.apache.camel.spi.ManagementObjectStrategy;
import org.apache.camel.spi.ManagementStrategy;
import org.apache.camel.util.ServiceHelper;
-import org.fusesource.commons.management.Statistic;
/**
* A default management strategy that does <b>not</b> manage.
@@ -127,7 +126,7 @@ public class DefaultManagementStrategy i
// noop
}
- public void manageNamedObject(Object managedObject, Object preferedName)
throws Exception {
+ public void manageNamedObject(Object managedObject, Object preferredName)
throws Exception {
// noop
}
Added:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultStatistic.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultStatistic.java?rev=1152620&view=auto
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultStatistic.java
(added)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultStatistic.java
Sun Jul 31 19:33:46 2011
@@ -0,0 +1,89 @@
+/**
+ * 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.camel.management;
+
+/**
+ * Default implementation of {@link Statistic}
+ */
+public class DefaultStatistic implements Statistic {
+
+ private final Statistic.UpdateMode updateMode;
+ private long value;
+ private long updateCount;
+
+ /**
+ * Instantiates a new statistic.
+ *
+ * @param updateMode The statistic update mode.
+ */
+ public DefaultStatistic(Statistic.UpdateMode updateMode) {
+ this.updateMode = updateMode;
+ }
+
+ public synchronized void updateValue(long newValue) {
+ switch (this.updateMode) {
+ case COUNTER:
+ this.value += newValue;
+ break;
+ case VALUE:
+ this.value = newValue;
+ break;
+ case DIFFERENCE:
+ this.value -= newValue;
+ if (this.value < 0) {
+ this.value = -this.value;
+ }
+ break;
+ case MAXIMUM:
+ // initialize value at first time
+ if (this.updateCount == 0 || this.value < newValue) {
+ this.value = newValue;
+ }
+ break;
+ case MINIMUM:
+ // initialize value at first time
+ if (this.updateCount == 0 || this.value > newValue) {
+ this.value = newValue;
+ }
+ break;
+ default:
+ }
+ this.updateCount++;
+ }
+
+ public synchronized void increment() {
+ updateValue(1);
+ }
+
+ public synchronized long getValue() {
+ return this.value;
+ }
+
+ public synchronized long getUpdateCount() {
+ return this.updateCount;
+ }
+
+ public synchronized void reset() {
+ this.value = 0;
+ this.updateCount = 0;
+ }
+
+ public String toString() {
+ return "" + value;
+ }
+
+}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/management/ManagedManagementStrategy.java
Sun Jul 31 19:33:46 2011
@@ -35,9 +35,6 @@ import org.apache.camel.management.mbean
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.spi.ManagementAgent;
-import org.fusesource.commons.management.Statistic;
-import org.fusesource.commons.management.basic.StatisticImpl;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,8 +67,8 @@ public class ManagedManagementStrategy e
manageNamedObject(managedObject, null);
}
- public void manageNamedObject(Object managedObject, Object preferedName)
throws Exception {
- ObjectName objectName = getObjectName(managedObject, preferedName);
+ public void manageNamedObject(Object managedObject, Object preferredName)
throws Exception {
+ ObjectName objectName = getObjectName(managedObject, preferredName);
if (objectName != null) {
getManagementAgent().register(managedObject, objectName);
@@ -145,9 +142,9 @@ public class ManagedManagementStrategy e
}
}
- public boolean isManaged(Object managableObject, Object name) {
+ public boolean isManaged(Object managedObject, Object name) {
try {
- ObjectName objectName = getObjectName(managableObject, name);
+ ObjectName objectName = getObjectName(managedObject, name);
if (objectName != null) {
return getManagementAgent().isRegistered(objectName);
}
@@ -164,7 +161,7 @@ public class ManagedManagementStrategy e
@Override
public Statistic createStatistic(String name, Object owner,
Statistic.UpdateMode updateMode) {
- return new StatisticImpl(updateMode);
+ return new DefaultStatistic(updateMode);
}
private ObjectName getObjectName(Object managedObject, Object
preferedName) throws Exception {
Added:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/Statistic.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/Statistic.java?rev=1152620&view=auto
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/management/Statistic.java
(added)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/management/Statistic.java
Sun Jul 31 19:33:46 2011
@@ -0,0 +1,76 @@
+/**
+ * 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.camel.management;
+
+/**
+ * For gathering basic statistics
+ */
+public interface Statistic {
+
+ /**
+ * Statistics mode
+ * <ul>
+ * <li>VALUE - A statistic with this update mode is a simple value that is
a straight forward
+ * representation of the updated value.</li>
+ * <li>DIFFERENCE - A statistic with this update mode is a value that
represents the difference
+ * between the last two recorded values (or the initial value if two
updates have
+ * not been recorded).</li>
+ * <li>COUNTER - A statistic with this update mode interprets updates as
increments (positive values)
+ * or decrements (negative values) to the current value.</li>
+ * <li>MAXIMUM - A statistic with this update mode is a value that
represents the maximum value
+ * amongst the update values applied to this statistic.</li>
+ * <li>MINIMUM - A statistic with this update mode is a value that
represents the minimum value
+ * amongst the update values applied to this statistic.</li>
+ * <ul>
+ */
+ public enum UpdateMode {
+ VALUE, DIFFERENCE, COUNTER, MAXIMUM, MINIMUM
+ }
+
+ /**
+ * Shorthand for updateValue(1).
+ */
+ void increment();
+
+ /**
+ * Update statistic value. The update will be applied according to the
+ * {@link UpdateMode}
+ *
+ * @param value the value
+ */
+ void updateValue(long value);
+
+ /**
+ * Gets the current value of the statistic since the last reset.
+ *
+ * @return the value
+ */
+ long getValue();
+
+ /**
+ * Gets the number of times the statistic has been updated since the last
reset.
+ *
+ * @return the update count
+ */
+ long getUpdateCount();
+
+ /**
+ * Resets the statistic's value and update count to zero.
+ */
+ void reset();
+
+}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
Sun Jul 31 19:33:46 2011
@@ -16,8 +16,8 @@
*/
package org.apache.camel.management.mbean;
+import org.apache.camel.management.Statistic;
import org.apache.camel.spi.ManagementStrategy;
-import org.fusesource.commons.management.Statistic;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
Sun Jul 31 19:33:46 2011
@@ -20,9 +20,9 @@ import java.util.Date;
import org.apache.camel.Exchange;
import org.apache.camel.management.PerformanceCounter;
+import org.apache.camel.management.Statistic;
import org.apache.camel.spi.ManagementStrategy;
import org.apache.camel.util.ExchangeHelper;
-import org.fusesource.commons.management.Statistic;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java
Sun Jul 31 19:33:46 2011
@@ -16,10 +16,12 @@
*/
package org.apache.camel.spi;
+import java.util.EventObject;
import java.util.List;
import org.apache.camel.ManagementStatisticsLevel;
import org.apache.camel.Service;
+import org.apache.camel.management.Statistic;
import org.apache.camel.model.ProcessorDefinition;
/**
@@ -33,7 +35,86 @@ import org.apache.camel.model.ProcessorD
* @see org.apache.camel.spi.ManagementAgent
* @version
*/
-public interface ManagementStrategy extends
org.fusesource.commons.management.ManagementStrategy, Service {
+public interface ManagementStrategy extends Service {
+
+ /**
+ * Adds a managed object allowing the ManagementStrategy implementation to
record or expose
+ * the object as it sees fit.
+ *
+ * @param managedObject the managed object
+ * @throws Exception can be thrown if the object could not be added
+ */
+ void manageObject(Object managedObject) throws Exception;
+
+ /**
+ * Adds a managed object allowing the ManagementStrategy implementation
+ * to record or expose the object as it sees fit.
+ *
+ * @param managedObject the managed object
+ * @param preferredName representing the preferred name, maybe a String,
or a JMX ObjectName
+ * @throws Exception can be thrown if the object could not be added
+ */
+ void manageNamedObject(Object managedObject, Object preferredName) throws
Exception;
+
+ /**
+ * Construct an object name, where either the object to be managed and/or
+ * a custom name component are provided
+ *
+ * @param managedObject the object to be managed
+ * @param customName a custom name component
+ * @param nameType the name type required
+ * @return an object name of the required type if supported, otherwise
<tt>null</tt>
+ * @throws Exception can be thrown if the object name could not be created
+ */
+ <T> T getManagedObjectName(Object managedObject, String customName,
Class<T> nameType) throws Exception;
+
+ /**
+ * Removes the managed object.
+ *
+ * @param managedObject the managed object
+ * @throws Exception can be thrown if the object could not be removed
+ */
+ void unmanageObject(Object managedObject) throws Exception;
+
+ /**
+ * Removes a managed object by name.
+ *
+ * @param name an object name previously created by this strategy.
+ * @throws Exception can be thrown if the object could not be removed
+ */
+ void unmanageNamedObject(Object name) throws Exception;
+
+ /**
+ * Determines if an object or name is managed.
+ *
+ * @param managedObject the object to consider
+ * @param name the name to consider
+ * @return <tt>true</tt> if the given object or name is managed
+ */
+ boolean isManaged(Object managedObject, Object name);
+
+ /**
+ * Management events provide a single model for capturing information
about execution points in the
+ * application code. Management strategy implementations decide if and
where to record these events.
+ * Applications communicate events to management strategy implementations
via the notify(EventObject)
+ * method.
+ *
+ * @param event the event
+ * @throws Exception can be thrown if the notification failed
+ */
+ void notify(EventObject event) throws Exception;
+
+ /**
+ * Creates a statistic; a representation of raw statistical data.
+ *
+ * @param name The unique name assigned to the statistic usage.
+ * @param owner The object whose identity is to be associated with the
metric.
+ * @param updateMode The update mode to be assigned to the returned
statistic.
+ * @return the statistic
+ *
+ * @see Statistic.UpdateMode
+ */
+ Statistic createStatistic(String name, Object owner, Statistic.UpdateMode
updateMode);
/**
* Gets the event notifiers.
@@ -164,4 +245,5 @@ public interface ManagementStrategy exte
* @return the level
*/
ManagementStatisticsLevel getStatisticsLevel();
+
}
Modified: camel/trunk/parent/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Sun Jul 31 19:33:46 2011
@@ -66,7 +66,6 @@
<ehcache-bundle-version>2.3.0_3</ehcache-bundle-version>
<flatpack-version>3.2.0_1</flatpack-version>
<ftpserver-version>1.0.5</ftpserver-version>
- <fuse-commons-management-version>1.0</fuse-commons-management-version>
<freemarker-version>2.3.18</freemarker-version>
<geronimo-el-spec-version>1.0.1</geronimo-el-spec-version>
<geronimo-j2ee-connector-spec-version>2.0.0</geronimo-j2ee-connector-spec-version>
@@ -892,13 +891,6 @@
<version>${project.version}</version>
</dependency>
- <!-- Required dependencies -->
- <dependency>
- <groupId>org.fusesource.commonman</groupId>
- <artifactId>commons-management</artifactId>
- <version>${fuse-commons-management-version}</version>
- </dependency>
-
<!-- optional dependencies -->
<dependency>
<groupId>javax.xml.bind</groupId>
Modified: camel/trunk/platforms/karaf/features/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/pom.xml?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/pom.xml (original)
+++ camel/trunk/platforms/karaf/features/pom.xml Sun Jul 31 19:33:46 2011
@@ -54,7 +54,6 @@
<commons-io-bundle-version>1.3.2_3</commons-io-bundle-version>
<commons-jxpath-version>1.3</commons-jxpath-version>
<commons-net-version>2.2</commons-net-version>
- <commons-management-version>1.0</commons-management-version>
<commons-math-version>2.2</commons-math-version>
<commons-pool-bundle-version>1.5.4_1</commons-pool-bundle-version>
<dom4j-bundle-version>1.6.1_2</dom4j-bundle-version>
Modified: camel/trunk/platforms/karaf/features/src/main/resources/features.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/src/main/resources/features.xml?rev=1152620&r1=1152619&r2=1152620&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/src/main/resources/features.xml
(original)
+++ camel/trunk/platforms/karaf/features/src/main/resources/features.xml Sun
Jul 31 19:33:46 2011
@@ -27,7 +27,6 @@
<bundle
dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.2/${servicemix-specs-version}</bundle>
<bundle
dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/${servicemix-specs-version}</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/${jaxb-bundle-version}</bundle>
-
<bundle>mvn:org.fusesource.commonman/commons-management/${commons-management-version}</bundle>
<bundle>mvn:org.apache.camel/camel-core/${pom.version}</bundle>
<bundle>mvn:org.apache.camel.karaf/camel-karaf-commands/${pom.version}</bundle>
</feature>