001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel.management.mbean;
018
019 import java.util.concurrent.TimeUnit;
020
021 import org.apache.camel.CamelContext;
022 import org.apache.camel.impl.ScheduledPollConsumer;
023 import org.springframework.jmx.export.annotation.ManagedAttribute;
024 import org.springframework.jmx.export.annotation.ManagedResource;
025
026 /**
027 * @version $Revision: 810535 $
028 */
029 @ManagedResource(description = "Managed Scheduled Polling Consumer")
030 public class ManagedScheduledPollConsumer extends ManagedConsumer {
031
032 private ScheduledPollConsumer consumer;
033
034 public ManagedScheduledPollConsumer(CamelContext context, ScheduledPollConsumer consumer) {
035 super(context, consumer);
036 this.consumer = consumer;
037 }
038
039 public ScheduledPollConsumer getConsumer() {
040 return consumer;
041 }
042
043 @ManagedAttribute(description = "Scheduled Delay")
044 public long getDelay() {
045 return getConsumer().getDelay();
046 }
047
048 @ManagedAttribute(description = "Scheduled Delay")
049 public void setDelay(long delay) {
050 getConsumer().setDelay(delay);
051 }
052
053 @ManagedAttribute(description = "Scheduled Initial Delay")
054 public long getInitialDelay() {
055 return getConsumer().getInitialDelay();
056 }
057
058 @ManagedAttribute(description = "Scheduled Initial Delay")
059 public void setInitialDelay(long initialDelay) {
060 getConsumer().setInitialDelay(initialDelay);
061 }
062
063 @ManagedAttribute(description = "Scheduled Fixed Delay")
064 public boolean isUseFixedDelay() {
065 return getConsumer().isUseFixedDelay();
066 }
067
068 @ManagedAttribute(description = "Scheduled Fixed Delay")
069 public void setUseFixedDelay(boolean useFixedDelay) {
070 getConsumer().setUseFixedDelay(useFixedDelay);
071 }
072
073 @ManagedAttribute(description = "Scheduled TimeUnit")
074 public String getTimeUnit() {
075 return getConsumer().getTimeUnit().name();
076 }
077
078 @ManagedAttribute(description = "Scheduled TimeUnit")
079 public void setTimeUnit(String timeUnit) {
080 getConsumer().setTimeUnit(TimeUnit.valueOf(timeUnit));
081 }
082 }