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