Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Cdi extension fix #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jersey-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
<configuration>
<instructions>
<Private-Package>
com.sun.jersey.server.impl.cdi,
com.sun.jersey.server.impl.ejb,
com.sun.jersey.server.impl.managedbeans
</Private-Package>
Expand All @@ -193,6 +192,7 @@
com.sun.jersey.spi.container.servlet,
com.sun.jersey.api.core.servlet,
com.sun.jersey.api.container.servlet,
com.sun.jersey.server.impl.cdi,
<!-- the following is being used internally in GF REST API code! :-( -->
com.sun.jersey.server.impl.container.servlet
</Export-Package>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public CDIComponentProviderFactory(Object bm, ResourceConfig rc, WebApplication
beanManager = (BeanManager)bm;
// work around proxying bug in Weld
if (CDIExtension.lookupExtensionInBeanManager) {
extension = Utils.getInstance(beanManager, CDIExtension.class);
extension = Utils.getExtension(beanManager, CDIExtension.class);
}
else {
extension = CDIExtension.getInitializedExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import java.util.Collections;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.spi.Bean;
Expand Down Expand Up @@ -88,6 +89,15 @@ public static <T> T getInstance(BeanManager bm, Class<T> c) {
CreationalContext<?> cc = bm.createCreationalContext(b);
return c.cast(bm.getReference(b, c, cc));
}

public static <T> T getExtension(BeanManager bm, Class<T> clazz) {
Bean<?> bean = getBean(bm, clazz);
if (bean == null) {
return null;
}

return clazz.cast(bm.getContext(ApplicationScoped.class).get(bean));
}

private static boolean isSharedBaseClass(Class<?> c, Set<Bean<?>> bs) {
for (Bean<?> b : bs) {
Expand Down