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 */ 017package org.apache.camel.management.mbean; 018 019import java.util.concurrent.TimeUnit; 020 021import org.apache.camel.CamelContext; 022import org.apache.camel.api.management.ManagedResource; 023import org.apache.camel.api.management.mbean.ManagedSchedulePollConsumerMBean; 024import org.apache.camel.support.ScheduledPollConsumer; 025 026@ManagedResource(description = "Managed Scheduled Polling Consumer") 027public class ManagedScheduledPollConsumer extends ManagedConsumer implements ManagedSchedulePollConsumerMBean { 028 private final ScheduledPollConsumer consumer; 029 030 public ManagedScheduledPollConsumer(CamelContext context, ScheduledPollConsumer consumer) { 031 super(context, consumer); 032 this.consumer = consumer; 033 } 034 035 public ScheduledPollConsumer getConsumer() { 036 return consumer; 037 } 038 039 public long getDelay() { 040 return getConsumer().getDelay(); 041 } 042 043 public void setDelay(long delay) { 044 getConsumer().setDelay(delay); 045 } 046 047 public long getInitialDelay() { 048 return getConsumer().getInitialDelay(); 049 } 050 051 public void setInitialDelay(long initialDelay) { 052 getConsumer().setInitialDelay(initialDelay); 053 } 054 055 public boolean isUseFixedDelay() { 056 return getConsumer().isUseFixedDelay(); 057 } 058 059 public void setUseFixedDelay(boolean useFixedDelay) { 060 getConsumer().setUseFixedDelay(useFixedDelay); 061 } 062 063 public String getTimeUnit() { 064 return getConsumer().getTimeUnit().name(); 065 } 066 067 public void setTimeUnit(String timeUnit) { 068 getConsumer().setTimeUnit(TimeUnit.valueOf(timeUnit)); 069 } 070 071 public boolean isSchedulerStarted() { 072 return getConsumer().isSchedulerStarted(); 073 } 074 075 public void startScheduler() { 076 getConsumer().startScheduler(); 077 } 078 079 public String getSchedulerClassName() { 080 return getConsumer().getScheduler().getClass().getName(); 081 } 082 083 public int getBackoffMultiplier() { 084 return getConsumer().getBackoffMultiplier(); 085 } 086 087 public int getBackoffIdleThreshold() { 088 return getConsumer().getBackoffIdleThreshold(); 089 } 090 091 public int getBackoffErrorThreshold() { 092 return getConsumer().getBackoffErrorThreshold(); 093 } 094 095 public int getBackoffCounter() { 096 return getConsumer().getBackoffCounter(); 097 } 098}