Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6C8669FE7 for ; Thu, 15 Mar 2012 10:27:59 +0000 (UTC) Received: (qmail 15510 invoked by uid 500); 15 Mar 2012 10:27:59 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 15481 invoked by uid 500); 15 Mar 2012 10:27:59 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 15473 invoked by uid 99); 15 Mar 2012 10:27:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 10:27:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 10:27:57 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B060921C12 for ; Thu, 15 Mar 2012 10:27:37 +0000 (UTC) Date: Thu, 15 Mar 2012 10:27:37 +0000 (UTC) From: "Angelo (Updated) (JIRA)" To: issues@cxf.apache.org Message-ID: <1979684011.18428.1331807257724.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1073642451.18422.1331806898565.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (DOSGI-115) Use Spring DM and Eclipse Gemini Blueprint with DOSGi MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DOSGI-115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Angelo updated DOSGI-115: ------------------------- Attachment: cxf-dosgi-ri-dsw-Eclipse Projects cxf with Spring DM+Eclipse Gemini Blueprint.zip This zip contains 3 Eclipse Projects: 1) cxf-dosgi-ri-dsw-cxf : bundle which has no dependencies to Spring DM. 2) cxf-dosgi-ri-dsw-cxf-gemini :fragment for Eclipse Gemini Blueprint using. 3) cxf-dosgi-ri-dsw-cxf-springdm :fragment for Spring DM using. If you like this idea, I will create clean patch with pom.xml etc > 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 > * > */ > public interface OsgiSpringContainer { > /** > * Publish the given springs files and returns the Spring > * {@link ApplicationContext}. > * > * @param springIntentLocations > * @param bundleContext > * @return > */ > ApplicationContext publish(List 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 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 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 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. -- 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