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 */ 017 package org.apache.camel.spi; 018 019 import org.apache.camel.CamelContext; 020 021 /** 022 * The <code>Container</code> interface defines an object that can be used 023 * to customize all Camel contexts created. 024 * 025 * A container can be used to globally intercept and customize Camel contexts, 026 * by registering a <code>LifecycleStrategy</code>, a <code>ProcessorFactory</code>, 027 * or any other SPI object. 028 */ 029 public interface Container { 030 031 /** 032 * The <code>Instance</code> class holds a <code>Container</code> singleton. 033 */ 034 public static final class Instance { 035 036 private static Container container; 037 038 private Instance() { 039 } 040 041 /** 042 * Access the registered Container. 043 * 044 * @return the Container singleton 045 */ 046 public static Container get() { 047 return container; 048 } 049 050 /** 051 * Register the Container. 052 * 053 * @param container the Container to register 054 */ 055 public static void set(Container container) { 056 Instance.container = container; 057 } 058 059 /** 060 * Called by Camel when a <code>CamelContext</code> has been created. 061 * 062 * @param camelContext the newly created CamelContext 063 */ 064 public static void manage(CamelContext camelContext) { 065 Container cnt = container; 066 if (cnt != null) { 067 cnt.manage(camelContext); 068 } 069 } 070 } 071 072 /** 073 * Called by Camel when a <code>CamelContext</code> has been created. 074 * 075 * @param camelContext the newly created CamelContext 076 */ 077 void manage(CamelContext camelContext); 078 079 }