pax_global_header00006660000000000000000000000064116600072230014507gustar00rootroot0000000000000052 comment=1098f0cb2c3c7b82abc783d22ce94b0efaf4e905 cdi-api-1.0/000077500000000000000000000000001166000722300126555ustar00rootroot00000000000000cdi-api-1.0/src/000077500000000000000000000000001166000722300134445ustar00rootroot00000000000000cdi-api-1.0/src/META-INF/000077500000000000000000000000001166000722300146045ustar00rootroot00000000000000cdi-api-1.0/src/META-INF/MANIFEST.MF000066400000000000000000000001421166000722300162330ustar00rootroot00000000000000Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: 14.1-b02-90 (Apple Inc.) cdi-api-1.0/src/beans.xsd000066400000000000000000000041431166000722300152560ustar00rootroot00000000000000 cdi-api-1.0/src/javax/000077500000000000000000000000001166000722300145555ustar00rootroot00000000000000cdi-api-1.0/src/javax/decorator/000077500000000000000000000000001166000722300165375ustar00rootroot00000000000000cdi-api-1.0/src/javax/decorator/Decorator.java000066400000000000000000000034321166000722300213260ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 { } cdi-api-1.0/src/javax/decorator/Delegate.java000066400000000000000000000055541166000722300211250ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 { } cdi-api-1.0/src/javax/decorator/package-info.java000066400000000000000000000060151166000722300217300ustar00rootroot00000000000000/** *

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.

* *

Decorated types

* *

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.

* *

Delegate injection points

* *

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.

* *

Enabled decorators

* *

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; cdi-api-1.0/src/javax/enterprise/000077500000000000000000000000001166000722300167355ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/context/000077500000000000000000000000001166000722300204215ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/context/ApplicationScoped.java000066400000000000000000000055151166000722300246730ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

Specifies that a bean is application scoped.

* *

The application scope is active:

* * * *

The application context is shared between all servlet * requests, asynchronous observer method notifications, 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.

* * @author Gavin King * @author Pete Muir */ @Target( { TYPE, METHOD, FIELD }) @Retention(RUNTIME) @Documented @NormalScope @Inherited public @interface ApplicationScoped { } cdi-api-1.0/src/javax/enterprise/context/BusyConversationException.java000066400000000000000000000036521166000722300264660ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 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); } } cdi-api-1.0/src/javax/enterprise/context/ContextException.java000066400000000000000000000025641166000722300245760ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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); } } cdi-api-1.0/src/javax/enterprise/context/ContextNotActiveException.java000066400000000000000000000027351166000722300264130ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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); } } cdi-api-1.0/src/javax/enterprise/context/Conversation.java000066400000000000000000000063441166000722300237450ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.

* * @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(); }cdi-api-1.0/src/javax/enterprise/context/ConversationScoped.java000066400000000000000000000120301166000722300250700ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.Retention; import java.lang.annotation.Target; /** *

Specifies that a bean is conversation scoped.

* *

The conversation scope is active:

* * * *

The conversation context provides access to state associated * with a particular conversation. Every JSF 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 JSF request * is in the transient state at the end of a JSF request, it is * destroyed, and the conversation context is also destroyed.

* *

If the conversation associated with the current JSF request * is in the long-running state at the end of a JSF request, it is * not destroyed. Instead, it may be propagated to other requests * according to the following rules:

* * * *

When no conversation is propagated to a JSF request, 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 reassociated with the request:

* * * * @see javax.enterprise.context.Conversation * @see javax.enterprise.context.NonexistentConversationException * @see javax.enterprise.context.BusyConversationException * * @author Gavin King * @author Pete Muir */ @Target( { TYPE, METHOD, FIELD }) @Retention(RUNTIME) @Documented @NormalScope(passivating = true) public @interface ConversationScoped { } cdi-api-1.0/src/javax/enterprise/context/Dependent.java000066400000000000000000000106611166000722300231760ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.context.spi.Contextual; import javax.inject.Scope; /** *

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 { } cdi-api-1.0/src/javax/enterprise/context/NonexistentConversationException.java000066400000000000000000000034061166000722300300570ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 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 from the * restore view phase of the JSF lifecycle.

* * @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); } } cdi-api-1.0/src/javax/enterprise/context/NormalScope.java000066400000000000000000000034511166000722300235110ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; } cdi-api-1.0/src/javax/enterprise/context/RequestScoped.java000066400000000000000000000054361166000722300240620ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

Specifies that a bean is request scoped.

* *

The request scope is active:

* * * *

The request context is destroyed:

* * * * @author Gavin King * @author Pete Muir */ @Target( { TYPE, METHOD, FIELD }) @Retention(RUNTIME) @Documented @NormalScope @Inherited public @interface RequestScoped { } cdi-api-1.0/src/javax/enterprise/context/SessionScoped.java000066400000000000000000000042141166000722300240460ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

Specifies that a bean is session scoped.

* *

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 when the HTTPSession times out, * after all HttpSessionListeners have been called, * and at the very end of any request in which * invalidate() was called, after all filters and * ServletRequestListeners have been called.

* * @author Gavin King * @author Pete Muir */ @Target( { TYPE, METHOD, FIELD }) @Retention(RUNTIME) @Documented @NormalScope(passivating = true) @Inherited public @interface SessionScoped { } cdi-api-1.0/src/javax/enterprise/context/package-info.java000066400000000000000000000127551166000722300236220ustar00rootroot00000000000000/** *

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:

* * * *

Built-in scopes

* *

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.

* *

Normal scopes and pseudo-scopes

* *

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(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.

* *

Contextual and injected reference validity

* *

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:

* * * * @see javax.enterprise.inject * */ package javax.enterprise.context;cdi-api-1.0/src/javax/enterprise/context/spi/000077500000000000000000000000001166000722300212145ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/context/spi/Context.java000066400000000000000000000064601166000722300235110ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 java.lang.annotation.Annotation; import javax.enterprise.context.ContextNotActiveException; /** *

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.

* *

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)}.

* * @author Gavin King * @author Pete Muir */ public interface Context { /** * Get the scope type of the context object. * * @return the scope */ public Class getScope(); /** * Return an existing instance of certain contextual type or create a new * instance by calling * {@link javax.enterprise.context.spi.Contextual#create(CreationalContext)} * and return the new instance. * * @param the type of contextual type * @param contextual the contextual type * @param creationalContext the context in which the new instance will be created * @return the contextual instance * * @throws ContextNotActiveException if the context is not active */ public T get(Contextual contextual, CreationalContext creationalContext); /** * Return an existing instance of a certain contextual type or a null value. * * @param the type of the contextual type * @param contextual the contextual type * @return the contextual instance, or a null value * * @throws ContextNotActiveException if the context is not active */ public T get(Contextual contextual); /** * Determines if the context object is active. * * @return true if the context is active, or false otherwise. */ boolean isActive(); } cdi-api-1.0/src/javax/enterprise/context/spi/Contextual.java000066400000000000000000000051151166000722300242070ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.inject.CreationException; /** *

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.

* * @see javax.enterprise.inject.spi.Bean * * @author Gavin King * @author Nicklas Karlsson * @author Pete Muir */ public interface Contextual { /** * Create a new instance of the contextual type. Instances should * use the given {@link javax.enterprise.context.spi.CreationalContext} * when obtaining contextual references to inject, in order to ensure * that any dependent objects are associated with the contextual instance * that is being created. An implementation may call * {@link javax.enterprise.context.spi.CreationalContext#push(Object)} * between instantiation and injection to help the container minimize the * use of client proxy objects. * * @param creationalContext * the context in which this instance is being created * @return the contextual instance * @throws CreationException * if a checked exception occurs while creating the instance */ public T create(CreationalContext creationalContext); /** * Destroy an instance of the contextual type. Implementations should * call {@link javax.enterprise.context.spi.CreationalContext#release()} * to allow the container to destroy dependent objects of the contextual * instance. * * @param instance * the contextual instance to destroy * @param creationalContext * the context in which this instance was created */ public void destroy(T instance, CreationalContext creationalContext); } cdi-api-1.0/src/javax/enterprise/context/spi/CreationalContext.java000066400000000000000000000033151166000722300255070ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

Provides operations that are used by the * {@link javax.enterprise.context.spi.Contextual} implementation during * instance creation and destruction.

* * @author Gavin King * @author Pete Muir * */ public interface CreationalContext { /** * Registers an incompletely initialized contextual instance the with the * container. A contextual instance is considered incompletely initialized * until it is returned by * {@link javax.enterprise.context.spi.Contextual#create(CreationalContext)}. * * @param incompleteInstance the incompletely initialized instance */ public void push(T incompleteInstance); /** * Destroys all dependent objects of the instance which is being destroyed, * by passing each dependent object to * {@link javax.enterprise.context.spi.Contextual#destroy(Object, CreationalContext)}. */ public void release(); } cdi-api-1.0/src/javax/enterprise/context/spi/package-info.java000066400000000000000000000012061166000722300244020ustar00rootroot00000000000000/** *

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.

* * @see javax.enterprise.context * @see javax.enterprise.inject.spi */ package javax.enterprise.context.spi;cdi-api-1.0/src/javax/enterprise/event/000077500000000000000000000000001166000722300200565ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/event/Event.java000066400000000000000000000101001166000722300217720ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; import java.lang.annotation.Annotation; import javax.enterprise.util.TypeLiteral; /** *

Allows the application to fire events of a particular type.

* *

Beans fire events via an instance of the Event * interface, which may be injected:

* *
 * @Inject @Any Event<LoggedInEvent> loggedInEvent;
 * 
* *

The fire() method accepts an event object:

* *
 * public void login() { 
 *    ...
 *    loggedInEvent.fire( new LoggedInEvent(user) );
 * }
 * 
* *

Any combination of qualifiers may be specified at the injection * point:

* *
 * @Inject @Admin Event<LoggedInEvent> adminLoggedInEvent;
 * 
* *

Or, the {@link javax.enterprise.inject.Any @Any} qualifier may * be used, allowing the application to specify qualifiers dynamically:

* *
 * @Inject @Any Event<LoggedInEvent> loggedInEvent;
 * 
* *

For an injected Event:

* *
    *
  • the specified type is the type parameter specified at the * injection point, and
  • *
  • the specified qualifiers are the qualifiers specified at * the injection point.
  • *
* * @author Gavin King * @author Pete Muir * @author David Allen * * @param the type of the event object */ public interface Event { /** *

Fires an event with the specified qualifiers and notifies * observers.

* * @param event the event object * @throws IllegalArgumentException if the runtime type of the event object contains a type variable */ public void fire(T event); /** *

Obtains a child Event for the given additional * required qualifiers.

* * @param qualifiers the additional specified qualifiers * @return the child Event * @throws IllegalArgumentException if passed two instances of the * same qualifier type, or an instance of an annotation that is not * a qualifier type */ public Event select(Annotation... qualifiers); /** *

Obtains a child Event for the given required type and * additional required qualifiers.

* * @param the specified type * @param subtype a {@link java.lang.Class} representing the specified type * @param qualifiers the additional specified qualifiers * @return the child Event * @throws IllegalArgumentException if passed two instances of the * same qualifier type, or an instance of an annotation that is not * a qualifier type */ public Event select(Class subtype, Annotation... qualifiers); /** *

Obtains a child Event for the given required type and * additional required qualifiers.

* * @param the specified type * @param subtype a {@link javax.enterprise.util.TypeLiteral} representing the specified type * @param qualifiers the additional specified qualifiers * @return the child Event * @throws IllegalArgumentException if passed two instances of the * same qualifier type, or an instance of an annotation that is not * a qualifier type */ public Event select(TypeLiteral subtype, Annotation... qualifiers); } cdi-api-1.0/src/javax/enterprise/event/ObserverException.java000066400000000000000000000026041166000722300243710ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

Indicates that a checked exception was thrown by an * observer method during event notification.

* * @author Pete Muir * @author Gavin King */ public class ObserverException extends RuntimeException { private static final long serialVersionUID = -801836224808304381L; public ObserverException() { } public ObserverException(String message) { super(message); } public ObserverException(Throwable cause) { super(cause); } public ObserverException(String message, Throwable cause) { super(message, cause); } } cdi-api-1.0/src/javax/enterprise/event/Observes.java000066400000000000000000000063071166000722300225170ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; 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 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}.

* *
 * public void afterLogin(@Observes LoggedInEvent event) { ... }
 * 
* *

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.

* *

A bean (or extension) may declare multiple observer methods.

* *

Observer methods are inherited by bean subclasses.

* *

Interceptors and decorators may not declare observer * methods.

* * @author Gavin King * @author Pete Muir * @author David Allen */ @Target(PARAMETER) @Retention(RUNTIME) @Documented public @interface Observes { /** *

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.

*/ public Reception notifyObserver() default Reception.ALWAYS; /** *

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.

*/ public TransactionPhase during() default TransactionPhase.IN_PROGRESS; } cdi-api-1.0/src/javax/enterprise/event/Reception.java000066400000000000000000000032231166000722300226510ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

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.

* * @author Gavin King * @author Dan Allen * @author David Allen */ public enum Reception { /** * Specifies that an observer method is only called if the current instance * of the bean declaring the observer method already exists. */ IF_EXISTS, /** * Specifies that an observer method always receives event notifications. */ ALWAYS }cdi-api-1.0/src/javax/enterprise/event/TransactionPhase.java000066400000000000000000000043611166000722300241730ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

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.

* * @author Pete Muir * @author Gavin King * */ public enum TransactionPhase { /** *

Identifies a regular observer method, called when the event * is fired.

*/ IN_PROGRESS, /** *

Identifies a before completion observer method, called during * the before completion phase of the transaction.

*/ BEFORE_COMPLETION, /** *

Identifies an after completion observer method, called during the * after completion phase of the transaction.

*/ AFTER_COMPLETION, /** *

Identifies an after failure observer method, called during the * after completion phase of the transaction, only when the transaction * fails.

*/ AFTER_FAILURE, /** *

Identifies an after success observer method, called during the * after completion phase of the transaction, only when the transaction * completes successfully.

*/ AFTER_SUCCESS } cdi-api-1.0/src/javax/enterprise/event/package-info.java000066400000000000000000000072631166000722300232550ustar00rootroot00000000000000/** *

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.

* *

An event comprises:

* *
    *
  • A Java object, called the event object
  • *
  • A (possibly empty) set of instances of qualifier types, called * the event qualifiers
  • *
* *

The {@link javax.enterprise.event.Event} interface is used to * fire events.

* *

Event objects and event types

* *

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.

* *

Event qualifiers

* *

The event qualifiers act as topic selectors, allowing the consumer * to narrow the set of events it observes. An event qualfier may be an * instance of any {@linkplain javax.inject.Qualifier qualifier type}.

* *

Observer methods

* *

An {@linkplain javax.enterprise.event.Observes observer method} * allows the application to receive and respond to event notifications. * It acts as event consumer, 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}.

* *

An observer method will be notified of an event if:

* *
    *
  • the event object is assignable to the type observed by the observer * method,
  • *
  • the observer method has all the event qualifiers of the event, and
  • *
  • either the event is not a * {@linkplain javax.enterprise.inject.spi container lifecycle event}, or * the observer method belongs to an * {@linkplain javax.enterprise.inject.spi.Extension extension}. *
* *

If the 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 is not defined, and * so portable applications should not rely upon the order in which * observers are called.

* *

Observer methods may throw exceptions:

* *
    *
  • If the observer method is a * {@linkplain javax.enterprise.event.TransactionPhase transactional * observer method}, any exception is caught and logged by the container.
  • *
  • Otherwise, the exception aborts processing of the event. * No other observer methods of that event will be called. The * exception is rethrown. If the exception is a checked exception, * it is wrapped and rethrown as an (unchecked) * {@link javax.enterprise.event.ObserverException}.
  • *
* * @see javax.enterprise.inject * * @see javax.enterprise.event.Observes * @see javax.enterprise.event.Event * @see javax.inject.Qualifier */ package javax.enterprise.event; cdi-api-1.0/src/javax/enterprise/inject/000077500000000000000000000000001166000722300202115ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/inject/Alternative.java000066400000000000000000000051741166000722300233410ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

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:

* *
    *
  • the alternative is a managed bean or session bean and the * bean class of the bean is listed,
  • *
  • the alternative is a producer method, field or resource, * and the bean class that declares the method or field is listed, * or
  • *
  • any @Alternative stereotype of the alternative * is listed.
  • *
* * @author Gavin King * @author Pete Muir */ @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) @Documented public @interface Alternative { } cdi-api-1.0/src/javax/enterprise/inject/AmbiguousResolutionException.java000066400000000000000000000030311166000722300267470ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 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); } } cdi-api-1.0/src/javax/enterprise/inject/Any.java000066400000000000000000000042631166000722300216100ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.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 { } cdi-api-1.0/src/javax/enterprise/inject/CreationException.java000066400000000000000000000025521166000722300245030ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 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); } } cdi-api-1.0/src/javax/enterprise/inject/Default.java000066400000000000000000000047011166000722300224420ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.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 { } cdi-api-1.0/src/javax/enterprise/inject/Disposes.java000066400000000000000000000061251166000722300226510ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

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();
 *    }
 *
 * }
 * 
* *

A disposer method allows the application to perform * customized cleanup of an object returned by a * {@linkplain javax.enterprise.inject.Produces producer method}.

* *

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 return type. When searching for disposer methods * for a producer method, the container considers the type * and qualifiers of the disposed parameter. If a disposed * parameter resolves to a producer method declared by the * same bean class, the container must call this method when * destroying any instance returned by that producer method.

* *

A disposer method may resolve to multiple producer * methods declared by the bean class, in which case the * container must call it when destroying any instance * returned by any of these producer methods.

* *

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 { } cdi-api-1.0/src/javax/enterprise/inject/IllegalProductException.java000066400000000000000000000027421166000722300256520ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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); } } cdi-api-1.0/src/javax/enterprise/inject/InjectionException.java000066400000000000000000000025451166000722300246630ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 a problem relating to dependency injection. * * @author Pete Muir */ public class InjectionException extends RuntimeException { private static final long serialVersionUID = -2132733164534544788L; public InjectionException() { } public InjectionException(String message, Throwable throwable) { super(message, throwable); } public InjectionException(String message) { super(message); } public InjectionException(Throwable throwable) { super(throwable); } } cdi-api-1.0/src/javax/enterprise/inject/Instance.java000066400000000000000000000150271166000722300226250ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.Annotation; import javax.enterprise.util.TypeLiteral; import javax.inject.Provider; /** *

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:

* *
    *
  • the bean type or qualifiers vary dynamically at runtime, or
  • *
  • depending upon the deployment, there may be no bean which * satisfies the type and qualifiers, or
  • *
  • we would like to iterate over all beans of a certain type.
  • *
* *

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 required type is the type parameter specified at the * injection point, and
  • *
  • the required qualifiers are the qualifiers specified at * the injection point.
  • *
* *

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 * * @param the required bean type */ public interface Instance extends Iterable, Provider { /** *

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 qualifier type, or an instance of an annotation that is not * a qualifier type */ public Instance select(Annotation... qualifiers); /** *

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 qualifier type, or an instance of an annotation that is not * a qualifier type */ public 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 qualifier type, or an instance of an annotation that is not * a qualifier type */ public Instance select(TypeLiteral subtype, Annotation... qualifiers); /** *

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. */ public 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. */ public boolean isAmbiguous(); } cdi-api-1.0/src/javax/enterprise/inject/Model.java000066400000000000000000000014431166000722300221160ustar00rootroot00000000000000package 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 { }cdi-api-1.0/src/javax/enterprise/inject/New.java000066400000000000000000000053261166000722300216130ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.inject.Qualifier; /** *

The built-in qualifier type.

* *

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; } cdi-api-1.0/src/javax/enterprise/inject/Produces.java000066400000000000000000000064471166000722300226530ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * *

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 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 { } cdi-api-1.0/src/javax/enterprise/inject/ResolutionException.java000066400000000000000000000025201166000722300250750ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 a problem relating to typesafe resolution. * * @author Gavin King */ public class ResolutionException extends InjectionException { private static final long serialVersionUID = -6280627846071966243L; public ResolutionException() { super(); } public ResolutionException(String message, Throwable cause) { super(message, cause); } public ResolutionException(String message) { super(message); } public ResolutionException(Throwable cause) { super(cause); } } cdi-api-1.0/src/javax/enterprise/inject/Specializes.java000066400000000000000000000051261166000722300233330ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.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; /** *

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:

* *
    *
  • all qualifiers of the second bean, and
  • *
  • the name, if any, of the second bean.
  • *
* *

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 class of a managed bean is annotated * @Specializes, then the bean class must * directly extend the bean class of a second managed bean. * Then the first managed bean directly specializes the * second managed bean.
  • * *
  • If a bean class of a session bean is annotated * @Specializes, then the bean class must * directly extend the bean class of a second session bean. * Then the first session bean directly specializes the * second session bean.
  • * *
  • If a producer method is annotated * @Specializes, then it must be non-static * and directly override another producer method. Then the * first producer method directly specializes the second * producer method.
  • *
* *

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 { } cdi-api-1.0/src/javax/enterprise/inject/Stereotype.java000066400000000000000000000100111166000722300232100ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.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 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:

* *
    *
  • a default scope, and
  • *
  • a set of interceptor bindings.
  • *
* *

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:

* *
    *
  • all beans with the stereotype have defaulted bean EL names, or * that
  • *
  • all beans with the stereotype are alternatives.
  • *
* *

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 {} cdi-api-1.0/src/javax/enterprise/inject/Typed.java000066400000000000000000000041241166000722300221420ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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; /** *

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 {}; } cdi-api-1.0/src/javax/enterprise/inject/UnproxyableResolutionException.java000066400000000000000000000030761166000722300273350ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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 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); } } cdi-api-1.0/src/javax/enterprise/inject/UnsatisfiedResolutionException.java000066400000000000000000000030431166000722300272750ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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); } } cdi-api-1.0/src/javax/enterprise/inject/package-info.java000066400000000000000000000426051166000722300234070ustar00rootroot00000000000000/** *

Annotations relating to bean and stereotype definition, * built-in qualifiers, and interfaces and classes relating * to programmatic lookup.

* *

A bean is a source of contextual objects which define application * state and/or logic. These objects are called contextual instances of * the bean. The container creates and destroys these instances and * associates them with the appropriate * {@linkplain javax.enterprise.context.spi.Context context}. Contextual * instances of a bean may be injected into other objects (including * other bean instances) that execute in the same context, and may be * used in Unified EL expressions that are evaluated in the same * context.

* *

The lifecycle of contextual instances is managed by the container * according to the * {@linkplain javax.enterprise.context lifecycle context model}. * Annotations define the lifecycle of the bean and its interactions * with other beans.

* *

A bean comprises the following attributes:

* *
    *
  • A (nonempty) set of bean types
  • *
  • A (nonempty) set of qualifiers
  • *
  • A scope
  • *
  • Optionally, a bean EL name
  • *
  • A set of interceptor bindings
  • *
  • A bean implementation
  • *
* *

Bean types

* *

A bean type is a client-visible type of the bean. A * bean may have multiple bean types. The following bean has * bean types BookShop, Business, * Shop<Book> and {@link java.lang.Object}.

* *
 * public class BookShop 
 *       extends Business 
 *       implements Shop<Book> { 
 *    ... 
 * } 
 * 
* *

Almost any Java type may be a bean type of a bean: * *

    *
  • A bean type may be an interface, a concrete class or an * abstract class, and may be declared final or have final methods.
  • *
  • A bean type may be a parameterized type with actual type * parameters and type variables.
  • *
  • A bean type may be an array type. Two array types are * considered identical only if the element type is identical.
  • *
  • A bean type may be a primitive type. Primitive types are * considered to be identical to their corresponding wrapper types * in java.lang.
  • *
  • A bean type may be a raw type.
  • *
* *

A type variable is not a legal bean type. A parameterized type * that contains a wildcard type parameter is not a legal bean type.

* *

The bean types of a bean are determined automatically. However, * the set of bean types may be resticted using the * {@link javax.enterprise.inject.Typed @Typed} annotation.

* *

Qualifiers

* *

A {@linkplain javax.inject.Qualifier qualifier} represents some * client-visible semantic associated with a type that is satisfied * by some implementations of the type (and not by others). Qualifiers * are applied to injection points to distinguish which implementation * is required by the client.

* *
 * @Inject @Synchronous PaymentProcessor paymentProcessor; 
 * 
* *

A qualifier type is a Java annotation annotated * {@link javax.inject.Qualifier @Qualifier}. * The qualifiers of a bean are declared by annotating the bean class * or producer method or field with the qualifier types.

* *
 * @Synchronous @Reliable 
 * class SynchronousReliablePaymentProcessor 
 *       implements PaymentProcessor { 
 *    ... 
 * } 
 * 
* *

If a bean does not explicitly declare a qualifier other than * {@link javax.inject.Named @Named}, the bean has the qualifier * {@link javax.enterprise.inject.Default @Default}.

* *

Scope

* *

All beans have a {@linkplain javax.enterprise.context scope}. The * scope of a bean determines the lifecycle of its instances, and which * instances of the bean are visible to instances of other beans.

* *

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 is defined by annotating the bean class or producer * method or field with a scope type or with a stereotype that declares a * default scope.

* *
 * @ConversationScoped 
 * public class Order { ... } 
 * 
* *

A bean class or producer method or field may specify at most one * scope type annotation.

* *

If the bean does not explicitly declare a scope or a stereotype * with a default scope, the scope defaults to * {@link javax.enterprise.context.Dependent @Dependent}.

* *

Bean EL name

* *

A bean may have a bean EL name. A bean with an EL name may be referred * to by its name in {@linkplain javax.el Unified EL} expressions. A valid * bean EL name is a period-separated list of valid EL identifiers.

* *

To specify the EL name of a bean, the qualifier * {@link javax.inject.Named @Named} is applied to the bean class or * producer method or field. * *

 * @Named("currentOrder") 
 * public class Order { ... } 
 * 
* * If the @Named annotation does not specify the * {@link javax.inject.Named#value() value} member, the EL name is defaulted. * *

Interceptor bindings

* *

{@linkplain javax.interceptor Interceptors} may be bound to any managed * bean that is not itself an interceptor or decorator or to any EJB session * or message-driven bean. An interceptor that is annotated * {@link javax.interceptor.Interceptor @Interceptor} may be identified * by its interceptor bindings.

* *
 * @Transactional @Interceptor
 * public class TransactionInterceptor {
 *    @AroundInvoke 
 *    public Object manageTransaction(InvocationContext ctx) { ... }
 * }
 * 
* *

An interceptor binding type is a Java annotation annotated * {@link javax.interceptor.InterceptorBinding @InterceptorBinding}. * An interceptor binding of a bean may be declared by annotating the bean * class, or a method of the bean class, with an interceptor binding type * or with a stereotype that declares the interceptor binding.

* *

In the following example, the TransactionInterceptor will be * applied at the class level, and therefore applies to all business methods * of the class: * *

 * @Transactional 
 * public class ShoppingCart { ... }
 * 
* *

In this example, the TransactionInterceptor will be applied at * the method level:

* *
 * public class ShoppingCart { 
 *    @Transactional 
 *    public void placeOrder() { ... } 
 * } 
 * 
* *

If a managed bean class is declared final, it may not have any interceptor * bindings. If a managed bean has a non-static, non-private, final method, it * may not have any class-level interceptor bindings, and that method may not * have any method-level interceptor bindings.

* *

Bean implementation

* *

The container provides built-in support for injection and contextual * lifecycle management of the following kinds of bean:

* *
    *
  • Managed beans
  • *
  • Session beans
  • *
  • Producer methods and fields
  • *
  • Resources (Java EE resources, persistence contexts, persistence units, * remote EJBs and web services)
  • *
* *

Managed beans

* *

A managed bean is a bean that is implemented by a Java class. The basic * lifecycle and semantics of managed beans are defined by the Managed Beans * specification.

* *

A top-level Java class is a managed bean if it is defined to be a managed * bean by any other Java EE specification, or if it meets all of the following * conditions:

* *
    *
  • It is not a non-static inner class.
  • *
  • It is a concrete class, or is annotated * {@link javax.decorator.Decorator @Decorator}.
  • *
  • It is not annotated with an EJB component-defining annotation or declared * as an EJB bean class in ejb-jar.xml.
  • *
  • It does not implement {@link javax.enterprise.inject.spi.Extension}.
  • *
  • It has an appropriate constructor; either the class has a constructor with * no parameters, or the class declares a constructor annotated * {@link javax.inject.Inject @Inject}.
  • *
* *

All Java classes that meet these conditions are managed beans and thus no * special declaration is required to define a managed bean. Optionally, a * managed bean may be annotated {@link javax.annotation.ManagedBean}.

* *

If a managed bean has a public field, it must have scope * {@link javax.enterprise.context.Dependent @Dependent}.

* *

If the managed bean class is a generic type, it must have scope * {@link javax.enterprise.context.Dependent @Dependent}.

* *

Session beans

* *

The basic lifecycle and semantics of EJB session beans are defined by the * EJB specification.

* *
    *
  • A {@linkplain javax.ejb.Stateless stateless session bean} must belong to * the {@link javax.enterprise.context.Dependent @Dependent} pseudo-scope.
  • *
  • A {@linkplain javax.ejb.Singleton singleton bean} must belong to either the * {@link javax.enterprise.context.ApplicationScoped @ApplicationScoped} * scope or to the {@link javax.enterprise.context.Dependent @Dependent} * pseudo-scope.
  • *
  • A {@linkplain javax.ejb.Stateful stateful session bean} may have any scope.
  • *
* *

If the session bean class is a generic type, it must have scope * {@link javax.enterprise.context.Dependent @Dependent}.

* *

If a session bean is a stateful session bean:

* *
    *
  • If the scope is {@link javax.enterprise.context.Dependent @Dependent}, * the application may call any EJB remove method of a contextual instance of the * session bean.
  • *
  • Otherwise, the application may not directly call any EJB remove method of * any contextual instance of the session bean.
  • *
* *

Producer methods and fields

* *

A {@linkplain javax.enterprise.inject.Produces producer method or field} * acts as a source of objects to be injected, where:

* *
    *
  • the objects to be injected are not required to be instances of beans, or
  • *
  • the concrete type of the objects to be injected may vary at runtime, or
  • *
  • the objects require some custom initialization that is not performed by * the bean constructor.
  • *
* *

A producer method or field is a method or field of a bean class annotated * {@link javax.enterprise.inject.Produces @Produces}.

* *

A common pattern in generic code is a producer method that injects an * {@link javax.enterprise.inject.spi.InjectionPoint} object.

* *

Resources

* *

A resource is a bean that represents a reference to a resource, persistence * context, persistence unit, remote EJB or web service in the Java EE component * environment.

* *

A resource may be declared by specifying a Java EE component environment * injection annotation as part of a producer field declaration.

* *
    *
  • For a Java EE resource, @Resource must be specified.
  • *
  • For a persistence context, @PersistenceContext must be specified. *
  • For a persistence unit, @PersistenceUnit must be specified. *
  • For a remote EJB, @EJB must be specified. *
  • or a web service, @WebServiceRef must be specified. *
* *

The injection annotation specifies the metadata needed to obtain the * resources, entity manager, entity manager factory, remote EJB instance or * web service reference from the component environment.

* *
 * @Produces @WebServiceRef(lookup="java:app/service/PaymentService")
 * PaymentService paymentService;
 * 
* *
 * @Produces @EJB(ejbLink="../their.jar#PaymentService")
 * PaymentService paymentService;
 * 
* *
 * @Produces @Resource(lookup="java:global/env/jdbc/CustomerDatasource")
 * @CustomerDatabase Datasource customerDatabase;
 * 
* *
 * @Produces @PersistenceContext(unitName="CustomerDatabase")
 * @CustomerDatabase EntityManager customerDatabasePersistenceContext;
 * 
* *
 * @Produces @PersistenceUnit(unitName="CustomerDatabase")
 * @CustomerDatabase EntityManagerFactory customerDatabasePersistenceUnit;
 * 
* *

A resource may not have an EL name.

* *

Enabled and disabled beans

* *

A bean is said to be enabled if:

* *
    *
  • it is deployed in a bean archive, and
  • *
  • it is not a * {@linkplain javax.enterprise.inject.Produces producer method or field} * of a disabled bean, and
  • *
  • it is not {@linkplain javax.enterprise.inject.Specializes specialized} * by any other enabled bean, and either
  • *
  • it is not an {@linkplain javax.enterprise.inject.Alternative alternative}, * or it is a selected alternative of at least one bean archive.
  • *
* *

Otherwise, the bean is said to be disabled.

* *

Inter-module injection

* *

Beans and their clients may be deployed in modules in a module architecture * such as the Java EE environment. In a module architecture, certain modules are * considered bean archives. In the Java EE module architecture, any Java EE * module or library is a module. The Java EE module or library is a bean archive * if it contains a beans.xml file in the metadata directory. * *

A bean is available for injection in a certain module if:

* *
    *
  • the bean is not an interceptor or decorator,
  • *
  • the bean is enabled,
  • *
  • the bean is either not an alternative, or the module is a bean archive and * the bean is a selected alternative of the bean archive, and
  • *
  • the bean class is required to be accessible to classes in the module, * according to the class accessibility requirements of the module architecture.
  • *
* *

Dependency injection

* *

A bean is assignable to a given injection point if:

* *
    *
  • The bean has a bean type that matches the type of the injection point. For * this purpose, primitive types are considered to match their corresponding wrapper * types in {@link java.lang} and array types are considered to match only if their * element types are identical.
  • *
  • The bean has all the qualifiers of the injection point. If the injection point * does not explicitly declare a qualifier, it has the default qualifier * {@link javax.enterprise.inject.Default @Default}.
  • *
  • The bean is eligible for injection into the class that declares the injection * point.
  • *
* *

A bean is eligible for injection into a given injection point if:

* *
    *
  • it is available for injection in the module that contains the * class that declares the injection point, and
  • *
  • it is assignable to the injection point.
  • *
* *

If more than one bean is eligible for injection to the injection point, the * container attempts to resolve the ambiguity by eliminating all beans which are * not alternatives, except for producer methods and fields of beans that are * alternatives.

* *

Certain legal bean types cannot be proxied by the container:

* *
    *
  • classes which don't have a non-private constructor with no parameters,
  • *
  • classes which are declared final or have final methods,
  • *
  • primitive types,
  • *
  • and array types.
  • *
* *

An injection point whose declared type cannot be proxied by the container must * not resolve to a bean with a {@linkplain javax.enterprise.context normal scope}.

* *

EL name resolution

* *

EL names are resolved when Unified EL expressions are evaluated. An EL name * resolves to a bean if:

* *
    *
  • the bean has the given EL name, and
  • *
  • the bean is available for injection in the war containing the JSP or JSF * page with the EL expression.
  • *
* *

If an EL name resolves to more than one bean, the container attempts to * resolve the ambiguity by eliminating all beans which are not alternatives, * except for producer methods and fields of beans that are alternatives.

* *

Enabled interceptors

* *

By default, a bean archive has no enabled interceptors. An interceptor * must be explicitly enabled by listing its bean class under the * <interceptors> element of the beans.xml file of the * bean archive. The order of the interceptor declarations determines the * interceptor ordering. Interceptors which occur earlier in the list are * called first.

* *

An interceptor is bound to a bean if:

* *
    *
  • The bean has all the interceptor bindings of the interceptor.
  • *
  • The interceptor is enabled in the bean archive of the bean.
  • *
* *

An interceptor instance is a * {@linkplain javax.enterprise.context.Dependent dependent object} * of the object it intercepts.

* * @see javax.enterprise.context * @see javax.inject * @see javax.interceptor * @see javax.decorator * @see javax.enterprise.event * * @see javax.enterprise.inject.Produces * @see javax.enterprise.inject.Alternative * */ package javax.enterprise.inject;cdi-api-1.0/src/javax/enterprise/inject/spi/000077500000000000000000000000001166000722300210045ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/inject/spi/AfterBeanDiscovery.java000066400000000000000000000071231166000722300253710ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import javax.enterprise.context.spi.Context; /** *

* The event type of the second event fired by the container when it has fully * completed the bean discovery process, validated that there are no definition * errors relating to the discovered beans, and registered * {@link javax.enterprise.inject.spi.Bean} and * {@link javax.enterprise.inject.spi.ObserverMethod} objects for the discovered * beans, but before detecting deployment problems. *

*

* A portable extension may take advantage of this event to register * {@linkplain javax.enterprise.inject.spi.Bean beans}, * {@linkplain javax.enterprise.inject.spi.Interceptor interceptors}, * {@linkplain javax.decorator.Decorator decorators}, * {@linkplain javax.enterprise.event.Observes observer methods} and * {@linkplain javax.enterprise.context custom context} objects with the * container. *

* *
 *     void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) { ... }
 * 
*

* If any observer method of the {@code AfterBeanDiscovery} event throws an * exception, the exception is treated as a definition error by the container. *

* * @author David Allen */ public interface AfterBeanDiscovery { /** * Registers a definition error with the container, causing the container to * abort deployment after all observers have been notified. * * @param t The definition error as a {@link java.lang.Throwable} */ public void addDefinitionError(Throwable t); /** * Fires an event of type {@link javax.enterprise.inject.spi.ProcessBean} * containing the given {@link javax.enterprise.inject.spi.Bean} and then * registers the {@link javax.enterprise.inject.spi.Bean} with the container, * thereby making it available for injection into other beans. The given * {@link javax.enterprise.inject.spi.Bean} may implement * {@link javax.enterprise.inject.spi.Interceptor} or * {@link javax.decorator.Decorator}. * * @param bean The bean to add to the deployment */ public void addBean(Bean bean); /** * Fires an event of type * {@link javax.enterprise.inject.spi.ProcessObserverMethod} containing the * given {@link javax.enterprise.inject.spi.ObserverMethod} and then * registers the {@link javax.enterprise.inject.spi.ObserverMethod} with the * container, thereby making it available for event notifications. * * @param observerMethod The custom observer method to add to the deployment */ public void addObserverMethod(ObserverMethod observerMethod); /** * Registers a custom {@link javax.enterprise.context.spi.Context} object * with the container. * * @param context The custom context to add to the deployment */ public void addContext(Context context); } cdi-api-1.0/src/javax/enterprise/inject/spi/AfterDeploymentValidation.java000066400000000000000000000032021166000722300267610ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The event type of the third event fired by the container after it has * validated that there are no deployment problems and before creating contexts * or processing requests. If any observer method of the {@code * AfterDeploymentValidation} event throws an exception, the exception is * treated as a deployment problem by the container. *

*

* No requests will be processed by the deployment until all observers of this * event return. *

* * @author David Allen */ public interface AfterDeploymentValidation { /** * Registers a deployment problem with the container, causing the container * to abort deployment after all observers have been notified. * * @param t The deployment problem as a {@link java.lang.Throwable} */ public void addDeploymentProblem(Throwable t); } cdi-api-1.0/src/javax/enterprise/inject/spi/Annotated.java000066400000000000000000000050071166000722300235660ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Set; /** *

Represents a Java program element that can be annotated.

* * @see java.lang.reflect.AnnotatedElement * * @author Gavin King * @author Pete Muir * @author Clint Popetz * */ public interface Annotated { /** *

Get the type of the annotated program element.

* * @return the type of the annotated program element */ public Type getBaseType(); /** *

Get all types to which the base type should be considered * assignable.

* * @return a set of all types to which the base type should be considered * assignable */ public Set getTypeClosure(); /** *

Get program element annotation of a certain annotation type.

* * @param the type of the annotation * @param annotationType the class of the annotation type * @return the program element annotation of the given annotation type, * or a null value */ public T getAnnotation(Class annotationType); /** *

Get all annotations of the program element.

* * @return all annotations of the program element, or an empty set if no * annotations are present */ public Set getAnnotations(); /** *

Determine if the program element has an annotation of a * certain annotation type.

* * @param annotationType the annotation type to check for * @return true if the program element has an annotation of the * given annotation type, or false otherwise */ public boolean isAnnotationPresent(Class annotationType); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedCallable.java000066400000000000000000000023141166000722300252040ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.util.List; /** *

Represents a callable member of a Java type.

* * @author Gavin King * @author Pete Muir * * @param the declaring type */ public interface AnnotatedCallable extends AnnotatedMember { /** *

Get the parameters of the callable member.

* * @return the parameters */ public List> getParameters(); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedConstructor.java000066400000000000000000000023441166000722300260350ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.reflect.Constructor; /** *

Represents a constructor of a Java class.

* * @author Gavin King * @author Pete Muir * * @param the declaring class * @see Constructor */ public interface AnnotatedConstructor extends AnnotatedCallable { /** *

Get the underlying {@link Constructor}.

* * @return the constructor */ public Constructor getJavaMember(); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedField.java000066400000000000000000000022721166000722300245330ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.reflect.Field; /** *

Represents a field of a Java class.

* * @author Gavin King * @author Pete Muir * * @param the declaring type * @see Field */ public interface AnnotatedField extends AnnotatedMember { /** *

Get the underlying {@link Field}.

* * @return the {@link Field} */ public Field getJavaMember(); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedMember.java000066400000000000000000000030371166000722300247170ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.reflect.Member; /** *

Represents a member of a Java type.

* * @author Gavin King * @author Pete Muir * * @param the declaring type * @see Member */ public interface AnnotatedMember extends Annotated { /** *

Get the underlying {@link Member}.

* * @return the {@link Member} */ public Member getJavaMember(); /** *

Determines if the member is static.

* * @return true if the member is static */ public boolean isStatic(); /** *

Get the {@linkplain AnnotatedType type} which declares this * member.

* * @return the type which declares this member */ public AnnotatedType getDeclaringType(); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedMethod.java000066400000000000000000000023031166000722300247230ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.reflect.Method; /** *

Represents a method of a Java type.

* * @author Gavin King * @author Pete Muir * * @param the declaring type * @see Method */ public interface AnnotatedMethod extends AnnotatedCallable { /** *

Get the underlying {@link Method}.

* * @return the {@link Method} */ public Method getJavaMember(); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedParameter.java000066400000000000000000000026741166000722300254360ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

Represents a parameter of a method or constructor.

* * @author Gavin King * @author Pete Muir * * @param the type that declares the method or constructor */ public interface AnnotatedParameter extends Annotated { /** *

Get the position of the parameter in the method or * constructor argument list.

* * @return the position of the parameter */ public int getPosition(); /** *

Get the declaring {@linkplain AnnotatedCallable method or * constructor}.

* * @return the declaring callable */ public AnnotatedCallable getDeclaringCallable(); } cdi-api-1.0/src/javax/enterprise/inject/spi/AnnotatedType.java000066400000000000000000000036521166000722300244340ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.util.Set; /** *

Represents a Java class or interface.

* * @author Gavin King * @author Pete Muir * * @param the type * @see java.lang.Class */ public interface AnnotatedType extends Annotated { /** *

Get the underlying {@link java.lang.Class}.

* * @return the {@link java.lang.Class} */ public Class getJavaClass(); /** *

Get the {@linkplain AnnotatedConstructor constructors} of the type. * If an empty set is returned, a default constructor with no parameters * will be assumed.

* * @return the constructors, or an empty set if none are defined */ public Set> getConstructors(); /** *

Get the {@linkplain AnnotatedMethod methods} of the type.

* * @return the methods, or an empty set if none are defined */ public Set> getMethods(); /** *

Get the {@linkplain AnnotatedField fields} of the type.

* * @return the fields, or an empty set if none are defined */ public Set> getFields(); } cdi-api-1.0/src/javax/enterprise/inject/spi/Bean.java000066400000000000000000000071011166000722300225130ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Set; import javax.enterprise.context.spi.Contextual; /** *

Represents an {@linkplain javax.enterprise.inject enabled bean}. This * interface defines everything the container needs to manage instances of * the bean.

* * @author Gavin King * @author David Allen * @param the class of the bean instance */ public interface Bean extends Contextual { /** * Obtains the {@linkplain javax.enterprise.inject bean types} of the bean. * * @return the {@linkplain javax.enterprise.inject bean types} */ public Set getTypes(); /** * Obtains the {@linkplain javax.inject.Qualifier qualifiers} of the bean. * * @return the {@linkplain javax.inject.Qualifier qualifiers} */ public Set getQualifiers(); /** * Obtains the {@linkplain javax.enterprise.context scope} of the bean. * * @return the {@linkplain javax.enterprise.context scope} */ public Class getScope(); /** * Obtains the {@linkplain javax.enterprise.inject EL name} of a bean, if it has one. * * @return the {@linkplain javax.enterprise.inject EL name} */ public String getName(); /** * Obtains the {@linkplain javax.enterprise.inject.Stereotype stereotypes} * of the bean. * * @return the set of {@linkplain javax.enterprise.inject.Stereotype stereotypes} */ public Set> getStereotypes(); /** * The bean {@linkplain Class class} of the managed bean or session bean or * of the bean that declares the producer method or field. * * @return the bean {@linkplain Class class} */ public Class getBeanClass(); /** * Determines if the bean is an * {@linkplain javax.enterprise.inject.Alternative alternative}. * * @return true if the bean is an * {@linkplain javax.enterprise.inject.Alternative alternative}, * and false otherwise. */ public boolean isAlternative(); /** * Determines if * {@link javax.enterprise.context.spi.Contextual#create(CreationalContext)} * sometimes return a null value. * * @return true if the {@code create()} method may return a null * value, and false otherwise */ public boolean isNullable(); /** * Obtains the {@link javax.enterprise.inject.spi.InjectionPoint} objects * representing injection points of the bean, that will be validated by the * container at initialization time. * * @return the set of {@linkplain javax.enterprise.inject.spi.InjectionPoint injection points} of the bean */ public Set getInjectionPoints(); }cdi-api-1.0/src/javax/enterprise/inject/spi/BeanManager.java000066400000000000000000000373571166000722300240260ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.List; import java.util.Set; import javax.el.ELResolver; import javax.el.ExpressionFactory; import javax.enterprise.context.ContextNotActiveException; import javax.enterprise.context.spi.Context; import javax.enterprise.context.spi.Contextual; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.AmbiguousResolutionException; import javax.enterprise.inject.InjectionException; import javax.enterprise.inject.UnsatisfiedResolutionException; /** *

Allows a portable extension to interact directly with the container. * Provides operations for obtaining contextual references for beans, along * with many other operations of use to portable extensions.

* *

Any bean may obtain an instance of BeanManager by injecting * it:

* *
 * @Inject BeanManager manager;
 * 
* *

Java EE components may obtain an instance of BeanManager from * {@linkplain javax.naming JNDI} by looking up the name {@code * java:comp/BeanManager}.

* *

Any operation of BeanManager may be called at any time during * the execution of the application.

* * @author Gavin King * @author Pete Muir * @author Clint Popetz * @author David Allen */ public interface BeanManager { /** * Obtains a contextual reference for a certain {@linkplain Bean bean} and * a certain bean type of the bean. * * @param bean the {@link Bean} object representing the bean * @param beanType a bean type that must be implemented by any client proxy * that is returned * @param ctx a {@link javax.enterprise.context.spi.CreationalContext} that * may be used to destroy any object with scope * {javax.enterprise.context.Dependent} that is created * @return a contextual reference representing the bean * @throws IllegalArgumentException if the given type is not a bean type of * the given bean */ public Object getReference(Bean bean, Type beanType, CreationalContext ctx); /** * Obtains an injectable reference for a certain {@linkplain InjectionPoint * injection point}. * * @param ij the target injection point * @param ctx a {@link javax.enterprise.context.spi.CreationalContext} that * may be used to destroy any object with scope * {javax.enterprise.context.Dependent} that is created * @return the injectable reference * @throws UnsatisfiedResolutionException if typesafe resolution results in * an unsatisfied dependency * @throws AmbiguousResolutionException typesafe resolution results in an * unresolvable ambiguous dependency */ public Object getInjectableReference(InjectionPoint ij, CreationalContext ctx); /** * Obtain an instance of a {@link javax.enterprise.context.spi.CreationalContext} * for the given {@linkplain javax.enterprise.context.spi.Contextual contextual type}, * or for a non-contextual object. * * @param contextual the {@link javax.enterprise.context.spi.Contextual}, or * a null value in the case of a non-contextual object * @return the new {@link javax.enterprise.context.spi.CreationalContext} */ public CreationalContext createCreationalContext(Contextual contextual); /** * Return the set of beans which have the given required type and qualifiers * and are available for injection in the module or library containing the class * into which the BeanManager was injected or the Java EE component from * whose JNDI environment namespace the BeanManager was obtained, * according to the rules of typesafe resolution. If no qualifiers are given, the * {@linkplain javax.enterprise.inject.Default default qualifier} is assumed. * * @param beanType the required bean type * @param qualifiers the required qualifiers * @return the resulting set of {@linkplain Bean beans} * @throws IllegalArgumentException if the given type represents a type * variable * @throws IllegalArgumentException if two instances of the same qualifier type * are given * @throws IllegalArgumentException if an instance of an annotation that is * not a qualifier type is given */ public Set> getBeans(Type beanType, Annotation... qualifiers); /** * Return the set of beans which have the given EL name and are available for * injection in the module or library containing the class into which the * BeanManager was injected or the Java EE component from whose JNDI * environment namespace the BeanManager was obtained, according to * the rules of EL name resolution. * * @param name the EL name * @return the resulting set of {@linkplain Bean beans} */ public Set> getBeans(String name); /** * Returns the {@link javax.enterprise.inject.spi.PassivationCapable} bean with * the given identifier. * * @param id the identifier * @return a {@link Bean} that implements * {@link javax.enterprise.inject.spi.PassivationCapable} * and has the given identifier, or a null value if there * is no such bean */ public Bean getPassivationCapableBean(String id); /** * Apply the ambiguous dependency resolution rules to a set of * {@linkplain Bean beans}. * * @param a common type of the beans * @param beans a set of {@linkplain Bean beans} of the given type * @throws AmbiguousResolutionException if the ambiguous dependency * resolution rules fail */ public Bean resolve(Set> beans); /** * Validate a certain {@linkplain InjectionPoint injection point}. * * @param injectionPoint the {@linkplain InjectionPoint injection point} to * validate * @throws InjectionException if there is a deployment problem (for * example, an unsatisfied or unresolvable ambiguous dependency) * associated with the injection point */ public void validate(InjectionPoint injectionPoint); /** * Fire an event and notify observers. * * @param event the event object * @param qualifiers the event qualifiers * @throws IllegalArgumentException if the runtime type of the event object * contains a type variable * @throws IllegalArgumentException if two instances of the same qualifier type * are given * @throws IllegalArgumentException if an instance of an annotation that is not * a qualifier type is given */ public void fireEvent(Object event, Annotation... qualifiers); /** * Return the set of observers for an event. * * @param the type of the event * @param event the event object * @param qualifiers the event qualifiers * @throws IllegalArgumentException if the runtime type of the event object * contains a type variable * @throws IllegalArgumentException if two instances of the same qualifier type * are given * @throws IllegalArgumentException if an instance of an annotation that is not * a qualifier type is given */ public Set> resolveObserverMethods(T event, Annotation... qualifiers); /** * Return an ordered list of {@linkplain Decorator decorators} for a set of * bean types and a set of qualifiers and which are enabled in the module or * library containing the class into which the BeanManager was * injected or the Java EE component from whose JNDI environment namespace * the BeanManager was obtained. * * @param types the set of bean types of the decorated bean * @param qualifiers the qualifiers declared by the decorated bean * @return the resulting set of {@linkplain Decorator decorators} * @throws IllegalArgumentException if the set of bean types is empty * @throws IllegalArgumentException if an annotation which is not a binding * type is passed * @throws IllegalArgumentException if two instances of the same binding type * are passed */ public List> resolveDecorators(Set types, Annotation... qualifiers); /** * Return an ordered list of enabled {@linkplain Interceptor interceptors} for * a set of interceptor bindings and a type of interception and which are enabled * in the module or library containing the class into which the BeanManager * was injected or the Java EE component from whose JNDI environment namespace * the BeanManager was obtained. * * @param type the type of the interception * @param interceptorBindings the interceptor bindings * @return the resulting set of {@linkplain Interceptor interceptors} * @throws IllegalArgumentException if no interceptor binding type is given * @throws IllegalArgumentException if two instances of the same interceptor * binding type are given * @throws IllegalArgumentException if an instance of an annotation that is not * an interceptor binding type is given */ public List> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings); /** * Test the given annotation type to determine if it is a * {@linkplain javax.enterprise.context scope type}. * * @param annotationType the annotation type * @return true if the annotation type is a * {@linkplain javax.enterprise.context scope type} */ public boolean isScope(Class annotationType); /** * Test the given annotation type to determine if it is a * {@linkplain javax.enterprise.context normal scope type}. * * @param annotationType the annotation type * @return true if the annotation type is a * {@linkplain javax.enterprise.context normal scope type} */ public boolean isNormalScope(Class annotationType); /** * Test the given annotation type to determine if it is a passivating * {@linkplain javax.enterprise.context scope type}. * * @param annotationType the annotation type * @return true if the annotation type is a passivating scope type */ public boolean isPassivatingScope(Class annotationType); /** * Test the given annotation type to determine if it is a * {@linkplain javax.inject.Qualifier qualifier type}. * * @param annotationType the annotation type * @return true if the annotation type is a * {@linkplain javax.inject.Qualifier qualifier type} */ public boolean isQualifier(Class annotationType); /** * Test the given annotation type to determine if it is an * {@linkplain javax.interceptor.InterceptorBinding interceptor binding type}. * * @param annotationType the annotation to test * @return true if the annotation type is a {@linkplain * javax.interceptor.InterceptorBinding interceptor binding type} */ public boolean isInterceptorBinding(Class annotationType); /** * Test the given annotation type to determine if it is a * {@linkplain javax.enterprise.inject.Stereotype stereotype}. * * @param annotationType the annotation type * @return true if the annotation type is a * {@linkplain javax.enterprise.inject.Stereotype stereotype} */ public boolean isStereotype(Class annotationType); /** * Obtains the set of meta-annotations for a certain * {@linkplain javax.interceptor.InterceptorBinding interceptor binding type}. * * @param bindingType the * {@linkplain javax.interceptor.InterceptorBinding interceptor binding type} * @return the set of meta-annotations */ public Set getInterceptorBindingDefinition(Class bindingType); /** * Obtains meta-annotations for a certain * {@linkplain javax.enterprise.inject.Stereotype stereotype}. * * @param stereotype the {@linkplain javax.enterprise.inject.Stereotype * stereotype} * @return the set of meta-annotations */ public Set getStereotypeDefinition(Class stereotype); /** * Obtains an active {@linkplain javax.enterprise.context.spi.Context * context object} for the given {@linkplain javax.enterprise.context scope}. * * @param scopeType the {@linkplain javax.enterprise.context scope} * @return the {@linkplain javax.enterprise.context.spi.Context context object} * @throws ContextNotActiveException if there is no active context object for the * given scope * @throws IllegalArgumentException if there is more than one active context object * for the given scope */ public Context getContext(Class scopeType); /** * Returns a {@link javax.el.ELResolver} that resolves beans by EL name. */ public ELResolver getELResolver(); /** * Returns a wrapper {@link javax.el.ExpressionFactory} that delegates * {@link javax.el.MethodExpression} and {@link javax.el.ValueExpression} * creation to the given {@link javax.el.ExpressionFactory}. When a Unified * EL expression is evaluated using a {@link javax.el.MethodExpression} or * {@link javax.el.ValueExpression} returned by the wrapper * {@link javax.el.ExpressionFactory}, the container handles destruction of * objects with scope {@link javax.enterprise.context.Dependent}. * * * @param expressionFactory the {@link javax.el.ExpressionFactory} to wrap * @return the wrapped {@link javax.el.ExpressionFactory} */ public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory); /** * Obtain an {@link AnnotatedType} that may be used to read the annotations * of the given class or interface. * * @param the class or interface * @param type the {@link java.lang.Class} object * @return the {@link AnnotatedType} */ public AnnotatedType createAnnotatedType(Class type); /** * Obtains an {@link InjectionTarget} for the given {@link AnnotatedType}. * The container ignores the annotations and types declared by the elements * of the actual Java class and uses the metadata provided via the * {@link Annotated} interface instead. * * @param the type * @param type the {@link AnnotatedType} * @returns a container provided implementation of {@link InjectionTarget} * @throws IllegalArgumentException if there is a definition error associated * with any injection point of the type */ public InjectionTarget createInjectionTarget(AnnotatedType type); } cdi-api-1.0/src/javax/enterprise/inject/spi/BeforeBeanDiscovery.java000066400000000000000000000062541166000722300255360ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; /** *

* This event type is thrown by the container before the bean discovery process * begins. If any observer method of the {@code BeforeBeanDiscovery} event * throws an exception, the exception is treated as a definition error by the * container. *

* * @author Pete Muir * @author David Allen */ public interface BeforeBeanDiscovery { /** * Declares an annotation type as a {@linkplain javax.inject.Qualifier} * qualifier type. * * @param qualifier The annotation to treat as a qualifier */ public void addQualifier(Class qualifier); /** * Declares an annotation type as a {@linkplain javax.enterprise.context * scope type}. * * @param scopeType The annotation type to treat as a * {@linkplain javax.enterprise.context scope type} * @param normal Indicates if the scope is normal * @param passivating Indicates if the scope is * {@linkplain javax.enterprise.inject.spi.PassivationCapable * passivation capable} */ public void addScope(Class scopeType, boolean normal, boolean passivating); /** * Declares an annotation type as a * {@linkplain javax.enterprise.inject.Stereotype stereotype}, and specifies * its meta-annotations. * * @param stereotype The annotation type to treat as a * {@linkplain javax.enterprise.inject.Stereotype stereotype} * @param stereotypeDef An optional list of annotations defining the * {@linkplain javax.enterprise.inject.Stereotype stereotype} */ public void addStereotype(Class stereotype, Annotation... stereotypeDef); /** * Declares an annotation type as an {@linkplain Interceptor interceptor} * binding type, and specifies its meta-annotations. * * @param bindingType The annotation type to treat as an interceptor binding * type */ public void addInterceptorBinding(Class bindingType); /** * Adds a given {@link javax.enterprise.inject.spi.AnnotatedType} to the set * of types which will be scanned during bean discovery. * * @param type The {@link javax.enterprise.inject.spi.AnnotatedType} to add * for later scanning */ public void addAnnotatedType(AnnotatedType type); } cdi-api-1.0/src/javax/enterprise/inject/spi/BeforeShutdown.java000066400000000000000000000022141166000722300246040ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The type of the final event the container fires after it has finished processing * requests and destroyed all contexts. If any observer method of the * {@code BeforeShutdown} event throws an exception, the exception is ignored by the * container. *

* * @author David Allen */ public interface BeforeShutdown { } cdi-api-1.0/src/javax/enterprise/inject/spi/Decorator.java000066400000000000000000000035101166000722300235700ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Set; /** *

Represents an enabled {@linkplain javax.decorator decorator}.

* * @author Gavin King * @author Pete Muir * * @param the decorator bean class */ public interface Decorator extends Bean { /** *

Obtains the {@linkplain Type type} of the * {@linkplain javax.decorator.Delegate delegate injection point}.

* * @return the delegate {@linkplain Type type} */ public Type getDelegateType(); /** *

Obtains the {@linkplain javax.inject.Qualifier qualifiers} of the * {@linkplain javax.decorator.Delegate delegate injection point}.

* * @return the delegate {@linkplain javax.inject.Qualifier qualifiers} */ public Set getDelegateQualifiers(); /** *

Obtains the {@linkplain javax.decorator decorated types}.

* * @return the set of decorated {@linkplain Type types} */ public Set getDecoratedTypes(); }cdi-api-1.0/src/javax/enterprise/inject/spi/Extension.java000066400000000000000000000034301166000722300236230ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

Service interface implemented by extensions. An extension * is a service provider declared in META-INF/services.

* *

Service providers may have * {@linkplain javax.enterprise.event.Observes observer methods}, * which may observe any event, including any * {@linkplain javax.enterprise.inject.spi container lifecycle event}, * and obtain an injected * {@link javax.enterprise.inject.spi.BeanManager}.

* *

The container instantiates a single instance of each * extension at the beginning of the application initialization * process and maintains a reference to it until the application * shuts down. The container delivers event notifications to this * instance by calling its observer methods.

* *

Service providers are made available for injection as beans * with the qualifier {@link javax.enterprise.inject.Default @Default}.

* * @author Gavin King * @author Pete Muir * */ public interface Extension {}cdi-api-1.0/src/javax/enterprise/inject/spi/InjectionPoint.java000066400000000000000000000104351166000722300246060ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; import java.lang.reflect.Member; import java.lang.reflect.Type; import java.util.Set; /** *

Provides access to metadata about an injection point. May represent an * {@linkplain javax.inject.Inject injected field} or a parameter of a * {@linkplain javax.inject.Inject bean constructor}, * {@linkplain javax.inject.Inject initializer method}, * {@linkplain javax.enterprise.inject.Produces producer method}, * {@linkplain javax.enterprise.inject.Disposes disposer method} or * {@linkplain javax.enterprise.event.Observes observer method}.

* *

Occasionally, a bean with scope * {@link javax.enterprise.context.Dependent @Dependent} needs to access * metadata relating to the object to which it belongs. The bean may inject an * {@code InjectionPoint} representing the injection point into which the bean * was injected.

* *

For example, the following producer method creates injectable Loggers. * The log category of a Logger depends upon the class of the object into * which it is injected.

* *
 * @Produces 
 * Logger createLogger(InjectionPoint injectionPoint) { 
 *    return Logger.getLogger( injectionPoint.getMember().getDeclaringClass().getName() );
 * }
 * 
* *

Only {@linkplain javax.enterprise.context.Dependent dependent} objects, may * obtain information about the injection point to which they belong.

* * @author Gavin King * @author Pete Muir */ public interface InjectionPoint { /** * Get the required type of injection point. * * @return the required type */ public Type getType(); /** * Get the required qualifiers of the injection point. * * @return the required qualifiers */ public Set getQualifiers(); /** * Get the {@link javax.enterprise.inject.spi.Bean} object representing the * bean that defines the injection point. If the injection point does not * belong to a bean, return a null value. * * @return the {@link javax.enterprise.inject.spi.Bean} object representing * bean that defines the injection point, of null if the injection * point does not belong to a bean */ public Bean getBean(); /** * Get the {@link java.lang.reflect.Field} object in the case of field * injection, the {@link java.lang.reflect.Method} object in * the case of method parameter injection or the * {@link java.lang.reflect.Constructor} object in the case of constructor * parameter injection. * * @return the member */ public Member getMember(); /** * Obtain an instance of {@link javax.enterprise.inject.spi.AnnotatedField} * or {@link javax.enterprise.inject.spi.AnnotatedParameter}, depending upon * whether the injection point is an injected field or a constructor/method parameter. * * @return an {@code AnnotatedField} or {@code AnnotatedParameter} */ public Annotated getAnnotated(); /** * Determines if the injection point is a decorator delegate injection point. * * @return true if the injection point is a decorator delegate injection point, * and false otherwise */ public boolean isDelegate(); /** * Determines if the injection is a transient field. * * @return true if the injection point is a transient field, and false * otherwise */ public boolean isTransient(); } cdi-api-1.0/src/javax/enterprise/inject/spi/InjectionTarget.java000066400000000000000000000047041166000722300247450ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import javax.enterprise.context.spi.CreationalContext; /** *

* Provides operations for performing * {@linkplain javax.enterprise.inject dependency injection} and * lifecycle callbacks on an instance of a type. *

* * @see javax.annotation.PostConstruct * @see javax.annotation.PreDestroy * * @author Pete Muir * @author David Allen * @param The class of the instance */ public interface InjectionTarget extends Producer { /** *

* Performs dependency injection upon the given object. Performs Java EE * component environment injection, sets the value of all injected fields, * and calls all initializer methods. *

* * @param instance The instance upon which to perform injection * @param ctx The {@link javax.enterprise.context.spi.CreationalContext} to * use for creating new instances */ public void inject(T instance, CreationalContext ctx); /** *

* Calls the {@link javax.annotation.PostConstruct} callback, if it exists, * according to the semantics required by the Java EE platform specification. *

* * @param instance The instance on which to invoke the * {@link javax.annotation.PostConstruct} method */ public void postConstruct(T instance); /** *

* Calls the {@link javax.annotation.PreDestroy} callback, if it exists, * according to the semantics required by the Java EE platform specification. *

* * @param instance The instance on which to invoke the * {@link javax.annotation.PreDestroy} method */ public void preDestroy(T instance); } cdi-api-1.0/src/javax/enterprise/inject/spi/InterceptionType.java000066400000000000000000000026411166000722300251570ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

Identifies the kind of lifecycle callback, EJB timeout method or * business method interception.

* * @author Gavin King * @author Pete Muir * */ public enum InterceptionType { /** * Intercepts method invocation */ AROUND_INVOKE, /** * Intercepts a timeout */ AROUND_TIMEOUT, /** * Intercepts bean construction */ POST_CONSTRUCT, /** * Intercepts bean destruction */ PRE_DESTROY, /** * Intercepts bean passivation */ PRE_PASSIVATE, /** * Intercepts bean activation */ POST_ACTIVATE }cdi-api-1.0/src/javax/enterprise/inject/spi/Interceptor.java000066400000000000000000000046071166000722300241540ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.lang.annotation.Annotation; import java.util.Set; import javax.interceptor.InvocationContext; /** *

Represents an enabled {@linkplain javax.interceptor interceptor}.

* * @author Gavin King * @author Pete Muir * @author David Allen * * @param the interceptor bean class */ public interface Interceptor extends Bean { /** *

Obtains the {@linkplain javax.interceptor.InterceptorBinding interceptor bindings} * of the interceptor.

* * @return the set of {@linkplain javax.interceptor.InterceptorBinding interceptor bindings} */ public Set getInterceptorBindings(); /** *

Determines if the interceptor intercepts the specified * {@linkplain InterceptionType kind of lifecycle callback or method invocation}.

* * @param type the {@linkplain InterceptionType kind of interception} * @return returns true if the interceptor intercepts callbacks * or business methods of the given type, and false otherwise. */ public boolean intercepts(InterceptionType type); /** *

Invokes the specified {@linkplain InterceptionType kind of lifecycle * callback or method invocation interception} upon the given interceptor instance.

* * @param type the {@linkplain InterceptionType kind of interception} * @param instance the interceptor instance to invoke * @param ctx the context for the invocation * @return the invocation return value */ public Object intercept(InterceptionType type, T instance, InvocationContext ctx); }cdi-api-1.0/src/javax/enterprise/inject/spi/ObserverMethod.java000066400000000000000000000033661166000722300246070ustar00rootroot00000000000000package javax.enterprise.inject.spi; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Set; import javax.enterprise.event.Reception; import javax.enterprise.event.TransactionPhase; /** *

Represents an {@linkplain javax.enterprise.event.Observes observer method} * of an {@linkplain javax.enterprise.inject enabled bean}. Defines everything * the container needs to know about an observer method.

* * @author Gavin King * @author David Allen * @param the event type */ public interface ObserverMethod { /** * Obtains the bean {@linkplain Class class} of the bean that declares the * observer method. * * @return the defining {@linkplain Class class} */ public Class getBeanClass(); /** * Obtains the {@linkplain javax.enterprise.event observed event type}. * * @return the observed event {@linkplain Type type} */ public Type getObservedType(); /** * Obtains the set of {@linkplain javax.enterprise.event observed event qualifiers}. * * @return the observed event {@linkplain javax.inject.Qualifier qualifiers} */ public Set getObservedQualifiers(); /** * Obtains the specified {@link Reception} for the observer method. This * indicates if the observer is conditional or not. * * @return the {@link Reception} */ public Reception getReception(); /** * Obtains the specified {@link TransactionPhase} for the observer method. * * @return the {@link TransactionPhase} */ public TransactionPhase getTransactionPhase(); /** * Calls the observer method, passing the given event object. * * @param event the event object */ public void notify(T event); } cdi-api-1.0/src/javax/enterprise/inject/spi/PassivationCapable.java000066400000000000000000000030711166000722300254200ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** * Indicates that a custom implementation of * {@link javax.enterprise.inject.spi.Bean} or * {@link javax.enterprise.context.spi.Contextual} * is passivation capable. * * @author Gavin King * @author David Allen * */ public interface PassivationCapable { /** * A string that uniquely identifies the instance of * {@link javax.enterprise.inject.spi.Bean} or * {@link javax.enterprise.context.spi.Contextual}. It is * recommended that the string contain the package name of * the class that implements {@code Bean} or {@code Contextual}. * * @return a unique identifier for the * {@link javax.enterprise.inject.spi.Bean} or * {@link javax.enterprise.context.spi.Contextual} */ public String getId(); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessAnnotatedType.java000066400000000000000000000050341166000722300257670ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each Java class or interface * it discovers in a bean archive, before it reads the declared annotations. *

*

* Any observer of this event is permitted to wrap and/or replace the * {@link javax.enterprise.inject.spi.AnnotatedType}. The container must use the * final value of this property, after all observers have been called, to * discover the types and read the annotations of the program elements. *

*

* For example, the following observer decorates the * {@link javax.enterprise.inject.spi.AnnotatedType} for every class that is * discovered by the container. *

* *
 * public <T> void decorateAnnotatedType(@Observes ProcessAnnotatedType<T> pat)
 * {
 *    pat.setAnnotatedType(decorate(pat.getAnnotatedType()));
 * }
 * 
*

* If any observer method of a {@code ProcessAnnotatedType} event throws an * exception, the exception is treated as a definition error by the container. *

* * @author David Allen * @see AnnotatedType * @param The class being annotated */ public interface ProcessAnnotatedType { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedType} object that * will be used by the container to read the declared annotations. * * @return the {@code AnnotatedType} object */ public AnnotatedType getAnnotatedType(); /** * Replaces the {@link javax.enterprise.inject.spi.AnnotatedType}. * * @param type the new {@link javax.enterprise.inject.spi.AnnotatedType} * object to use */ public void setAnnotatedType(AnnotatedType type); /** * Forces the container to ignore this type. */ public void veto(); }cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessBean.java000066400000000000000000000064501166000722300240600ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each enabled bean, interceptor * or decorator deployed in a bean archive, before registering the * {@link javax.enterprise.inject.spi.Bean} object. *

*

* The event object type depends upon what kind of bean was discovered: *

*
    *
  • For a managed bean with bean class X, the container must raise an event * of type {@link javax.enterprise.inject.spi.ProcessManagedBean}.
  • *
  • For a session bean with bean class X, the container must raise an event * of type {@link javax.enterprise.inject.spi.ProcessSessionBean}.
  • *
  • For a producer method with method return type X of a bean with bean class * T, the container must raise an event of type * {@link javax.enterprise.inject.spi.ProcessProducerMethod}.
  • *
  • For a producer field with field type X of a bean with bean class T, the * container must raise an event of type * {@link javax.enterprise.inject.spi.ProcessProducerField}.
  • *
*

* Resources are considered to be producer fields. *

*

* If any observer method of a {@code ProcessBean} event throws an exception, * the exception is treated as a definition error by the container. *

* * @see Bean * @author David Allen * @param The class of the bean */ public interface ProcessBean { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedType} representing * the bean class, the {@link javax.enterprise.inject.spi.AnnotatedMethod} * representing the producer method, or the * {@link javax.enterprise.inject.spi.AnnotatedField} representing the * producer field. * * @return the {@link javax.enterprise.inject.spi.AnnotatedType} for the bean * being registered */ public Annotated getAnnotated(); /** * Returns the {@link javax.enterprise.inject.spi.Bean} object that is about * to be registered. The {@link javax.enterprise.inject.spi.Bean} may * implement {@link javax.enterprise.inject.spi.Interceptor} or * {@link javax.decorator.Decorator}. * * @return the {@link javax.enterprise.inject.spi.Bean} object about to be * registered */ public Bean getBean(); /** * Registers a definition error with the container, causing the container to * abort deployment after bean discovery is complete. * * @param t The definition error to register as a {@link java.lang.Throwable} */ public void addDefinitionError(Throwable t); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessInjectionTarget.java000066400000000000000000000067621166000722300263120ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for every Java EE component class supporting * injection that may be instantiated by the container at runtime, including every * managed bean declared using {@code javax.annotation.ManagedBean}, EJB session * or message-driven bean, enabled bean, enabled interceptor or enabled decorator. *

*

* Any observer of this event is permitted to wrap and/or replace the * {@link javax.enterprise.inject.spi.InjectionTarget}. The container must use * the final value of this property, after all observers have been called, * whenever it performs injection upon the managed bean, session bean or other * Java EE component class supporting injection. *

*

* For example, this observer decorates the {@code InjectionTarget} for all * servlets. *

* *
 * public <T extends Servlet> void decorateServlet(@Observes ProcessInjectionTarget<T> pit)
 * {
 *    pit.setInjectionTarget(decorate(pit.getInjectionTarget()));
 * }
 * 
*

* If any observer method of a {@code ProcessInjectionTarget} event throws an exception, * the exception is treated as a definition error by the container. *

* * @see InjectionTarget * @author David Allen * @param The managed bean class, session bean class or Java EE component * class supporting injection */ public interface ProcessInjectionTarget { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedType} representing * the managed bean class, session bean class or other Java EE component * class supporting injection. * * @return the {@link javax.enterprise.inject.spi.AnnotatedType} of the bean * with an injection target */ public AnnotatedType getAnnotatedType(); /** * Returns the {@link javax.enterprise.inject.spi.InjectionTarget} object * that will be used by the container to perform injection. * * @return the {@link javax.enterprise.inject.spi.InjectionTarget} object * which performs the injection */ public InjectionTarget getInjectionTarget(); /** * Replaces the {@link javax.enterprise.inject.spi.InjectionTarget} which * performs injection for this target. * * @param injectionTarget The new * {@link javax.enterprise.inject.spi.InjectionTarget} to use */ public void setInjectionTarget(InjectionTarget injectionTarget); /** * Registers a definition error with the container, causing the container to * abort deployment after bean discovery is complete. * * @param t A {@link java.lang.Throwable} representing the definition error */ public void addDefinitionError(Throwable t); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessManagedBean.java000066400000000000000000000030601166000722300253270ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each enabled managed bean, * before registering the {@link javax.enterprise.inject.spi.Bean} object. *

*

* If any observer method of a {@code ProcessManagedBean} event throws an * exception, the exception is treated as a definition error by the container. *

* * @author David Allen * @param The class of the bean */ public interface ProcessManagedBean extends ProcessBean { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedType} representing * the bean class. * * @return the {@link javax.enterprise.inject.spi.AnnotatedType} for the bean * being registered */ public AnnotatedType getAnnotatedBeanClass(); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessObserverMethod.java000066400000000000000000000046241166000722300261440ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each * {@linkplain javax.enterprise.event.Observes observer method} * of each enabled bean, before registering the * {@link javax.enterprise.inject.spi.ObserverMethod} object. *

*

* If any observer method of a {@code ProcessObserverMethod} event throws an * exception, the exception is treated as a definition error by the container. *

* * @see ObserverMethod * @author Gavin King * @author David Allen * @param The bean type containing the observer method * @param The type of the event being observed */ public interface ProcessObserverMethod { /** * The {@link javax.enterprise.inject.spi.AnnotatedMethod} representing the * observer method. * * @return the {@link javax.enterprise.inject.spi.AnnotatedMethod} * representing the observer method */ public AnnotatedMethod getAnnotatedMethod(); /** * The {@link javax.enterprise.inject.spi.ObserverMethod} object that will be * used by the container to invoke the observer when a matching event is * fired. * * @return the {@link javax.enterprise.inject.spi.ObserverMethod} object that * will be used by the container to call the observer method */ public ObserverMethod getObserverMethod(); /** * Registers a definition error with the container, causing the container to * abort deployment after bean discovery is complete. * * @param t A {@link java.lang.Throwable} representing the definition error */ public void addDefinitionError(Throwable t); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessProducer.java000066400000000000000000000065301166000722300247750ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each * {@linkplain javax.enterprise.inject.Produces producer method or field} * of each enabled bean, including resources. *

*

* Any observer of this event is permitted to wrap and/or replace the {@code * Producer}. The container must use the final value of this property, after all * observers have been called, whenever it calls the producer or disposer. *

*

* For example, this observer decorates the {@code Producer} for the all producer * methods and field of type {@code EntityManager}. *

* *
 * void decorateEntityManager(@Observes ProcessProducer<?, EntityManager> pp)
 * {
 *    pit.setProducer(decorate(pp.getProducer()));
 * }
 * 
*

* If any observer method of a {@code ProcessProducer} event throws an exception, the * exception is treated as a definition error by the container. *

* * @see Producer * @author David Allen * @param The bean class of the bean that declares the producer method or * field * @param The return type of the producer method or the type of the producer * field */ public interface ProcessProducer { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedField} * representing the producer field or the * {@link javax.enterprise.inject.spi.AnnotatedMethod} representing the * producer method. * * @return the {@link javax.enterprise.inject.spi.AnnotatedMember} * representing the producer */ public AnnotatedMember getAnnotatedMember(); /** * Returns the {@link javax.enterprise.inject.spi.Producer} object that will * be used by the container to call the producer method or read the producer * field. * * @return the {@link javax.enterprise.inject.spi.Producer} invoker object * used by the container */ public Producer getProducer(); /** * Replaces the {@link javax.enterprise.inject.spi.Producer} object that will * be used by the container to call the producer method or read the producer * field. * * @param producer the new {@link javax.enterprise.inject.spi.Producer} * object to use */ public void setProducer(Producer producer); /** * Registers a definition error with the container, causing the container to * abort deployment after bean discovery is complete. * * @param t The definition error to register as a {@link java.lang.Throwable} */ public void addDefinitionError(Throwable t); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessProducerField.java000066400000000000000000000033171166000722300257410ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each enabled producer field, * before registering the {@link javax.enterprise.inject.spi.Bean} object. * Resources are considered to be producer fields. *

*

* If any observer method of a {@code ProcessProducerField} event throws an * exception, the exception is treated as a definition error by the container. *

* * @author David Allen * @param The class of the producer field * @param The class of the bean representing the producer field */ public interface ProcessProducerField extends ProcessBean { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedField} * representing the producer field. * * @return the {@link javax.enterprise.inject.spi.AnnotatedField} for the * producer field being registered */ public AnnotatedField getAnnotatedProducerField(); }cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessProducerMethod.java000066400000000000000000000040631166000722300261350ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each enabled producer method, * before registering the {@link javax.enterprise.inject.spi.Bean} object. *

*

* If any observer method of a {@code ProcessProducerMethod} event throws an * exception, the exception is treated as a definition error by the container. *

* * @author David Allen * @param The class of the return type of the producer method * @param The class of the bean representing the producer method */ public interface ProcessProducerMethod extends ProcessBean { /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedMethod} * representing the producer method. * * @return the {@link javax.enterprise.inject.spi.AnnotatedMethod} for the * producer method being registered */ public AnnotatedMethod getAnnotatedProducerMethod(); /** * Returns the {@link javax.enterprise.inject.spi.AnnotatedParameter} for * any matching injection point of the same type as the producer method * return type found on a disposal method. * * @return the disposal method's {@link javax.enterprise.inject.spi.AnnotatedParameter} */ public AnnotatedParameter getAnnotatedDisposedParameter(); } cdi-api-1.0/src/javax/enterprise/inject/spi/ProcessSessionBean.java000066400000000000000000000032111166000722300254140ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** *

* The container fires an event of this type for each enabled session bean, * before registering the {@link javax.enterprise.inject.spi.Bean} object. *

*

* If any observer method of a {@code ProcessSessionBean} event throws an * exception, the exception is treated as a definition error by the container. *

* * @author David Allen * @param */ public interface ProcessSessionBean extends ProcessManagedBean { /** * Returns the EJB name of the session bean. * * @return the name of the EJB */ public String getEjbName(); /** * Returns a {@link javax.enterprise.inject.spi.SessionBeanType} representing the * kind of session bean. * * @return the {@link javax.enterprise.inject.spi.SessionBeanType} */ public SessionBeanType getSessionBeanType(); }cdi-api-1.0/src/javax/enterprise/inject/spi/Producer.java000066400000000000000000000063371166000722300234430ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; import java.util.Set; import javax.enterprise.context.spi.CreationalContext; /** *

* Provides a generic operation for producing an instance of a type. *

* * @author Pete Muir * @author David Allen * @param The class of object produced by the producer */ public interface Producer { /** *

* Causes an instance to be produced via the {@code Producer}. *

*

* If the {@code Producer} represents a class, this will invoke the * constructor annotated {@link javax.inject.Inject} if it exists, or the * constructor with no parameters otherwise. If the class has interceptors, * produce() is responsible for building the interceptors and * decorators of the instance. *

*

* If the {@code Producer} represents a producer field or method, this will * invoke the producer method on, or access the producer field of, a * contextual instance of the bean that declares the producer. *

* * @param ctx The {@link javax.enterprise.context.spi.CreationalContext} to * use for the produced object * @return the instance produced */ public T produce(CreationalContext ctx); /** *

* Destroys the instance. *

*

* If the {@code Producer} represents a class, then this operation does * nothing. *

*

* If the {@code Producer} represents a producer field or method, this * calls the disposer method, if any, on a contextual instance of the * bean that declares the disposer method or performs any additional * required cleanup, if any, to destroy state associated with a resource. *

* * @param instance The instance to dispose */ public void dispose(T instance); /** *

* Returns the set of all {@code InjectionPoints}. If the * {@code Producer} represents a class, then this returns returns the set of * {@code InjectionPoint} objects representing all injected fields, bean * constructor parameters and initializer method parameters. For a producer * method, this returns the set of {@code InjectionPoint} objects * representing all parameters of the producer method. *

* * @return the set of all * {@linkplain javax.enterprise.inject.spi.InjectionPoint injection * points} for the producer */ public Set getInjectionPoints(); }cdi-api-1.0/src/javax/enterprise/inject/spi/SessionBeanType.java000066400000000000000000000022731166000722300247260ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.spi; /** * Identifies the kind of EJB session bean. * * @author Gavin King * */ public enum SessionBeanType { /** * A {@linkplain javax.ejb.Stateless stateless} session bean */ STATELESS, /** * A {@linkplain javax.ejb.Stateful stateful} session bean */ STATEFUL, /** * A {@linkplain javax.ejb.Singleton singleton} session bean */ SINGLETON }cdi-api-1.0/src/javax/enterprise/inject/spi/package-info.java000066400000000000000000000125671166000722300242060ustar00rootroot00000000000000/** *

The portable extension integration SPI.

* *

A portable extension may integrate with the container by:

* *
    *
  • Providing its own beans, interceptors and decorators to the * container
  • *
  • Injecting dependencies into its own objects using the * dependency injection service
  • *
  • Providing a context implementation for a custom scope
  • *
  • Augmenting or overriding the annotation-based metadata with * metadata from some other source
  • *
* *

The BeanManager object

* *

Portable extensions sometimes interact directly with the container * via programmatic API call. The interface * {@link javax.enterprise.inject.spi.BeanManager} provides operations * for obtaining contextual references for beans, along with many other * operations of use to portable extensions.

* *

Container lifecycle events

* *

During the application initialization process, the container fires * a series of {@linkplain javax.enterprise.event events}, allowing * portable extensions to integrate with the container initialization * process. Observer methods of these events must belong to * {@linkplain javax.enterprise.inject.spi.Extension extensions} declared * in META-INF/services.

* *

Lifecycle events include * {@link javax.enterprise.inject.spi.BeforeBeanDiscovery}, * {@link javax.enterprise.inject.spi.AfterBeanDiscovery}, * {@link javax.enterprise.inject.spi.AfterDeploymentValidation} and * {@link javax.enterprise.inject.spi.BeforeShutdown}.

* *

Interfaces representing enabled beans

* *

The interfaces * {@link javax.enterprise.inject.spi.Bean}, * {@link javax.enterprise.inject.spi.Decorator}, * {@link javax.enterprise.inject.spi.Interceptor} and * {@link javax.enterprise.inject.spi.ObserverMethod} * define everything the container needs to manage instances of * a bean, interceptor, decorator or observer method.

* *

An instance of Bean exists for every * {@linkplain javax.enterprise.inject enabled bean}. A portable * extension may add support for new kinds of beans by implementing * Bean, observing the event * {@link javax.enterprise.inject.spi.AfterBeanDiscovery} event * {@linkplain javax.enterprise.inject.spi.AfterBeanDiscovery#addBean(Bean) * registering beans} with the container. An instance of * ObserverMethod exists for every * {@linkplain javax.enterprise.event observer method} of every * enabled bean. A portable extension may add observers by implementing * ObserverMethod and * {@linkplain javax.enterprise.inject.spi.AfterBeanDiscovery#addObserverMethod(ObserverMethod) * registering an instance} with the container.

* *

A portable extension may be notified of the existence of an * enabled bean by observing the container lifecycle event type * {@link javax.enterprise.inject.spi.ProcessBean} or one of its * {@linkplain javax.enterprise.inject.spi.ProcessBean subtypes}, * or of the existence of an observer method of an enabled bean by * observing the event type * {@link javax.enterprise.inject.spi.ProcessObserverMethod}.

* *

Alternate metadata sources

* *

A portable extension may provide an alternative metadata * source, such as configuration by XML.

* *

{@link javax.enterprise.inject.spi.Annotated} * and its subtypes allow a portable extension to specify * metadata that overrides the annotations that exist on a * bean class. The portable extension is responsible for * implementing the interfaces, thereby exposing the metadata * to the container. The container must use the operations of * Annotated and its subinterfaces to discover program * element types and annotations, instead of directly calling the * Java Reflection API.

* *

A portable extension provides its metadata to the * container by observing the event * {@link javax.enterprise.inject.spi.ProcessAnnotatedType} and * {@linkplain javax.enterprise.inject.spi.ProcessAnnotatedType#setAnnotatedType(AnnotatedType) * wrapping} the {@link javax.enterprise.inject.spi.AnnotatedType}.

* *

Producer and InjectionTarget

* * The interfaces {@link javax.enterprise.inject.spi.Producer} and * {@link javax.enterprise.inject.spi.InjectionTarget} abstract the * basic lifecycle of (contextual or non-contextual) container managed * objects, including instantiation and destruction, dependency injection * and lifecycle callbacks.

* *

An instance of {@link javax.enterprise.inject.spi.InjectionTarget} * may be * {@linkplain javax.enterprise.inject.spi.BeanManager#createInjectionTarget(AnnotatedType) * obtained} from the {@link javax.enterprise.inject.spi.BeanManager}, * allowing a portable extension to request these container services for * objects under the control of the portable extension.

* *

Furthermore, a portable extension may replace the implementation * of {@link javax.enterprise.inject.spi.InjectionTarget} or * {@link javax.enterprise.inject.spi.Producer} used by the container * with its own implementation by observing the events * {@link javax.enterprise.inject.spi.ProcessInjectionTarget} or * {@link javax.enterprise.inject.spi.ProcessProducer}.

* * @see javax.enterprise.inject * @see javax.enterprise.context.spi */ package javax.enterprise.inject.spi;cdi-api-1.0/src/javax/enterprise/util/000077500000000000000000000000001166000722300177125ustar00rootroot00000000000000cdi-api-1.0/src/javax/enterprise/util/AnnotationLiteral.java000066400000000000000000000271671166000722300242210ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.util; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Arrays; /** *

Supports inline instantiation of annotation type instances.

* *

An instance of an annotation type may be obtained by subclassing * AnnotationLiteral.

* *
 * public abstract class PayByQualifier 
 *       extends AnnotationLiteral<PayBy>
 *       implements PayBy {}
 * 
* *
 * PayBy paybyCheque = new PayByQualifier() { public PaymentMethod value() { return CHEQUE; } };
 * 
* * @author Pete Muir * @author Gavin King * * @param the annotation type * * @see javax.enterprise.inject.Instance#select(Annotation...) * @see javax.enterprise.event.Event#select(Annotation...) * */ public abstract class AnnotationLiteral implements Annotation, Serializable { private transient Class annotationType; private transient Method[] members; protected AnnotationLiteral() {} private Method[] getMembers() { if (members==null) { members = annotationType().getDeclaredMethods(); if ( members.length>0 && !annotationType().isAssignableFrom(this.getClass()) ) { throw new RuntimeException(getClass() + " does not implement the annotation type with members " + annotationType().getName()); } } return members; } private static Class getAnnotationLiteralSubclass(Class clazz) { Class superclass = clazz.getSuperclass(); if (superclass.equals(AnnotationLiteral.class)) { return clazz; } else if (superclass.equals(Object.class)) { return null; } else { return (getAnnotationLiteralSubclass(superclass)); } } @SuppressWarnings("unchecked") private static Class getTypeParameter(Class annotationLiteralSuperclass) { Type type = annotationLiteralSuperclass.getGenericSuperclass(); if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; if (parameterizedType.getActualTypeArguments().length == 1) { return (Class) parameterizedType .getActualTypeArguments()[0]; } } return null; } public Class annotationType() { if (annotationType==null) { Class annotationLiteralSubclass = getAnnotationLiteralSubclass(this.getClass()); if (annotationLiteralSubclass == null) { throw new RuntimeException(getClass() + "is not a subclass of AnnotationLiteral"); } annotationType = getTypeParameter(annotationLiteralSubclass); if (annotationType == null) { throw new RuntimeException(getClass() + " does not specify the type parameter T of AnnotationLiteral"); } } return annotationType; } @Override public String toString() { StringBuilder string = new StringBuilder(); string.append('@').append(annotationType().getName()).append('('); for (int i = 0; i < getMembers().length; i++) { string.append(getMembers()[i].getName()).append('='); Object value = invoke(getMembers()[i], this); if (value instanceof boolean[]) { appendInBraces(string, Arrays.toString((boolean[])value)); } else if (value instanceof byte[]) { appendInBraces(string, Arrays.toString((byte[])value)); } else if (value instanceof short[]) { appendInBraces(string, Arrays.toString((short[])value)); } else if (value instanceof int[]) { appendInBraces(string, Arrays.toString((int[])value)); } else if (value instanceof long[]) { appendInBraces(string, Arrays.toString((long[])value)); } else if (value instanceof float[]) { appendInBraces(string, Arrays.toString((float[])value)); } else if (value instanceof double[]) { appendInBraces(string, Arrays.toString((double[])value)); } else if (value instanceof char[]) { appendInBraces(string, Arrays.toString((char[])value)); } else if (value instanceof String[]) { String[] strings = (String[]) value; String[] quoted = new String[strings.length]; for(int j=0; j[]) { Class[] classes = (Class[]) value; String[] names = new String[classes.length]; for(int j=0; j) { string.append(((Class)value).getName()).append(".class"); } else { string.append(value); } if (i < getMembers().length - 1) { string.append(", "); } } return string.append(')').toString(); } private void appendInBraces(StringBuilder buf, String s) { buf.append('{').append(s.substring(1,s.length()-1)).append('}'); } @Override public boolean equals(Object other) { if (other instanceof Annotation) { Annotation that = (Annotation) other; if (this.annotationType().equals(that.annotationType())) { for (Method member : getMembers()) { Object thisValue = invoke(member, this); Object thatValue = invoke(member, that); if (thisValue instanceof byte[] && thatValue instanceof byte[]) { if ( !Arrays.equals((byte[])thisValue, (byte[])thatValue) ) return false; } else if (thisValue instanceof short[] && thatValue instanceof short[]) { if ( !Arrays.equals((short[])thisValue, (short[])thatValue) ) return false; } else if (thisValue instanceof int[] && thatValue instanceof int[]) { if ( !Arrays.equals((int[])thisValue, (int[])thatValue) ) return false; } else if (thisValue instanceof long[] && thatValue instanceof long[]) { if ( !Arrays.equals((long[])thisValue, (long[])thatValue) ) return false; } else if (thisValue instanceof float[] && thatValue instanceof float[]) { if ( !Arrays.equals((float[])thisValue, (float[])thatValue) ) return false; } else if (thisValue instanceof double[] && thatValue instanceof double[]) { if ( !Arrays.equals((double[])thisValue, (double[])thatValue) ) return false; } else if (thisValue instanceof char[] && thatValue instanceof char[]) { if ( !Arrays.equals((char[])thisValue, (char[])thatValue) ) return false; } else if (thisValue instanceof boolean[] && thatValue instanceof boolean[]) { if ( !Arrays.equals((boolean[])thisValue, (boolean[])thatValue) ) return false; } else if (thisValue instanceof Object[] && thatValue instanceof Object[]) { if ( !Arrays.equals((Object[])thisValue, (Object[])thatValue) ) return false; } else { if (!thisValue.equals(thatValue)) return false; } } return true; } } return false; } @Override public int hashCode() { int hashCode = 0; for (Method member: getMembers()) { int memberNameHashCode = 127 * member.getName().hashCode(); Object value = invoke(member, this); int memberValueHashCode; if (value instanceof boolean[]) { memberValueHashCode = Arrays.hashCode((boolean[]) value); } else if (value instanceof short[]) { memberValueHashCode = Arrays.hashCode((short[]) value); } else if (value instanceof int[]) { memberValueHashCode = Arrays.hashCode((int[]) value); } else if (value instanceof long[]) { memberValueHashCode = Arrays.hashCode((long[]) value); } else if (value instanceof float[]) { memberValueHashCode = Arrays.hashCode((float[]) value); } else if (value instanceof double[]) { memberValueHashCode = Arrays.hashCode((double[]) value); } else if (value instanceof byte[]) { memberValueHashCode = Arrays.hashCode((byte[]) value); } else if (value instanceof char[]) { memberValueHashCode = Arrays.hashCode((char[]) value); } else if (value instanceof Object[]) { memberValueHashCode = Arrays.hashCode((Object[]) value); } else { memberValueHashCode = value.hashCode(); } hashCode += memberNameHashCode ^ memberValueHashCode; } return hashCode; } private static Object invoke(Method method, Object instance) { try { if (!method.isAccessible()) method.setAccessible(true); return method.invoke(instance); } catch (IllegalArgumentException e) { throw new RuntimeException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e); } catch (IllegalAccessException e) { throw new RuntimeException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e); } catch (InvocationTargetException e) { throw new RuntimeException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e); } } } cdi-api-1.0/src/javax/enterprise/util/Nonbinding.java000066400000000000000000000032771166000722300226530ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.util; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** *

Excludes a member of an annotation type (such as a * {@linkplain javax.inject.Qualifier qualifier type} or * {@linkplain javax.interceptor interceptor binding type}) * from consideration when the container compares two * annotation instances.

* *
 * @Qualifier
 * @Retention(RUNTIME)
 * @Target({METHOD, FIELD, PARAMETER, TYPE})
 * public @interface PayBy {
 *    PaymentMethod value();
 *    @Nonbinding String comment();
 * }
 * 
* * @author Gavin King * * @see javax.inject.Qualifier @Qualifier * @see javax.interceptor.InterceptorBinding @InterceptorBinding * */ @Retention(RUNTIME) @Target(METHOD) public @interface Nonbinding { } cdi-api-1.0/src/javax/enterprise/util/TypeLiteral.java000066400000000000000000000101641166000722300230150ustar00rootroot00000000000000/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, 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.util; import java.io.Serializable; import java.lang.reflect.GenericArrayType; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; /** *

Supports inline instantiation of objects that represent parameterized types * with actual type parameters.

* *

An object that represents any parameterized type may be obtained by * subclassing TypeLiteral.

* *
 * TypeLiteral<List<String>> stringListType = new TypeLiteral<List<String>>() {};
 * 
* * @author Gavin King * @author Pete Muir * * @param the type, including all actual type parameters * * @see javax.enterprise.inject.Instance#select(TypeLiteral, Annotation...) * @see javax.enterprise.event.Event#select(TypeLiteral, Annotation...) * */ public abstract class TypeLiteral implements Serializable { private transient Type actualType; protected TypeLiteral() {} /** * @return the actual type represented by this object */ public final Type getType() { if (actualType==null) { Class typeLiteralSubclass = getTypeLiteralSubclass(this.getClass()); if (typeLiteralSubclass == null) { throw new RuntimeException(getClass() + " is not a subclass of TypeLiteral"); } actualType = getTypeParameter(typeLiteralSubclass); if (actualType == null) { throw new RuntimeException(getClass() + " does not specify the type parameter T of TypeLiteral"); } } return actualType; } /** * @return the raw type represented by this object */ @SuppressWarnings("unchecked") public final Class getRawType() { Type type = getType(); if (type instanceof Class) { return (Class) type; } else if (type instanceof ParameterizedType) { return (Class) ((ParameterizedType) type).getRawType(); } else if (type instanceof GenericArrayType) { return (Class) Object[].class; } else { throw new RuntimeException("Illegal type"); } } private static Class getTypeLiteralSubclass(Class clazz) { Class superclass = clazz.getSuperclass(); if (superclass.equals(TypeLiteral.class)) { return clazz; } else if (superclass.equals(Object.class)) { return null; } else { return (getTypeLiteralSubclass(superclass)); } } private static Type getTypeParameter(Class superclass) { Type type = superclass.getGenericSuperclass(); if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; if (parameterizedType.getActualTypeArguments().length == 1) { return parameterizedType.getActualTypeArguments()[0]; } } return null; } @Override public boolean equals(Object obj) { if (obj instanceof TypeLiteral) { TypeLiteral that = (TypeLiteral) obj; return this.getType().equals(that.getType()); } return false; } @Override public int hashCode() { return getType().hashCode(); } @Override public String toString() { return getType().toString(); } } cdi-api-1.0/src/javax/enterprise/util/package-info.java000066400000000000000000000001521166000722300230770ustar00rootroot00000000000000/** * Contains shared, general-purpose helper classes and annotations. */ package javax.enterprise.util;