Skip to content

Commit

Permalink
Merge pull request #24480 from arjantijms/weld_411
Browse files Browse the repository at this point in the history
Integrate Weld 5.1.1
  • Loading branch information
dmatej authored Jun 27, 2023
2 parents 68571fa + 7ac421a commit 03d70e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion appserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@

<!-- Jakarta CDI -->
<jakarta.cdi-api.version>4.0.1</jakarta.cdi-api.version>
<weld.version>5.1.0.Final</weld.version>
<weld.version>5.1.1.Final</weld.version>
<jboss.classfilewriter.version>1.3.0.Final</jboss.classfilewriter.version>

<!-- Jakarta MVC -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Contributors to Eclipse Foundation.
* Copyright (c) 2021, 2023 Contributors to Eclipse Foundation.
* Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -72,6 +72,7 @@
import org.jboss.weld.bootstrap.WeldBootstrap;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.contexts.WeldCreationalContext;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.manager.api.WeldInjectionTarget;
import org.jboss.weld.manager.api.WeldManager;
import org.jvnet.hk2.annotations.Service;
Expand Down Expand Up @@ -379,9 +380,19 @@ public <T> T createInterceptorInstance(Class<T> interceptorClass, EjbDescriptor
// This happens when @Interceptor or @InterceptorBinding is used.
Interceptor interceptor = findEjbInterceptor(interceptorClass, ejbInterceptors);
if (interceptor != null) {
// using the ejb's creationalContext so we don't have to do any cleanup.
// the cleanup will be handled by weld when it clean's up the ejb.
Object instance = beanManager.getReference(interceptor, interceptorClass, creationalContext);
// Using the ejb's creationalContext so we don't have to do any cleanup.
// the cleanup will be handled by weld when it cleans up the ejb.

Object instance = null;
if (beanManager instanceof BeanManagerImpl) {
// Since Weld 5.1.1 the default beanManager.getReference method doesn't create a creational context
// for the Interceptor.
BeanManagerImpl beanManagerImpl = (BeanManagerImpl) beanManager;
instance = beanManagerImpl.getReference(interceptor, interceptorClass, creationalContext, false);
} else {
instance = beanManager.getReference(interceptor, interceptorClass, creationalContext);
}

return (T) instance;
}

Expand Down

0 comments on commit 03d70e3

Please sign in to comment.