You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/11/18 09:22:09 UTC
svn commit: r1036339 - in /camel/trunk/examples/camel-example-jmx: ./
src/main/java/org/apache/camel/example/jmx/
src/main/resources/META-INF/spring/
Author: davsclaus
Date: Thu Nov 18 08:22:08 2010
New Revision: 1036339
URL: http://svn.apache.org/viewvc?rev=1036339&view=rev
Log:
CAMEL-3330: Polished JMX example.
Modified:
camel/trunk/examples/camel-example-jmx/README.txt
camel/trunk/examples/camel-example-jmx/pom.xml
camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/ISimpleMXBean.java
camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/MyRouteBuilder.java
camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/SimpleBean.java
camel/trunk/examples/camel-example-jmx/src/main/resources/META-INF/spring/camel-context.xml
Modified: camel/trunk/examples/camel-example-jmx/README.txt
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-jmx/README.txt?rev=1036339&r1=1036338&r2=1036339&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-jmx/README.txt (original)
+++ camel/trunk/examples/camel-example-jmx/README.txt Thu Nov 18 08:22:08 2010
@@ -1,8 +1,8 @@
JMX Example
===========
-This example shows how to work with the Camel-JMX component. It can be run using
-Maven or Ant.
+This example shows how to work with the Camel-JMX component.
+It can be run using Maven.
The example creates a simple MBean, registers a route to listen for
notification events on that bean and creates another route that calls
@@ -21,13 +21,6 @@ src/main/resources/META-INF/spring
To stop the example hit ctrl + c
-To use log4j as the logging framework add this to the pom.xml:
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
-and log4j.properties is located in src/main/resources
-
If you hit any problems please talk to us on the Camel Forums
http://camel.apache.org/discussion-forums.html
Modified: camel/trunk/examples/camel-example-jmx/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-jmx/pom.xml?rev=1036339&r1=1036338&r2=1036339&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-jmx/pom.xml (original)
+++ camel/trunk/examples/camel-example-jmx/pom.xml Thu Nov 18 08:22:08 2010
@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-
- <!--
- 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.
- -->
-
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -29,7 +27,7 @@
<artifactId>camel-example-jmx</artifactId>
<packaging>bundle</packaging>
<name>Camel :: Example :: JMX</name>
- <description>An example showing how to work with Camel and Spring</description>
+ <description>An example showing how to work with Camel and JMX</description>
<properties>
<camel.osgi.export.pkg>org.apache.camel.example.jmx.*</camel.osgi.export.pkg>
@@ -49,7 +47,6 @@
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jmx</artifactId>
- <version>2.6-SNAPSHOT</version>
</dependency>
<dependency>
@@ -67,49 +64,14 @@
</dependencies>
<build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-resources</phase>
- <goals>
- <goal>resources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <plugins>
<!-- Allows the routes to be run via 'mvn camel:run' -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
-
- <!--
- lets make an executable jar you can then start this up via java -jar
- target/camel-example-spring-*.one-jar.jar -ac
- META-INF/spring/camel-context.xml
- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.camel.jmx.Main</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
</plugins>
</build>
@@ -124,4 +86,5 @@
</plugin>
</plugins>
</reporting>
+
</project>
Modified: camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/ISimpleMXBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/ISimpleMXBean.java?rev=1036339&r1=1036338&r2=1036339&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/ISimpleMXBean.java (original)
+++ camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/ISimpleMXBean.java Thu Nov 18 08:22:08 2010
@@ -18,6 +18,11 @@ package org.apache.camel.example.jmx;
import java.io.Serializable;
+/**
+ * Interface defining the POJO
+ */
public interface ISimpleMXBean extends Serializable {
+
void tick() throws Exception;
+
}
Modified: camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/MyRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/MyRouteBuilder.java?rev=1036339&r1=1036338&r2=1036339&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/MyRouteBuilder.java (original)
+++ camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/MyRouteBuilder.java Thu Nov 18 08:22:08 2010
@@ -16,34 +16,20 @@
*/
package org.apache.camel.example.jmx;
-import org.apache.camel.builder.RouteBuilder;
-
+import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.util.Vector;
+import org.apache.camel.builder.RouteBuilder;
/**
* A simple example router demonstrating the camel-jmx component.
*/
public class MyRouteBuilder extends RouteBuilder {
- static Vector<String> strings = new Vector<String>();
private SimpleBean bean;
private MBeanServer server;
- /**
- * Allow this route to be run as an application
- *
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- MyRouteBuilder mrb = new MyRouteBuilder();
- }
-
-
public MyRouteBuilder() throws Exception {
server = ManagementFactory.getPlatformMBeanServer();
bean = new SimpleBean();
@@ -59,7 +45,6 @@ public class MyRouteBuilder extends Rout
to("log:jmxEvent");
// END SNIPPET: e1
- from("timer:foo?period=6000").
- bean(bean, "tick");
+ from("timer:foo?period=6000").bean(bean, "tick");
}
}
Modified: camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/SimpleBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/SimpleBean.java?rev=1036339&r1=1036338&r2=1036339&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/SimpleBean.java (original)
+++ camel/trunk/examples/camel-example-jmx/src/main/java/org/apache/camel/example/jmx/SimpleBean.java Thu Nov 18 08:22:08 2010
@@ -22,13 +22,13 @@ import javax.management.AttributeChangeN
import javax.management.NotificationBroadcasterSupport;
/**
+ * Our business logic which also is capable of broadcasting JMX notifications,
+ * such as an attribute being changed.
*/
public class SimpleBean extends NotificationBroadcasterSupport implements ISimpleMXBean {
private int sequence;
private int tick;
- private String mStringValue;
-
public void tick() throws Exception {
tick++;
@@ -37,7 +37,7 @@ public class SimpleBean extends Notifica
long timeStamp = date.getTime();
AttributeChangeNotification acn = new AttributeChangeNotification(
- this, sequence++, timeStamp, "attribute changed", "stringValue", "string", tick-1, tick);
+ this, sequence++, timeStamp, "attribute changed", "stringValue", "string", tick - 1, tick);
sendNotification(acn);
}
Modified: camel/trunk/examples/camel-example-jmx/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-jmx/src/main/resources/META-INF/spring/camel-context.xml?rev=1036339&r1=1036338&r2=1036339&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-jmx/src/main/resources/META-INF/spring/camel-context.xml (original)
+++ camel/trunk/examples/camel-example-jmx/src/main/resources/META-INF/spring/camel-context.xml Thu Nov 18 08:22:08 2010
@@ -24,11 +24,12 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <!-- this is Camel -->
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myRouteBuilder"/>
</camelContext>
- <bean id="myRouteBuilder" class="org.apache.camel.example.jmx.MyRouteBuilder">
- </bean>
+ <!-- this is our route -->
+ <bean id="myRouteBuilder" class="org.apache.camel.example.jmx.MyRouteBuilder"/>
</beans>