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.Set; 020 021import org.apache.camel.CamelContext; 022import org.apache.camel.api.management.ManagedResource; 023import org.apache.camel.api.management.mbean.ManagedAggregateProcessorMBean; 024import org.apache.camel.model.AggregateDefinition; 025import org.apache.camel.processor.aggregate.AggregateProcessor; 026import org.apache.camel.spi.ManagementStrategy; 027 028/** 029 * @version 030 */ 031@ManagedResource(description = "Managed AggregateProcessor") 032public class ManagedAggregateProcessor extends ManagedProcessor implements ManagedAggregateProcessorMBean { 033 private final AggregateProcessor processor; 034 035 public ManagedAggregateProcessor(CamelContext context, AggregateProcessor processor, AggregateDefinition definition) { 036 super(context, processor, definition); 037 this.processor = processor; 038 } 039 040 public void init(ManagementStrategy strategy) { 041 super.init(strategy); 042 } 043 044 public AggregateProcessor getProcessor() { 045 return processor; 046 } 047 048 @Override 049 public AggregateDefinition getDefinition() { 050 return (AggregateDefinition) super.getDefinition(); 051 } 052 053 public String getCorrelationExpressionLanguage() { 054 if (getDefinition().getCorrelationExpression() != null) { 055 return getDefinition().getCorrelationExpression().getExpressionType().getLanguage(); 056 } else { 057 return null; 058 } 059 } 060 061 public String getCorrelationExpression() { 062 if (getDefinition().getCorrelationExpression() != null) { 063 return getDefinition().getCorrelationExpression().getExpressionType().getExpression(); 064 } else { 065 return null; 066 } 067 } 068 069 public long getCompletionTimeout() { 070 return processor.getCompletionTimeout(); 071 } 072 073 public String getCompletionTimeoutLanguage() { 074 if (getDefinition().getCompletionTimeoutExpression() != null) { 075 return getDefinition().getCompletionTimeoutExpression().getExpressionType().getLanguage(); 076 } else { 077 return null; 078 } 079 } 080 081 public String getCompletionTimeoutExpression() { 082 if (getDefinition().getCompletionTimeoutExpression() != null) { 083 return getDefinition().getCompletionTimeoutExpression().getExpressionType().getExpression(); 084 } else { 085 return null; 086 } 087 } 088 089 public long getCompletionInterval() { 090 return processor.getCompletionInterval(); 091 } 092 093 public long getCompletionTimeoutCheckerInterval() { 094 return processor.getCompletionTimeoutCheckerInterval(); 095 } 096 097 public int getCompletionSize() { 098 return processor.getCompletionSize(); 099 } 100 101 public String getCompletionSizeExpressionLanguage() { 102 if (getDefinition().getCompletionSizeExpression() != null) { 103 return getDefinition().getCompletionSizeExpression().getExpressionType().getLanguage(); 104 } else { 105 return null; 106 } 107 } 108 109 public String getCompletionSizeExpression() { 110 if (getDefinition().getCompletionSizeExpression() != null) { 111 return getDefinition().getCompletionSizeExpression().getExpressionType().getExpression(); 112 } else { 113 return null; 114 } 115 } 116 117 public boolean isCompletionFromBatchConsumer() { 118 return processor.isCompletionFromBatchConsumer(); 119 } 120 121 public boolean isIgnoreInvalidCorrelationKeys() { 122 return processor.isIgnoreInvalidCorrelationKeys(); 123 } 124 125 public Integer getCloseCorrelationKeyOnCompletion() { 126 return processor.getCloseCorrelationKeyOnCompletion(); 127 } 128 129 public boolean isParallelProcessing() { 130 return processor.isParallelProcessing(); 131 } 132 133 public boolean isOptimisticLocking() { 134 return processor.isOptimisticLocking(); 135 } 136 137 public boolean isEagerCheckCompletion() { 138 return processor.isEagerCheckCompletion(); 139 } 140 141 @Override 142 public String getCompletionPredicateLanguage() { 143 if (getDefinition().getCompletionPredicate() != null) { 144 return getDefinition().getCompletionPredicate().getExpressionType().getLanguage(); 145 } else { 146 return null; 147 } 148 } 149 150 public String getCompletionPredicate() { 151 if (getDefinition().getCompletionPredicate() != null) { 152 return getDefinition().getCompletionPredicate().getExpressionType().getExpression(); 153 } else { 154 return null; 155 } 156 } 157 158 public boolean isDiscardOnCompletionTimeout() { 159 return processor.isDiscardOnCompletionTimeout(); 160 } 161 162 public boolean isForceCompletionOnStop() { 163 return processor.isCompletionFromBatchConsumer(); 164 } 165 166 public boolean isCompleteAllOnStop() { 167 return processor.isCompleteAllOnStop(); 168 } 169 170 public int getInProgressCompleteExchanges() { 171 return processor.getInProgressCompleteExchanges(); 172 } 173 174 public int aggregationRepositoryGroups() { 175 Set<String> keys = processor.getAggregationRepository().getKeys(); 176 if (keys != null) { 177 return keys.size(); 178 } else { 179 return 0; 180 } 181 } 182 183 public int forceCompletionOfGroup(String key) { 184 if (processor.getAggregateController() != null) { 185 return processor.getAggregateController().forceCompletionOfGroup(key); 186 } else { 187 return 0; 188 } 189 } 190 191 public int forceCompletionOfAllGroups() { 192 if (processor.getAggregateController() != null) { 193 return processor.getAggregateController().forceCompletionOfAllGroups(); 194 } else { 195 return 0; 196 } 197 } 198 199 public int getClosedCorrelationKeysCacheSize() { 200 return processor.getClosedCorrelationKeysCacheSize(); 201 } 202 203 public void clearClosedCorrelationKeysCache() { 204 processor.clearClosedCorrelationKeysCache(); 205 } 206 207 public long getTotalIn() { 208 return processor.getStatistics().getTotalIn(); 209 } 210 211 public long getTotalCompleted() { 212 return processor.getStatistics().getTotalCompleted(); 213 } 214 215 public long getCompletedBySize() { 216 return processor.getStatistics().getCompletedBySize(); 217 } 218 219 public long getCompletedByStrategy() { 220 return processor.getStatistics().getCompletedByStrategy(); 221 } 222 223 public long getCompletedByInterval() { 224 return processor.getStatistics().getCompletedByInterval(); 225 } 226 227 public long getCompletedByTimeout() { 228 return processor.getStatistics().getCompletedByTimeout(); 229 } 230 231 public long getCompletedByPredicate() { 232 return processor.getStatistics().getCompletedByPredicate(); 233 } 234 235 public long getCompletedByBatchConsumer() { 236 return processor.getStatistics().getCompletedByBatchConsumer(); 237 } 238 239 public long getCompletedByForce() { 240 return processor.getStatistics().getCompletedByForce(); 241 } 242 243 public void resetStatistics() { 244 processor.getStatistics().reset(); 245 } 246}