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.ManagedResequencerMBean; 022import org.apache.camel.model.ProcessorDefinition; 023import org.apache.camel.processor.Resequencer; 024import org.apache.camel.processor.StreamResequencer; 025 026@ManagedResource(description = "Managed Resequencer") 027public class ManagedResequencer extends ManagedProcessor implements ManagedResequencerMBean { 028 private final Resequencer processor; 029 private final StreamResequencer streamProcessor; 030 private final String expression; 031 032 public ManagedResequencer(CamelContext context, Resequencer processor, ProcessorDefinition<?> definition) { 033 super(context, processor, definition); 034 this.processor = processor; 035 this.streamProcessor = null; 036 this.expression = processor.getExpression().toString(); 037 } 038 039 public ManagedResequencer(CamelContext context, StreamResequencer processor, ProcessorDefinition<?> definition) { 040 super(context, processor, definition); 041 this.processor = null; 042 this.streamProcessor = processor; 043 this.expression = streamProcessor.getExpression().toString(); 044 } 045 046 @Override 047 public String getExpression() { 048 return expression; 049 } 050 051 @Override 052 public Integer getBatchSize() { 053 if (processor != null) { 054 return processor.getBatchSize(); 055 } else { 056 return null; 057 } 058 } 059 060 @Override 061 public Long getTimeout() { 062 if (processor != null) { 063 return processor.getBatchTimeout(); 064 } else { 065 return streamProcessor.getTimeout(); 066 } 067 } 068 069 @Override 070 public Boolean isAllowDuplicates() { 071 if (processor != null) { 072 return processor.isAllowDuplicates(); 073 } else { 074 return null; 075 } 076 } 077 078 @Override 079 public Boolean isReverse() { 080 if (processor != null) { 081 return processor.isReverse(); 082 } else { 083 return null; 084 } 085 } 086 087 @Override 088 public Boolean isIgnoreInvalidExchanges() { 089 if (processor != null) { 090 return processor.isIgnoreInvalidExchanges(); 091 } else { 092 return streamProcessor.isIgnoreInvalidExchanges(); 093 } 094 } 095 096 @Override 097 public Integer getCapacity() { 098 if (processor != null) { 099 return null; 100 } else { 101 return streamProcessor.getCapacity(); 102 } 103 } 104 105 @Override 106 public Boolean isRejectOld() { 107 if (processor != null) { 108 return null; 109 } else { 110 return streamProcessor.isRejectOld(); 111 } 112 } 113}