Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: future release
    • Component/s: OSGi-JavaEE
    • Labels:
      None

      Description

      We should explore use of CDI event mechanism for OSGi event admin

        Activity

        Hide
        TangYong added a comment -

        Splited patch for GLASSFISH-15365 is uploaded, please seeing GLASSFISH-15365-patch-20121211.zip.

        Show
        TangYong added a comment - Splited patch for GLASSFISH-15365 is uploaded, please seeing GLASSFISH-15365 -patch-20121211.zip.
        Hide
        TangYong added a comment -

        Because GLASSFISH-19359 has been resolved, now, starting to enter into fighterfish test phrase.

        Show
        TangYong added a comment - Because GLASSFISH-19359 has been resolved, now, starting to enter into fighterfish test phrase.
        Hide
        TangYong added a comment -

        Currently, WAB's OSGi/CDI event integration is blocked by GLASSFISH-19359 and waiting for siva and sahoo's confirmation.

        Show
        TangYong added a comment - Currently, WAB's OSGi/CDI event integration is blocked by GLASSFISH-19359 and waiting for siva and sahoo's confirmation.
        Hide
        TangYong added a comment -

        However, there is a bug which is in process of investigation.
        Once the observer method is in a servlet of WAB, the observer has not been triggered.

        Show
        TangYong added a comment - However, there is a bug which is in process of investigation. Once the observer method is in a servlet of WAB, the observer has not been triggered.
        Hide
        TangYong added a comment -

        Currently, event integration has been tested between multi plain osgi bundles successfully, the following displayed that event callback method(OnServiceRegistered) can be called many times once MyServiceInf's implementation is available.

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|MyService has been registered OSGi Service!|#]

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|SimpleStockQuoteServiceImpl::Initializing quotes|#]

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|SimpleStockQuoteServiceImpl::getSymbols|#]

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|Registered:[IBM, MSFT, HPQ, ORCL]|#]

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|OnServiceRegistered() method is getting : [org.acme.myservice.api.MyServiceInf]|#]

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|OnServiceRegistered(): MyService: Hello Word!|#]

        [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|Started sample.osgicdi.myservice [284]|#]

        [#|2012-11-19T22:44:35.671+0900|INFO|44.0|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675671;_LevelValue=800;|myservice was successfully deployed in 109 milliseconds.|#]

        [#|2012-11-19T22:45:09.906+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332709906;_LevelValue=800;|Stopped sample.osgicdi.myservice [284]|#]

        [#|2012-11-19T22:45:09.921+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332709921;_LevelValue=800;|Uninstalled sample.osgicdi.myservice [284]|#]

        [#|2012-11-19T22:45:19.250+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719250;_LevelValue=800;|Installed sample.osgicdi.myservice [285] from reference:file:/D:/gf/1102/glassfish3/glassfish/domains/domain1/applications/myservice/|#]

        [#|2012-11-19T22:45:19.250+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719250;_LevelValue=800;|Hello!|#]

        [#|2012-11-19T22:45:19.265+0900|INFO|44.0|org.jboss.weld.Bootstrap|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719265;_LevelValue=800;|WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|MyService has been registered OSGi Service!|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|SimpleStockQuoteServiceImpl::Initializing quotes|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|SimpleStockQuoteServiceImpl::getSymbols|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|Registered:[IBM, MSFT, HPQ, ORCL]|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|OnServiceRegistered() method is getting : [org.acme.myservice.api.MyServiceInf]|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|OnServiceRegistered(): MyService: Hello Word!|#]

        [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|Started sample.osgicdi.myservice [285]|#]

        Show
        TangYong added a comment - Currently, event integration has been tested between multi plain osgi bundles successfully, the following displayed that event callback method(OnServiceRegistered) can be called many times once MyServiceInf's implementation is available. [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|MyService has been registered OSGi Service!|#] [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|SimpleStockQuoteServiceImpl::Initializing quotes|#] [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|SimpleStockQuoteServiceImpl::getSymbols|#] [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|Registered: [IBM, MSFT, HPQ, ORCL] |#] [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|OnServiceRegistered() method is getting : [org.acme.myservice.api.MyServiceInf] |#] [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|OnServiceRegistered(): MyService: Hello Word!|#] [#|2012-11-19T22:44:35.656+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675656;_LevelValue=800;|Started sample.osgicdi.myservice [284] |#] [#|2012-11-19T22:44:35.671+0900|INFO|44.0|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332675671;_LevelValue=800;|myservice was successfully deployed in 109 milliseconds.|#] [#|2012-11-19T22:45:09.906+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332709906;_LevelValue=800;|Stopped sample.osgicdi.myservice [284] |#] [#|2012-11-19T22:45:09.921+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332709921;_LevelValue=800;|Uninstalled sample.osgicdi.myservice [284] |#] [#|2012-11-19T22:45:19.250+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719250;_LevelValue=800;|Installed sample.osgicdi.myservice [285] from reference: file:/D:/gf/1102/glassfish3/glassfish/domains/domain1/applications/myservice/ |#] [#|2012-11-19T22:45:19.250+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719250;_LevelValue=800;|Hello!|#] [#|2012-11-19T22:45:19.265+0900|INFO|44.0|org.jboss.weld.Bootstrap|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719265;_LevelValue=800;|WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.|#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|MyService has been registered OSGi Service!|#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|SimpleStockQuoteServiceImpl::Initializing quotes|#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|SimpleStockQuoteServiceImpl::getSymbols|#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|Registered: [IBM, MSFT, HPQ, ORCL] |#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|OnServiceRegistered() method is getting : [org.acme.myservice.api.MyServiceInf] |#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|OnServiceRegistered(): MyService: Hello Word!|#] [#|2012-11-19T22:45:19.281+0900|INFO|44.0|javax.enterprise.logging.stdout|_ThreadID=12;_ThreadName=admin-listener(1);_TimeMillis=1353332719281;_LevelValue=800;|Started sample.osgicdi.myservice [285] |#]
        Hide
        TangYong added a comment -

        CDI/OSGi Event Integration is in progress. Now, desgin of the integration is as following:

        1 CDI/OSGi Event API

        1) defining three CDI/OSGi Events

        ・ServiceRegistered
        ・ServiceModified
        ・ServiceUnregistering

        2) defining a @ServiceContract Qualifier used for qualifying CDI/OSGi event

        @Target(

        { PARAMETER }

        )
        @Retention(RetentionPolicy.RUNTIME)
        @Documented
        @Qualifier
        public @interface ServiceContract {
        /**

        • The specification class filtering the received
        • {@link javax.enterprise.event.Event}

          .
          */
          Class<?> value();
          }

        By 1) and 2), a user can write the following observer method:

        public void postOnActivator(@Observes @ServiceContract(StockQuoteService.class) ServiceRegistered event)

        { System.out.println("postOnActivator() method is getting : " + event.getServiceContractNames()); Set<String> set = ((StockQuoteService)event.getService()).getSymbols(); ... }

        2 OSGi Service Listening
        Adding ServiceListener into OSGiCDIContainerActivator and wraping OSGi Service Event into CDI/OSGi Event

        3 Firing CDI/OSGi Event using CDI Event Interface
        Here, I use Instance<Object> to select Event<Object> and fire CDI/OSGi Event. In order to get Instance<Object>, I need to register Instance<Object> related each Weld Container Instance as OSGi Services while getting Instance<Object> from OSGiServiceExtension class.

        Note: while using Instance<Object> to select Event<Object>, Weld will call ACLSingletonProvider.get() , so we must take care of set TCCL.

        4 Handling Instance<Object>'s Unregistering
        While a bundle is in process of stopping or uninstalled, we must unregister OSGi Service of Instance<Object> which belongs to current bundle.

        [Current State Of Integration]
        Prototype has been made and fixing some bugs.

        Show
        TangYong added a comment - CDI/OSGi Event Integration is in progress. Now, desgin of the integration is as following: 1 CDI/OSGi Event API 1) defining three CDI/OSGi Events ・ServiceRegistered ・ServiceModified ・ServiceUnregistering 2) defining a @ServiceContract Qualifier used for qualifying CDI/OSGi event @Target( { PARAMETER } ) @Retention(RetentionPolicy.RUNTIME) @Documented @Qualifier public @interface ServiceContract { /** The specification class filtering the received {@link javax.enterprise.event.Event} . */ Class<?> value(); } By 1) and 2), a user can write the following observer method: public void postOnActivator(@Observes @ServiceContract(StockQuoteService.class) ServiceRegistered event) { System.out.println("postOnActivator() method is getting : " + event.getServiceContractNames()); Set<String> set = ((StockQuoteService)event.getService()).getSymbols(); ... } 2 OSGi Service Listening Adding ServiceListener into OSGiCDIContainerActivator and wraping OSGi Service Event into CDI/OSGi Event 3 Firing CDI/OSGi Event using CDI Event Interface Here, I use Instance<Object> to select Event<Object> and fire CDI/OSGi Event. In order to get Instance<Object>, I need to register Instance<Object> related each Weld Container Instance as OSGi Services while getting Instance<Object> from OSGiServiceExtension class. Note: while using Instance<Object> to select Event<Object>, Weld will call ACLSingletonProvider.get() , so we must take care of set TCCL. 4 Handling Instance<Object>'s Unregistering While a bundle is in process of stopping or uninstalled, we must unregister OSGi Service of Instance<Object> which belongs to current bundle. [Current State Of Integration] Prototype has been made and fixing some bugs.

          People

          • Assignee:
            Sanjeeb Sahoo
            Reporter:
            Sanjeeb Sahoo
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: