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     */
017    package org.apache.camel.management.mbean;
018    
019    import org.apache.camel.CamelContext;
020    import org.apache.camel.api.management.ManagedResource;
021    import org.apache.camel.api.management.mbean.ManagedProducerCacheMBean;
022    import org.apache.camel.impl.ProducerCache;
023    
024    /**
025     * @version 
026     */
027    @ManagedResource(description = "Managed ProducerCache")
028    public class ManagedProducerCache extends ManagedService implements ManagedProducerCacheMBean {
029        private final ProducerCache producerCache;
030    
031        public ManagedProducerCache(CamelContext context, ProducerCache producerCache) {
032            super(context, producerCache);
033            this.producerCache = producerCache;
034        }
035    
036        public ProducerCache getProducerCache() {
037            return producerCache;
038        }
039    
040        public String getSource() {
041            if (producerCache.getSource() != null) {
042                return producerCache.getSource().toString();
043            }
044            return null;
045        }
046    
047        public Integer getSize() {
048            return producerCache.size();
049        }
050    
051        public Integer getMaximumCacheSize() {
052            return producerCache.getCapacity();
053        }
054    
055        public Long getHits() {
056            return producerCache.getHits();
057        }
058    
059        public Long getMisses() {
060            return producerCache.getMisses();
061        }
062    
063        public Long getEvicted() {
064            return producerCache.getEvicted();
065        }
066    
067        public void resetStatistics() {
068            producerCache.resetCacheStatistics();
069        }
070    
071        public void purge() {
072            producerCache.purge();
073        }
074    
075        public Boolean isEventNotifierEnabled() {
076            return producerCache.isEventNotifierEnabled();
077        }
078    }