[GLASSFISH-16805] [osgi-cdi] support @Inject @OSGiService Instance<T> Created: 06/Jun/11  Updated: 22/Nov/12

Status: Open
Project: glassfish
Component/s: OSGi-JavaEE
Affects Version/s: 3.1
Fix Version/s: not determined

Type: Improvement Priority: Major
Reporter: Sanjeeb Sahoo Assignee: Sivakumar Thyagarajan
Resolution: Unresolved Votes: 1
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Sub-Tasks:
Key
Summary
Type
Status
Assignee
GLASSFISH-18978 select OSGi services used in CDI bean... Sub-task Open Sanjeeb Sahoo  
Tags: 3_1-next

 Description   

Currently having something like
@Inject @OSGiService(dynamic=true)
private Instance<AdminService> adminService;

cause following exception:

java.lang.UnsupportedOperationException: Injection target type javax.enterprise.inject.Instance<org.glassfish.fighterfish.test.app18.AdminService>not supported
at org.glassfish.osgicdi.impl.OSGiServiceExtension.afterBeanDiscovery(OSGiServiceExtension.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:88)
at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:52)
at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:43)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:372)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:270)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:55)
at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:43)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:372)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
... 17 more

#]


 Comments   
Comment by Sanjeeb Sahoo [ 06/Jun/11 ]

assigning to Siva for evaluation.

Comment by Sivakumar Thyagarajan [ 07/Jun/11 ]

Tagging this as 3_1-next, as this is not critical for the 3.1.1 release.

Comment by Sanjeeb Sahoo [ 07/Jun/11 ]

Do you know why it is not working? Can you at least mention the reason?

Comment by Sivakumar Thyagarajan [ 13/Jun/11 ]

Marked it as an improvement(RFE)

Comment by Tom Mueller [ 06/Mar/12 ]

Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

Comment by TangYong [ 06/Aug/12 ]

Now, the feature has been supported combined with subTask(GLASSFISH-18978). Please see.

https://github.com/tangyong/gf-cdi-osgi-integration

DEMO1: https://github.com/tangyong/gf-cdi-osgi-integration/tree/master/samples/[RFP146]CDI018
DEMO2: https://github.com/tangyong/gf-cdi-osgi-integration/tree/master/samples/[RFP146]CDI004

Using Way:

1 get all osgi services
@Inject Service<StockQuoteService> sqses;
....

2 get osgi services qualified @ServiceFilter
@Inject @ServiceFilter("(country=CN)") Service<StockQuoteService> sqses;
...

Comment by TangYong [ 22/Nov/12 ]

After event integration was finished, the feature will start because compared with other features, it has been turned more important.

Generated at Thu Sep 03 02:56:54 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.