/*
 * Copyright 2002-2013 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.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * Indicates that a component is eligible for registration when one or more {@linkplain
 * #value specified profiles} are active.
 *
 * <p>A <em>profile</em> is a named logical grouping that may be activated
 * programmatically via {@link ConfigurableEnvironment#setActiveProfiles} or declaratively
 * through setting the {@link AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
 * spring.profiles.active} property, usually through JVM system properties, as an
 * environment variable, or for web applications as a Servlet context parameter in
 * {@code web.xml}.
 *
 * <p>The {@code @Profile} annotation may be used in any of the following ways:
 * <ul>
 * <li>as a type-level annotation on any class directly or indirectly annotated with
 * {@code @Component}, including {@link Configuration @Configuration} classes</li>
 * <li>as a meta-annotation, for the purpose of composing custom stereotype annotations</li>
 * <li>as a method-level annotation on any {@link Bean @Bean} method</li>
 * </ul>
 *
 * <p>If a {@code @Configuration} class is marked with {@code @Profile}, all of the
 * {@code @Bean} methods and {@link Import @Import} annotations associated with that class
 * will be bypassed unless one or more of the specified profiles are active. This is very
 * similar to the behavior in Spring XML: if the {@code profile} attribute of the
 * {@code beans} element is supplied e.g., {@code <beans profile="p1,p2">}, the
 * {@code beans} element will not be parsed unless profiles 'p1' and/or 'p2' have been
 * activated. Likewise, if a {@code @Component} or {@code @Configuration} class is marked
 * with {@code @Profile({"p1", "p2"})}, that class will not be registered/processed unless
 * profiles 'p1' and/or 'p2' have been activated.
 *
 * <p>If a given profile is prefixed with the NOT operator ({@code !}), the annotated
 * will be registered if the profile is <em>not</em> active. e.g., for
 * {@code @Profile({"p1", "!p2"})}, registration will occur if profile 'p1' is active or
 * if profile 'p2' is not active.
 *
 * <p>If the {@code @Profile} annotation is omitted, registration will occur, regardless
 * of which (if any) profiles are active.
 *
 * <p>When defining Spring beans via XML, the {@code "profile"} attribute of the
 * {@code <beans>} element may be used. See the documentation in
 * {@code spring-beans} XSD (version 3.1 or greater) for details.
 *
 * @author Chris Beams
 * @author Phillip Webb
 * @since 3.1
 * @see ConfigurableEnvironment#setActiveProfiles
 * @see ConfigurableEnvironment#setDefaultProfiles
 * @see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
 * @see AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Conditional(ProfileCondition.class)
public @interface Profile {

	/**
	 * The set of profiles for which the annotated component should be registered.
	 */
	String[] value();

}

@@ -17,17 +17,17 @@
 2002-201
-3
+5
  the ori
@@ -1064,16 +1064,19 @@
  or more
+%0A *
  %7B@linkp
@@ -1079,19 +1079,16 @@
 inkplain
-%0A *
  #value 
@@ -1291,23 +1291,18 @@
 vely%0A * 
-through
+by
  setting
@@ -1402,25 +1402,13 @@
 erty
-, usually through
+ as a
  JVM
@@ -1426,11 +1426,9 @@
 pert
-ies
+y
 , as
@@ -1463,81 +1463,194 @@
  or 
-for web applications as a Servlet context parameter in%0A * %7B@code web.xml%7D
+as a Servlet context parameter in %7B@code web.xml%7D%0A * for web applications. Profiles may also be activated declaratively in%0A * integration tests via the %7B@code @ActiveProfiles%7D annotation
 .%0A *
@@ -2348,24 +2348,21 @@
 s is
- very%0A * similar
+%0A * analogous
  to 
@@ -2560,34 +2560,38 @@
  unless 
+at least 
 profile
-s
  'p1' 
-and/
 or 'p2' 
@@ -2588,26 +2588,25 @@
 ' or 'p2' ha
-ve
+s
  been%0A * act
@@ -2762,17 +2762,20 @@
 gistered
-/
+ or 
 processe
@@ -2785,24 +2785,33 @@
 nless%0A *
+ at least
  profile
 s 'p1' a
@@ -2806,19 +2806,14 @@
 file
-s
  'p1' 
-and/
 or '
@@ -2818,18 +2818,17 @@
  'p2' ha
-ve
+s
  been ac
@@ -2927,16 +2927,26 @@
 tated%0A *
+ component
  will be
@@ -2998,22 +2998,38 @@
 tive
-. e.g., for%0A *
+ &mdash; for example,%0A * given
  %7B@c
@@ -3133,19 +3133,28 @@
 'p2' is 
-not
+%3Cem%3Enot%3C/em%3E
  active.
@@ -3233,17 +3233,16 @@
 ll occur
-,
  regardl
@@ -3435,16 +3435,20 @@
 ation in
+ the
 %0A * %7B@co
@@ -3556,16 +3556,39 @@
 ip Webb%0A
+ * @author Sam Brannen%0A
  * @sinc
@@ -3811,16 +3811,92 @@
 TY_NAME%0A
+ * @see Conditional%0A * @see org.springframework.test.context.ActiveProfiles%0A
  */%0A@Ret

Clarify semantics for multiple profiles in @Profile