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 029 private final String expression; 030 031 public ManagedResequencer(CamelContext context, Resequencer processor, ProcessorDefinition<?> definition) { 032 super(context, processor, definition); 033 this.expression = processor.getExpression().toString(); 034 } 035 036 public ManagedResequencer(CamelContext context, StreamResequencer processor, ProcessorDefinition<?> definition) { 037 super(context, processor, definition); 038 this.expression = processor.getExpression().toString(); 039 } 040 041 @Override 042 public String getExpression() { 043 return expression; 044 } 045 046 private Resequencer getResequencer() { 047 if (getProcessor() instanceof Resequencer r) { 048 return r; 049 } 050 return null; 051 } 052 053 private StreamResequencer getStreamResequencer() { 054 if (getProcessor() instanceof StreamResequencer r) { 055 return r; 056 } 057 return null; 058 } 059 060 @Override 061 public Integer getBatchSize() { 062 if (getResequencer() != null) { 063 return getResequencer().getBatchSize(); 064 } else { 065 return null; 066 } 067 } 068 069 @Override 070 public Long getTimeout() { 071 if (getResequencer() != null) { 072 return getResequencer().getBatchTimeout(); 073 } else { 074 return getStreamResequencer().getTimeout(); 075 } 076 } 077 078 @Override 079 public Boolean isAllowDuplicates() { 080 if (getResequencer() != null) { 081 return getResequencer().isAllowDuplicates(); 082 } else { 083 return null; 084 } 085 } 086 087 @Override 088 public Boolean isReverse() { 089 if (getResequencer() != null) { 090 return getResequencer().isReverse(); 091 } else { 092 return null; 093 } 094 } 095 096 @Override 097 public Boolean isIgnoreInvalidExchanges() { 098 if (getResequencer() != null) { 099 return getResequencer().isIgnoreInvalidExchanges(); 100 } else { 101 return getStreamResequencer().isIgnoreInvalidExchanges(); 102 } 103 } 104 105 @Override 106 public Integer getCapacity() { 107 if (getResequencer() != null) { 108 return null; 109 } else { 110 return getStreamResequencer().getCapacity(); 111 } 112 } 113 114 @Override 115 public Boolean isRejectOld() { 116 if (getResequencer() != null) { 117 return null; 118 } else { 119 return getStreamResequencer().isRejectOld(); 120 } 121 } 122}