cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r690991 [3/20] - in /cxf/sandbox/dosgi: ./ discovery/ discovery/local/ discovery/local/src/ discovery/local/src/main/ discovery/local/src/main/java/ discovery/local/src/main/java/org/ discovery/local/src/main/java/org/apache/ discovery/loca...
Date Mon, 01 Sep 2008 15:08:10 GMT
Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml Mon Sep  1 08:08:01 2008
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:p="http://cxf.apache.org/policy"
+       xmlns:wsp="http://www.w3.org/ns/ws-policy"
+       xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+       xmlns:core="http://cxf.apache.org/core"
+       xmlns:soap="http://cxf.apache.org/bindings/soap"
+       xsi:schemaLocation="
+       http://cxf.apache.org/policy http://cxf.apache.org/schemas/policy.xsd
+       http://www.w3.org/ns/ws-policy http://www.w3.org/2007/02/ws-policy.xsd
+       http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+       http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <bean id="intentMap" class="org.apache.cxf.dosgi.dsw.qos.IntentMap">
+       <property name="intents">
+         <map>
+           <entry key="addressing" value-ref="nonDecoupledAddressing"/>
+           <entry key="logging" value-ref="messageLogging"/>
+           <entry key="SOAP" value-ref="soap11Binding"/>
+           <entry key="SOAP.1_1" value-ref="soap11Binding"/>
+           <entry key="SOAP.1_2" value-ref="soap12Binding"/>
+         </map>
+       </property>
+    </bean>
+
+    <p:policies id="nonDecoupledAddressing">
+        <wsp:PolicyReference URI="#AddressingPolicy"/>
+    </p:policies>
+
+    <wsp:Policy wsu:Id="AddressingPolicy"
+        xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata">
+        <wsam:Addressing>
+            <wsp:Policy />
+        </wsam:Addressing>
+    </wsp:Policy>
+
+    <core:logging id="messageLogging"/>
+
+    <soap:soapBinding id="soap11Binding" version="1.1"/>
+    <soap:soapBinding id="soap12Binding" version="1.2"/>
+
+</beans>

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/resources/META-INF/osgi/intent-map.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/BundleTestContext.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/BundleTestContext.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/BundleTestContext.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/BundleTestContext.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,151 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.hooks;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class BundleTestContext implements BundleContext {
+
+    private Bundle bundle;
+    private Object serviceObject;
+    private Map<String, ServiceReference> testReferences = new
+        HashMap<String, ServiceReference>();
+    private Map<String, ServiceReference> registeredReferences = new
+        HashMap<String, ServiceReference>();
+    
+        
+    public BundleTestContext(Bundle b) {
+        bundle = b;
+    }
+    
+    public void addBundleListener(BundleListener arg0) {
+    }
+
+    public void addFrameworkListener(FrameworkListener arg0) {
+    }
+
+    public void addServiceListener(ServiceListener arg0) {
+    }
+
+    public void addServiceListener(ServiceListener arg0, String arg1) throws InvalidSyntaxException {
+    }
+
+    public Filter createFilter(String arg0) throws InvalidSyntaxException {
+        return null;
+    }
+
+    public ServiceReference[] getAllServiceReferences(String arg0, String arg1) throws InvalidSyntaxException {
+        return null;
+    }
+
+    public Bundle getBundle() {
+        return bundle;
+    }
+
+    public Bundle getBundle(long arg0) {
+        return null;
+    }
+
+    public Bundle[] getBundles() {
+        return null;
+    }
+
+    public File getDataFile(String arg0) {
+        return null;
+    }
+
+    public String getProperty(String arg0) {
+        return null;
+    }
+
+    public Object getService(ServiceReference sref) {
+        return serviceObject;
+    }
+
+    public ServiceReference getServiceReference(String name) {
+        return registeredReferences.get(name);
+    }
+
+    public ServiceReference[] getServiceReferences(String arg0, String arg1) throws InvalidSyntaxException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Bundle installBundle(String arg0) throws BundleException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Bundle installBundle(String arg0, InputStream arg1) throws BundleException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ServiceRegistration registerService(String[] names, Object service, Dictionary props) {
+        for (String s : names) {
+            registeredReferences.put(s, testReferences.get(s));
+        }
+        serviceObject = service;
+        return null;
+    }
+
+    public ServiceRegistration registerService(String arg0, Object arg1, Dictionary arg2) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void removeBundleListener(BundleListener arg0) {
+    }
+
+    public void removeFrameworkListener(FrameworkListener arg0) {
+    }
+
+    public void removeServiceListener(ServiceListener arg0) {
+    }
+
+    public boolean ungetService(ServiceReference arg0) {
+        return false;
+    }
+
+    // test methods
+    public void addServiceReference(String name, ServiceReference sref) {
+        testReferences.put(name, sref);
+    }
+    
+    public List<ServiceReference> getRegisteredReferences() {
+        return new ArrayList<ServiceReference>(registeredReferences.values());
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/BundleTestContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/BundleTestContext.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,84 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.hooks;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.cxf.dosgi.dsw.hooks.CxfListenerHook;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class CxfListenerHookTest extends Assert {
+
+    private IMocksControl control;
+    
+    @Before
+    public void setUp() {
+        control = EasyMock.createNiceControl();
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSyncListenerHook() throws Exception {
+        
+        Bundle bundle = control.createMock(Bundle.class);
+        bundle.getEntry("/META-INF/osgi/remote-services.xml");
+        EasyMock.expectLastCall().andReturn(
+            getClass().getResource("/META-INF/osgi/remote-services.xml"));
+        Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
+        bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, 
+                          "Test Bundle");
+        bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION, 
+                          "1.0.0");
+        bundle.getHeaders();
+        EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes();
+        bundle.loadClass(TestService.class.getName());
+        EasyMock.expectLastCall().andReturn(TestService.class).anyTimes();
+        final BundleContext requestingContext = control.createMock(BundleContext.class);
+        requestingContext.getBundle();
+        EasyMock.expectLastCall().andReturn(bundle).anyTimes();
+        
+        BundleTestContext dswContext = new BundleTestContext(bundle);
+        dswContext.addServiceReference(TestService.class.getName(), 
+                                       control.createMock(ServiceReference.class));
+        control.replay();
+     
+        CxfListenerHook hook = new CxfListenerHook(dswContext);
+        
+        // TODO : if the next call ends up being executed in a thread of its own then
+        // update the test accordingly, use Futures for ex
+        
+        hook.serviceReferencesRequested(requestingContext, 
+                                       TestService.class.getName(), null, true);
+        
+        List<ServiceReference> registeredRefs = dswContext.getRegisteredReferences();
+        assertNotNull(registeredRefs);
+        assertEquals(1, registeredRefs.size());
+        
+    }
+
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 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=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,140 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.hooks;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+
+
+import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.hooks.CxfPublishHook;
+import org.apache.cxf.endpoint.Server;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.discovery.ServiceDescription;
+
+public class CxfPublishHookTest extends Assert {
+
+    private IMocksControl control;
+    
+    @Before
+    public void setUp() {
+        control = EasyMock.createNiceControl();
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testPublishHook() throws Exception {
+        
+        Bundle bundle = control.createMock(Bundle.class);
+        bundle.getEntry("/META-INF/osgi/remote-services.xml");
+        EasyMock.expectLastCall().andReturn(
+            getClass().getResource("/META-INF/osgi/remote-services.xml"));
+        Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
+        bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, 
+                          "Test Bundle");
+        bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION, 
+                          "1.0.0");
+        bundle.getHeaders();
+        EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes();
+        BundleContext requestingContext = control.createMock(BundleContext.class);
+        bundle.getBundleContext();
+        EasyMock.expectLastCall().andReturn(requestingContext).anyTimes();
+        
+        TestService serviceObject = new TestServiceImpl();
+        String[] serviceNames = new String[]{TestService.class.getName()};
+        Dictionary serviceProps = new Hashtable();
+        
+        ServiceReference sref = control.createMock(ServiceReference.class);
+        sref.getBundle();
+        EasyMock.expectLastCall().andReturn(bundle).anyTimes();
+        sref.getProperty(Constants.OBJECTCLASS);
+        EasyMock.expectLastCall().andReturn(serviceNames);
+        sref.getPropertyKeys();                           
+        EasyMock.expectLastCall().andReturn(new String[]{}).anyTimes();
+        
+        BundleContext dswContext = new BundleTestContext(bundle);
+        dswContext.registerService(serviceNames, serviceObject, serviceProps);
+        
+        Server server = control.createMock(Server.class);
+        
+        control.replay();
+     
+        TestPublishHook hook = new TestPublishHook(dswContext, 
+                                                   serviceObject, 
+                                                   server);
+        hook.publishEndpoint(sref);
+        hook.verify();
+        
+    }
+
+    private static class TestPublishHook extends CxfPublishHook {
+        
+        private boolean called;
+        private TestService serviceObject;
+        private Server server;
+        
+        public TestPublishHook(BundleContext bc, TestService serviceObject,
+                               Server s) {
+            super(bc);
+            this.serviceObject = serviceObject;
+            this.server = s;
+        }
+        
+        @Override
+        protected ConfigurationTypeHandler getHandler(ServiceDescription sd,
+                                                      Map<String, Object> props) {
+            return new ConfigurationTypeHandler() {
+
+                public Object createProxy(BundleContext dswContext, BundleContext callingContext, 
+                                          Class<?> iClass, ServiceDescription sd) {
+                    throw new UnsupportedOperationException();
+                }
+
+                public Server createServer(BundleContext dswContext, BundleContext callingContext, 
+                                           ServiceDescription sd, Class<?> iClass, Object serviceBean) {
+                    Assert.assertSame(serviceBean, serviceObject);
+                    TestPublishHook.this.setCalled();
+                    return server;
+                }
+                
+            };
+        }
+        
+        public void setCalled() {
+            called = true;
+        }
+        
+        public void verify() {
+            Assert.assertTrue(called);
+        }
+    }
+    
+    private static class TestServiceImpl implements TestService {
+        
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,23 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.hooks;
+
+public interface TestService {
+
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml Mon Sep  1 08:08:01 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<remote-references xmlns="http://www.osgi.org/xmlns/rs/v1.0.0">
+<reference>
+<provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService"/>
+<property name="org.osgi.remote.publish">true</property>
+<property name="org.osgi.remote.intents">SOAP HTTP</property>
+<property name="org.osgi.remote.configuration.type">pojo</property>
+<property name="org.osgi.remote.address">http://localhost:9000/hello</property>
+</reference>
+</remote-references>

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/META-INF/osgi/remote-services.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/sandbox/dosgi/dsw/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/pom.xml?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/pom.xml (added)
+++ cxf/sandbox/dosgi/dsw/pom.xml Mon Sep  1 08:08:01 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf</groupId>
+    <artifactId>cxf-dosgi-ri-dsw</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>Distributed OSGI Distributed Software Modules</name>
+    <url>http://cxf.apache.org</url>
+
+    <parent>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-dosgi-ri-parent</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <topDirectoryLocation>..</topDirectoryLocation>
+    </properties>
+
+    <modules>
+      <module>cxf-dsw</module>
+    </modules> 
+</project>

Propchange: cxf/sandbox/dosgi/dsw/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/sandbox/dosgi/dsw/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/sandbox/dosgi/felix/framework/LICENSE
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/LICENSE?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/LICENSE (added)
+++ cxf/sandbox/dosgi/felix/framework/LICENSE Mon Sep  1 08:08:01 2008
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Propchange: cxf/sandbox/dosgi/felix/framework/LICENSE
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/LICENSE
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/sandbox/dosgi/felix/framework/NOTICE
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/NOTICE?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/NOTICE (added)
+++ cxf/sandbox/dosgi/felix/framework/NOTICE Mon Sep  1 08:08:01 2008
@@ -0,0 +1,26 @@
+Apache Felix Framework
+Copyright 2008 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright 2006 The OSGi Alliance.
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright 2006 The OSGi Alliance.
+Licensed under the Apache License 2.0.
+
+
+III. License Summary
+- Apache License 2.0

Propchange: cxf/sandbox/dosgi/felix/framework/NOTICE
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/NOTICE
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/sandbox/dosgi/felix/framework/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/pom.xml?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/pom.xml (added)
+++ cxf/sandbox/dosgi/felix/framework/pom.xml Mon Sep  1 08:08:01 2008
@@ -0,0 +1,98 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>bundle</packaging>
+  <name>CXF-Distributed OSGi Temporary Private Apache Felix Framework Build</name>
+  <description>CXF-Distributed OSGi Temporary Private Apache Felix Framework.</description> 
+  <groupId>org.apache.felix</groupId>
+  <artifactId>org.apache.felix.framework</artifactId>
+  <version>1.1.0-cxf_dosgi-SNAPSHOT</version>
+
+  <parent>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-dosgi-ri-parent</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <relativePath>../../parent/pom.xml</relativePath> 
+  </parent>
+
+  <properties>
+        <topDirectoryLocation>../..</topDirectoryLocation>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+       <groupId>junit</groupId>
+       <artifactId>junit</artifactId>
+       <scope>test</scope>
+    </dependency>  
+    <dependency>
+       <groupId>org.easymock</groupId>
+       <artifactId>easymockclassextension</artifactId>
+       <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-checkstyle-plugin</artifactId>
+          <configuration>
+             <excludes>**/*.java</excludes>
+          </configuration>
+      </plugin>
+      <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-pmd-plugin</artifactId>
+          <configuration>
+             <excludes>
+                 <exclude>**/*.java</exclude>
+             </excludes>
+          </configuration>
+      </plugin> 
+      
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-Name>Apache Felix Framework</Bundle-Name>
+            <Bundle-Description>OSGi R4 framework implementation.</Bundle-Description>
+            <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+            <Export-Package>org.osgi.framework;-split-package:=merge-first,org.osgi.framework.hooks.service;-split-package:=merge-first,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.discovery,org.osgi.service.dsw,org.osgi.service.startlevel,org.osgi.util.tracker</Export-Package>
+            <Private-Package>org.apache.felix.moduleloader.*,org.apache.felix.framework.*</Private-Package>
+            <Import-Package>!*</Import-Package>
+            <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,{src/main/resources/},org/osgi/framework/=target/classes/org/osgi/framework/</Include-Resource> 
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: cxf/sandbox/dosgi/felix/framework/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/sandbox/dosgi/felix/framework/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,455 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Dictionary;
+
+import org.apache.felix.framework.ext.FelixBundleContext;
+import org.osgi.framework.*;
+
+class BundleContextImpl implements FelixBundleContext
+{
+    private Logger m_logger = null;
+    private Felix m_felix = null;
+    private FelixBundle m_bundle = null;
+    private boolean m_valid = true;
+
+    protected BundleContextImpl(Logger logger, Felix felix, FelixBundle bundle)
+    {
+        m_logger = logger;
+        m_felix = felix;
+        m_bundle = bundle;
+    }
+
+    protected void invalidate()
+    {
+        m_valid = false;
+    }
+
+    public void addRequirement(String s) throws BundleException
+    {
+        // TODO: EXPERIMENTAL - Experimental implicit wire concept to try
+        //       to deal with code generation.
+        m_felix.addRequirement(m_bundle, s);
+    }
+
+    public void removeRequirement() throws BundleException
+    {
+        throw new BundleException("Not implemented yet.");
+    }
+
+    public void addCapability() throws BundleException
+    {
+        throw new BundleException("Not implemented yet.");
+    }
+
+    public void removeCapability() throws BundleException
+    {
+        throw new BundleException("Not implemented yet.");
+    }
+
+    public String getProperty(String name)
+    {
+        checkValidity();
+
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            if (!(Constants.FRAMEWORK_VERSION.equals(name) ||
+                Constants.FRAMEWORK_VENDOR.equals(name) ||
+                Constants.FRAMEWORK_LANGUAGE.equals(name)||
+                Constants.FRAMEWORK_OS_NAME.equals(name) ||
+                Constants.FRAMEWORK_OS_VERSION.equals(name) ||
+                Constants.FRAMEWORK_PROCESSOR.equals(name)))
+            {
+                ((SecurityManager) sm).checkPermission(
+                    new java.util.PropertyPermission(name, "read"));
+            }
+        }
+
+        return m_felix.getProperty(name);
+    }
+
+    public Bundle getBundle()
+    {
+        checkValidity();
+
+        return m_bundle;
+    }
+
+    public Filter createFilter(String expr)
+        throws InvalidSyntaxException
+    {
+        checkValidity();
+
+        return new FilterImpl(m_logger, expr);
+    }
+
+    public Bundle installBundle(String location)
+        throws BundleException
+    {
+        return installBundle(location, null);
+    }
+
+    public Bundle installBundle(String location, InputStream is)
+        throws BundleException
+    {
+        checkValidity();
+
+        Bundle result = null;
+
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            result = m_felix.installBundle(location, is);
+            // Do check the bundle again in case that is was installed
+            // already.
+            ((SecurityManager) sm).checkPermission(
+                new AdminPermission(result, AdminPermission.LIFECYCLE));
+        }
+        else
+        {
+            result = m_felix.installBundle(location, is);
+        }
+
+        return result;
+    }
+
+    public Bundle getBundle(long id)
+    {
+        checkValidity();
+
+        return m_felix.getBundle(id);
+    }
+
+    public Bundle[] getBundles()
+    {
+        checkValidity();
+
+        return m_felix.getBundles();
+    }
+
+    public void addBundleListener(BundleListener l)
+    {
+        checkValidity();
+
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            if (l instanceof SynchronousBundleListener)
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(m_bundle,
+                    AdminPermission.LISTENER));
+            }
+        }
+
+        m_felix.addBundleListener(m_bundle, l);
+    }
+
+    public void removeBundleListener(BundleListener l)
+    {
+        checkValidity();
+
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            if (l instanceof SynchronousBundleListener)
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(m_bundle,
+                    AdminPermission.LISTENER));
+            }
+        }
+
+        m_felix.removeBundleListener(m_bundle, l);
+    }
+
+    public void addServiceListener(ServiceListener l)
+    {
+        try
+        {
+            addServiceListener(l, null);
+        }
+        catch (InvalidSyntaxException ex)
+        {
+            // This will not happen since the filter is null.
+        }
+    }
+
+    public void addServiceListener(ServiceListener l, String s)
+        throws InvalidSyntaxException
+    {
+        checkValidity();
+
+        m_felix.addServiceListener(m_bundle, l, s);
+    }
+
+    public void removeServiceListener(ServiceListener l)
+    {
+        checkValidity();
+
+        m_felix.removeServiceListener(m_bundle, l);
+    }
+
+    public void addFrameworkListener(FrameworkListener l)
+    {
+        checkValidity();
+
+        m_felix.addFrameworkListener(m_bundle, l);
+    }
+
+    public void removeFrameworkListener(FrameworkListener l)
+    {
+        checkValidity();
+
+        m_felix.removeFrameworkListener(m_bundle, l);
+    }
+
+    public ServiceRegistration registerService(
+        String clazz, Object svcObj, Dictionary dict)
+    {
+        return registerService(new String[] { clazz }, svcObj, dict);
+    }
+
+    public ServiceRegistration registerService(
+        String[] clazzes, Object svcObj, Dictionary dict)
+    {
+        checkValidity();
+
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            if (clazzes != null)
+            {
+                for (int i = 0;i < clazzes.length;i++)
+                {
+                    ((SecurityManager) sm).checkPermission(
+                        new ServicePermission(clazzes[i], ServicePermission.REGISTER));
+                }
+            }
+        }
+
+        return m_felix.registerService(m_bundle, clazzes, svcObj, dict);
+    }
+
+    public ServiceReference getServiceReference(String clazz)
+    {
+        checkValidity();
+
+        try
+        {
+            ServiceReference[] refs = getServiceReferences(clazz, null);
+            return getBestServiceReference(refs);
+        }
+        catch (InvalidSyntaxException ex)
+        {
+            m_logger.log(Logger.LOG_ERROR, "BundleContextImpl: " + ex);
+        }
+        return null;
+    }
+
+    private ServiceReference getBestServiceReference(ServiceReference[] refs)
+    {
+        if (refs == null)
+        {
+            return null;
+        }
+
+        if (refs.length == 1)
+        {
+            return refs[0];
+        }
+
+        // Loop through all service references and return
+        // the "best" one according to its rank and ID.
+        ServiceReference bestRef = null;
+        Integer bestRank = null;
+        Long bestId = null;
+        for (int i = 0; i < refs.length; i++)
+        {
+            ServiceReference ref = refs[i];
+
+            // The first time through the loop just
+            // assume that the first reference is best.
+            if (bestRef == null)
+            {
+                bestRef = ref;
+                bestRank = (Integer) bestRef.getProperty("service.ranking");
+                // The spec says no ranking defaults to zero.
+                if (bestRank == null)
+                {
+                    bestRank = new Integer(0);
+                }
+                bestId = (Long) bestRef.getProperty("service.id");
+            }
+
+            // Compare current and best references to see if
+            // the current reference is a better choice.
+            Integer rank = (Integer) ref.getProperty("service.ranking");
+
+            // The spec says no ranking defaults to zero.
+            if (rank == null)
+            {
+                rank = new Integer(0);
+            }
+
+            // If the current reference ranking is greater than the
+            // best ranking, then keep the current reference.
+            if (bestRank.compareTo(rank) < 0)
+            {
+                bestRef = ref;
+                bestRank = rank;
+                bestId = (Long) bestRef.getProperty("service.id");
+            }
+            // If rankings are equal, then compare IDs and
+            // keep the smallest.
+            else if (bestRank.compareTo(rank) == 0)
+            {
+                Long id = (Long) ref.getProperty("service.id");
+                // If either reference has a null ID, then keep
+                // the one with a non-null ID.
+                if ((bestId == null) || (id == null))
+                {
+                    bestRef = (bestId == null) ? ref : bestRef;
+                    // bestRank = bestRank; // No need to update since they are equal.
+                    bestId = (Long) bestRef.getProperty("service.id");
+                }
+                // Otherwise compare IDs.
+                else
+                {
+                    // If the current reference ID is less than the
+                    // best ID, then keep the current reference.
+                    if (bestId.compareTo(id) > 0)
+                    {
+                        bestRef = ref;
+                        // bestRank = bestRank; // No need to update since they are equal.
+                        bestId = (Long) bestRef.getProperty("service.id");
+                    }
+                }
+            }
+        }
+
+        return bestRef;
+    }
+
+    public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+    {
+        checkValidity();
+
+        return m_felix.getAllowedServiceReferences(m_bundle, clazz, filter, false);
+
+    }
+
+    public ServiceReference[] getServiceReferences(String clazz, String filter)
+        throws InvalidSyntaxException
+    {
+        checkValidity();
+
+        return m_felix.getAllowedServiceReferences(m_bundle, clazz, filter, true);
+
+    }
+
+    public Object getService(ServiceReference ref)
+    {
+        checkValidity();
+
+        if (ref == null)
+        {
+            throw new NullPointerException("Specified service reference cannot be null.");
+        }
+
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            String[] objectClass = (String[]) ref.getProperty(Constants.OBJECTCLASS);
+
+            if (objectClass == null)
+            {
+                return null;
+            }
+
+            boolean hasPermission = false;
+
+            for (int i = 0;(i < objectClass.length) && !hasPermission;i++)
+            {
+                try
+                {
+                    ((SecurityManager) sm).checkPermission(
+                        new ServicePermission(objectClass[i], ServicePermission.GET));
+
+                    hasPermission = true;
+                }
+                catch (Exception ex)
+                {
+
+                }
+            }
+
+            if (!hasPermission)
+            {
+                throw new SecurityException("No permission");
+            }
+        }
+
+        return m_felix.getService(m_bundle, ref);
+    }
+
+    public boolean ungetService(ServiceReference ref)
+    {
+        checkValidity();
+
+        if (ref == null)
+        {
+            throw new NullPointerException("Specified service reference cannot be null.");
+        }
+
+        // Unget the specified service.
+        return m_felix.ungetService(m_bundle, ref);
+    }
+
+    public File getDataFile(String s)
+    {
+        checkValidity();
+
+        return m_felix.getDataFile(m_bundle, s);
+    }
+
+    private void checkValidity()
+    {
+        if (m_valid)
+        {
+            switch (m_bundle.getInfo().getState())
+            {
+                case Bundle.ACTIVE:
+                case Bundle.STARTING:
+                case Bundle.STOPPING:
+                    return;
+            }
+        }
+
+        throw new IllegalStateException("Invalid BundleContext.");
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleImpl.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleImpl.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,427 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.*;
+
+import org.osgi.framework.*;
+
+class BundleImpl extends FelixBundle
+{
+    private final long m_id;
+    private Felix m_felix = null;
+    private BundleInfo m_info = null;
+
+    protected BundleImpl(Felix felix, BundleInfo info)
+    {
+        m_felix = felix;
+        m_info = info;
+        m_id = info.getBundleId();
+    }
+
+    /* package private */ BundleInfo getInfo()
+    {
+        return m_info;
+    }
+
+    /*
+     * Only used when refreshing a bundle.
+    **/
+    /* package private */ void setInfo(BundleInfo info)
+    {
+        m_info = info;
+    }
+
+    public BundleContext getBundleContext()
+    {
+// TODO: SECURITY - We need a security check here.
+        return m_info.getBundleContext();
+    }
+
+    public long getBundleId()
+    {
+        return m_id;
+    }
+
+    public URL getEntry(String name)
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            try
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                    AdminPermission.RESOURCE));
+            }
+            catch (Exception e)
+            {
+                return null; // No permission
+            }
+        }
+
+        return m_felix.getBundleEntry(this, name);
+    }
+
+    public Enumeration getEntryPaths(String path)
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            try
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                    AdminPermission.RESOURCE));
+            }
+            catch (Exception e)
+            {
+                return null; // No permission
+            }
+        }
+
+        return m_felix.getBundleEntryPaths(this, path);
+    }
+
+    public Enumeration findEntries(String path, String filePattern, boolean recurse)
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            try
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                    AdminPermission.RESOURCE));
+            }
+            catch (Exception e)
+            {
+                return null; // No permission
+            }
+        }
+
+        return m_felix.findBundleEntries(this, path, filePattern, recurse);
+    }
+
+    public Dictionary getHeaders()
+    {
+        return getHeaders(Locale.getDefault().toString());
+    }
+
+    public Dictionary getHeaders(String locale)
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                AdminPermission.METADATA));
+        }
+
+        if (locale == null)
+        {
+            locale = Locale.getDefault().toString();
+        }
+
+        return m_felix.getBundleHeaders(this, locale);
+    }
+
+    public long getLastModified()
+    {
+        return m_info.getLastModified();
+    }
+
+    public String getLocation()
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                AdminPermission.METADATA));
+        }
+        return m_felix.getBundleLocation(this);
+    }
+
+    /**
+     * Returns a URL to a named resource in the bundle.
+     *
+     * @return a URL to named resource, or null if not found.
+    **/
+    public URL getResource(String name)
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            try
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                    AdminPermission.RESOURCE));
+            }
+            catch (Exception e)
+            {
+                return null; // No permission
+            }
+        }
+
+        return m_felix.getBundleResource(this, name);
+    }
+
+    public Enumeration getResources(String name) throws IOException
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            try
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                    AdminPermission.RESOURCE));
+            }
+            catch (Exception e)
+            {
+                return null; // No permission
+            }
+        }
+
+        return m_felix.getBundleResources(this, name);
+    }
+
+    /**
+     * Returns an array of service references corresponding to
+     * the bundle's registered services.
+     *
+     * @return an array of service references or null.
+    **/
+    public ServiceReference[] getRegisteredServices()
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ServiceReference[] refs = m_felix.getBundleRegisteredServices(this);
+
+            if (refs == null)
+            {
+                return refs;
+            }
+
+            List result = new ArrayList();
+
+            for (int i = 0;i < refs.length;i++)
+            {
+                String[] objectClass = (String[]) refs[i].getProperty(
+                    Constants.OBJECTCLASS);
+
+                if (objectClass == null)
+                {
+                    continue;
+                }
+
+                for (int j = 0;j < objectClass.length;j++)
+                {
+                    try
+                    {
+                        ((SecurityManager) sm).checkPermission(new ServicePermission(
+                            objectClass[j], ServicePermission.GET));
+
+                        result.add(refs[i]);
+
+                        break;
+                    }
+                    catch (Exception ex)
+                    {
+                        // Silently ignore.
+                    }
+                }
+            }
+
+            if (result.isEmpty())
+            {
+                return null;
+            }
+
+            return (ServiceReference[]) result.toArray(new ServiceReference[result.size()]);
+        }
+        else
+        {
+            return m_felix.getBundleRegisteredServices(this);
+        }
+    }
+
+    public ServiceReference[] getServicesInUse()
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ServiceReference[] refs = m_felix.getBundleServicesInUse(this);
+
+            if (refs == null)
+            {
+                return refs;
+            }
+
+            List result = new ArrayList();
+
+            for (int i = 0;i < refs.length;i++)
+            {
+                String[] objectClass = (String[]) refs[i].getProperty(
+                    Constants.OBJECTCLASS);
+
+                if (objectClass == null)
+                {
+                    continue;
+                }
+
+                for (int j = 0;j < objectClass.length;j++)
+                {
+                    try
+                    {
+                        ((SecurityManager) sm).checkPermission(new ServicePermission(
+                            objectClass[j], ServicePermission.GET));
+
+                        result.add(refs[i]);
+
+                        break;
+                    }
+                    catch (Exception ex)
+                    {
+                        // Silently ignore.
+                    }
+                }
+            }
+
+            if (result.isEmpty())
+            {
+                return null;
+            }
+
+            return (ServiceReference[]) result.toArray(new ServiceReference[result.size()]);
+        }
+
+        return m_felix.getBundleServicesInUse(this);
+    }
+
+    public int getState()
+    {
+        return m_info.getState();
+    }
+
+    public String getSymbolicName()
+    {
+        return m_felix.getBundleSymbolicName(this);
+    }
+
+    public boolean hasPermission(Object obj)
+    {
+        return m_felix.bundleHasPermission(this, obj);
+    }
+
+    public Class loadClass(String name) throws ClassNotFoundException
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            try
+            {
+                ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                    AdminPermission.CLASS));
+            }
+            catch (Exception e)
+            {
+                throw new ClassNotFoundException("No permission.", e);
+            }
+        }
+
+        return m_felix.loadBundleClass(this, name);
+    }
+
+    public void start() throws BundleException
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                AdminPermission.EXECUTE));
+        }
+
+        m_felix.startBundle(this, true);
+    }
+
+    public void update() throws BundleException
+    {
+        update(null);
+    }
+
+    public void update(InputStream is) throws BundleException
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                AdminPermission.LIFECYCLE));
+        }
+
+        m_felix.updateBundle(this, is);
+    }
+
+    public void stop() throws BundleException
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                AdminPermission.EXECUTE));
+        }
+
+        m_felix.stopBundle(this, true);
+    }
+
+    public void uninstall() throws BundleException
+    {
+        Object sm = System.getSecurityManager();
+
+        if (sm != null)
+        {
+            ((SecurityManager) sm).checkPermission(new AdminPermission(this,
+                AdminPermission.LIFECYCLE));
+        }
+
+        m_felix.uninstallBundle(this);
+    }
+
+    public String toString()
+    {
+        return m_felix.getBundleSymbolicName(this) + " [" + getBundleId() +"]";
+    }
+
+    Object getSignerMatcher()
+    {
+        return m_felix.getSignerMatcher(this);
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleInfo.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleInfo.java?rev=690991&view=auto
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleInfo.java (added)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleInfo.java Mon Sep  1 08:08:01 2008
@@ -0,0 +1,554 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.*;
+
+import org.apache.felix.framework.cache.BundleArchive;
+import org.apache.felix.moduleloader.IContentLoader;
+import org.apache.felix.moduleloader.IModule;
+import org.osgi.framework.*;
+
+class BundleInfo
+{
+    private Logger m_logger = null;
+    private BundleArchive m_archive = null;
+    private IModule[] m_modules = null;
+    private int m_state = 0;
+    private BundleActivator m_activator = null;
+    private BundleContext m_context = null;
+    private Map m_cachedHeaders = new HashMap();
+    private long m_cachedHeadersTimestamp;
+    
+    // Indicates whether the bundle is stale, meaning that it has
+    // been refreshed and completely removed from the framework.
+    private boolean m_stale = false;
+
+    // Indicates whether the bundle is an extension, meaning that it is
+    // installed as an extension bundle to the framework (i.e., can not be
+    // removed or updated until a framework restart.
+    private boolean m_extension = false;
+
+    // Used for bundle locking.
+    private int m_lockCount = 0;
+    private Thread m_lockThread = null;
+
+    protected BundleInfo(Logger logger, BundleArchive archive, IModule module)
+    {
+        m_logger = logger;
+        m_archive = archive;
+        m_modules = (module == null) ? new IModule[0] : new IModule[] { module };
+
+        m_state = Bundle.INSTALLED;
+        m_stale = false;
+        m_activator = null;
+        m_context = null;
+    }
+
+    /**
+     *  Returns the bundle archive associated with this bundle.
+     * @return the bundle archive associated with this bundle.
+    **/
+    public BundleArchive getArchive()
+    {
+        return m_archive;
+    }
+
+    /**
+     * Returns an array of all modules associated with the bundle represented by
+     * this <tt>BundleInfo</tt> object. A module in the array corresponds to a
+     * revision of the bundle's JAR file and is ordered from oldest to newest.
+     * Multiple revisions of a bundle JAR file might exist if a bundle is
+     * updated, without refreshing the framework. In this case, exports from
+     * the prior revisions of the bundle JAR file are still offered; the
+     * current revision will be bound to packages from the prior revision,
+     * unless the packages were not offered by the prior revision. There is
+     * no limit on the potential number of bundle JAR file revisions.
+     * @return array of modules corresponding to the bundle JAR file revisions.
+    **/
+    public synchronized IModule[] getModules()
+    {
+        return m_modules;
+    }
+
+    /**
+     * Determines if the specified module is associated with this bundle.
+     * @param module the module to determine if it is associate with this bundle.
+     * @return <tt>true</tt> if the specified module is in the array of modules
+     *         associated with this bundle, <tt>false</tt> otherwise.
+    **/
+    public synchronized boolean hasModule(IModule module)
+    {
+        for (int i = 0; i < m_modules.length; i++)
+        {
+            if (m_modules[i] == module)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns the newest module, which corresponds to the last module
+     * in the module array.
+     * @return the newest module.
+    **/
+    public synchronized IModule getCurrentModule()
+    {
+        return m_modules[m_modules.length - 1];
+    }
+
+    /**
+     * Add a module that corresponds to a new bundle JAR file revision for
+     * the bundle associated with this <tt>BundleInfo</tt> object.
+     * @param module the module to add.
+    **/
+    public synchronized void addModule(IModule module)
+    {
+        IModule[] dest = new IModule[m_modules.length + 1];
+        System.arraycopy(m_modules, 0, dest, 0, m_modules.length);
+        dest[m_modules.length] = module;
+        m_modules = dest;
+    }
+
+    public long getBundleId()
+    {
+        try
+        {
+            return m_archive.getId();
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error getting the identifier from bundle archive.",
+                ex);
+            return -1;
+        }
+    }
+
+    public String getLocation()
+    {
+        try
+        {
+            return m_archive.getLocation();
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error getting location from bundle archive.",
+                ex);
+            return null;
+        }
+    }
+
+    public int getStartLevel(int defaultLevel)
+    {
+        try
+        {
+            return m_archive.getStartLevel();
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error reading start level from bundle archive.",
+                ex);
+            return defaultLevel;
+        }
+    }
+
+    public void setStartLevel(int i)
+    {
+        try
+        {
+            m_archive.setStartLevel(i);
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error writing start level to bundle archive.",
+                ex);
+        }
+    }
+
+    public Map getCurrentHeader()
+    {
+        try
+        {
+            // Return the header for the most recent bundle revision only,
+            // since we shouldn't ever need access to older revisions.
+            return m_archive.getRevision(m_archive.getRevisionCount() - 1).getManifestHeader();
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error reading manifest from bundle archive.",
+                ex);
+            return null;
+        }
+    }
+
+    public Map getCurrentLocalizedHeader(String locale)
+    {
+        synchronized (m_cachedHeaders)
+        {
+            // If the bundle has been updated, clear the cached headers
+            if (getLastModified() > m_cachedHeadersTimestamp)
+            {
+                m_cachedHeaders.clear();
+            }
+            else
+            {
+                // Check if headers for this locale have already been resolved
+                if (m_cachedHeaders.containsKey(locale))
+                {
+                    return (Map) m_cachedHeaders.get(locale);
+                }
+            }
+        }
+
+        Map headers;
+        try
+        {
+            Map rawHeaders = m_archive.getRevision(m_archive.getRevisionCount() - 1).getManifestHeader();
+            headers = new HashMap(rawHeaders.size());
+            headers.putAll(rawHeaders);
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error reading manifest from bundle archive.",
+                ex);
+            return null;
+        }
+
+        // Check to see if we actually need to localize anything
+        boolean needsLocalization = false;
+        for (Iterator it = headers.values().iterator(); it.hasNext(); )
+        {
+            if (((String) it.next()).startsWith("%"))
+            {
+                needsLocalization = true;
+                break;
+            }
+        }
+
+        if (!needsLocalization)
+        {
+            // If localization is not needed, just cache the headers and return them as-is
+            // Not sure if this is useful
+            updateHeaderCache(locale, headers);
+            return headers;
+        }
+
+        // Do localization here and return the localized headers
+        IContentLoader loader = this.getCurrentModule().getContentLoader();
+
+        String basename = (String) headers.get(Constants.BUNDLE_LOCALIZATION);
+        if (basename == null)
+        {
+            basename = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
+        }
+
+        // Create ordered list of files to load properties from
+        List resourceList = createResourceList(basename, locale);
+
+        // Create a merged props file with all available props for this locale
+        Properties mergedProperties = new Properties();
+        for (Iterator it = resourceList.iterator(); it.hasNext(); )
+        {
+            URL temp = loader.getResource(it.next() + ".properties");
+            if (temp == null)
+            {
+                continue;
+            }
+            try
+            {
+                mergedProperties.load(temp.openConnection().getInputStream());
+            }
+            catch (IOException ex)
+            {
+                // File doesn't exist, just continue loop
+            }
+        }
+
+        // Resolve all localized header entries
+        for (Iterator it = headers.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+            String value = (String) entry.getValue();
+            if (value.startsWith("%"))
+            {
+                String newvalue;
+                String key = value.substring(value.indexOf("%") + 1);
+                newvalue = mergedProperties.getProperty(key);
+                if (newvalue==null)
+                {
+                    newvalue = key;
+                }
+                entry.setValue(newvalue);
+            }
+        }
+
+        updateHeaderCache(locale, headers);
+        return headers;
+    }
+
+    private void updateHeaderCache(String locale, Map localizedHeaders)
+    {
+        synchronized(m_cachedHeaders)
+        {
+            m_cachedHeaders.put(locale, localizedHeaders);
+            m_cachedHeadersTimestamp = System.currentTimeMillis();
+        }
+    }
+
+    private List createResourceList(String basename, String locale)
+    {
+        List result = new ArrayList(4);
+
+        StringTokenizer tokens;
+        StringBuffer tempLocale = new StringBuffer(basename);
+
+        result.add(tempLocale.toString());
+
+        if (locale.length() > 0)
+        {
+            tokens = new StringTokenizer(locale, "_");
+            while (tokens.hasMoreTokens())
+            {
+                tempLocale.append("_").append(tokens.nextToken());
+                result.add(tempLocale.toString());
+            }
+        }
+        return result;
+    }
+
+    public synchronized int getState()
+    {
+        return m_state;
+    }
+
+    public synchronized void setState(int i)
+    {
+        m_state = i;
+    }
+
+    public long getLastModified()
+    {
+        try
+        {
+            return m_archive.getLastModified();
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error reading last modification time from bundle archive.",
+                ex);
+            return 0;
+        }
+    }
+
+    public void setLastModified(long l)
+    {
+        try
+        {
+            m_archive.setLastModified(l);
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error writing last modification time to bundle archive.",
+                ex);
+        }
+    }
+
+    public int getPersistentState()
+    {
+        try
+        {
+            return m_archive.getPersistentState();
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error reading persistent state from bundle archive.",
+                ex);
+            return Bundle.INSTALLED;
+        }
+    }
+
+    public void setPersistentStateInactive()
+    {
+        try
+        {
+            m_archive.setPersistentState(Bundle.INSTALLED);
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(Logger.LOG_ERROR,
+                "Error writing persistent state to bundle archive.",
+                ex);
+        }
+    }
+
+    public void setPersistentStateActive()
+    {
+        try
+        {
+            m_archive.setPersistentState(Bundle.ACTIVE);
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error writing persistent state to bundle archive.",
+                ex);
+        }
+    }
+
+    public void setPersistentStateUninstalled()
+    {
+        try
+        {
+            m_archive.setPersistentState(Bundle.UNINSTALLED);
+        }
+        catch (Exception ex)
+        {
+            m_logger.log(
+                Logger.LOG_ERROR,
+                "Error writing persistent state to bundle archive.",
+                ex);
+        }
+    }
+
+    public synchronized BundleContext getBundleContext()
+    {
+        return m_context;
+    }
+
+    public synchronized void setBundleContext(BundleContext context)
+    {
+        m_context = context;
+    }
+
+    public synchronized BundleActivator getActivator()
+    {
+        return m_activator;
+    }
+
+    public synchronized void setActivator(BundleActivator activator)
+    {
+        m_activator = activator;
+    }
+
+    public synchronized boolean isStale()
+    {
+        return m_stale;
+    }
+
+    public synchronized void setStale()
+    {
+        m_stale = true;
+    }
+
+    public synchronized boolean isExtension()
+    {
+        return m_extension;
+    }
+
+    public synchronized void setExtension(boolean extension)
+    {
+        m_extension = extension;
+    }
+
+    //
+    // Locking related methods.
+    // NOTE: These methods are not synchronized because it is assumed they
+    // will only ever be called when the caller is in a synchronized block.
+    //
+
+    public synchronized boolean isLockable()
+    {
+        return (m_lockCount == 0) || (m_lockThread == Thread.currentThread());
+    }
+
+    public synchronized void lock()
+    {
+        if ((m_lockCount > 0) && (m_lockThread != Thread.currentThread()))
+        {
+            throw new IllegalStateException("Bundle is locked by another thread.");
+        }
+        m_lockCount++;
+        m_lockThread = Thread.currentThread();
+    }
+
+    public synchronized void unlock()
+    {
+        if (m_lockCount == 0)
+        {
+            throw new IllegalStateException("Bundle is not locked.");
+        }
+        if ((m_lockCount > 0) && (m_lockThread != Thread.currentThread()))
+        {
+            throw new IllegalStateException("Bundle is locked by another thread.");
+        }
+        m_lockCount--;
+        if (m_lockCount == 0)
+        {
+            m_lockThread = null;
+        }
+    }
+
+    public synchronized void syncLock(BundleInfo info)
+    {
+        m_lockCount = info.m_lockCount;
+        m_lockThread = info.m_lockThread;
+    }
+    
+    public synchronized void setProtectionDomain(ProtectionDomain pd)
+    {
+        getCurrentModule().getContentLoader().setSecurityContext(pd);
+    }
+    
+    public synchronized ProtectionDomain getProtectionDomain()
+    {
+        ProtectionDomain pd = null;
+        
+        for (int i = m_modules.length - 1; (i >= 0) && (pd == null); i--)
+        {
+            pd = (ProtectionDomain) 
+                m_modules[i].getContentLoader().getSecurityContext();
+        }
+        
+        return pd;
+    }
+}
\ No newline at end of file

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/felix/framework/src/main/java/org/apache/felix/framework/BundleInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message