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 org.apache.camel.CamelContext; 020import org.apache.camel.api.management.ManagedResource; 021import org.apache.camel.api.management.mbean.ManagedStreamCachingStrategyMBean; 022import org.apache.camel.spi.ManagementStrategy; 023import org.apache.camel.spi.StreamCachingStrategy; 024 025@ManagedResource(description = "Managed StreamCachingStrategy") 026public class ManagedStreamCachingStrategy extends ManagedService implements ManagedStreamCachingStrategyMBean { 027 028 private final CamelContext camelContext; 029 private final StreamCachingStrategy streamCachingStrategy; 030 031 public ManagedStreamCachingStrategy(CamelContext camelContext, StreamCachingStrategy streamCachingStrategy) { 032 super(camelContext, streamCachingStrategy); 033 this.camelContext = camelContext; 034 this.streamCachingStrategy = streamCachingStrategy; 035 } 036 037 public CamelContext getCamelContext() { 038 return camelContext; 039 } 040 041 public StreamCachingStrategy getStreamCachingStrategy() { 042 return streamCachingStrategy; 043 } 044 045 public boolean isEnabled() { 046 return streamCachingStrategy.isEnabled(); 047 } 048 049 public String getSpoolDirectory() { 050 return streamCachingStrategy.getSpoolDirectory().getPath(); 051 } 052 053 public String getSpoolChiper() { 054 return streamCachingStrategy.getSpoolChiper(); 055 } 056 057 public void setSpoolThreshold(long threshold) { 058 streamCachingStrategy.setSpoolThreshold(threshold); 059 } 060 061 public long getSpoolThreshold() { 062 return streamCachingStrategy.getSpoolThreshold(); 063 } 064 065 public void setSpoolUsedHeapMemoryThreshold(int percentage) { 066 streamCachingStrategy.setSpoolUsedHeapMemoryThreshold(percentage); 067 } 068 069 public int getSpoolUsedHeapMemoryThreshold() { 070 return streamCachingStrategy.getSpoolUsedHeapMemoryThreshold(); 071 } 072 073 public void setSpoolUsedHeapMemoryLimit(StreamCachingStrategy.SpoolUsedHeapMemoryLimit limit) { 074 streamCachingStrategy.setSpoolUsedHeapMemoryLimit(limit); 075 } 076 077 public StreamCachingStrategy.SpoolUsedHeapMemoryLimit getSpoolUsedHeapMemoryLimit() { 078 return streamCachingStrategy.getSpoolUsedHeapMemoryLimit(); 079 } 080 081 public void setBufferSize(int bufferSize) { 082 streamCachingStrategy.setBufferSize(bufferSize); 083 } 084 085 public int getBufferSize() { 086 return streamCachingStrategy.getBufferSize(); 087 } 088 089 public void setRemoveSpoolDirectoryWhenStopping(boolean remove) { 090 streamCachingStrategy.setRemoveSpoolDirectoryWhenStopping(remove); 091 } 092 093 public boolean isRemoveSpoolDirectoryWhenStopping() { 094 return streamCachingStrategy.isRemoveSpoolDirectoryWhenStopping(); 095 } 096 097 public void setAnySpoolRules(boolean any) { 098 streamCachingStrategy.setAnySpoolRules(any); 099 } 100 101 public boolean isAnySpoolRules() { 102 return streamCachingStrategy.isAnySpoolRules(); 103 } 104 105 public long getCacheMemoryCounter() { 106 return streamCachingStrategy.getStatistics().getCacheMemoryCounter(); 107 } 108 109 public long getCacheMemorySize() { 110 return streamCachingStrategy.getStatistics().getCacheMemorySize(); 111 } 112 113 public long getCacheMemoryAverageSize() { 114 return streamCachingStrategy.getStatistics().getCacheMemoryAverageSize(); 115 } 116 117 public long getCacheSpoolCounter() { 118 return streamCachingStrategy.getStatistics().getCacheSpoolCounter(); 119 } 120 121 public long getCacheSpoolSize() { 122 return streamCachingStrategy.getStatistics().getCacheSpoolSize(); 123 } 124 125 public long getCacheSpoolAverageSize() { 126 return streamCachingStrategy.getStatistics().getCacheSpoolAverageSize(); 127 } 128 129 public boolean isStatisticsEnabled() { 130 return streamCachingStrategy.getStatistics().isStatisticsEnabled(); 131 } 132 133 public void setStatisticsEnabled(boolean enabled) { 134 streamCachingStrategy.getStatistics().setStatisticsEnabled(enabled); 135 } 136 137 public void resetStatistics() { 138 streamCachingStrategy.getStatistics().reset(); 139 } 140 141}