[ 
https://issues.apache.org/jira/browse/DOSGI-115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Angelo updated DOSGI-115:
-------------------------

    Description: 
Today cxf-dosgi-ri-dsw-cxf supports only Spring DM. This goal of this issue is 
to modify cxf-dosgi-ri-dsw-cxf to support both Spring DM and Eclipse Gemini 
Blueprint.
The idea is : 

* 1) cxf-dosgi-ri-dsw-cxf :remove Spring DM dependencies (don't use directly 
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext and 
org.springframework.osgi.context.BundleContextAware) in this project but use a 
commons interface :

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container;

import java.util.List;

import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;

/**
 * OSGi Spring container API.
 * 
 * @author Angelo Zerr <[email protected]>
 * 
 */
public interface OsgiSpringContainer {

        /**
         * Publish the given springs files and returns the Spring
         * {@link ApplicationContext}.
         * 
         * @param springIntentLocations
         * @param bundleContext
         * @return
         */
        ApplicationContext publish(List<String> springIntentLocations,
                        BundleContext bundleContext);

        /**
         * Returns the {@link BundleContext} from the given Spring application
         * context.
         * 
         * @param context
         * @return
         */
        BundleContext getBundleContext(ApplicationContext context);
}
------------------------------------------------------------------------

1.1) In the class OsgiUtils:

do like this:

------------------------------------------------------------------------
ApplicationContext ctx = 
OsgiSpringContainerProvider.getContainer().publish(springIntentLocations, 
bundleContext);
------------------------------------------------------------------------

Instead of doing that: 

------------------------------------------------------------------------
//            
//            
//            OsgiBundleXmlApplicationContext ctx = new 
OsgiBundleXmlApplicationContext(springIntentLocations
//                .toArray(new String[] {}));
//            ctx.setPublishContextAsService(false);
//            ctx.setBundleContext(bundleContext);
//            ctx.refresh();
------------------------------------------------------------------------

1.2) In the Activator class: 

Implements ApplicationContextAware (instead of BundleContextAware) : 
public class Activator implements ManagedService, 
ApplicationContextAware/*,BundleContextAware*/ {

and implements setApplicationContext liek this 

------------------------------------------------------------------------
public void setApplicationContext(ApplicationContext context)
                        throws BeansException {
 bc = OsgiUtils.getBundleContext(context);
}
------------------------------------------------------------------------

where OsgiUtils.getBundleContext use the interface 

------------------------------------------------------------------------
public static BundleContext getBundleContext(ApplicationContext context) {
  return OsgiSpringContainerProvider.getContainer().getBundleContext(context);
}: 
------------------------------------------------------------------------

1.1) OsgiSpringContainerProvider:

The OsgiSpringContainerProvider use SPI ServiceRegistry to retrieves the 
implemententation of OsgiSpringContainer  : 

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container;

import java.util.Iterator;

import javax.imageio.spi.ServiceRegistry;

public class OsgiSpringContainerProvider {

        private static OsgiSpringContainer container;

        public static OsgiSpringContainer getContainer()
                        throws OsgiSpringContainerNotFoundException {
                if (container == null) {
                        container = getContainerFromFragment();
                }
                return container;
        }

        public static synchronized OsgiSpringContainer 
getContainerFromFragment()
                        throws OsgiSpringContainerNotFoundException {

                if (container != null) {
                        return container;
                }
                Iterator<OsgiSpringContainer> containers = ServiceRegistry
                                .lookupProviders(OsgiSpringContainer.class,
                                                
OsgiSpringContainerProvider.class.getClassLoader());
                while (containers.hasNext()) {
                        return containers.next();
                }
                throw new OsgiSpringContainerNotFoundException();
        }
}
------------------------------------------------------------------------

2) cxf-dosgi-ri-dsw-cxf-gemini : new project which is a fragment linked to 
cxf-dosgi-ri-dsw-cxf and register with SPI ServiceRegistry the Gemini BluePring 
implementation of OSgiSpringContainer : 

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container.geminiblueprint;

import java.util.List;

import org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer;
import 
org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;

public class GeminiBlueprintContainer
                implements OsgiSpringContainer {

        public ApplicationContext publish(List<String> springIntentLocations,
                        BundleContext bundleContext) {
                OsgiBundleXmlApplicationContext ctx = new 
OsgiBundleXmlApplicationContext(
                                springIntentLocations.toArray(new String[] {}));
                ctx.setPublishContextAsService(false);
                ctx.setBundleContext(bundleContext);
                ctx.refresh();
                return ctx;
        }
                
        public BundleContext getBundleContext(ApplicationContext context) {
                return 
((OsgiBundleXmlApplicationContext)context).getBundleContext();
        }
}
------------------------------------------------------------------------

This implementation is registered in the file 
META-INF/services/org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer : 

------------------------------------------------------------------------
org.apache.cxf.dosgi.dsw.container.geminiblueprint.GeminiBlueprintContainer
------------------------------------------------------------------------

This fragment has Eclipse Gemini Blueprint dependencies.

3) cxf-dosgi-ri-dsw-cxf-springdm: new project which is a fragment linked to 
cxf-dosgi-ri-dsw-cxf and register with SPI ServiceRegistry the SppringDM 
implementation of OSgiSpringContainer : 

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container.springdm;

import java.util.List;

import org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer;
import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;

public class SpringDMContainer implements
                OsgiSpringContainer {

        
        public ApplicationContext publish(List<String> springIntentLocations,
                        BundleContext bundleContext) {
                OsgiBundleXmlApplicationContext ctx = new 
OsgiBundleXmlApplicationContext(
                                springIntentLocations.toArray(new String[] {}));
                ctx.setPublishContextAsService(false);
                ctx.setBundleContext(bundleContext);
                ctx.refresh();
                return ctx;
        }
        
        public BundleContext getBundleContext(ApplicationContext context) {
                return 
((OsgiBundleXmlApplicationContext)context).getBundleContext();
        }

}
------------------------------------------------------------------------

This implementation is registered in the file 
META-INF/services/org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer : 

------------------------------------------------------------------------
org.apache.cxf.dosgi.dsw.container.springdm.SpringDMContainer
------------------------------------------------------------------------

This fragment has Spring DM dependencies.

4) Use cxf-dosgi-ri-dsw-cxf with Eclipse Gemini Blueprint

So to use cxf-dosgi-ri-dsw-cxf with Eclipse Gemini Blueprint, add in the OSGi 
container cxf-dosgi-ri-dsw-cxf+cxf-dosgi-ri-dsw-cxf-gemini

5) Use cxf-dosgi-ri-dsw-cxf with Spring DM 

So to use cxf-dosgi-ri-dsw-cxf with Spring DM, add in the OSGi container 
cxf-dosgi-ri-dsw-cxf+cxf-dosgi-ri-dsw-cxf-springdm

I don't know Gemini Aires, but if it is based on Spring, we could create a new 
fragment cxf-dosgi-ri-dsw-cxf-aires.

Hope you will like it this idea.

  was:
Today cxf-dosgi-ri-dsw-cxf supports only Spring DM. This goal of this issue is 
to modify cxf-dosgi-ri-dsw-cxf to support both Spring DM and Eclipse Gemini 
Blueprint.
The idea is : 

* 1) cxf-dosgi-ri-dsw-cxf :remove Spring DM dependencies (don't use directly 
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext and 
org.springframework.osgi.context.BundleContextAware) in this project but use a 
commons interface :

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container;

import java.util.List;

import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;

/**
 * OSGi Spring container API.
 * 
 * @author Angelo Zerr <[email protected]>
 * 
 */
public interface OsgiSpringContainer {

        /**
         * Publish the given springs files and returns the Spring
         * {@link ApplicationContext}.
         * 
         * @param springIntentLocations
         * @param bundleContext
         * @return
         */
        ApplicationContext publish(List<String> springIntentLocations,
                        BundleContext bundleContext);

        /**
         * Returns the {@link BundleContext} from the given Spring application
         * context.
         * 
         * @param context
         * @return
         */
        BundleContext getBundleContext(ApplicationContext context);
}
------------------------------------------------------------------------

1.1) In the class OsgiUtils:

do like this:

------------------------------------------------------------------------
ApplicationContext ctx = 
OsgiSpringContainerProvider.getContainer().publish(springIntentLocations, 
bundleContext);
------------------------------------------------------------------------

Instead of doing that: 

------------------------------------------------------------------------
//            
//            
//            OsgiBundleXmlApplicationContext ctx = new 
OsgiBundleXmlApplicationContext(springIntentLocations
//                .toArray(new String[] {}));
//            ctx.setPublishContextAsService(false);
//            ctx.setBundleContext(bundleContext);
//            ctx.refresh();
------------------------------------------------------------------------

1.2) In the Activator class: 

Implements ApplicationContextAware (instead of BundleContextAware) : 
public class Activator implements ManagedService, 
ApplicationContextAware/*,BundleContextAware*/ {

and implements setApplicationContext liek this 

------------------------------------------------------------------------
public void setApplicationContext(ApplicationContext context)
                        throws BeansException {
 bc = OsgiUtils.getBundleContext(context);
}
------------------------------------------------------------------------

where OsgiUtils.getBundleContext use the interface 

------------------------------------------------------------------------
public static BundleContext getBundleContext(ApplicationContext context) {
  return OsgiSpringContainerProvider.getContainer().getBundleContext(context);
}: 
------------------------------------------------------------------------

1.1) OsgiSpringContainerProvider:

The OsgiSpringContainerProvider use SPI ServiceRegistry to retrieves the 
implemententation of OsgiSpringContainer  : 

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container;

import java.util.Iterator;

import javax.imageio.spi.ServiceRegistry;

public class OsgiSpringContainerProvider {

        private static OsgiSpringContainer container;

        public static OsgiSpringContainer getContainer()
                        throws OsgiSpringContainerNotFoundException {
                if (container == null) {
                        container = getContainerFromFragment();
                }
                return container;
        }

        public static synchronized OsgiSpringContainer 
getContainerFromFragment()
                        throws OsgiSpringContainerNotFoundException {

                if (container != null) {
                        return container;
                }
                Iterator<OsgiSpringContainer> containers = ServiceRegistry
                                .lookupProviders(OsgiSpringContainer.class,
                                                
OsgiSpringContainerProvider.class.getClassLoader());
                while (containers.hasNext()) {
                        return containers.next();
                }
                throw new OsgiSpringContainerNotFoundException();
        }
}
------------------------------------------------------------------------

2) cxf-dosgi-ri-dsw-cxf-gemini : new project which is a fragment linked to 
cxf-dosgi-ri-dsw-cxf and register with SPI ServiceRegistry the Gemini BluePring 
implementation of OSgiSpringContainer : 

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container.geminiblueprint;

import java.util.List;

import org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer;
import 
org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;

public class GeminiBlueprintContainer
                implements OsgiSpringContainer {

        public ApplicationContext publish(List<String> springIntentLocations,
                        BundleContext bundleContext) {
                OsgiBundleXmlApplicationContext ctx = new 
OsgiBundleXmlApplicationContext(
                                springIntentLocations.toArray(new String[] {}));
                ctx.setPublishContextAsService(false);
                ctx.setBundleContext(bundleContext);
                ctx.refresh();
                return ctx;
        }
                
        public BundleContext getBundleContext(ApplicationContext context) {
                return 
((OsgiBundleXmlApplicationContext)context).getBundleContext();
        }
}
------------------------------------------------------------------------

This implementation is registered in the file 
META-INF/services/org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer : 

------------------------------------------------------------------------
org.apache.cxf.dosgi.dsw.container.geminiblueprint.GeminiBlueprintContainer
------------------------------------------------------------------------

This fragment has Eclipse Gemini Blueprint dependencies.

3) cxf-dosgi-ri-dsw-cxf-springdm: new project which is a fragment linked to 
cxf-dosgi-ri-dsw-cxf and register with SPI ServiceRegistry the SppringDM 
implementation of OSgiSpringContainer : 

------------------------------------------------------------------------
package org.apache.cxf.dosgi.dsw.container.springdm;

import java.util.List;

import org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer;
import org.osgi.framework.BundleContext;
import org.springframework.context.ApplicationContext;
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;

public class SpringDMContainer implements
                OsgiSpringContainer {

        
        public ApplicationContext publish(List<String> springIntentLocations,
                        BundleContext bundleContext) {
                OsgiBundleXmlApplicationContext ctx = new 
OsgiBundleXmlApplicationContext(
                                springIntentLocations.toArray(new String[] {}));
                ctx.setPublishContextAsService(false);
                ctx.setBundleContext(bundleContext);
                ctx.refresh();
                return ctx;
        }
        
        public BundleContext getBundleContext(ApplicationContext context) {
                return 
((OsgiBundleXmlApplicationContext)context).getBundleContext();
        }

}
------------------------------------------------------------------------

This implementation is registered in the file 
META-INF/services/org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer : 

------------------------------------------------------------------------
org.apache.cxf.dosgi.dsw.container.springdm.SpringDMContainer
------------------------------------------------------------------------

This fragment has Spring DM dependencies.

4) Use cxf-dosgi-ri-dsw-cxf with Eclipse Gemini Blueprint

So to use cxf-dosgi-ri-dsw-cxf with Eclipse Gemini Blueprint, add in the OSGi 
container cxf-dosgi-ri-dsw-cxf+cxf-dosgi-ri-dsw-cxf-gemini

5) Use cxf-dosgi-ri-dsw-cxf with Spring DM 

So to use cxf-dosgi-ri-dsw-cxf with Spring DM, add in the OSGi container 
cxf-dosgi-ri-dsw-cxf+cxf-dosgi-ri-dsw-cxf-springdm

I don't Gemini Aires, but if it is based on Spring, we could create a new 
fragment cxf-dosgi-ri-dsw-cxf-aires.

Hope you will like it this idea.

    
> Use Spring DM and Eclipse Gemini Blueprint with DOSGi
> -----------------------------------------------------
>
>                 Key: DOSGI-115
>                 URL: https://issues.apache.org/jira/browse/DOSGI-115
>             Project: CXF Distributed OSGi
>          Issue Type: New Feature
>          Components: DSW
>    Affects Versions: 1.4
>         Environment: Developped in Windows OS
>            Reporter: Angelo
>              Labels: patch
>             Fix For: 1.4
>
>         Attachments: cxf-dosgi-ri-dsw-Eclipse Projects cxf with Spring 
> DM+Eclipse Gemini Blueprint.zip
>
>
> Today cxf-dosgi-ri-dsw-cxf supports only Spring DM. This goal of this issue 
> is to modify cxf-dosgi-ri-dsw-cxf to support both Spring DM and Eclipse 
> Gemini Blueprint.
> The idea is : 
> * 1) cxf-dosgi-ri-dsw-cxf :remove Spring DM dependencies (don't use directly 
> org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext and 
> org.springframework.osgi.context.BundleContextAware) in this project but use 
> a commons interface :
> ------------------------------------------------------------------------
> package org.apache.cxf.dosgi.dsw.container;
> import java.util.List;
> import org.osgi.framework.BundleContext;
> import org.springframework.context.ApplicationContext;
> /**
>  * OSGi Spring container API.
>  * 
>  * @author Angelo Zerr <[email protected]>
>  * 
>  */
> public interface OsgiSpringContainer {
>       /**
>        * Publish the given springs files and returns the Spring
>        * {@link ApplicationContext}.
>        * 
>        * @param springIntentLocations
>        * @param bundleContext
>        * @return
>        */
>       ApplicationContext publish(List<String> springIntentLocations,
>                       BundleContext bundleContext);
>       /**
>        * Returns the {@link BundleContext} from the given Spring application
>        * context.
>        * 
>        * @param context
>        * @return
>        */
>       BundleContext getBundleContext(ApplicationContext context);
> }
> ------------------------------------------------------------------------
> 1.1) In the class OsgiUtils:
> do like this:
> ------------------------------------------------------------------------
> ApplicationContext ctx = 
> OsgiSpringContainerProvider.getContainer().publish(springIntentLocations, 
> bundleContext);
> ------------------------------------------------------------------------
> Instead of doing that: 
> ------------------------------------------------------------------------
> //            
> //            
> //            OsgiBundleXmlApplicationContext ctx = new 
> OsgiBundleXmlApplicationContext(springIntentLocations
> //                .toArray(new String[] {}));
> //            ctx.setPublishContextAsService(false);
> //            ctx.setBundleContext(bundleContext);
> //            ctx.refresh();
> ------------------------------------------------------------------------
> 1.2) In the Activator class: 
> Implements ApplicationContextAware (instead of BundleContextAware) : 
> public class Activator implements ManagedService, 
> ApplicationContextAware/*,BundleContextAware*/ {
> and implements setApplicationContext liek this 
> ------------------------------------------------------------------------
> public void setApplicationContext(ApplicationContext context)
>                       throws BeansException {
>  bc = OsgiUtils.getBundleContext(context);
> }
> ------------------------------------------------------------------------
> where OsgiUtils.getBundleContext use the interface 
> ------------------------------------------------------------------------
> public static BundleContext getBundleContext(ApplicationContext context) {
>   return OsgiSpringContainerProvider.getContainer().getBundleContext(context);
> }: 
> ------------------------------------------------------------------------
> 1.1) OsgiSpringContainerProvider:
> The OsgiSpringContainerProvider use SPI ServiceRegistry to retrieves the 
> implemententation of OsgiSpringContainer  : 
> ------------------------------------------------------------------------
> package org.apache.cxf.dosgi.dsw.container;
> import java.util.Iterator;
> import javax.imageio.spi.ServiceRegistry;
> public class OsgiSpringContainerProvider {
>       private static OsgiSpringContainer container;
>       public static OsgiSpringContainer getContainer()
>                       throws OsgiSpringContainerNotFoundException {
>               if (container == null) {
>                       container = getContainerFromFragment();
>               }
>               return container;
>       }
>       public static synchronized OsgiSpringContainer 
> getContainerFromFragment()
>                       throws OsgiSpringContainerNotFoundException {
>               if (container != null) {
>                       return container;
>               }
>               Iterator<OsgiSpringContainer> containers = ServiceRegistry
>                               .lookupProviders(OsgiSpringContainer.class,
>                                               
> OsgiSpringContainerProvider.class.getClassLoader());
>               while (containers.hasNext()) {
>                       return containers.next();
>               }
>               throw new OsgiSpringContainerNotFoundException();
>       }
> }
> ------------------------------------------------------------------------
> 2) cxf-dosgi-ri-dsw-cxf-gemini : new project which is a fragment linked to 
> cxf-dosgi-ri-dsw-cxf and register with SPI ServiceRegistry the Gemini 
> BluePring implementation of OSgiSpringContainer : 
> ------------------------------------------------------------------------
> package org.apache.cxf.dosgi.dsw.container.geminiblueprint;
> import java.util.List;
> import org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer;
> import 
> org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
> import org.osgi.framework.BundleContext;
> import org.springframework.context.ApplicationContext;
> public class GeminiBlueprintContainer
>               implements OsgiSpringContainer {
>       public ApplicationContext publish(List<String> springIntentLocations,
>                       BundleContext bundleContext) {
>               OsgiBundleXmlApplicationContext ctx = new 
> OsgiBundleXmlApplicationContext(
>                               springIntentLocations.toArray(new String[] {}));
>               ctx.setPublishContextAsService(false);
>               ctx.setBundleContext(bundleContext);
>               ctx.refresh();
>               return ctx;
>       }
>               
>       public BundleContext getBundleContext(ApplicationContext context) {
>               return 
> ((OsgiBundleXmlApplicationContext)context).getBundleContext();
>       }
> }
> ------------------------------------------------------------------------
> This implementation is registered in the file 
> META-INF/services/org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer : 
> ------------------------------------------------------------------------
> org.apache.cxf.dosgi.dsw.container.geminiblueprint.GeminiBlueprintContainer
> ------------------------------------------------------------------------
> This fragment has Eclipse Gemini Blueprint dependencies.
> 3) cxf-dosgi-ri-dsw-cxf-springdm: new project which is a fragment linked to 
> cxf-dosgi-ri-dsw-cxf and register with SPI ServiceRegistry the SppringDM 
> implementation of OSgiSpringContainer : 
> ------------------------------------------------------------------------
> package org.apache.cxf.dosgi.dsw.container.springdm;
> import java.util.List;
> import org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer;
> import org.osgi.framework.BundleContext;
> import org.springframework.context.ApplicationContext;
> import 
> org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
> public class SpringDMContainer implements
>               OsgiSpringContainer {
>       
>       public ApplicationContext publish(List<String> springIntentLocations,
>                       BundleContext bundleContext) {
>               OsgiBundleXmlApplicationContext ctx = new 
> OsgiBundleXmlApplicationContext(
>                               springIntentLocations.toArray(new String[] {}));
>               ctx.setPublishContextAsService(false);
>               ctx.setBundleContext(bundleContext);
>               ctx.refresh();
>               return ctx;
>       }
>       
>       public BundleContext getBundleContext(ApplicationContext context) {
>               return 
> ((OsgiBundleXmlApplicationContext)context).getBundleContext();
>       }
> }
> ------------------------------------------------------------------------
> This implementation is registered in the file 
> META-INF/services/org.apache.cxf.dosgi.dsw.container.OsgiSpringContainer : 
> ------------------------------------------------------------------------
> org.apache.cxf.dosgi.dsw.container.springdm.SpringDMContainer
> ------------------------------------------------------------------------
> This fragment has Spring DM dependencies.
> 4) Use cxf-dosgi-ri-dsw-cxf with Eclipse Gemini Blueprint
> So to use cxf-dosgi-ri-dsw-cxf with Eclipse Gemini Blueprint, add in the OSGi 
> container cxf-dosgi-ri-dsw-cxf+cxf-dosgi-ri-dsw-cxf-gemini
> 5) Use cxf-dosgi-ri-dsw-cxf with Spring DM 
> So to use cxf-dosgi-ri-dsw-cxf with Spring DM, add in the OSGi container 
> cxf-dosgi-ri-dsw-cxf+cxf-dosgi-ri-dsw-cxf-springdm
> I don't know Gemini Aires, but if it is based on Spring, we could create a 
> new fragment cxf-dosgi-ri-dsw-cxf-aires.
> Hope you will like it this idea.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to