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.getSpoolCipher();
054    }
055
056    @Override
057    public String getSpoolCipher() {
058        return streamCachingStrategy.getSpoolCipher();
059    }
060
061    public void setSpoolThreshold(long threshold) {
062        streamCachingStrategy.setSpoolThreshold(threshold);
063    }
064
065    public long getSpoolThreshold() {
066        return streamCachingStrategy.getSpoolThreshold();
067    }
068
069    public void setSpoolUsedHeapMemoryThreshold(int percentage) {
070        streamCachingStrategy.setSpoolUsedHeapMemoryThreshold(percentage);
071    }
072
073    public int getSpoolUsedHeapMemoryThreshold() {
074        return streamCachingStrategy.getSpoolUsedHeapMemoryThreshold();
075    }
076
077    public void setSpoolUsedHeapMemoryLimit(StreamCachingStrategy.SpoolUsedHeapMemoryLimit limit) {
078        streamCachingStrategy.setSpoolUsedHeapMemoryLimit(limit);
079    }
080
081    public StreamCachingStrategy.SpoolUsedHeapMemoryLimit getSpoolUsedHeapMemoryLimit() {
082        return streamCachingStrategy.getSpoolUsedHeapMemoryLimit();
083    }
084
085    public void setBufferSize(int bufferSize) {
086        streamCachingStrategy.setBufferSize(bufferSize);
087    }
088
089    public int getBufferSize() {
090        return streamCachingStrategy.getBufferSize();
091    }
092
093    public void setRemoveSpoolDirectoryWhenStopping(boolean remove) {
094        streamCachingStrategy.setRemoveSpoolDirectoryWhenStopping(remove);
095    }
096
097    public boolean isRemoveSpoolDirectoryWhenStopping() {
098        return streamCachingStrategy.isRemoveSpoolDirectoryWhenStopping();
099    }
100
101    public void setAnySpoolRules(boolean any) {
102        streamCachingStrategy.setAnySpoolRules(any);
103    }
104
105    public boolean isAnySpoolRules() {
106        return streamCachingStrategy.isAnySpoolRules();
107    }
108
109    public long getCacheMemoryCounter() {
110        return streamCachingStrategy.getStatistics().getCacheMemoryCounter();
111    }
112
113    public long getCacheMemorySize() {
114        return streamCachingStrategy.getStatistics().getCacheMemorySize();
115    }
116
117    public long getCacheMemoryAverageSize() {
118        return streamCachingStrategy.getStatistics().getCacheMemoryAverageSize();
119    }
120
121    public long getCacheSpoolCounter() {
122        return streamCachingStrategy.getStatistics().getCacheSpoolCounter();
123    }
124
125    public long getCacheSpoolSize() {
126        return streamCachingStrategy.getStatistics().getCacheSpoolSize();
127    }
128
129    public long getCacheSpoolAverageSize() {
130        return streamCachingStrategy.getStatistics().getCacheSpoolAverageSize();
131    }
132
133    public boolean isStatisticsEnabled() {
134        return streamCachingStrategy.getStatistics().isStatisticsEnabled();
135    }
136
137    public void setStatisticsEnabled(boolean enabled) {
138        streamCachingStrategy.getStatistics().setStatisticsEnabled(enabled);
139    }
140
141    public void resetStatistics() {
142        streamCachingStrategy.getStatistics().reset();
143    }
144
145}