Author: marrs
Date: Wed Jun  6 02:11:21 2007
New Revision: 544776

URL: http://svn.apache.org/viewvc?view=rev&rev=544776
Log:
FELIX-50 Added support for configuration dependencies. Read the JavaDoc of 
ConfigurationDependency for more info.
Updated all headers to contain the correct license information and @author.
Fixed an issue with methods not becoming accessible (which was caused by some 
strange, undocumented behaviour).
Fixed an issue that prevented callback methods in superclasses from being 
invocable.

Added:
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java
Modified:
    felix/trunk/dependencymanager/pom.xml
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DefaultNullObject.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Service.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTracker.java
    
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTrackerCustomizer.java

Modified: felix/trunk/dependencymanager/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/pom.xml?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- felix/trunk/dependencymanager/pom.xml (original)
+++ felix/trunk/dependencymanager/pom.xml Wed Jun  6 02:11:21 2007
@@ -15,6 +15,12 @@
       <version>${pom.version}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>${pom.version}</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java?view=auto&rev=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java
 (added)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java
 Wed Jun  6 02:11:21 2007
@@ -0,0 +1,127 @@
+/*
+ * 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.dependencymanager;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+/**
+ * Configuration dependency that can track the availability of a (valid) 
configuration.
+ * To use it, specify a PID for the configuration. The dependency is always 
required,
+ * because if it is not, it does not make sense to use the dependency manager. 
In that
+ * scenario, simply register your service as a 
<code>ManagedService(Factory></code> and
+ * handle everything yourself. Also, only managed services are supported, not 
factories.
+ * There are a couple of things you need to be aware of when implementing the
+ * <code>updated(Dictionary)</code> method:
+ * <li>
+ * <ul>Make sure it throws a <code>ConfigurationException</code> when you get a
+ * configuration that is invalid. In this case, the dependency will not change:
+ * if it was not available, it will still not be. If it was available, it will
+ * remain available and implicitly assume you keep working with your old
+ * configuration.</ul>
+ * <ul>This method will be called before all required dependencies are 
available.
+ * Make sure you do not depend on these to parse your settings.</ul>
+ * </li>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ */
+public class ConfigurationDependency implements Dependency, ManagedService {
+       private BundleContext m_context;
+       private String m_pid;
+       private ServiceRegistration m_registration;
+       private volatile Service m_service;
+       private Dictionary m_settings;
+       
+       public ConfigurationDependency(BundleContext context) {
+               m_context = context;
+       }
+       
+       public boolean isAvailable() {
+               return m_settings != null;
+       }
+
+       public boolean isRequired() {
+               return true;
+       }
+       
+       public void start(Service service) {
+               m_service = service;
+               Properties props = new Properties();
+               props.put(Constants.SERVICE_PID, m_pid);
+               m_registration = 
m_context.registerService(ManagedService.class.getName(), this, props);
+       }
+
+       public void stop(Service service) {
+               m_registration.unregister();
+               m_service = null;
+       }
+
+       public void updated(Dictionary settings) throws ConfigurationException {
+               // if non-null settings come in, we have to instantiate the 
service and
+               // apply these settings
+               ((ServiceImpl) m_service).initService();
+               Object service = m_service.getService();
+               if (service != null) {
+                       if (service instanceof ManagedService) {
+                               ManagedService ms = (ManagedService) service;
+                               ms.updated(settings);
+                               
+                               // if exception is thrown here, what does that 
mean for the
+                               // state of this dependency? how smart do we 
want to be??
+                               // it's okay like this, if the new settings 
contain errors, we
+                               // remain in the state we were, assuming that 
any error causes
+                               // the "old" configuration to stay in effect
+                       }
+               }
+               else {
+                       throw new IllegalStateException("Could not instantiate 
implementation");
+               }
+               // if these settings did not cause a configuration exception, 
we determine
+               // if they have caused the dependency state to change
+               Dictionary oldSettings = m_settings;
+               m_settings = settings;
+               if ((oldSettings == null) && (settings != null)) {
+                       m_service.dependencyAvailable(this);
+               }
+               if ((oldSettings == null) && (settings == null)) {
+                       m_service.dependencyUnavailable(this);
+               }
+               if ((oldSettings != null) && (settings != null)) {
+                       m_service.dependencyChanged(this);
+               }
+       }
+
+       public ConfigurationDependency setPid(String pid) {
+               ensureNotActive();
+               m_pid = pid;
+               return this;
+       }
+       
+    private void ensureNotActive() {
+        if (m_service != null) {
+            throw new IllegalStateException("Cannot modify state while 
active.");
+        }
+    }
+}

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DefaultNullObject.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DefaultNullObject.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DefaultNullObject.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DefaultNullObject.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -24,7 +26,7 @@
  * Default null object implementation. Uses a dynamic proxy. Null objects are 
used
  * as placeholders for services that are not available.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public class DefaultNullObject implements InvocationHandler {
     private static final Boolean DEFAULT_BOOLEAN = Boolean.FALSE;

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -28,7 +30,7 @@
  * methods. State changes of the dependency itself may only be made as long as
  * the dependency is not 'active', meaning it is associated with a running 
service.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public interface Dependency {
     /**

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -28,7 +30,7 @@
  * the bundle context and the dependency manager. The dependency manager can 
be used
  * to define all the dependencies.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public abstract class DependencyActivatorBase implements BundleActivator {
     private BundleContext m_context;
@@ -101,6 +103,15 @@
      */
     public ServiceDependency createServiceDependency() {
         return new ServiceDependency(m_context);
+    }
+    
+    /**
+     * Creates a new configuration dependency.
+     * 
+     * @return the configuration dependency
+     */
+    public ConfigurationDependency createConfigurationDependency() {
+       return new ConfigurationDependency(m_context);
     }
 
     /**

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -25,7 +27,7 @@
 /**
  * The dependency manager. Manages all services and their dependencies.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public class DependencyManager {
     private BundleContext m_context;

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Service.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Service.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Service.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/Service.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -24,7 +26,7 @@
 /**
  * Service interface.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public interface Service {
     /**

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
 Wed Jun  6 02:11:21 2007
@@ -1,22 +1,23 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
-import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -29,7 +30,7 @@
 /**
  * Service dependency that can track an OSGi service.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public class ServiceDependency implements Dependency, ServiceTrackerCustomizer 
{
     private boolean m_isRequired;

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
 Wed Jun  6 02:11:21 2007
@@ -1,23 +1,26 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -31,7 +34,7 @@
 /**
  * Service implementation.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public class ServiceImpl implements Service {
     private static final ServiceRegistration NULL_REGISTRATION;
@@ -237,12 +240,22 @@
     private void invoke(String name) {
         if (name != null) {
             // invoke method if it exists
-            
AccessibleObject.setAccessible(m_serviceInstance.getClass().getDeclaredMethods(),
 true);
             try {
-                m_serviceInstance.getClass().getDeclaredMethod(name, 
null).invoke(m_serviceInstance, null);
-            }
-            catch (NoSuchMethodException e) {
-                // ignore this, we don't care if the method does not exist
+                Class clazz = m_serviceInstance.getClass();
+                while (clazz != null) {
+                       try {
+                       Method method = clazz.getDeclaredMethod(name, null);
+                               if (method != null) {
+                                       AccessibleObject.setAccessible(new 
AccessibleObject[] { method }, true);
+                                       method.invoke(m_serviceInstance, null);
+                                       return;
+                               }
+                       }
+                       catch (NoSuchMethodException e) {
+                               // ignore this, we keep searching if the method 
does not exist
+                       }
+                       clazz = clazz.getSuperclass();
+                }
             }
             catch (Exception e) {
                 // TODO handle this exception
@@ -340,26 +353,27 @@
         }
     }
 
-    private void initService() {
-        if (m_implementation instanceof Class) {
-            // instantiate
-            try {
-                m_serviceInstance = ((Class) m_implementation).newInstance();
-            } catch (InstantiationException e) {
-                // TODO handle this exception
-                e.printStackTrace();
-            } catch (IllegalAccessException e) {
-                // TODO handle this exception
-                e.printStackTrace();
-            }
-        }
-        else {
-            m_serviceInstance = m_implementation;
-        }
-        // configure the bundle context
-        configureImplementation(BundleContext.class, m_context);
-        configureImplementation(ServiceRegistration.class, NULL_REGISTRATION);
-        
+    void initService() {
+       if (m_serviceInstance == null) {
+               if (m_implementation instanceof Class) {
+                   // instantiate
+                   try {
+                       m_serviceInstance = ((Class) 
m_implementation).newInstance();
+                   } catch (InstantiationException e) {
+                       // TODO handle this exception
+                       e.printStackTrace();
+                   } catch (IllegalAccessException e) {
+                       // TODO handle this exception
+                       e.printStackTrace();
+                   }
+               }
+               else {
+                   m_serviceInstance = m_implementation;
+               }
+               // configure the bundle context
+               configureImplementation(BundleContext.class, m_context);
+               configureImplementation(ServiceRegistration.class, 
NULL_REGISTRATION);
+       }        
     }
     
     private void configureService() {

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -25,7 +27,7 @@
  * A wrapper around a service registration that blocks until the
  * service registration is available.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public class ServiceRegistrationImpl implements ServiceRegistration {
     public static final ServiceRegistrationImpl ILLEGAL_STATE = new 
ServiceRegistrationImpl();

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -22,7 +24,7 @@
  * when the service is starting, started, stopping and stopped. Each callback
  * includes a reference to the service in question.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public interface ServiceStateListener {
     /**

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTracker.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTracker.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTracker.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTracker.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -34,7 +36,7 @@
  * integrate only the parts I want as soon as this code is finished. Perhaps
  * it would be better to borrow the Knopflerfish implementation here.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public class ServiceTracker implements ServiceTrackerCustomizer
 {

Modified: 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTrackerCustomizer.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTrackerCustomizer.java?view=diff&rev=544776&r1=544775&r2=544776
==============================================================================
--- 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTrackerCustomizer.java
 (original)
+++ 
felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceTrackerCustomizer.java
 Wed Jun  6 02:11:21 2007
@@ -1,18 +1,20 @@
 /*
- *   Copyright 2006 The Apache Software Foundation
+ * 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
  *
- *   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.
+ *   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.dependencymanager;
 
@@ -23,7 +25,7 @@
  * extra callback "addedservice" that is invoked after the service has been 
added
  * to the tracker (and therefore is accessible through the tracker API)
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
 public interface ServiceTrackerCustomizer {
     public Object addingService(ServiceReference ref);


Reply via email to