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

org.springframework.context.annotation.Conditional Maven / Gradle / Ivy

There is a newer version: org.apache.commons.net.ftp.FTPClient
Show newest version
/*
 * Copyright 2002-2014 the original author or authors.
 *
 * Licensed 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.springframework.context.annotation;

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

/**
 * Indicates that a component is only eligible for registration when all
 * {@linkplain #value() specified conditions} match.
 *
 * 

A condition is any state that can be determined programmatically * before the bean definition is due to be registered (see {@link Condition} for details). * *

The {@code @Conditional} annotation may be used in any of the following ways: *

    *
  • as a type-level annotation on any class directly or indirectly annotated with * {@code @Component}, including {@link Configuration @Configuration} classes
  • *
  • as a meta-annotation, for the purpose of composing custom stereotype * annotations
  • *
  • as a method-level annotation on any {@link Bean @Bean} method
  • *
* *

If a {@code @Configuration} class is marked with {@code @Conditional}, all of the * {@code @Bean} methods, {@link Import @Import} and {@link ComponentScan @ComponentScan} * annotations associated with that class will be subject to the conditions. * *

NOTE: {@code @Conditional} annotations are not inherited; any conditions from * superclasses or from overridden methods are not being considered. * * @author Phillip Webb * @since 4.0 * @see Condition */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) public @interface Conditional { /** * All {@link Condition}s that must {@linkplain Condition#matches match} * in order for the component to be registered. */ Class[] value(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy