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 2009/08/31 14:58:27 UTC
svn commit: r809568 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/management/
main/java/org/apache/camel/management/mbean/
main/java/org/apache/camel/processor/ test/java/org/apache/camel/management/
Author: davsclaus
Date: Mon Aug 31 12:58:27 2009
New Revision: 809568
URL: http://svn.apache.org/viewvc?rev=809568&view=rev
Log:
CAMEL-1933: Overhaul of JMX. Added management of timer endpoint. Fixed CS.
Added:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java (with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java (with props)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java?rev=809568&r1=809567&r2=809568&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java Mon Aug 31 12:58:27 2009
@@ -32,6 +32,7 @@
import org.apache.camel.Producer;
import org.apache.camel.Route;
import org.apache.camel.Service;
+import org.apache.camel.component.timer.TimerEndpoint;
import org.apache.camel.impl.EventDrivenConsumerRoute;
import org.apache.camel.impl.ScheduledPollConsumer;
import org.apache.camel.management.mbean.ManagedBrowsableEndpoint;
@@ -47,6 +48,7 @@
import org.apache.camel.management.mbean.ManagedScheduledPollConsumer;
import org.apache.camel.management.mbean.ManagedSendProcessor;
import org.apache.camel.management.mbean.ManagedThrottler;
+import org.apache.camel.management.mbean.ManagedTimerEndpoint;
import org.apache.camel.management.mbean.ManagedTracer;
import org.apache.camel.model.AOPDefinition;
import org.apache.camel.model.InterceptDefinition;
@@ -190,6 +192,8 @@
ManagedEndpoint me;
if (endpoint instanceof BrowsableEndpoint) {
me = new ManagedBrowsableEndpoint((BrowsableEndpoint) endpoint);
+ } else if (endpoint instanceof TimerEndpoint) {
+ me = new ManagedTimerEndpoint((TimerEndpoint) endpoint);
} else {
me = new ManagedEndpoint(endpoint);
}
@@ -225,6 +229,8 @@
ManagedEndpoint me;
if (endpoint instanceof BrowsableEndpoint) {
me = new ManagedBrowsableEndpoint((BrowsableEndpoint) endpoint);
+ } else if (endpoint instanceof TimerEndpoint) {
+ me = new ManagedTimerEndpoint((TimerEndpoint) endpoint);
} else {
me = new ManagedEndpoint(endpoint);
}
Added: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java?rev=809568&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java Mon Aug 31 12:58:27 2009
@@ -0,0 +1,91 @@
+/**
+ * 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.mbean;
+
+import org.apache.camel.component.timer.TimerEndpoint;
+import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedResource;
+
+/**
+ * @version $Revision$
+ */
+
+@ManagedResource(description = "Managed Timer Endpoint")
+public class ManagedTimerEndpoint extends ManagedEndpoint {
+
+ private TimerEndpoint endpoint;
+
+ public ManagedTimerEndpoint(TimerEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ public TimerEndpoint getEndpoint() {
+ return endpoint;
+ }
+
+ @ManagedAttribute(description = "Timer Name")
+ public String getTimerName() {
+ return getEndpoint().getTimerName();
+ }
+
+ @ManagedAttribute(description = "Timer Name")
+ public void setTimerName(String timerName) {
+ getEndpoint().setTimerName(timerName);
+ }
+
+ @ManagedAttribute(description = "Timer Daemon")
+ public boolean getDaemon() {
+ return getEndpoint().isDaemon();
+ }
+
+ @ManagedAttribute(description = "Timer Daemon")
+ public void setDaemon(boolean daemon) {
+ getEndpoint().setDaemon(daemon);
+ }
+
+ @ManagedAttribute(description = "Timer Delay")
+ public long getDelay() {
+ return getEndpoint().getDelay();
+ }
+
+ @ManagedAttribute(description = "Timer Delay")
+ public void setDelay(long delay) {
+ getEndpoint().setDelay(delay);
+ }
+
+ @ManagedAttribute(description = "Timer FixedRate")
+ public boolean getFixedRate() {
+ return getEndpoint().isFixedRate();
+ }
+
+ @ManagedAttribute(description = "Timer FixedRate")
+ public void setFixedRate(boolean fixedRate) {
+ getEndpoint().setFixedRate(fixedRate);
+ }
+
+ @ManagedAttribute(description = "Timer Period")
+ public long getPeriod() {
+ return getEndpoint().getPeriod();
+ }
+
+ @ManagedAttribute(description = "Timer Period")
+ public void setPeriod(long period) {
+ getEndpoint().setPeriod(period);
+ }
+
+}
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTimerEndpoint.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java?rev=809568&r1=809567&r2=809568&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/PollEnricher.java Mon Aug 31 12:58:27 2009
@@ -24,9 +24,9 @@
import org.apache.camel.impl.ServiceSupport;
import org.apache.camel.processor.aggregate.AggregationStrategy;
import org.apache.camel.util.ExchangeHelper;
-import static org.apache.camel.util.ExchangeHelper.copyResultsPreservePattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.apache.camel.util.ExchangeHelper.copyResultsPreservePattern;
/**
* A content enricher that enriches input data by first obtaining additional
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java?rev=809568&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java Mon Aug 31 12:58:27 2009
@@ -0,0 +1,84 @@
+/**
+ * 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;
+
+import java.util.Set;
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedTimerTest extends ContextTestSupport {
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = new DefaultCamelContext();
+ DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+ naming.setHostName("localhost");
+ naming.setDomainName("org.apache.camel");
+ return context;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testTimer() throws Exception {
+ MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+ ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"timer://foo\\?delay=5000&period=8000\"");
+ assertEquals("Should be registered", true, mbeanServer.isRegistered(name));
+
+ Long period = (Long) mbeanServer.getAttribute(name, "Period");
+ assertEquals(8000, period.longValue());
+
+ // change period
+ mbeanServer.setAttribute(name, new Attribute("Period", 1000));
+ mbeanServer.setAttribute(name, new Attribute("Delay", 0));
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.reset();
+
+ // restart consumer
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=consumers,*"), null);
+ assertEquals(1, set.size());
+ ObjectName on = set.iterator().next();
+ mbeanServer.invoke(on, "stop", null, null);
+ mbeanServer.invoke(on, "start", null, null);
+
+ // start and we should be done in at most 3 second
+ mock.expectedMinimumMessageCount(3);
+ mock.setResultWaitTime(3900);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("timer://foo?delay=5000&period=8000").to("mock:result");
+ }
+ };
+ }
+
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTimerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date