All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.camel.cdi.ImportResource Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.cdi;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.enterprise.inject.Default;

/**
 * Indicates one or more resources representing
 * Camel XML configuration to
 * import. Resources are currently loaded from the classpath.
 * 

* * {@code CamelContext} elements and other Camel primitives are automatically deployed as CDI beans during the container * bootstrap so that they become available for injection at runtime. If such an element has an explicit {@code id} * attribute set, the corresponding CDI bean is qualified with the {@code @Named} qualifier, e.g., given the following * Camel XML configuration: * *

 * {@code
 * 
 *     
 *         
 *         
 *     
 * 
 * }
 * 
* * Corresponding CDI beans are automatically deployed and can be injected, e.g.: * *
 * 
 * {@literal @}Inject
 * {@literal @}ContextName("foo")
 *  CamelContext context;
 * 
 * 
* *
 * 
 * {@literal @}Inject
 * {@literal @}Named("bar")
 *  Endpoint endpoint;
 * 
 * 
* * Note that {@code CamelContext} beans are automatically qualified with both the {@code Named} and {@code ContextName} * qualifiers. If the imported {@code CamelContext} element doesn't have an {@code id} attribute, the corresponding bean * is deployed with the built-in {@code Default} qualifier. *

* * Conversely, CDI beans deployed in the application can be referred to from the Camel XML configuration, usually using * the {@code ref} attribute, e.g., given the following bean declared: * *

 * 
 * {@literal @}Produces
 * {@literal @}Named("baz")
 *  Processor processor = exchange{@literal ->} exchange.getIn().setHeader("qux", "quux");
 * 
 * 
* * A reference to that bean can be declared in the imported Camel XML configuration, e.g.: * *
 * {@code
 * 
 *     
 *         
 *         
 *     
 * 
 * }
 * 
* * @since 2.18.0 */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE }) @Default public @interface ImportResource { /** * Resource locations from which to import Camel XML configuration. * * @return the locations of the resources to import */ String[] value() default {}; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy