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;
018
019import java.util.Collection;
020import java.util.List;
021import java.util.Map;
022import java.util.Set;
023import java.util.concurrent.ExecutorService;
024import java.util.concurrent.ScheduledExecutorService;
025
026import org.apache.camel.spi.AnnotationBasedProcessorFactory;
027import org.apache.camel.spi.AsyncProcessorAwaitManager;
028import org.apache.camel.spi.BeanIntrospection;
029import org.apache.camel.spi.BeanProcessorFactory;
030import org.apache.camel.spi.BeanProxyFactory;
031import org.apache.camel.spi.CamelBeanPostProcessor;
032import org.apache.camel.spi.DataFormatResolver;
033import org.apache.camel.spi.DeferServiceFactory;
034import org.apache.camel.spi.EndpointStrategy;
035import org.apache.camel.spi.FactoryFinder;
036import org.apache.camel.spi.FactoryFinderResolver;
037import org.apache.camel.spi.InterceptStrategy;
038import org.apache.camel.spi.LifecycleStrategy;
039import org.apache.camel.spi.LogListener;
040import org.apache.camel.spi.ManagementMBeanAssembler;
041import org.apache.camel.spi.ModelJAXBContextFactory;
042import org.apache.camel.spi.NodeIdFactory;
043import org.apache.camel.spi.PackageScanClassResolver;
044import org.apache.camel.spi.ProcessorFactory;
045import org.apache.camel.spi.Registry;
046import org.apache.camel.spi.RouteStartupOrder;
047import org.apache.camel.spi.UnitOfWorkFactory;
048
049/**
050 * Extended {@link CamelContext} which contains the methods and APIs that are not primary intended for Camel end users
051 * but for SPI, custom components, or more advanced used-cases with Camel.
052 */
053public interface ExtendedCamelContext extends CamelContext {
054
055    /**
056     * Sets the name (id) of the this context.
057     * <p/>
058     * This operation is mostly only used by different Camel runtimes such as camel-spring, camel-cdi, camel-spring-boot etc.
059     * Important: Setting the name should only be set before CamelContext is started.
060     *
061     * @param name the name
062     */
063    void setName(String name);
064
065    /**
066     * Sets the registry Camel should use for looking up beans by name or type.
067     * <p/>
068     * This operation is mostly only used by different Camel runtimes such as camel-spring, camel-cdi, camel-spring-boot etc.
069     * Important: Setting the registry should only be set before CamelContext is started.
070     *
071     * @param registry the registry such as DefaultRegistry or
072     */
073    void setRegistry(Registry registry);
074
075    /**
076     * Method to signal to {@link CamelContext} that the process to initialize setup routes is in progress.
077     *
078     * @param done <tt>false</tt> to start the process, call again with <tt>true</tt> to signal its done.
079     * @see #isSetupRoutes()
080     */
081    void setupRoutes(boolean done);
082
083    /**
084     * Indicates whether current thread is setting up route(s) as part of starting Camel from spring/blueprint.
085     * <p/>
086     * This can be useful to know by {@link LifecycleStrategy} or the likes, in case
087     * they need to react differently.
088     * <p/>
089     * As the startup procedure of {@link CamelContext} is slightly different when using plain Java versus
090     * Spring or Blueprint, then we need to know when Spring/Blueprint is setting up the routes, which
091     * can happen after the {@link CamelContext} itself is in started state, due the asynchronous event nature
092     * of especially Blueprint.
093     *
094     * @return <tt>true</tt> if current thread is setting up route(s), or <tt>false</tt> if not.
095     */
096    boolean isSetupRoutes();
097
098    /**
099     * Registers a {@link org.apache.camel.spi.EndpointStrategy callback} to allow you to do custom
100     * logic when an {@link Endpoint} is about to be registered to the {@link org.apache.camel.spi.EndpointRegistry}.
101     * <p/>
102     * When a callback is registered it will be executed on the already registered endpoints allowing you to catch-up
103     *
104     * @param strategy callback to be invoked
105     */
106    void registerEndpointCallback(EndpointStrategy strategy);
107
108    /**
109     * Returns the order in which the route inputs was started.
110     * <p/>
111     * The order may not be according to the startupOrder defined on the route.
112     * For example a route could be started manually later, or new routes added at runtime.
113     *
114     * @return a list in the order how routes was started
115     */
116    List<RouteStartupOrder> getRouteStartupOrder();
117
118    /**
119     * Returns the bean post processor used to do any bean customization.
120     *
121     * @return the bean post processor.
122     */
123    CamelBeanPostProcessor getBeanPostProcessor();
124
125    /**
126     * Returns the management mbean assembler
127     *
128     * @return the mbean assembler
129     */
130    ManagementMBeanAssembler getManagementMBeanAssembler();
131
132    /**
133     * Creates a new multicast processor which sends an exchange to all the processors.
134     *
135     * @param processors the list of processors to send to
136     * @param executor the executor to use
137     * @return a multicasting processor
138     */
139    AsyncProcessor createMulticast(Collection<Processor> processors,
140                                   ExecutorService executor, boolean shutdownExecutorService);
141
142    /**
143     * Gets the default error handler builder which is inherited by the routes
144     *
145     * @return the builder
146     */
147    ErrorHandlerFactory getErrorHandlerFactory();
148
149    /**
150     * Sets the default error handler builder which is inherited by the routes
151     *
152     * @param errorHandlerFactory the builder
153     */
154    void setErrorHandlerFactory(ErrorHandlerFactory errorHandlerFactory);
155
156    /**
157     * Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions
158     *
159     * @param factory custom factory to use
160     */
161    void setNodeIdFactory(NodeIdFactory factory);
162
163    /**
164     * Gets the node id factory
165     *
166     * @return the node id factory
167     */
168    NodeIdFactory getNodeIdFactory();
169
170    /**
171     * Gets the current data format resolver
172     *
173     * @return the resolver
174     */
175    DataFormatResolver getDataFormatResolver();
176
177    /**
178     * Sets a custom data format resolver
179     *
180     * @param dataFormatResolver the resolver
181     */
182    void setDataFormatResolver(DataFormatResolver dataFormatResolver);
183
184    /**
185     * Returns the package scanning class resolver
186     *
187     * @return the resolver
188     */
189    PackageScanClassResolver getPackageScanClassResolver();
190
191    /**
192     * Sets the package scanning class resolver to use
193     *
194     * @param resolver the resolver
195     */
196    void setPackageScanClassResolver(PackageScanClassResolver resolver);
197
198    /**
199     * Gets the default FactoryFinder which will be used for the loading the factory class from META-INF
200     *
201     * @return the default factory finder
202     */
203    FactoryFinder getDefaultFactoryFinder();
204
205    /**
206     * Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path
207     *
208     * @param path the META-INF path
209     * @return the factory finder
210     * @throws NoFactoryAvailableException is thrown if a factory could not be found
211     */
212    FactoryFinder getFactoryFinder(String path) throws NoFactoryAvailableException;
213
214    /**
215     * Sets the factory finder resolver to use.
216     *
217     * @param resolver the factory finder resolver
218     */
219    void setFactoryFinderResolver(FactoryFinderResolver resolver);
220
221    /**
222     * Gets the factory finder resolver to use
223     *
224     * @return the factory finder resolver
225     */
226    FactoryFinderResolver getFactoryFinderResolver();
227
228    /**
229     * Gets the current {@link org.apache.camel.spi.ProcessorFactory}
230     *
231     * @return the factory, can be <tt>null</tt> if no custom factory has been set
232     */
233    ProcessorFactory getProcessorFactory();
234
235    /**
236     * Sets a custom {@link org.apache.camel.spi.ProcessorFactory}
237     *
238     * @param processorFactory the custom factory
239     */
240    void setProcessorFactory(ProcessorFactory processorFactory);
241
242    /**
243     * Returns the JAXB Context factory used to create Models.
244     *
245     * @return the JAXB Context factory used to create Models.
246     */
247    ModelJAXBContextFactory getModelJAXBContextFactory();
248
249    /**
250     * Sets a custom JAXB Context factory to be used
251     *
252     * @param modelJAXBContextFactory a JAXB Context factory
253     */
254    void setModelJAXBContextFactory(ModelJAXBContextFactory modelJAXBContextFactory);
255
256    /**
257     * Gets the {@link DeferServiceFactory} to use.
258     */
259    DeferServiceFactory getDeferServiceFactory();
260
261    /**
262     * Gets the {@link UnitOfWorkFactory} to use.
263     */
264    UnitOfWorkFactory getUnitOfWorkFactory();
265
266    /**
267     * Sets a custom {@link UnitOfWorkFactory} to use.
268     */
269    void setUnitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory);
270
271    /**
272     * Gets the {@link AnnotationBasedProcessorFactory} to use.
273     */
274    AnnotationBasedProcessorFactory getAnnotationBasedProcessorFactory();
275
276    /**
277     * Gets the {@link BeanProxyFactory} to use.
278     */
279    BeanProxyFactory getBeanProxyFactory();
280
281    /**
282     * Gets the {@link BeanProcessorFactory} to use.
283     */
284    BeanProcessorFactory getBeanProcessorFactory();
285
286    /**
287     * Gets the default shared thread pool for error handlers which
288     * leverages this for asynchronous redelivery tasks.
289     */
290    ScheduledExecutorService getErrorHandlerExecutorService();
291
292    /**
293     * Adds the given interceptor strategy
294     *
295     * @param interceptStrategy the strategy
296     */
297    void addInterceptStrategy(InterceptStrategy interceptStrategy);
298
299    /**
300     * Gets the interceptor strategies
301     *
302     * @return the list of current interceptor strategies
303     */
304    List<InterceptStrategy> getInterceptStrategies();
305
306    /**
307     * Setup management according to whether JMX is enabled or disabled.
308     *
309     * @param options optional parameters to configure {@link org.apache.camel.spi.ManagementAgent}.
310     */
311    void setupManagement(Map<String, Object> options);
312
313    /**
314     * Gets a list of {@link LogListener}.
315     */
316    Set<LogListener> getLogListeners();
317
318    /**
319     * Adds a {@link LogListener}.
320     */
321    void addLogListener(LogListener listener);
322
323    /**
324     * Gets the {@link org.apache.camel.AsyncProcessor} await manager.
325     *
326     * @return the manager
327     */
328    AsyncProcessorAwaitManager getAsyncProcessorAwaitManager();
329
330    /**
331     * Sets a custom {@link org.apache.camel.AsyncProcessor} await manager.
332     *
333     * @param manager the manager
334     */
335    void setAsyncProcessorAwaitManager(AsyncProcessorAwaitManager manager);
336
337    /**
338     * Gets the {@link BeanIntrospection}
339     */
340    BeanIntrospection getBeanIntrospection();
341
342    /**
343     * Sets a custom {@link BeanIntrospection}.
344     */
345    void setBeanIntrospection(BeanIntrospection beanIntrospection);
346
347}




























































OSZAR »