Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 54829 invoked from network); 10 Oct 2008 13:34:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Oct 2008 13:34:49 -0000 Received: (qmail 39051 invoked by uid 500); 10 Oct 2008 13:34:48 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 38998 invoked by uid 500); 10 Oct 2008 13:34:48 -0000 Mailing-List: contact commits-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 commits@cxf.apache.org Received: (qmail 38989 invoked by uid 99); 10 Oct 2008 13:34:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2008 06:34:48 -0700 X-ASF-Spam-Status: No, hits=-1998.4 required=10.0 tests=ALL_TRUSTED,DNS_FROM_SECURITYSAGE,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2008 13:33:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1EB4123888AF; Fri, 10 Oct 2008 06:34:28 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r703452 - in /cxf/sandbox/dosgi/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java test/resources/OSGI-INF/remote-services/multi-services.xml Date: Fri, 10 Oct 2008 13:34:27 -0000 To: commits@cxf.apache.org From: eglynn@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081010133428.1EB4123888AF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: eglynn Date: Fri Oct 10 06:34:27 2008 New Revision: 703452 URL: http://svn.apache.org/viewvc?rev=703452&view=rev Log: [dOSGi] Adding support for configuration of per-interface addresses for multi-interface OSGi services Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=703452&r1=703451&r2=703452&view=diff ============================================================================== --- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java (original) +++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java Fri Oct 10 06:34:27 2008 @@ -68,6 +68,10 @@ private static final String PROPERTY_ELEMENT = "property"; private static final String PROPERTY_KEY_ATTRIBUTE = "key"; + private static final String PROPERTY_INTERFACE_ATTRIBUTE = "interface"; + + private static final String INTERFACE_WILDCARD = "*"; + private static final String INTERFACE_SEPARATOR = ":"; private OsgiUtils() { } @@ -150,6 +154,21 @@ Map props = excludeProperty(sd.getProperties(), Constants.REMOTE_INTERFACES_PROPERTY); + String keys[] = props.keySet().toArray(new String[props.size()]); + for (int j = 0; j < keys.length; j++) { + int sep = keys[j].indexOf(INTERFACE_SEPARATOR); + if (sep > -1) { + String value = (String)props.remove(keys[j]); + String root = keys[j].substring(0, sep); + String iface = + sep + INTERFACE_SEPARATOR.length() < keys[j].length() + ? keys[j].substring(sep + INTERFACE_SEPARATOR.length()) + : ""; + if (iNames[i].equals(iface)) { + props.put(root, value); + } + } + } list[i] = new ServiceEndpointDescriptionImpl(iNames[i], props); } } @@ -308,8 +327,12 @@ for (Element p : elements) { String key = p.getAttributeValue(PROPERTY_KEY_ATTRIBUTE); + String iface = p.getAttributeValue(PROPERTY_INTERFACE_ATTRIBUTE); if (key != null) { - props.put(key, p.getTextTrim()); + props.put(iface == null || iface.length() == 0 + ? key + : key + INTERFACE_SEPARATOR + iface, + p.getTextTrim()); } } @@ -444,7 +467,7 @@ && publishProperty != null && publishProperty.length() > 0) { - if ("*".equals(publishProperty)) { + if (INTERFACE_WILDCARD.equals(publishProperty)) { // wildcard indicates all interfaces should be published // publishableInterfaces = actualInterfaces; Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java?rev=703452&r1=703451&r2=703452&view=diff ============================================================================== --- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java (original) +++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java Fri Oct 10 06:34:27 2008 @@ -52,19 +52,23 @@ @Test public void testPublishSingleInterface() throws Exception { String[] serviceNames = new String[]{TestService.class.getName()}; - doTestPublishHook("remote-services.xml", serviceNames); + String[] addresses = new String[]{"http://localhost:9000/hello"}; + doTestPublishHook("remote-services.xml", serviceNames, addresses); } @Test public void testPublishMultiInterface() throws Exception { String[] serviceNames = new String[]{TestService.class.getName(), AdditionalInterface.class.getName()}; - doTestPublishHook("multi-services.xml", serviceNames); + String[] addresses = new String[]{"http://localhost:9001/hello", + "http://localhost:9002/hello"}; + doTestPublishHook("multi-services.xml", serviceNames, addresses); } @SuppressWarnings("unchecked") private void doTestPublishHook(String remoteServices, - String[] serviceNames) throws Exception { + String[] serviceNames, + String[] addresses) throws Exception { Bundle bundle = control.createMock(Bundle.class); bundle.findEntries(EasyMock.eq("OSGI-INF/remote-services"), @@ -122,6 +126,9 @@ String excludeProp = org.apache.cxf.dosgi.dsw.Constants.REMOTE_INTERFACES_PROPERTY; assertNull(sd.getProperties().get(excludeProp)); + String addrProp = + org.apache.cxf.dosgi.dsw.Constants.POJO_ADDRESS_PROPERTY; + assertEquals(addresses[i], sd.getProperties().get(addrProp)); } } Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml?rev=703452&r1=703451&r2=703452&view=diff ============================================================================== --- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml (original) +++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml Fri Oct 10 06:34:27 2008 @@ -26,6 +26,13 @@ org.apache.cxf.dosgi.dsw.hooks.TestService,org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface SOAP HTTP pojo - http://localhost:9001/hello + + http://localhost:9001/hello + + + http://localhost:9002/hello +