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.LoggingLevel; 023import org.apache.camel.api.management.ManagedResource; 024import org.apache.camel.api.management.mbean.ManagedShutdownStrategyMBean; 025import org.apache.camel.spi.ShutdownStrategy; 026 027@ManagedResource(description = "Managed ShutdownStrategy") 028public class ManagedShutdownStrategy extends ManagedService implements ManagedShutdownStrategyMBean { 029 030 private final ShutdownStrategy strategy; 031 032 public ManagedShutdownStrategy(CamelContext context, ShutdownStrategy controller) { 033 super(context, controller); 034 this.strategy = controller; 035 } 036 037 public ShutdownStrategy getShutdownStrategy() { 038 return strategy; 039 } 040 041 @Override 042 public void setTimeout(long timeout) { 043 strategy.setTimeout(timeout); 044 } 045 046 @Override 047 public long getTimeout() { 048 return strategy.getTimeout(); 049 } 050 051 @Override 052 public void setTimeUnit(TimeUnit timeUnit) { 053 strategy.setTimeUnit(timeUnit); 054 } 055 056 @Override 057 public TimeUnit getTimeUnit() { 058 return strategy.getTimeUnit(); 059 } 060 061 @Override 062 public void setSuppressLoggingOnTimeout(boolean suppressLoggingOnTimeout) { 063 strategy.setSuppressLoggingOnTimeout(suppressLoggingOnTimeout); 064 } 065 066 @Override 067 public boolean isSuppressLoggingOnTimeout() { 068 return strategy.isSuppressLoggingOnTimeout(); 069 } 070 071 @Override 072 public void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { 073 strategy.setShutdownNowOnTimeout(shutdownNowOnTimeout); 074 } 075 076 @Override 077 public boolean isShutdownNowOnTimeout() { 078 return strategy.isShutdownNowOnTimeout(); 079 } 080 081 @Override 082 public void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { 083 strategy.setShutdownRoutesInReverseOrder(shutdownRoutesInReverseOrder); 084 } 085 086 @Override 087 public boolean isShutdownRoutesInReverseOrder() { 088 return strategy.isShutdownRoutesInReverseOrder(); 089 } 090 091 @Override 092 public void setLogInflightExchangesOnTimeout(boolean logInflightExchangesOnTimeout) { 093 strategy.setLogInflightExchangesOnTimeout(logInflightExchangesOnTimeout); 094 } 095 096 @Override 097 public boolean isLogInflightExchangesOnTimeout() { 098 return strategy.isLogInflightExchangesOnTimeout(); 099 } 100 101 @Override 102 public boolean isForceShutdown() { 103 return strategy.isForceShutdown(); 104 } 105 106 @Override 107 public boolean isTimeoutOccurred() { 108 return strategy.isTimeoutOccurred(); 109 } 110 111 @Override 112 public String getLoggingLevel() { 113 return strategy.getLoggingLevel().toString(); 114 } 115 116 @Override 117 public void setLoggingLevel(String loggingLevel) { 118 strategy.setLoggingLevel(LoggingLevel.valueOf(loggingLevel)); 119 } 120}