Browse Source

KERNEL-2034 引入javax库、javamail、slf4j-api的源码,从原来的jdk11挪包到default

research/10.0
zhouping 5 years ago
parent
commit
743ee17865
  1. 55
      fine-third-default/fine-javax-cdi/src/javax/decorator/Decorator.java
  2. 88
      fine-third-default/fine-javax-cdi/src/javax/decorator/Delegate.java
  3. 97
      fine-third-default/fine-javax-cdi/src/javax/decorator/package-info.java
  4. 104
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ApplicationScoped.java
  5. 84
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/BeforeDestroyed.java
  6. 59
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/BusyConversationException.java
  7. 48
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextException.java
  8. 52
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextNotActiveException.java
  9. 113
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Conversation.java
  10. 159
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ConversationScoped.java
  11. 118
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Dependent.java
  12. 85
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Destroyed.java
  13. 85
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Initialized.java
  14. 56
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NonexistentConversationException.java
  15. 56
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NormalScope.java
  16. 107
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/RequestScoped.java
  17. 98
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/SessionScoped.java
  18. 45
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/control/ActivateRequestContext.java
  19. 66
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/control/RequestContextController.java
  20. 130
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/package-info.java
  21. 63
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/AlterableContext.java
  22. 94
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/Context.java
  23. 58
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/Contextual.java
  24. 47
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/CreationalContext.java
  25. 34
      fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/package-info.java
  26. 186
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/Event.java
  27. 76
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ImmutableNotificationOptions.java
  28. 86
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/NotificationOptions.java
  29. 48
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObserverException.java
  30. 109
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/Observes.java
  31. 99
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObservesAsync.java
  32. 55
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/Reception.java
  33. 92
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/TransactionPhase.java
  34. 118
      fine-third-default/fine-javax-cdi/src/javax/enterprise/event/package-info.java
  35. 83
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Alternative.java
  36. 47
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/AmbiguousResolutionException.java
  37. 97
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Any.java
  38. 48
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/CreationException.java
  39. 62
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Decorated.java
  40. 111
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Default.java
  41. 120
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Disposes.java
  42. 45
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/IllegalProductException.java
  43. 44
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/InjectionException.java
  44. 240
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Instance.java
  45. 56
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Intercepted.java
  46. 48
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Model.java
  47. 115
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/New.java
  48. 121
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Produces.java
  49. 44
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/ResolutionException.java
  50. 89
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Specializes.java
  51. 137
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Stereotype.java
  52. 72
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/TransientReference.java
  53. 95
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Typed.java
  54. 49
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnproxyableResolutionException.java
  55. 48
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnsatisfiedResolutionException.java
  56. 69
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Vetoed.java
  57. 34
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/InjectLiteral.java
  58. 49
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/NamedLiteral.java
  59. 34
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/QualifierLiteral.java
  60. 34
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/SingletonLiteral.java
  61. 63
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/se/SeContainer.java
  62. 298
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/se/SeContainerInitializer.java
  63. 142
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AfterBeanDiscovery.java
  64. 42
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AfterDeploymentValidation.java
  65. 111
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AfterTypeDiscovery.java
  66. 108
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Annotated.java
  67. 42
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedCallable.java
  68. 53
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedConstructor.java
  69. 52
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedField.java
  70. 60
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedMember.java
  71. 52
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedMethod.java
  72. 79
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedParameter.java
  73. 80
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedType.java
  74. 66
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Bean.java
  75. 79
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeanAttributes.java
  76. 663
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeanManager.java
  77. 246
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeforeBeanDiscovery.java
  78. 28
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeforeShutdown.java
  79. 141
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/CDI.java
  80. 43
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/CDIProvider.java
  81. 68
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Decorator.java
  82. 59
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/DefinitionException.java
  83. 59
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/DeploymentException.java
  84. 43
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/EventContext.java
  85. 69
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/EventMetadata.java
  86. 47
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Extension.java
  87. 123
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InjectionPoint.java
  88. 67
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InjectionTarget.java
  89. 77
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InjectionTargetFactory.java
  90. 137
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InterceptionFactory.java
  91. 65
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InterceptionType.java
  92. 77
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Interceptor.java
  93. 140
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ObserverMethod.java
  94. 38
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/PassivationCapable.java
  95. 48
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Prioritized.java
  96. 86
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessAnnotatedType.java
  97. 84
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessBean.java
  98. 108
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessBeanAttributes.java
  99. 82
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessInjectionPoint.java
  100. 83
      fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessInjectionTarget.java
  101. Some files were not shown because too many files have changed in this diff Show More

55
fine-third-default/fine-javax-cdi/src/javax/decorator/Decorator.java

@ -0,0 +1,55 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.decorator;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.inject.Stereotype;
/**
* <p>
* Specifies that a class is a decorator. May be applied to a managed bean class.
* </p>
*
* <pre>
* &#064;Decorator
* class TimestampLogger implements Logger { ... }
* </pre>
*
* <p>
* 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.
* </p>
*
* @see javax.decorator.Delegate &#064;Delegate identifies the delegate injection point of a decorator.
*
* @author Gavin King
* @author Pete Muir
*/
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Stereotype
public @interface Decorator {
}

88
fine-third-default/fine-javax-cdi/src/javax/decorator/Delegate.java

@ -0,0 +1,88 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.decorator;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* <p>
* 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.
* </p>
*
* <pre>
* &#064;Decorator
* class TimestampLogger implements Logger {
* &#064;Inject &#064;Delegate &#064;Any Logger logger;
* ...
* }
* </pre>
*
* <pre>
* &#064;Decorator
* class TimestampLogger implements Logger {
* private Logger logger;
*
* &#064;Inject
* public TimestampLogger(&#064;Delegate &#064;Debug Logger logger) {
* this.logger=logger;
* }
* ...
* }
* </pre>
*
* <p>
* 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.
* </p>
*
* <p>
* 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}.
* </p>
*
* <pre>
* &#064;Decorator
* class TimestampLogger implements Logger {
* &#064;Inject &#064;Delegate &#064;Any Logger logger;
*
* void log(String message) {
* logger.log( timestamp() + ": " + message );
* }
* ...
* }
* </pre>
*
* @see javax.decorator.Decorator &#064;Decorator specifies that a class is a decorator.
*
* @author Gavin King
* @author Pete Muir
*/
@Target({ FIELD, PARAMETER })
@Retention(RUNTIME)
@Documented
public @interface Delegate {
}

97
fine-third-default/fine-javax-cdi/src/javax/decorator/package-info.java

@ -0,0 +1,97 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>Annotations relating to decorators.</p>
*
* <p>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.</p>
*
* <p>A decorator is a managed bean annotated {@link
* javax.decorator.Decorator &#064;Decorator}.</p>
*
* <p>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.</p>
*
* <h3>Decorated types</h3>
*
* <p>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.</p>
*
* <p>A decorator intercepts every method:</p>
* <ul>
* <li>declared by a decorated type of the decorator</li>
* <li>that is implemented by the bean class of the decorator.</li>
* </ul>
*
* <p>A decorator may be an abstract class, and is not required to
* implement every method of every decorated type.</p>
*
* <h3>Delegate injection points</h3>
*
* <p>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 &#064;Delegate}.</p>
*
* <p>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.</p>
*
* <h3>Enabled decorators</h3>
*
* <p>By default, a bean archive has no enabled decorators. A
* decorator must be explicitly enabled by listing its bean class
* under the <tt>&lt;decorators&gt;</tt> element of the
* <tt>beans.xml</tt> 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.</p>
*
* <p>A decorator is bound to a bean if:</p>
*
* <ul>
* <li>The bean is {@linkplain javax.enterprise.inject eligible for injection}
* to the delegate injection point of the decorator.</li>
* <li>The decorator is enabled in the bean archive of the bean.</li>
* </ul>
*
* <p>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.</p>
*
* <p>A decorator instance is a
* {@linkplain javax.enterprise.context.Dependent dependent object}
* of the object it decorates.</p>
*
* @see javax.enterprise.inject
*
* @see javax.decorator.Decorator
* @see javax.decorator.Delegate
*
*/
package javax.decorator;

104
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ApplicationScoped.java

@ -0,0 +1,104 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Specifies that a bean is application scoped.
* </p>
* <p>
* While <tt>ApplicationScoped</tt> must be associated with the built-in application context required by the specification,
* third-party extensions are
* allowed to also associate it with their own context. Behavior described below is only related to the built-in application context.
* </p>
*
* <p>
* The application scope is active:
* </p>
*
* <ul>
* <li>during the <tt>service()</tt> method of any servlet in the web application, during the <tt>doFilter()</tt> method of any
* servlet filter and when the container calls any <tt>ServletContextListener</tt>, <tt>HttpSessionListener</tt>,
* <tt>AsyncListener</tt> or <tt>ServletRequestListener</tt>,</li>
* <li>during any Java EE web service invocation,</li>
* <li>during any remote method invocation of any EJB, during any asynchronous method invocation of any EJB, during any call to
* an EJB timeout method and during message delivery to any EJB message-driven bean,</li>
* <li>when the disposer method or <tt>@PreDestroy</tt> callback of any bean with any normal scope other than
* <tt>@ApplicationScoped</tt> is called, and</li>
* <li>during <tt>@PostConstruct</tt> callback of any bean.</li>
* </ul>
*
* <p>
* The application context is shared between all servlet requests, web service invocations, EJB remote method invocations, EJB
* asynchronous method invocations, EJB timeouts and message deliveries to message-driven beans that execute within the same
* application.
* </p>
* <p>
* The application context is destroyed when the application is shut down.
* </p>
*
* <p>
* An event with qualifier <tt>@Initialized(ApplicationScoped.class)</tt> is fired when the application context is initialized
* and an event with qualifier <tt>@Destroyed(ApplicationScoped.class)</tt> when the application context is destroyed.
* The event payload is:
* </p>
*
* <ul>
* <li>the <tt>ServletContext</tt> if the application is a web application deployed to a Servlet container, or</li>
* <li>any <tt>java.lang.Object</tt> for other types of application.</li>
* </ul>
*
* @author Gavin King
* @author Pete Muir
* @author Antoine Sabot-Durand
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@NormalScope
@Inherited
public @interface ApplicationScoped {
/**
* Supports inline instantiation of the {@link ApplicationScoped} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<ApplicationScoped> implements ApplicationScoped {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

84
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/BeforeDestroyed.java

@ -0,0 +1,84 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* An event with this qualifier is fired when a context is about to be destroyed, i.e. before the actual destruction.
*
* @author Pete Muir
* @author Martin Kouba
* @see Initialized
* @see Destroyed
* @since 2.0
*/
@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface BeforeDestroyed {
/**
* The scope for which to observe destruction
*/
Class<? extends Annotation> value();
/**
* Supports inline instantiation of the {@link BeforeDestroyed} qualifier.
*/
public final static class Literal extends AnnotationLiteral<BeforeDestroyed> implements BeforeDestroyed {
public static final Literal REQUEST = of(RequestScoped.class);
public static final Literal CONVERSATION = of(ConversationScoped.class);
public static final Literal SESSION = of(SessionScoped.class);
public static final Literal APPLICATION = of(ApplicationScoped.class);
private static final long serialVersionUID = 1L;
private final Class<? extends Annotation> value;
public static Literal of(Class<? extends Annotation> value) {
return new Literal(value);
}
private Literal(Class<? extends Annotation> value) {
this.value = value;
}
public Class<? extends Annotation> value() {
return value;
}
}
}

59
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/BusyConversationException.java

@ -0,0 +1,59 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
/**
* <p>
* Indicates that the container has rejected a request because a concurrent request is associated with the same conversation
* context.
* </p>
*
* <p>
* 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 <tt>BusyConversationException</tt> from the restore view phase of the JSF
* lifecycle.
* </p>
*
* @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);
}
}

48
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextException.java

@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
/**
* <p>
* Indicates a problem relating to context management.
* </p>
*
* @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);
}
}

52
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ContextNotActiveException.java

@ -0,0 +1,52 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
/**
* <p>
* Indicates that a context is not active.
* </p>
*
* @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);
}
}

113
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Conversation.java

@ -0,0 +1,113 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
/**
* <p>
* 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.
* </p>
*
* <p>
* An instance may be injected:
* </p>
*
* <pre>
* &#064;Inject
* Conversation conversation;
* </pre>
*
* <p>
* 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.
* </p>
*
* @see javax.enterprise.context.ConversationScoped &#064;ConversationScoped
*
* @author Pete Muir
* @author Gavin King
*
*/
public interface Conversation {
/**
* <p>
* Mark the current transient conversation long-running. A conversation identifier is generated by the container.
* </p>
*
* @throws IllegalStateException if the current conversation is already marked long-running.
*/
public void begin();
/**
* <p>
* Mark the current transient conversation long-running, with a specified identifier.
* </p>
*
* @param id conversation id
* @throws IllegalStateException if the current conversation is already marked long-running.
* @throws IllegalArgumentException if a conversation with the specified identifier already exists.
*/
public void begin(String id);
/**
* <p>
* Marks the current long-running conversation transient.
* </p>
*
* @throws IllegalStateException if the current conversation is already marked transient.
*/
public void end();
/**
* <p>
* Get the identifier of the current long-running conversation.
* </p>
*
* @return the identifier of the current long-running conversation, or a null value if the current conversation is
* transient.
*/
public String getId();
/**
* <p>
* Get the timeout of the current conversation.
* </p>
*
* @return the current timeout in milliseconds.
*/
public long getTimeout();
/**
* <p>
* Set the timeout of the current conversation.
* </p>
*
* @param milliseconds the new timeout in milliseconds.
*/
public void setTimeout(long milliseconds);
/**
* <p>
* Determine if the conversation is marked transient or long-running.
* </p>
*
* @return <tt>true</tt> if the conversation is marked transient, or <tt>false</tt>if it is marked long-running.
*/
public boolean isTransient();
}

159
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/ConversationScoped.java

@ -0,0 +1,159 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Specifies that a bean is conversation scoped.
* </p>
* <p>
* While <tt>ConversationScoped</tt> must be associated with the built-in conversation context required by the specification,
* third-party extensions are
* allowed to also associate it with their own context. Behavior described below is only related to the built-in conversation context.
* </p>
* <p>
* The conversation scope is active:
* </p>
* <ul>
* <li>during all Servlet requests.</li>
* </ul>
* <p>
* An event with qualifier <tt>@Initialized(ConversationScoped.class)</tt> is fired when the conversation context is initialized
* and an event with qualifier <tt>@Destroyed(ConversationScoped.class)</tt> is fired when the conversation is destroyed.
* The event payload is:
* </p>
* <ul>
* <li>the conversation id if the conversation context is destroyed and is not associated with a current Servlet request, or</li>
* <li>the <tt>ServletRequest</tt> if the application is a web application deployed to a Servlet container, or</li>
* <li>any <tt>java.lang.Object</tt> for other types of application.</li>
* </ul>
*
* <p>
* The conversation context provides access to state associated with a particular <em>conversation</em>. Every Servlet request
* has an associated conversation. This association is managed automatically by the container according to the following rules:
* </p>
*
* <ul>
* <li>Any Servlet request has exactly one associated conversation.</li>
* <li>The container provides a filter with the name "CDI Conversation Filter", which may be mapped in <tt>web.xml</tt>,
* allowing the user alter when the conversation is associated with the servlet request. If this filter is not mapped in any
* <tt>web.xml</tt> in the application, the conversation associated with a Servlet request is determined at the beginning of the
* request before calling any <tt>service()</tt> method of any servlet in the web application, calling the <tt>doFilter()</tt>
* method of any servlet filter in the web application and before the container calls any <tt>ServletRequestListener</tt> or
* <tt>AsyncListener</tt> in the web application.</li>
* </ul>
* <p>
*
* <p>
* Any conversation is in one of two states: <em>transient</em> or <em>long-running</em>.
* </p>
*
* <ul>
* <li>By default, a conversation is transient</li>
* <li>A transient conversation may be marked long-running by calling {@link javax.enterprise.context.Conversation#begin()}</li>
* <li>A long-running conversation may be marked transient by calling {@link javax.enterprise.context.Conversation#end()}</li>
* </ul>
*
* <p>
* 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.
* </p>
*
* <p>
* If the conversation associated with the current Servlet request is in the <em>transient</em> state at the end of a Servlet
* request, it is destroyed, and the conversation context is also destroyed.
* </p>
*
* <p>
* If the conversation associated with the current Servlet request is in the <em>long-running</em> state at the end of a Servlet
* request, it is not destroyed. The long-running conversation associated with a request may be propagated to any Servlet
* request via use of a request parameter named <tt>cid</tt> containing the unique identifier of the conversation. In this
* case, the application must manage this request parameter.
* </p>
*
* <p>
* If the current Servlet request is a JSF request, and the conversation is in <em>long-running</em> state, it is propagated
* according to the following rules:
* </p>
*
* <ul>
* <li>The long-running conversation context associated with a request that renders a JSF view is automatically propagated to
* any faces request (JSF form submission) that originates from that rendered page.</li>
* <li>The long-running conversation context associated with a request that results in a JSF redirect (a redirect resulting from
* a navigation rule or JSF <tt>NavigationHandler</tt>) is automatically propagated to the resulting non-faces request, and to any other
* subsequent request to the same URL. This is accomplished via use of a request parameter named <tt>cid</tt> containing the
* unique identifier of the conversation.</li>
* </ul>
*
* <p>
* When no conversation is propagated to a Servlet request, or if a request parameter named <tt>conversationPropagation</tt> has
* the value <tt>none</tt> the request is associated with a new transient conversation.
* All long-running conversations are scoped to a particular HTTP servlet session and may not cross session boundaries.
* In the following cases, a propagated long-running conversation cannot be restored and re-associated with the request:
* </p>
*
* <ul>
* <li>When the HTTP servlet session is invalidated, all long-running conversation contexts created during the current session
* are destroyed, after the servlet <tt>service()</tt> method completes.</li>
* <li>The container is permitted to arbitrarily destroy any long-running conversation that is associated with no current
* Servlet request, in order to conserve resources.</li>
* </ul>
*
* @see javax.enterprise.context.Conversation
* @see javax.enterprise.context.NonexistentConversationException
* @see javax.enterprise.context.BusyConversationException
*
* @author Gavin King
* @author Pete Muir
* @author Antoine Sabot-Durand
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@NormalScope(passivating = true)
@Inherited
public @interface ConversationScoped {
/**
* Supports inline instantiation of the {@link ConversationScoped} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<ConversationScoped> implements ConversationScoped {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

118
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Dependent.java

@ -0,0 +1,118 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Scope;
/**
* <p>
* Specifies that a bean belongs to the dependent pseudo-scope.
* </p>
*
* <p>
* Beans declared with scope <tt>@Dependent</tt> behave differently to beans with other built-in scope types. When a bean is
* declared to have scope <tt>@Dependent</tt>:
* </p>
*
* <ul>
* <li>No injected instance of the bean is ever shared between multiple injection points.</li>
* <li>Any instance of the bean injected into an object that is being created by the container is bound to the lifecycle of the
* newly created object.</li>
* <li>When a Unified EL expression in a JSF or JSP page that refers to the bean by its EL name is evaluated, at most one
* instance of the bean is instantiated. This instance exists to service just a single evaluation of the EL expression. It is
* reused if the bean EL name appears multiple times in the EL expression, but is never reused when the EL expression is
* evaluated again, or when another EL expression is evaluated.</li>
* <li>Any instance of the bean that receives a producer method, producer field, disposer method or observer method invocation
* exists to service that invocation only.</li>
* <li>Any instance of the bean injected into method parameters of a disposer method or observer method exists to service the
* method invocation only.</li>
* </ul>
*
* <p>
* Every invocation of the {@link javax.enterprise.context.spi.Context#get(Contextual, CreationalContext)} operation of the
* context object for the <tt>@Dependent</tt> scope returns a new instance of the given bean.
* </p>
*
* <p>
* Every invocation of the {@link javax.enterprise.context.spi.Context#get(Contextual)} operation of the context object for the
* <tt>@Dependent</tt> scope returns a null value.
* </p>
*
* <p>
* The <tt>@Dependent</tt> scope is always active.
* </p>
*
* <p>
* Many instances of beans with scope <tt>@Dependent</tt> belong to some other bean or Java EE component class instance and are
* called dependent objects.
* </p>
*
* <ul>
* <li>Instances of decorators and interceptors are dependent objects of the bean instance they decorate.</li>
* <li>An instance of a bean with scope <tt>@Dependent</tt> injected into a field, bean constructor or initializer method is a
* dependent object of the bean or Java EE component class instance into which it was injected.</li>
* <li>An instance of a bean with scope <tt>@Dependent</tt> injected into a producer method is a dependent object of the
* producer method bean instance that is being produced.</li>
* <li>An instance of a bean with scope <tt>@Dependent</tt> obtained by direct invocation of an
* {@link javax.enterprise.inject.Instance} is a dependent object of the instance of {@link javax.enterprise.inject.Instance}.</li>
* </ul>
*
* <p>
* 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 <tt>@PreDestroy</tt> callback completes and after the servlet
* <tt>destroy()</tt> method is called.
* </p>
*
* @author Gavin King
* @author Pete Muir
*/
@Target({ METHOD, TYPE, FIELD })
@Retention(RUNTIME)
@Documented
@Scope
@Inherited
public @interface Dependent {
/**
* Supports inline instantiation of the {@link Dependent} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<Dependent> implements Dependent {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

85
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Destroyed.java

@ -0,0 +1,85 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
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.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* An event with this qualifier is fired when a context is destroyed, i.e. after the actual destruction.
*
* @author Pete Muir
* @see Initialized
* @see BeforeDestroyed
* @since 1.1
*/
@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Destroyed {
/**
* The scope for which to observe destruction
*/
Class<? extends Annotation> value();
/**
* Supports inline instantiation of the {@link Destroyed} qualifier.
*
* @author Martin Kouba
*/
public final static class Literal extends AnnotationLiteral<Destroyed> implements Destroyed {
public static final Literal REQUEST = of(RequestScoped.class);
public static final Literal CONVERSATION = of(ConversationScoped.class);
public static final Literal SESSION = of(SessionScoped.class);
public static final Literal APPLICATION = of(ApplicationScoped.class);
private static final long serialVersionUID = 1L;
private final Class<? extends Annotation> value;
public static Literal of(Class<? extends Annotation> value) {
return new Literal(value);
}
private Literal(Class<? extends Annotation> value) {
this.value = value;
}
public Class<? extends Annotation> value() {
return value;
}
}
}

85
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/Initialized.java

@ -0,0 +1,85 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
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.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* An event with this qualifier is fired when a context is initialized, i.e. ready for use.
*
* @author Pete Muir
* @see BeforeDestroyed
* @see Destroyed
* @since 1.1
*/
@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Initialized {
/**
* The scope for which to observe initialization
*/
Class<? extends Annotation> value();
/**
* Supports inline instantiation of the {@link Initialized} qualifier.
*
* @author Martin Kouba
*/
public final static class Literal extends AnnotationLiteral<Initialized> implements Initialized {
public static final Literal REQUEST = of(RequestScoped.class);
public static final Literal CONVERSATION = of(ConversationScoped.class);
public static final Literal SESSION = of(SessionScoped.class);
public static final Literal APPLICATION = of(ApplicationScoped.class);
private static final long serialVersionUID = 1L;
private final Class<? extends Annotation> value;
public static Literal of(Class<? extends Annotation> value) {
return new Literal(value);
}
private Literal(Class<? extends Annotation> value) {
this.value = value;
}
public Class<? extends Annotation> value() {
return value;
}
}
}

56
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NonexistentConversationException.java

@ -0,0 +1,56 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
/**
* <p>
* Indicates that the conversation context could not be restored.
* </p>
*
* <p>
* If the propagated conversation cannot be restored, the container must associate the request with a new transient conversation
* and throw an exception of type <tt>NonexistentConversationException</tt>.
* </p>
*
* @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);
}
}

56
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/NormalScope.java

@ -0,0 +1,56 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* <p>
* Specifies that an annotation type is a normal scope type.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @see javax.inject.Scope &#064;Scope is used to declare pseudo-scopes.
*/
@Target(ANNOTATION_TYPE)
@Retention(RUNTIME)
@Documented
public @interface NormalScope {
/**
* <p>
* Determines whether the normal scope type is a passivating scope.
* </p>
*
* <p>
* 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.
* </p>
*
* @return <tt>true</tt> if the scope type is a passivating scope type
*/
boolean passivating() default false;
}

107
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/RequestScoped.java

@ -0,0 +1,107 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Specifies that a bean is request scoped.
* </p>
* <p>
* While <tt>RequestScoped</tt> must be associated with the built-in request context required by the specification,
* third-party extensions are
* allowed to also associate it with their own context. Behavior described below is only related to the built-in request context.
* </p>
*
* <p>
* The request scope is active:
* </p>
*
* <ul>
* <li>during the <tt>service()</tt> method of any servlet in the web application, during the <tt>doFilter()</tt> method of any
* servlet filter and when the container calls any <tt>ServletRequestListener</tt> or <tt>AsyncListener</tt>,</li>
* <li>during any Java EE web service invocation,</li>
* <li>during any remote method invocation of any EJB, during any asynchronous method invocation of any EJB, during any call to
* an EJB timeout method and during message delivery to any EJB message-driven bean, and</li>
* <li>during <tt>@PostConstruct</tt> callback of any bean.</li>
* </ul>
*
* <p>
* The request context is destroyed:
* </p>
*
* <ul>
* <li>at the end of the servlet request, after the <tt>service()</tt> method, all <tt>doFilter()</tt> methods, and all
* <tt>requestDestroyed()</tt> and <tt>onComplete()</tt> notifications return,</li>
* <li>after the web service invocation completes,</li>
* <li>after the EJB remote method invocation, asynchronous method invocation, timeout or message delivery completes if it
* did not already exist when the invocation occurred, or</li>
* <li>after the <tt>@PostConstruct</tt> callback completes, if it did not already exist when the <tt>@PostConstruct</tt>
* callback occurred.</li>
* </ul>
*
* <p>
* An event with qualifier <tt>@Initialized(RequestScoped.class)</tt> is fired when the request context is initialized and an
* event
* with qualifier <tt>@Destroyed(RequestScoped.class)</tt> when the request context is destroyed. The event payload is:
* </p>
*
* <ul>
* <li>the <tt>ServletRequest</tt> if the context is initialized or destroyed due to a servlet request, or</li>
* <li>the <tt>ServletRequest</tt> if the context is initialized or destroyed due to a web service invocation, or</li>
* <li>any <tt>java.lang.Object</tt> for other types of request.</li>
* </ul>
*
* @author Gavin King
* @author Pete Muir
* @author Antoine Sabot-Durand
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@NormalScope
@Inherited
public @interface RequestScoped {
/**
* Supports inline instantiation of the {@link RequestScoped} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<RequestScoped> implements RequestScoped {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

98
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/SessionScoped.java

@ -0,0 +1,98 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Specifies that a bean is session scoped.
* </p>
* <p>
* While <tt>SessionScoped</tt> must be associated with the built-in session context required by the specification,
* third-party extensions are
* allowed to also associate it with their own context. Behavior described below is only related to the built-in session context.
* </p>
* <p>
* The session scope is active:
* </p>
*
* <ul>
* <li>during the <tt>service()</tt> method of any servlet in the web application,
* <li>during the doFilter() method of any servlet filter, and</li>
* <li>when the container calls any <tt>HttpSessionListener</tt>, <tt>AsyncListener</tt> or
* <tt>ServletRequestListener</tt>.</li>
* </ul>
*
* <p>
* The session context is shared between all servlet requests that occur in the same HTTP session.
* </p>
* <p>
* The session context is destroyed:
* </p>
*
* <ul>
* <li>when the HTTPSession times out, after all <tt>HttpSessionListeners</tt> have been called, or</li>
* <li>at the very end of
* any request in which <tt>invalidate()</tt> was called, after all filters and <tt>ServletRequestListeners</tt> have been
* called.</Li>
* </ul>
*
* <p>
* An event with qualifier <tt>@Initialized(SessionScoped.class)</tt> is fired when the session context is initialized and an
* event
* with qualifier <tt>@Destroyed(SessionScoped.class)</tt> when the session context is destroyed. The event payload is
* the <tt>HttpSession</tt>
*
* @author Gavin King
* @author Pete Muir
* @author Antoine Sabot-Durand
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@NormalScope(passivating = true)
@Inherited
public @interface SessionScoped {
/**
* Supports inline instantiation of the {@link SessionScoped} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<SessionScoped> implements SessionScoped {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

45
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/control/ActivateRequestContext.java

@ -0,0 +1,45 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context.control;
import javax.interceptor.InterceptorBinding;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* The container provides a built in interceptor that may be used to annotate classes and methods to indicate
* that a request context should be activated when this method is invoked.
*
* The request context will be activated before the method is called, and deactivated when the method invocation is
* complete (regardless of any exceptions being thrown). If the context is already active, it is ignored, neither
* activated nor deactivated.
*
* @since 2.0
* @author John D. Ament
*/
@InterceptorBinding
@Target({METHOD, TYPE})
@Retention(RUNTIME)
@Documented
public @interface ActivateRequestContext {
}

66
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/control/RequestContextController.java

@ -0,0 +1,66 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context.control;
import javax.enterprise.context.ContextNotActiveException;
/**
* The CDI container provides a built in instance of RequestContextController that is dependent scoped for the purposes
* of activating and deactivating. For example:
*
* <pre>
* &#064;Inject
* private RequestContextController requestContextController;
*
* public void doRequest(String body) {
* // activate request context
* requestContextController.activate();
*
* // do work in a request context.
*
* // deactivate the request context
* requestContextController.deactivate();
* }
* </pre>
*
* Once the request context has been deactivated, you may activate it once again, creating a brand new request context.
* The activated request context is bound to the current thread, any injection points targeting a request scoped bean
* will be satisfied with the same request scoped objects.
*
* @since 2.0
* @author John D. Ament
*/
public interface RequestContextController {
/**
* Activates a RequestContext for the current thread if one is not already active.
* @return true if the context was activated by this invocation, false if not.
*/
boolean activate();
/**
* Deactivates the current Request Context if it was activated by this context controller. If the context is active
* but was not activated by this controller, then it may not be deactivated by this controller,
* meaning this method will do nothing.
*
* If the context is not active, a {@see ContextNotActiveException} is thrown.
*
* @throws ContextNotActiveException if the context is not active
*/
void deactivate() throws ContextNotActiveException;
}

130
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/package-info.java

@ -0,0 +1,130 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>Annotations and interfaces relating to scopes and contexts.</p>
*
* <p>A scope type is a Java annotation annotated
* {@link javax.inject.Scope &#064;Scope} or
* {@link javax.enterprise.context.NormalScope &#064;NormalScope}.
* The scope of a bean determines the lifecycle and visibility of
* its instances. In particular, the scope determines:</p>
*
* <ul>
* <li>When a new instance of the bean is created</li>
* <li>When an existing instance of the bean is destroyed</li>
* <li>Which injected references refer to any instance of the
* bean</li>
* </ul>
*
* <h3>Built-in scopes</h3>
*
* <p>The following built-in scopes are provided:
* {@link javax.enterprise.context.Dependent &#064;Dependent},
* {@link javax.enterprise.context.RequestScoped &#064;RequestScoped},
* {@link javax.enterprise.context.ConversationScoped &#064;ConversationScoped},
* {@link javax.enterprise.context.SessionScoped &#064;SessionScoped},
* {@link javax.enterprise.context.ApplicationScoped &#064;ApplicationScoped},
* {@link javax.inject.Singleton &#064;Singleton}.</p>
*
* <p>The container provides an implementation of the <tt>Context</tt>
* 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.</p>
*
* <p>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.</p>
*
* <p>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.</p>
*
* <h3>Normal scopes and pseudo-scopes</h3>
*
* <p>Most scopes are <em>normal scopes</em>. Normal scopes are declared
* using {@link javax.enterprise.context.NormalScope &#064;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 <em>current instance</em> of the bean. The operation
* {@link javax.enterprise.context.spi.Context#get(javax.enterprise.context.spi.Contextual)} of the
* context object for a normal scope type always returns the current
* instance of the given bean.</p>
*
* <p>Any scope that is not a normal scope is called a <em>pseudo-scope</em>.
* Pseudo-scopes are declared using {@link javax.inject.Scope &#064;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 &#064;Dependent} pseudo-scope,
* every client has its own private instance of the bean.</p>
*
* <p>All built-in scopes are normal scopes, except for the
* {@link javax.enterprise.context.Dependent &#064;Dependent} and
* {@link javax.inject.Singleton &#064;Singleton} pseudo-scopes.</p>
*
* <h3>Contextual and injected reference validity</h3>
*
* <p>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.</p>
*
* <p>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:</p>
*
* <ul>
* <li>Any reference to a bean with a normal scope is valid as long as
* the application maintains a hard reference to it. However, it may
* only be invoked when the context associated with the normal scope is
* active. If it is invoked when the context is inactive, a
* {@link javax.enterprise.context.ContextNotActiveException} is thrown
* by the container.</li>
* <li>Any reference to a bean with a pseudo-scope is valid until the
* bean instance to which it refers is destroyed. It may be invoked
* even if the context associated with the pseudo-scope is not active.
* If the application invokes a method of a reference to an instance
* that has already been destroyed, the behavior is undefined.</li>
* </ul>
*
* <p>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:</p>
*
* <ul>
* <li>A reference to a bean injected into a field, bean constructor or
* initializer method is only valid until the object into which it was
* injected is destroyed.</li>
* <li>A reference to a bean injected into a producer method is only
* valid until the producer method bean instance that is being produced
* is destroyed.<li>
* <li>A reference to a bean injected into a disposer method or observer
* method is only valid until the invocation of the method completes.</li>
* </ul>
*
* @see javax.enterprise.inject
*
*/
package javax.enterprise.context;

63
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/AlterableContext.java

@ -0,0 +1,63 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context.spi;
import javax.enterprise.context.ContextNotActiveException;
/**
* <p>
* Provides an operation for obtaining and destroying contextual instances with a particular scope of any contextual type. Any
* instance of {@code Context} is called a context object.
* </p>
*
* <p>
* {@link AlterableContext} was introduced in CDI 1.1 to allow bean instances to be destroyed by the application. Extensions
* should implement {@link AlterableContext} instead of {@link Context}.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* A custom context object may be registered with the container using
* {@link javax.enterprise.inject.spi.AfterBeanDiscovery#addContext(Context)}.
* </p>
*
* @author Pete Muir
* @since 1.1
*/
public interface AlterableContext extends Context {
/**
* <p>
* Destroy the existing contextual instance. If there is no existing instance, no action is taken.
* </p>
*
* @param contextual the contextual type
* @throws ContextNotActiveException if the context is not active
*/
public void destroy(Contextual<?> contextual);
}

94
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/Context.java

@ -0,0 +1,94 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context.spi;
import java.lang.annotation.Annotation;
import javax.enterprise.context.ContextNotActiveException;
/**
* <p>
* 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.
* </p>
*
* <p>
* {@link AlterableContext} was introduced in CDI 1.1 to allow bean instances to be destroyed by the application. Extensions
* should implement {@link AlterableContext} instead of {@link Context}.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* A custom context object may be registered with the container using
* {@link javax.enterprise.inject.spi.AfterBeanDiscovery#addContext(Context)}.
* </p>
*
* @author Gavin King
* @author Pete Muir
*/
public interface Context {
/**
* Get the scope type of the context object.
*
* @return the scope
*/
public Class<? extends Annotation> 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 <T> 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> T get(Contextual<T> contextual, CreationalContext<T> creationalContext);
/**
* Return an existing instance of a certain contextual type or a null value.
*
* @param <T> 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> T get(Contextual<T> contextual);
/**
* Determines if the context object is active.
*
* @return <tt>true</tt> if the context is active, or <tt>false</tt> otherwise.
*/
public boolean isActive();
}

58
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/Contextual.java

@ -0,0 +1,58 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context.spi;
import javax.enterprise.inject.CreationException;
/**
* <p>
* 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.
* </p>
*
* @see javax.enterprise.inject.spi.Bean
*
* @author Gavin King
* @author Nicklas Karlsson
* @author Pete Muir
* @param <T> type of the instance
*/
public interface Contextual<T> {
/**
* 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<T> 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<T> creationalContext);
}

47
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/CreationalContext.java

@ -0,0 +1,47 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.context.spi;
/**
* <p>
* Provides operations that are used by the {@link javax.enterprise.context.spi.Contextual} implementation during instance
* creation and destruction.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <T> type of the instances on which this CreationalContext operates
*/
public interface CreationalContext<T> {
/**
* 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();
}

34
fine-third-default/fine-javax-cdi/src/javax/enterprise/context/spi/package-info.java

@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>The custom context SPI.</p>
*
* <p>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.</p>
*
* <p>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.</p>
*
* @see javax.enterprise.context
* @see javax.enterprise.inject.spi
*/
package javax.enterprise.context.spi;

186
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/Event.java

@ -0,0 +1,186 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, 2015, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
import java.lang.annotation.Annotation;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import javax.enterprise.util.TypeLiteral;
/**
* <p>
* Allows the application to fire events of a particular type.
* </p>
*
* <p>
* Beans fire events via an instance of the <tt>Event</tt> interface, which may be injected:
* </p>
*
* <pre>
* &#064;Inject
* &#064;Any
* Event&lt;LoggedInEvent&gt; loggedInEvent;
* </pre>
*
* <p>
* The <tt>fire()</tt> method accepts an event object:
* </p>
*
* <pre>
* public void login() {
* ...
* loggedInEvent.fire( new LoggedInEvent(user) );
* }
* </pre>
*
* <p>
* Any combination of qualifiers may be specified at the injection point:
* </p>
*
* <pre>
* &#064;Inject
* &#064;Admin
* Event&lt;LoggedInEvent&gt; adminLoggedInEvent;
* </pre>
*
* <p>
* Or, the {@link javax.enterprise.inject.Any &#064;Any} qualifier may be used, allowing the application to specify qualifiers
* dynamically:
* </p>
*
* <pre>
* &#064;Inject
* &#064;Any
* Event&lt;LoggedInEvent&gt; loggedInEvent;
* </pre>
*
* <p>
* For an injected <tt>Event</tt>:
* </p>
*
* <ul>
* <li>the <em>specified type</em> is the type parameter specified at the injection point, and</li>
* <li>the <em>specified qualifiers</em> are the qualifiers specified at the injection point.</li>
* </ul>
*
* <p>
* Events may also be fired asynchronously with {@link #fireAsync(Object)} and {@link #fireAsync(Object, NotificationOptions)} methods
* </p>
*
* @author Gavin King
* @author Pete Muir
* @author David Allen
* @author Antoine Sabot-Durand
*
* @param <T> the type of the event object
*/
public interface Event<T> {
/**
* <p>
* Fires an event with the specified qualifiers and notifies observers.
* </p>
*
* @param event the event object
* @throws IllegalArgumentException if the runtime type of the event object contains a type variable
* @throws ObserverException if a notified observer throws a checked exception, it will be wrapped and rethrown as an
* (unchecked) {@link ObserverException}
*/
public void fire(T event);
/**
* <p>
* Fires an event asynchronously with the specified qualifiers and notifies asynchronous observers.
* </p>
*
* @param event the event object
* @return a {@link CompletionStage} allowing further pipeline composition on the asynchronous operation.
* Default asynchronous execution facility is container specific.
* If any observer notified by this event throws an exception
* then the resulting CompletionStage is completed exceptionally with {@link java.util.concurrent.CompletionException}
* that wraps all the exceptions raised by observers as suppressed exception.
* If no exception is thrown by observers then the resulting CompletionStage is completed normally with the event payload.
* @throws IllegalArgumentException if the runtime type of the event object contains a type variable
*
* @since 2.0
*/
public <U extends T> CompletionStage<U> fireAsync(U event);
/**
* <p>
* Fires an event asynchronously with the specified qualifiers and notifies asynchronous observers.
* A custom {@link Executor} will be used to make asynchronous calls
* </p>
*
* @param event the event object
* @param options the notification options
* @return a {@link CompletionStage} allowing further pipeline composition on the asynchronous operation.
* Default asynchronous execution facility is container specific.
* If any observer notified by this event throws an exception
* then the resulting CompletionStage is completed exceptionally with {@link java.util.concurrent.CompletionException}
* that wraps all the exceptions raised by observers as suppressed exception.
* If no exception is thrown by observers then the resulting CompletionStage is completed normally with the event payload.
* @throws IllegalArgumentException if the runtime type of the event object contains a type variable
*
* @since 2.0
*/
public <U extends T> CompletionStage<U> fireAsync(U event, NotificationOptions options);
/**
* <p>
* Obtains a child <tt>Event</tt> for the given additional required qualifiers.
* </p>
*
* @param qualifiers the additional specified qualifiers
* @return the child <tt>Event</tt>
* @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that
* is not a qualifier type
*/
public Event<T> select(Annotation... qualifiers);
/**
* <p>
* Obtains a child <tt>Event</tt> for the given required type and additional required qualifiers.
* </p>
*
* @param <U> the specified type
* @param subtype a {@link java.lang.Class} representing the specified type
* @param qualifiers the additional specified qualifiers
* @return the child <tt>Event</tt>
* @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that
* is not a qualifier type
*/
public <U extends T> Event<U> select(Class<U> subtype, Annotation... qualifiers);
/**
* <p>
* Obtains a child <tt>Event</tt> for the given required type and additional required qualifiers.
* </p>
*
* @param <U> the specified type
* @param subtype a {@link javax.enterprise.util.TypeLiteral} representing the specified type
* @param qualifiers the additional specified qualifiers
* @return the child <tt>Event</tt>
* @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that
* is not a qualifier type
*/
public <U extends T> Event<U> select(TypeLiteral<U> subtype, Annotation... qualifiers);
}

76
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ImmutableNotificationOptions.java

@ -0,0 +1,76 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
/**
* The immutable implementation of {@link NotificationOptions}.
*
* @author Martin Kouba
*
*/
class ImmutableNotificationOptions implements NotificationOptions {
private final Executor executor;
private final Map<String, Object> options;
private ImmutableNotificationOptions(Executor executor, Map<String, Object> options) {
this.executor = executor;
this.options = new HashMap<>(options);
}
@Override
public Executor getExecutor() {
return executor;
}
@Override
public Object get(String name) {
return options.get(name);
}
static class Builder implements javax.enterprise.event.NotificationOptions.Builder {
private Executor executor;
private Map<String, Object> options;
Builder() {
this.options = new HashMap<>();
}
public Builder setExecutor(Executor executor) {
this.executor = executor;
return this;
}
public Builder set(String name, Object value) {
options.put(name, value);
return this;
}
public ImmutableNotificationOptions build() {
return new ImmutableNotificationOptions(executor, options);
}
}
}

86
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/NotificationOptions.java

@ -0,0 +1,86 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
import java.util.concurrent.Executor;
/**
* Notification options are used to configure observer notification.
*
* @author Martin Kouba
* @see Event#fireAsync(Object, NotificationOptions)
* @since 2.0
*/
public interface NotificationOptions {
/**
*
* @return the executor used to execute an asynchronous event
*/
Executor getExecutor();
/**
*
* @param optionName name of the option to get value of
* @return the value of an option or <code>null</code> if no option for the given name exists
*/
Object get(String optionName);
/**
*
* @param executor a specific {@link Executor} to handle observer notification
* @return an immutable holder of an executor
*/
static NotificationOptions ofExecutor(Executor executor) {
return builder().setExecutor(executor).build();
}
/**
*
* @param optionName name of the option to set
* @param optionValue value for the option
* @return an immutable holder of a single option
*/
static NotificationOptions of(String optionName, Object optionValue) {
return builder().set(optionName, optionValue).build();
}
/**
*
* @return the options builder
*/
static Builder builder() {
return new ImmutableNotificationOptions.Builder();
}
/**
* Notification options builder.
*
* @author Martin Kouba
* @since 2.0
*/
interface Builder {
Builder setExecutor(Executor executor);
Builder set(String optionName, Object optionValue);
NotificationOptions build();
}
}

48
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObserverException.java

@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
/**
* <p>
* Indicates that a checked exception was thrown by an observer method during event notification.
* </p>
*
* @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);
}
}

109
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/Observes.java

@ -0,0 +1,109 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
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;
/**
* <p>
* 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}.
* </p>
*
* <pre>
* public void afterLogin(&#064;Observes LoggedInEvent event) { ... }
* </pre>
*
* <p>
* 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.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* If the event parameter does not explicitly declare any qualifier, the observer method observes events with no qualifier.
* </p>
*
* <p>
* The event parameter type may contain a type variable or wildcard.
* </p>
*
* <p>
* In addition to the event parameter, observer methods may declare additional parameters, which may declare qualifiers. These
* additional parameters are injection points.
* </p>
*
* <pre>
* public void afterLogin(&#064;Observes LoggedInEvent event, &#064;Manager User user, Logger log) { ... }
* </pre>
*
* <p>
* A bean (or extension) may declare multiple observer methods.
* </p>
*
* <p>
* Observer methods are inherited by bean subclasses.
* </p>
*
* <p>
* Interceptors and decorators may not declare observer methods.
* </p>
*
* @author Gavin King
* @author Pete Muir
* @author David Allen
*/
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
public @interface Observes {
/**
* <p>
* Specifies {@linkplain javax.enterprise.event.Reception under what conditions the observer method is notified}.
* </p>
*
* <p>
* 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.
* </p>
*/
public Reception notifyObserver() default Reception.ALWAYS;
/**
* <p>
* Specifies {@linkplain javax.enterprise.event.Reception at what time the observer method is notified}.
* </p>
*
* <p>
* By default, the observer method is notified when the event is fired.
* </p>
*/
public TransactionPhase during() default TransactionPhase.IN_PROGRESS;
}

99
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/ObservesAsync.java

@ -0,0 +1,99 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
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;
/**
* <p>
* Identifies the event parameter of an asynchronous observer method. May be applied to a parameter of a method of a bean class
* </p>
*
* <pre>
* public void afterLogin(&#064;ObservesAsync LoggedInEvent event) { ... }
* </pre>
*
* <p>
* 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.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* If the event parameter does not explicitly declare any qualifier, the observer method observes events with no qualifier.
* </p>
*
* <p>
* The event parameter type may contain a type variable or wildcard.
* </p>
*
* <p>
* In addition to the event parameter, observer methods may declare additional parameters, which may declare qualifiers. These
* additional parameters are injection points.
* </p>
*
* <pre>
* public void afterLogin(&#064;ObservesAsync LoggedInEvent event, &#064;Manager User user, Logger log) { ... }
* </pre>
*
* <p>
* A bean (or extension) may declare multiple observer methods.
* </p>
*
* <p>
* Observer methods are inherited by bean subclasses.
* </p>
*
* <p>
* Interceptors and decorators may not declare observer methods.
* </p>
*
* @author Gavin King
* @author Pete Muir
* @author David Allen
*/
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
public @interface ObservesAsync {
/**
* <p>
* Specifies {@linkplain Reception under what conditions the observer method is notified}.
* </p>
*
* <p>
* 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.
* </p>
*/
public Reception notifyObserver() default Reception.ALWAYS;
}

55
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/Reception.java

@ -0,0 +1,55 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
/**
* <p>
* Distinguishes conditional {@linkplain javax.enterprise.event.Observes observer methods} from observer methods which are
* always notified.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* Beans with scope {@link javax.enterprise.context.Dependent &#064;Dependent} may not have conditional observer methods.
* </p>
*
* @author Gavin King
* @author Dan Allen
* @author David Allen
*/
public enum Reception {
/**
* <p>
* Specifies that an observer method is only called if the current instance of the bean declaring the observer method
* already exists.
* </p>
* <p>
* If there is no active context for the scope to which the bean declaring this observer method belongs, then the observer
* method is not called.
* </p>
*/
IF_EXISTS,
/**
* Specifies that an observer method always receives event notifications.
*/
ALWAYS
}

92
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/TransactionPhase.java

@ -0,0 +1,92 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.event;
/**
* <p>
* Distinguishes the various kinds of transactional {@linkplain javax.enterprise.event.Observes observer methods} from regular
* observer methods which are notified immediately.
* </p>
* <p>
* Transactional observer methods are observer methods which receive event notifications during the before or after completion
* phase of the transaction in which the event was fired. If no transaction is in progress when the event is fired, they are
* notified at the same time as other observers.
* If the transaction is in progress, but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
* marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered, the {@link #BEFORE_COMPLETION},
* {@link #AFTER_COMPLETION} and {@link #AFTER_FAILURE} observer methods are notified at the same time as other observers,
* but {@link #AFTER_SUCCESS} observer methods get skipped.
* </p>
*
* @author Pete Muir
* @author Gavin King
*
*/
public enum TransactionPhase {
/**
* <p>
* Identifies a regular observer method, called when the event is fired.
* </p>
*/
IN_PROGRESS,
/**
* <p>
* Identifies a before completion observer method, called during the before completion phase of the transaction.
* </p>
* <p>
* Transactional observer will be notified if there is no transaction in progress, or the transaction is in progress,
* but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
* marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered.
* </p>
*/
BEFORE_COMPLETION,
/**
* <p>
* Identifies an after completion observer method, called during the after completion phase of the transaction.
* </p>
* <p>
* Transactional observer will be notified if there is no transaction in progress, or the transaction is in progress,
* but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
* marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered.
* </p>
*/
AFTER_COMPLETION,
/**
* <p>
* Identifies an after failure observer method, called during the after completion phase of the transaction, only when the
* transaction fails.
* </p>
* <p>
* Transactional observer will be notified will also get invoked if there is no transaction in progress, or the transaction is in progress,
* but {@link javax.transaction.Synchronization} callback cannot be registered due to the transaction being already
* marked for rollback or in state where {@link javax.transaction.Synchronization} callbacks cannot be registered.
* </p>
*/
AFTER_FAILURE,
/**
* <p>
* Identifies an after success observer method, called during the after completion phase of the transaction, only when the
* transaction completes successfully.
* </p>
*/
AFTER_SUCCESS
}

118
fine-third-default/fine-javax-cdi/src/javax/enterprise/event/package-info.java

@ -0,0 +1,118 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, 2015, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>Annotations and interfaces relating to events.<p>
*
* <p>{@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.</p>
*
* <p>Events may be fired synchronously or asynchronously.</p>
*
* <p>An event comprises:</p>
*
* <ul>
* <li>A Java object, called the event object</li>
* <li>A (possibly empty) set of instances of qualifier types, called
* the event qualifiers</li>
* </ul>
*
* <p>The {@link javax.enterprise.event.Event} interface is used to
* fire events.</p>
*
* <h3>Event objects and event types</h3>
*
* <p>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.</p>
*
* <p>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.</p>
*
* <h3>Event qualifiers</h3>
*
* <p>The event qualifiers act as topic selectors, allowing the consumer
* to narrow the set of events it observes. An event qualifier may be an
* instance of any {@linkplain javax.inject.Qualifier qualifier type}.</p>
*
* <h3>Observer methods</h3>
*
* <p>An {@linkplain javax.enterprise.event.Observes observer method}
* allows the application to receive and respond synchronously to event notifications.
* And an {@linkplain javax.enterprise.event.ObservesAsync async observer method}
* allows the application to receive and respond asynchronously to event notifications.
* they both act as event consumers, observing events of a specific type, with a
* specific set of qualifiers. Any Java type may be observed by an
* observer method.</p>
*
* <p>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 &#064;Observes}
* or {@link javax.enterprise.event.ObservesAsync &#064;ObservesAsync}.</p>
*
* <p>An observer method will be notified of an event if:</p>
*
* <ul>
* <li>the event object is assignable to the type observed by the observer
* method,</li>
* <li>the observer method has all the event qualifiers of the event, and</li>
* <li>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}.
* </ul>
*
* <p>If a synchronous observer method is a
* {@linkplain javax.enterprise.event.TransactionPhase transactional
* observer method} and there is a JTA transaction in progress when the
* event is fired, the observer method is notified during the appropriate
* transaction completion phase. Otherwise, the observer is notified when
* the event is fired.</p>
*
* <p>The order in which observer methods are called depends on the value of
* the {@linkplain javax.annotation.Priority &#064;Priority} applied to the observer.</p>
* <p></p>If no priority is defined on a observer, its priority is javax.interceptor.Interceptor.Priority.APPLICATION+500.</p>
* <p>If two observer have the same priority their relative order is undefined.</p>
*
* <p>Observer methods may throw exceptions:</p>
*
* <ul>
* <li>If the observer method is a
* {@linkplain javax.enterprise.event.TransactionPhase transactional
* observer method}, any exception is caught and logged by the container.</li>
* <li>If the observer method is asynchronous, any exception is caught by the container and added as a suppressed exception
* to a {@link java.util.concurrent.CompletionException} that could be handle by the application</li>
* <li>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}.</li>
* </ul>
*
* @see javax.enterprise.inject
*
* @see javax.enterprise.event.Observes
* @see javax.enterprise.event.Event
* @see javax.inject.Qualifier
*/
package javax.enterprise.event;

83
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Alternative.java

@ -0,0 +1,83 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* 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}.
* </p>
*
* <pre>
* &#064;Alternative
* public class MockOrder extends Order { ... }
* </pre>
*
* <p>
* 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 <em>selected</em> in that bean archive. An alternative is never
* available for injection, lookup or EL resolution in a module that is not a bean archive.
* </p>
*
* <p>
* By default, a bean archive has no selected alternatives. An alternative must be explicitly declared using the
* <tt>&lt;alternatives&gt;</tt> element of the <tt>beans.xml</tt> file of the bean archive. The <tt>&lt;alternatives&gt;</tt>
* element contains a list of bean classes and stereotypes. An alternative is selected for the bean archive if either:
* </p>
*
* <ul>
* <li>the alternative is a managed bean or session bean and the bean class of the bean is listed,</li>
* <li>the alternative is a producer method, field or resource, and the bean class that declares the method or field is listed,
* or</li>
* <li>any <tt>&#064;Alternative</tt> stereotype of the alternative is listed.</li>
* </ul>
*
* @author Gavin King
* @author Pete Muir
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Alternative {
/**
* Supports inline instantiation of the {@link Alternative} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<Alternative> implements Alternative {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

47
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/AmbiguousResolutionException.java

@ -0,0 +1,47 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <p>
* Indicates that multiple beans match a certain combination of required type and required qualifiers and are eligible for
* injection into a certain class.
* </p>
*
* @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);
}
}

97
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Any.java

@ -0,0 +1,97 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.event.Event;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* <p>
* The built-in qualifier type.
* </p>
*
* <p>
* Every bean has the qualifier <tt>&#064;Any</tt>, even if it does not explicitly declare this qualifier, except for the
* special {@link javax.enterprise.inject.New &#064;New qualified beans}.
* </p>
*
* <p>
* Every event has the qualifier <tt>&#064;Any</tt>, even if it was raised without explicitly declaration of this qualifier.
* </p>
*
* <p>
* The <tt>&#064;Any</tt> qualifier allows an injection point to refer to all beans or all events of a certain bean type.
* </p>
*
* <pre>
* &#064;Inject
* &#064;Any
* Instance&lt;PaymentProcessor&gt; anyPaymentProcessor;
* </pre>
*
* <pre>
* &#064;Inject
* &#064;Any
* Event&lt;User&gt; anyUserEvent;
* </pre>
*
* <pre>
* &#064;Inject
* &#064;Delegate
* &#064;Any
* Logger logger;
* </pre>
*
* @author Gavin King
* @author David Allen
*/
@Qualifier
@Retention(RUNTIME)
@Target({ TYPE, METHOD, FIELD, PARAMETER })
@Documented
public @interface Any {
/**
* Supports inline instantiation of the {@link Any} qualifier.
*
* @author Martin Kouba
* @since 2.0
* @see Instance
* @see Event
*/
public static final class Literal extends AnnotationLiteral<Any> implements Any {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

48
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/CreationException.java

@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <p>
* Indicates that a checked exception was thrown during creation of a bean.
* </p>
*
* @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);
}
}

62
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Decorated.java

@ -0,0 +1,62 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* <p>
* A decorator may inject metadata about the bean it is decorating
* </p>
*
* <pre>
* &#064;Decorator
* class TimestampLogger implements Logger {
* &#064;Inject
* &#064;Delegate
* &#064;Any
* Logger logger;
*
* &#064;Inject
* &#064;Decorated
* Bean&lt;Logger&gt; bean;
*
* void log(String message) {
* ...
* }
* }
* </pre>
*
* @author Pete Muir
* @since 1.1
*/
@Target({ PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
@Qualifier
public @interface Decorated {
}

111
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Default.java

@ -0,0 +1,111 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.event.Event;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* <p>
* The default qualifier type.
* </p>
*
* <p>
* If a bean does not explicitly declare a qualifier other than {@link javax.inject.Named &#064;Named}, the bean has the
* qualifier <tt>&#064;Default</tt>.
* </p>
*
* <p>
* If an injection point declares no qualifier, the injection point has exactly one qualifier, the default qualifier
* <tt>&#064;Default</tt>.
* </p>
*
* <p>
* The following are equivalent:
* </p>
*
* <pre>
* &#064;ConversationScoped
* public class Order {
*
* private Product product;
* private User customer;
*
* &#064;Inject
* public void init(@Selected Product product, User customer) {
* this.product = product;
* this.customer = customer;
* }
*
* }
* </pre>
*
* <pre>
* &#064;Default
* &#064;ConversationScoped
* public class Order {
*
* private Product product;
* private User customer;
*
* &#064;Inject
* public void init(@Selected Product product, @Default User customer) {
* this.product = product;
* this.customer = customer;
* }
*
* }
* </pre>
*
* @author Pete Muir
* @author Gavin King
*/
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
@Qualifier
public @interface Default {
/**
* Supports inline instantiation of the {@link Default} qualifier.
*
* @author Martin Kouba
* @since 2.0
* @see Instance
* @see Event
*/
public static final class Literal extends AnnotationLiteral<Default> implements Default {
public static final Literal INSTANCE = new Literal();
private static final long serialVersionUID = 1L;
}
}

120
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Disposes.java

@ -0,0 +1,120 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* <p>
* Identifies the disposed parameter of a disposer method. May be applied to a parameter of a method of a bean class.
* </p>
*
* <pre>
* public class UserDatabaseEntityManager {
*
* &#064;Produces
* &#064;ConversationScoped
* &#064;UserDatabase
* public EntityManager create(EntityManagerFactory emf) {
* return emf.createEntityManager();
* }
*
* public void close(@Disposes @UserDatabase EntityManager em) {
* em.close();
* }
*
* }
* </pre>
*
* <pre>
* public class Resources {
*
* &#064;PersistenceContext
* &#064;Produces
* &#064;UserDatabase
* private EntityManager em;
*
* public void close(@Disposes @UserDatabase EntityManager em) {
* em.close();
* }
*
* }
* </pre>
*
* <p>
* A disposer method allows the application to perform customized cleanup of an object returned by a
* {@linkplain javax.enterprise.inject.Produces producer method or producer field}.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* A bean may declare multiple disposer methods.
* </p>
*
* <p>
* Each disposer method must have exactly one disposed parameter, of the same type as the corresponding producer method or
* producer field return type. When searching for disposer methods for a producer method or producer field, the container
* considers the type and qualifiers of the disposed parameter. If a disposed parameter resolves to a producer method or
* producer field declared by the same bean class, the container must call this method when destroying any instance returned by
* that producer method or producer field.
* </p>
*
* <p>
* In addition to the disposed parameter, a disposer method may declare additional parameters, which may also specify
* qualifiers. These additional parameters are injection points.
* </p>
*
* <pre>
* public void close(&#064Disposes &#064UserDatabase EntityManager em, Logger log) { ... }
* </pre>
*
* <p>
* A disposer method may resolve to multiple producer methods or producer fields declared by the bean class, in which case the
* container must call it when destroying any instance returned by any of these producer methods or producer fields.
* </p>
*
* <p>
* Disposer methods are not inherited by bean subclasses.
* </p>
*
* <p>
* Interceptors and decorators may not declare disposer methods.
* </p>
*
* @see javax.enterprise.inject.Produces &#064;Produces
*
* @author Gavin King
* @author Pete Muir
*/
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
public @interface Disposes {
}

45
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/IllegalProductException.java

@ -0,0 +1,45 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <p>
* 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}.
* </p>
*/
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);
}
}

44
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/InjectionException.java

@ -0,0 +1,44 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <t>Indicates a problem relating to dependency injection.</t>
*
* @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);
}
}

240
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Instance.java

@ -0,0 +1,240 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import java.lang.annotation.Annotation;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import javax.enterprise.util.TypeLiteral;
import javax.inject.Provider;
/**
* <p>
* Allows the application to dynamically obtain instances of beans with a specified combination of required type and qualifiers.
* </p>
*
* <p>
* In certain situations, injection is not the most convenient way to obtain a contextual reference. For example, it may not be
* used when:
* </p>
*
* <ul>
* <li>the bean type or qualifiers vary dynamically at runtime, or</li>
* <li>depending upon the deployment, there may be no bean which satisfies the type and qualifiers, or</li>
* <li>we would like to iterate over all beans of a certain type.</li>
* </ul>
*
* <p>
* In these situations, an instance of the <tt>Instance</tt> may be injected:
* </p>
*
* <pre>
* &#064;Inject
* Instance&lt;PaymentProcessor&gt; paymentProcessor;
* </pre>
*
* <p>
* Any combination of qualifiers may be specified at the injection point:
* </p>
*
* <pre>
* &#064;Inject
* &#064;PayBy(CHEQUE)
* Instance&lt;PaymentProcessor&gt; chequePaymentProcessor;
* </pre>
*
* <p>
* Or, the {@link javax.enterprise.inject.Any &#064;Any} qualifier may be used, allowing the application to specify qualifiers
* dynamically:
* </p>
*
* <pre>
* &#064;Inject
* &#064;Any
* Instance&lt;PaymentProcessor&gt; anyPaymentProcessor;
* </pre>
*
* <p>
* Finally, the {@link javax.enterprise.inject.New &#064;New} qualifier may be used, allowing the application to obtain a
* {@link javax.enterprise.inject.New &#064;New} qualified bean:
* </p>
*
* <pre>
* &#064;Inject
* &#064;New(ChequePaymentProcessor.class)
* Instance&lt;PaymentProcessor&gt; chequePaymentProcessor;
* </pre>
*
* <p>
* For an injected <tt>Instance</tt>:
* </p>
*
* <ul>
* <li>the <em>required type</em> is the type parameter specified at the injection point, and</li>
* <li>the <em>required qualifiers</em> are the qualifiers specified at the injection point.</li>
* </ul>
*
* <p>
* 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 <tt>Instance</tt>
* was injected, or throws an {@link javax.enterprise.inject.UnsatisfiedResolutionException} or
* {@link javax.enterprise.inject.AmbiguousResolutionException}.
* </p>
*
* <pre>
* PaymentProcessor pp = chequePaymentProcessor.get();
* </pre>
*
* <p>
* 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
* <tt>Instance</tt> was injected.
* </p>
*
* <pre>
* for (PaymentProcessor pp : anyPaymentProcessor)
* pp.test();
* </pre>
*
* @see javax.inject.Provider#get()
* @see java.lang.Iterable#iterator()
* @see javax.enterprise.util.AnnotationLiteral
* @see javax.enterprise.util.TypeLiteral
*
* @author Gavin King
* @author John Ament
* @author Martin Kouba
*
* @param <T> the required bean type
*/
public interface Instance<T> extends Iterable<T>, Provider<T> {
/**
* <p>
* Obtains a child <tt>Instance</tt> for the given additional required qualifiers.
* </p>
*
* @param qualifiers the additional required qualifiers
* @return the child <tt>Instance</tt>
* @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that
* is not a qualifier type
* @throws IllegalStateException if the container is already shutdown
*/
Instance<T> select(Annotation... qualifiers);
/**
* <p>
* Obtains a child <tt>Instance</tt> for the given required type and additional required qualifiers.
* </p>
*
* @param <U> the required type
* @param subtype a {@link java.lang.Class} representing the required type
* @param qualifiers the additional required qualifiers
* @return the child <tt>Instance</tt>
* @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that
* is not a qualifier type
* @throws IllegalStateException if the container is already shutdown
*/
<U extends T> Instance<U> select(Class<U> subtype, Annotation... qualifiers);
/**
* <p>
* Obtains a child <tt>Instance</tt> for the given required type and additional required qualifiers.
* </p>
*
* @param <U> the required type
* @param subtype a {@link javax.enterprise.util.TypeLiteral} representing the required type
* @param qualifiers the additional required qualifiers
* @return the child <tt>Instance</tt>
* @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an annotation that
* is not a qualifier type
* @throws IllegalStateException if the container is already shutdown
*/
<U extends T> Instance<U> select(TypeLiteral<U> subtype, Annotation... qualifiers);
/**
* <p>
* When called, provides back a Stream of the beans available in this Instance. If no beans are found, it returns an empty
* stream.
* </p>
*
* @since 2.0
* @return a <tt>Stream</tt> representing the beans associated with this {@link Instance} object
*/
default Stream<T> stream() {
return StreamSupport.stream(this.spliterator(), false);
}
/**
* <p>
* 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 <tt>Instance</tt> was injected.
* </p>
*
* @return <tt>true</tt> if there is no bean that matches the required type and qualifiers and is eligible for injection
* into the class into which the parent <tt>Instance</tt> was injected, or <tt>false</tt> otherwise.
*/
boolean isUnsatisfied();
/**
* <p>
* 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 <tt>Instance</tt> was injected.
* </p>
*
* @return <tt>true</tt> 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 <tt>Instance</tt> was injected, or <tt>false</tt> otherwise.
*/
boolean isAmbiguous();
/**
* <p>
* Determines if there is exactly one bean that matches the required type and qualifiers and is eligible for injection
* into the class into which the parent <tt>Instance</tt> was injected.
* </p>
*
* @since 2.0
* @return <tt>true</tt> if there is exactly one bean that matches the required type and qualifiers and is eligible for
* injection into the class into which the parent <tt>Instance</tt> was injected, or <tt>false</tt> otherwise.
*/
default boolean isResolvable() {
return !isUnsatisfied() && !isAmbiguous();
}
/**
* <p>
* When called, the container destroys the instance if the active context object for the scope type of the bean supports
* destroying bean instances. All normal scoped built-in contexts support destroying bean instances.
* </p>
*
* <p>
* The instance passed should either be a dependent scoped bean instance obtained from the same {@link Instance} object, or
* the client proxy for a normal scoped bean instance.
* </p>
*
*
* @since 1.1
* @param instance the instance to destroy
* @throws UnsupportedOperationException if the active context object for the scope type of the bean does not support
* destroying bean instances
*/
void destroy(T instance);
}

56
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Intercepted.java

@ -0,0 +1,56 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* <p>
* An interceptor may inject metadata about the bean it is intercepting.
* </p>
*
* <pre>
* &#064;Transactional &#064;Interceptor
* public class TransactionInterceptor {
*
* &#064;Inject &#064;Intercepted Bean&lt;?&gt; bean;
*
* &#064;AroundInvoke
* public Object manageTransaction(InvocationContext ctx) throws Exception { ... }
*
* }
* </pre>
*
* @author Pete Muir
* @since 1.1
*/
@Target({ PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
@Qualifier
public @interface Intercepted {
}

48
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Model.java

@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
* <p>
* The built-in stereotype intended for use with beans that define the model layer of an MVC web application architecture such
* as JSF.
* </p>
*
* @see javax.enterprise.inject.Stereotype
* @author Gavin King
*/
@Named
@RequestScoped
@Documented
@Stereotype
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
public @interface Model {
}

115
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/New.java

@ -0,0 +1,115 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.context.Dependent;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* <p>
* The {@link New} qualifier was deprecated in CDI 1.1. CDI applications are encouraged to inject {@link Dependent} scoped beans
* instead.
* </p>
*
* <p>
* The <tt>&#064;New</tt> 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.
* </p>
*
* <pre>
* &#064;Produces &#064;ConversationScoped
* &#064;Special Order getSpecialOrder(&#064;New(Order.class) Order order) {
* ...
* return order;
* }
* </pre>
*
* <p>
* When the <tt>&#064;New</tt> 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 <tt>&#064;New(Order.class)</tt>:
* </p>
*
* <pre>
* &#064;Produces &#064;ConversationScoped
* &#064;Special Order getSpecialOrder(&#064;New Order order) { ... }
* </pre>
*
* @author Gavin King
* @author Pete Muir
*/
@Target({ FIELD, PARAMETER, METHOD, TYPE })
@Retention(RUNTIME)
@Documented
@Qualifier
public @interface New {
/**
* <p>
* 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.
* </p>
*
* <p>
* Defaults to the declared type of the injection point if not specified.
* </p>
*
* @return the bean class of the new instance
*/
Class<?> value() default New.class;
/**
* Supports inline instantiation of the {@link New} qualifier.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<New> implements New {
public static final Literal INSTANCE = of(New.class);
private static final long serialVersionUID = 1L;
private final Class<?> value;
public static Literal of(Class<?> value) {
return new Literal(value);
}
private Literal(Class<?> value) {
this.value = value;
}
public Class<?> value() {
return value;
}
}
}

121
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Produces.java

@ -0,0 +1,121 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
*
* <p>
* Identifies a producer method or field. May be applied to a method or field of a bean class.
* </p>
*
* <p>
* 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.
* </p>
*
* <pre>
* public class Shop {
* &#064;Produces &#064;ApplicationScoped
* &#064;Catalog &#064;Named("catalog")
* List&lt;Product&gt; getProducts() { ... }
* ...
* }
* </pre>
*
* <p>
* 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.
* </p>
*
* <pre>
* public class Shop {
* &#064;Produces &#064;ApplicationScoped
* &#064;Catalog &#064;Named("catalog")
* List&lt;Product&gt; products = ...;
* ...
* }
* </pre>
*
* <p>
* 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 &#064;Dependent}.
* </p>
*
* <p>
* A producer method return type or producer field type may not be a type variable.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* 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 &#064;Dependent}.
* </p>
*
* <p>
* A producer method may have any number of parameters. All producer method parameters are injection points.
* </p>
*
* <pre>
* public class OrderFactory {
*
* &#064;Produces
* &#064;ConversationScoped
* public Order createCurrentOrder(Shop shop, @Selected Product product) {
* Order order = new Order(product, shop);
* return order;
* }
*
* }
* </pre>
*
* <p>
* A bean may declare multiple producer methods or fields.
* </p>
*
* <p>
* Producer methods and fields are not inherited by bean subclasses.
* </p>
*
* <p>
* Interceptors and decorators may not declare producer methods or fields.
* </p>
*
* @see javax.enterprise.inject.Disposes &#064;Disposes
*
* @author Gavin King
* @author Pete Muir
*/
@Target({ METHOD, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Produces {
}

44
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/ResolutionException.java

@ -0,0 +1,44 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <t>Indicates a problem relating to typesafe resolution.</t>
*
* @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);
}
}

89
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Specializes.java

@ -0,0 +1,89 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.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.event.Event;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Indicates that a bean directly specializes another bean. May be applied to a bean class or producer method.
* </p>
*
* <p>
* If a bean directly specializes a second bean, it inherits:
* </p>
*
* <ul>
* <li>all qualifiers of the second bean, and</li>
* <li>the name, if any, of the second bean.</li>
* </ul>
*
* <p>
* If the second bean has a name, the bean may not declare a name using {@link javax.inject.Named &#064;Named}. Furthermore, the
* bean must have all the bean types of the second bean.
* </p>
*
* <ul>
* <li>If a bean class of a managed bean is annotated <tt>&#064;Specializes</tt> , 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.</li>
*
* <li>If a bean class of a session bean is annotated <tt>&#064;Specializes</tt> , 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.</li>
*
* <li>If a producer method is annotated <tt>&#064;Specializes</tt>, then it must be non-static and directly override another
* producer method. Then the first producer method directly specializes the second producer method.</li>
* </ul>
*
* <p>
* If a bean is specialized by any enabled bean, the first bean is disabled.
* </p>
*
* @author Gavin King
* @author Pete Muir
*/
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
@Documented
public @interface Specializes {
/**
* Supports inline instantiation of the {@link Specializes} annotation.
*
* @author Martin Kouba
* @since 2.0
* @see Instance
* @see Event
*/
public static final class Literal extends AnnotationLiteral<Specializes> implements Specializes {
private static final long serialVersionUID = 1L;
public static final Literal INSTANCE = new Literal();
}
}

137
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Stereotype.java

@ -0,0 +1,137 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* <p>
* Specifies that an annotation type is a stereotype.
* </p>
*
* <p>
* 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.
* </p>
*
* <p>
* A bean may declare zero, one or multiple stereotypes, by applying the stereotype annotation to the bean class or producer
* method or field.
* </p>
*
* <p>
* A stereotype encapsulates any combination of:
* </p>
*
* <ul>
* <li>a default scope, and</li>
* <li>a set of interceptor bindings.</li>
* </ul>
*
* <p>
* 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.
* </p>
*
* <pre>
* &#064;RequestScoped
* &#064;Stereotype
* &#064;Target(TYPE)
* &#064;Retention(RUNTIME)
* public @interface Action {
* }
* </pre>
*
* <p>
* 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.
* </p>
*
* <pre>
* &#064;RequestScoped
* &#064;Secure
* &#064;Transactional
* &#064;Stereotype
* &#064;Target(TYPE)
* &#064;Retention(RUNTIME)
* public @interface Action {
* }
* </pre>
*
* <p>
* A stereotype may also specify that:
* </p>
*
* <ul>
* <li>all beans with the stereotype have defaulted bean EL names, or that</li>
* <li>all beans with the stereotype are alternatives.</li>
* </ul>
*
* <p>
* A stereotype may declare an empty {@link javax.inject.Named &#064;Named} annotation, which specifies that every bean with the
* stereotype has a defaulted name when a name is not explicitly specified by the bean.
* </p>
*
* <pre>
* &#064;RequestScoped
* &#064;Named
* &#064;Secure
* &#064;Transactional
* &#064;Stereotype
* &#064;Target(TYPE)
* &#064;Retention(RUNTIME)
* public @interface Action {
* }
* </pre>
*
* <p>
* A stereotype may declare an {@link javax.enterprise.inject.Alternative &#064;Alternative} annotation, which specifies that
* every bean with the stereotype is an alternative.
* </p>
*
* <pre>
* &#064;Alternative
* &#064;Stereotype
* &#064;Target(TYPE)
* &#064;Retention(RUNTIME)
* public @interface Mock {
* }
* </pre>
*
* <p>
* 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.
* </p>
*
* @see javax.enterprise.inject.Model the built-in stereotype <tt>&#064;Model</tt>
*
* @author Pete Muir
* @author Gavin King
*/
@Retention(RUNTIME)
@Target(ANNOTATION_TYPE)
@Documented
public @interface Stereotype {
}

72
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/TransientReference.java

@ -0,0 +1,72 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.event.Event;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* If a parameter annotated with <tt>&#064;TransientReference</tt> resolves to a dependent scoped bean, then the bean will be
* destroyed after the invocation completes.
* </p>
*
* <pre>
* public class OrderManager {
*
* &#064;Inject
* public OrderManager(@TransientReference Order order) {
* ...
*
* }
* }
* </pre>
*
* @author Pete Muir
* @since 1.1
*/
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
public @interface TransientReference {
/**
* Supports inline instantiation of the {@link TransientReference} annotation.
*
* @author Martin Kouba
* @since 2.0
* @see Instance
* @see Event
*/
public static final class Literal extends AnnotationLiteral<TransientReference> implements TransientReference {
private static final long serialVersionUID = 1L;
public static final Literal INSTANCE = new Literal();
}
}

95
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Typed.java

@ -0,0 +1,95 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Restricts the bean types of a bean. May be applied to a bean class or producer method or field.
* </p>
*
* <pre>
* &#064;Typed(Shop.class)
* public class BookShop
* extends Business
* implements Shop&lt;Book&gt; {
* ...
* }
* </pre>
*
* <p>
* When a <tt>&#064;Typed</tt> 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.
* </p>
*
* @author Pete Muir
* @author Gavin King
*
*/
@Target({ FIELD, METHOD, TYPE })
@Retention(RUNTIME)
@Documented
public @interface Typed {
/**
* <p>
* Selects the bean types of the bean. Every class must correspond to a type in the unrestricted set of bean types of a
* bean.
* </p>
*
* @return the classes corresponding to the bean types of the bean
*/
Class<?>[] value() default {};
/**
* Supports inline instantiation of the {@link Typed} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final static class Literal extends AnnotationLiteral<Typed> implements Typed {
public static final Literal INSTANCE = of(new Class<?>[]{});
private static final long serialVersionUID = 1L;
private final Class<?>[] value;
public static Literal of(Class<?>[] value) {
return new Literal(value);
}
private Literal(Class<?>[] value) {
this.value = value;
}
public Class<?>[] value() {
return value;
}
}
}

49
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnproxyableResolutionException.java

@ -0,0 +1,49 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <p>
* 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.
* </p>
*
* @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);
}
}

48
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/UnsatisfiedResolutionException.java

@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
/**
* <p>
* Indicates that no bean matches a certain combination of required type and required qualifiers and is eligible for injection
* into a certain class.
* </p>
*
* @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);
}
}

69
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/Vetoed.java

@ -0,0 +1,69 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.enterprise.event.Event;
import javax.enterprise.util.AnnotationLiteral;
/**
* <p>
* Veto the processing of the class. Any beans or observer methods defined by this class will not be installed.
* </p>
*
* <p>
* When placed on package, all beans in the package are prevented from being installed. If packages are split across jars,
* non-portable behavior results. An application can prevent packages being split across jars by sealing the package.
* </p>
*
* <p>
* No container lifecycle events are fired for classes annotated {@link Vetoed}.
* </p>
*
* @author Stuart Douglas
* @since 1.1
* @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#sealing">JAR File Specification</a>
*
*/
@Target({ ElementType.TYPE, ElementType.PACKAGE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Vetoed {
/**
* Supports inline instantiation of the {@link Vetoed} annotation.
*
* @author Martin Kouba
* @since 2.0
* @see Instance
* @see Event
*/
public static final class Literal extends AnnotationLiteral<Vetoed> implements Vetoed {
private static final long serialVersionUID = 1L;
public static final Literal INSTANCE = new Literal();
}
}

34
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/InjectLiteral.java

@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.literal;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
/**
* Supports inline instantiation of the {@link Inject} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final class InjectLiteral extends AnnotationLiteral<Inject> implements Inject {
public static final InjectLiteral INSTANCE = new InjectLiteral();
private static final long serialVersionUID = 1L;
}

49
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/NamedLiteral.java

@ -0,0 +1,49 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.literal;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Named;
/**
* Supports inline instantiation of the {@link Named} qualifier.
*
* @author Pete Muir
* @author Jozef Hartinger
* @since 2.0
*/
public final class NamedLiteral extends AnnotationLiteral<Named> implements Named {
public static final Named INSTANCE = of("");
private static final long serialVersionUID = 1L;
private final String value;
public static NamedLiteral of(String value) {
return new NamedLiteral(value);
}
public String value() {
return value;
}
private NamedLiteral(String value) {
this.value = value;
}
}

34
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/QualifierLiteral.java

@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.literal;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
/**
* Supports inline instantiation of the {@link Qualifier} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final class QualifierLiteral extends AnnotationLiteral<Qualifier> implements Qualifier {
public static final QualifierLiteral INSTANCE = new QualifierLiteral();
private static final long serialVersionUID = 1L;
}

34
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/literal/SingletonLiteral.java

@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.literal;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Singleton;
/**
* Supports inline instantiation of the {@link Singleton} annotation.
*
* @author Martin Kouba
* @since 2.0
*/
public final class SingletonLiteral extends AnnotationLiteral<Singleton> implements Singleton {
public static final SingletonLiteral INSTANCE = new SingletonLiteral();
private static final long serialVersionUID = 1L;
}

63
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/se/SeContainer.java

@ -0,0 +1,63 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.se;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
/**
* Provides access to the current container in Java SE.
*
* <p>
* SeContainer implements {@link Instance} and therefore might be used to perform programmatic lookup.
* If no qualifier is passed to {@link #select} method, the <tt>@Default</tt> qualifier is assumed.
* </p>
*
* @author Antoine Sabot-Durand
* @author John D. Ament
* @since 2.0
*/
public interface SeContainer extends Instance<Object>,AutoCloseable {
/**
* <p>
* Shuts down this SeContainer instance when it is no longer in scope. Implemented from {@link AutoCloseable},
* </p>
* @throws IllegalStateException if the container is already shutdown
*/
@Override
void close();
/**
*
* Check if the container is running or was shut down
*
* @return true if called before container shutdown
*/
boolean isRunning();
/**
* Get the CDI BeanManager for this container
*
* @return the BeanManager
* @throws IllegalStateException if called when the container is already shutdown
*/
BeanManager getBeanManager();
}

298
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/se/SeContainerInitializer.java

@ -0,0 +1,298 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.se;
import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.Map;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import javax.enterprise.inject.spi.Extension;
/**
* A CDI container initializer for Java SE. An instance may be obtained by calling {@link SeContainerInitializer#newInstance()}
* static method.
* <p>
* Typical usage looks like this:
* </p>
*
* <pre>
* SeContainer container = SeContainerInitializer.newInstance().initialize();
* container.select(Foo.class).get();
* container.close();
* </pre>
*
* <p>
* Since {@link SeContainer} interface implements AutoCloseable:
* </p>
*
* <pre>
* try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
* container.select(Foo.class).get();
* }
* </pre>
*
* <p>
* By default, the discovery is enabled so that all beans from all discovered bean archives are considered. However, it's
* possible to define a "synthetic" bean archive, or the set of bean classes and enablement respectively:
* </p>
* <pre>
* SeContainer container = SeContainerInitializer.newInstance().addBeanClasses(Foo.class, Bar.class).selectAlternatives(Bar.class).initialize());
* </pre>
*
* <p>
* Moreover, it's also possible to disable the discovery completely so that only the "synthetic" bean archive is considered:
* </p>
*
* <pre>
* SeContainer container = SeContainerInitializer.newInstance().disableDiscovery().addBeanClasses(Foo.class, Bar.class).initialize());
* </pre>
* <p>
* In the same manner, it is possible to explicitly declare interceptors, decorators, extensions and implementation specific
* options using the builder.
* </p>
*
* <pre>
* SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance()
* .disableDiscovery()
* .addPackages(Main.class, Utils.class)
* .enableInterceptors(TransactionalInterceptor.class)
* .addProperty("property", true);
* SeContainer container = container.initialize();
* </pre>
*
* @author Antoine Sabot-Durand
* @author Martin Kouba
* @author John D. Ament
* @since 2.0
*/
public abstract class SeContainerInitializer {
/**
* Returns an instance of {@link SeContainerInitializer}
* Each call returns a new instance
*
* @return a new SeContainerInitializer instance.
* @throws IllegalStateException if called in a Java EE container
*/
public static SeContainerInitializer newInstance() {
return findSeContainerInitializer();
}
private static SeContainerInitializer findSeContainerInitializer() {
SeContainerInitializer result;
Iterator<SeContainerInitializer> iterator = ServiceLoader.load(SeContainerInitializer.class, SeContainerInitializer.class.getClassLoader()).iterator();
if (!iterator.hasNext()) {
throw new IllegalStateException("No valid CDI implementation found");
}
try {
result = iterator.next();
} catch (ServiceConfigurationError e) {
throw new IllegalStateException("Error while instantiating SeContainerInitializer", e);
}
if (iterator.hasNext())
throw new IllegalStateException("Two or more CDI implementations found, only one is supported");
return result;
}
/**
* Add provided bean classes to the synthetic bean archive.
*
* @param classes classes to add to the synthetic bean archive
* @return self
*/
public abstract SeContainerInitializer addBeanClasses(Class<?>... classes);
/**
* All classes from the packages of the specified classes will be added to the set of bean classes for the synthetic bean archive.
* <p>
* <p>
* Note that the scanning possibilities are limited. Therefore, only directories and jar files from the filesystem are supported.
* </p>
* <p>
* <p>
* Scanning may also have negative impact on SE performance.
* </p>
*
* @param packageClasses classes whose packages will be added to the synthetic bean archive
* @return self
*/
public abstract SeContainerInitializer addPackages(Class<?>... packageClasses);
/**
* Packages of the specified classes will be scanned and found classes will be added to the set of bean classes for the synthetic bean archive.*
* <p>
* <p>
* Note that the scanning possibilities are limited. Therefore, only directories and jar files from the filesystem are supported.
* </p>
* <p>
* <p>
* Scanning may also have negative impact on SE performance.
* </p>
*
* @param scanRecursively should subpackages be scanned or not
* @param packageClasses classes whose packages will be scanned
* @return self
*/
public abstract SeContainerInitializer addPackages(boolean scanRecursively, Class<?>... packageClasses);
/**
* All classes from the specified packages will be added to the set of bean classes for the synthetic bean archive.
* <p>
* <p>
* Note that the scanning possibilities are limited. Therefore, only directories and jar files from the filesystem are supported.
* </p>
* <p>
* <p>
* Scanning may also have negative impact on SE performance.
* </p>
*
* @param packages packages that will be added to the synthetic bean archive
* @return self
*/
public abstract SeContainerInitializer addPackages(Package... packages);
/**
* All classes from the specified packages will be added to the set of bean classes for the synthetic bean archive.
* <p>
* <p>
* Note that the scanning possibilities are limited. Therefore, only directories and jar files from the filesystem are supported.
* </p>
* <p>
* <p>
* Scanning may also have negative impact on SE performance.
* </p>
*
* @param scanRecursively should subpackages be scanned or not
* @param packages packages that will be added to the synthetic bean archive
* @return self
*/
public abstract SeContainerInitializer addPackages(boolean scanRecursively, Package... packages);
/**
* Add extensions to the set of extensions.
*
* @param extensions extensions to use in the container
* @return self
*/
public abstract SeContainerInitializer addExtensions(Extension... extensions);
/**
* Add extensions to the set of extensions.
*
* @param extensions extensions class to use in the container
* @return self
*/
@SuppressWarnings("unchecked")
public abstract SeContainerInitializer addExtensions(Class<? extends Extension>... extensions);
/**
* Add interceptor classes to the list of enabled interceptors for the synthetic bean archive.
* <p>
* This method does not add any class to the set of bean classes of the synthetic bean archive.
* </p>
* @param interceptorClasses classes of the interceptors to enable.
* @return self
*/
public abstract SeContainerInitializer enableInterceptors(Class<?>... interceptorClasses);
/**
* Add decorator classes to the list of enabled decorators for the synthetic bean archive.
* <p>
* This method does not add any class to the set of bean classes of the synthetic bean archive.
* </p>
* @param decoratorClasses classes of the decorators to enable.
* @return self
*/
public abstract SeContainerInitializer enableDecorators(Class<?>... decoratorClasses);
/**
* Add alternatives classes to the list of selected alternatives for the synthetic bean archive.
* <p>
* This method does not add any class to the set of bean classes of the synthetic bean archive.
* </p>
* @param alternativeClasses classes of the alternatives to select
* @return self
*/
public abstract SeContainerInitializer selectAlternatives(Class<?>... alternativeClasses);
/**
* Add alternative stereotype classes to the list of selected alternative stereotypes for the synthetic bean archive.
* <p>
* This method does not add any class to the set of bean classes of the synthetic bean archive.
* </p>
* @param alternativeStereotypeClasses alternatives stereotypes to select
* @return self
*/
@SuppressWarnings("unchecked")
public abstract SeContainerInitializer selectAlternativeStereotypes(Class<? extends Annotation>... alternativeStereotypeClasses);
/**
* Add a configuration property to the container
*
* @param key property name
* @param value property value
* @return self
*/
public abstract SeContainerInitializer addProperty(String key, Object value);
/**
* Set all the configuration properties.
* Erase previous properties set
*
* @param properties a map containing properties to add
* @return self
*/
public abstract SeContainerInitializer setProperties(Map<String, Object> properties);
/**
* By default, the discovery is enabled. However, it's possible to disable the discovery completely so that only the "synthetic" bean archive is considered.
*
* @return self
*/
public abstract SeContainerInitializer disableDiscovery();
/**
* Set a {@link ClassLoader}. The given {@link ClassLoader} will be scanned automatically for bean archives if scanning is enabled.
*
* @param classLoader the class loader to use
* @return self
*/
public abstract SeContainerInitializer setClassLoader(ClassLoader classLoader);
/**
* <p>
* Initializes a CDI SeContainerInitializer.
* </p>
* <p>
* Cannot be called within an application server.
* </p>
*
* @return the {@link SeContainer} instance associated with the container.
* @throws UnsupportedOperationException if called within an application server
*/
public abstract SeContainer initialize();
}

142
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AfterBeanDiscovery.java

@ -0,0 +1,142 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.context.spi.Context;
import javax.enterprise.inject.spi.configurator.BeanConfigurator;
import javax.enterprise.inject.spi.configurator.ObserverMethodConfigurator;
/**
* <p>
* 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.
* </p>
* <p>
* 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.
* </p>
*
* <pre>
* void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) { ... }
* </pre>
* <p>
* If any observer method of the {@code AfterBeanDiscovery} event throws an exception, the exception is treated as a definition
* error by the container.
* </p>
*
* @author David Allen
* @author Antoine Sabot-Durand
*/
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}
* @throws IllegalStateException if called outside of the observer method invocation
*/
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 a bean which is not an interceptor nor a decorator 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addBean(Bean<?> bean);
/**
*
* Obtains a new {@link BeanConfigurator} to configure a new {@link Bean} and add it at the end of the observer invocation.
* It will then fire an event of type {@link javax.enterprise.inject.spi.ProcessBean} containing the built
* {@link javax.enterprise.inject.spi.Bean} from this configuration and then register it with the
* container, thereby making it available for injection into other beans.
*
* Each call returns a new BeanConfigurator.
*
* @return a non reusable {@link BeanConfigurator} to configure the bean to add
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public <T> BeanConfigurator<T> addBean();
/**
* 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addObserverMethod(ObserverMethod<?> observerMethod);
/**
* obtains a new {@link ObserverMethodConfigurator} to configure a new {@link ObserverMethod} and add it at the end of the observer invocation.
* It will then fire an event of type {@link javax.enterprise.inject.spi.ProcessObserverMethod} containing the built
* {@link javax.enterprise.inject.spi.ObserverMethod} from this configuration and then registers the
* {@link javax.enterprise.inject.spi.ObserverMethod} with the container, thereby making it available for event
* notifications.
*
* Each call returns a new ObserverMethodConfigurator.
*
* @return a non reusable {@link ObserverMethodConfigurator} instance
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public <T> ObserverMethodConfigurator<T> addObserverMethod();
/**
* Registers a custom {@link javax.enterprise.context.spi.Context} object with the container.
*
* @param context The custom context to add to the deployment
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addContext(Context context);
/**
* Obtain the {@link AnnotatedType} that may be used to read the annotations of the given class or interface as defined
* during container initialization.
*
* @param <T> the class or interface
* @param type the {@link java.lang.Class} object
* @param id the type identifier. If null, the fully qualifier class name of type is used
* @return the {@link AnnotatedType}
* @throws IllegalStateException if called outside of the observer method invocation
* @since 1.1
*/
public <T> AnnotatedType<T> getAnnotatedType(Class<T> type, String id);
/**
* Obtain the {@link AnnotatedType}s that may be used to read the annotations of the given class or interface as defined
* during container initialization.
*
* @param <T> the class or interface
* @param type the {@link java.lang.Class} object
* @return the {@link AnnotatedType}s
* @throws IllegalStateException if called outside of the observer method invocation
* @since 1.1
*/
public <T> Iterable<AnnotatedType<T>> getAnnotatedTypes(Class<T> type);
}

42
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AfterDeploymentValidation.java

@ -0,0 +1,42 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* 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.
* </p>
* <p>
* No requests will be processed by the deployment until all observers of this event return.
* </p>
*
* @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}
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addDeploymentProblem(Throwable t);
}

111
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AfterTypeDiscovery.java

@ -0,0 +1,111 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
import java.util.List;
/**
* <p>
* This event type is thrown by the container after type discovery is complete. If any observer method of the
* {@code AfterTypeDiscovery} event throws an exception, the exception is treated as a definition error by the container.
* </p>
* <p>
* Any observer of this event is permitted to add classes to, or remove classes from, the list of alternatives, list of
* interceptors or list of decorators. The container will use the final values of these lists, after all observers have been
* called, to determine the enabled alternatives, interceptors, and decorators for application.
* Changes made to these lists after the invocation of the last observer method of the {@code AfterTypeDiscovery} are ignored.
* </p>
*
* @author Pete Muir
* @author Antoine Sabot-Durand
* @since 1.1
*/
public interface AfterTypeDiscovery {
/**
* @return the list of enabled alternatives for the application, sorted by priority in ascending order. Alternatives enabled for a bean archive are not included.
* @throws IllegalStateException if called outside of the observer method invocation
*/
public List<Class<?>> getAlternatives();
/**
* @return the list of enabled interceptors for the application, sorted by priority in ascending order. Interceptors enabled for a bean archive are not included.
* @throws IllegalStateException if called outside of the observer method invocation
*/
public List<Class<?>> getInterceptors();
/**
* @return the list of enabled decorators for the application, sorted by priority in ascending order. Decorators enabled for a bean archive are not included.
* @throws IllegalStateException if called outside of the observer method invocation
*/
public List<Class<?>> getDecorators();
/**
* <p>
* Adds a given {@link javax.enterprise.inject.spi.AnnotatedType} to the set of types which will be scanned during bean
* discovery.
* </p>
*
* <p>
* Thanks to the id parameter, this method allows multiple annotated types, based on the same underlying type, to be defined. {@link AnnotatedType}s
* discovered by the container use the fully qualified class name of {@link AnnotatedType#getJavaClass()} to identify the
* type.
* </p>
*
* <p>
* {@link AfterBeanDiscovery#getAnnotatedType(Class, String)} and {@link AfterBeanDiscovery#getAnnotatedTypes(Class)} allows
* annotated types to be obtained by identifier.
* </p>
*
* @param type The {@link javax.enterprise.inject.spi.AnnotatedType} to add for later scanning
* @param id the identifier used to distinguish this AnnotatedType from an other one based on the same underlying type
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addAnnotatedType(AnnotatedType<?> type, String id);
/**
* <p>
* Obtains a new {@link AnnotatedTypeConfigurator} to configure a new {@link javax.enterprise.inject.spi.AnnotatedType} and
* add it to the set of types which will be scanned during bean discovery at the end of the observer invocation.
* Calling this method multiple times will return a new AnnotatedTypeConfigurator.
* </p>
*
* <p>
* Thanks to the id parameter, this method allows multiple annotated types, based on the same underlying type, to be defined. {@link AnnotatedType}s
* discovered by the container use the fully qualified class name of {@link AnnotatedType#getJavaClass()} to identify the
* type.
* </p>
*
* <p>
* {@link AfterBeanDiscovery#getAnnotatedType(Class, String)} and {@link AfterBeanDiscovery#getAnnotatedTypes(Class)} allows
* annotated types to be obtained by identifier.
* </p>
*
* Each call returns a new AnnotatedTypeConfigurator.
*
*
* @param type class used to initialized the type and annotations on the {@link AnnotatedTypeConfigurator}
* @param id the identifier used to distinguish this AnnotatedType from an other one based on the same underlying type
* @return a non reusable {@link AnnotatedTypeConfigurator} to configure the new AnnotatedType
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> type, String id);
}

108
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Annotated.java

@ -0,0 +1,108 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
import java.util.Set;
/**
* <p>
* Represents a Java program element that can be annotated.
* <p>
*
* @see java.lang.reflect.AnnotatedElement
*
* @author Gavin King
* @author Pete Muir
* @author Clint Popetz
* @author John D. Ament
*
*/
public interface Annotated {
/**
* <p>
* Get the type of the annotated program element.
* </p>
*
* @return the type of the annotated program element
*/
Type getBaseType();
/**
* <p>
* Get all types to which the base type should be considered assignable.
* </p>
*
* @return a set of all types to which the base type should be considered assignable
*/
Set<Type> getTypeClosure();
/**
* <p>
* Get program element annotation of a certain annotation type.
*
* The behavior of this method is intended to be the same behavior as {@link AnnotatedElement#getAnnotation(Class)},
* where repeatable annotations are not supported.
*</p>
*
* @param <T> the type of the annotation
* @param annotationType the class of the annotation type
* @return the first program element annotation of the given annotation type, or a null value
*/
<T extends Annotation> T getAnnotation(Class<T> annotationType);
/**
* <p>
* Get program element annotations of a certain annotation type.
* <p>
* This method returns back all annotations, including repeatable annotations of this type.
*
* The behavior of this method is intended to be the same behavior as {@link AnnotatedElement#getAnnotationsByType(Class)},
* where repeatable annotations are supported.
* </p>
*
* @param <T> the type of the annotation
* @param annotationType the class of the annotation type
* @return the program element annotations of the given annotation type, or an empty collection
*/
<T extends Annotation> Set<T> getAnnotations(Class<T> annotationType);
/**
* <p>
* Get all annotations of the program element.
* </p>
*
* @return all annotations of the program element, or an empty set if no annotations are present
*/
Set<Annotation> getAnnotations();
/**
* <p>
* Determine if the program element has an annotation of a certain annotation type.
*
* The behavior of this method is similar to {@link AnnotatedElement#isAnnotationPresent(Class)} for the underlying
* program element.
*
* @param annotationType the annotation type to check for
* @return <tt>true</tt> if the program element has an annotation of the given annotation type, or <tt>false</tt> otherwise
*/
boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
}

42
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedCallable.java

@ -0,0 +1,42 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.util.List;
/**
* <p>
* Represents a callable member of a Java type.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <X> the declaring type
*/
public interface AnnotatedCallable<X> extends AnnotatedMember<X> {
/**
* <p>
* Get the parameters of the callable member.
* </p>
*
* @return the parameters
*/
public List<AnnotatedParameter<X>> getParameters();
}

53
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedConstructor.java

@ -0,0 +1,53 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Arrays.asList;
/**
* <p>
* Represents a constructor of a Java class.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <X> the declaring class
* @see Constructor
*/
public interface AnnotatedConstructor<X> extends AnnotatedCallable<X> {
/**
* <p>
* Get the underlying {@link Constructor}.
* </p>
*
* @return the constructor
*/
public Constructor<X> getJavaMember();
@Override default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType) {
T[] annotationsByType = getJavaMember().getAnnotationsByType(annotationType);
return new LinkedHashSet<>(asList(annotationsByType));
}
}

52
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedField.java

@ -0,0 +1,52 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Arrays.asList;
/**
* <p>
* Represents a field of a Java class.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <X> the declaring type
* @see Field
*/
public interface AnnotatedField<X> extends AnnotatedMember<X> {
/**
* <p>
* Get the underlying {@link Field}.
* </p>
*
* @return the {@link Field}
*/
public Field getJavaMember();
@Override default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType) {
T[] annotationsByType = getJavaMember().getAnnotationsByType(annotationType);
return new LinkedHashSet<>(asList(annotationsByType));
}
}

60
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedMember.java

@ -0,0 +1,60 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.reflect.Member;
/**
* <p>
* Represents a member of a Java type.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <X> the declaring type
* @see Member
*/
public interface AnnotatedMember<X> extends Annotated {
/**
* <p>
* Get the underlying {@link Member}.
* </p>
*
* @return the {@link Member}
*/
public Member getJavaMember();
/**
* <p>
* Determines if the member is static.
* </p>
*
* @return <tt>true</tt> if the member is static
*/
public boolean isStatic();
/**
* <p>
* Get the {@linkplain AnnotatedType type} which defines this member.
* </p>
*
* @return the type which defines this member
*/
public AnnotatedType<X> getDeclaringType();
}

52
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedMethod.java

@ -0,0 +1,52 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Arrays.asList;
/**
* <p>
* Represents a method of a Java type.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <X> the declaring type
* @see Method
*/
public interface AnnotatedMethod<X> extends AnnotatedCallable<X> {
/**
* <p>
* Get the underlying {@link Method}.
* </p>
*
* @return the {@link Method}
*/
public Method getJavaMember();
@Override default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType) {
T[] annotationsByType = getJavaMember().getAnnotationsByType(annotationType);
return new LinkedHashSet<>(asList(annotationsByType));
}
}

79
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedParameter.java

@ -0,0 +1,79 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Executable;
import java.lang.reflect.Member;
import java.lang.reflect.Parameter;
import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Arrays.asList;
/**
* <p>
* Represents a parameter of a method or constructor.
* </p>
*
* @author Gavin King
* @author Pete Muir
* @author Jozef Hartinger
*
* @param <X> the type that declares the method or constructor
*/
public interface AnnotatedParameter<X> extends Annotated {
/**
* <p>
* Get the position of the parameter in the method or constructor argument list.
* </p>
*
* @return the position of the parameter
*/
public int getPosition();
/**
* <p>
* Get the declaring {@linkplain AnnotatedCallable method or constructor}.
* </p>
*
* @return the declaring callable
*/
public AnnotatedCallable<X> getDeclaringCallable();
/**
* Get the underlying {@link Parameter}.
*
* @return the {@link Parameter}
*/
default Parameter getJavaParameter() {
Member member = getDeclaringCallable().getJavaMember();
if (!(member instanceof Executable)) {
throw new IllegalStateException("Parameter does not belong to an executable: " + member);
}
Executable executable = (Executable) member;
return executable.getParameters()[getPosition()];
}
@Override default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType) {
T[] annotationsByType = getJavaParameter().getAnnotationsByType(annotationType);
return new LinkedHashSet<>(asList(annotationsByType));
}
}

80
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/AnnotatedType.java

@ -0,0 +1,80 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Arrays.asList;
/**
* <p>
* Represents a Java class or interface.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <X> the type
* @see java.lang.Class
*/
public interface AnnotatedType<X> extends Annotated {
/**
* <p>
* Get the underlying {@link java.lang.Class}.
* </p>
*
* @return the {@link java.lang.Class}
*/
public Class<X> getJavaClass();
/**
* <p>
* Get the {@linkplain AnnotatedConstructor constructors} of the type. If an empty set is returned, a default constructor
* with no parameters will be assumed.
* </p>
*
* @return the constructors, or an empty set if none are defined
*/
public Set<AnnotatedConstructor<X>> getConstructors();
/**
* <p>
* Get the {@linkplain AnnotatedMethod methods} of the type.
* </p>
*
* @return the methods, or an empty set if none are defined
*/
public Set<AnnotatedMethod<? super X>> getMethods();
/**
* <p>
* Get the {@linkplain AnnotatedField fields} of the type.
* <p>
*
* @return the fields, or an empty set if none are defined
*/
public Set<AnnotatedField<? super X>> getFields();
@Override default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType) {
T[] annotationsByType = getJavaClass().getAnnotationsByType(annotationType);
return new LinkedHashSet<>(asList(annotationsByType));
}
}

66
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Bean.java

@ -0,0 +1,66 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.util.Set;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
/**
* <p>
* Represents an {@linkplain javax.enterprise.inject enabled bean}. This interface defines everything the container needs to
* manage instances of the bean.
* </p>
*
* @author Gavin King
* @author David Allen
* @param <T> the class of the bean instance
*/
public interface Bean<T> extends Contextual<T>, BeanAttributes<T> {
/**
* 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();
/**
* 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<InjectionPoint> getInjectionPoints();
/**
* <p>
* Determines if {@link javax.enterprise.context.spi.Contextual#create(CreationalContext)} sometimes return a null value.
* </p>
*
* <p>
* As of CDI 1.1 this method is deprecated and can safely always return false.
* </p>
*
* @return <tt>true</tt> if the {@code create()} method may return a null value, and <tt>false</tt> otherwise
*/
public boolean isNullable();
}

79
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeanAttributes.java

@ -0,0 +1,79 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
/**
* The BeanAttributes interface exposes the basic attributes of a bean.
*
* @author Pete Muir
* @since 1.1
* @param <T> the class of the bean instance
*/
public interface BeanAttributes<T> {
/**
* Obtains the {@linkplain javax.enterprise.inject bean types} of the bean.
*
* @return the {@linkplain javax.enterprise.inject bean types}
*/
public Set<Type> getTypes();
/**
* Obtains the {@linkplain javax.inject.Qualifier qualifiers} of the bean.
*
* @return the {@linkplain javax.inject.Qualifier qualifiers}
*/
public Set<Annotation> getQualifiers();
/**
* Obtains the {@linkplain javax.enterprise.context scope} of the bean.
*
* @return the {@linkplain javax.enterprise.context scope}
*/
public Class<? extends Annotation> 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<Class<? extends Annotation>> getStereotypes();
/**
* Determines if the bean is an {@linkplain javax.enterprise.inject.Alternative alternative}.
*
* A custom implementation of {@link Bean} may implement {@link Prioritized} in order to be selected for the application.
* {@link Prioritized#getPriority()} determines the priority used to resolve ambiguities.
*
* @return <tt>true</tt> if the bean is an {@linkplain javax.enterprise.inject.Alternative alternative}, and <tt>false</tt>
* otherwise.
*/
public boolean isAlternative();
}

663
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeanManager.java

@ -0,0 +1,663 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, 2013 Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
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.event.Event;
import javax.enterprise.event.ObserverException;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.InjectionException;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.util.Nonbinding;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Set;
/**
* <p>
* 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.
* </p>
*
* <p>
* Any bean may obtain an instance of <tt>BeanManager</tt> by injecting it:
* </p>
*
* <pre>
* &#064;Inject
* BeanManager manager;
* </pre>
*
* <p>
* Java EE components may obtain an instance of <tt>BeanManager</tt> from {@linkplain javax.naming JNDI} by looking up the name
* {@code java:comp/BeanManager}.
* </p>
*
* <p>
* Most operations of BeanManager may be called at any time during the execution of the application.
* </p>
* <p>
* However, the following operations must not be called before the {@link AfterBeanDiscovery} event is fired:
* </p>
* <ul>
* <li>{@link #getBeans(String)},</li>
* <li>{@link #getBeans(java.lang.reflect.Type, java.lang.annotation.Annotation...)},</li>
* <li>{@link #getPassivationCapableBean(String)},</li>
* <li>{@link #resolve(java.util.Set)},</li>
* <li>{@link #resolveDecorators(java.util.Set, java.lang.annotation.Annotation...)},</li>
* <li>{@link #resolveInterceptors(InterceptionType, java.lang.annotation.Annotation...)},</li>
* <li>{@link #resolveObserverMethods(Object, java.lang.annotation.Annotation...)},</li>
* <li>{@link #validate(InjectionPoint)},</li>
* <li>{@link #createInstance()}</li>
* </ul>
* <p>
* and the following operations must not be called before the {@link AfterDeploymentValidation} event is fired:
* </p>
* <ul>
* <li>{@link #getReference(Bean, java.lang.reflect.Type, javax.enterprise.context.spi.CreationalContext)},</li>
* <li>{@link #getInjectableReference(InjectionPoint, javax.enterprise.context.spi.CreationalContext)},</li>
* </ul>
* <p>
* or the container will throw an Exception.
* </p>
*
* @author Gavin King
* @author Pete Muir
* @author Clint Popetz
* @author David Allen
* @author Antoine Sabot-Durand
*/
public interface BeanManager {
/**
* <p>
* Obtains a contextual reference for a certain {@linkplain Bean bean} and a certain bean type of the bean.
* </p>
*
* @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
* {@link 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
* @throws IllegalStateException if called during application initialization, before the {@link AfterDeploymentValidation}
* event is fired.
*/
public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> ctx);
/**
* <p>
* Obtains an injectable reference for a certain {@linkplain InjectionPoint injection point}.
* </p>
*
* @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
* {@link 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
* @throws IllegalStateException if called during application initialization, before the {@link AfterDeploymentValidation}
* event is fired.
*/
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 <T> CreationalContext<T> createCreationalContext(Contextual<T> 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 <tt>BeanManager</tt> was injected or the Java EE component from whose JNDI
* environment namespace the <tt>BeanManager</tt> was obtained, according to the rules of typesafe resolution. If no
* qualifiers are given, the {@linkplain javax.enterprise.inject.Default default qualifier} is assumed.
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return beans discovered by the container before the {@link AfterBeanDiscovery} event is fired.
*
* @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 non repeating qualifier type are given
* @throws IllegalArgumentException if an instance of an annotation that is not a qualifier type is given
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public Set<Bean<?>> 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 <tt>BeanManager</tt> was injected or the Java EE component from whose JNDI environment namespace
* the <tt>BeanManager</tt> was obtained, according to the rules of EL name resolution.
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return beans discovered by the container before the {@link AfterBeanDiscovery} event is fired.
*
* @param name the EL name
* @return the resulting set of {@linkplain Bean beans}
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public Set<Bean<?>> getBeans(String name);
/**
* Returns the {@link javax.enterprise.inject.spi.PassivationCapable} bean with the given identifier.
*
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return beans discovered by the container before the {@link AfterBeanDiscovery} event is fired.
*
* @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
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public Bean<?> getPassivationCapableBean(String id);
/**
* Apply the ambiguous dependency resolution rules to a set of {@linkplain Bean beans}.
*
* <p/>
Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return beans discovered by the container before the {@link AfterBeanDiscovery} event is fired.
*
* @param <X> a common type of the beans
* @param beans a set of {@linkplain Bean beans} of the given type
* @return the resolved bean, or null if null or an empty set is passed
* @throws AmbiguousResolutionException if the ambiguous dependency resolution rules fail
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public <X> Bean<? extends X> resolve(Set<Bean<? extends X>> beans);
/**
* Validate a certain {@linkplain InjectionPoint injection point}.
*
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only validate injection points discovered by the container before the {@link AfterBeanDiscovery}
* event is fired.
*
* @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
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public void validate(InjectionPoint injectionPoint);
/**
* Fire an event and notify observers.
*
* <p>
* This method is deprecated from CDI 2.0 and {@link #getEvent())} should be used instead.
* </p>
*
* @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 non repeating qualifier type are given
* @throws IllegalArgumentException if an instance of an annotation that is not a qualifier type is given
* @throws IllegalArgumentException if the runtime type of the event object is assignable to the type of a container
* lifecycle event
* @throws ObserverException if a notified observer throws a checked exception, it will be wrapped and rethrown as an
* (unchecked) {@link ObserverException}
*/
public void fireEvent(Object event, Annotation... qualifiers);
/**
* Return an ordered set of {@linkplain ObserverMethod observer methods} for an event.
*
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return observers discovered by the container before the {@link AfterBeanDiscovery} event is fired.
*
* @param <T> the type of the event
* @param event the event object
* @param qualifiers the event qualifiers
* @return the resulting set of {@linkplain ObserverMethod observer methods}
* @throws IllegalArgumentException if the runtime type of the event object contains a type variable
* @throws IllegalArgumentException if two instances of the same non repeating qualifier type are given
* @throws IllegalArgumentException if an instance of an annotation that is not a qualifier type is given
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public <T> Set<ObserverMethod<? super T>> 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 <tt>BeanManager</tt> was injected or the Java EE
* component from whose JNDI environment namespace the <tt>BeanManager</tt> was obtained.
*
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return decorators discovered by the container before the {@link AfterBeanDiscovery} event is fired.
*
* @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
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public List<Decorator<?>> resolveDecorators(Set<Type> 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 <tt>BeanManager</tt> was
* injected or the Java EE component from whose JNDI environment namespace the <tt>BeanManager</tt> was obtained.
*
* <p/>
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* this method will only return interceptors discovered by the container before the {@link AfterBeanDiscovery} event is
* fired.
*
* @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
* @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery}
* event is fired.
*/
public List<Interceptor<?>> 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<? extends Annotation> 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 <tt>true</tt> if the annotation type is a {@linkplain javax.enterprise.context normal scope type}
*/
public boolean isNormalScope(Class<? extends Annotation> 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 <tt>true</tt> if the annotation type is a passivating scope type
*/
public boolean isPassivatingScope(Class<? extends Annotation> annotationType);
/**
* Test the given annotation type to determine if it is a {@linkplain javax.inject.Qualifier qualifier type}.
*
* @param annotationType the annotation type
* @return <tt>true</tt> if the annotation type is a {@linkplain javax.inject.Qualifier qualifier type}
*/
public boolean isQualifier(Class<? extends Annotation> 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 <tt>true</tt> if the annotation type is a {@linkplain javax.interceptor.InterceptorBinding interceptor binding
* type}
*/
public boolean isInterceptorBinding(Class<? extends Annotation> annotationType);
/**
* Test the given annotation type to determine if it is a {@linkplain javax.enterprise.inject.Stereotype stereotype}.
*
* @param annotationType the annotation type
* @return <tt>true</tt> if the annotation type is a {@linkplain javax.enterprise.inject.Stereotype stereotype}
*/
public boolean isStereotype(Class<? extends Annotation> 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<Annotation> getInterceptorBindingDefinition(Class<? extends Annotation> 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<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype);
/**
* Determine if two qualifiers are considered equivalent for the purposes of typesafe resolution, taking into account any
* members annotated with {@link Nonbinding}.
*
* @param qualifier1 a qualifier to check
* @param qualifier2 a qualifier to check
* @return true if the two qualifiers are equivalent, otherwise false
* @since 1.1
*/
public boolean areQualifiersEquivalent(Annotation qualifier1, Annotation qualifier2);
/**
* Determine if two interceptor bindings are considered equivalent for the purposes of typesafe resolution, taking into
* account any members annotated with {@link Nonbinding}.
*
* @param interceptorBinding1 an interceptor binding to check
* @param interceptorBinding2 an interceptor binding to check
* @return true if the two interceptor bindings are equivalent, otherwise false
* @since 1.1
*/
public boolean areInterceptorBindingsEquivalent(Annotation interceptorBinding1, Annotation interceptorBinding2);
/**
* Determine the hash code of a qualifier, using the JDK algorithm for determining an annotation hash code, ignoring any
* members annotated with {@link Nonbinding}.
*
* @param qualifier the qualifier to consider
* @return the hashCode for the qualifier
* @since 1.1
*/
public int getQualifierHashCode(Annotation qualifier);
/**
* Determine the hash code of an interceptor binding, using the JDK algorithm for determining an annotation hash code,
* ignoring any members annotated with {@link Nonbinding}.
*
* @param interceptorBinding the interceptor binding to consider
* @return the hashCode for the interceptor binding
* @since 1.1
*/
public int getInterceptorBindingHashCode(Annotation interceptorBinding);
/**
* 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<? extends Annotation> scopeType);
/**
* Returns a {@link javax.el.ELResolver} that resolves beans by EL name.
*
* @return the {@link javax.el.ELResolver}
*/
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 <T> the class or interface
* @param type the {@link java.lang.Class} object
* @return the {@link AnnotatedType}
*/
public <T> AnnotatedType<T> createAnnotatedType(Class<T> type);
/**
* <p>
* 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.
* </p>
*
* <p>
* This method is deprecated from CDI 1.1 and {@link #getInjectionTargetFactory(AnnotatedType)} should be used instead.
* </p>
*
* @param <T> the type
* @param type the {@link AnnotatedType}
* @return a container provided implementation of {@link InjectionTarget}
* @throws IllegalArgumentException if there is a definition error associated with any injection point of the type
*/
public <T> InjectionTarget<T> createInjectionTarget(AnnotatedType<T> type);
/**
* <p>
* An implementation of {@link InjectionTargetFactory} that provides container created {@link InjectionTarget} instances.
* </p>
*
* <p>
* This factory can be wrapped to add behavior to container created injection targets.
* </p>
*
* @param annotatedType the annotated type to create the injection target factory for
* @return an {@link InjectionTargetFactory}
* @since 1.1
*/
public <T> InjectionTargetFactory<T> getInjectionTargetFactory(AnnotatedType<T> annotatedType);
/**
* <p>
* An implementation of {@link ProducerFactory} that provides container created {@link Producer} instances for the given
* field.
* </p>
*
* <p>
* This factory can be wrapped to add behavior to container created producers.
* </p>
*
* @param field the field to create the producer factory for
* @param declaringBean the bean declaring the producer. May be null if the producer is static or the declaring object is
* non-contextual
* @return the producer factory for the field
* @since 1.1
*/
public <X> ProducerFactory<X> getProducerFactory(AnnotatedField<? super X> field, Bean<X> declaringBean);
/**
* <p>
* An implementation of {@link ProducerFactory} that provides container created {@link Producer} instances for the given
* method.
* </p>
*
* <p>
* This factory can be wrapped to add behavior to container created producers.
* </p>
*
* @param method the method to create the producer factory for
* @param declaringBean the bean declaring the producer. May be null if the producer is static or the declaring object is
* non-contextual
* @return the producer factory for the method
* @since 1.1
*/
public <X> ProducerFactory<X> getProducerFactory(AnnotatedMethod<? super X> method, Bean<X> declaringBean);
/**
* Obtains a {@link BeanAttributes} 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 <T> the type
* @param type the {@link AnnotatedType}
* @return a container provided implementation of {@link InjectionTarget}
* @since 1.1
*/
public <T> BeanAttributes<T> createBeanAttributes(AnnotatedType<T> type);
/**
* Obtains a {@link BeanAttributes} 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 type the {@link AnnotatedType}
* @return a container provided implementation of {@link InjectionTarget}
* @since 1.1
*/
public BeanAttributes<?> createBeanAttributes(AnnotatedMember<?> type);
/**
* <p>
* Obtains a {@link Bean} for the given {@link BeanAttributes}, bean class and {@link InjectionTarget}.
* </p>
*
* <p>
* The {@link InjectionTarget} creates and destroys instances of the bean, performs dependency injection and lifecycle
* callbacks, and determines the return value of {@link Bean#getInjectionPoints()}. The {@link InjectionTarget} is obtained
* from the {@link InjectionTargetFactory}. {@link #getInjectionTargetFactory(AnnotatedType)} allows use of a container created
* {@link InjectionTarget}.
* </p>
*
* @param <T> the type
* @param attributes a {@link BeanAttributes} which determines the bean types, qualifiers, scope, name and stereotypes of
* the returned {@link Bean}, and the return values of {@link Bean#isAlternative()} and {@link Bean#isNullable()}
* @param beanClass a class, which determines the return value of {@link Bean#getBeanClass()}
* @param injectionTargetFactory an {@link InjectionTargetFactory}, used to obtain an {@link InjectionTarget}
* @return a container provided implementation of {@link Bean}
* @since 1.1
*/
public <T> Bean<T> createBean(BeanAttributes<T> attributes, Class<T> beanClass,
InjectionTargetFactory<T> injectionTargetFactory);
/**
* <p>
* Obtains a {@link Bean} for the given {@link BeanAttributes}, bean class and {@link Producer}.
* </p>
*
* <p>
* The {@link Producer} creates and destroys instances of the decorator, and determines the return value of
* {@link Bean#getInjectionPoints()}. The {@link Producer} is obtained from the {@link ProducerFactory}.
* {@link #getProducerFactory(AnnotatedMethod, Bean)} or {@link #getProducerFactory(AnnotatedField, Bean)} allows use of a
* container created {@link Producer}.
* </p>
*
* @param <T> the type
* @param <X> the type of the declaring bean
* @param attributes a {@link BeanAttributes} which determines the bean types, qualifiers, scope, name and stereotypes of
* the returned {@link Bean}, and the return values of {@link Bean#isAlternative()} and {@link Bean#isNullable()}
* @param beanClass a class, which determines the return value of <tt>Bean.getClass()</tt>
* @param producerFactory a {@link ProducerFactory}, used to obtain a {@link Producer}
* @return a container provided implementation of {@link Bean}
* @since 1.1
*/
public <T, X> Bean<T> createBean(BeanAttributes<T> attributes, Class<X> beanClass, ProducerFactory<X> producerFactory);
/**
* Obtains a container provided implementation of {@link InjectionPoint} for the given {@link AnnotatedField}.
*
* @param field the {@link AnnotatedField} defining the injection point
* @return the container provided {@link InjectionPoint}
* @throws IllegalArgumentException if there is a definition error associated with the injection point
* @since 1.1
*/
public InjectionPoint createInjectionPoint(AnnotatedField<?> field);
/**
* Obtains a container provided implementation of {@link InjectionPoint} for the given {@link AnnotatedParameter}.
*
* @param parameter the {@link AnnotatedParameter} defining the injection point
* @return the container provided {@link InjectionPoint}
* @throws IllegalArgumentException if there is a definition error associated with the injection point
* @since 1.1
*/
public InjectionPoint createInjectionPoint(AnnotatedParameter<?> parameter);
/**
* Obtains the container's instance of an Extension class declared in <code>META-INF/services</code>.
*
* @param <T> the type of the extension
* @param extensionClass the type of the extension class
* @return the extension instance
* @throws IllegalArgumentException if the container has no instance of the given class
* @since 1.1
*/
public <T extends Extension> T getExtension(Class<T> extensionClass);
/**
*
* Create an {@link InterceptionFactory} for the given {@link CreationalContext} and type.
*
* @param ctx {@link CreationalContext} for the {@link InterceptionFactory} to create
* @param clazz class of the instance this factory will work on
* @param <T> type of the instance this factory will work on
* @return a new {@link InterceptionFactory} to add services on on instances of T
* @since 2.0
*/
<T> InterceptionFactory<T> createInterceptionFactory(CreationalContext<T> ctx, Class<T> clazz);
/**
*
* Returns an instance of Event with specified type <tt>java.lang.Object</tt> and specified qualifier <tt>@Default</tt>
* It allows typesafe synchronous or asynchronous event firing without injection of {@link Event} built-in bean requirement.
*
* @return a new {@link Event} object whose event type is <tt>Object</tt> and qualifier <tt>@Default</tt>
* @since 2.0
*/
Event<Object> getEvent();
/**
*
* Obtains an {@link Instance} object to access to beans instances.
*
* The returned <tt>Instance</tt> object can only access instances of beans that are available for injection in the module
* or library containing the class into which the <tt>BeanManager</tt> was injected or the Java EE component from whose JNDI
* environment namespace the <tt>BeanManager</tt> was obtained, according to the rules of typesafe resolution.
*
* Note that when called during invocation of an {@link AfterBeanDiscovery} event observer,
* the <tt>Instance</tt> returned by this method will only give access to instances of beans discovered by the container
* before the {@link AfterBeanDiscovery} event is fired.
*
* Instances of dependent scoped beans obtained with this <tt>Instance</tt> must be explicitly destroyed by calling {@link Instance#destroy(Object)}
*
* If no qualifier is passed to {@link Instance#select} method, the <tt>@Default</tt> qualifier is assumed.
*
* @return an {@link Instance} object to request beans instances
* @throws IllegalStateException if called during application initialization, before the {@link AfterDeploymentValidation}
* event is fired.
* @since 2.0
*/
Instance<Object> createInstance();
}

246
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeforeBeanDiscovery.java

@ -0,0 +1,246 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.context.NormalScope;
import javax.enterprise.inject.Stereotype;
import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
import javax.inject.Qualifier;
import javax.inject.Scope;
import javax.interceptor.InterceptorBinding;
import java.lang.annotation.Annotation;
/**
* <p>
* 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.
* </p>
*
* @author Pete Muir
* @author David Allen
* @author Antoine Sabot-Durand
*/
public interface BeforeBeanDiscovery {
/**
* <p>
* Declares an annotation type as a {@linkplain javax.inject.Qualifier} qualifier type.
* </p>
*
* <p>
* This is only required if you wish to make an annotation a qualifier without adding {@link Qualifier} to it.
* </p>
*
* @param qualifier The annotation to treat as a qualifier
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addQualifier(Class<? extends Annotation> qualifier);
/**
* <p>
* Declares an annotation type as a {@linkplain javax.inject.Qualifier} qualifier type.
* </p>
*
* <p>
* This is only required if you wish to make an annotation a qualifier without adding {@link Qualifier} to it.
* </p>
*
* @param qualifier The annotation to treat as a qualifier
* @throws IllegalStateException if called outside of the observer method invocation
* @since 1.1
*/
public void addQualifier(AnnotatedType<? extends Annotation> qualifier);
/**
* <p>
* Declares an annotation type as a {@linkplain javax.enterprise.context scope type}.
* </p>
*
* <p>
* This is only required if you wish to make an annotation a scope type without adding the {@link NormalScope} or
* {@link Scope} annotations to it. You can also use this method to override an existing normal scope definition.
* </p>
*
* @see AfterBeanDiscovery#addContext(javax.enterprise.context.spi.Context)
*
* @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}
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addScope(Class<? extends Annotation> scopeType, boolean normal, boolean passivating);
/**
* <p>
* Declares an annotation type as a {@linkplain javax.enterprise.inject.Stereotype stereotype}, and specifies its
* meta-annotations.
* </p>
*
* <p>
* This is only required if you wish to make an annotation a stereotype without adding {@link Stereotype} to it. You can
* also use this method to override an existing stereotype definition.
* </p>
*
* @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}
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addStereotype(Class<? extends Annotation> stereotype, Annotation... stereotypeDef);
/**
* <p>
* Declares an annotation type as an {@linkplain Interceptor interceptor} binding type.
* </p>
*
* <p>
* This is only required if you wish to make an annotation an interceptor binding type without adding
* {@link InterceptorBinding} to it.
* </p>
*
* @param bindingType The annotation type to treat as an interceptor binding type
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addInterceptorBinding(AnnotatedType<? extends Annotation> bindingType);
/**
* <p>
* Declares an annotation type as an {@linkplain Interceptor interceptor} binding type, and specifies its meta-annotations.
* </p>
*
* <p>
* This is only required if you wish to make an annotation an interceptor binding type without adding
* {@link InterceptorBinding} to it.
* </p>
*
* @param bindingType The annotation type to treat as an interceptor binding type
* @param bindingTypeDef An optional list of annotations defining the {@linkplain Interceptor interceptor}
* @throws IllegalStateException if called outside of the observer method invocation
* @since 1.1
*/
public void addInterceptorBinding(Class<? extends Annotation> bindingType, Annotation... bindingTypeDef);
/**
* <p>
* Adds a given {@link javax.enterprise.inject.spi.AnnotatedType} to the set of types which will be scanned during bean
* discovery.
* </p>
*
* <p>
* This method is deprecated from CDI 1.1 and {@link #addAnnotatedType(AnnotatedType, String)} should be used instead.
* </p>
*
* @throws IllegalStateException if called outside of the observer method invocation
* @param type The {@link javax.enterprise.inject.spi.AnnotatedType} to add for later scanning
*/
public void addAnnotatedType(AnnotatedType<?> type);
/**
* <p>
* Adds a given {@link javax.enterprise.inject.spi.AnnotatedType} to the set of types which will be scanned during bean
* discovery.
* </p>
*
* <p>
* Thanks to the id parameter, this method allows multiple annotated types, based on the same underlying type, to be defined. {@link AnnotatedType}s
* discovered by the container use the fully qualified class name of {@link AnnotatedType#getJavaClass()} to identify the
* type.
* </p>
*
* <p>
* {@link AfterBeanDiscovery#getAnnotatedType(Class, String)} and {@link AfterBeanDiscovery#getAnnotatedTypes(Class)} allows
* annotated types to be obtained by identifier.
* </p>
*
* @param type The {@link javax.enterprise.inject.spi.AnnotatedType} to add for later scanning
* @param id the identifier used to distinguish this AnnotatedType from an other one based on the same underlying type
* @throws IllegalStateException if called outside of the observer method invocation
* @since 1.1
*/
public void addAnnotatedType(AnnotatedType<?> type, String id);
/**
* <p>
* Obtains a new {@link AnnotatedTypeConfigurator} to configure a new {@link javax.enterprise.inject.spi.AnnotatedType} and
* add it to the set of types which will be scanned during bean discovery at the end of the observer invocation
* </p>
*
* <p>
* Thanks to the id parameter, this method allows multiple annotated types, based on the same underlying type, to be defined with a builder.
* {@link AnnotatedType}s discovered by the container use the fully qualified class name of
* {@link AnnotatedType#getJavaClass()} to identify the type.
* </p>
*
* <p>
* {@link AfterBeanDiscovery#getAnnotatedType(Class, String)} and {@link AfterBeanDiscovery#getAnnotatedTypes(Class)} allows
* annotated types to be obtained by identifier.
* </p>
*
* Each call returns a new AnnotatedTypeConfigurator
*
*
* @param type class used to initialized the type and annotations on the {@link AnnotatedTypeConfigurator}
* @param id the identifier used to distinguish this AnnotatedType from an other one based on the same underlying type
* @return a non reusable {@link AnnotatedTypeConfigurator} to configure the new AnnotatedType
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> type, String id);
/**
*
* <p>
* Obtains a new {@link AnnotatedTypeConfigurator} to configure a new {@link javax.enterprise.inject.spi.AnnotatedType}
* and declares it as a {@linkplain javax.inject.Qualifier} qualifier type.
* </p>
*
* <p>
* This is only required if you wish to make an annotation a qualifier without adding {@link Qualifier} to it and need to
* easily add other annotations (like {@link javax.enterprise.util.Nonbinding} on its members.
* </p>
*
* @param qualifier The annotation class used to initialized the configurator
* @throws IllegalStateException if called outside of the observer method invocation
* @return a non reusable {@link AnnotatedTypeConfigurator} to configure the qualifier
* @since 2.0
*/
<T extends Annotation> AnnotatedTypeConfigurator<T> configureQualifier(Class<T> qualifier);
/**
*
* <p>
* Obtains a new {@link AnnotatedTypeConfigurator} to configure a new {@link javax.enterprise.inject.spi.AnnotatedType}
* and declares it as an {@linkplain Interceptor interceptor} binding type.
* </p>
*
* <p>
* This is only required if you wish to make an annotation an interceptor binding type without adding
* {@link InterceptorBinding} to it and need to easily add other annotations
* (like {@link javax.enterprise.util.Nonbinding} on its members.
* </p>
*
* @param bindingType The annotation class used to initialized the configurator
* @throws IllegalStateException if called outside of the observer method invocation
* @return a non reusable {@link AnnotatedTypeConfigurator} to configure the interceptor binding
* @since 2.0
*/
<T extends Annotation> AnnotatedTypeConfigurator<T> configureInterceptorBinding(Class<T> bindingType);
}

28
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/BeforeShutdown.java

@ -0,0 +1,28 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* 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.
* </p>
*
* @author David Allen
*/
public interface BeforeShutdown {
}

141
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/CDI.java

@ -0,0 +1,141 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, 2015, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.inject.Instance;
import java.util.Collections;
import java.util.Comparator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.TreeSet;
/**
* Provides access to the current container.
*
* <p>
* CDI implements {@link Instance} and therefore might be used to perform programmatic lookup.
* If no qualifier is passed to {@link #select} method, the <tt>@Default</tt> qualifier is assumed.
* </p>
*
*
* @author Pete Muir
* @author Antoine Sabot-Durand
* @author John D. Ament
* @since 1.1
* @param <T> type inherited from {@link Instance}. Always Object for CDI
*/
public abstract class CDI<T> implements Instance<T> {
private static final Object lock = new Object();
protected static volatile Set<CDIProvider> discoveredProviders = null;
protected static volatile CDIProvider configuredProvider = null;
/**
* <p>
* Get the CDI instance that provides access to the current container.
* </p>
*
* <p>
* If there are no providers available, an {@link IllegalStateException} is thrown, otherwise the first provider which can
* access the container is used.
* </p>
*
* @throws IllegalStateException if no {@link CDIProvider} is available
* @return the CDI instance
*/
public static CDI<Object> current() {
return getCDIProvider().getCDI();
}
/**
*
* Obtain the {@link CDIProvider} the user set with {@link #setCDIProvider(CDIProvider)}, or if it wasn't set, use the
* serviceloader the retrieve the {@link CDIProvider} with the highest priority.
*
* @return the {@link CDIProvider} set by user or retrieved by serviceloader
*/
private static CDIProvider getCDIProvider() {
if (configuredProvider != null) {
return configuredProvider;
} else {
// Discover providers and cache
if (discoveredProviders == null) {
synchronized (lock) {
if (discoveredProviders == null) {
findAllProviders();
}
}
}
configuredProvider = discoveredProviders.stream()
.filter(c -> c.getCDI() != null)
.findFirst().orElseThrow(() -> new IllegalStateException("Unable to access CDI"));
return configuredProvider;
}
}
/**
* <p>
* Set the {@link CDIProvider} to use.
* </p>
*
* <p>
* If a {@link CDIProvider} is set using this method, any provider specified as a service provider will not be used.
* </p>
*
* @param provider the provider to use
* @throws IllegalStateException if the {@link CDIProvider} is already set
*/
public static void setCDIProvider(CDIProvider provider) {
if (provider != null) {
configuredProvider = provider;
} else {
throw new IllegalStateException("CDIProvider must not be null");
}
}
private static void findAllProviders() {
ServiceLoader<CDIProvider> providerLoader;
Set<CDIProvider> providers = new TreeSet<>(Comparator.comparingInt(CDIProvider::getPriority).reversed());
providerLoader = SecurityActions.loadService(CDIProvider.class, CDI.class.getClassLoader());
if(! providerLoader.iterator().hasNext()) {
throw new IllegalStateException("Unable to locate CDIProvider");
}
try {
providerLoader.forEach(providers::add);
} catch (ServiceConfigurationError e) {
throw new IllegalStateException(e);
}
CDI.discoveredProviders = Collections.unmodifiableSet(providers);
}
// Helper methods
/**
* Get the CDI BeanManager for the current context
*
* @return the BeanManager
*/
public abstract BeanManager getBeanManager();
}

43
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/CDIProvider.java

@ -0,0 +1,43 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, 2015 Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* Interface implemented by a CDI provider to provide access to the current container
*
* @author Pete Muir
* @since 1.1
*/
public interface CDIProvider extends Prioritized {
public static final int DEFAULT_CDI_PROVIDER_PRIORITY = 0;
/**
* Provides access to the current container
*
* @return the CDI instance for the current container
* @throws IllegalStateException if no CDI container is available
*/
CDI<Object> getCDI();
@Override
default int getPriority() {
return DEFAULT_CDI_PROVIDER_PRIORITY;
};
}

68
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Decorator.java

@ -0,0 +1,68 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
/**
* <p>
* Represents an enabled {@linkplain javax.decorator decorator}.
* </p>
* <p>
* Since CDI 2.0, an implementation of this interface may implement {@link Prioritized} in order to enable the decorator with
* given priority value for entire application.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
* @param <T> the decorator bean class
*/
public interface Decorator<T> extends Bean<T> {
/**
* <p>
* Obtains the {@linkplain Type type} of the {@linkplain javax.decorator.Delegate delegate injection point}.
* </p>
*
* @return the delegate {@linkplain Type type}
*/
public Type getDelegateType();
/**
* <p>
* Obtains the {@linkplain javax.inject.Qualifier qualifiers} of the {@linkplain javax.decorator.Delegate delegate injection
* point}.
* </p>
*
* @return the delegate {@linkplain javax.inject.Qualifier qualifiers}
*/
public Set<Annotation> getDelegateQualifiers();
/**
* <p>
* Obtains the {@linkplain javax.decorator decorated types}.
* </p>
*
* @return the set of decorated {@linkplain Type types}
*/
public Set<Type> getDecoratedTypes();
}

59
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/DefinitionException.java

@ -0,0 +1,59 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* Thrown when a definition error occurs.
* </p>
*
* <p>
* Definition errors are developer errors. They may be detected by tooling at development time, and are also detected by the
* container at initialization time. If a definition error exists in a deployment, initialization will be aborted by the
* container.
* </p>
*
* <p>
* The container is permitted to define a non-portable mode, for use at development time, in which some definition errors do not
* cause application initialization to abort.
* </p>
*
* <p>
* An implementation is permitted to throw a subclass of {@link DefinitionException} for any definition error which exists.
* </p>
*
* @author Pete Muir
* @since 1.1
*/
public class DefinitionException extends RuntimeException {
private static final long serialVersionUID = -2699170549782567339L;
public DefinitionException(String message, Throwable t) {
super(message, t);
}
public DefinitionException(String message) {
super(message);
}
public DefinitionException(Throwable t) {
super(t);
}
}

59
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/DeploymentException.java

@ -0,0 +1,59 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* Thrown when a deployment problem occurs.
* </p>
*
* <p>
* Deployment problems are detected by the container at initialization time. If a deployment problem exists in a deployment,
* initialization will be aborted by the container.
* </p>
*
* <p>
* The container is permitted to define a non-portable mode, for use at development time, in which some deployment problems do
* not cause application initialization to abort.
* </p>
*
* <p>
* An implementation is permitted to throw a subclass of {@link DeploymentException} for any deployment problem.
* </p>
*
* @author Pete Muir
* @since 1.1
*
*/
public class DeploymentException extends RuntimeException {
private static final long serialVersionUID = 2604707587772339984L;
public DeploymentException(String message, Throwable t) {
super(message, t);
}
public DeploymentException(String message) {
super(message);
}
public DeploymentException(Throwable t) {
super(t);
}
}

43
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/EventContext.java

@ -0,0 +1,43 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016 Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* Represents a context of a fired event. Provides access to an event object and corresponding metadata.
*
* @author Martin Kouba
* @see ObserverMethod#notify(EventContext)
* @see EventMetadata
* @since 2.0
* @param <T> type of event object
*/
public interface EventContext<T> {
/**
*
* @return the event object, aka the payload
*/
T getEvent();
/**
*
* @return the event metadata
*/
EventMetadata getMetadata();
}

69
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/EventMetadata.java

@ -0,0 +1,69 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, 2015 Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
/**
* <p>
* Provides access to metadata about an observed event payload. The metadata may be for events fired with either of
* {@link javax.enterprise.event.Event} or {@link BeanManager#fireEvent(Object, Annotation...)}.
* </p>
* <p>
* {@link EventMetadata} may only be injected into an observer method. For example:
* </p>
*
* <pre>
* public void afterLogin(&#064;Observes LoggedInEvent event, EventMetadata eventMetadata) { ... }
* </pre>
*
* @see Observes
*
* @author Lincoln Baxter, III
* @author Pete Muir
* @author Antoine Sabot-Durand
* @since 1.1
*/
public interface EventMetadata {
/**
* @return the qualifiers for which event payload was fired.
*/
public Set<Annotation> getQualifiers();
/**
* Get the {@link InjectionPoint} representing the injected {@link Event} instance which fired the event, or
* <code>null</code> if it was fired from {@link BeanManager#fireEvent(Object, Annotation...)};
*
* @return InjectionPoint of the Event
*/
public InjectionPoint getInjectionPoint();
/**
* Get the type representing runtime class of the event object with type variables resolved.
*
*
* @return the runtime type of the event object
*/
public Type getType();
}

47
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Extension.java

@ -0,0 +1,47 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* Service interface implemented by extensions. An extension is a service provider declared in <tt>META-INF/services</tt>.
* </p>
*
* <p>
* 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}.
* <p>
*
* <p>
* 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.
* </p>
*
* <p>
* Service providers are made available for injection as beans with the qualifier {@link javax.enterprise.inject.Default
* &#064;Default}.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
*/
public interface Extension {
}

123
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InjectionPoint.java

@ -0,0 +1,123 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Type;
import java.util.Set;
import javax.enterprise.inject.Instance;
/**
* <p>
* 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}.
* </p>
*
* <p>
* If the injection point is a dynamically selected reference obtained then the metadata obtain reflects the injection point of
* the {@link Instance}, with the required type and any additional required qualifiers defined by {@linkplain Instance
* Instance.select()}.
* </p>
*
* <p>
* Occasionally, a bean with scope {@link javax.enterprise.context.Dependent &#064;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.
* </p>
*
* <p>
* For example, the following producer method creates injectable <tt>Logger</tt> s. The log category of a <tt>Logger</tt>
* depends upon the class of the object into which it is injected.
* </p>
*
* <pre>
* &#064;Produces
* Logger createLogger(InjectionPoint injectionPoint) {
* return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
* }
* </pre>
*
* <p>
* Only {@linkplain javax.enterprise.context.Dependent dependent} objects, may obtain information about the injection point to
* which they belong.
* </p>
*
* @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<Annotation> 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 <tt>true</tt> if the injection point is a decorator delegate injection point, and <tt>false</tt> otherwise
*/
public boolean isDelegate();
/**
* Determines if the injection is a transient field.
*
* @return <tt>true</tt> if the injection point is a transient field, and <tt>false</tt> otherwise
*/
public boolean isTransient();
}

67
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InjectionTarget.java

@ -0,0 +1,67 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.context.spi.CreationalContext;
/**
* <p>
* Provides operations for performing {@linkplain javax.enterprise.inject dependency injection} and lifecycle callbacks on an
* instance of a type.
* </p>
*
* @see javax.annotation.PostConstruct
* @see javax.annotation.PreDestroy
*
* @author Pete Muir
* @author David Allen
* @param <T> The class of the instance
*/
public interface InjectionTarget<T> extends Producer<T> {
/**
* <p>
* 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.
* </p>
*
* @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<T> ctx);
/**
* <p>
* Calls the {@link javax.annotation.PostConstruct} callback, if it exists, according to the semantics required by the Java
* EE platform specification.
* </p>
*
* @param instance The instance on which to invoke the {@link javax.annotation.PostConstruct} method
*/
public void postConstruct(T instance);
/**
* <p>
* Calls the {@link javax.annotation.PreDestroy} callback, if it exists, according to the semantics required by the Java EE
* platform specification.
* </p>
*
* @param instance The instance on which to invoke the {@link javax.annotation.PreDestroy} method
*/
public void preDestroy(T instance);
}

77
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InjectionTargetFactory.java

@ -0,0 +1,77 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
/**
* <p>
* An {@link InjectionTargetFactory} can create an {@link InjectionTarget} for a given bean.
* </p>
*
* <p>
* The {@link InjectionTargetFactory} obtained from {@link BeanManager#getInjectionTargetFactory(AnnotatedType)} is capable of providing
* container created injection targets. This factory can be wrapped to add behavior to container created injection targets.
* </p>
*
* <p>
* For example:
* </p>
*
* <pre>
* BeanAttributes&lt;MyBean&gt; myBeanAttributes = beanManager.createBeanAttributes(myBeanAnnotatedType);
* beanManager.createBean(myBeanAttributes, MyBean.class, new InjectionTargetFactory() {
*
* public &lt;T&gt; InjectionTarget&lt;T&gt; createInjectionTarget(Bean&lt;T&gt; bean) {
* return new WrappingInjectionTarget&lt;T&gt;(beanManager.getInjectionTargetFactory(myBeanAnnotatedType).createInjectionTarget(
* bean));
* }
* });
* </pre>
*
* @author Pete Muir
* @author Antoine Sabot-Durand
* @since 1.1
*
* @param <T> type on which this InjectionTarget operates
*/
public interface InjectionTargetFactory<T> {
/**
* Create a new injection target for a bean.
*
* @param bean the bean to create the injection target for, or null if creating a non-contextual object
* @return the injection target
*/
public InjectionTarget<T> createInjectionTarget(Bean<T> bean);
/**
*
* Returns an {@link AnnotatedTypeConfigurator} to to configure the {@link AnnotatedType} used to create the {@link InjectionTarget}.
*
* Each call returns the same AnnotatedTypeConfigurator.
*
* @return an {@link AnnotatedTypeConfigurator} to configure injection points
* @throws IllegalStateException if used after {@link #createInjectionTarget(Bean)} invocation
* @since 2.0
*/
public default AnnotatedTypeConfigurator<T> configure() {
throw new UnsupportedOperationException("Configuration not supported here");
}
}

137
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InterceptionFactory.java

@ -0,0 +1,137 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
/**
* {@link InterceptionFactory} allows to create a wrapper instance whose method invocations are intercepted by method
* interceptors and forwarded to a provided instance.
*
* <p>
* An implementation of {@link InterceptionFactory} may be obtained by calling
* {@link BeanManager#createInterceptionFactory(CreationalContext, Class)} to be used in the create method of a custom bean for
* example.
* </p>
*
* <pre>
* public class MyCustomBean implements Bean&lt;MyClass&gt; {
*
* BeanManager bm;
*
* public MyBean(BeanManager bm) {
* this.bm = bm;
* }
*
* public MyClass create(CreationalContext&lt;MyClass&gt; creationalContext) {
*
* InterceptionFactory<MyClass> factory = bm.createInterceptionFactory(creationalContext, MyClass.class);
*
* factory.configure().filterMethods(m -> m.getJavaMember().getName().equals("shouldBeTransactional")).findFirst()
* .ifPresent(m -> m.add(new AnnotationLiteral&lt;Transactional&gt;() {
* }));
*
* return factory.createInterceptedInstance(new MyClass());
* }
* }
* </pre>
*
* <p>
* The container must also provide a built-in bean with scope {@link Dependent}, bean type {@link InterceptionFactory} and
* qualifier {@link Default} that can be injected in a producer method parameter.
* </p>
*
* <pre>
* &#64;Produces
* &#64;RequestScoped
* public MyClass produceMyClass(InterceptionFactory<MyClass> factory) {
* factory.configure().add(new AnnotationLiteral<Transactional>() {
* });
* return factory.createInterceptedInstance(new MyClass());
* }
* </pre>
*
* <p>
* Instances of this class are neither reusable nor suitable for sharing between threads.
* </p>
*
* @author Antoine Sabot-Durand
* @since 2.0
* @param <T> type for which the wrapper is created
*/
public interface InterceptionFactory<T> {
/**
* Instructs the container to ignore all non-static, final methods with public, protected or default visibility declared by
* any class in the type hierarchy of the intercepted instance during invocation of
* {@link #createInterceptedInstance(Object)}.
*
* <p>
* Ignored methods should never be invoked upon the wrapper instance created by
* {@link #createInterceptedInstance(Object)}. Otherwise, unpredictable behavior results.
* </p>
*
* @return self
*/
InterceptionFactory<T> ignoreFinalMethods();
/**
* Returns an {@link AnnotatedTypeConfigurator} initialized with the {@link AnnotatedType} created either for the class
* passed to {@link BeanManager#createInterceptionFactory(CreationalContext, Class)} or derived from the
* {@link InterceptionFactory} parameter injection point.
*
* <p>
* The configurator allows to add or remove interceptor bindings used to associate interceptors with the wrapper instance
* returned by {@link #createInterceptedInstance(Object)}.
* </p>
*
* <p>
* Each call returns the same {@link AnnotatedTypeConfigurator}.
* </p>
*
* @return an {@link AnnotatedTypeConfigurator} to configure interceptors bindings
*/
AnnotatedTypeConfigurator<T> configure();
/**
* Returns a wrapper instance whose method invocations are intercepted by method interceptors and forwarded to a provided
* instance.
*
* <p>
* This method should only be called once, subsequent calls will throw an {@link IllegalStateException}.
* </p>
*
* <p>
* If T is not proxyable as defined in section 3.11 of the spec an
* {@link javax.enterprise.inject.UnproxyableResolutionException} exception is thrown. Calling {@link #ignoreFinalMethods()}
* before this method can loosen these restrictions.
* </p>
*
* <p>
* If the provided instance is an internal container construct (such as client proxy), non-portable behavior results.
* </p>
*
* @param instance The provided instance
* @return a wrapper instance
*/
T createInterceptedInstance(T instance);
}

65
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/InterceptionType.java

@ -0,0 +1,65 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* Identifies the kind of lifecycle callback, EJB timeout method or business method interception.
* </p>
*
* @author Gavin King
* @author Pete Muir
*
*/
public enum InterceptionType {
/**
* Intercepts method invocation
*/
AROUND_INVOKE,
/**
* Intercepts a timeout
*/
AROUND_TIMEOUT,
/**
* Intercepts a constructor invocation
*/
AROUND_CONSTRUCT,
/**
* Intercepts bean construction
*/
POST_CONSTRUCT,
/**
* Intercepts bean destruction
*/
PRE_DESTROY,
/**
* Intercepts bean passivation, only called for EJBs
*/
PRE_PASSIVATE,
/**
* Intercepts bean activation, only called for EJBs
*/
POST_ACTIVATE
}

77
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Interceptor.java

@ -0,0 +1,77 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.util.Set;
import javax.interceptor.InvocationContext;
/**
* <p>
* Represents an enabled {@linkplain javax.interceptor interceptor}.
* </p>
* <p>
* Since CDI 2.0, an implementation of this interface may implement {@link Prioritized} in order to enable the interceptor with
* given priority value for entire application.
* </p>
*
* @author Gavin King
* @author Pete Muir
* @author David Allen
*
* @param <T> the interceptor bean class
*/
public interface Interceptor<T> extends Bean<T> {
/**
* <p>
* Obtains the {@linkplain javax.interceptor.InterceptorBinding interceptor bindings} of the interceptor.
* </p>
*
* @return the set of {@linkplain javax.interceptor.InterceptorBinding interceptor bindings}
*/
public Set<Annotation> getInterceptorBindings();
/**
* <p>
* Determines if the interceptor intercepts the specified {@linkplain InterceptionType kind of lifecycle callback or method
* invocation}.
* </p>
*
* @param type the {@linkplain InterceptionType kind of interception}
* @return returns <tt>true</tt> if the interceptor intercepts callbacks or business methods of the given type, and
* <tt>false</tt> otherwise.
*/
public boolean intercepts(InterceptionType type);
/**
* <p>
* Invokes the specified {@linkplain InterceptionType kind of lifecycle callback or method invocation interception} upon the
* given interceptor instance.
* </p>
*
* @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
* @throws Exception thrown by the target method and/or the following interceptors in the chain
*/
public Object intercept(InterceptionType type, T instance, InvocationContext ctx) throws Exception;
}

140
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ObserverMethod.java

@ -0,0 +1,140 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, 2015 Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
import javax.enterprise.event.ObservesAsync;
import javax.enterprise.event.Reception;
import javax.enterprise.event.TransactionPhase;
/**
* <p>
* 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.
* </p>
*
* <p>
* If a custom implementation of this interface does not override either {@link #notify(Object)} or
* {@link #notify(EventContext)}, the container automatically detects the problem and treats it as a definition error.
* </p>
*
* @author Gavin King
* @author David Allen
* @author Mark Paluch
* @author Antoine Sabot-Durand
* @param <T> the event type
*/
public interface ObserverMethod<T> extends Prioritized {
public static final int DEFAULT_PRIORITY = javax.interceptor.Interceptor.Priority.APPLICATION + 500;
/**
* <p>
* Obtains the {@linkplain Class class} of the type that declares the observer method.
* </p>
*
* @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<Annotation> 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();
/**
* The priority that will be used by the container to determine the notification order in which event observer
* methods are invoked.
*
* @return The priority that will be used by the container to determine the notification order in which event
* observer methods are invoked.
* @since 2.0
*/
@Override
public default int getPriority() {
return DEFAULT_PRIORITY;
}
/**
* <p>
* Calls the observer method, passing the given event object.
* </p>
*
* <p>
* The implementation of this method for a custom observer method is responsible for deciding whether to call
* the method if the {@link #getReception()} returns {@link Reception#IF_EXISTS}.
* </p>
*
* @param event the event object
*/
public default void notify(T event) {
}
/**
* Calls the observer method, passing the given event context.
* <p>
* The container should always call this method, but the default implementation delegates to {@link #notify(Object)}.
* <p>
* The implementation of this method for a custom observer method is responsible for deciding whether to call the method if
* the {@link #getReception()} returns {@link Reception#IF_EXISTS}.
*
* @param eventContext {@link EventContext} used to notify observers
*/
public default void notify(EventContext<T> eventContext) {
notify(eventContext.getEvent());
}
/**
* <p>
* Determines if this observer method is asynchronous
* </p>
*
* @return returns <tt>true</tt> if the method is an asynchronous observer method (i.e. defined with {@link ObservesAsync}),
* otherwise returns <tt>false</tt>
*
*/
public default boolean isAsync() {
return false;
}
}

38
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/PassivationCapable.java

@ -0,0 +1,38 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.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();
}

48
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/Prioritized.java

@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* This interface allows some SPI implementation to change their priority programmatically.
* </p>
*
* <p>
* For instance {@link ObserverMethod} extends this interface to set the observer priority.
*
* A custom alternative {@link Bean}, {@link Interceptor} or {@link Decorator} may implement this interface to be activated
* with a given priority
*
* </p>
*
* @see Bean
* @author Mark Paluch
* @author Antoine Sabot-Durand
* @since 2.0
*/
public interface Prioritized {
/**
* <p>
* Returns the priority for this SPI element.
* </p>
*
* @return the priority value
*/
int getPriority();
}

86
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessAnnotatedType.java

@ -0,0 +1,86 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
/**
* <p>
* 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.
* </p>
* <p>
* Any observer of this event is permitted to wrap and/or replace the {@link javax.enterprise.inject.spi.AnnotatedType} by calling either {@link #setAnnotatedType(AnnotatedType)} or {@link #configureAnnotatedType()}.
* If both methods are called within an observer notification an {@link IllegalStateException} is thrown.
* 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.
* </p>
* <p>
* For example, the following observer decorates the {@link javax.enterprise.inject.spi.AnnotatedType} for every class that is
* discovered by the container.
* </p>
*
* <pre>
* public &lt;T&gt; void decorateAnnotatedType(@Observes ProcessAnnotatedType&lt;T&gt; pat) {
* pat.setAnnotatedType(decorate(pat.getAnnotatedType()));
* }
* </pre>
* <p>
* If any observer method of a {@code ProcessAnnotatedType} event throws an exception, the exception is treated as a definition
* error by the container.
* </p>
*
* @author David Allen
* @author Antoine Sabot-Durand
* @see AnnotatedType
* @param <X> The class being annotated
*/
public interface ProcessAnnotatedType<X> {
/**
* 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public AnnotatedType<X> getAnnotatedType();
/**
* Replaces the {@link javax.enterprise.inject.spi.AnnotatedType}.
*
* @param type the new {@link javax.enterprise.inject.spi.AnnotatedType} object to use
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void setAnnotatedType(AnnotatedType<X> type);
/**
* Returns an {@link AnnotatedTypeConfigurator} initialized with the {@link AnnotatedType} processed by this event
* to configure a new AnnotatedType that will replace the original one at the end of the observer invocation.
*
* Each call returns the same AnnotatedTypeConfigurator.
*
* @return a non reusable {@link AnnotatedTypeConfigurator} to configure the replacing AnnotatedType
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public AnnotatedTypeConfigurator<X> configureAnnotatedType();
/**
* Forces the container to ignore this type.
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void veto();
}

84
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessBean.java

@ -0,0 +1,84 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* 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.
* </p>
* <p>
* The event object type depends upon what kind of bean was discovered:
* </p>
* <ul>
* <li>For a managed bean with bean class X, the container must raise an event of type
* {@link javax.enterprise.inject.spi.ProcessManagedBean}.</li>
* <li>For a session bean with bean class X, the container must raise an event of type
* {@link javax.enterprise.inject.spi.ProcessSessionBean}.</li>
* <li>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}.</li>
* <li>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}.</li>
* <li>For a custom implementation of {@link Bean}, the container must raise an event of type {@link ProcessSyntheticBean}.</li>
* </ul>
* <p>
* Resources are considered to be producer fields.
* </p>
* <p>
* If any observer method of a {@code ProcessBean} event throws an exception, the exception is treated as a definition error by
* the container.
* </p>
*
* @see Bean
* @author David Allen
* @param <X> The class of the bean
*/
public interface ProcessBean<X> {
/**
* 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.
*
* <p>
* If invoked upon a {@link ProcessSyntheticBean} event, non-portable behavior results and the returned value should be ignored.
* </p>
*
* @return the {@link javax.enterprise.inject.spi.Annotated} for the bean being registered
* @throws IllegalStateException if called outside of the observer method invocation
*/
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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public Bean<X> 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}
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addDefinitionError(Throwable t);
}

108
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessBeanAttributes.java

@ -0,0 +1,108 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.inject.New;
import javax.enterprise.inject.spi.configurator.BeanAttributesConfigurator;
/**
* <p>
* 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.
* </p>
* <p>
* No event is fired for {@link New} qualified beans.
* </p>
* <p>
* Any observer of this event is permitted to wrap and/or replace the {@link BeanAttributes} by calling either {@link #setBeanAttributes(BeanAttributes)} or {@link #configureBeanAttributes()}.
* If both methods are called within an observer notification an {@link IllegalStateException} is thrown.
* The container must use the final value of this property, after all observers have been called, to manage instances of the bean.
* </p>
* <p>
* If any observer method of a {@code ProcessBeanAttributes} event throws an exception, the exception is treated as a definition
* error by the container.
* </p>
*
* @author Pete Muir
* @author Antoine Sabot-Durand
* @param <T> The class of the bean
* @since 1.1
*/
public interface ProcessBeanAttributes<T> {
/**
* @return the {@link AnnotatedType} representing the managed bean class or session bean class, the {@link AnnotatedMethod}
* representing the producer field, or the {@link AnnotatedField} representing the producer field
* @throws IllegalStateException if called outside of the observer method invocation
*/
public Annotated getAnnotated();
/**
* @return the {@link BeanAttributes} object that will be used by the container to manage instances of the bean
* @throws IllegalStateException if called outside of the observer method invocation
*/
public BeanAttributes<T> getBeanAttributes();
/**
* Replaces the {@link BeanAttributes}.
*
* @param beanAttributes the new {@link BeanAttributes} to use
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void setBeanAttributes(BeanAttributes<T> beanAttributes);
/**
* returns a {@link BeanAttributesConfigurator} initialized with the {@link BeanAttributes} processed by this event
* to configure a new BeanAttributes that will replace the original one at the end of the observer invocation.
*
* Each call returns the same BeanAttributesConfigurator.
*
* @return a non reusable {@link BeanAttributesConfigurator} to configure the replacing BeanAttributes
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public BeanAttributesConfigurator<T> configureBeanAttributes();
/**
* Registers a definition error with the container, causing the container to abort deployment after bean discovery is
* complete.
*
* @param t the error to add
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addDefinitionError(Throwable t);
/**
* Forces the container to ignore the bean.
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void veto();
/**
* <p>Instructs the container to ignore all non-static, final methods with public, protected or default visibility
* declared on any bean type of the specific bean during validation of injection points that require proxyable bean type.</p>
*
* <p>These method should never be invoked upon bean instances. Otherwise, unpredictable behavior results.</p>
*
*
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public void ignoreFinalMethods();
}

82
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessInjectionPoint.java

@ -0,0 +1,82 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
import javax.enterprise.inject.spi.configurator.InjectionPointConfigurator;
/**
* <p>
* The container fires an event of this type for every injection point of 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.
* </p>
* <p>
* Any observer of this event is permitted to wrap and/or replace the {@link javax.enterprise.inject.spi.InjectionPoint} by calling either {@link #setInjectionPoint(InjectionPoint)} or {@link #configureInjectionPoint()}.
* If both methods are called within an observer notification an {@link IllegalStateException} is thrown.
* The container must use the final value of this property, after all observers have been called, he container must use the final
* value of this property, after all observers have been called, whenever it performs injection upon the injection point.
* </p>
* <p>
* If any observer method of a {@code ProcessInjectionPoint} event throws an exception, the exception is treated as a definition
* error by the container.
* </p>
*
* @see InjectionPoint
* @author Pete Muir
* @author Antoine Sabot-Durand
* @param <X> the declared type of the injection point.
* @param <T> the bean class of the bean that declares the injection point
*/
public interface ProcessInjectionPoint<T, X> {
/**
* @return the InjectionPoint object that will be used by the container to perform injection
* @throws IllegalStateException if called outside of the observer method invocation
*/
public InjectionPoint getInjectionPoint();
/**
* Replaces the InjectionPoint.
*
* @param injectionPoint the new injection point
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void setInjectionPoint(InjectionPoint injectionPoint);
/**
* Returns an {@link InjectionPointConfigurator} initialized with the {@link InjectionPoint} processed by this event
* to configure a new InjectionPoint that will replace the original one at the end of the observer invocation.
*
* Each call returns the same InjectionPointConfigurator
*
* @return a non reusable {@link InjectionPointConfigurator} to configure the replacing InjectionPoint
* @throws IllegalStateException if called outside of the observer method invocation
* @since 2.0
*/
public InjectionPointConfigurator configureInjectionPoint();
/**
* Registers a definition error with the container, causing the container to abort deployment after bean discovery is
* complete.
*
* @param t the definition error
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addDefinitionError(Throwable t);
}

83
fine-third-default/fine-javax-cdi/src/javax/enterprise/inject/spi/ProcessInjectionTarget.java

@ -0,0 +1,83 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi;
/**
* <p>
* 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.
* </p>
* <p>
* 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.
* </p>
* <p>
* For example, this observer decorates the {@code InjectionTarget} for all servlets.
* </p>
*
* <pre>
* public &lt;T extends Servlet&gt; void decorateServlet(@Observes ProcessInjectionTarget&lt;T&gt; pit) {
* pit.setInjectionTarget(decorate(pit.getInjectionTarget()));
* }
* </pre>
* <p>
* If any observer method of a {@code ProcessInjectionTarget} event throws an exception, the exception is treated as a
* definition error by the container.
* </p>
*
* @see InjectionTarget
* @author David Allen
* @param <X> The managed bean class, session bean class or Java EE component class supporting injection
*/
public interface ProcessInjectionTarget<X> {
/**
* 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public AnnotatedType<X> 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public InjectionTarget<X> 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void setInjectionTarget(InjectionTarget<X> 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
* @throws IllegalStateException if called outside of the observer method invocation
*/
public void addDefinitionError(Throwable t);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save