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.spi; 018 019import java.util.List; 020 021import org.apache.camel.NamedNode; 022import org.apache.camel.Service; 023 024/** 025 * Strategy for management. 026 * <p/> 027 * This is totally pluggable allowing to use a custom or 3rd party management implementation with Camel. 028 * 029 * @see org.apache.camel.spi.EventNotifier 030 * @see org.apache.camel.spi.EventFactory 031 * @see ManagementObjectNameStrategy 032 * @see org.apache.camel.spi.ManagementAgent 033 */ 034public interface ManagementStrategy extends Service { 035 036 /** 037 * Adds a managed object allowing the ManagementStrategy implementation to record or expose 038 * the object as it sees fit. 039 * 040 * @param managedObject the managed object 041 * @throws Exception can be thrown if the object could not be added 042 */ 043 void manageObject(Object managedObject) throws Exception; 044 045 /** 046 * Removes the managed object. 047 * 048 * @param managedObject the managed object 049 * @throws Exception can be thrown if the object could not be removed 050 */ 051 void unmanageObject(Object managedObject) throws Exception; 052 053 /** 054 * Determines if an object or name is managed. 055 * 056 * @param managedObject the object to consider 057 * @return <tt>true</tt> if the given object is managed 058 */ 059 boolean isManaged(Object managedObject); 060 061 /** 062 * Determines if an object or name is managed. 063 * 064 * @param name the name to consider 065 * @return <tt>true</tt> if the given name is managed 066 */ 067 boolean isManagedName(Object name); 068 069 /** 070 * Management events provide a single model for capturing information about execution points in the 071 * application code. Management strategy implementations decide if and where to record these events. 072 * Applications communicate events to management strategy implementations via the notify(EventObject) 073 * method. 074 * 075 * @param event the event 076 * @throws Exception can be thrown if the notification failed 077 */ 078 void notify(CamelEvent event) throws Exception; 079 080 /** 081 * Gets the event notifiers. 082 * 083 * @return event notifiers 084 */ 085 List<EventNotifier> getEventNotifiers(); 086 087 /** 088 * Adds the event notifier to use. 089 * <p/> 090 * Ensure the event notifier has been started if its a {@link Service}, as otherwise 091 * it would not be used. 092 * 093 * @param eventNotifier event notifier 094 */ 095 void addEventNotifier(EventNotifier eventNotifier); 096 097 /** 098 * Removes the event notifier 099 * 100 * @param eventNotifier event notifier to remove 101 * @return <tt>true</tt> if removed, <tt>false</tt> if already removed 102 */ 103 boolean removeEventNotifier(EventNotifier eventNotifier); 104 105 /** 106 * Gets the event factory 107 * 108 * @return event factory 109 */ 110 EventFactory getEventFactory(); 111 112 /** 113 * Sets the event factory to use 114 * 115 * @param eventFactory event factory 116 */ 117 void setEventFactory(EventFactory eventFactory); 118 119 /** 120 * Gets the naming strategy to use 121 * 122 * @return naming strategy 123 */ 124 ManagementObjectNameStrategy getManagementObjectNameStrategy(); 125 126 /** 127 * Sets the naming strategy to use 128 * 129 * @param strategy naming strategy 130 */ 131 void setManagementObjectNameStrategy(ManagementObjectNameStrategy strategy); 132 133 /** 134 * Gets the object strategy to use 135 * 136 * @return object strategy 137 */ 138 ManagementObjectStrategy getManagementObjectStrategy(); 139 140 /** 141 * Sets the object strategy to use 142 * 143 * @param strategy object strategy 144 */ 145 void setManagementObjectStrategy(ManagementObjectStrategy strategy); 146 147 /** 148 * Gets the management agent 149 * 150 * @return management agent 151 */ 152 ManagementAgent getManagementAgent(); 153 154 /** 155 * Sets the management agent to use 156 * 157 * @param managementAgent management agent 158 */ 159 void setManagementAgent(ManagementAgent managementAgent); 160 161 /** 162 * Filter whether the processor should be managed or not. 163 * <p/> 164 * Is used to filter out unwanted processors to avoid managing at too fine grained level. 165 * 166 * @param definition definition of the processor 167 * @return <tt>true</tt> to manage it 168 */ 169 boolean manageProcessor(NamedNode definition); 170 171}