diff --git a/fine-third-default/fine-javax-cdi/src/javax/decorator/Decorator.java b/fine-third-default/fine-javax-cdi/src/javax/decorator/Decorator.java new file mode 100644 index 000000000..7e8c22439 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/decorator/Decorator.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.decorator; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.inject.Stereotype; + +/** + *
+ * Specifies that a class is a decorator. May be applied to a managed bean class. + *
+ * + *+ * @Decorator + * class TimestampLogger implements Logger { ... } + *+ * + *
+ * Decorators of a session bean must comply with the bean provider programming restrictions defined by the EJB specification. + * Decorators of a stateful session bean must comply with the rules for instance passivation and conversational state defined by + * the EJB specification. + *
+ * + * @see javax.decorator.Delegate @Delegate identifies the delegate injection point of a decorator. + * + * @author Gavin King + * @author Pete Muir + */ +@Target(TYPE) +@Retention(RUNTIME) +@Documented +@Stereotype +public @interface Decorator { +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/decorator/Delegate.java b/fine-third-default/fine-javax-cdi/src/javax/decorator/Delegate.java new file mode 100644 index 000000000..bae717cc7 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/decorator/Delegate.java @@ -0,0 +1,88 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.decorator; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + *+ * Identifies the delegate injection point of a decorator. May be applied to a field, bean constructor parameter or initializer + * method parameter of a decorator bean class. + *
+ * + *+ * @Decorator + * class TimestampLogger implements Logger { + * @Inject @Delegate @Any Logger logger; + * ... + * } + *+ * + *
+ * @Decorator + * class TimestampLogger implements Logger { + * private Logger logger; + * + * @Inject + * public TimestampLogger(@Delegate @Debug Logger logger) { + * this.logger=logger; + * } + * ... + * } + *+ * + *
+ * A decorator must have exactly one delegate injection point. The delegate injection point must be an injected field, + * initializer method parameter or bean constructor method parameter. + *
+ * + *+ * The container injects a delegate object to the delegate injection point. The delegate object implements the delegate type and + * delegates method invocations along the decorator stack. When the container calls a decorator during business method + * interception, the decorator may invoke any method of the delegate object. If a decorator invokes the delegate object at any + * other time, the invoked method throws an {@link java.lang.IllegalStateException}. + *
+ * + *+ * @Decorator + * class TimestampLogger implements Logger { + * @Inject @Delegate @Any Logger logger; + * + * void log(String message) { + * logger.log( timestamp() + ": " + message ); + * } + * ... + * } + *+ * + * @see javax.decorator.Decorator @Decorator specifies that a class is a decorator. + * + * @author Gavin King + * @author Pete Muir + */ +@Target({ FIELD, PARAMETER }) +@Retention(RUNTIME) +@Documented +public @interface Delegate { +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/decorator/package-info.java b/fine-third-default/fine-javax-cdi/src/javax/decorator/package-info.java new file mode 100644 index 000000000..2bf95b183 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/decorator/package-info.java @@ -0,0 +1,97 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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. + */ +/** + *
Annotations relating to decorators.
+ * + *A decorator implements one or more bean types and + * intercepts business method invocations of + * {@linkplain javax.enterprise.inject beans} which + * implement those bean types. These bean types are called + * decorated types.
+ * + *A decorator is a managed bean annotated {@link + * javax.decorator.Decorator @Decorator}.
+ * + *Decorators are superficially similar to interceptors, + * but because they directly implement operations with business + * semantics, they are able to implement business logic and, + * conversely, unable to implement the cross-cutting concerns + * for which interceptors are optimized. Decorators are called + * after interceptors.
+ * + *The set of decorated types of a decorator includes all + * bean types of the managed bean that are Java interfaces, + * except for {@link java.io.Serializable}. The decorator bean + * class and its superclasses are not decorated types of the + * decorator. The decorator class may be abstract.
+ * + *A decorator intercepts every method:
+ *A decorator may be an abstract class, and is not required to + * implement every method of every decorated type.
+ * + *All decorators have a + * {@linkplain javax.decorator.Delegate delegate injection point}. + * A delegate injection point is an injection point of the bean + * class annotated {@link javax.decorator.Delegate @Delegate}.
+ * + *The type of the delegate injection point must implement or + * extend every decorated type. A decorator is not required to + * implement the type of the delegate injection point.
+ * + *By default, a bean archive has no enabled decorators. A + * decorator must be explicitly enabled by listing its bean class + * under the <decorators> element of the + * beans.xml file of the bean archive. The order of the + * decorator declarations determines the decorator ordering. + * Decorators which occur earlier in the list are called first.
+ * + *A decorator is bound to a bean if:
+ * + *If a managed bean class is declared final, it may not have + * decorators. If a managed bean has a non-static, non-private, + * final method, it may not have any decorator which implements + * that method.
+ * + *A decorator instance is a + * {@linkplain javax.enterprise.context.Dependent dependent object} + * of the object it decorates.
+ * + * @see javax.enterprise.inject + * + * @see javax.decorator.Decorator + * @see javax.decorator.Delegate + * + */ +package javax.decorator; + diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ApplicationScoped.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ApplicationScoped.java new file mode 100644 index 000000000..361893f09 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ApplicationScoped.java @@ -0,0 +1,104 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.util.AnnotationLiteral; + +/** + *+ * Specifies that a bean is application scoped. + *
+ *+ * While ApplicationScoped must be associated with the built-in application context required by the specification, + * third-party extensions are + * allowed to also associate it with their own context. Behavior described below is only related to the built-in application context. + *
+ * + *+ * The application scope is active: + *
+ * + *+ * The application context is shared between all servlet requests, web service invocations, EJB remote method invocations, EJB + * asynchronous method invocations, EJB timeouts and message deliveries to message-driven beans that execute within the same + * application. + *
+ *+ * The application context is destroyed when the application is shut down. + *
+ * + *+ * An event with qualifier @Initialized(ApplicationScoped.class) is fired when the application context is initialized + * and an event with qualifier @Destroyed(ApplicationScoped.class) when the application context is destroyed. + * The event payload is: + *
+ * + *+ * Indicates that the container has rejected a request because a concurrent request is associated with the same conversation + * context. + *
+ * + *+ * The container ensures that a long-running conversation may be associated with at most one request at a time, by blocking or + * rejecting concurrent requests. If the container rejects a request, it must associate the request with a new transient + * conversation and throw an exception of type BusyConversationException from the restore view phase of the JSF + * lifecycle. + *
+ * + * @see javax.enterprise.context.ConversationScoped + * + * @author Pete Muir + * @author Gavin King + */ + +public class BusyConversationException extends ContextException { + + private static final long serialVersionUID = -3599813072560026919L; + + public BusyConversationException() { + super(); + } + + public BusyConversationException(String message) { + super(message); + } + + public BusyConversationException(Throwable cause) { + super(cause); + } + + public BusyConversationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextException.java new file mode 100644 index 000000000..dfe4ee139 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextException.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +/** + *+ * Indicates a problem relating to context management. + *
+ * + * @author Pete Muir + * @author Shane Bryzak + */ +public class ContextException extends RuntimeException { + + private static final long serialVersionUID = -3599813072560026919L; + + public ContextException() { + super(); + } + + public ContextException(String message) { + super(message); + } + + public ContextException(Throwable cause) { + super(cause); + } + + public ContextException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextNotActiveException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextNotActiveException.java new file mode 100644 index 000000000..595b8ae63 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextNotActiveException.java @@ -0,0 +1,52 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +/** + *+ * Indicates that a context is not active. + *
+ * + * @see javax.enterprise.context.spi.Context + * + * @author Pete Muir + * @author Shane Bryzak + * @author Gavin King + */ + +public class ContextNotActiveException extends ContextException { + + private static final long serialVersionUID = -3599813072560026919L; + + public ContextNotActiveException() { + super(); + } + + public ContextNotActiveException(String message) { + super(message); + } + + public ContextNotActiveException(Throwable cause) { + super(cause); + } + + public ContextNotActiveException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Conversation.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Conversation.java new file mode 100644 index 000000000..d833e8b58 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Conversation.java @@ -0,0 +1,113 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +/** + *+ * Allows the application to manage the {@linkplain javax.enterprise.context.ConversationScoped conversation context} by marking + * the current conversation as transient or long-running, specifying a conversation identifier, or setting the conversation + * timeout. + *
+ * + *+ * An instance may be injected: + *
+ * + *+ * @Inject + * Conversation conversation; + *+ * + *
+ * The conversation timeout is a hint to the container that a conversation should not be destroyed if it has been active within + * the last given interval in milliseconds. + *
+ * + * @see javax.enterprise.context.ConversationScoped @ConversationScoped + * + * @author Pete Muir + * @author Gavin King + * + */ +public interface Conversation { + + /** + *+ * Mark the current transient conversation long-running. A conversation identifier is generated by the container. + *
+ * + * @throws IllegalStateException if the current conversation is already marked long-running. + */ + public void begin(); + + /** + *+ * Mark the current transient conversation long-running, with a specified identifier. + *
+ * + * @param id conversation id + * @throws IllegalStateException if the current conversation is already marked long-running. + * @throws IllegalArgumentException if a conversation with the specified identifier already exists. + */ + public void begin(String id); + + /** + *+ * Marks the current long-running conversation transient. + *
+ * + * @throws IllegalStateException if the current conversation is already marked transient. + */ + public void end(); + + /** + *+ * Get the identifier of the current long-running conversation. + *
+ * + * @return the identifier of the current long-running conversation, or a null value if the current conversation is + * transient. + */ + public String getId(); + + /** + *+ * Get the timeout of the current conversation. + *
+ * + * @return the current timeout in milliseconds. + */ + public long getTimeout(); + + /** + *+ * Set the timeout of the current conversation. + *
+ * + * @param milliseconds the new timeout in milliseconds. + */ + public void setTimeout(long milliseconds); + + /** + *+ * Determine if the conversation is marked transient or long-running. + *
+ * + * @return true if the conversation is marked transient, or falseif it is marked long-running. + */ + public boolean isTransient(); +} \ No newline at end of file diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ConversationScoped.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ConversationScoped.java new file mode 100644 index 000000000..6cc9919bf --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ConversationScoped.java @@ -0,0 +1,159 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.util.AnnotationLiteral; + +/** + *+ * Specifies that a bean is conversation scoped. + *
+ *+ * While ConversationScoped must be associated with the built-in conversation context required by the specification, + * third-party extensions are + * allowed to also associate it with their own context. Behavior described below is only related to the built-in conversation context. + *
+ *+ * The conversation scope is active: + *
+ *+ * An event with qualifier @Initialized(ConversationScoped.class) is fired when the conversation context is initialized + * and an event with qualifier @Destroyed(ConversationScoped.class) is fired when the conversation is destroyed. + * The event payload is: + *
+ *+ * The conversation context provides access to state associated with a particular conversation. Every Servlet request + * has an associated conversation. This association is managed automatically by the container according to the following rules: + *
+ * + *+ * + *
+ * Any conversation is in one of two states: transient or long-running. + *
+ * + *+ * All long-running conversations have a string-valued unique identifier, which may be set by the application when the + * conversation is marked long-running, or generated by the container. + *
+ * + *+ * If the conversation associated with the current Servlet request is in the transient state at the end of a Servlet + * request, it is destroyed, and the conversation context is also destroyed. + *
+ * + *+ * If the conversation associated with the current Servlet request is in the long-running state at the end of a Servlet + * request, it is not destroyed. The long-running conversation associated with a request may be propagated to any Servlet + * request via use of a request parameter named cid containing the unique identifier of the conversation. In this + * case, the application must manage this request parameter. + *
+ * + *+ * If the current Servlet request is a JSF request, and the conversation is in long-running state, it is propagated + * according to the following rules: + *
+ * + *+ * When no conversation is propagated to a Servlet request, or if a request parameter named conversationPropagation has + * the value none the request is associated with a new transient conversation. + * All long-running conversations are scoped to a particular HTTP servlet session and may not cross session boundaries. + * In the following cases, a propagated long-running conversation cannot be restored and re-associated with the request: + *
+ * + *+ * Specifies that a bean belongs to the dependent pseudo-scope. + *
+ * + *+ * Beans declared with scope @Dependent behave differently to beans with other built-in scope types. When a bean is + * declared to have scope @Dependent: + *
+ * + *+ * Every invocation of the {@link javax.enterprise.context.spi.Context#get(Contextual, CreationalContext)} operation of the + * context object for the @Dependent scope returns a new instance of the given bean. + *
+ * + *+ * Every invocation of the {@link javax.enterprise.context.spi.Context#get(Contextual)} operation of the context object for the + * @Dependent scope returns a null value. + *
+ * + *+ * The @Dependent scope is always active. + *
+ * + *+ * Many instances of beans with scope @Dependent belong to some other bean or Java EE component class instance and are + * called dependent objects. + *
+ * + *+ * When the container destroys an instance of a bean or of any Java EE component class supporting injection, the container + * destroys all its dependent objects, after the @PreDestroy callback completes and after the servlet + * destroy() method is called. + *
+ * + * @author Gavin King + * @author Pete Muir + */ + +@Target({ METHOD, TYPE, FIELD }) +@Retention(RUNTIME) +@Documented +@Scope +@Inherited +public @interface Dependent { + + /** + * Supports inline instantiation of the {@link Dependent} annotation. + * + * @author Martin Kouba + * @since 2.0 + */ + public final static class Literal extends AnnotationLiteral+ * Indicates that the conversation context could not be restored. + *
+ * + *+ * If the propagated conversation cannot be restored, the container must associate the request with a new transient conversation + * and throw an exception of type NonexistentConversationException. + *
+ * + * @see javax.enterprise.context.ConversationScoped + * + * @author Pete Muir + * @author Gavin King + */ + +public class NonexistentConversationException extends ContextException { + + private static final long serialVersionUID = -3599813072560026919L; + + public NonexistentConversationException() { + super(); + } + + public NonexistentConversationException(String message) { + super(message); + } + + public NonexistentConversationException(Throwable cause) { + super(cause); + } + + public NonexistentConversationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NormalScope.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NormalScope.java new file mode 100644 index 000000000..934ae8897 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NormalScope.java @@ -0,0 +1,56 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + *+ * Specifies that an annotation type is a normal scope type. + *
+ * + * @author Gavin King + * @author Pete Muir + * + * @see javax.inject.Scope @Scope is used to declare pseudo-scopes. + */ +@Target(ANNOTATION_TYPE) +@Retention(RUNTIME) +@Documented +public @interface NormalScope { + + /** + *+ * Determines whether the normal scope type is a passivating scope. + *
+ * + *+ * A bean is called passivation capable if the container is able to temporarily transfer the state of any idle instance to + * secondary storage. A passivating scope requires that beans with the scope are passivation capable. + *
+ * + * @return true if the scope type is a passivating scope type + */ + boolean passivating() default false; + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/RequestScoped.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/RequestScoped.java new file mode 100644 index 000000000..abdf7f17d --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/RequestScoped.java @@ -0,0 +1,107 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.context; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.util.AnnotationLiteral; + +/** + *+ * Specifies that a bean is request scoped. + *
+ *+ * While RequestScoped must be associated with the built-in request context required by the specification, + * third-party extensions are + * allowed to also associate it with their own context. Behavior described below is only related to the built-in request context. + *
+ * + *+ * The request scope is active: + *
+ * + *+ * The request context is destroyed: + *
+ * + *+ * An event with qualifier @Initialized(RequestScoped.class) is fired when the request context is initialized and an + * event + * with qualifier @Destroyed(RequestScoped.class) when the request context is destroyed. The event payload is: + *
+ * + *+ * Specifies that a bean is session scoped. + *
+ *+ * While SessionScoped must be associated with the built-in session context required by the specification, + * third-party extensions are + * allowed to also associate it with their own context. Behavior described below is only related to the built-in session context. + *
+ *+ * The session scope is active: + *
+ * + *+ * The session context is shared between all servlet requests that occur in the same HTTP session. + *
+ *+ * The session context is destroyed: + *
+ * + *
+ * An event with qualifier @Initialized(SessionScoped.class) is fired when the session context is initialized and an
+ * event
+ * with qualifier @Destroyed(SessionScoped.class) when the session context is destroyed. The event payload is
+ * the HttpSession
+ *
+ * @author Gavin King
+ * @author Pete Muir
+ * @author Antoine Sabot-Durand
+ */
+
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+@NormalScope(passivating = true)
+@Inherited
+public @interface SessionScoped {
+
+ /**
+ * Supports inline instantiation of the {@link SessionScoped} annotation.
+ *
+ * @author Martin Kouba
+ * @since 2.0
+ */
+ public final static class Literal extends AnnotationLiteral Annotations and interfaces relating to scopes and contexts. A scope type is a Java annotation annotated
+ * {@link javax.inject.Scope @Scope} or
+ * {@link javax.enterprise.context.NormalScope @NormalScope}.
+ * The scope of a bean determines the lifecycle and visibility of
+ * its instances. In particular, the scope determines: The following built-in scopes are provided:
+ * {@link javax.enterprise.context.Dependent @Dependent},
+ * {@link javax.enterprise.context.RequestScoped @RequestScoped},
+ * {@link javax.enterprise.context.ConversationScoped @ConversationScoped},
+ * {@link javax.enterprise.context.SessionScoped @SessionScoped},
+ * {@link javax.enterprise.context.ApplicationScoped @ApplicationScoped},
+ * {@link javax.inject.Singleton @Singleton}. The container provides an implementation of the Context
+ * interface for each of the built-in scopes. The built-in request,
+ * session, and application contexts support servlet, web service
+ * and EJB invocations. The built-in conversation context supports
+ * JSF requests. For other kinds of invocations, a portable extension may define a
+ * custom {@linkplain javax.enterprise.context.spi.Context context object}
+ * for any or all of the built-in scopes. For example, a third-party web
+ * application framework might provide a conversation context object for
+ * the built-in conversation scope. The context associated with a built-in scope propagates across
+ * local, synchronous Java method calls, including invocation of EJB
+ * local business methods. The context does not propagate across remote
+ * method invocations or to asynchronous processes such as JMS message
+ * listeners or EJB timer service timeouts. Most scopes are normal scopes. Normal scopes are declared
+ * using {@link javax.enterprise.context.NormalScope @NormalScope}.
+ * If a bean has a normal scope, every client executing in a certain
+ * thread sees the same contextual instance of the bean. This instance is
+ * called the current instance of the bean. The operation
+ * {@link javax.enterprise.context.spi.Context#get(javax.enterprise.context.spi.Contextual)} of the
+ * context object for a normal scope type always returns the current
+ * instance of the given bean. Any scope that is not a normal scope is called a pseudo-scope.
+ * Pseudo-scopes are declared using {@link javax.inject.Scope @Scope}.
+ * The concept of a current instance is not well-defined in the case of
+ * a pseudo-scope. Different clients executing in the same thread may
+ * see different instances of the bean. In the extreme case of the
+ * {@link javax.enterprise.context.Dependent @Dependent} pseudo-scope,
+ * every client has its own private instance of the bean. All built-in scopes are normal scopes, except for the
+ * {@link javax.enterprise.context.Dependent @Dependent} and
+ * {@link javax.inject.Singleton @Singleton} pseudo-scopes. A reference to a bean obtained from the container via {@linkplain
+ * javax.enterprise.inject.Instance programmatic lookup} is called a
+ * contextual reference. A contextual reference for a bean with a normal
+ * scope refers to the current instance of the bean. A contextual
+ * reference for a bean are valid only for a certain period of time. The
+ * application should not invoke a method of an invalid reference. The validity of a contextual reference for a bean depends upon
+ * whether the scope of the bean is a normal scope or a pseudo-scope: A reference to a bean obtained from the container via {@linkplain
+ * javax.inject.Inject dependency injection} is a special kind of
+ * contextual reference, called an injected reference. Additional
+ * restrictions apply to the validity of an injected reference:
+ * Provides an operation for obtaining and destroying contextual instances with a particular scope of any contextual type. Any
+ * instance of {@code Context} is called a context object.
+ *
+ * {@link AlterableContext} was introduced in CDI 1.1 to allow bean instances to be destroyed by the application. Extensions
+ * should implement {@link AlterableContext} instead of {@link Context}.
+ *
+ * The context object is responsible for creating and destroying contextual instances by calling operations of
+ * {@link javax.enterprise.context.spi.Contextual}. In particular, the context object is responsible for destroying any
+ * contextual instance it creates by passing the instance to
+ * {@link javax.enterprise.context.spi.Contextual#destroy(Object, CreationalContext)} . A destroyed instance must not
+ * subsequently be returned by {@code get()}. The context object must pass the same instance of
+ * {@link javax.enterprise.context.spi.CreationalContext} to {@code Contextual.destroy()} that it passed to
+ * {@code Contextual.create()} when it created the instance.
+ *
+ * A custom context object may be registered with the container using
+ * {@link javax.enterprise.inject.spi.AfterBeanDiscovery#addContext(Context)}.
+ *
+ * Destroy the existing contextual instance. If there is no existing instance, no action is taken.
+ *
+ * Provides an operation for obtaining contextual instances with a particular scope of any contextual type. Any instance of
+ * {@code Context} is called a context object.
+ *
+ * {@link AlterableContext} was introduced in CDI 1.1 to allow bean instances to be destroyed by the application. Extensions
+ * should implement {@link AlterableContext} instead of {@link Context}.
+ *
+ * The context object is responsible for creating and destroying contextual instances by calling operations of
+ * {@link javax.enterprise.context.spi.Contextual}. In particular, the context object is responsible for destroying any
+ * contextual instance it creates by passing the instance to
+ * {@link javax.enterprise.context.spi.Contextual#destroy(Object, CreationalContext)} . A destroyed instance must not
+ * subsequently be returned by {@code get()}. The context object must pass the same instance of
+ * {@link javax.enterprise.context.spi.CreationalContext} to {@code Contextual.destroy()} that it passed to
+ * {@code Contextual.create()} when it created the instance.
+ *
+ * A custom context object may be registered with the container using
+ * {@link javax.enterprise.inject.spi.AfterBeanDiscovery#addContext(Context)}.
+ *
+ * Defines operations to create and destroy contextual instances of a certain type. Any implementation of {@code Contextual} is
+ * called a contextual type. In particular, all beans are contextual types.
+ *
+ * Provides operations that are used by the {@link javax.enterprise.context.spi.Contextual} implementation during instance
+ * creation and destruction.
+ * The custom context SPI. Associated with every
+ * {@linkplain javax.enterprise.context scope type} is a
+ * {@linkplain javax.enterprise.context.spi.Context context object}.
+ * The context object implements the semantics of the scope type. The context implementation collaborates with the container via
+ * the {@link javax.enterprise.context.spi.Context Context} and
+ * {@link javax.enterprise.context.spi.Contextual Contextual}
+ * interfaces to create and destroy contextual instances.
+ * Allows the application to fire events of a particular type.
+ *
+ * Beans fire events via an instance of the Event interface, which may be injected:
+ *
+ * The fire() method accepts an event object:
+ *
+ * Any combination of qualifiers may be specified at the injection point:
+ *
+ * Or, the {@link javax.enterprise.inject.Any @Any} qualifier may be used, allowing the application to specify qualifiers
+ * dynamically:
+ *
+ * For an injected Event:
+ *
+ * Events may also be fired asynchronously with {@link #fireAsync(Object)} and {@link #fireAsync(Object, NotificationOptions)} methods
+ *
+ * Fires an event with the specified qualifiers and notifies observers.
+ *
+ * Fires an event asynchronously with the specified qualifiers and notifies asynchronous observers.
+ *
+ * Fires an event asynchronously with the specified qualifiers and notifies asynchronous observers.
+ * A custom {@link Executor} will be used to make asynchronous calls
+ *
+ * Obtains a child Event for the given additional required qualifiers.
+ *
+ * Obtains a child Event for the given required type and additional required qualifiers.
+ *
+ * Obtains a child Event for the given required type and additional required qualifiers.
+ *
+ * Indicates that a checked exception was thrown by an observer method during event notification.
+ *
+ * Identifies the event parameter of an observer method. May be applied to a parameter of a method of a bean class or
+ * {@linkplain javax.enterprise.inject.spi.Extension extension}.
+ *
+ * An observer method is a non-abstract method of a managed bean class or session bean class (or of an extension). An observer
+ * method may be either static or non-static. If the bean is a session bean, the observer method must be either a business
+ * method of the EJB or a static method of the bean class.
+ *
+ * Each observer method must have exactly one event parameter, of the same type as the event type it observes. Event qualifiers
+ * may be declared by annotating the event parameter. When searching for observer methods for an event, the container considers
+ * the type and qualifiers of the event parameter.
+ *
+ * If the event parameter does not explicitly declare any qualifier, the observer method observes events with no qualifier.
+ *
+ * The event parameter type may contain a type variable or wildcard.
+ *
+ * In addition to the event parameter, observer methods may declare additional parameters, which may declare qualifiers. These
+ * additional parameters are injection points.
+ *
+ * A bean (or extension) may declare multiple observer methods.
+ *
+ * Observer methods are inherited by bean subclasses.
+ *
+ * Interceptors and decorators may not declare observer methods.
+ *
+ * Specifies {@linkplain javax.enterprise.event.Reception under what conditions the observer method is notified}.
+ *
+ * By default, the observer method is notified even if no instance of the bean that defines the observer method already
+ * exists in the current context.
+ *
+ * Specifies {@linkplain javax.enterprise.event.Reception at what time the observer method is notified}.
+ *
+ * By default, the observer method is notified when the event is fired.
+ *
+ * Identifies the event parameter of an asynchronous observer method. May be applied to a parameter of a method of a bean class
+ *
+ * An observer method is a non-abstract method of a managed bean class or session bean class (or of an extension). An observer
+ * method may be either static or non-static. If the bean is a session bean, the observer method must be either a business
+ * method of the EJB or a static method of the bean class.
+ *
+ * Each observer method must have exactly one event parameter, of the same type as the event type it observes. Event qualifiers
+ * may be declared by annotating the event parameter. When searching for observer methods for an event, the container considers
+ * the type and qualifiers of the event parameter.
+ *
+ * If the event parameter does not explicitly declare any qualifier, the observer method observes events with no qualifier.
+ *
+ * The event parameter type may contain a type variable or wildcard.
+ *
+ * In addition to the event parameter, observer methods may declare additional parameters, which may declare qualifiers. These
+ * additional parameters are injection points.
+ *
+ * A bean (or extension) may declare multiple observer methods.
+ *
+ * Observer methods are inherited by bean subclasses.
+ *
+ * Interceptors and decorators may not declare observer methods.
+ *
+ * Specifies {@linkplain Reception under what conditions the observer method is notified}.
+ *
+ * By default, the observer method is notified even if no instance of the bean that defines the observer method already
+ * exists in the current context.
+ *
+ * Distinguishes conditional {@linkplain javax.enterprise.event.Observes observer methods} from observer methods which are
+ * always notified.
+ *
+ * A conditional observer method is an observer method which is notified of an event only if an instance of the bean that
+ * defines the observer method already exists in the current context.
+ *
+ * Beans with scope {@link javax.enterprise.context.Dependent @Dependent} may not have conditional observer methods.
+ *
+ * Specifies that an observer method is only called if the current instance of the bean declaring the observer method
+ * already exists.
+ *
+ * If there is no active context for the scope to which the bean declaring this observer method belongs, then the observer
+ * method is not called.
+ *
+ * Distinguishes the various kinds of transactional {@linkplain javax.enterprise.event.Observes observer methods} from regular
+ * observer methods which are notified immediately.
+ *
+ * Transactional observer methods are observer methods which receive event notifications during the before or after completion
+ * phase of the transaction in which the event was fired. If no transaction is in progress when the event is fired, they are
+ * notified at the same time as other observers.
+ * If the transaction is in progress, but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
+ * marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered, the {@link #BEFORE_COMPLETION},
+ * {@link #AFTER_COMPLETION} and {@link #AFTER_FAILURE} observer methods are notified at the same time as other observers,
+ * but {@link #AFTER_SUCCESS} observer methods get skipped.
+ *
+ * Identifies a regular observer method, called when the event is fired.
+ *
+ * Identifies a before completion observer method, called during the before completion phase of the transaction.
+ *
+ * Transactional observer will be notified if there is no transaction in progress, or the transaction is in progress,
+ * but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
+ * marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered.
+ *
+ * Identifies an after completion observer method, called during the after completion phase of the transaction.
+ *
+ * Transactional observer will be notified if there is no transaction in progress, or the transaction is in progress,
+ * but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
+ * marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered.
+ *
+ * Identifies an after failure observer method, called during the after completion phase of the transaction, only when the
+ * transaction fails.
+ *
+ * Transactional observer will be notified will also get invoked if there is no transaction in progress, or the transaction is in progress,
+ * but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
+ * marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered.
+ *
+ * Identifies an after success observer method, called during the after completion phase of the transaction, only when the
+ * transaction completes successfully.
+ * Annotations and interfaces relating to events.
+ *
+ * {@linkplain javax.enterprise.inject Beans} may produce and
+ * consume events. Events allows beans to interact in a completely
+ * decoupled fashion, with no compile-time dependency between the
+ * interacting beans. Most importantly, it allows stateful beans
+ * in one architectural tier of the application to synchronize
+ * their internal state with state changes that occur in a
+ * different tier. Events may be fired synchronously or asynchronously. An event comprises: The {@link javax.enterprise.event.Event} interface is used to
+ * fire events. The event object acts as a payload, to propagate state from
+ * producer to consumer. An event object is an instance of a concrete
+ * Java class with no type variables. The event types of the event include all superclasses and
+ * interfaces of the runtime class of the event object. An event type
+ * may not contain a type variable. The event qualifiers act as topic selectors, allowing the consumer
+ * to narrow the set of events it observes. An event qualifier may be an
+ * instance of any {@linkplain javax.inject.Qualifier qualifier type}. An {@linkplain javax.enterprise.event.Observes observer method}
+ * allows the application to receive and respond synchronously to event notifications.
+ * And an {@linkplain javax.enterprise.event.ObservesAsync async observer method}
+ * allows the application to receive and respond asynchronously to event notifications.
+ * they both act as event consumers, observing events of a specific type, with a
+ * specific set of qualifiers. Any Java type may be observed by an
+ * observer method. An observer method is a method of a bean class or
+ * {@linkplain javax.enterprise.inject.spi.Extension extension} with a
+ * parameter annotated {@link javax.enterprise.event.Observes @Observes}
+ * or {@link javax.enterprise.event.ObservesAsync @ObservesAsync}. An observer method will be notified of an event if: If a synchronous observer method is a
+ * {@linkplain javax.enterprise.event.TransactionPhase transactional
+ * observer method} and there is a JTA transaction in progress when the
+ * event is fired, the observer method is notified during the appropriate
+ * transaction completion phase. Otherwise, the observer is notified when
+ * the event is fired. The order in which observer methods are called depends on the value of
+ * the {@linkplain javax.annotation.Priority @Priority} applied to the observer.
+ * @Inject
+ * private RequestContextController requestContextController;
+ *
+ * public void doRequest(String body) {
+ * // activate request context
+ * requestContextController.activate();
+ *
+ * // do work in a request context.
+ *
+ * // deactivate the request context
+ * requestContextController.deactivate();
+ * }
+ *
+ *
+ * Once the request context has been deactivated, you may activate it once again, creating a brand new request context.
+ * The activated request context is bound to the current thread, any injection points targeting a request scoped bean
+ * will be satisfied with the same request scoped objects.
+ *
+ * @since 2.0
+ * @author John D. Ament
+ */
+public interface RequestContextController {
+
+ /**
+ * Activates a RequestContext for the current thread if one is not already active.
+ * @return true if the context was activated by this invocation, false if not.
+ */
+ boolean activate();
+
+ /**
+ * Deactivates the current Request Context if it was activated by this context controller. If the context is active
+ * but was not activated by this controller, then it may not be deactivated by this controller,
+ * meaning this method will do nothing.
+ *
+ * If the context is not active, a {@see ContextNotActiveException} is thrown.
+ *
+ * @throws ContextNotActiveException if the context is not active
+ */
+ void deactivate() throws ContextNotActiveException;
+}
diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/package-info.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/package-info.java
new file mode 100644
index 000000000..b79adc15f
--- /dev/null
+++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/package-info.java
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.
+ */
+/**
+ *
+ *
+ *
+ * Built-in scopes
+ *
+ * Normal scopes and pseudo-scopes
+ *
+ * Contextual and injected reference validity
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * @see javax.enterprise.inject
+ *
+ */
+package javax.enterprise.context;
+
diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/AlterableContext.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/AlterableContext.java
new file mode 100644
index 000000000..3e206aea2
--- /dev/null
+++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/AlterableContext.java
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 javax.enterprise.context.spi;
+
+import javax.enterprise.context.ContextNotActiveException;
+
+/**
+ *
+ * @Inject
+ * @Any
+ * Event<LoggedInEvent> loggedInEvent;
+ *
+ *
+ *
+ * public void login() {
+ * ...
+ * loggedInEvent.fire( new LoggedInEvent(user) );
+ * }
+ *
+ *
+ *
+ * @Inject
+ * @Admin
+ * Event<LoggedInEvent> adminLoggedInEvent;
+ *
+ *
+ *
+ * @Inject
+ * @Any
+ * Event<LoggedInEvent> loggedInEvent;
+ *
+ *
+ *
+ *
+ *
+ * null
if no option for the given name exists
+ */
+ Object get(String optionName);
+
+ /**
+ *
+ * @param executor a specific {@link Executor} to handle observer notification
+ * @return an immutable holder of an executor
+ */
+ static NotificationOptions ofExecutor(Executor executor) {
+ return builder().setExecutor(executor).build();
+ }
+
+ /**
+ *
+ * @param optionName name of the option to set
+ * @param optionValue value for the option
+ * @return an immutable holder of a single option
+ */
+ static NotificationOptions of(String optionName, Object optionValue) {
+ return builder().set(optionName, optionValue).build();
+ }
+
+ /**
+ *
+ * @return the options builder
+ */
+ static Builder builder() {
+ return new ImmutableNotificationOptions.Builder();
+ }
+
+ /**
+ * Notification options builder.
+ *
+ * @author Martin Kouba
+ * @since 2.0
+ */
+ interface Builder {
+
+ Builder setExecutor(Executor executor);
+
+ Builder set(String optionName, Object optionValue);
+
+ NotificationOptions build();
+
+ }
+
+}
diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObserverException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObserverException.java
new file mode 100644
index 000000000..91e282cb4
--- /dev/null
+++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObserverException.java
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 javax.enterprise.event;
+
+/**
+ *
+ * public void afterLogin(@Observes LoggedInEvent event) { ... }
+ *
+ *
+ *
+ * public void afterLogin(@Observes LoggedInEvent event, @Manager User user, Logger log) { ... }
+ *
+ *
+ *
+ * public void afterLogin(@ObservesAsync LoggedInEvent event) { ... }
+ *
+ *
+ *
+ * public void afterLogin(@ObservesAsync LoggedInEvent event, @Manager User user, Logger log) { ... }
+ *
+ *
+ *
+ *
+ *
+ * Event objects and event types
+ *
+ * Event qualifiers
+ *
+ * Observer methods
+ *
+ *
+ *
+ *
+ *
If two observer have the same priority their relative order is undefined.
+ * + *Observer methods may throw exceptions:
+ * + *+ * Specifies that a bean is an alternative. May be applied to a bean class, producer method or field or + * {@linkplain javax.enterprise.inject.Stereotype stereotype}. + *
+ * + *+ * @Alternative + * public class MockOrder extends Order { ... } + *+ * + *
+ * An alternative is not available for injection, lookup or EL resolution to classes or JSP/JSF pages in a module unless the + * module is a bean archive and the alternative is explicitly selected in that bean archive. An alternative is never + * available for injection, lookup or EL resolution in a module that is not a bean archive. + *
+ * + *+ * By default, a bean archive has no selected alternatives. An alternative must be explicitly declared using the + * <alternatives> element of the beans.xml file of the bean archive. The <alternatives> + * element contains a list of bean classes and stereotypes. An alternative is selected for the bean archive if either: + *
+ * + *+ * Indicates that multiple beans match a certain combination of required type and required qualifiers and are eligible for + * injection into a certain class. + *
+ * + * @author Pete Muir + * @author Gavin King + */ +public class AmbiguousResolutionException extends ResolutionException { + + private static final long serialVersionUID = -2132733164534544788L; + + public AmbiguousResolutionException() { + } + + public AmbiguousResolutionException(String message, Throwable throwable) { + super(message, throwable); + } + + public AmbiguousResolutionException(String message) { + super(message); + } + + public AmbiguousResolutionException(Throwable throwable) { + super(throwable); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Any.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Any.java new file mode 100644 index 000000000..bf0c9c45d --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Any.java @@ -0,0 +1,97 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.event.Event; +import javax.enterprise.util.AnnotationLiteral; +import javax.inject.Qualifier; + +/** + *+ * The built-in qualifier type. + *
+ * + *+ * Every bean has the qualifier @Any, even if it does not explicitly declare this qualifier, except for the + * special {@link javax.enterprise.inject.New @New qualified beans}. + *
+ * + *+ * Every event has the qualifier @Any, even if it was raised without explicitly declaration of this qualifier. + *
+ * + *+ * The @Any qualifier allows an injection point to refer to all beans or all events of a certain bean type. + *
+ * + *+ * @Inject + * @Any + * Instance<PaymentProcessor> anyPaymentProcessor; + *+ * + *
+ * @Inject + * @Any + * Event<User> anyUserEvent; + *+ * + *
+ * @Inject + * @Delegate + * @Any + * Logger logger; + *+ * + * @author Gavin King + * @author David Allen + */ + +@Qualifier +@Retention(RUNTIME) +@Target({ TYPE, METHOD, FIELD, PARAMETER }) +@Documented +public @interface Any { + + /** + * Supports inline instantiation of the {@link Any} qualifier. + * + * @author Martin Kouba + * @since 2.0 + * @see Instance + * @see Event + */ + public static final class Literal extends AnnotationLiteral
+ * Indicates that a checked exception was thrown during creation of a bean. + *
+ * + * @author Pete Muir + * @author Gavin King + */ +public class CreationException extends InjectionException { + + private static final long serialVersionUID = 1002854668862145298L; + + public CreationException() { + + } + + public CreationException(String message) { + super(message); + } + + public CreationException(Throwable cause) { + super(cause); + } + + public CreationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Decorated.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Decorated.java new file mode 100644 index 000000000..e68d7485e --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Decorated.java @@ -0,0 +1,62 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + *+ * A decorator may inject metadata about the bean it is decorating + *
+ * + *+ * @Decorator + * class TimestampLogger implements Logger { + * @Inject + * @Delegate + * @Any + * Logger logger; + * + * @Inject + * @Decorated + * Bean<Logger> bean; + * + * void log(String message) { + * ... + * } + * } + *+ * + * @author Pete Muir + * @since 1.1 + */ + +@Target({ PARAMETER, FIELD }) +@Retention(RUNTIME) +@Documented +@Qualifier +public @interface Decorated { +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Default.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Default.java new file mode 100644 index 000000000..11c13fbdc --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Default.java @@ -0,0 +1,111 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.event.Event; +import javax.enterprise.util.AnnotationLiteral; +import javax.inject.Qualifier; + +/** + *
+ * The default qualifier type. + *
+ * + *+ * If a bean does not explicitly declare a qualifier other than {@link javax.inject.Named @Named}, the bean has the + * qualifier @Default. + *
+ * + *+ * If an injection point declares no qualifier, the injection point has exactly one qualifier, the default qualifier + * @Default. + *
+ * + *+ * The following are equivalent: + *
+ * + *+ * @ConversationScoped + * public class Order { + * + * private Product product; + * private User customer; + * + * @Inject + * public void init(@Selected Product product, User customer) { + * this.product = product; + * this.customer = customer; + * } + * + * } + *+ * + *
+ * @Default + * @ConversationScoped + * public class Order { + * + * private Product product; + * private User customer; + * + * @Inject + * public void init(@Selected Product product, @Default User customer) { + * this.product = product; + * this.customer = customer; + * } + * + * } + *+ * + * @author Pete Muir + * @author Gavin King + */ + +@Target({ TYPE, METHOD, PARAMETER, FIELD }) +@Retention(RUNTIME) +@Documented +@Qualifier +public @interface Default { + + /** + * Supports inline instantiation of the {@link Default} qualifier. + * + * @author Martin Kouba + * @since 2.0 + * @see Instance + * @see Event + */ + public static final class Literal extends AnnotationLiteral
+ * Identifies the disposed parameter of a disposer method. May be applied to a parameter of a method of a bean class. + *
+ * + *+ * public class UserDatabaseEntityManager { + * + * @Produces + * @ConversationScoped + * @UserDatabase + * public EntityManager create(EntityManagerFactory emf) { + * return emf.createEntityManager(); + * } + * + * public void close(@Disposes @UserDatabase EntityManager em) { + * em.close(); + * } + * + * } + *+ * + *
+ * public class Resources { + * + * @PersistenceContext + * @Produces + * @UserDatabase + * private EntityManager em; + * + * public void close(@Disposes @UserDatabase EntityManager em) { + * em.close(); + * } + * + * } + *+ * + *
+ * A disposer method allows the application to perform customized cleanup of an object returned by a + * {@linkplain javax.enterprise.inject.Produces producer method or producer field}. + *
+ * + *+ * A disposer method must be a non-abstract method of a managed bean class or session bean class. A disposer method may be + * either static or non-static. If the bean is a session bean, the disposer method must be a business method of the EJB or a + * static method of the bean class. + *
+ * + *+ * A bean may declare multiple disposer methods. + *
+ * + *+ * Each disposer method must have exactly one disposed parameter, of the same type as the corresponding producer method or + * producer field return type. When searching for disposer methods for a producer method or producer field, the container + * considers the type and qualifiers of the disposed parameter. If a disposed parameter resolves to a producer method or + * producer field declared by the same bean class, the container must call this method when destroying any instance returned by + * that producer method or producer field. + *
+ * + *+ * In addition to the disposed parameter, a disposer method may declare additional parameters, which may also specify + * qualifiers. These additional parameters are injection points. + *
+ * + *+ * public void close(@Disposes @UserDatabase EntityManager em, Logger log) { ... } + *+ * + *
+ * A disposer method may resolve to multiple producer methods or producer fields declared by the bean class, in which case the + * container must call it when destroying any instance returned by any of these producer methods or producer fields. + *
+ * + *+ * Disposer methods are not inherited by bean subclasses. + *
+ * + *+ * Interceptors and decorators may not declare disposer methods. + *
+ * + * @see javax.enterprise.inject.Produces @Produces + * + * @author Gavin King + * @author Pete Muir + */ + +@Target(PARAMETER) +@Retention(RUNTIME) +@Documented +public @interface Disposes { + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/IllegalProductException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/IllegalProductException.java new file mode 100644 index 000000000..64881597c --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/IllegalProductException.java @@ -0,0 +1,45 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +/** + *+ * Indicates that a producer method returned a null value or a producer field contained a null value, and the scope of the + * producer method or field was not {@link javax.enterprise.context.Dependent}. + *
+ */ +public class IllegalProductException extends InjectionException { + + private static final long serialVersionUID = -6280627846071966243L; + + public IllegalProductException() { + super(); + } + + public IllegalProductException(String message, Throwable cause) { + super(message, cause); + } + + public IllegalProductException(String message) { + super(message); + } + + public IllegalProductException(Throwable cause) { + super(cause); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/InjectionException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/InjectionException.java new file mode 100644 index 000000000..5f615c319 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/InjectionException.java @@ -0,0 +1,44 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +/** + *+ * Allows the application to dynamically obtain instances of beans with a specified combination of required type and qualifiers. + *
+ * + *+ * In certain situations, injection is not the most convenient way to obtain a contextual reference. For example, it may not be + * used when: + *
+ * + *+ * In these situations, an instance of the Instance may be injected: + *
+ * + *+ * @Inject + * Instance<PaymentProcessor> paymentProcessor; + *+ * + *
+ * Any combination of qualifiers may be specified at the injection point: + *
+ * + *+ * @Inject + * @PayBy(CHEQUE) + * Instance<PaymentProcessor> chequePaymentProcessor; + *+ * + *
+ * Or, the {@link javax.enterprise.inject.Any @Any} qualifier may be used, allowing the application to specify qualifiers + * dynamically: + *
+ * + *+ * @Inject + * @Any + * Instance<PaymentProcessor> anyPaymentProcessor; + *+ * + *
+ * Finally, the {@link javax.enterprise.inject.New @New} qualifier may be used, allowing the application to obtain a + * {@link javax.enterprise.inject.New @New} qualified bean: + *
+ * + *+ * @Inject + * @New(ChequePaymentProcessor.class) + * Instance<PaymentProcessor> chequePaymentProcessor; + *+ * + *
+ * For an injected Instance: + *
+ * + *+ * The inherited {@link javax.inject.Provider#get()} method returns a contextual references for the unique bean that matches the + * required type and required qualifiers and is eligible for injection into the class into which the parent Instance + * was injected, or throws an {@link javax.enterprise.inject.UnsatisfiedResolutionException} or + * {@link javax.enterprise.inject.AmbiguousResolutionException}. + *
+ * + *+ * PaymentProcessor pp = chequePaymentProcessor.get(); + *+ * + *
+ * The inherited {@link java.lang.Iterable#iterator()} method returns an iterator over contextual references for beans that + * match the required type and required qualifiers and are eligible for injection into the class into which the parent + * Instance was injected. + *
+ * + *+ * for (PaymentProcessor pp : anyPaymentProcessor) + * pp.test(); + *+ * + * @see javax.inject.Provider#get() + * @see java.lang.Iterable#iterator() + * @see javax.enterprise.util.AnnotationLiteral + * @see javax.enterprise.util.TypeLiteral + * + * @author Gavin King + * @author John Ament + * @author Martin Kouba + * + * @param
+ * Obtains a child Instance for the given additional required qualifiers. + *
+ * + * @param qualifiers the additional required qualifiers + * @return the child Instance + * @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that + * is not a qualifier type + * @throws IllegalStateException if the container is already shutdown + */ + Instance+ * Obtains a child Instance for the given required type and additional required qualifiers. + *
+ * + * @param the required type + * @param subtype a {@link java.lang.Class} representing the required type + * @param qualifiers the additional required qualifiers + * @return the child Instance + * @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that + * is not a qualifier type + * @throws IllegalStateException if the container is already shutdown + */ + Instance select(Class subtype, Annotation... qualifiers); + + /** + *+ * Obtains a child Instance for the given required type and additional required qualifiers. + *
+ * + * @param the required type + * @param subtype a {@link javax.enterprise.util.TypeLiteral} representing the required type + * @param qualifiers the additional required qualifiers + * @return the child Instance + * @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that + * is not a qualifier type + * @throws IllegalStateException if the container is already shutdown + */ + Instance select(TypeLiteral subtype, Annotation... qualifiers); + + /** + *+ * When called, provides back a Stream of the beans available in this Instance. If no beans are found, it returns an empty + * stream. + *
+ * + * @since 2.0 + * @return a Stream representing the beans associated with this {@link Instance} object + */ + default Stream+ * Determines if there is no bean that matches the required type and qualifiers and is eligible for injection into the class + * into which the parent Instance was injected. + *
+ * + * @return true if there is no bean that matches the required type and qualifiers and is eligible for injection + * into the class into which the parent Instance was injected, or false otherwise. + */ + boolean isUnsatisfied(); + + /** + *+ * Determines if there is more than one bean that matches the required type and qualifiers and is eligible for injection + * into the class into which the parent Instance was injected. + *
+ * + * @return true if there is more than one bean that matches the required type and qualifiers and is eligible for + * injection into the class into which the parent Instance was injected, or false otherwise. + */ + boolean isAmbiguous(); + + /** + *+ * Determines if there is exactly one bean that matches the required type and qualifiers and is eligible for injection + * into the class into which the parent Instance was injected. + *
+ * + * @since 2.0 + * @return true if there is exactly one bean that matches the required type and qualifiers and is eligible for + * injection into the class into which the parent Instance was injected, or false otherwise. + */ + default boolean isResolvable() { + return !isUnsatisfied() && !isAmbiguous(); + } + + /** + *+ * When called, the container destroys the instance if the active context object for the scope type of the bean supports + * destroying bean instances. All normal scoped built-in contexts support destroying bean instances. + *
+ * + *+ * The instance passed should either be a dependent scoped bean instance obtained from the same {@link Instance} object, or + * the client proxy for a normal scoped bean instance. + *
+ * + * + * @since 1.1 + * @param instance the instance to destroy + * @throws UnsupportedOperationException if the active context object for the scope type of the bean does not support + * destroying bean instances + */ + void destroy(T instance); + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Intercepted.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Intercepted.java new file mode 100644 index 000000000..67d89cd19 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Intercepted.java @@ -0,0 +1,56 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + *+ * An interceptor may inject metadata about the bean it is intercepting. + *
+ * + *+ * @Transactional @Interceptor + * public class TransactionInterceptor { + * + * @Inject @Intercepted Bean<?> bean; + * + * @AroundInvoke + * public Object manageTransaction(InvocationContext ctx) throws Exception { ... } + * + * } + *+ * + * @author Pete Muir + * @since 1.1 + */ + +@Target({ PARAMETER, FIELD }) +@Retention(RUNTIME) +@Documented +@Qualifier +public @interface Intercepted { +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Model.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Model.java new file mode 100644 index 000000000..c2e083c97 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Model.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + *
+ * The built-in stereotype intended for use with beans that define the model layer of an MVC web application architecture such + * as JSF. + *
+ * + * @see javax.enterprise.inject.Stereotype + * @author Gavin King + */ + +@Named +@RequestScoped +@Documented +@Stereotype +@Target({ TYPE, METHOD, FIELD }) +@Retention(RUNTIME) +public @interface Model { +} \ No newline at end of file diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/New.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/New.java new file mode 100644 index 000000000..a352bd22d --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/New.java @@ -0,0 +1,115 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.context.Dependent; +import javax.enterprise.util.AnnotationLiteral; +import javax.inject.Qualifier; + +/** + *+ * The {@link New} qualifier was deprecated in CDI 1.1. CDI applications are encouraged to inject {@link Dependent} scoped beans + * instead. + *
+ * + *+ * The @New qualifier allows the application to obtain a new instance of a bean which is not bound to the declared + * scope, but has had dependency injection performed. + *
+ * + *+ * @Produces @ConversationScoped + * @Special Order getSpecialOrder(@New(Order.class) Order order) { + * ... + * return order; + * } + *+ * + *
+ * When the @New qualifier is specified at an injection point and no {@link javax.enterprise.inject.New#value() + * value} member is explicitly specified, the container defaults the {@link javax.enterprise.inject.New#value() value} to the + * declared type of the injection point. So the following injection point has qualifier @New(Order.class): + *
+ * + *+ * @Produces @ConversationScoped + * @Special Order getSpecialOrder(@New Order order) { ... } + *+ * + * @author Gavin King + * @author Pete Muir + */ + +@Target({ FIELD, PARAMETER, METHOD, TYPE }) +@Retention(RUNTIME) +@Documented +@Qualifier +public @interface New { + /** + *
+ * Specifies the bean class of the new instance. The class must be the bean class of an enabled or disabled bean. The bean + * class need not be deployed in a bean archive. + *
+ * + *+ * Defaults to the declared type of the injection point if not specified. + *
+ * + * @return the bean class of the new instance + */ + Class> value() default New.class; + + /** + * Supports inline instantiation of the {@link New} qualifier. + * + * @author Martin Kouba + * @since 2.0 + */ + public final static class Literal extends AnnotationLiteral+ * Identifies a producer method or field. May be applied to a method or field of a bean class. + *
+ * + *+ * A producer method must be a non-abstract method of a managed bean class or session bean class. A producer method may be + * either static or non-static. If the bean is a session bean, the producer method must be either a business method of the EJB + * or a static method of the bean class. + *
+ * + *+ * public class Shop { + * @Produces @ApplicationScoped + * @Catalog @Named("catalog") + * List<Product> getProducts() { ... } + * ... + * } + *+ * + *
+ * A producer field must be a field of a managed bean class or session bean class. A producer field may be either static or + * non-static. If the bean is a session bean, the producer field must be a static field of the bean class. + *
+ * + *+ * public class Shop { + * @Produces @ApplicationScoped + * @Catalog @Named("catalog") + * List<Product> products = ...; + * ... + * } + *+ * + *
+ * If a producer method sometimes returns a null value, or if a producer field sometimes contains a null value when accessed, + * then the producer method or field must have scope {@link javax.enterprise.context.Dependent @Dependent}. + *
+ * + *+ * A producer method return type or producer field type may not be a type variable. + *
+ * + *+ * If the producer method return type or producer field type is a parameterized type, it must specify an actual type parameter + * or type variable for each type parameter. + *
+ * + *+ * If the producer method return type or producer field type is a parameterized type with a type variable, it must have scope + * {@link javax.enterprise.context.Dependent @Dependent}. + *
+ * + *+ * A producer method may have any number of parameters. All producer method parameters are injection points. + *
+ * + *+ * public class OrderFactory { + * + * @Produces + * @ConversationScoped + * public Order createCurrentOrder(Shop shop, @Selected Product product) { + * Order order = new Order(product, shop); + * return order; + * } + * + * } + *+ * + *
+ * A bean may declare multiple producer methods or fields. + *
+ * + *+ * Producer methods and fields are not inherited by bean subclasses. + *
+ * + *+ * Interceptors and decorators may not declare producer methods or fields. + *
+ * + * @see javax.enterprise.inject.Disposes @Disposes + * + * @author Gavin King + * @author Pete Muir + */ + +@Target({ METHOD, FIELD }) +@Retention(RUNTIME) +@Documented +public @interface Produces { +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/ResolutionException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/ResolutionException.java new file mode 100644 index 000000000..a9efb449a --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/ResolutionException.java @@ -0,0 +1,44 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +/** + *+ * Indicates that a bean directly specializes another bean. May be applied to a bean class or producer method. + *
+ * + *+ * If a bean directly specializes a second bean, it inherits: + *
+ * + *+ * If the second bean has a name, the bean may not declare a name using {@link javax.inject.Named @Named}. Furthermore, the + * bean must have all the bean types of the second bean. + *
+ * + *+ * If a bean is specialized by any enabled bean, the first bean is disabled. + *
+ * + * @author Gavin King + * @author Pete Muir + */ + +@Target({ TYPE, METHOD }) +@Retention(RUNTIME) +@Documented +public @interface Specializes { + + /** + * Supports inline instantiation of the {@link Specializes} annotation. + * + * @author Martin Kouba + * @since 2.0 + * @see Instance + * @see Event + */ + public static final class Literal extends AnnotationLiteral+ * Specifies that an annotation type is a stereotype. + *
+ * + *+ * In many systems, use of architectural patterns produces a set of recurring bean roles. A stereotype allows a framework + * developer to identify such a role and declare some common metadata for beans with that role in a central place. + *
+ * + *+ * A bean may declare zero, one or multiple stereotypes, by applying the stereotype annotation to the bean class or producer + * method or field. + *
+ * + *+ * A stereotype encapsulates any combination of: + *
+ * + *+ * The default scope of a stereotype is defined by annotating the stereotype with a scope type. A stereotype may declare at most + * one scope. If a bean explicitly declares a scope, any default scopes declared by its stereotypes are ignored. + *
+ * + *+ * @RequestScoped + * @Stereotype + * @Target(TYPE) + * @Retention(RUNTIME) + * public @interface Action { + * } + *+ * + *
+ * The interceptor bindings of a stereotype are defined by annotating the stereotype with the interceptor binding types. A + * stereotype may declare zero, one or multiple interceptor bindings. An interceptor binding declared by a stereotype is + * inherited by any bean that declares that stereotype. + *
+ * + *+ * @RequestScoped + * @Secure + * @Transactional + * @Stereotype + * @Target(TYPE) + * @Retention(RUNTIME) + * public @interface Action { + * } + *+ * + *
+ * A stereotype may also specify that: + *
+ * + *+ * A stereotype may declare an empty {@link javax.inject.Named @Named} annotation, which specifies that every bean with the + * stereotype has a defaulted name when a name is not explicitly specified by the bean. + *
+ * + *+ * @RequestScoped + * @Named + * @Secure + * @Transactional + * @Stereotype + * @Target(TYPE) + * @Retention(RUNTIME) + * public @interface Action { + * } + *+ * + *
+ * A stereotype may declare an {@link javax.enterprise.inject.Alternative @Alternative} annotation, which specifies that + * every bean with the stereotype is an alternative. + *
+ * + *+ * @Alternative + * @Stereotype + * @Target(TYPE) + * @Retention(RUNTIME) + * public @interface Mock { + * } + *+ * + *
+ * A stereotype may declare other stereotypes. Stereotype declarations are transitive. A stereotype declared by a second + * stereotype is inherited by all beans and other stereotypes that declare the second stereotype. + *
+ * + * @see javax.enterprise.inject.Model the built-in stereotype @Model + * + * @author Pete Muir + * @author Gavin King + */ + +@Retention(RUNTIME) +@Target(ANNOTATION_TYPE) +@Documented +public @interface Stereotype { +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/TransientReference.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/TransientReference.java new file mode 100644 index 000000000..0e7c7867d --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/TransientReference.java @@ -0,0 +1,72 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.enterprise.event.Event; +import javax.enterprise.util.AnnotationLiteral; + +/** + *+ * If a parameter annotated with @TransientReference resolves to a dependent scoped bean, then the bean will be + * destroyed after the invocation completes. + *
+ * + *+ * public class OrderManager { + * + * @Inject + * public OrderManager(@TransientReference Order order) { + * ... + * + * } + * } + *+ * + * @author Pete Muir + * @since 1.1 + */ + +@Target(PARAMETER) +@Retention(RUNTIME) +@Documented +public @interface TransientReference { + + /** + * Supports inline instantiation of the {@link TransientReference} annotation. + * + * @author Martin Kouba + * @since 2.0 + * @see Instance + * @see Event + */ + public static final class Literal extends AnnotationLiteral
+ * Restricts the bean types of a bean. May be applied to a bean class or producer method or field. + *
+ * + *+ * @Typed(Shop.class) + * public class BookShop + * extends Business + * implements Shop<Book> { + * ... + * } + *+ * + *
+ * When a @Typed annotation is specified, only the types whose classes are explicitly listed using the + * {@link javax.enterprise.inject.Typed#value() value} member, along with {@link java.lang.Object}, are bean types of the bean. + *
+ * + * @author Pete Muir + * @author Gavin King + * + */ +@Target({ FIELD, METHOD, TYPE }) +@Retention(RUNTIME) +@Documented +public @interface Typed { + /** + *+ * Selects the bean types of the bean. Every class must correspond to a type in the unrestricted set of bean types of a + * bean. + *
+ * + * @return the classes corresponding to the bean types of the bean + */ + Class>[] value() default {}; + + /** + * Supports inline instantiation of the {@link Typed} annotation. + * + * @author Martin Kouba + * @since 2.0 + */ + public final static class Literal extends AnnotationLiteral+ * Indicates that a contextual reference for a bean with a normal scope and a certain bean type cannot be obtained because the + * bean type cannot be proxied by the container. + *
+ * + * @author Pete Muir + * @author Gavin King + */ +public class UnproxyableResolutionException extends ResolutionException { + + private static final long serialVersionUID = 1667539354548135465L; + + public UnproxyableResolutionException() { + super(); + } + + public UnproxyableResolutionException(String message, Throwable throwable) { + super(message, throwable); + } + + public UnproxyableResolutionException(String message) { + super(message); + } + + public UnproxyableResolutionException(Throwable throwable) { + super(throwable); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnsatisfiedResolutionException.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnsatisfiedResolutionException.java new file mode 100644 index 000000000..79f08566f --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnsatisfiedResolutionException.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +/** + *+ * Indicates that no bean matches a certain combination of required type and required qualifiers and is eligible for injection + * into a certain class. + *
+ * + * @author Pete Muir + * @author Gavin King + */ +public class UnsatisfiedResolutionException extends ResolutionException { + + private static final long serialVersionUID = 5350603312442756709L; + + public UnsatisfiedResolutionException() { + super(); + } + + public UnsatisfiedResolutionException(String message, Throwable throwable) { + super(message, throwable); + } + + public UnsatisfiedResolutionException(String message) { + super(message); + } + + public UnsatisfiedResolutionException(Throwable throwable) { + super(throwable); + } + +} diff --git a/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Vetoed.java b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Vetoed.java new file mode 100644 index 000000000..11ccba438 --- /dev/null +++ b/fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Vetoed.java @@ -0,0 +1,69 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2013, Red Hat, Inc., and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * 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 javax.enterprise.inject; + +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 javax.enterprise.event.Event; +import javax.enterprise.util.AnnotationLiteral; + +/** + *+ * Veto the processing of the class. Any beans or observer methods defined by this class will not be installed. + *
+ * + *+ * When placed on package, all beans in the package are prevented from being installed. If packages are split across jars, + * non-portable behavior results. An application can prevent packages being split across jars by sealing the package. + *
+ * + *+ * No container lifecycle events are fired for classes annotated {@link Vetoed}. + *
+ * + * @author Stuart Douglas + * @since 1.1 + * @see JAR File Specification + * + */ +@Target({ ElementType.TYPE, ElementType.PACKAGE }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Vetoed { + + /** + * Supports inline instantiation of the {@link Vetoed} annotation. + * + * @author Martin Kouba + * @since 2.0 + * @see Instance + * @see Event + */ + public static final class Literal extends AnnotationLiteral+ * SeContainer implements {@link Instance} and therefore might be used to perform programmatic lookup. + * If no qualifier is passed to {@link #select} method, the @Default qualifier is assumed. + *
+ * + * @author Antoine Sabot-Durand + * @author John D. Ament + * @since 2.0 + */ +public interface SeContainer extends Instance