0 Replies Latest reply on May 15, 2013 5:49 AM by matiou

    JBoss AS 7.2.0.Alpha : Spring, Gemini Blueprint and WAB association

    matiou

      Hello guys,

       

      I'm using gemini blueprint in a WAB to discover services exposed by somes bundles deployed on JBoss OSGi container and all works fine, expect the reference-listener on the service consumed.

      Here's my use case :

       

      I have the bundle myServiceImpl which expose one service with gemini blueprint :

       

      (file META-INF/spring/app-context.xml)

       

      ...
      <bean id="myServiceBean" class="xxx.yyy.MyServiceImpl" init-method="startService" destroy-method="stopService"/>
      
      <osgi:service id="myServiceOsgi" ref="myServiceBean" interface="xxx.yyy.IMyService" />
      ...
      

       

      I have a WAB myWab which consumes the service exposed as below :

       

      (file src/main/webapp/WEB-INF/spring/app-context.xml)

      ...
      <bean class="xxx.yyy.ServiceListener" id="myServiceListener" />
      
      <osgi:list id="myServicesOsgi" interface="xxx.yyy.IMyService">
                <osgi:reference-listener bind-method="myBind" unbind-method="myUnbind" >
                          <ref bean="myServicesListener"/>
                </osgi:reference-listener>
      </osgi:list>
      ...
      

       

      (file src/main/java/xxx/yyy/zzz/ServiceListener.java)

      public class ServiceListener {
      
                public void myBind(IMyService myService, Map<String, Object> properties) throws Exception {
                          System.out.println("A binding is normally done");
                }
      
                public void myUnbind(Object myService, Map<String, Object> properties) throws Exception {
                          System.out.println("An unbinding is normally done");
                }
      }
      

       

      (file src/main/java/xxx/yyy/controller/FileUploadController.java)

      @Controller
      public class FileUploadController {
      
                private List<IMyService> myServices;
      
                @Autowired
                protected FileUploadController(@Value("#{myServicesOsgi}") List<IMyService> myServices) {
                          super();
                          this.myServices = myServices;
                }
      
                @RequestMapping(value="/post", method = RequestMethod.POST)
                @ResponseBody
                public String upload(MultipartFile file) throws IOException, Exception {
      
                          SomeClass someClass = new SomeClass(1L, file.getInputStream());
      
                          for (Iterator<IMyService> iterator = myServices.iterator(); iterator.hasNext();) {
                                    IMyService service = (IMyService) iterator.next();
                                    service.doSomeStuff(invoice);
                          }
      
                          return file.getOriginalFilename();
                }
      }
      

       

      When I upload a file on my IHM, I can see in the logs that the service defined by myServiceImpl is well called (and when others services are exposed by others bundle, these services are called too)

      However, If i stop the bundle myServiceImpl, the sentence "An unbinding is normally done" is not printed and so the listener seems not to be called.

       

      So I tried to do this (listening the services publication) outside of the Wab to be sure it wasn't an implementation problem.

      I have done a third bundle, named myServiceConsumer with exactly the same classes than the Wab :

      The class ServiceListener in a package src/main/java/xxx/yyy/zzz/

      The spring/gemini file in src/main/ressources/META-INF/spring

       

      I deployed this bundle on JBoss and when I start/stop myServiceImpl, I'm able to see the output as expected : "A binding is normally done"/"An unbinding is normally done".

       

      Any ideas ?

       

      Thanks in advance

       

      My conf :

      JBoss AS 7.2.0.Alpha

      org.eclipse.gemini 2.0.0.M02

      org.springframework 3.2.2.RELEASE