├── CODEOWNERS ├── .github ├── project.yml ├── dependabot.yml └── workflows │ ├── ci-actions.yml │ └── release.yml ├── .gitignore ├── SECURITY.md ├── weld-spi ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── jboss │ │ │ └── weld │ │ │ ├── bootstrap │ │ │ ├── spi │ │ │ │ ├── Metadata.java │ │ │ │ ├── SystemPropertyActivation.java │ │ │ │ ├── ClassAvailableActivation.java │ │ │ │ ├── Filter.java │ │ │ │ ├── Scanning.java │ │ │ │ ├── WeldFilter.java │ │ │ │ ├── BeanDiscoveryMode.java │ │ │ │ ├── helpers │ │ │ │ │ ├── EEModuleDescriptorImpl.java │ │ │ │ │ ├── MetadataImpl.java │ │ │ │ │ └── ForwardingBeanDeploymentArchive.java │ │ │ │ ├── CDI11Deployment.java │ │ │ │ └── EEModuleDescriptor.java │ │ │ └── api │ │ │ │ ├── Service.java │ │ │ │ ├── helpers │ │ │ │ ├── AbstractBootstrapService.java │ │ │ │ ├── RegistrySingletonProvider.java │ │ │ │ ├── ServiceRegistries.java │ │ │ │ ├── IsolatedStaticSingletonProvider.java │ │ │ │ ├── TCCLSingletonProvider.java │ │ │ │ ├── ForwardingBootstrap.java │ │ │ │ └── ForwardingServiceRegistry.java │ │ │ │ ├── BootstrapService.java │ │ │ │ ├── TypeDiscoveryConfiguration.java │ │ │ │ ├── Singleton.java │ │ │ │ └── Environment.java │ │ │ ├── servlet │ │ │ ├── spi │ │ │ │ ├── helpers │ │ │ │ │ ├── AcceptingHttpContextActivationFilter.java │ │ │ │ │ └── RegexHttpContextActivationFilter.java │ │ │ │ └── HttpContextActivationFilter.java │ │ │ └── api │ │ │ │ ├── ServletListener.java │ │ │ │ ├── helpers │ │ │ │ ├── AbstractServletListener.java │ │ │ │ └── ForwardingServletListener.java │ │ │ │ └── InitParameters.java │ │ │ ├── ejb │ │ │ ├── spi │ │ │ │ ├── BusinessInterfaceDescriptor.java │ │ │ │ ├── SubclassedComponentDescriptor.java │ │ │ │ ├── helpers │ │ │ │ │ ├── ForwadingBusinessInterfaceDescriptor.java │ │ │ │ │ └── ForwardingEjbServices.java │ │ │ │ └── EjbServices.java │ │ │ └── api │ │ │ │ └── SessionObjectReference.java │ │ │ ├── injection │ │ │ └── spi │ │ │ │ ├── ResourceReference.java │ │ │ │ ├── ResourceReferenceFactory.java │ │ │ │ ├── helpers │ │ │ │ ├── SimpleResourceReference.java │ │ │ │ ├── ForwardingResourceInjectionServices.java │ │ │ │ └── ForwardingJpaInjectionServices.java │ │ │ │ ├── JaxwsInjectionServices.java │ │ │ │ ├── EjbInjectionServices.java │ │ │ │ ├── InjectionContext.java │ │ │ │ ├── ResourceInjectionServices.java │ │ │ │ └── JpaInjectionServices.java │ │ │ ├── serialization │ │ │ └── spi │ │ │ │ ├── helpers │ │ │ │ ├── SerializableContextual.java │ │ │ │ └── SerializableContextualInstance.java │ │ │ │ └── BeanIdentifier.java │ │ │ ├── manager │ │ │ └── api │ │ │ │ ├── WeldInjectionTarget.java │ │ │ │ └── WeldInjectionTargetFactory.java │ │ │ ├── configuration │ │ │ └── spi │ │ │ │ ├── ExternalConfiguration.java │ │ │ │ └── helpers │ │ │ │ └── ExternalConfigurationBuilder.java │ │ │ ├── construction │ │ │ └── api │ │ │ │ ├── ConstructionHandle.java │ │ │ │ ├── WeldCreationalContext.java │ │ │ │ └── AroundConstructCallback.java │ │ │ ├── resources │ │ │ └── spi │ │ │ │ ├── ResourceLoadingException.java │ │ │ │ ├── ClassFileServices.java │ │ │ │ ├── ClassFileInfoException.java │ │ │ │ ├── helpers │ │ │ │ └── ForwardingResourceLoader.java │ │ │ │ └── ResourceLoader.java │ │ │ ├── security │ │ │ └── spi │ │ │ │ ├── SecurityContext.java │ │ │ │ └── SecurityServices.java │ │ │ └── transaction │ │ │ └── spi │ │ │ └── TransactionServices.java │ └── test │ │ └── java │ │ └── org │ │ └── jboss │ │ └── weld │ │ ├── bootstrap │ │ └── api │ │ │ └── test │ │ │ ├── MockService.java │ │ │ ├── MockResourceReference.java │ │ │ ├── MockSecurityServices.java │ │ │ ├── MockResourceFactory.java │ │ │ ├── MockResourceLoader.java │ │ │ ├── MockEjbInjectionServices.java │ │ │ ├── MockTransactionServices.java │ │ │ ├── MockResourceServices.java │ │ │ ├── MockJpaServices.java │ │ │ └── MockEjbServices.java │ │ └── servlet │ │ └── spi │ │ └── test │ │ └── HttpContextActivationFilterTest.java └── pom.xml ├── weld ├── src │ └── main │ │ └── java │ │ └── org │ │ └── jboss │ │ └── weld │ │ ├── context │ │ ├── DependentContext.java │ │ ├── ejb │ │ │ ├── EjbRequestContext.java │ │ │ ├── Ejb.java │ │ │ └── EjbLiteral.java │ │ ├── bound │ │ │ ├── BoundRequestContext.java │ │ │ ├── BoundSessionContext.java │ │ │ ├── Bound.java │ │ │ ├── MutableBoundRequest.java │ │ │ ├── BoundLiteral.java │ │ │ ├── BoundRequest.java │ │ │ └── BoundConversationContext.java │ │ ├── http │ │ │ ├── HttpRequestContext.java │ │ │ ├── Http.java │ │ │ ├── HttpLiteral.java │ │ │ ├── HttpSessionContext.java │ │ │ └── HttpConversationContext.java │ │ ├── unbound │ │ │ ├── Unbound.java │ │ │ └── UnboundLiteral.java │ │ ├── ApplicationContext.java │ │ ├── SingletonContext.java │ │ ├── ManagedContext.java │ │ ├── SessionContext.java │ │ ├── ManagedConversation.java │ │ ├── api │ │ │ └── ContextualInstance.java │ │ ├── RequestContext.java │ │ ├── BoundContext.java │ │ ├── activator │ │ │ └── ActivateRequestContext.java │ │ └── WeldAlterableContext.java │ │ ├── invoke │ │ └── WeldInvokerFactory.java │ │ ├── bootstrap │ │ └── event │ │ │ ├── WeldProcessManagedBean.java │ │ │ ├── WeldAfterBeanDiscovery.java │ │ │ └── InterceptorConfigurator.java │ │ ├── proxy │ │ ├── WeldConstruct.java │ │ └── WeldClientProxy.java │ │ ├── interceptor │ │ └── WeldInvocationContext.java │ │ └── events │ │ └── WeldEvent.java └── pom.xml ├── dco.txt └── CODE_OF_CONDUCT.md /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @manovotn 2 | -------------------------------------------------------------------------------- /.github/project.yml: -------------------------------------------------------------------------------- 1 | name: Weld API 2 | release: 3 | current-version: 7.0.Alpha4 4 | next-version: 7.0-SNAPSHOT -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .classpath 4 | .cache 5 | target 6 | *.iml 7 | .idea/ 8 | .checkstyle 9 | 10 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Any security vulnerability can be reported at the project [JIRA](https://issues.redhat.com/projects/WELD). 6 | When creating the issue, there is a special tick box to mark the issue as security sensitive so make sure to select it: 7 | - [x] `This issue is security relevant` 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 15 8 | target-branch: master 9 | - package-ecosystem: maven 10 | directory: "/" 11 | schedule: 12 | interval: monthly 13 | open-pull-requests-limit: 10 14 | target-branch: master 15 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Metadata.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.spi; 2 | 3 | /** 4 | * A piece of metadata, of type T 5 | * 6 | * @author Pete Muir 7 | * 8 | * @param the type of the metadata 9 | */ 10 | public interface Metadata { 11 | 12 | /** 13 | * The metadata value 14 | * 15 | * @return the metadata value 16 | */ 17 | T getValue(); 18 | 19 | /** 20 | * The location of the metadata, used in error and log messages 21 | * 22 | * @return location of the metadata, used in error and log messages 23 | */ 24 | String getLocation(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/DependentContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | import jakarta.enterprise.context.Dependent; 4 | import jakarta.enterprise.context.spi.AlterableContext; 5 | 6 | /** 7 | *

8 | * The built in dependent context, associated with {@link Dependent}. It is always active. 9 | *

10 | * 11 | *

12 | * Weld comes with one Dependent context which can be injected using: 13 | *

14 | * 15 | *
16 |  * @Inject
17 |  * DependentContext dependentContext;
18 |  * 
19 | * 20 | * @author Pete Muir 21 | * 22 | */ 23 | public interface DependentContext extends AlterableContext { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/invoke/WeldInvokerFactory.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.invoke; 2 | 3 | import jakarta.enterprise.inject.build.compatible.spi.BeanInfo; 4 | import jakarta.enterprise.inject.build.compatible.spi.InvokerFactory; 5 | import jakarta.enterprise.inject.build.compatible.spi.InvokerInfo; 6 | import jakarta.enterprise.lang.model.declarations.MethodInfo; 7 | 8 | /** 9 | * Weld specific version of {@link InvokerFactory}. 10 | * Allows access to {@link WeldInvokerBuilder} without the need to manually type cast. 11 | */ 12 | public interface WeldInvokerFactory extends InvokerFactory { 13 | 14 | @Override 15 | WeldInvokerBuilder createInvoker(BeanInfo bean, MethodInfo method); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/bootstrap/event/WeldProcessManagedBean.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.event; 2 | 3 | import jakarta.enterprise.inject.spi.AnnotatedMethod; 4 | import jakarta.enterprise.inject.spi.ProcessManagedBean; 5 | import jakarta.enterprise.invoke.Invoker; 6 | 7 | import org.jboss.weld.invoke.WeldInvokerBuilder; 8 | 9 | /** 10 | * Represents an enhanced version of {@link ProcessManagedBean}. 11 | * 12 | * Allows access to {@link WeldInvokerBuilder} without the need to manually type cast. 13 | */ 14 | public interface WeldProcessManagedBean extends ProcessManagedBean { 15 | 16 | @Override 17 | WeldInvokerBuilder> createInvoker(AnnotatedMethod method); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/ejb/EjbRequestContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.ejb; 2 | 3 | import jakarta.interceptor.InvocationContext; 4 | 5 | import org.jboss.weld.context.BoundContext; 6 | import org.jboss.weld.context.RequestContext; 7 | 8 | /** 9 | *

10 | * A request context which can be bound to the {@link InvocationContext}. The context is automatically attached to the map on 11 | * activation, and detached when {@link #invalidate()} is called. 12 | *

13 | * 14 | *

15 | * This context is not thread safe, and provides no thread safety for the underlying map. 16 | *

17 | * 18 | * 19 | * @author Pete Muir 20 | * 21 | */ 22 | public interface EjbRequestContext extends RequestContext, BoundContext { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/BoundRequestContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.bound; 2 | 3 | import java.util.Map; 4 | 5 | import org.jboss.weld.context.BoundContext; 6 | import org.jboss.weld.context.RequestContext; 7 | 8 | /** 9 | *

10 | * A request context which can be bound to any Map. The context is automatically attached to the map on activation, and detached 11 | * when {@link #invalidate()} is called. 12 | *

13 | * 14 | *

15 | * This context is not thread safe, and provides no thread safety for the underlying map. A thread-safe map can be used to back 16 | * the context. 17 | *

18 | * 19 | * 20 | * @author Pete Muir 21 | * 22 | */ 23 | public interface BoundRequestContext extends RequestContext, BoundContext> { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/BoundSessionContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.bound; 2 | 3 | import java.util.Map; 4 | 5 | import org.jboss.weld.context.BoundContext; 6 | import org.jboss.weld.context.SessionContext; 7 | 8 | /** 9 | *

10 | * A session context which can be bound to any Map. The context is automatically attached to the map on activation, and detached 11 | * when {@link #invalidate()} is called. 12 | *

13 | * 14 | *

15 | * This context is not thread safe, and provides no thread safety for the underlying map. A thread-safe map can be used to back 16 | * the context. 17 | *

18 | * 19 | * 20 | * @author Pete Muir 21 | * 22 | */ 23 | public interface BoundSessionContext extends SessionContext, BoundContext> { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/SystemPropertyActivation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.spi; 2 | 3 | /** 4 | *

5 | * {@link SystemPropertyActivation} is a data structures representing the <if-system-property> element in Weld's 6 | * extensions to beans.xml. See the XSD for Weld's extensions to beans.xml for details of the semantics of 7 | * <if-system-property>. 8 | *

9 | * 10 | * @author Pete Muir 11 | * @see Filter 12 | */ 13 | public interface SystemPropertyActivation { 14 | 15 | /** 16 | * The name attribute 17 | * 18 | * @return the name attribute 19 | */ 20 | String getName(); 21 | 22 | /** 23 | * The value attribute 24 | * 25 | * @return the name attribute 26 | */ 27 | String getValue(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/http/HttpRequestContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.http; 2 | 3 | import jakarta.servlet.ServletRequest; 4 | import jakarta.servlet.http.HttpServletRequest; 5 | 6 | import org.jboss.weld.context.BoundContext; 7 | import org.jboss.weld.context.RequestContext; 8 | 9 | /** 10 | *

11 | * A request context which can be bound to the {@link ServletRequest}. The context is automatically attached to the map on 12 | * activation, and detached when {@link #invalidate()} is called. 13 | *

14 | * 15 | *

16 | * This context is not thread safe, and provides no thread safety for the underlying map. 17 | *

18 | * 19 | * @author Pete Muir 20 | * 21 | */ 22 | public interface HttpRequestContext extends BoundContext, RequestContext { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/ejb/Ejb.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.ejb; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | import java.lang.annotation.Documented; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | import jakarta.inject.Qualifier; 14 | 15 | /** 16 | * Qualifier used with all for all of the EJB contexts Weld offers. 17 | * 18 | * @author Pete Muir 19 | * 20 | */ 21 | @Qualifier 22 | @Target({ TYPE, METHOD, PARAMETER, FIELD }) 23 | @Retention(RUNTIME) 24 | @Documented 25 | public @interface Ejb { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/http/Http.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.http; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | import java.lang.annotation.Documented; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | import jakarta.inject.Qualifier; 14 | 15 | /** 16 | * Qualifier used with all for all of the Servlet backed contexts Weld offers. 17 | * 18 | * @author Pete Muir 19 | * 20 | */ 21 | @Qualifier 22 | @Target({ TYPE, METHOD, PARAMETER, FIELD }) 23 | @Retention(RUNTIME) 24 | @Documented 25 | public @interface Http { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/Bound.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.bound; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | import java.lang.annotation.Documented; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | import jakarta.inject.Qualifier; 14 | 15 | /** 16 | * Qualifier used with all for all of the bound (map backed) contexts Weld offers. 17 | * 18 | * @author Pete Muir 19 | * 20 | */ 21 | @Qualifier 22 | @Target({ TYPE, METHOD, PARAMETER, FIELD }) 23 | @Retention(RUNTIME) 24 | @Documented 25 | public @interface Bound { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/unbound/Unbound.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.unbound; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | import java.lang.annotation.Documented; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | import jakarta.inject.Qualifier; 14 | 15 | /** 16 | * Qualifier used with all for all of the unbound contexts Weld offers. 17 | * 18 | * @author Pete Muir 19 | * 20 | */ 21 | @Qualifier 22 | @Target({ TYPE, METHOD, PARAMETER, FIELD }) 23 | @Retention(RUNTIME) 24 | @Documented 25 | public @interface Unbound { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/ClassAvailableActivation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.spi; 2 | 3 | /** 4 | *

5 | * {@link ClassAvailableActivation} is a data structures representing the <if-class-available> element in Weld's 6 | * extensions to beans.xml. See the XSD for Weld's extensions to beans.xml for details of the semantics of 7 | * <if-class-available>. 8 | *

9 | * 10 | * @author Pete Muir 11 | * @see Filter 12 | */ 13 | public interface ClassAvailableActivation { 14 | 15 | /** 16 | * The name attribute 17 | * 18 | * @return the name attribute 19 | */ 20 | String getClassName(); 21 | 22 | /** 23 | * Returns true if the filter is inverted (via {@code !}), false otherwise 24 | * 25 | * @return true if inverted, false otherwise 26 | */ 27 | boolean isInverted(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.enterprise.context.spi.AlterableContext; 5 | 6 | /** 7 | *

8 | * The built in application context, associated with {@link ApplicationScoped}. It is always active (not managed) and is backed 9 | * by an application scoped singleton. 10 | *

11 | * 12 | *

13 | * Weld comes with one Application context which can be injected using: 14 | *

15 | * 16 | *
17 |  * @Inject
18 |  * ApplicationContext applicationContext;
19 |  * 
20 | * 21 | * @author Pete Muir 22 | * @see SingletonContext 23 | * @see ApplicationScoped 24 | * 25 | */ 26 | public interface ApplicationContext extends AlterableContext { 27 | 28 | /** 29 | * Invalidate the context, causing all bean instances to be destroyed. 30 | */ 31 | void invalidate(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/SingletonContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | import jakarta.enterprise.context.ApplicationScoped; 4 | import jakarta.enterprise.context.spi.AlterableContext; 5 | import jakarta.inject.Singleton; 6 | 7 | /** 8 | *

9 | * The built in singleton context, associated with {@link Singleton}. It is always active (not managed) and is backed by an 10 | * application scoped singleton. 11 | *

12 | * 13 | *

14 | * Weld comes with one Singleton context which can be injected using: 15 | *

16 | * 17 | *
18 |  * @Inject
19 |  * SingletonContext singletonContext;
20 |  * 
21 | * 22 | * @author Pete Muir 23 | * @see SingletonContext 24 | * @see ApplicationScoped 25 | * 26 | */ 27 | public interface SingletonContext extends AlterableContext { 28 | 29 | /** 30 | * Invalidate the context, causing all bean instances to be destroyed. 31 | */ 32 | void invalidate(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/spi/helpers/AcceptingHttpContextActivationFilter.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.servlet.spi.helpers; 2 | 3 | import jakarta.servlet.http.HttpServletRequest; 4 | 5 | import org.jboss.weld.servlet.spi.HttpContextActivationFilter; 6 | 7 | /** 8 | * A helper implementation of {@link HttpContextActivationFilter} that accepts every request. 9 | * 10 | * @author Jozef Hartinger 11 | * 12 | */ 13 | public class AcceptingHttpContextActivationFilter implements HttpContextActivationFilter { 14 | 15 | /** 16 | * Instance of {@link AcceptingHttpContextActivationFilter} 17 | */ 18 | public static final AcceptingHttpContextActivationFilter INSTANCE = new AcceptingHttpContextActivationFilter(); 19 | 20 | private AcceptingHttpContextActivationFilter() { 21 | } 22 | 23 | @Override 24 | public void cleanup() { 25 | } 26 | 27 | @Override 28 | public boolean accepts(HttpServletRequest request) { 29 | return true; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/ci-actions.yml: -------------------------------------------------------------------------------- 1 | # Simple CI job that does `mvn clean install` on several JDKs 2 | name: Weld API CI 3 | 4 | on: 5 | pull_request: 6 | branches: [ master ] 7 | 8 | jobs: 9 | build: 10 | name: "Build Weld API - JDK ${{matrix.java.name}}" 11 | runs-on: ubuntu-latest 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | java: 16 | - { 17 | name: "17", 18 | java-version: 17, 19 | } 20 | - { 21 | name: "21", 22 | java-version: 21, 23 | } 24 | - { 25 | name: "25", 26 | java-version: 25, 27 | } 28 | steps: 29 | - uses: actions/checkout@v6 30 | - name: Set up JDK ${{ matrix.java.name }} 31 | uses: actions/setup-java@v5 32 | with: 33 | java-version: ${{ matrix.java.java-version }} 34 | distribution: 'temurin' 35 | - name: "Build with Maven" 36 | run: | 37 | mvn clean install -Dno-format 38 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/MutableBoundRequest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.bound; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * An implementation of {@link BoundRequest} backed by a pair of maps. 7 | * 8 | * @author Pete Muir 9 | * 10 | */ 11 | public class MutableBoundRequest implements BoundRequest { 12 | 13 | private final Map requestMap; 14 | private final Map sessionMap; 15 | 16 | /** 17 | * The parameters are a backing storage for current request and session respectively 18 | * 19 | * @param requestMap represents backing storage for current request 20 | * @param sessionMap represents backing storage for current session 21 | */ 22 | public MutableBoundRequest(Map requestMap, Map sessionMap) { 23 | this.requestMap = requestMap; 24 | this.sessionMap = sessionMap; 25 | } 26 | 27 | public Map getRequestMap() { 28 | return requestMap; 29 | } 30 | 31 | public Map getSessionMap(boolean create) { 32 | return sessionMap; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/spi/HttpContextActivationFilter.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.servlet.spi; 2 | 3 | import jakarta.servlet.http.HttpServletRequest; 4 | 5 | import org.jboss.weld.bootstrap.api.Service; 6 | 7 | /** 8 | * Enables an integrator to control if CDI contexts should be activated for a particular {@link HttpServletRequest}. An 9 | * integrator may be interested in filtering 10 | * out requests where CDI is not necessary to eliminate the overhead of context activation/deactivation. For example, an 11 | * integrator may want to use this filter 12 | * to filter out static resource requests from CDI processing. 13 | * 14 | * This service is optional. If not present, every request is accepted. 15 | * 16 | * @author Jozef Hartinger 17 | * 18 | */ 19 | public interface HttpContextActivationFilter extends Service { 20 | 21 | /** 22 | * Determines whether CDI contexts should be active during processing of this request 23 | * 24 | * @param request the request 25 | * @return true if CDI contexts should be active during processing of this request 26 | */ 27 | boolean accepts(HttpServletRequest request); 28 | } 29 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import org.jboss.weld.bootstrap.api.Service; 20 | 21 | /** 22 | * @author pmuir 23 | * 24 | */ 25 | public abstract class MockService implements Service { 26 | 27 | public void cleanup() { 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Filter.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.spi; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | *

7 | * {@link Filter} is a data structures representing the <exclude> elements beans.xml (Since CDI 1.1). See the XSD for 8 | * details of the semantics of <exclude>. 9 | *

10 | * 11 | * @see Beans 1.1 12 | * 13 | * @author Pete Muir 14 | * @see Scanning 15 | */ 16 | public interface Filter { 17 | 18 | /** 19 | * The name attribute 20 | * 21 | * @return the name attribute 22 | */ 23 | String getName(); 24 | 25 | /** 26 | * Nested <if-system-property> elements 27 | * 28 | * @return nested <if-system-property> elements 29 | */ 30 | Collection> getSystemPropertyActivations(); 31 | 32 | /** 33 | * Nested <if-class-available> elements 34 | * 35 | * @return nested <if-class-available> elements 36 | */ 37 | Collection> getClassAvailableActivations(); 38 | 39 | } -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/ManagedContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | /** 4 | *

5 | * Lifecycle management for built in contexts. {@link ManagedContext} only allows a context to be activated, deactivated and 6 | * destroyed. It does not allow the context to be associated with an underlying data store. These operations are defined on 7 | * {@link BoundContext}. 8 | *

9 | * 10 | *

11 | * Weld provides a number of managed contexts: {@link SessionContext}, {@link ConversationContext}, {@link RequestContext}. All 12 | * these managed contexts are scoped to the thread, and propagation of the backing store between threads is the responsibility 13 | * of the managed context user. 14 | *

15 | * 16 | * @author Pete Muir 17 | * @see BoundContext 18 | * 19 | */ 20 | public interface ManagedContext extends WeldAlterableContext { 21 | 22 | /** 23 | * Activate the Context. 24 | */ 25 | void activate(); 26 | 27 | /** 28 | * Deactivate the Context, destroying any instances if the context is invalid. 29 | */ 30 | void deactivate(); 31 | 32 | /** 33 | * Mark the context as due for destruction when deactivate is called. 34 | */ 35 | void invalidate(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockResourceReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import org.jboss.weld.injection.spi.ResourceReference; 20 | 21 | public class MockResourceReference implements ResourceReference { 22 | 23 | @Override 24 | public T getInstance() { 25 | return null; 26 | } 27 | 28 | @Override 29 | public void release() { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api; 18 | 19 | /** 20 | * Marks a Service which is used by Weld to interact with it's environment 21 | * 22 | * @author Pete Muir 23 | * 24 | */ 25 | public interface Service { 26 | 27 | /** 28 | * Called by Weld when it is shutting down, allowing the service to perform any cleanup needed. 29 | */ 30 | void cleanup(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockSecurityServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import java.security.Principal; 20 | 21 | import org.jboss.weld.security.spi.SecurityServices; 22 | 23 | /** 24 | * @author pmuir 25 | * 26 | */ 27 | public class MockSecurityServices extends MockService implements SecurityServices { 28 | 29 | public Principal getPrincipal() { 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockResourceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import org.jboss.weld.injection.spi.ResourceReference; 20 | import org.jboss.weld.injection.spi.ResourceReferenceFactory; 21 | 22 | public class MockResourceFactory implements ResourceReferenceFactory { 23 | 24 | @Override 25 | public ResourceReference createResource() { 26 | return new MockResourceReference(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/AbstractBootstrapService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.helpers; 18 | 19 | import org.jboss.weld.bootstrap.api.BootstrapService; 20 | 21 | /** 22 | * Defines {@link #cleanup()} implementation as a simple delegation to {@link #cleanupAfterBoot()} 23 | */ 24 | public abstract class AbstractBootstrapService implements BootstrapService { 25 | 26 | @Override 27 | public void cleanup() { 28 | cleanupAfterBoot(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/ejb/spi/BusinessInterfaceDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.ejb.spi; 19 | 20 | /** 21 | * Represents the business interface of an EJB 22 | * 23 | * @author Pete Muir 24 | * 25 | * @param the type of the business interface 26 | */ 27 | public interface BusinessInterfaceDescriptor { 28 | 29 | /** 30 | * Gets the business interface class 31 | * 32 | * @return the business interface class 33 | */ 34 | Class getInterface(); 35 | 36 | } -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/proxy/WeldConstruct.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.proxy; 18 | 19 | /** 20 | * Marker interface denoting that the instance is an internal Weld contruct. This ranges from intercepted/decorated subclass to 21 | * client proxy. This ranges from contextual instances of intercepted/decorated beans to contextual references for normal scoped 22 | * beans (client proxies). 23 | * 24 | * @author Matej Novotny 25 | */ 26 | public interface WeldConstruct { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/ejb/EjbLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2008, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context.ejb; 18 | 19 | import jakarta.enterprise.util.AnnotationLiteral; 20 | 21 | /** 22 | * Annotation literal for {@link Ejb} 23 | * 24 | * @author Pete Muir 25 | */ 26 | public class EjbLiteral extends AnnotationLiteral implements Ejb { 27 | 28 | /** 29 | * An instance of {@link Ejb} annotation literal 30 | */ 31 | public static final Ejb INSTANCE = new EjbLiteral(); 32 | 33 | private EjbLiteral() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Scanning.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.spi; 2 | 3 | import static java.util.Collections.emptyList; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | *

9 | * Scanning is a data structures representing the <scan> element in Weld's extensions to beans.xml. See the XSD for Weld's 10 | * extensions to beans.xml for details of the semantics of <scan>. {@link Scanning} contains an include {@link Filter} 11 | * list and an exclude {@link Filter} list. 12 | *

13 | * 14 | * @author Pete Muir 15 | * 16 | */ 17 | public interface Scanning { 18 | 19 | /** 20 | * A {@link Scanning} instance with no include or exclude filters 21 | */ 22 | Scanning EMPTY_SCANNING = new Scanning() { 23 | 24 | public Collection> getIncludes() { 25 | return emptyList(); 26 | } 27 | 28 | public Collection> getExcludes() { 29 | return emptyList(); 30 | } 31 | }; 32 | 33 | /** 34 | * The <include> element 35 | * 36 | * @return the include element 37 | */ 38 | Collection> getIncludes(); 39 | 40 | /** 41 | * The <exclude> element 42 | * 43 | * @return the exclude element 44 | */ 45 | Collection> getExcludes(); 46 | 47 | } -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/http/HttpLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2008, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context.http; 18 | 19 | import jakarta.enterprise.util.AnnotationLiteral; 20 | 21 | /** 22 | * Annotation literal for {@link Http} 23 | * 24 | * @author Pete Muir 25 | */ 26 | public class HttpLiteral extends AnnotationLiteral implements Http { 27 | 28 | /** 29 | * An instance of {@link Http} annotation literal 30 | */ 31 | public static final Http INSTANCE = new HttpLiteral(); 32 | 33 | private HttpLiteral() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/SessionContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | import java.util.Map; 4 | 5 | import jakarta.enterprise.context.SessionScoped; 6 | import jakarta.servlet.http.HttpSession; 7 | 8 | import org.jboss.weld.context.bound.BoundSessionContext; 9 | import org.jboss.weld.context.http.HttpSessionContext; 10 | 11 | /** 12 | *

13 | * The built in session context is associated with {@link SessionScoped}. It can be activated, invalidated and deactivated. 14 | *

15 | * 16 | *

17 | * Weld comes with two implementation of the session context. The {@link HttpSessionContext}, in which conversations are bound 18 | * to the {@link HttpSession}, can be injected: 19 | *

20 | * 21 | *
22 |  * @Inject
23 |  * @Http
24 |  * SessionContext sessionContext;
25 |  * 
26 | * 27 | *

28 | * Alternatively the {@link BoundSessionContext} in which conversations are bound a {@link Map} can be injected: 29 | *

30 | * 31 | *
32 |  * @Inject
33 |  * @Bound
34 |  * SessionContext sessionContext;
35 |  * 
36 | * 37 | * @author Pete Muir 38 | * @see org.jboss.weld.context.bound.BoundSessionContext 39 | * @see jakarta.servlet.http.HttpSession 40 | * @see jakarta.enterprise.context.SessionScoped 41 | * 42 | */ 43 | public interface SessionContext extends ManagedContext { 44 | 45 | } 46 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/BoundLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2008, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context.bound; 18 | 19 | import jakarta.enterprise.util.AnnotationLiteral; 20 | 21 | /** 22 | * Annotation literal for {@link Bound} 23 | * 24 | * @author Pete Muir 25 | */ 26 | public class BoundLiteral extends AnnotationLiteral implements Bound { 27 | 28 | /** 29 | * An instance of {@link Bound} annotation literal 30 | */ 31 | public static final Bound INSTANCE = new BoundLiteral(); 32 | 33 | private BoundLiteral() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/api/ServletListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.servlet.api; 18 | 19 | import jakarta.servlet.ServletContextListener; 20 | import jakarta.servlet.ServletRequestListener; 21 | import jakarta.servlet.http.HttpSessionListener; 22 | 23 | /** 24 | * Combines access to {@link ServletContextListener}, {@link ServletRequestListener} and {@link HttpSessionListener} into a 25 | * single interface. 26 | */ 27 | public interface ServletListener extends ServletContextListener, ServletRequestListener, HttpSessionListener { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/BoundRequest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.bound; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | *

7 | * A conversation is used to span multiple requests, however is shorter than a session. The {@link BoundConversationContext} 8 | * uses one Map to represent a request, and a second to represent the session, which are encapsulated in a {@link BoundRequest}. 9 | *

10 | * 11 | * @author Pete Muir 12 | * 13 | */ 14 | public interface BoundRequest { 15 | 16 | /** 17 | * Get the current request map. 18 | * 19 | * @return the request map. 20 | */ 21 | Map getRequestMap(); 22 | 23 | /** 24 | *

25 | * Get the current session map. 26 | *

27 | * 28 | *

29 | * A {@link BoundRequest} may be backed by a data store that only creates sessions on demand. It is recommended that if the 30 | * session is not created on demand, or that the session has already been created (but is not required by this access) that 31 | * the session is returned as it allows the conversation context to work more efficiently. 32 | *

33 | * 34 | * @param create if true, then a session must be created 35 | * @return the session map; null may be returned if create is false 36 | */ 37 | Map getSessionMap(boolean create); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/BootstrapService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api; 18 | 19 | /** 20 | * Marks a {@link Service} that needs to clean up its state once bootstrap is finished. 21 | * 22 | * @author Jozef Hartinger 23 | * 24 | */ 25 | public interface BootstrapService extends Service { 26 | 27 | /** 28 | * Called by Weld once it finishes initialization and before it starts serving requests. This method is not guaranteed to be 29 | * called by Weld if the deployment fails with an error. 30 | */ 31 | void cleanupAfterBoot(); 32 | } 33 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/ResourceReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi; 18 | 19 | /** 20 | * Holds a reference to a resource instance. 21 | * 22 | * @author Jozef Hartinger 23 | * @author Stuart Douglas 24 | * 25 | * @param the type of the resource 26 | */ 27 | public interface ResourceReference { 28 | 29 | /** 30 | * Get the instance of the resource 31 | * 32 | * @return instance 33 | */ 34 | T getInstance(); 35 | 36 | /** 37 | * Release the resource instance 38 | */ 39 | void release(); 40 | } 41 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/bound/BoundConversationContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.bound; 2 | 3 | import java.util.Map; 4 | 5 | import org.jboss.weld.context.BoundContext; 6 | import org.jboss.weld.context.ConversationContext; 7 | 8 | /** 9 | *

10 | * A conversation context which can be bound to a pair of Maps encapsulated by {@link BoundRequest}. The context is 11 | * automatically attached to the bound request on activation, and detached when {@link #invalidate()} is called. 12 | *

13 | * 14 | *

15 | * The {@link BoundConversationContext} is detachable, and transient conversations are only attached at the end of a request. 16 | *

17 | * 18 | *

19 | * This context is not thread safe, and provides no thread safety for the underlying map. A thread-safe map can be used to back 20 | * the context - in this case the map can be used as an underlying store in multiple threads safely. 21 | *

22 | * 23 | * 24 | * @author Pete Muir 25 | * 26 | */ 27 | public interface BoundConversationContext extends ConversationContext, BoundContext { 28 | 29 | /** 30 | * Destroy all conversations in the session. 31 | * 32 | * @param session the session for which to destroy all conversations 33 | * @return true if all conversations in the session have been destroyed 34 | */ 35 | boolean destroy(Map session); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/ResourceReferenceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi; 18 | 19 | /** 20 | * Identifies a container resource and allows a resource instance to be created for injection. 21 | * 22 | * @author Jozef Hartinger 23 | * @author Stuart Douglas 24 | * 25 | * @param the type of the resource 26 | */ 27 | public interface ResourceReferenceFactory { 28 | 29 | /** 30 | * Creates a resource reference for resource {@code T} 31 | * 32 | * @return resource reference instance 33 | */ 34 | ResourceReference createResource(); 35 | } 36 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import java.net.URL; 20 | import java.util.Collection; 21 | 22 | import org.jboss.weld.resources.spi.ResourceLoader; 23 | 24 | public class MockResourceLoader extends MockService implements ResourceLoader { 25 | 26 | public Class classForName(String name) { 27 | return null; 28 | } 29 | 30 | public URL getResource(String name) { 31 | return null; 32 | } 33 | 34 | public Collection getResources(String name) { 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/unbound/UnboundLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2008, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context.unbound; 18 | 19 | import jakarta.enterprise.util.AnnotationLiteral; 20 | 21 | import org.jboss.weld.context.bound.Bound; 22 | 23 | /** 24 | * Annotation literal for {@link Bound} 25 | * 26 | * @author Pete Muir 27 | */ 28 | public class UnboundLiteral extends AnnotationLiteral implements Unbound { 29 | 30 | /** 31 | * An instance of {@link Unbound} annotation literal 32 | */ 33 | public static final Unbound INSTANCE = new UnboundLiteral(); 34 | 35 | private UnboundLiteral() { 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextual.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.serialization.spi.helpers; 19 | 20 | import java.io.Serializable; 21 | 22 | import jakarta.enterprise.context.spi.Contextual; 23 | 24 | /** 25 | * A serializable version of contextual that knows how to restore the original bean if necessary. 26 | * 27 | * @author Pete Muir 28 | * @author Marius Bogoevici 29 | */ 30 | public interface SerializableContextual, I> extends Serializable, Contextual { 31 | /** 32 | * 33 | * @return original bean 34 | */ 35 | C get(); 36 | } 37 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockEjbInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | 21 | import org.jboss.weld.injection.spi.EjbInjectionServices; 22 | import org.jboss.weld.injection.spi.ResourceReferenceFactory; 23 | 24 | /** 25 | * @author pmuir 26 | * 27 | */ 28 | public class MockEjbInjectionServices extends MockService implements EjbInjectionServices { 29 | 30 | public ResourceReferenceFactory registerEjbInjectionPoint(InjectionPoint injectionPoint) { 31 | return new MockResourceFactory(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /dco.txt: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this 7 | license document, but changing it is not allowed. 8 | 9 | 10 | Developer's Certificate of Origin 1.1 11 | 12 | By making a contribution to this project, I certify that: 13 | 14 | (a) The contribution was created in whole or in part by me and I 15 | have the right to submit it under the open source license 16 | indicated in the file; or 17 | 18 | (b) The contribution is based upon previous work that, to the best 19 | of my knowledge, is covered under an appropriate open source 20 | license and I have the right under that license to submit that 21 | work with modifications, whether created in whole or in part 22 | by me, under the same open source license (unless I am 23 | permitted to submit under a different license), as indicated 24 | in the file; or 25 | 26 | (c) The contribution was provided directly to me by some other 27 | person who certified (a), (b) or (c) and I have not modified 28 | it. 29 | 30 | (d) I understand and agree that this project and the contribution 31 | are public and that a record of the contribution (including all 32 | personal information I submit with it, including my sign-off) is 33 | maintained indefinitely and may be redistributed consistent with 34 | this project or the open source license(s) involved. 35 | 36 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockTransactionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import jakarta.transaction.Synchronization; 20 | import jakarta.transaction.UserTransaction; 21 | 22 | import org.jboss.weld.transaction.spi.TransactionServices; 23 | 24 | public class MockTransactionServices extends MockService implements TransactionServices { 25 | 26 | public boolean isTransactionActive() { 27 | return false; 28 | } 29 | 30 | public void registerSynchronization(Synchronization synchronizedObserver) { 31 | } 32 | 33 | public UserTransaction getUserTransaction() { 34 | return null; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/WeldFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi; 18 | 19 | /** 20 | * 21 | *

22 | * {@link Filter} is a data structures representing the <include> and <exclude> elements in Weld's extensions to 23 | * beans.xml. See the XSD for Weld's extensions to beans.xml for details of the semantics of <include> and 24 | * <exclude>. 25 | *

26 | * 27 | * @author Pete Muir 28 | * @author Jozef Hartinger 29 | * 30 | */ 31 | public interface WeldFilter extends Filter { 32 | 33 | /** 34 | * The pattern attribute 35 | * 36 | * @return the pattern attribute 37 | */ 38 | String getPattern(); 39 | } 40 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/RegistrySingletonProvider.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.bootstrap.api.helpers; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | import org.jboss.weld.bootstrap.api.Singleton; 7 | import org.jboss.weld.bootstrap.api.SingletonProvider; 8 | 9 | /** 10 | * 11 | * @author mathieuancelin 12 | */ 13 | public class RegistrySingletonProvider extends SingletonProvider { 14 | /** 15 | * Static instance constant 16 | */ 17 | public static final String STATIC_INSTANCE = "STATIC_INSTANCE"; 18 | 19 | @Override 20 | public Singleton create(Class type) { 21 | return new RegistrySingleton(); 22 | } 23 | 24 | private static class RegistrySingleton implements Singleton { 25 | 26 | private final Map store = new ConcurrentHashMap(); 27 | 28 | public T get(String id) { 29 | T instance = store.get(id); 30 | if (instance == null) { 31 | throw new IllegalStateException("Singleton not set for " + id + " => " + store.keySet()); 32 | } 33 | return instance; 34 | } 35 | 36 | public void set(String id, T object) { 37 | store.put(id, object); 38 | } 39 | 40 | public void clear(String id) { 41 | store.remove(id); 42 | } 43 | 44 | public boolean isSet(String id) { 45 | return store.containsKey(id); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/spi/helpers/RegexHttpContextActivationFilter.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.servlet.spi.helpers; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | import jakarta.servlet.http.HttpServletRequest; 6 | 7 | import org.jboss.weld.servlet.spi.HttpContextActivationFilter; 8 | 9 | /** 10 | * A helper implementation of {@link HttpContextActivationFilter} that accepts every request that matches a predefined regular 11 | * expression. 12 | * 13 | * @author Jozef Hartinger 14 | * 15 | */ 16 | public class RegexHttpContextActivationFilter implements HttpContextActivationFilter { 17 | 18 | private final Pattern pattern; 19 | 20 | /** 21 | * Constructs an instance using provided {@link Pattern} 22 | * 23 | * @param pattern regex pattern 24 | */ 25 | public RegexHttpContextActivationFilter(Pattern pattern) { 26 | this.pattern = pattern; 27 | } 28 | 29 | /** 30 | * Constructs an instance using provided String 31 | * 32 | * @param regex string representation which will be compiled to {@link Pattern} 33 | */ 34 | public RegexHttpContextActivationFilter(String regex) { 35 | this.pattern = Pattern.compile(regex); 36 | } 37 | 38 | @Override 39 | public boolean accepts(HttpServletRequest request) { 40 | final String path = request.getRequestURI().substring(request.getContextPath().length()); 41 | return pattern.matcher(path).matches(); 42 | } 43 | 44 | @Override 45 | public void cleanup() { 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/manager/api/WeldInjectionTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.manager.api; 18 | 19 | import jakarta.enterprise.inject.spi.AnnotatedType; 20 | import jakarta.enterprise.inject.spi.InjectionTarget; 21 | 22 | /** 23 | * Specialized version of {@link InjectionTarget} that exposes additional information. 24 | * 25 | * @author Jozef Hartinger 26 | * 27 | * @param the type of the instance 28 | */ 29 | public interface WeldInjectionTarget extends InjectionTarget { 30 | 31 | /** 32 | * Returns the {@link AnnotatedType} for this injection target 33 | * 34 | * @return annotated type for this injection target 35 | */ 36 | AnnotatedType getAnnotatedType(); 37 | } 38 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextualInstance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.serialization.spi.helpers; 18 | 19 | import java.io.Serializable; 20 | 21 | import jakarta.enterprise.context.spi.Contextual; 22 | import jakarta.enterprise.context.spi.CreationalContext; 23 | 24 | import org.jboss.weld.context.api.ContextualInstance; 25 | 26 | /** 27 | * A Serializable wrapper for a {@link ContextualInstance} 28 | * 29 | * @author Pete Muir 30 | * @author Marius Bogoevici 31 | */ 32 | public interface SerializableContextualInstance, I> extends ContextualInstance, Serializable { 33 | SerializableContextual getContextual(); 34 | 35 | I getInstance(); 36 | 37 | CreationalContext getCreationalContext(); 38 | } 39 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeanDiscoveryMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi; 18 | 19 | /** 20 | * Represents the value of the bean-discovery-mode attribute within beans.xml. If a 21 | * beans.xml file does not contain the bean-discovery-mode attribute, the value defaults to 22 | * {@link BeanDiscoveryMode#ALL}. 23 | * 24 | * @author Jozef Hartinger 25 | * 26 | */ 27 | public enum BeanDiscoveryMode { 28 | 29 | /** 30 | * This archive will be ignored. 31 | */ 32 | NONE, 33 | 34 | /** 35 | * Only those types with bean defining annotations will be considered. 36 | */ 37 | ANNOTATED, 38 | 39 | /** 40 | * All types in the archive will be considered. 41 | */ 42 | ALL, 43 | } 44 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockResourceServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | 21 | import org.jboss.weld.injection.spi.ResourceInjectionServices; 22 | import org.jboss.weld.injection.spi.ResourceReferenceFactory; 23 | 24 | public class MockResourceServices extends MockService implements ResourceInjectionServices { 25 | 26 | @Override 27 | public ResourceReferenceFactory registerResourceInjectionPoint(InjectionPoint injectionPoint) { 28 | return new MockResourceFactory(); 29 | } 30 | 31 | @Override 32 | public ResourceReferenceFactory registerResourceInjectionPoint(String jndiName, String mappedName) { 33 | return new MockResourceFactory(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/ManagedConversation.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | import jakarta.enterprise.context.ContextNotActiveException; 4 | import jakarta.enterprise.context.Conversation; 5 | 6 | /** 7 | *

8 | * Provides management operations for conversations, including locking, and expiration management. 9 | *

10 | * 11 | * @author Pete Muir 12 | * @see ConversationContext 13 | * 14 | */ 15 | public interface ManagedConversation extends Conversation { 16 | 17 | /** 18 | * Attempts to unlock the conversation 19 | * 20 | * @throws ContextNotActiveException if the conversation context is not active 21 | * @return true if the unlock was successful, false otherwise 22 | */ 23 | boolean unlock(); 24 | 25 | /** 26 | * Attempts to lock the conversation for exclusive usage 27 | * 28 | * @param timeout The time in milliseconds to wait on the lock 29 | * @return True if lock was successful, false otherwise 30 | * @throws ContextNotActiveException if the conversation context is not active 31 | */ 32 | boolean lock(long timeout); 33 | 34 | /** 35 | * Gets the last time the conversation was used (for data access) 36 | * 37 | * @return time (in ms) since the conversation was last used 38 | * @throws ContextNotActiveException if the conversation context is not active 39 | */ 40 | long getLastUsed(); 41 | 42 | /** 43 | * Touches the managed conversation, updating the "last used" timestamp 44 | * 45 | * @throws ContextNotActiveException if the conversation context is not active 46 | */ 47 | void touch(); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /weld/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | weld-api-parent 4 | org.jboss.weld 5 | 7.0-SNAPSHOT 6 | ../pom.xml 7 | 8 | 4.0.0 9 | weld-api 10 | Weld APIs 11 | Weld specifc extensions to the CDI API 12 | http://weld.cdi-spec.org 13 | 14 | 15 | Apache License, Version 2.0 16 | repo 17 | http://www.apache.org/licenses/LICENSE-2.0.html 18 | 19 | 20 | 21 | 22 | 23 | 24 | jakarta.cdi 25 | jakarta.cdi-api 26 | 27 | 28 | 29 | jakarta.cdi 30 | jakarta.cdi-el-api 31 | 32 | 33 | 34 | jakarta.servlet 35 | jakarta.servlet-api 36 | true 37 | 38 | 39 | 40 | jakarta.interceptor 41 | jakarta.interceptor-api 42 | true 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/TypeDiscoveryConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link TypeDiscoveryConfiguration} is used by an integrator to determine which classes to discover during the type discovery 24 | * phase. 25 | * 26 | * @author Jozef Hartinger 27 | * 28 | */ 29 | public interface TypeDiscoveryConfiguration { 30 | 31 | /** 32 | * Returns a set of bean defining annotations. This set is used in combination with bean defining annotations discovered by 33 | * the integrator for discovering beans. See {@link CDI11Bootstrap#startExtensions(Iterable)} for details. 34 | * 35 | * @return the set of bean defining annotations 36 | */ 37 | Set> getKnownBeanDefiningAnnotations(); 38 | } 39 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/servlet/spi/test/HttpContextActivationFilterTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.servlet.spi.test; 2 | 3 | import org.jboss.weld.servlet.spi.HttpContextActivationFilter; 4 | import org.jboss.weld.servlet.spi.helpers.RegexHttpContextActivationFilter; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | public class HttpContextActivationFilterTest { 9 | 10 | @Test 11 | public void test1() { 12 | HttpContextActivationFilter filter = new RegexHttpContextActivationFilter("/foo.*"); 13 | Assert.assertTrue(filter.accepts(new MockHttpServletRequest("/app/foo", "/app"))); 14 | Assert.assertTrue(filter.accepts(new MockHttpServletRequest("/app/foo/bar", "/app"))); 15 | Assert.assertTrue(filter.accepts(new MockHttpServletRequest("/app/foofoo", "/app"))); 16 | Assert.assertFalse(filter.accepts(new MockHttpServletRequest("/app/bar", "/app"))); 17 | Assert.assertFalse(filter.accepts(new MockHttpServletRequest("/app/bar/foo", "/app"))); 18 | } 19 | 20 | @Test 21 | public void test2() { 22 | HttpContextActivationFilter filter = new RegexHttpContextActivationFilter("/.*\\.jsf"); 23 | Assert.assertTrue(filter.accepts(new MockHttpServletRequest("/app/foo.jsf", "/app"))); 24 | Assert.assertTrue(filter.accepts(new MockHttpServletRequest("/app/bar.jsf", "/app"))); 25 | Assert.assertTrue(filter.accepts(new MockHttpServletRequest("/app/foo/bar/baz.jsf", "/app"))); 26 | Assert.assertFalse(filter.accepts(new MockHttpServletRequest("/app/foo.jpg", "/app"))); 27 | Assert.assertFalse(filter.accepts(new MockHttpServletRequest("/app/foo/bar/baz.css", "/app"))); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/ejb/spi/SubclassedComponentDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.ejb.spi; 18 | 19 | /** 20 | * An implementation of {@link EjbDescriptor} may optionally implement this interface if the EJB container uses 21 | * subclassing to implement EJB functionality. Weld will use the class returned from {@link #getComponentSubclass()} 22 | * when instantiating a new EJB instance. 23 | * 24 | * @author Jozef Hartinger 25 | * 26 | * @param the component type 27 | */ 28 | public interface SubclassedComponentDescriptor { 29 | 30 | /** 31 | * Returns the enhanced subclass of the component type. Weld will use this subclass to create EJB instances instead 32 | * of creating instances of the component class. 33 | * 34 | * @return the enhanced subclass of the component type 35 | */ 36 | Class getComponentSubclass(); 37 | } 38 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockJpaServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | import jakarta.persistence.EntityManager; 21 | import jakarta.persistence.EntityManagerFactory; 22 | 23 | import org.jboss.weld.injection.spi.JpaInjectionServices; 24 | import org.jboss.weld.injection.spi.ResourceReferenceFactory; 25 | 26 | public class MockJpaServices extends MockService implements JpaInjectionServices { 27 | 28 | @Override 29 | public ResourceReferenceFactory registerPersistenceContextInjectionPoint(InjectionPoint injectionPoint) { 30 | return new MockResourceFactory(); 31 | } 32 | 33 | @Override 34 | public ResourceReferenceFactory registerPersistenceUnitInjectionPoint(InjectionPoint injectionPoint) { 35 | return new MockResourceFactory(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/configuration/spi/ExternalConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.configuration.spi; 18 | 19 | import java.util.Map; 20 | 21 | import org.jboss.weld.bootstrap.api.Service; 22 | 23 | /** 24 | * An integrator may provide a map of configuration properties. This map is considered the source with the lowest priority (i.e. 25 | * it may be overriden by other 26 | * sources such as system properties). The supported keys are declared in the documentation. Entries with unsupported keys are 27 | * ignored. Invalid property value 28 | * is a deployment problem - initialization will be aborted by the container. 29 | * 30 | * @see WELD-1791 31 | * @author Martin Kouba 32 | */ 33 | public interface ExternalConfiguration extends Service { 34 | 35 | /** 36 | * @return the map of configuration properties 37 | */ 38 | Map getConfigurationProperties(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/construction/api/ConstructionHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.construction.api; 18 | 19 | import java.util.Map; 20 | 21 | /** 22 | * A handle for controlling {@link AroundConstructCallback} invocations. 23 | * 24 | * @author Jozef Hartinger 25 | * 26 | * @see AroundConstructCallback 27 | * 28 | * @param type the component class 29 | */ 30 | public interface ConstructionHandle { 31 | 32 | /** 33 | * Proceed to the next {@link AroundConstructCallback}. If there is no next callback, the component is constructed and the 34 | * component instance is returned 35 | * from the method. 36 | * 37 | * @param parameters the parameters to be passed to the component constructor 38 | * @param data the context data associated with the {@link AroundConstructCallback} interception 39 | * @return instance the constructed instance 40 | */ 41 | T proceed(Object[] parameters, Map data); 42 | } 43 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/api/helpers/AbstractServletListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.servlet.api.helpers; 18 | 19 | import jakarta.servlet.ServletContextEvent; 20 | import jakarta.servlet.ServletRequestEvent; 21 | import jakarta.servlet.http.HttpSessionEvent; 22 | 23 | import org.jboss.weld.servlet.api.ServletListener; 24 | 25 | /** 26 | * No-op implementation of ServletListener 27 | * 28 | * @author Pete Muir 29 | * 30 | */ 31 | public class AbstractServletListener implements ServletListener { 32 | 33 | public void contextDestroyed(ServletContextEvent sce) { 34 | } 35 | 36 | public void contextInitialized(ServletContextEvent sce) { 37 | } 38 | 39 | public void requestDestroyed(ServletRequestEvent sre) { 40 | } 41 | 42 | public void requestInitialized(ServletRequestEvent sre) { 43 | } 44 | 45 | public void sessionCreated(HttpSessionEvent se) { 46 | } 47 | 48 | public void sessionDestroyed(HttpSessionEvent se) { 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/serialization/spi/BeanIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.serialization.spi; 18 | 19 | import java.io.Serializable; 20 | 21 | import jakarta.enterprise.inject.spi.PassivationCapable; 22 | 23 | /** 24 | * Represents a bean identifier - implementations may differ for producers, class based and so on. 25 | * However, they all support {@link #asString()} to converts these identifiers into {@code String} 26 | */ 27 | public interface BeanIdentifier extends Serializable { 28 | 29 | /** 30 | * Predefined bean ID separator symbol 31 | */ 32 | String BEAN_ID_SEPARATOR = "%"; 33 | 34 | /** 35 | * String representation of this identifier. This is required as some parts of the CDI API use String identifiers, for 36 | * example 37 | * {@link PassivationCapable#getId()}. Unlike {@link Object#toString()}, this method returns a non-verbose canonical string 38 | * identifier. 39 | * 40 | * @return string representation of this identifier 41 | */ 42 | String asString(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/helpers/EEModuleDescriptorImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2015, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi.helpers; 18 | 19 | import org.jboss.weld.bootstrap.spi.EEModuleDescriptor; 20 | 21 | /** 22 | * A convenience impl class for {@link EEModuleDescriptor} 23 | */ 24 | public class EEModuleDescriptorImpl implements EEModuleDescriptor { 25 | 26 | private final String id; 27 | private final EEModuleDescriptor.ModuleType moduleType; 28 | 29 | /** 30 | * Creates new instance of this class 31 | * 32 | * @param id identifier 33 | * @param moduleType type of the module (EAR, WAR, ...) 34 | */ 35 | public EEModuleDescriptorImpl(String id, EEModuleDescriptor.ModuleType moduleType) { 36 | this.id = id; 37 | this.moduleType = moduleType; 38 | } 39 | 40 | @Override 41 | public String getId() { 42 | return id; 43 | } 44 | 45 | @Override 46 | public ModuleType getType() { 47 | return moduleType; 48 | } 49 | 50 | @Override 51 | public void cleanup() { 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/MockEjbServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.test; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | 21 | import org.jboss.weld.ejb.api.SessionObjectReference; 22 | import org.jboss.weld.ejb.spi.EjbDescriptor; 23 | import org.jboss.weld.ejb.spi.EjbServices; 24 | import org.jboss.weld.ejb.spi.InterceptorBindings; 25 | 26 | public class MockEjbServices extends MockService implements EjbServices { 27 | 28 | public Iterable> discoverEjbs() { 29 | return null; 30 | } 31 | 32 | public SessionObjectReference resolveEjb(EjbDescriptor ejbDescriptor) { 33 | return null; 34 | } 35 | 36 | public void registerInterceptors(EjbDescriptor ejbDescriptor, InterceptorBindings interceptorBindings) { 37 | // do nothing 38 | } 39 | 40 | public Object resolveEjb(InjectionPoint injectionPoint) { 41 | return null; 42 | } 43 | 44 | public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink) { 45 | return null; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/api/ContextualInstance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context.api; 18 | 19 | import jakarta.enterprise.context.spi.Contextual; 20 | import jakarta.enterprise.context.spi.CreationalContext; 21 | 22 | /** 23 | * Represents a contextual instance of a given type. This is an abstraction on top of the actual bean instance stored in each 24 | * context. It glues together the actual instance with its {@link CreationalContext} and {@link Contextual} 25 | * 26 | * @author Matej Novotny 27 | */ 28 | public interface ContextualInstance { 29 | 30 | /** 31 | * Returns the actual bean instance 32 | * 33 | * @return bean instance 34 | */ 35 | T getInstance(); 36 | 37 | /** 38 | * Returns the {@link CreationalContext} for this contextual instance 39 | * 40 | * @return creational context 41 | */ 42 | CreationalContext getCreationalContext(); 43 | 44 | /** 45 | * Returns the {@link Contextual} for this contextual instance 46 | * 47 | * @return contextual object 48 | */ 49 | Contextual getContextual(); 50 | } 51 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/RequestContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | import java.util.Map; 4 | 5 | import jakarta.enterprise.context.RequestScoped; 6 | import jakarta.interceptor.InvocationContext; 7 | import jakarta.servlet.ServletRequest; 8 | 9 | import org.jboss.weld.context.bound.BoundRequestContext; 10 | import org.jboss.weld.context.ejb.EjbRequestContext; 11 | import org.jboss.weld.context.http.HttpRequestContext; 12 | 13 | /** 14 | *

15 | * The built in request context is associated with {@link RequestScoped} and is a managed context which can be activated, 16 | * invalidated and deactivated. 17 | *

18 | * 19 | *

20 | * Weld comes with four implementation of the request context. The {@link HttpRequestContext}, in which conversations are bound 21 | * to the {@link ServletRequest}, can be injected: 22 | *

23 | * 24 | *
25 |  * @Inject
26 |  * @Http
27 |  * RequestContext requestContext;
28 |  * 
29 | * 30 | *

31 | * Alternatively the {@link BoundRequestContext} in which requests are bound a {@link Map} can be injected: 32 | *

33 | * 34 | *
35 |  * @Inject
36 |  * @Bound
37 |  * RequestContext requestContext;
38 |  * 
39 | * 40 | *

41 | * Additionally, Weld provides an unbound request context (which is automatially bound to the thread) which can be injected: 42 | *

43 | * 44 | *
45 |  * @Inject
46 |  * @Unbound
47 |  * RequestContext requestContext;
48 |  * 
49 | * 50 | *

51 | * Finally, Weld provides a request context which is bound to an {@link InvocationContext} and can be injected: 52 | *

53 | * 54 | * 55 | *
56 |  * @Inject
57 |  * @Ejb
58 |  * RequestContext requestContext;
59 |  * 
60 | * 61 | * @author Pete Muir 62 | * @see BoundRequestContext 63 | * @see HttpRequestContext 64 | * @see EjbRequestContext 65 | * @see RequestScoped 66 | * 67 | */ 68 | public interface RequestContext extends ManagedContext { 69 | 70 | } 71 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/resources/spi/ResourceLoadingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.resources.spi; 18 | 19 | /** 20 | * Exception thrown when errors occur while loading resource 21 | * 22 | * @author Pete Muir 23 | * 24 | */ 25 | public class ResourceLoadingException extends RuntimeException { 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructor 30 | */ 31 | public ResourceLoadingException() { 32 | super(); 33 | } 34 | 35 | /** 36 | * Constructor 37 | * 38 | * @param message The message 39 | * @param throwable The exception 40 | */ 41 | public ResourceLoadingException(String message, Throwable throwable) { 42 | super(message, throwable); 43 | } 44 | 45 | /** 46 | * Constructor 47 | * 48 | * @param message The message 49 | */ 50 | public ResourceLoadingException(String message) { 51 | super(message); 52 | } 53 | 54 | /** 55 | * Constructor 56 | * 57 | * @param throwable The exception 58 | */ 59 | public ResourceLoadingException(Throwable throwable) { 60 | super(throwable); 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/SimpleResourceReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2012, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi.helpers; 18 | 19 | import java.io.Serializable; 20 | 21 | import org.jboss.weld.injection.spi.ResourceReference; 22 | 23 | /** 24 | * A trivial holder that holds a resource reference and does not handle releasing. 25 | * 26 | * The holder is serializable as long as the held instance is serializable. 27 | * 28 | * @author Jozef Hartinger 29 | * 30 | * @param the type of the instance 31 | */ 32 | public class SimpleResourceReference implements ResourceReference, Serializable { 33 | 34 | private static final long serialVersionUID = -4908795910866810739L; 35 | 36 | /** 37 | * Resource reference 38 | */ 39 | private final T instance; 40 | 41 | /** 42 | * Construct an instance from provided instance 43 | * 44 | * @param instance resource reference 45 | */ 46 | public SimpleResourceReference(T instance) { 47 | this.instance = instance; 48 | } 49 | 50 | @Override 51 | public T getInstance() { 52 | return instance; 53 | } 54 | 55 | @Override 56 | public void release() { 57 | // noop 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ServiceRegistries.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.helpers; 18 | 19 | import org.jboss.weld.bootstrap.api.Service; 20 | import org.jboss.weld.bootstrap.api.ServiceRegistry; 21 | 22 | /** 23 | * Utility class for {@link ServiceRegistry} 24 | */ 25 | public class ServiceRegistries { 26 | 27 | private ServiceRegistries() { 28 | } 29 | 30 | /** 31 | * Returns an unmodifiable version of provided {@link ServiceRegistry} where any attempt to add a service results in an 32 | * exception 33 | * 34 | * @param serviceRegistry service registry to process 35 | * @return unmodifiable variant 36 | */ 37 | public static ServiceRegistry unmodifiableServiceRegistry(final ServiceRegistry serviceRegistry) { 38 | return new ForwardingServiceRegistry() { 39 | 40 | public void add(java.lang.Class type, S service) { 41 | throw new UnsupportedOperationException("This service registry is unmodifiable"); 42 | } 43 | 44 | @Override 45 | protected ServiceRegistry delegate() { 46 | return serviceRegistry; 47 | } 48 | 49 | }; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/api/InitParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.servlet.api; 18 | 19 | /** 20 | * Names of init parameters that can be used in web.xml to configure Weld's Servlet integration. 21 | * 22 | * @author Jozef Hartinger 23 | * 24 | */ 25 | public interface InitParameters { 26 | 27 | /** 28 | * Enable/disable ignoring HttpServletListeners notifications for forwarded requests. 29 | */ 30 | String CONTEXT_IGNORE_FORWARD = "org.jboss.weld.context.ignore.forward"; 31 | /** 32 | * Enable/disable ignoring HttpServletListeners notifications for include requests (inner requests). 33 | */ 34 | String CONTEXT_IGNORE_INCLUDE = "org.jboss.weld.context.ignore.include"; 35 | /** 36 | * A string representation of regex used in {@link org.jboss.weld.servlet.spi.helpers.RegexHttpContextActivationFilter}. 37 | * Allows to define a pattern for HTTP requests where Weld should skip CDI req. context manipulation. 38 | * 39 | */ 40 | String CONTEXT_MAPPING = "org.jboss.weld.context.mapping"; 41 | 42 | /** 43 | * Enable/disable lazy initialization of the conversation context. 44 | */ 45 | String CONVERSATION_CONTEXT_LAZY_PARAM = "org.jboss.weld.context.conversation.lazy"; 46 | } 47 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/BoundContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context; 2 | 3 | /** 4 | *

5 | * Allows a thread-based context to be bound to some external instance storage (such as an HttpSession). 6 | *

7 | * 8 | *

9 | * A context may be detachable in which case a call to {@link ManagedContext#invalidate()} will detach the context from 10 | * it's associated storage. A detached context is still usable (instances may be added or removed) however changes will not be 11 | * written through to the underlying data store. 12 | *

13 | * 14 | *

15 | * Normally, a detachable context will have it's underlying bean store attached on a call to {@link ManagedContext#activate()} 16 | * and detached on a call to {@link ManagedContext#deactivate()} however a subtype of {@link BoundContext} may change this 17 | * behavior. 18 | *

19 | * 20 | *

21 | * If you call {@link #associate(Object)} you must ensure that you call {@link #dissociate(Object)} in all cases, otherwise you 22 | * risk memory leaks. 23 | *

24 | * 25 | * @author Pete Muir 26 | * 27 | * @param the type of the external instance storage 28 | * @see ManagedContext 29 | */ 30 | public interface BoundContext extends WeldAlterableContext { 31 | 32 | /** 33 | * Associate the context with the storage (for this thread). Once {@link #associate(Object)} has been called, further calls 34 | * to {@link #associate(Object)} will be ignored, until the context has been subsequently {@link #dissociate(Object)} from 35 | * the storage. 36 | * 37 | * @param storage the external storage 38 | * @return true if the storage was attached, otherwise false 39 | */ 40 | boolean associate(S storage); 41 | 42 | /** 43 | * Dissociate the context from the storage (for this thread). The context will only dissociate from the same storage it 44 | * associated with. 45 | * 46 | * @param storage the external storage 47 | * @return true if the storage was dissociated 48 | */ 49 | boolean dissociate(S storage); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/security/spi/SecurityContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2015, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.security.spi; 18 | 19 | /** 20 | * Encapsulation of security information that can be associated with a thread. 21 | * 22 | * @author Jozef Hartinger 23 | * @since 3.0 24 | */ 25 | public interface SecurityContext extends AutoCloseable { 26 | 27 | /** 28 | * A trivial implementation where all operations are no-op 29 | */ 30 | SecurityContext NOOP_SECURITY_CONTEXT = new SecurityContext() { 31 | @Override 32 | public void dissociate() { 33 | } 34 | 35 | @Override 36 | public void close() { 37 | } 38 | 39 | @Override 40 | public void associate() { 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "NOOP_SECURITY_CONTEXT"; 46 | } 47 | }; 48 | 49 | /** 50 | * Associate this security context with the current thread. 51 | */ 52 | void associate(); 53 | 54 | /** 55 | * Clear the security context associated with the current thread. 56 | */ 57 | void dissociate(); 58 | 59 | /** 60 | * Signals to the integrator that this instance will no longer be used by Weld. 61 | */ 62 | void close(); 63 | } 64 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/CDI11Deployment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi; 18 | 19 | /** 20 | * Represents CDI 1.1 and newer deployment. 21 | * 22 | * @see Deployment javadoc 23 | */ 24 | public interface CDI11Deployment extends Deployment { 25 | 26 | /** 27 | *

28 | * Returns the {@link BeanDeploymentArchive} containing the given class. 29 | *

30 | * 31 | *

32 | * If the deployment archive containing the given class is not currently a bean deployment archive, null is returned. Unlike 33 | * {@link #loadBeanDeploymentArchive(Class)}, invocation of this method never results in a new {@link BeanDeploymentArchive} 34 | * instance to be created. This method may be called at runtime. 35 | *

36 | * 37 | *

38 | * Alternatively, this method may return some kind of a "root" BDA instead of returning null if the class does not come from 39 | * a known bean archive. 40 | *

41 | * 42 | * @param beanClass the given class 43 | * @return the {@link BeanDeploymentArchive} containing the bean class or null if no such {@link BeanDeploymentArchive} 44 | * exists 45 | */ 46 | BeanDeploymentArchive getBeanDeploymentArchive(Class beanClass); 47 | } 48 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/resources/spi/ClassFileServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.resources.spi; 18 | 19 | import org.jboss.weld.bootstrap.api.BootstrapService; 20 | 21 | /** 22 | * An optional service that provides fast access to Java class metadata without the need to load the given class. 23 | * 24 | * An integrator may use this service to expose its bytecode scanning facility. If a service implementation is present, Weld 25 | * uses it to optimize the bootstrap 26 | * process. The ClassFileServices implementation is used to determine whether a given Java class fulfills CDI bean requirements 27 | * instead of loading the class 28 | * using a {@link ClassLoader} and examining the result using Java reflection. 29 | * 30 | * @author Jozef Hartinger 31 | * 32 | */ 33 | public interface ClassFileServices extends BootstrapService { 34 | 35 | /** 36 | * Obtains Java class metadata for a class identified with the specified class name. 37 | * 38 | * @param className the specified class name 39 | * @return the class metadata 40 | * @throws ClassFileInfoException if the service implementation is not able to obtain metadata of a class with the specified 41 | * name 42 | */ 43 | ClassFileInfo getClassFileInfo(String className); 44 | } 45 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/interceptor/WeldInvocationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.interceptor; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.util.Set; 21 | 22 | import jakarta.interceptor.InvocationContext; 23 | 24 | /** 25 | * Represents an enhanced version of {@link InvocationContext}. 26 | * 27 | * @author Martin Kouba 28 | * @see CDI-468 29 | */ 30 | public interface WeldInvocationContext extends InvocationContext { 31 | 32 | /** 33 | * Deprecated, users are encouraged to use {@link InvocationContext#getInterceptorBindings()} instead. 34 | *

35 | * A key value under which we store interceptor bindings in {@link InvocationContext} 36 | */ 37 | @Deprecated 38 | String INTERCEPTOR_BINDINGS_KEY = "org.jboss.weld.interceptor.bindings"; 39 | 40 | /** 41 | * @deprecated use {@link #getInterceptorBindings(Class)} 42 | * 43 | * @param annotationType type of the interceptor binding annotations 44 | * @return immutable set of interceptor binding annotations of given type, never null 45 | * @param annotation type 46 | */ 47 | @Deprecated 48 | Set getInterceptorBindingsByType(Class annotationType); 49 | 50 | } -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Weld API Release 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - closed 7 | paths: 8 | - '.github/project.yml' 9 | 10 | jobs: 11 | release: 12 | name: Release 13 | runs-on: ubuntu-latest 14 | if: ${{github.event.pull_request.merged == true}} 15 | env: 16 | GITHUB_TOKEN: ${{secrets.RELEASE_TOKEN}} 17 | steps: 18 | - name: Retrieve project metadata 19 | id: metadata 20 | uses: radcortez/project-metadata-action@main 21 | with: 22 | github-token: ${{secrets.GITHUB_TOKEN}} 23 | metadata-file-path: '.github/project.yml' 24 | 25 | - name: Checkout 26 | uses: actions/checkout@v6 27 | with: 28 | token: ${{secrets.RELEASE_TOKEN}} 29 | 30 | - name: Set up JDK 17 31 | uses: actions/setup-java@v5 32 | with: 33 | distribution: temurin 34 | java-version: 17 35 | server-id: 'central' 36 | server-username: 'CENTRAL_PORTAL_USERNAME' 37 | server-password: 'CENTRAL_PORTAL_PWD' 38 | gpg-private-key: ${{secrets.MAVEN_GPG_PRIVATE_KEY}} 39 | gpg-passphrase: 'MAVEN_GPG_PASSPHRASE' 40 | 41 | - name: Maven release ${{steps.metadata.outputs.current-version}} 42 | env: 43 | CENTRAL_PORTAL_USERNAME: ${{secrets.CENTRAL_PORTAL_USERNAME}} 44 | CENTRAL_PORTAL_PWD: ${{secrets.CENTRAL_PORTAL_PWD}} 45 | MAVEN_GPG_PASSPHRASE: ${{secrets.MAVEN_GPG_PASSPHRASE}} 46 | run: | 47 | export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED" 48 | java -version 49 | git config --global user.name "Weld CI" 50 | git config --global user.email "weld-dev@lists.jboss.org" 51 | git checkout -b release 52 | mvn release:prepare --batch-mode -Drelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -Dtag=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} 53 | git checkout ${{github.base_ref}} 54 | git rebase release 55 | mvn -B release:perform -Drelease 56 | git push 57 | git push --tags -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/JaxwsInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi; 18 | 19 | import jakarta.enterprise.inject.spi.DefinitionException; 20 | import jakarta.enterprise.inject.spi.InjectionPoint; 21 | 22 | import org.jboss.weld.bootstrap.api.Service; 23 | 24 | /** 25 | * An integrator should implement this interface to allow Weld to resolve web service references 26 | * 27 | * {@link JaxwsInjectionServices} is a per-module service. 28 | * 29 | * @author Jozef Hartinger 30 | * 31 | */ 32 | public interface JaxwsInjectionServices extends Service { 33 | 34 | /** 35 | * Register a WebServiceRef injection point. The implementation validates the injection point. If the validation passes, an 36 | * instance of {@link ResourceReferenceFactory} is returned which may be used at runtime for creating instances of the 37 | * resource. 38 | * 39 | * @param the type of the injected instance 40 | * @param injectionPoint the injection point metadata 41 | * @return factory for the web service reference 42 | * @throws DefinitionException if there is a definition problem related to the injection point 43 | */ 44 | ResourceReferenceFactory registerWebServiceRefInjectionPoint(InjectionPoint injectionPoint); 45 | } 46 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/resources/spi/ClassFileInfoException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.resources.spi; 18 | 19 | /** 20 | * Thrown when a {@link ClassFileServices} implementation is not able to obtain metadata for a class with the specified name. 21 | * 22 | * @author Jozef Hartinger 23 | * 24 | */ 25 | public class ClassFileInfoException extends RuntimeException { 26 | 27 | private static final long serialVersionUID = 930782465793465696L; 28 | 29 | /** 30 | * Initializes {@link ClassFileInfoException} with both, exception message and throwable cause 31 | * 32 | * @param message exception message 33 | * @param cause throwable cause 34 | */ 35 | public ClassFileInfoException(String message, Throwable cause) { 36 | super(message, cause); 37 | } 38 | 39 | /** 40 | * Initializes {@link ClassFileInfoException} with exception message 41 | * 42 | * @param message exception message 43 | */ 44 | public ClassFileInfoException(String message) { 45 | super(message); 46 | } 47 | 48 | /** 49 | * Initializes {@link ClassFileInfoException} with throwable cause 50 | * 51 | * @param cause throwable cause 52 | */ 53 | public ClassFileInfoException(Throwable cause) { 54 | super(cause); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/ejb/spi/helpers/ForwadingBusinessInterfaceDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.ejb.spi.helpers; 18 | 19 | import org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor; 20 | 21 | /** 22 | * An implementation of {@link BusinessInterfaceDescriptor} which forwards all its method calls to another 23 | * {@link BusinessInterfaceDescriptor} . Subclasses should override one or more methods to modify the behavior of the backing 24 | * {@link BusinessInterfaceDescriptor} as desired per the decorator 25 | * pattern. 26 | * 27 | * @author Pete Muir 28 | * 29 | */ 30 | public abstract class ForwadingBusinessInterfaceDescriptor implements BusinessInterfaceDescriptor { 31 | 32 | /** 33 | * Returns the delegate 34 | * 35 | * @return delegate 36 | */ 37 | protected abstract BusinessInterfaceDescriptor delegate(); 38 | 39 | public Class getInterface() { 40 | return delegate().getInterface(); 41 | } 42 | 43 | @Override 44 | public boolean equals(Object obj) { 45 | return delegate().equals(obj); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return delegate().toString(); 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | return delegate().hashCode(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/ejb/spi/EjbServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.ejb.spi; 19 | 20 | import org.jboss.weld.bootstrap.api.Service; 21 | import org.jboss.weld.ejb.api.SessionObjectReference; 22 | 23 | /** 24 | * A container should implement this interface to allow Weld to resolve EJB and discover EJBs 25 | * 26 | * {@link EjbServices} is a per-BeanDeploymentArchive service. 27 | * 28 | * @author Pete Muir 29 | * @author Marius Bogoevici 30 | * 31 | */ 32 | public interface EjbServices extends Service { 33 | 34 | /** 35 | * Request a reference to an EJB session object from the container. If the EJB being resolved is a stateful session bean, 36 | * the container should ensure the session bean is created before this method returns. 37 | * 38 | * @param ejbDescriptor the ejb to resolve 39 | * @return a reference to the session object 40 | */ 41 | SessionObjectReference resolveEjb(EjbDescriptor ejbDescriptor); 42 | 43 | /** 44 | * Provides interceptor binding metadata to the container. This method should be called before any EJB object is created. 45 | * 46 | * @param ejbDescriptor the ejb to bound interceptors to 47 | * @param interceptorBindings the interceptor bindings descriptor 48 | */ 49 | void registerInterceptors(EjbDescriptor ejbDescriptor, InterceptorBindings interceptorBindings); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Weld Community Code of Conduct v1.0 2 | 3 | ### Contributor Code of Conduct 4 | 5 | As contributors and maintainers of this project, and in the interest of fostering 6 | an open and welcoming community, we pledge to respect all people who contribute 7 | through reporting issues, posting feature requests, updating documentation, 8 | submitting pull requests or patches, and other activities. 9 | 10 | We are committed to making participation in this project a harassment-free experience for 11 | everyone, regardless of level of experience, gender, gender identity and expression, 12 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, 13 | religion, or nationality. 14 | 15 | Examples of unacceptable behavior by participants include: 16 | 17 | * The use of sexualized language or imagery 18 | * Personal attacks 19 | * Trolling or insulting/derogatory comments 20 | * Public or private harassment 21 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission 22 | * Other unethical or unprofessional conduct. 23 | 24 | Project maintainers have the right and responsibility to remove, edit, or reject 25 | comments, commits, code, wiki edits, issues, and other contributions that are not 26 | aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers 27 | commit themselves to fairly and consistently applying these principles to every aspect 28 | of managing this project. Project maintainers who do not follow or enforce the Code of 29 | Conduct may be permanently removed from the project team. 30 | 31 | This code of conduct applies both within project spaces and in public spaces 32 | when an individual is representing the project or its community. 33 | 34 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 35 | contacting the Weld project lead, Matej Novotny . 36 | 37 | 38 | This Code of Conduct is adapted from the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md) which is 39 | adapted from the Contributor Covenant 40 | (http://contributor-covenant.org), version 1.2.0, available at 41 | http://contributor-covenant.org/version/1/2/0/ 42 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/EjbInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.injection.spi; 19 | 20 | import jakarta.enterprise.inject.spi.DefinitionException; 21 | import jakarta.enterprise.inject.spi.InjectionPoint; 22 | 23 | import org.jboss.weld.bootstrap.api.Service; 24 | 25 | /** 26 | * A container should implement this interface to allow Weld to resolve EJB. 27 | * 28 | * {@link EjbInjectionServices} is a per-module service. 29 | * 30 | * @author Pete Muir 31 | * @author Jozef Hartinger 32 | * 33 | */ 34 | public interface EjbInjectionServices extends Service { 35 | 36 | /** 37 | * Register an EJB injection point. The implementation validates the injection point. If the validation passes, an instance 38 | * of {@link ResourceReferenceFactory} is returned which may be used at runtime for creating instances of the resource. 39 | * 40 | * @param injectionPoint the injection point metadata 41 | * @return EJB instance factory 42 | * @throws DefinitionException if the injection point is not annotated with @EJB, if the injection point is a method that 43 | * doesn't follow JavaBean conventions or if the injection point type does not match the EJB type 44 | * @throws IllegalStateException if no suitable EJB can be resolved 45 | */ 46 | ResourceReferenceFactory registerEjbInjectionPoint(InjectionPoint injectionPoint); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/IsolatedStaticSingletonProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2019, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.bootstrap.api.helpers; 19 | 20 | import org.jboss.weld.bootstrap.api.Singleton; 21 | import org.jboss.weld.bootstrap.api.SingletonProvider; 22 | 23 | /** 24 | * 25 | * A singleton provider that assumes an isolated classloder per application 26 | * 27 | * @author Sanjeeb.Sahoo@Sun.COM 28 | * @author Pete Muir 29 | */ 30 | public class IsolatedStaticSingletonProvider extends SingletonProvider { 31 | 32 | @Override 33 | public Singleton create(Class type) { 34 | return new IsolatedStaticSingleton(); 35 | } 36 | 37 | private static class IsolatedStaticSingleton implements Singleton { 38 | private T object; 39 | 40 | public T get(String id) { 41 | if (object == null) { 42 | throw new IllegalStateException( 43 | "Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly?"); 44 | } 45 | return object; 46 | } 47 | 48 | public void set(String id, T object) { 49 | this.object = object; 50 | } 51 | 52 | public void clear(String id) { 53 | this.object = null; 54 | } 55 | 56 | public boolean isSet(String id) { 57 | return object != null; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/ForwardingResourceInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi.helpers; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | 21 | import org.jboss.weld.injection.spi.ResourceInjectionServices; 22 | import org.jboss.weld.injection.spi.ResourceReferenceFactory; 23 | 24 | /** 25 | * An implementation of {@link ResourceInjectionServices} which forwards all its method calls to another 26 | * {@link ResourceInjectionServices} 27 | * Subclasses should override one or more methods to modify the behavior of the backing {@link ResourceInjectionServices} as 28 | * desired per the decorator pattern. 29 | * 30 | */ 31 | public abstract class ForwardingResourceInjectionServices implements ResourceInjectionServices { 32 | 33 | /** 34 | * Returns the delegate 35 | * 36 | * @return delegate 37 | */ 38 | protected abstract ResourceInjectionServices delegate(); 39 | 40 | public ResourceReferenceFactory registerResourceInjectionPoint(InjectionPoint injectionPoint) { 41 | return delegate().registerResourceInjectionPoint(injectionPoint); 42 | } 43 | 44 | public ResourceReferenceFactory registerResourceInjectionPoint(String jndiName, String mappedName) { 45 | return delegate().registerResourceInjectionPoint(jndiName, mappedName); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/proxy/WeldClientProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.proxy; 18 | 19 | import jakarta.enterprise.inject.spi.Bean; 20 | 21 | /** 22 | * An extension to {@link WeldConstruct} interface which denotes a client proxy object. All Weld client proxies implement this 23 | * interface hence allowing access to the underlying bean {@link Metadata}. 24 | * 25 | * @author Matej Novotny 26 | */ 27 | public interface WeldClientProxy extends WeldConstruct { 28 | 29 | /** 30 | * Retrieve a wrapper class contextual metadata. 31 | * 32 | * @return wrapper allowing access to contextual instance and {@link Bean} metadata 33 | */ 34 | Metadata getMetadata(); 35 | 36 | /** 37 | * An abstraction allowing access to {@link Bean} metadata as well as the contextual instance 38 | */ 39 | public interface Metadata { 40 | 41 | /** 42 | * Retrieve {@link Bean} metadata for this proxy instance. 43 | * 44 | * @return {@link Bean} metadata for this proxy 45 | */ 46 | Bean getBean(); 47 | 48 | /** 49 | * Retrieve the current contextual instance associated with the current context for this client proxy. Note that in some 50 | * cases the contextual instance is still an instance of {@link WeldConstruct}. 51 | * 52 | * @return the underlying contextual instance of this client proxy instance. 53 | */ 54 | Object getContextualInstance(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/http/HttpSessionContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.http; 2 | 3 | import jakarta.servlet.http.HttpServletRequest; 4 | import jakarta.servlet.http.HttpSession; 5 | 6 | import org.jboss.weld.context.BoundContext; 7 | import org.jboss.weld.context.SessionContext; 8 | 9 | /** 10 | *

11 | * A session context which can be bound to the {@link HttpServletRequest}. The context is automatically attached to the map on 12 | * activation, and detached when {@link #invalidate()} is called. 13 | *

14 | * 15 | *

16 | * This context is not thread safe, and provides no thread safety for the underlying map. 17 | *

18 | * 19 | * 20 | * @author Pete Muir 21 | * 22 | */ 23 | public interface HttpSessionContext extends BoundContext, SessionContext { 24 | 25 | /** 26 | *

27 | * Mark the Session Context for destruction; the Session Context will be detached from the underling Http Session, and 28 | * instances marked for destruction when the Http Request is destroyed. 29 | *

30 | * 31 | */ 32 | void invalidate(); 33 | 34 | /** 35 | *

36 | * Returns false if the session has been invalidated (using {@link #invalidate()}). Returns true otherwise. 37 | *

38 | * 39 | * @return true if {@link #invalidate()} has been called on this context 40 | */ 41 | boolean isValid(); 42 | 43 | /** 44 | *

45 | * Destroy the session and all conversations stored in the session. 46 | *

47 | * 48 | *

49 | * If the context is not currently associated with a {@link HttpServletRequest}, then the context will be associated with 50 | * the specified {@link HttpSession} (for this thread), activated, destroyed, and then deactivated. 51 | *

52 | * 53 | *

54 | * If the context is already associated with a {@link HttpServletRequest} then this call will detach the context from the 55 | * underlying Http Session, and mark the context for destruction when the request is destroyed. 56 | *

57 | * 58 | * @param session the {@link HttpSession} in which to store the bean instances 59 | * @return true if the context was destroyed immediately 60 | */ 61 | boolean destroy(HttpSession session); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/Singleton.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2019, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.bootstrap.api; 19 | 20 | /** 21 | * Holds a reference to an application singleton. This singleton is used internally by Weld to store various application scoped 22 | * objects. 23 | * 24 | * This allows Weld to operate as a shared library. In a shared mode, the same instance of Weld implementation is used by all 25 | * the applications in a server 26 | * environment. In the exclusive mode, each application loads a separate copy of Weld implementation at the application level. 27 | * 28 | * Alternative implementations of Singleton can be used as required 29 | * 30 | * @see SingletonProvider 31 | * @author Sanjeeb.Sahoo@Sun.COM 32 | * @author Pete Muir 33 | */ 34 | public interface Singleton { 35 | /** 36 | * Access the singleton 37 | * 38 | * @param id singleton identifier 39 | * @return a singleton object 40 | * @throws IllegalStateException if the singleton is not set 41 | */ 42 | T get(String id); 43 | 44 | /** 45 | * Check if the singleton is set 46 | * 47 | * @param id singleton identifier 48 | * @return true if the singleton is set 49 | */ 50 | boolean isSet(String id); 51 | 52 | /** 53 | * Store a singleton 54 | * 55 | * @param id singleton identifier 56 | * @param object the object to store 57 | */ 58 | void set(String id, T object); 59 | 60 | /** 61 | * Clear the singleton 62 | * 63 | * @param id singleton identifier 64 | */ 65 | void clear(String id); 66 | 67 | } 68 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/resources/spi/helpers/ForwardingResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.resources.spi.helpers; 18 | 19 | import java.net.URL; 20 | import java.util.Collection; 21 | 22 | import org.jboss.weld.resources.spi.ResourceLoader; 23 | 24 | /** 25 | * An implementation of {@link ResourceLoader} which forwards all its method calls to another {@link ResourceLoader} . 26 | * Subclasses should override one or more methods to modify the behavior of the backing {@link ResourceLoader} as desired per 27 | * the decorator pattern. 28 | * 29 | * @author Pete Muir 30 | * 31 | */ 32 | public abstract class ForwardingResourceLoader implements ResourceLoader { 33 | 34 | /** 35 | * Returns the delegate 36 | * 37 | * @return delegate 38 | */ 39 | protected abstract ResourceLoader delegate(); 40 | 41 | public Class classForName(String name) { 42 | return delegate().classForName(name); 43 | } 44 | 45 | public URL getResource(String name) { 46 | return delegate().getResource(name); 47 | } 48 | 49 | public Collection getResources(String name) { 50 | return delegate().getResources(name); 51 | } 52 | 53 | @Override 54 | public boolean equals(Object obj) { 55 | return this == obj || delegate().equals(obj); 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return delegate().toString(); 61 | } 62 | 63 | @Override 64 | public int hashCode() { 65 | return delegate().hashCode(); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/bootstrap/event/WeldAfterBeanDiscovery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2015, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.event; 18 | 19 | import jakarta.enterprise.inject.spi.AfterBeanDiscovery; 20 | import jakarta.enterprise.inject.spi.Interceptor; 21 | import jakarta.enterprise.inject.spi.configurator.BeanConfigurator; 22 | 23 | /** 24 | * Represents an enhanced version of {@link AfterBeanDiscovery}. 25 | * 26 | * @author Martin Kouba 27 | * @see WELD-2008 28 | */ 29 | public interface WeldAfterBeanDiscovery extends AfterBeanDiscovery { 30 | 31 | /** 32 | * Obtain a {@link InterceptorConfigurator} to configure a new {@link Interceptor}. 33 | *

34 | * The configured interceptor is automatically added at the end of the observer invocation. 35 | *

36 | *

37 | * Each call returns a new configurator instance. 38 | *

39 | * 40 | * @return a configurator to configure a new interceptor 41 | */ 42 | InterceptorConfigurator addInterceptor(); 43 | 44 | /** 45 | * Obtain a {@link WeldBeanConfigurator}, an extended version of {@link BeanConfigurator}. 46 | *

47 | * The configurator behaves in the same manner as {@link BeanConfigurator}. 48 | * Configured bean is added automatically at the end of the observer invocation. 49 | *

50 | *

51 | * Each call returns new configurator instance. 52 | *

53 | * 54 | * @return a configurator to configure custom new bean 55 | */ 56 | @Override 57 | public WeldBeanConfigurator addBean(); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/InjectionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi; 18 | 19 | import jakarta.enterprise.inject.spi.AnnotatedType; 20 | import jakarta.enterprise.inject.spi.InjectionTarget; 21 | import jakarta.inject.Inject; 22 | 23 | import org.jboss.weld.ejb.api.SessionObjectReference; 24 | 25 | /** 26 | * The context in which instance injection occurs. 27 | * 28 | * @author Pete Muir 29 | * 30 | */ 31 | public interface InjectionContext { 32 | 33 | /** 34 | * Calling {@link #proceed()} will cause Weld to perform injection on the instance as it normally would. It is legal to not 35 | * call {@link #proceed()}, however the container must ensure all injection, including CDI-style {@link Inject} injection is 36 | * done. 37 | */ 38 | void proceed(); 39 | 40 | /** 41 | * Get the underlying instance to be injected. If the instance being injected is an EJB this will be whatever is returned by 42 | * {@link SessionObjectReference#getBusinessObject(Class)} 43 | * 44 | * @return the underlying instance to be injected 45 | */ 46 | T getTarget(); 47 | 48 | /** 49 | * Get the {@link InjectionTarget} for the instance being injected 50 | * 51 | * @return the {@link InjectionTarget} for the instance being injected 52 | */ 53 | InjectionTarget getInjectionTarget(); 54 | 55 | /** 56 | * Get the {@link AnnotatedType} for the instance being injected 57 | * 58 | * @return the {@link AnnotatedType} for the instance being injected 59 | */ 60 | AnnotatedType getAnnotatedType(); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/ejb/api/SessionObjectReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.ejb.api; 18 | 19 | import java.io.Serializable; 20 | 21 | import jakarta.ejb.NoSuchEJBException; 22 | 23 | /** 24 | * A serializable reference to a session object in the EJB container 25 | * 26 | * @author Pete Muir 27 | */ 28 | public interface SessionObjectReference extends Serializable { 29 | 30 | /** 31 | * Get the reference from the EJB container to the session object for the given business interface 32 | * 33 | * @param the type of the business interface 34 | * @param businessInterfaceType the type of the business interface 35 | * @return a reference 36 | * 37 | * @throws IllegalStateException if the business interface is not a business interface of the session bean 38 | * @throws NoSuchEJBException if the session object has already been removed 39 | */ 40 | S getBusinessObject(Class businessInterfaceType); 41 | 42 | /** 43 | * Request the EJB container remove the stateful session object 44 | * 45 | * @throws UnsupportedOperationException if the reference is not backed by a stateful session object 46 | * @throws NoSuchEJBException if the session object has already been removed 47 | */ 48 | void remove(); 49 | 50 | /** 51 | * Determine whether the session object has been removed. 52 | * 53 | * If the session object has yet to be referenced by {@link #getBusinessObject(Class)} then this method should not return 54 | * true. 55 | * 56 | * @return true if the session object has been removed 57 | */ 58 | boolean isRemoved(); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/ejb/spi/helpers/ForwardingEjbServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.ejb.spi.helpers; 18 | 19 | import org.jboss.weld.ejb.api.SessionObjectReference; 20 | import org.jboss.weld.ejb.spi.EjbDescriptor; 21 | import org.jboss.weld.ejb.spi.EjbServices; 22 | import org.jboss.weld.ejb.spi.InterceptorBindings; 23 | 24 | /** 25 | * An implementation of {@link EjbServices} which forwards all its method calls to another {@link EjbServices} . Subclasses 26 | * should override one or more methods to modify the behavior of the backing {@link EjbServices} as desired per the decorator pattern. 28 | * 29 | * @author Pete Muir 30 | * 31 | */ 32 | public abstract class ForwardingEjbServices implements EjbServices { 33 | 34 | /** 35 | * Returns the delegate 36 | * 37 | * @return delegate 38 | */ 39 | public abstract EjbServices delegate(); 40 | 41 | public SessionObjectReference resolveEjb(EjbDescriptor ejbDescriptor) { 42 | return delegate().resolveEjb(ejbDescriptor); 43 | } 44 | 45 | public void registerInterceptors(EjbDescriptor ejbDescriptor, InterceptorBindings interceptorBindings) { 46 | delegate().registerInterceptors(ejbDescriptor, interceptorBindings); 47 | } 48 | 49 | @Override 50 | public boolean equals(Object obj) { 51 | return this == obj || delegate().equals(obj); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return delegate().toString(); 57 | } 58 | 59 | @Override 60 | public int hashCode() { 61 | return delegate().hashCode(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/resources/spi/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.resources.spi; 19 | 20 | import java.net.URL; 21 | import java.util.Collection; 22 | 23 | import org.jboss.weld.bootstrap.api.Service; 24 | 25 | /** 26 | * Resource loading/class creation services for Weld. By default an implementation which uses the Thread Context ClassLoader if 27 | * available, otherwise the classloading of the implementation is used. An alternative implementation that uses a predefined 28 | * classloader is available for multi-modular environments. 29 | * 30 | * The {@link ResourceLoader} is a per-BeanManager service. Single-module deployments can use the default implementation, but 31 | * applications that consist of multiple modules must use an implementation that is aware of the module classloader. 32 | * 33 | * @author Pete Muir 34 | * 35 | */ 36 | public interface ResourceLoader extends Service { 37 | /** 38 | * Name of the resource loader 39 | */ 40 | String PROPERTY_NAME = ResourceLoader.class.getName(); 41 | 42 | /** 43 | * Creates a class from a given FQCN 44 | * 45 | * @param name The name of the clsas 46 | * @return The class 47 | */ 48 | Class classForName(String name); 49 | 50 | /** 51 | * Gets a resource as a URL by name 52 | * 53 | * @param name The name of the resource 54 | * @return An URL to the resource 55 | */ 56 | URL getResource(String name); 57 | 58 | /** 59 | * Gets resources as URLs by name 60 | * 61 | * @param name The name of the resource 62 | * @return references to the URLS 63 | */ 64 | Collection getResources(String name); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/servlet/api/helpers/ForwardingServletListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.servlet.api.helpers; 18 | 19 | import jakarta.servlet.ServletContextEvent; 20 | import jakarta.servlet.ServletRequestEvent; 21 | import jakarta.servlet.http.HttpSessionEvent; 22 | 23 | import org.jboss.weld.servlet.api.ServletListener; 24 | 25 | /** 26 | * An implementation of {@link ServletListener} which forwards all its method calls to another {@link ServletListener} 27 | * Subclasses should override one or more methods to modify the behavior of the backing {@link ServletListener} as 28 | * desired per the decorator pattern. 29 | * 30 | */ 31 | public abstract class ForwardingServletListener implements ServletListener { 32 | 33 | /** 34 | * Returns the delegate 35 | * 36 | * @return delegate 37 | */ 38 | protected abstract ServletListener delegate(); 39 | 40 | public void contextDestroyed(ServletContextEvent sce) { 41 | delegate().contextDestroyed(sce); 42 | } 43 | 44 | public void contextInitialized(ServletContextEvent sce) { 45 | delegate().contextInitialized(sce); 46 | } 47 | 48 | public void requestDestroyed(ServletRequestEvent sre) { 49 | delegate().requestDestroyed(sre); 50 | } 51 | 52 | public void requestInitialized(ServletRequestEvent sre) { 53 | delegate().requestInitialized(sre); 54 | } 55 | 56 | public void sessionCreated(HttpSessionEvent se) { 57 | delegate().sessionCreated(se); 58 | } 59 | 60 | public void sessionDestroyed(HttpSessionEvent se) { 61 | delegate().sessionDestroyed(se); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/events/WeldEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2017, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.events; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.lang.reflect.Type; 21 | 22 | import jakarta.enterprise.event.Event; 23 | import jakarta.enterprise.util.TypeLiteral; 24 | 25 | /** 26 | * Enriched version of {@link jakarta.enterprise.event.Event}. 27 | * 28 | * @author Matej Novotny 29 | */ 30 | public interface WeldEvent extends Event { 31 | 32 | /** 33 | *

34 | * Obtains a child {@code Event} for the given required type and additional required qualifiers. Must be invoked on 35 | * {@code Event} where T is {@link java.lang.Object}. 36 | *

37 | * 38 | * @param the required type 39 | * @param type a {@link java.lang.reflect.Type} representing the required type 40 | * @param qualifiers the additional required qualifiers 41 | * @return the child {@code Event} 42 | * @throws IllegalArgumentException if passed two instances of the same non repeating qualifier type, or an instance of an 43 | * annotation that is not a qualifier type 44 | * @throws IllegalStateException if invoked on {@code Event} where T is of any other type than 45 | * {@link java.lang.Object} 46 | */ 47 | WeldEvent select(Type type, Annotation... qualifiers); 48 | 49 | @Override 50 | public WeldEvent select(Annotation... qualifiers); 51 | 52 | @Override 53 | public WeldEvent select(Class subtype, Annotation... qualifiers); 54 | 55 | @Override 56 | public WeldEvent select(TypeLiteral subtype, Annotation... qualifiers); 57 | } 58 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/TCCLSingletonProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2019, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.jboss.weld.bootstrap.api.helpers; 19 | 20 | import java.util.Map; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | import org.jboss.weld.bootstrap.api.Singleton; 24 | import org.jboss.weld.bootstrap.api.SingletonProvider; 25 | 26 | /** 27 | * Singleton provider that uses the Thread Context ClassLoader to differentiate between applications 28 | * 29 | * @author Sanjeeb.Sahoo@Sun.COM 30 | * @author Pete Muir 31 | */ 32 | public class TCCLSingletonProvider extends SingletonProvider { 33 | 34 | @Override 35 | public Singleton create(Class type) { 36 | return new TCCLSingleton(); 37 | } 38 | 39 | private static class TCCLSingleton implements Singleton { 40 | 41 | private final Map store = new ConcurrentHashMap(); 42 | 43 | public T get(String id) { 44 | T instance = store.get(getClassLoader()); 45 | if (instance == null) { 46 | throw new IllegalStateException("Singleton not set for " + getClassLoader()); 47 | } 48 | return instance; 49 | } 50 | 51 | public void set(String id, T object) { 52 | store.put(getClassLoader(), object); 53 | } 54 | 55 | public void clear(String id) { 56 | store.remove(getClassLoader()); 57 | } 58 | 59 | public boolean isSet(String id) { 60 | return store.containsKey(getClassLoader()); 61 | } 62 | 63 | private ClassLoader getClassLoader() { 64 | return Thread.currentThread().getContextClassLoader(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/activator/ActivateRequestContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2016, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context.activator; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.ElementType.TYPE; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | import jakarta.enterprise.context.RequestScoped; 27 | import jakarta.enterprise.util.AnnotationLiteral; 28 | import jakarta.interceptor.InterceptorBinding; 29 | 30 | /** 31 | * This interceptor binding can be used to activate the request context within a business method invocation. 32 | *

33 | * If the request context is already active then the associated interceptor does nothing. 34 | *

35 | * The interceptor is registered with a priority of {@link jakarta.interceptor.Interceptor.Priority#PLATFORM_BEFORE} + 100. The 36 | * same value is used for 37 | * {@link jakarta.enterprise.context.control.ActivateRequestContext}. 38 | * 39 | * @author Tomas Remes 40 | * @author Martin Kouba 41 | * @see RequestScoped 42 | */ 43 | @InterceptorBinding 44 | @Retention(RUNTIME) 45 | @Target({ METHOD, TYPE }) 46 | public @interface ActivateRequestContext { 47 | 48 | /** 49 | * Annotation literal for {@link ActivateRequestContext} 50 | */ 51 | class Literal extends AnnotationLiteral implements ActivateRequestContext { 52 | 53 | /** 54 | * An instance of {@link ActivateRequestContext} annotation literal 55 | */ 56 | public static final Literal INSTANCE = new Literal(); 57 | 58 | private static final long serialVersionUID = 1L; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/helpers/MetadataImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2016, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi.helpers; 18 | 19 | import org.jboss.weld.bootstrap.spi.Metadata; 20 | 21 | /** 22 | * Basic implementation of {@link Metadata} 23 | * 24 | * @param the type of metadata 25 | */ 26 | public class MetadataImpl implements Metadata { 27 | 28 | /** 29 | * Constant used to declare that the metadata location is not available 30 | */ 31 | public static final String LOCATION_NOT_AVAILABLE = "n/a"; 32 | 33 | private final String location; 34 | 35 | private final T value; 36 | 37 | /** 38 | * Constructs {@link Metadata} from given value. 39 | * Metadata location is set to {@link #LOCATION_NOT_AVAILABLE} 40 | * 41 | * @param value metadata value 42 | * @return instance of metadata 43 | * @param metadata type 44 | */ 45 | public static MetadataImpl from(T value) { 46 | return new MetadataImpl(value); 47 | } 48 | 49 | /** 50 | * 51 | * @param value type of metadata that this class holds 52 | */ 53 | public MetadataImpl(T value) { 54 | this(value, LOCATION_NOT_AVAILABLE); 55 | } 56 | 57 | /** 58 | * 59 | * @param value type of metadata that this class holds 60 | * @param location String representation of where is this metadata stored 61 | */ 62 | public MetadataImpl(T value, String location) { 63 | this.location = location; 64 | this.value = value; 65 | } 66 | 67 | public String getLocation() { 68 | return location; 69 | } 70 | 71 | public T getValue() { 72 | return value; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return getLocation(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/http/HttpConversationContext.java: -------------------------------------------------------------------------------- 1 | package org.jboss.weld.context.http; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import jakarta.servlet.http.HttpServletRequest; 6 | import jakarta.servlet.http.HttpSession; 7 | 8 | import org.jboss.weld.context.BoundContext; 9 | import org.jboss.weld.context.ConversationContext; 10 | 11 | /** 12 | * An Http Session backed conversation context. A transient conversation will be detached from the underlying session. If the 13 | * conversation is promoted to long running, context will be attached to the underlying Http Session at the end of the request. 14 | * 15 | * @author Pete Muir 16 | * 17 | */ 18 | public interface HttpConversationContext extends BoundContext, ConversationContext { 19 | 20 | /** 21 | *

22 | * If the context is not currently associated with a {@link HttpServletRequest}, then the context will be associated with 23 | * the specified {@link HttpSession} (for this thread), activated, destroyed, and then deactivated. Any conversations 24 | * associated with the context will also be destroyed. 25 | *

26 | * 27 | *

28 | * If the context is already associated with a {@link HttpServletRequest} then this call will detach the context from the 29 | * underlying Http Session, and mark the context for destruction when the request is destroyed. 30 | *

31 | * 32 | *

33 | * This will cause any transient conversations, and any long running conversations associated with the session, to be 34 | * destroyed. 35 | *

36 | * 37 | * @param session the {@link HttpSession} in which to store the bean instances 38 | * @return true if the context was destroyed immediately 39 | */ 40 | boolean destroy(HttpSession session); 41 | 42 | /** 43 | *

44 | * Activate the conversation context lazily - neither determine the conversation id, nor initialize the context. The context 45 | * is only initialized when a 46 | * conversation-scoped bean is accessed for the first time. The callback, if specified, is executed during initialization of 47 | * a transient conversation. The 48 | * implementation must throw a {@link RuntimeException} if the lazy initialization is not supported. 49 | *

50 | * 51 | * @param transientConversationInitializationCallback the callback which is invoked during initialization of a transient 52 | * conversation 53 | */ 54 | default void activateLazily(Consumer transientConversationInitializationCallback) { 55 | throw new UnsupportedOperationException(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /weld-spi/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | weld-api-parent 4 | org.jboss.weld 5 | 7.0-SNAPSHOT 6 | ../pom.xml 7 | 8 | 4.0.0 9 | weld-spi 10 | Weld SPIs for container integration 11 | http://weld.cdi-spec.org 12 | 13 | 14 | Apache License, Version 2.0 15 | repo 16 | http://www.apache.org/licenses/LICENSE-2.0.html 17 | 18 | 19 | 20 | 21 | 22 | 23 | org.jboss.weld 24 | weld-api 25 | ${project.version} 26 | 27 | 28 | 29 | jakarta.annotation 30 | jakarta.annotation-api 31 | true 32 | 33 | 34 | 35 | jakarta.persistence 36 | jakarta.persistence-api 37 | true 38 | 39 | 40 | 41 | org.testng 42 | testng 43 | test 44 | 45 | 46 | 47 | jakarta.transaction 48 | jakarta.transaction-api 49 | true 50 | 51 | 52 | 53 | jakarta.servlet 54 | jakarta.servlet-api 55 | true 56 | 57 | 58 | 59 | jakarta.validation 60 | jakarta.validation-api 61 | true 62 | 63 | 64 | 65 | jakarta.ejb 66 | jakarta.ejb-api 67 | true 68 | 69 | 70 | 71 | jakarta.interceptor 72 | jakarta.interceptor-api 73 | true 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/ForwardingJpaInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi.helpers; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | import jakarta.persistence.EntityManager; 21 | import jakarta.persistence.EntityManagerFactory; 22 | 23 | import org.jboss.weld.injection.spi.JpaInjectionServices; 24 | import org.jboss.weld.injection.spi.ResourceReferenceFactory; 25 | 26 | /** 27 | * An implementation of {@link JpaInjectionServices} which forwards all its method calls to another {@link JpaInjectionServices} 28 | * . Subclasses should override one or more methods to modify the behavior of the backing {@link JpaInjectionServices} as 29 | * desired per the decorator pattern. 30 | * 31 | * @author Pete Muir 32 | * 33 | */ 34 | public abstract class ForwardingJpaInjectionServices implements JpaInjectionServices { 35 | 36 | /** 37 | * Returns the delegate 38 | * 39 | * @return delegate 40 | */ 41 | protected abstract JpaInjectionServices delegate(); 42 | 43 | public ResourceReferenceFactory registerPersistenceContextInjectionPoint(InjectionPoint injectionPoint) { 44 | return delegate().registerPersistenceContextInjectionPoint(injectionPoint); 45 | } 46 | 47 | public ResourceReferenceFactory registerPersistenceUnitInjectionPoint(InjectionPoint injectionPoint) { 48 | return delegate().registerPersistenceUnitInjectionPoint(injectionPoint); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return delegate().toString(); 54 | } 55 | 56 | @Override 57 | public int hashCode() { 58 | return delegate().hashCode(); 59 | } 60 | 61 | @Override 62 | public boolean equals(Object obj) { 63 | return this == obj || delegate().equals(obj); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/configuration/spi/helpers/ExternalConfigurationBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.configuration.spi.helpers; 18 | 19 | import java.util.Collections; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import org.jboss.weld.configuration.spi.ExternalConfiguration; 24 | 25 | /** 26 | * A builder for building immutable {@link ExternalConfiguration} 27 | * 28 | * @author Jozef Hartinger 29 | * 30 | */ 31 | public final class ExternalConfigurationBuilder { 32 | 33 | private final Map builder = new HashMap(); 34 | 35 | /** 36 | * Add a key-value pair 37 | * 38 | * @param key configuration key as String 39 | * @param value configuration value as an object 40 | * @return self 41 | */ 42 | public ExternalConfigurationBuilder add(String key, Object value) { 43 | builder.put(key, value); 44 | return this; 45 | } 46 | 47 | /** 48 | * Builds an immutable {@link ExternalConfiguration} object 49 | * 50 | * @return immutable {@link ExternalConfiguration} object 51 | */ 52 | public ExternalConfiguration build() { 53 | return new ExternalConfigurationImpl(Collections.unmodifiableMap(builder)); 54 | } 55 | 56 | private static class ExternalConfigurationImpl implements ExternalConfiguration { 57 | 58 | private final Map properties; 59 | 60 | private ExternalConfigurationImpl(Map properties) { 61 | this.properties = properties; 62 | } 63 | 64 | @Override 65 | public Map getConfigurationProperties() { 66 | return properties; 67 | } 68 | 69 | @Override 70 | public void cleanup() { 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "ExternalConfigurationImpl [properties=" + properties + "]"; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ForwardingBootstrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.helpers; 18 | 19 | import org.jboss.weld.bootstrap.api.Bootstrap; 20 | import org.jboss.weld.bootstrap.api.Environment; 21 | import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive; 22 | import org.jboss.weld.bootstrap.spi.Deployment; 23 | import org.jboss.weld.manager.api.WeldManager; 24 | 25 | /** 26 | * Implementation of {@link Bootstrap} which supports the decorator pattern 27 | * 28 | * @author Pete Muir 29 | * 30 | */ 31 | public abstract class ForwardingBootstrap implements Bootstrap { 32 | 33 | /** 34 | * Returns the delegate 35 | * 36 | * @return delegate 37 | */ 38 | protected abstract Bootstrap delegate(); 39 | 40 | public WeldManager getManager(BeanDeploymentArchive beanDeploymentArchive) { 41 | return delegate().getManager(beanDeploymentArchive); 42 | } 43 | 44 | public Bootstrap startContainer(Environment environment, Deployment deployment) { 45 | return delegate().startContainer(environment, deployment); 46 | } 47 | 48 | public void shutdown() { 49 | delegate().shutdown(); 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return delegate().toString(); 55 | } 56 | 57 | @Override 58 | public int hashCode() { 59 | return delegate().hashCode(); 60 | } 61 | 62 | @Override 63 | public boolean equals(Object obj) { 64 | return this == obj || delegate().equals(obj); 65 | } 66 | 67 | public Bootstrap deployBeans() { 68 | return delegate().deployBeans(); 69 | } 70 | 71 | public Bootstrap endInitialization() { 72 | return delegate().endInitialization(); 73 | } 74 | 75 | public Bootstrap startInitialization() { 76 | return delegate().startInitialization(); 77 | } 78 | 79 | public Bootstrap validateBeans() { 80 | return delegate().validateBeans(); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/helpers/ForwardingBeanDeploymentArchive.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi.helpers; 18 | 19 | import java.util.Collection; 20 | 21 | import org.jboss.weld.bootstrap.api.ServiceRegistry; 22 | import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive; 23 | import org.jboss.weld.bootstrap.spi.BeansXml; 24 | import org.jboss.weld.ejb.spi.EjbDescriptor; 25 | 26 | /** 27 | * @author pmuir 28 | * 29 | */ 30 | public abstract class ForwardingBeanDeploymentArchive implements BeanDeploymentArchive { 31 | 32 | /** 33 | * Returns the delegate 34 | * 35 | * @return delegate 36 | */ 37 | protected abstract BeanDeploymentArchive delegate(); 38 | 39 | public Collection getBeanClasses() { 40 | return delegate().getBeanClasses(); 41 | } 42 | 43 | @Override 44 | public Collection getKnownClasses() { 45 | return delegate().getKnownClasses(); 46 | } 47 | 48 | @Override 49 | public Collection> getLoadedBeanClasses() { 50 | return delegate().getLoadedBeanClasses(); 51 | } 52 | 53 | @Override 54 | public ServiceRegistry getServices() { 55 | return delegate().getServices(); 56 | } 57 | 58 | @Override 59 | public String getId() { 60 | return delegate().getId(); 61 | } 62 | 63 | public Collection getBeanDeploymentArchives() { 64 | return delegate().getBeanDeploymentArchives(); 65 | } 66 | 67 | public BeansXml getBeansXml() { 68 | return delegate().getBeansXml(); 69 | } 70 | 71 | public Collection> getEjbs() { 72 | return delegate().getEjbs(); 73 | } 74 | 75 | @Override 76 | public int hashCode() { 77 | return delegate().hashCode(); 78 | } 79 | 80 | @Override 81 | public boolean equals(Object obj) { 82 | return this == obj || delegate().equals(obj); 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return delegate().toString(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/manager/api/WeldInjectionTargetFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.manager.api; 18 | 19 | import jakarta.enterprise.inject.CreationException; 20 | import jakarta.enterprise.inject.spi.Bean; 21 | import jakarta.enterprise.inject.spi.InjectionTarget; 22 | import jakarta.enterprise.inject.spi.InjectionTargetFactory; 23 | import jakarta.interceptor.Interceptors; 24 | 25 | /** 26 | * Specialized version which provides more options than the original {@link InjectionTargetFactory}. 27 | * 28 | * @author Jozef Hartinger 29 | */ 30 | public interface WeldInjectionTargetFactory extends InjectionTargetFactory { 31 | 32 | @Override 33 | WeldInjectionTarget createInjectionTarget(Bean bean); 34 | 35 | /** 36 | * Creates a {@link WeldInjectionTarget} implementation that does not support construction/destruction of instances but 37 | * provides field/setter injection 38 | * capabilities. Such implementation is often handy for integration with other frameworks in situations when an existing 39 | * Java object needs to be injected. 40 | * 41 | * {@link InjectionTarget#produce(jakarta.enterprise.context.spi.CreationalContext)} and 42 | * {@link InjectionTarget#dispose(Object)} methods should not be called on 43 | * the returned instance. The {@link InjectionTarget#produce(jakarta.enterprise.context.spi.CreationalContext)} method of 44 | * the returned injection target 45 | * throws {@link CreationException} if called. 46 | * 47 | * @return the injection target 48 | */ 49 | WeldInjectionTarget createNonProducibleInjectionTarget(); 50 | 51 | /** 52 | * Create a new injection target for an interceptor bound using {@link Interceptors} or a deployment descriptor. Unlike 53 | * {@link #createInjectionTarget(jakarta.enterprise.inject.spi.Bean)}, the resulting InjectionTarget does not support 54 | * interception as it is itself an 55 | * interceptor. 56 | * 57 | * @return the injection target 58 | */ 59 | WeldInjectionTarget createInterceptorInjectionTarget(); 60 | } 61 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/transaction/spi/TransactionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.transaction.spi; 18 | 19 | import jakarta.transaction.Synchronization; 20 | import jakarta.transaction.UserTransaction; 21 | 22 | import org.jboss.weld.bootstrap.api.Service; 23 | 24 | /** 25 | *

26 | * The container must implement the services related to transactional behavior used in JSR-299, if that behavior is going to be 27 | * used. 28 | *

29 | * 30 | *

31 | * The event framework specified by CDI includes the ability to create observer methods which are activated based on the phase 32 | * and status of a currently active transaction. In order to use these abilities, the container must provide these intermediary 33 | * services which in turn may interact with an application server and JTA. 34 | *

35 | * 36 | *

37 | * Required in a Java EE environment 38 | *

39 | * 40 | *

41 | * {@link TransactionServices} is a per-deployment service. 42 | *

43 | * 44 | * @author David Allen 45 | * 46 | */ 47 | public interface TransactionServices extends Service { 48 | 49 | /** 50 | * Registers a synchronization object with the currently executing transaction. 51 | * 52 | * @see jakarta.transaction.Synchronization 53 | * @param synchronizedObserver the synchronization 54 | * @throws RuntimeException if a problem occurs during registration, the {@link RuntimeException#getCause()} should return 55 | * the original exception so that 56 | * Weld could easily distinguish possible registration problems 57 | */ 58 | void registerSynchronization(Synchronization synchronizedObserver); 59 | 60 | /** 61 | * Queries the status of the current execution to see if a transaction is currently active. 62 | * 63 | * @return true if a transaction is active 64 | */ 65 | boolean isTransactionActive(); 66 | 67 | /** 68 | * Obtain a reference to the JTA UserTransaction 69 | * 70 | * @return a reference to the JTA UserTransaction 71 | */ 72 | UserTransaction getUserTransaction(); 73 | } 74 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/ResourceInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi; 18 | 19 | import jakarta.enterprise.inject.spi.DefinitionException; 20 | import jakarta.enterprise.inject.spi.InjectionPoint; 21 | 22 | import org.jboss.weld.bootstrap.api.Service; 23 | 24 | /** 25 | * A container should implement this interface to allow the Weld to resolve Resources 26 | * 27 | * {@link ResourceInjectionServices} is per-module service. 28 | * 29 | * @author Pete Muir 30 | * @author Jozef Hartinger 31 | * 32 | */ 33 | public interface ResourceInjectionServices extends Service { 34 | 35 | /** 36 | * Register a resource injection point. The implementation validates the injection point. If the validation passes, an 37 | * instance of {@link ResourceReferenceFactory} is returned which may be used at runtime for creating instances of the 38 | * resource. 39 | * 40 | * @param injectionPoint the injection point metadata 41 | * @return resource factory 42 | * @throws DefinitionException if the injection point is not annotated with @Resource, if the injection point is a method 43 | * that doesn't follow JavaBean conventions or if the injection point type does not match the resource type 44 | * @throws IllegalStateException if no resource can be resolved 45 | */ 46 | ResourceReferenceFactory registerResourceInjectionPoint(InjectionPoint injectionPoint); 47 | 48 | /** 49 | * Register a resource injection point with the given JNDI name and mapped name. The implementation validates the injection 50 | * point. If the validation passes, an instance of {@link ResourceReferenceFactory} is returned which may be used at runtime 51 | * for creating instances of the resource. 52 | * 53 | * @param jndiName JNDI name 54 | * @param mappedName mapped name 55 | * @return resource factory 56 | * @throws IllegalStateException if no resource can be resolved 57 | * @throws IllegalArgumentException if both jndiName and mappedName are null 58 | */ 59 | ResourceReferenceFactory registerResourceInjectionPoint(String jndiName, String mappedName); 60 | 61 | } -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/construction/api/WeldCreationalContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.construction.api; 18 | 19 | import jakarta.enterprise.context.spi.CreationalContext; 20 | import jakarta.interceptor.AroundConstruct; 21 | import jakarta.interceptor.Interceptors; 22 | 23 | /** 24 | * Extended version of {@link CreationalContext} which gives the integrator additional control over the process of constructing 25 | * an instance. 26 | * 27 | * @author Jozef Hartinger 28 | * 29 | */ 30 | public interface WeldCreationalContext extends CreationalContext { 31 | 32 | /** 33 | * By default Weld takes care of {@link AroundConstruct} interceptors of a component instance which are bound to the 34 | * component using interceptor bindings or 35 | * the {@link Interceptors} annotation. This may not be desired should an integrator want to manage these interceptors 36 | * themselves. In that case this switch 37 | * may be used to suppress Weld management of {@link AroundConstruct} interceptors. In that case an integrator is 38 | * responsible for performing 39 | * {@link AroundConstruct} interception. 40 | * 41 | * @see #registerAroundConstructCallback(AroundConstructCallback) 42 | * 43 | * @param value the value 44 | */ 45 | void setConstructorInterceptionSuppressed(boolean value); 46 | 47 | /** 48 | * Indicates whether Weld-managed {@link AroundConstruct} interceptors are suppressed. 49 | * 50 | * @see #setConstructorInterceptionSuppressed(boolean) 51 | * 52 | * @return true if Weld-managed {@link AroundConstruct} interceptors are suppressed 53 | */ 54 | boolean isConstructorInterceptionSuppressed(); 55 | 56 | /** 57 | * Register a callback which is notified of component construction. This callback allows an integrator to perform additional 58 | * tasks (e.g. invoking 59 | * interceptors bound using the deployment descriptor) around constructor invocation. {@link AroundConstructCallback}s are 60 | * invoked in the order in which 61 | * they were registered. 62 | * 63 | * @param callback the callback 64 | */ 65 | void registerAroundConstructCallback(AroundConstructCallback callback); 66 | } 67 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api; 18 | 19 | import java.util.Set; 20 | 21 | import org.jboss.weld.bootstrap.spi.EEModuleDescriptor; 22 | 23 | /** 24 | * Represents an environment. Specifies the services Weld requires 25 | * 26 | * @author Pete Muir 27 | */ 28 | public interface Environment { 29 | 30 | /** 31 | * The deployment scoped services required for this environment 32 | * 33 | * @return the services to require 34 | */ 35 | Set> getRequiredDeploymentServices(); 36 | 37 | /** 38 | * The bean deployment archive scoped services required for this environment 39 | * 40 | * @return the services to require 41 | */ 42 | Set> getRequiredBeanDeploymentArchiveServices(); 43 | 44 | /** 45 | * Environment aware of EE modules. In such environment each bean archive which belongs to a module should register 46 | * {@link EEModuleDescriptor} 47 | * 48 | * @return true by default 49 | */ 50 | default boolean isEEModulesAware() { 51 | return true; 52 | } 53 | 54 | /** 55 | * Since CDI 4.0, there is a requirement to fire {@link jakarta.enterprise.event.Startup} event when the container 56 | * is ready to accept requests and {@link jakarta.enterprise.event.Shutdown} before container shutdown. 57 | * 58 | *

59 | * By default, Weld fires these events close to {@code @Initialized(ApplicationScoped.class)}. 60 | * However, integrators may choose to fire it at later point if they, for instance, need to make sure other 61 | * related technologies or libraries also bootstrap successfully. 62 | *

63 | * 64 | *

65 | * Overriding this method and returning {@code false} means that Weld will not attempt to fire these events and 66 | * this responsibility then lies with the integrator. 67 | *

68 | * 69 | * @see jakarta.enterprise.event.Startup 70 | * @see jakarta.enterprise.event.Shutdown 71 | * 72 | * @return true by default 73 | */ 74 | default boolean automaticallyHandleStartupShutdownEvents() { 75 | return true; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/context/WeldAlterableContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2018, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.context; 18 | 19 | import java.util.Collection; 20 | 21 | import jakarta.enterprise.context.spi.AlterableContext; 22 | 23 | import org.jboss.weld.context.api.ContextualInstance; 24 | 25 | /** 26 | * Enriched version of {@link AlterableContext} which allows to capture all instances from given context or to set them to 27 | * previously obtained values. 28 | * 29 | * Most built-in contexts implement this in order to support context propagation. Exception are {@link ApplicationContext} which 30 | * works out of the box and then {@link SingletonContext} and {@link DependentContext} which are not to be propagated. 31 | * 32 | * @author Matej Novotny 33 | */ 34 | public interface WeldAlterableContext extends AlterableContext { 35 | 36 | /** 37 | * Retrieves set of {@link ContextualInstance} within the context. This entails all instances that were created up to this 38 | * point - Weld creates 39 | * them lazily so unless some beans were already used, they have not been stored. 40 | * 41 | * @return Set of all {@link ContextualInstance} existing in this context 42 | */ 43 | default Collection> getAllContextualInstances() { 44 | throw new UnsupportedOperationException( 45 | "getAllContextualInstances() is not implemented for context " + this.getClass()); 46 | } 47 | 48 | /** 49 | * Clears the backing bean store and feeds it with the set of {@link ContextualInstance} provided as parameter. 50 | * All {@link ContextualInstance} have to belong to the same scope as does this {@link WeldAlterableContext} otherwise 51 | * {@code IllegalArgumentException} is thrown. 52 | * 53 | * @param setOfInstances set of {@link ContextualInstance} which are to become the new bean store for this context 54 | * @throws IllegalArgumentException if {@link ContextualInstance}s belong to different scope than this context 55 | */ 56 | default void clearAndSet(Collection> setOfInstances) { 57 | throw new UnsupportedOperationException("clearAndSet is not implemented for context " + this.getClass()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/EEModuleDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2015, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.spi; 18 | 19 | import org.jboss.weld.bootstrap.api.Service; 20 | import org.jboss.weld.bootstrap.spi.helpers.EEModuleDescriptorImpl; 21 | 22 | /** 23 | * In Java EE environment, each {@link BeanDeploymentArchive} should provide a description of the Java EE module it belongs to 24 | * (WAR, RAR, etc.). This applies to physical bean archives deployed within the given module and also to logical bean archives 25 | * that belong to the module. 26 | * Bean archives that are not part of a Java EE module (e.g. built-in server libraries) are not required to have a 27 | * {@link EEModuleDescriptor} service registered. 28 | * 29 | *

30 | * {@link EEModuleDescriptor} is a per-BDA service. 31 | *

32 | * 33 | *

34 | * It is recommended to share an immutable {@link EEModuleDescriptor} instance for all bean deployment archives of the same Java 35 | * EE module. 36 | * However, each bean deployment archive may register its own {@link EEModuleDescriptor} instance. In this case, all descriptors 37 | * representing a given EE module must use the same id and type. 38 | *

39 | * 40 | * @author Jozef Hartinger 41 | * @author Martin Kouba 42 | * @see EEModuleDescriptorImpl 43 | */ 44 | public interface EEModuleDescriptor extends Service { 45 | 46 | /** 47 | * Enumeration of possible EE module types 48 | * 49 | * @author Jozef Hartinger 50 | * 51 | */ 52 | public enum ModuleType { 53 | /** 54 | * Enterprise archive libraries (ear/lib) 55 | */ 56 | EAR, 57 | /** 58 | * Web modules (wars) 59 | */ 60 | WEB, 61 | /** 62 | * EJB archive 63 | */ 64 | EJB_JAR, 65 | /** 66 | * Application client modules 67 | */ 68 | APPLICATION_CLIENT, 69 | /** 70 | * Connector modules (rar) 71 | */ 72 | CONNECTOR 73 | } 74 | 75 | /** 76 | * @return a unique identifier of an EE module a given {@link BeanDeploymentArchive} belongs to. 77 | */ 78 | String getId(); 79 | 80 | /** 81 | * Indicates which type of module this descriptor represents. 82 | * 83 | * @return the type of module 84 | */ 85 | ModuleType getType(); 86 | } 87 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ForwardingServiceRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.api.helpers; 18 | 19 | import java.util.Collection; 20 | import java.util.Iterator; 21 | import java.util.Map.Entry; 22 | import java.util.Optional; 23 | import java.util.Set; 24 | 25 | import org.jboss.weld.bootstrap.api.Service; 26 | import org.jboss.weld.bootstrap.api.ServiceRegistry; 27 | 28 | /** 29 | * An implementation of {@link ServiceRegistry} which forwards all its method calls to another {@link ServiceRegistry} 30 | * Subclasses should override one or more methods to modify the behavior of the backing {@link ServiceRegistry} as 31 | * desired per the decorator pattern. 32 | * 33 | */ 34 | public abstract class ForwardingServiceRegistry implements ServiceRegistry { 35 | 36 | /** 37 | * Returns the delegate 38 | * 39 | * @return delegate 40 | */ 41 | protected abstract ServiceRegistry delegate(); 42 | 43 | public void add(Class type, S service) { 44 | delegate().add(type, service); 45 | } 46 | 47 | public boolean contains(Class type) { 48 | return delegate().contains(type); 49 | } 50 | 51 | public S get(Class type) { 52 | return delegate().get(type); 53 | } 54 | 55 | @Override 56 | public Optional getOptional(Class type) { 57 | return delegate().getOptional(type); 58 | } 59 | 60 | public Iterator iterator() { 61 | return delegate().iterator(); 62 | } 63 | 64 | public void addAll(Collection, Service>> services) { 65 | delegate().addAll(services); 66 | } 67 | 68 | public Set, Service>> entrySet() { 69 | return delegate().entrySet(); 70 | } 71 | 72 | public void cleanup() { 73 | delegate().cleanup(); 74 | } 75 | 76 | public void cleanupAfterBoot() { 77 | delegate().cleanupAfterBoot(); 78 | } 79 | 80 | @Override 81 | public S getRequired(Class type) { 82 | return delegate().getRequired(type); 83 | } 84 | 85 | @Override 86 | public S addIfAbsent(Class type, S service) { 87 | return delegate().addIfAbsent(type, service); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/injection/spi/JpaInjectionServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.injection.spi; 18 | 19 | import jakarta.enterprise.inject.spi.InjectionPoint; 20 | import jakarta.persistence.EntityManager; 21 | import jakarta.persistence.EntityManagerFactory; 22 | import jakarta.persistence.PersistenceContext; 23 | import jakarta.persistence.PersistenceUnit; 24 | 25 | import org.jboss.weld.bootstrap.api.Service; 26 | 27 | /** 28 | * A container should implement this interface to allow the Weld RI to resolve JPA persistence units and discover entities 29 | * 30 | * {@link JpaInjectionServices} is a per-module service. 31 | * 32 | * @author Pete Muir 33 | * @author Jozef Hartinger 34 | * 35 | */ 36 | public interface JpaInjectionServices extends Service { 37 | 38 | /** 39 | * Register a persistence context injection point. The implementation validates the injection point. If the validation 40 | * passes, an instance of {@link ResourceReferenceFactory} is returned which may be used at runtime for creating instances 41 | * of the resource. 42 | * 43 | * @param injectionPoint the injection point metadata 44 | * @return factory for obtaining {@link EntityManager} instances 45 | * @throws IllegalArgumentException if the injection point is not annotated with {@link PersistenceContext}, 46 | * if the injection point is a method that doesn't follow JavaBean conventions or if the injection 47 | * @throws IllegalStateException if no suitable persistence units can be resolved 48 | */ 49 | ResourceReferenceFactory registerPersistenceContextInjectionPoint(InjectionPoint injectionPoint); 50 | 51 | /** 52 | * Register a persistence unit injection point. The implementation validates the injection point. If the validation passes, 53 | * an instance of {@link ResourceReferenceFactory} is returned which may be used at runtime for creating instances of the 54 | * resource. 55 | * 56 | * @param injectionPoint the injection point metadata 57 | * @return factory for obtaining {@link EntityManagerFactory} instances 58 | * @throws IllegalArgumentException if the injection point is not annotated with {@link PersistenceUnit}, or, 59 | * if the injection point is a method that doesn't follow JavaBean conventions 60 | * @throws IllegalStateException if no suitable persistence units can be resolved 61 | */ 62 | ResourceReferenceFactory registerPersistenceUnitInjectionPoint(InjectionPoint injectionPoint); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/construction/api/AroundConstructCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2013, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.construction.api; 18 | 19 | import java.util.Map; 20 | 21 | import jakarta.enterprise.inject.spi.AnnotatedConstructor; 22 | import jakarta.interceptor.InvocationContext; 23 | 24 | /** 25 | * An implementation of this interface may be registered with a {@link WeldCreationalContext}. Weld will then call the 26 | * {@link #aroundConstruct(ConstructionHandle, AnnotatedConstructor, Object[], Map)} method of the implementation during 27 | * component creation, allowing an 28 | * integrator to perform additional steps (e.g. invoking interceptors bound using the deployment descriptor) around component 29 | * construction. 30 | * 31 | * @author Jozef Hartinger 32 | * 33 | * @see WeldCreationalContext#registerAroundConstructCallback(AroundConstructCallback) 34 | * 35 | * @param type the component class 36 | */ 37 | public interface AroundConstructCallback { 38 | 39 | /** 40 | * The method is called during component creation, allowing an integrator to perform additional steps (e.g. invoking 41 | * interceptors bound using the deployment 42 | * descriptor) around component construction. 43 | * 44 | * @param handle the handle for controlling the component creation process and retrieving the created instance 45 | * @param constructor a representation of the component constructor used for component creation 46 | * @param parameters the parameters that will be passed to the component constructor. These parameters should be made 47 | * available to {@link jakarta.interceptor.AroundConstruct} 48 | * interceptors through the {@link InvocationContext#getParameters()} method. An implementation is free to modify the 49 | * parameters or provide a 50 | * different parameter array to the {@link ConstructionHandle}. 51 | * @param data the context data associated with this {@link jakarta.interceptor.AroundConstruct} interception. The data 52 | * should be made available to {@link jakarta.interceptor.AroundConstruct} 53 | * interceptors through {@link InvocationContext#getContextData()}. An implementation is free to modify the map or to 54 | * provide a different one to the 55 | * {@link ConstructionHandle}. 56 | * @return the created instance 57 | * @throws Exception any underlying exception is propagated directly 58 | */ 59 | T aroundConstruct(ConstructionHandle handle, AnnotatedConstructor constructor, Object[] parameters, 60 | Map data) throws Exception; 61 | } 62 | -------------------------------------------------------------------------------- /weld/src/main/java/org/jboss/weld/bootstrap/event/InterceptorConfigurator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2016, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.bootstrap.event; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.util.Set; 21 | import java.util.function.BiFunction; 22 | import java.util.function.Function; 23 | 24 | import jakarta.enterprise.inject.spi.Bean; 25 | import jakarta.enterprise.inject.spi.InterceptionType; 26 | import jakarta.enterprise.inject.spi.Interceptor; 27 | import jakarta.interceptor.InvocationContext; 28 | 29 | /** 30 | * Allows to configure a new {@link Interceptor} instance. 31 | * 32 | * @author Tomas Remes 33 | * @see WELD-2008 34 | */ 35 | public interface InterceptorConfigurator { 36 | 37 | /** 38 | * @param interceptionType specifies an interception type, e.g. around invoke, post construct, ... 39 | * @param interceptorFunction a function holding the interception logic 40 | * @return self 41 | */ 42 | InterceptorConfigurator intercept(InterceptionType interceptionType, 43 | Function interceptorFunction); 44 | 45 | /** 46 | * @param interceptionType specifies an interception type, e.g. around invoke, post construct, ... 47 | * @param interceptorFunction a function holding the interception logic 48 | * @return self 49 | */ 50 | InterceptorConfigurator interceptWithMetadata(InterceptionType interceptionType, 51 | BiFunction, Object> interceptorFunction); 52 | 53 | /** 54 | * Adds interceptor binding annotation. 55 | * 56 | * @param binding interceptor binding to add 57 | * @return self 58 | */ 59 | InterceptorConfigurator addBinding(Annotation binding); 60 | 61 | /** 62 | * Adds interceptor binding annotations. 63 | * 64 | * @param bindings interceptor bindings to add 65 | * @return self 66 | */ 67 | InterceptorConfigurator addBindings(Annotation... bindings); 68 | 69 | /** 70 | * Adds set of interceptor binding annotations. 71 | * 72 | * @param bindings interceptor bindings to add 73 | * @return self 74 | */ 75 | InterceptorConfigurator addBindings(Set bindings); 76 | 77 | /** 78 | * Replace all bindings 79 | * 80 | * @param bindings - new bindings to be set 81 | * @return self 82 | */ 83 | InterceptorConfigurator bindings(Annotation... bindings); 84 | 85 | /** 86 | * Adds priority annotation. 87 | * 88 | * @param priority value 89 | * @return self 90 | */ 91 | InterceptorConfigurator priority(int priority); 92 | 93 | } 94 | -------------------------------------------------------------------------------- /weld-spi/src/main/java/org/jboss/weld/security/spi/SecurityServices.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2010, Red Hat, Inc., and individual contributors 4 | * by the @authors tag. See the copyright.txt in the distribution for a 5 | * full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.weld.security.spi; 18 | 19 | import java.security.Principal; 20 | import java.util.function.Consumer; 21 | 22 | import org.jboss.weld.bootstrap.api.Service; 23 | 24 | /** 25 | * Responsible for accessing security related functionality the environment can provide. 26 | * 27 | *

28 | * Required in a Java EE environment. {@link SecurityServices} is a per-deployment service. 29 | *

30 | * 31 | *

32 | * An integrator should either implement {@link #getSecurityContext()} or {@link #getSecurityContextAssociator()}. By default, 33 | * the 34 | * {@link #getSecurityContextAssociator()} method delegates to {@link #getSecurityContext()}. The container always calls the 35 | * {@link #getSecurityContextAssociator()} method. 36 | *

37 | * 38 | * @author pmuir 39 | * @author Jozef Hartinger 40 | * 41 | */ 42 | public interface SecurityServices extends Service { 43 | 44 | /** 45 | * Obtain the Principal representing the current caller identity 46 | * 47 | * @return the Principal representing the current caller identity 48 | */ 49 | Principal getPrincipal(); 50 | 51 | /** 52 | * Obtain the security context associated with the current thread. This method is used by Weld to propagate the security 53 | * context of the current thread to 54 | * different threads. 55 | * 56 | *

57 | * By default, a noop fallback implementation is returned. 58 | *

59 | * 60 | * @return the security context associated with the current thread 61 | * @since 3.0 62 | */ 63 | default SecurityContext getSecurityContext() { 64 | return SecurityContext.NOOP_SECURITY_CONTEXT; 65 | } 66 | 67 | /** 68 | * Obtain the security context associated with the current thread and associate this context when an action is performed. 69 | * This method is used by Weld to propagate the security context of the current thread to 70 | * different threads. 71 | * 72 | *

73 | * By default, the consumer is using {@link #getSecurityContext()} to associate the security context. 74 | *

75 | * 76 | * @return a consumer that accepts an action to be performed with the security context associated with the current thread 77 | */ 78 | default Consumer getSecurityContextAssociator() { 79 | final SecurityContext securityContext = getSecurityContext(); 80 | return (action) -> { 81 | try { 82 | securityContext.associate(); 83 | action.run(); 84 | } finally { 85 | securityContext.dissociate(); 86 | securityContext.close(); 87 | } 88 | }; 89 | } 90 | 91 | } 92 | --------------------------------------------------------------------------------