You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2006/10/30 17:36:06 UTC

svn commit: r469182 [3/6] - in /incubator/felix/trunk: ipojo.metadata/ ipojo.metadata/src/main/java/org/apache/felix/ipojo/metadata/ ipojo.plugin/ ipojo.plugin/src/main/java/org/apache/felix/ipojo/manipulation/ ipojo.plugin/src/main/java/org/apache/fel...

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java Mon Oct 30 08:36:04 2006
@@ -1,24 +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.ipojo.architecture;
 
-import java.util.HashMap;
-
-
 /**
  * Component Description.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
@@ -32,19 +31,14 @@
     private String m_className;
 
     /**
-     * List of provided service.
+     * The name of the component (instance).
      */
-    private ProvidedServiceDescription[] m_provideServices = new ProvidedServiceDescription[0];
+    private String m_name;
 
     /**
-     * List of dependencies.
+     * Handlers of the component instance.
      */
-    private DependencyDescription[] m_dependencies = new DependencyDescription[0];
-
-    /**
-     * Hashmap [Instance reference, service reference] of the used service.
-     */
-    private HashMap m_usedServices = new HashMap();
+    private HandlerDescription[] m_handlers = new HandlerDescription[0];
 
     /**
      * Created Instances of the components.
@@ -57,18 +51,30 @@
     private int m_state;
 
     /**
+     * BundleId of the component.
+     */
+    private long m_bundleId;
+
+    /**
      * Constructor.
      * @param name : the name of the component (the class name).
      * @param state : the state of the component.
      */
-    public ComponentDescription(String name, int state) {
-        m_className = name;
+    public ComponentDescription(String name, String className, int state, long bundleId) {
+        m_name = name;
+        m_className = className;
         m_state = state;
-        m_usedServices.clear();
         m_instances = new String[0];
+        m_handlers = new HandlerDescription[0];
+        m_bundleId = bundleId;
     }
 
     /**
+     * @return the name of the component.
+     */
+    public String getName() { return m_name; }
+
+    /**
      * @return the created instances
      */
     public String[] getInstances() { return m_instances; }
@@ -84,67 +90,43 @@
     public String getClassName() { return m_className; }
 
     /**
-     * @return the live dependency list
-     */
-    public DependencyDescription[] getDependencies() { return m_dependencies; }
-
-    /**
-     * @return the live provided service list
+     * @return the live handler list
      */
-    public ProvidedServiceDescription[] getProvideServices() { return m_provideServices; }
+    public HandlerDescription[] getHandlers() { return m_handlers; }
 
     /**
-     * Add a dependency.
-     * @param dep : the dependency to add
+     * Add an handler description to the list.
+     * @param hd : the handler description to add
      */
-    public void addDependency(DependencyDescription dep) {
+    public void addHandler(HandlerDescription hd) {
         // Verify that the dependency description is not already in the array.
-        for (int i = 0; (i < m_dependencies.length); i++) {
-            if (m_dependencies[i] == dep) {
+        for (int i = 0; (i < m_handlers.length); i++) {
+            if (m_handlers[i] == hd) {
                 return; //NOTHING TO DO, the description is already in the array
             }
         }
             // The component Description is not in the array, add it
-            DependencyDescription[] newDep = new DependencyDescription[m_dependencies.length + 1];
-            System.arraycopy(m_dependencies, 0, newDep, 0, m_dependencies.length);
-            newDep[m_dependencies.length] = dep;
-            m_dependencies = newDep;
-    }
-
-    /**
-     * Add a provided service.
-     * @param pds : the provided service to add
-     */
-    public void addProvidedService(ProvidedServiceDescription pds) {
-        //Verify that the provided service description is not already in the array.
-        for (int i = 0; (i < m_provideServices.length); i++) {
-            if (m_provideServices[i] == pds) {
-                return; //NOTHING DO DO, the description is already in the array
-            }
-        }
-
-            // The component Description is not in the array, add it
-            ProvidedServiceDescription[] newPSD = new ProvidedServiceDescription[m_provideServices.length + 1];
-            System.arraycopy(m_provideServices, 0, newPSD, 0, m_provideServices.length);
-            newPSD[m_provideServices.length] = pds;
-            m_provideServices = newPSD;
-
+            HandlerDescription[] newHd = new HandlerDescription[m_handlers.length + 1];
+            System.arraycopy(m_handlers, 0, newHd, 0, m_handlers.length);
+            newHd[m_handlers.length] = hd;
+            m_handlers = newHd;
     }
 
     /**
      * Set the state of the component.
      * @param i : the state
      */
-    public void setState(int i) {
-        m_state = i;
-    }
+    public void setState(int i) { m_state = i; }
 
     /**
      * @return the state of the component.
      */
-    public int getState() {
-        return m_state;
-    }
+    public int getState() { return m_state; }
+
+    /**
+     * @return the bundle id owning the component implementation class.
+     */
+    public long getBundleId() { return m_bundleId; }
 
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java Mon Oct 30 08:36:04 2006
@@ -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.ipojo.architecture;
 
@@ -50,57 +52,41 @@
      * Filter.
      */
     private String m_filter;
+
     /**
      * Hashmap [Instance reference, service reference] of the used service.
      */
     private HashMap m_usedServices = new HashMap();
 
-
     /**
      * The list of service reference.
      */
     private ServiceReference[] m_serviceReferences;
 
     /**
-     * Parent of the dependency either de ProvidedServiceDescription or a ComponentDescription.
-     */
-    private Object m_parent;
-
-
-    /**
      * @return true if the dependency is a multiple dependency.
      */
-    public boolean isMultiple() {
-        return m_multiple;
-    }
+    public boolean isMultiple() { return m_multiple; }
 
     /**
      * @return true if the dependency is an optional dependency.
      */
-    public boolean isOptional() {
-        return m_optional;
-    }
+    public boolean isOptional() { return m_optional; }
 
     /**
      * @return the filter.
      */
-    public String getFilter() {
-        return m_filter;
-    }
+    public String getFilter() { return m_filter; }
 
     /**
      * @return the needed interface.
      */
-    public String getInterface() {
-        return m_interface;
-    }
+    public String getInterface() { return m_interface; }
 
     /**
      * @return the state of the dependency.
      */
-    public int getState() {
-        return m_state;
-    }
+    public int getState() { return m_state; }
 
     /**
      * Constructor.
@@ -119,37 +105,23 @@
         m_filter = filter;
         m_state = state;
         m_serviceReferences = new ServiceReference[0];
-        m_parent = parent;
     }
 
     /**
      * @return the array of service reference (only if the cardinality could be n).
      */
-    public ServiceReference[] getServiceReferences() {
-        return m_serviceReferences;
-    }
+    public ServiceReference[] getServiceReferences() { return m_serviceReferences; }
 
     /**
      * @return the ServiceReference (only if the cardinality could be 1).
      */
-    public ServiceReference getServiceReference() {
-        return m_serviceReferences[0];
-    }
+    public ServiceReference getServiceReference() { return m_serviceReferences[0]; }
 
     /**
      * Set the service reference array.
      * @param sr : the array of service reference
      */
-    public void setServiceReferences(ServiceReference[] sr) {
-        m_serviceReferences = sr;
-    }
-
-    /**
-     * @return the parent of the dependency
-     */
-    public Object getParent() {
-        return m_parent;
-    }
+    public void setServiceReferences(ServiceReference[] sr) { m_serviceReferences = sr; }
 
     /**
      * @return the hashmap [object reference, service reference] containing the used services
@@ -161,7 +133,7 @@
      * @param hm : the new usedService
      */
     public void setUsedServices(HashMap hm) {
-    	m_usedServices = hm;
+        m_usedServices = hm;
     }
 
 

Added: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java?view=auto&rev=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java (added)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java Mon Oct 30 08:36:04 2006
@@ -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.felix.ipojo.architecture;
+
+import java.util.Iterator;
+import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
+
+/**
+ * Dependency Handler Description.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class DependencyHandlerDescription extends HandlerDescription {
+
+
+    /**
+     * Dependencies managed by the dependency handler.
+     */
+    private DependencyDescription[] m_dependencies = new DependencyDescription[0];
+
+    /**
+     * Constructor.
+     * @param isValid : the validity of the dependency handler.
+     */
+    public DependencyHandlerDescription(boolean isValid) {
+        super(DependencyHandler.class.getName(), isValid);
+    }
+
+    /**
+     * @return the dependencies list.
+     */
+    public DependencyDescription[] getDependencies() { return m_dependencies; }
+
+    /**
+     * Add a dependency.
+     * @param dep : the dependency to add
+     */
+    public void addDependency(DependencyDescription dep) {
+        // Verify that the dependency description is not already in the array.
+        for (int i = 0; (i < m_dependencies.length); i++) {
+            if (m_dependencies[i] == dep) {
+                return; //NOTHING TO DO, the description is already in the array
+            }
+        }
+        // The component Description is not in the array, add it
+        DependencyDescription[] newDep = new DependencyDescription[m_dependencies.length + 1];
+        System.arraycopy(m_dependencies, 0, newDep, 0, m_dependencies.length);
+        newDep[m_dependencies.length] = dep;
+        m_dependencies = newDep;
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
+     */
+    public String getHandlerInfo() {
+        String info = "";
+        for (int i = 0; i < m_dependencies.length; i++) {
+            String state = "resolved";
+            if (m_dependencies[i].getState() == 2) { state = "unresolved"; }
+            info += "\t Dependency on " + m_dependencies[i].getInterface() + "[" + m_dependencies[i].getFilter() + "] is " + state;
+            Iterator it = m_dependencies[i].getUsedServices().keySet().iterator();
+            while (it.hasNext()) {
+                info += "\n \t\t Uses : " + it.next();
+            }
+        }
+        return info;
+    }
+
+}

Propchange: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/HandlerDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/HandlerDescription.java?view=auto&rev=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/HandlerDescription.java (added)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/HandlerDescription.java Mon Oct 30 08:36:04 2006
@@ -0,0 +1,65 @@
+/* 
+ * 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.ipojo.architecture;
+
+
+/**
+ * Handler Description.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class HandlerDescription {
+
+
+    /**
+     * Handler Class Name (i.e namespace).
+     */
+    private String m_handlerName;
+
+    /**
+     * Is the handler valid.
+     */
+    private boolean m_isValid;
+
+
+    /**
+     * Constructor.
+     * @param name : handler name
+     * @param isValid : is the handler valid
+     */
+    public HandlerDescription(String name, boolean isValid) {
+        m_handlerName = name;
+        m_isValid = isValid;
+    }
+
+    /**
+     * @return true if the handler is valid.
+     */
+    public boolean isValid() { return m_isValid; }
+
+    /**
+     * @return the handler name (i.e. namespace).
+     */
+    public String getHandlerName() { return m_handlerName; }
+
+    /**
+     * @return the handler information.
+     */
+    public String getHandlerInfo() { return ""; };
+
+}

Propchange: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/HandlerDescription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java Mon Oct 30 08:36:04 2006
@@ -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.ipojo.architecture;
 
@@ -36,7 +38,6 @@
      */
     private DependencyDescription[] m_dependencies = new DependencyDescription[0];
 
-
     /**
      * State.
      */
@@ -47,7 +48,6 @@
      */
     private ServiceReference m_serviceReference;
 
-
     /**
      * Handler on the component description who contains this description.
      */
@@ -91,11 +91,11 @@
                 return; //NOTHING DO DO, the description is already in the array
             }
         }
-            // The component Description is not in the array, add it
-            DependencyDescription[] newDep = new DependencyDescription[m_dependencies.length + 1];
-            System.arraycopy(m_dependencies, 0, newDep, 0, m_dependencies.length);
-            newDep[m_dependencies.length] = dep;
-            m_dependencies = newDep;
+        // The component Description is not in the array, add it
+        DependencyDescription[] newDep = new DependencyDescription[m_dependencies.length + 1];
+        System.arraycopy(m_dependencies, 0, newDep, 0, m_dependencies.length);
+        newDep[m_dependencies.length] = dep;
+        m_dependencies = newDep;
     }
 
     /**
@@ -112,7 +112,7 @@
      * @param props : the properties
      */
     public void setProperty(Properties props) {
-        m_properties = (Properties)props.clone();
+        m_properties = (Properties) props.clone();
     }
 
     /**

Added: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java?view=auto&rev=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java (added)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java Mon Oct 30 08:36:04 2006
@@ -0,0 +1,93 @@
+/* 
+ * 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.ipojo.architecture;
+
+import java.util.Iterator;
+
+import org.apache.felix.ipojo.handlers.providedservice.ProvidedService;
+import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler;
+
+/**
+ * Provided Service Handler Description.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class ProvidedServiceHandlerDescription extends HandlerDescription {
+
+    /**
+     * Provided Service Description list.
+     */
+    private ProvidedServiceDescription[] m_providedServices = new ProvidedServiceDescription[0];
+
+
+    /**
+     * Constructor.
+     * @param isValid : the validity of the provided service handler.
+     */
+    public ProvidedServiceHandlerDescription(boolean isValid) {
+        super(ProvidedServiceHandler.class.getName(), isValid);
+    }
+
+    /**
+     * @return the provided service description list.
+     */
+    public ProvidedServiceDescription[] getProvidedServices() { return m_providedServices; }
+
+    /**
+     * Add a provided service.
+     * @param pds : the provided service to add
+     */
+    public void addProvidedService(ProvidedServiceDescription pds) {
+        //Verify that the provided service description is not already in the array.
+        for (int i = 0; (i < m_providedServices.length); i++) {
+            if (m_providedServices[i] == pds) {
+                return; //NOTHING DO DO, the description is already in the array
+            }
+        }
+        // The component Description is not in the array, add it
+        ProvidedServiceDescription[] newPSD = new ProvidedServiceDescription[m_providedServices.length + 1];
+        System.arraycopy(m_providedServices, 0, newPSD, 0, m_providedServices.length);
+        newPSD[m_providedServices.length] = pds;
+        m_providedServices = newPSD;
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
+     */
+    public String getHandlerInfo() {
+        String info = "";
+        for (int i = 0; i < m_providedServices.length; i++) {
+            String state = "unregistered";
+            if (m_providedServices[i].getState() == ProvidedService.REGISTERED) { state = "registered"; }
+            String spec = "";
+            for (int j = 0; j < m_providedServices[i].getServiceSpecification().length; j++) {
+                spec += m_providedServices[i].getServiceSpecification()[j] + " ";
+            }
+            info += "\t Provided Service [" + spec + "] is " + state;
+            Iterator it = m_providedServices[i].getProperties().keySet().iterator();
+            while (it.hasNext()) {
+                String k = (String) it.next();
+                info += "\n\t\t Service Property : " + k + " = " + m_providedServices[i].getProperties().getProperty(k);
+            }
+        }
+        return info;
+    }
+
+
+
+}

Propchange: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java Mon Oct 30 08:36:04 2006
@@ -1,30 +1,35 @@
-/*
- *   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.ipojo.handlers.architecture;
 
 import java.util.Dictionary;
 import java.util.Properties;
 
-import org.apache.felix.ipojo.ComponentManager;
+import org.apache.felix.ipojo.ComponentManagerImpl;
 import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.architecture.Architecture;
 import org.apache.felix.ipojo.architecture.ComponentDescription;
 import org.apache.felix.ipojo.architecture.DependencyDescription;
+import org.apache.felix.ipojo.architecture.DependencyHandlerDescription;
+import org.apache.felix.ipojo.architecture.HandlerDescription;
 import org.apache.felix.ipojo.architecture.ProvidedServiceDescription;
+import org.apache.felix.ipojo.architecture.ProvidedServiceHandlerDescription;
 import org.apache.felix.ipojo.handlers.dependency.Dependency;
 import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
 import org.apache.felix.ipojo.handlers.dependency.DependencyMetadata;
@@ -42,12 +47,12 @@
  * Achtiecture Handler : do reflection on your component.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class ArchitectureHandler implements Handler, Architecture {
+public class ArchitectureHandler extends Handler implements Architecture {
 
-	/**
-	 * Component Manager.
-	 */
-	private ComponentManager m_manager;
+    /**
+     * Component Manager.
+     */
+    private ComponentManagerImpl m_manager;
 
     /**
      * Service Registration of the Architecture service provided by this handler.
@@ -55,123 +60,113 @@
     private ServiceRegistration m_sr;
 
     /**
-     * Unique name of the component : either the name of the component, either the classname if the name if not setted.
+     * Name of the component.
      */
     private String m_name;
 
-	/**
-	 * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManager, org.apache.felix.ipojo.metadata.Element)
-	 */
-	public void configure(ComponentManager cm, Element metadata) {
-		if (metadata.containsAttribute("architecture")) {
-			String isArchitectureEnabled = (metadata.getAttribute("architecture")).toLowerCase();
-			if (isArchitectureEnabled.equals("true")) { cm.register(this); }
-		}
-
-		if (metadata.containsAttribute("name")) { m_name = metadata.getAttribute("name"); }
-		else { m_name = metadata.getAttribute("className"); }
-
-		m_manager = cm;
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#stop()
-	 */
-	public void stop() {
+    /**
+     * Component Type.
+     */
+    private String m_className;
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManagerImpl, org.apache.felix.ipojo.metadata.Element)
+     */
+    public void configure(ComponentManagerImpl cm, Element metadata, Dictionary configuration) {
+        if (metadata.containsAttribute("architecture")) {
+            String isArchitectureEnabled = (metadata.getAttribute("architecture")).toLowerCase();
+            if (isArchitectureEnabled.equals("true")) { cm.register(this); }
+        }
+
+        m_className = metadata.getAttribute("className");
+
+        m_name = (String) configuration.get("name");
+
+        m_manager = cm;
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#stop()
+     */
+    public void stop() {
         try {
             if (m_sr != null) { m_sr.unregister(); }
         } catch (Exception e) { return; }
-	}
+    }
 
-	/**
-	 * @see org.apache.felix.ipojo.Handler#start()
-	 */
-	public void start() {
-		// Unregister the service if already registred
-		if (m_sr != null) { m_sr.unregister(); }
-
-		// Register the ManagedService
-		BundleContext bc = m_manager.getContext();
-		Dictionary properties = new Properties();
-		properties.put("Component Implementation Class", m_manager.getComponentMetatada().getClassName());
-		properties.put(Constants.SERVICE_PID, m_name);
-
-		m_sr = bc.registerService(Architecture.class.getName(), this, properties);
-
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#setterCallback(java.lang.String, java.lang.Object)
-	 */
-	public void setterCallback(String fieldName, Object value) { // Nothing to do
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
-	 */
-	public Object getterCallback(String fieldName, Object value) { return value; }
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#isValid()
-	 */
-	public boolean isValid() { return true; }
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#stateChanged(int)
-	 */
-	public void stateChanged(int state) {
-		// Nothing to do
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.architecture.Architecture#getComponentDescription()
-	 */
-	public ComponentDescription getComponentDescription() {
-		int componentState = m_manager.getState();
-		ComponentDescription componentDescription = new ComponentDescription(m_name, componentState);
-
-		String[] instances = new String[m_manager.getInstances().length];
-		for (int i = 0; i < m_manager.getInstances().length; i++) {
-			instances[i] = m_manager.getInstances()[i].toString();
-		}
-		componentDescription.setInstances(instances);
-
-		Handler[] handlers = m_manager.getRegistredHandlers();
-		for (int i = 0; i < handlers.length; i++) {
-			if (handlers[i] instanceof DependencyHandler) {
-				DependencyHandler dh = (DependencyHandler)handlers[i];
-				for (int j = 0; j < dh.getDependencies().length; j++) {
-					Dependency dep = dh.getDependencies()[j];
-					DependencyMetadata dm = dep.getMetadata();
-
-					// Create & add the dependency description
-					DependencyDescription dd = new DependencyDescription(dm.getServiceSpecification(), dm.isMultiple(), dm.isOptional(), dm.getFilter(), dep.getState(), componentDescription);
-					dd.setUsedServices(dep.getUsedServices());
-					componentDescription.addDependency(dd);
-				}
-			}
-			if (handlers[i] instanceof ProvidedServiceHandler) {
-				ProvidedServiceHandler psh = (ProvidedServiceHandler)handlers[i];
-				for (int j = 0; j < psh.getProvidedService().length; j++) {
-					ProvidedService ps = psh.getProvidedService()[j];
-					ProvidedServiceMetadata psm = ps.getMetadata();
-					ProvidedServiceDescription psd = new ProvidedServiceDescription(psm.getServiceSpecification(), ps.getState(), ps.getServiceReference(), componentDescription);
-
-					Properties props = new Properties();
-					for (int k = 0; k < ps.getProperties().length; k++) {
-						Property prop = ps.getProperties()[k];
-						PropertyMetadata pm = prop.getMetadata();
-						if (prop.getValue() != null) {
-							props.put(pm.getName(), prop.getValue().toString());
-						}
-					}
-					psd.setProperty(props);
-					componentDescription.addProvidedService(psd);
-				}
-			}
-
-		}
-		return componentDescription;
-	}
+    /**
+     * @see org.apache.felix.ipojo.Handler#start()
+     */
+    public void start() {
+        // Unregister the service if already registred
+        if (m_sr != null) { m_sr.unregister(); }
+
+        // Register the ManagedService
+        BundleContext bc = m_manager.getContext();
+        Dictionary properties = new Properties();
+        properties.put("Component Implementation Class", m_manager.getComponentMetatada().getClassName());
+        properties.put(Constants.SERVICE_PID, m_name);
+
+        m_sr = bc.registerService(Architecture.class.getName(), this, properties);
+
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.architecture.Architecture#getComponentDescription()
+     */
+    public ComponentDescription getComponentDescription() {
+        int componentState = m_manager.getState();
+        ComponentDescription componentDescription = new ComponentDescription(m_className, m_name, componentState, m_manager.getContext().getBundle().getBundleId());
+
+        String[] instances = new String[m_manager.getInstances().length];
+        for (int i = 0; i < m_manager.getInstances().length; i++) {
+            instances[i] = m_manager.getInstances()[i].toString();
+        }
+        componentDescription.setInstances(instances);
+
+        Handler[] handlers = m_manager.getRegistredHandlers();
+        for (int i = 0; i < handlers.length; i++) {
+            if (handlers[i] instanceof DependencyHandler) {
+                DependencyHandler dh = (DependencyHandler) handlers[i];
+                DependencyHandlerDescription dhd = new DependencyHandlerDescription(dh.isValid());
+
+                for (int j = 0; j < dh.getDependencies().length; j++) {
+                    Dependency dep = dh.getDependencies()[j];
+                    DependencyMetadata dm = dep.getMetadata();
+                    // Create & add the dependency description
+                    DependencyDescription dd = new DependencyDescription(dm.getServiceSpecification(), dm.isMultiple(), dm.isOptional(), dm.getFilter(), dep.getState(), componentDescription);
+                    dd.setUsedServices(dep.getUsedServices());
+                    dhd.addDependency(dd);
+                }
+                componentDescription.addHandler(dhd);
+                break;
+            }
+
+            if (handlers[i] instanceof ProvidedServiceHandler) {
+                ProvidedServiceHandler psh = (ProvidedServiceHandler) handlers[i];
+                ProvidedServiceHandlerDescription pshd = new ProvidedServiceHandlerDescription(psh.isValid());
+
+                for (int j = 0; j < psh.getProvidedService().length; j++) {
+                    ProvidedService ps = psh.getProvidedService()[j];
+                    ProvidedServiceMetadata psm = ps.getMetadata();
+                    ProvidedServiceDescription psd = new ProvidedServiceDescription(psm.getServiceSpecification(), ps.getState(), ps.getServiceReference(), componentDescription);
+
+                    Properties props = new Properties();
+                    for (int k = 0; k < ps.getProperties().length; k++) {
+                        Property prop = ps.getProperties()[k];
+                        PropertyMetadata pm = prop.getMetadata();
+                        if (prop.getValue() != null) { props.put(pm.getName(), prop.getValue().toString()); }
+                    }
+                    psd.setProperty(props);
+                    pshd.addProvidedService(psd);
+                }
+                componentDescription.addHandler(pshd);
+                break;
+            }
+            // Else add a generic handler to the description
+            componentDescription.addHandler(new HandlerDescription(handlers[i].getClass().getName(), handlers[i].isValid()));
+        }
+        return componentDescription;
+    }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java Mon Oct 30 08:36:04 2006
@@ -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.ipojo.handlers.configuration;
 
@@ -30,63 +32,80 @@
  */
 public class ConfigurableProperty {
 
-	/**
-	 * Name of the property (filed name if not set).
-	 */
-	private String m_name;
-
-	/**
-	 * Field of the property.
-	 */
-	private String m_field;
-
-	/**
-	 * Value of the property.
-	 */
-	private Object m_value;
-
-	/**
-	 * Configuration Handler managing this property.
-	 */
-	private ConfigurationHandler m_handler;
-
-	/**
-	 * Configurable Property Constructor.
-	 * @param name : name of the property (optional)
-	 * @param field : name of the field (mandatory)
-	 * @param value : initial value of the property (optional)
-	 * @param ch : configuration handler managing this configurable property
-	 */
-	public ConfigurableProperty(String name, String field, String value, ConfigurationHandler ch) {
-		m_handler = ch;
-		if (name != null) { m_name = name; }
-		else { m_name = field; }
-		m_field = field;
+    /**
+     * Name of the property (filed name if not set).
+     */
+    private String m_name;
+
+    /**
+     * Field of the property.
+     */
+    private String m_field;
+
+    /**
+     * Value of the property.
+     */
+    private Object m_value;
+
+    /**
+     * Configuration Handler managing this property.
+     */
+    private ConfigurationHandler m_handler;
+
+    /**
+     * Configurable Property Constructor.
+     * @param name : name of the property (optional)
+     * @param field : name of the field (mandatory)
+     * @param value : initial value of the property (optional)
+     * @param ch : configuration handler managing this configurable property
+     */
+    public ConfigurableProperty(String name, String field, String value, ConfigurationHandler ch) {
+        m_handler = ch;
+        if (name != null) { m_name = name; }
+        else { m_name = field; }
+        m_field = field;
+
+        if (value != null) { setValue(m_field, value); }
+
+    }
+
+    /**
+     * @return the type of a configurable property.
+     */
+    public String getType() {
+        Element manipulation = m_handler.getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
+        String type = null;
+        for (int i = 0; i < manipulation.getElements("Field").length; i++) {
+            if (m_field.equals(manipulation.getElements("Field")[i].getAttribute("name"))) {
+                return manipulation.getElements("Field")[i].getAttribute("type");
+            }
+        }
 
-		if (value != null) { setValue(m_field, value); }
+        if (type == null) { Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] The field " + m_field + " does not exist in the implementation"); }
+        return null;
 
-	}
+    }
 
-	/**
+    /**
      * Set the value of the property.
      * @param strValue : value of the property (String)
      */
     private void setValue(String field, String strValue) {
-    	// Look for the type of the field
-    	Element manipulation = m_handler.getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
-    	String type = null;
-    	for (int i = 0; i < manipulation.getElements("Field").length; i++) {
-    		if (field.equals(manipulation.getElements("Field")[i].getAttribute("name"))) {
-    			type = manipulation.getElements("Field")[i].getAttribute("type");
-    			break;
-    		}
-    	}
+        // Look for the type of the field
+        Element manipulation = m_handler.getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
+        String type = null;
+        for (int i = 0; i < manipulation.getElements("Field").length; i++) {
+            if (field.equals(manipulation.getElements("Field")[i].getAttribute("name"))) {
+                type = manipulation.getElements("Field")[i].getAttribute("type");
+                break;
+            }
+        }
 
-    	if (type == null) { Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] The field " + field + " does not exist in the implementation"); return; }
+        if (type == null) { Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] The field " + field + " does not exist in the implementation"); return; }
 
-    	Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Set the value of the configurable property " + field + " [" + type + "] " + " with the value : " + strValue);
+        Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Set the value of the configurable property " + field + " [" + type + "] " + " with the value : " + strValue);
 
-    	Object value = null;
+        Object value = null;
 
         if (type.equals("string") || type.equals("String")) { value = new String(strValue); }
         if (type.equals("boolean")) { value = new Boolean(strValue); }
@@ -96,95 +115,100 @@
         if (type.equals("long")) { value = new Long(strValue); }
         if (type.equals("float")) { value = new Float(strValue); }
         if (type.equals("double")) { value = new Double(strValue); }
-    	// Array :
-    	if (type.endsWith("[]")) {
-    		String internalType = type.substring(0, type.length() - 2);
-    		strValue = strValue.substring(1, strValue.length() - 1);
-    		String[] values = strValue.split(",");
-    		setArrayValue(internalType, values);
-    		return;
-    	}
+        // Array :
+        if (type.endsWith("[]")) {
+            String internalType = type.substring(0, type.length() - 2);
+            strValue = strValue.substring(1, strValue.length() - 1);
+            String[] values = strValue.split(",");
+            setArrayValue(internalType, values);
+            return;
+        }
 
         if (value == null) {
-        	// Else it is a neither a primitive type neither a String -> create the object by calling a constructor with a string in argument.
-        	try {
-        		Class c = m_handler.getComponentManager().getContext().getBundle().loadClass(type);
-        		Constructor cst = c.getConstructor(new Class[] {String.class});
-        		value = cst.newInstance(new Object[] {strValue});
-        	} catch (ClassNotFoundException e) {
-        		System.err.println("Class not found exception in setValue on " + type);
-        		e.printStackTrace();
-        		return;
-        	} catch (SecurityException e) {
-        		e.printStackTrace();
-        		return;
-        	} catch (NoSuchMethodException e) {
-        		System.err.println("Constructor not found exeption in setValue on " + type);
-        		e.printStackTrace();
-        		return;
-        	} catch (IllegalArgumentException e) {
-        		System.err.println("Argument problem to call the constructor of the type " + type);
-        		e.printStackTrace();
-        		return;
-        	} catch (InstantiationException e) {
-        		System.err.println("Instantiation problem  " + type);
-        		e.printStackTrace();
-        		return;
-        	} catch (IllegalAccessException e) {
-        		e.printStackTrace();
-        	} catch (InvocationTargetException e) {
-        		System.err.println("Invocation problem " + type);
-        		e.printStackTrace();
-        		return;
-        	}
+            // Else it is a neither a primitive type neither a String -> create the object by calling a constructor with a string in argument.
+            try {
+                Class c = m_handler.getComponentManager().getContext().getBundle().loadClass(type);
+                Constructor cst = c.getConstructor(new Class[] {String.class});
+                value = cst.newInstance(new Object[] {strValue});
+            } catch (ClassNotFoundException e) {
+                System.err.println("Class not found exception in setValue on " + type);
+                e.printStackTrace();
+                return;
+            } catch (SecurityException e) {
+                e.printStackTrace();
+                return;
+            } catch (NoSuchMethodException e) {
+                System.err.println("Constructor not found exeption in setValue on " + type);
+                e.printStackTrace();
+                return;
+            } catch (IllegalArgumentException e) {
+                System.err.println("Argument problem to call the constructor of the type " + type);
+                e.printStackTrace();
+                return;
+            } catch (InstantiationException e) {
+                System.err.println("Instantiation problem  " + type);
+                e.printStackTrace();
+                return;
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                System.err.println("Invocation problem " + type);
+                e.printStackTrace();
+                return;
+            }
         }
 
         m_value = value;
 
     }
 
+    /**
+     * Set array value to the current property.
+     * @param internalType : type of the property
+     * @param values : new property value
+     */
     private void setArrayValue(String internalType, String[] values) {
-   	 if (internalType.equals("string") || internalType.equals("String")) { m_value = values; return; }
+        if (internalType.equals("string") || internalType.equals("String")) { m_value = values; return; }
         if (internalType.equals("boolean")) {
-       	 boolean[] bool = new boolean[values.length];
-       	 for (int i = 0; i < values.length; i++) { bool[i] = new Boolean(values[i]).booleanValue(); }
-       	 m_value = bool;
-       	 return;
-       }
-       if (internalType.equals("byte")) {
-       	byte[] byt = new byte[values.length];
-      	 	for (int i = 0; i < values.length; i++) { byt[i] = new Byte(values[i]).byteValue(); }
-      	 	m_value = byt;
-       	return;
-       }
+            boolean[] bool = new boolean[values.length];
+            for (int i = 0; i < values.length; i++) { bool[i] = new Boolean(values[i]).booleanValue(); }
+            m_value = bool;
+            return;
+        }
+        if (internalType.equals("byte")) {
+            byte[] byt = new byte[values.length];
+            for (int i = 0; i < values.length; i++) { byt[i] = new Byte(values[i]).byteValue(); }
+            m_value = byt;
+            return;
+        }
         if (internalType.equals("short")) {
-       	 short[] shor = new short[values.length];
-       	 for (int i = 0; i < values.length; i++) { shor[i] = new Short(values[i]).shortValue(); }
-       	 m_value = shor;
-       	 return;
-       }
+            short[] shor = new short[values.length];
+            for (int i = 0; i < values.length; i++) { shor[i] = new Short(values[i]).shortValue(); }
+            m_value = shor;
+            return;
+        }
         if (internalType.equals("int")) {
-       	 int[] in = new int[values.length];
-       	 for (int i = 0; i < values.length; i++) { in[i] = new Integer(values[i]).intValue(); }
-       	 m_value = in;
-       	 return;
-       }
+            int[] in = new int[values.length];
+            for (int i = 0; i < values.length; i++) { in[i] = new Integer(values[i]).intValue(); }
+            m_value = in;
+            return;
+        }
         if (internalType.equals("long")) {
-       	 long[] ll = new long[values.length];
-       	 for (int i = 0; i < values.length; i++) { ll[i] = new Long(values[i]).longValue(); }
-       	 m_value = ll;
-       	 return;
-       }
+            long[] ll = new long[values.length];
+            for (int i = 0; i < values.length; i++) { ll[i] = new Long(values[i]).longValue(); }
+            m_value = ll;
+            return;
+        }
         if (internalType.equals("float")) {
-       	 float[] fl = new float[values.length];
-       	 for (int i = 0; i < values.length; i++) { fl[i] = new Float(values[i]).floatValue(); }
-       	 m_value = fl;
-       	 return; }
+            float[] fl = new float[values.length];
+            for (int i = 0; i < values.length; i++) { fl[i] = new Float(values[i]).floatValue(); }
+            m_value = fl;
+            return; }
         if (internalType.equals("double")) {
-       	 double[] dl = new double[values.length];
-       	 for (int i = 0; i < values.length; i++) { dl[i] = new Double(values[i]).doubleValue(); }
-       	 m_value = dl;
-       	 return; }
+            double[] dl = new double[values.length];
+            for (int i = 0; i < values.length; i++) { dl[i] = new Double(values[i]).doubleValue(); }
+            m_value = dl;
+            return; }
 
         // Else it is a neither a primitive type neither a String -> create the object by calling a constructor with a string in argument.
         try {
@@ -192,7 +216,7 @@
             Constructor cst = c.getConstructor(new Class[] {String.class});
             Object[] ob = (Object[]) Array.newInstance(c, values.length);
             for (int i = 0; i < values.length; i++) {
-           	 ob[i] = cst.newInstance(new Object[] {values[i]});
+                ob[i] = cst.newInstance(new Object[] {values[i]});
             }
             m_value = ob;
             return;
@@ -216,7 +240,7 @@
             System.err.println("Invocation problem " + internalType);
             e.printStackTrace();
         }
-	}
+    }
 
     /**
      * @return the name of the property.

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java Mon Oct 30 08:36:04 2006
@@ -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.ipojo.handlers.configuration;
 
@@ -21,11 +23,11 @@
 import java.util.Properties;
 import java.util.logging.Level;
 
-import org.apache.felix.ipojo.ComponentManager;
-import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.Activator;
-import org.apache.felix.ipojo.handlers.providedservice.Property;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedService;
+import org.apache.felix.ipojo.ComponentInfo;
+import org.apache.felix.ipojo.ComponentManagerImpl;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.PropertyInfo;
 import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler;
 import org.apache.felix.ipojo.metadata.Element;
 import org.osgi.framework.BundleContext;
@@ -38,229 +40,261 @@
  * Handler managing the Configuration Admin.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class ConfigurationHandler implements Handler, ManagedService {
+public class ConfigurationHandler extends Handler implements ManagedService {
+
+    /**
+     * Reference on the component manager.
+     */
+    private ComponentManagerImpl m_manager;
+
+    /**
+     * List of the configurable fields.
+     */
+    private ConfigurableProperty[] m_configurableProperties = new ConfigurableProperty[0];
+
+    /**
+     * ProvidedServiceHandler of the component.
+     * It is useful to priopagate properties to service registrations.
+     */
+    private ProvidedServiceHandler m_providedServiceHandler;
+
+    /**
+     * Properties porpagated at the last "updated".
+     */
+    private Dictionary m_propagated = new Properties();
+
+    /**
+     * PID of the component.
+     */
+    private String m_pid;
+
+    /**
+     * should the component provided ManagedService ?
+     */
+    private boolean m_isConfigurable;
+
+    /**
+     * Service registration of the ManagedService provided by this handler.
+     */
+    private ServiceRegistration m_sr;
+
+    /**
+     * @return component manager of this handler.
+     */
+    protected ComponentManagerImpl getComponentManager() { return m_manager; }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManagerImpl, org.apache.felix.ipojo.metadata.Element)
+     */
+    public void configure(ComponentManagerImpl cm, Element metadata, Dictionary configuration) {
+        // Store the component manager
+        m_manager = cm;
+        ComponentInfo ci = cm.getComponentInfo();
+        m_configurableProperties = new ConfigurableProperty[0];
+
+        // Build the hashmap
+        Element[] confs = metadata.getElements("Properties", "");
+        if (confs.length == 0) { return; }
+
+        // Check if the component is dynamically configurable
+        m_isConfigurable = false;
+        if (confs[0].containsAttribute("configurable") && confs[0].getAttribute("configurable").equalsIgnoreCase("true")) { m_isConfigurable = true; }
+
+        Element[] configurables = confs[0].getElements("Property");
+
+        for (int i = 0; i < configurables.length; i++) {
+            String fieldName = configurables[i].getAttribute("field");
+            String name = null;
+            if (configurables[i].containsAttribute("name")) { name = configurables[i].getAttribute("name"); }
+            else { name = fieldName; }
+            String value = null;
+            if (configurables[i].containsAttribute("value")) { value = configurables[i].getAttribute("value"); }
+
+            if (name != null && configuration.get(name) != null && configuration.get(name) instanceof String) { value = (String) configuration.get(name); }
+            else { if (fieldName != null &&  configuration.get(fieldName) != null && configuration.get(fieldName) instanceof String) { value = (String) configuration.get(fieldName); } }
+
+            ConfigurableProperty cp = new ConfigurableProperty(name, fieldName, value, this);
+
+            if (cp.getValue() != null) { ci.addProperty(new PropertyInfo(name, cp.getType(), cp.getValue().toString())); }
+            else { ci.addProperty(new PropertyInfo(name, cp.getType(), "")); }
+
+            addProperty(cp);
+        }
+
+        // Get the PID in the configuration name :
+        if (configuration.get("name") != null) { m_pid = (String) configuration.get("name"); }
+        else { m_pid = metadata.getAttribute("className"); }
+
+        // Get the provided service handler :
+        m_providedServiceHandler = (ProvidedServiceHandler) m_manager.getHandler(ProvidedServiceHandler.class.getName());
+
+        if (configurables.length > 0) {
+            String[] fields = new String[m_configurableProperties.length];
+            for (int k = 0; k < m_configurableProperties.length; k++) {
+                fields[k] = m_configurableProperties[k].getField();
+
+                // Check if the instance configuration contains value for the current property :
+                String name = m_configurableProperties[k].getName();
+                String fieldName = m_configurableProperties[k].getField();
+                if (name != null && configuration.get(name) != null && !(configuration.get(name) instanceof String)) { m_configurableProperties[k].setValue(configuration.get(name)); }
+                else { if (fieldName != null &&  configuration.get(fieldName) != null && !(configuration.get(fieldName) instanceof String)) { m_configurableProperties[k].setValue(configuration.get(fieldName)); } }
+            }
+            m_manager.register(this, fields);
+
+
+
+
+        }
+        else { return; }
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#stop()
+     */
+    public void stop() {
+        // Unregister the service
+        if (m_isConfigurable && m_sr != null) {
+            Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] Unregister Managed Service");
+            m_sr.unregister();
+            m_sr = null;
+        }
+
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#start()
+     */
+    public void start() {
+        // Unregister the service if already registred (it should not happen )
+        if (m_isConfigurable && m_sr != null) { m_sr.unregister(); }
+
+        // Register the ManagedService
+        if (m_isConfigurable) {
+            BundleContext bc = m_manager.getContext();
+            Dictionary properties = new Properties();
+            properties.put(Constants.SERVICE_PID, m_pid);
+
+            Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] Register Managed Service");
+            m_sr = bc.registerService(ManagedService.class.getName(), this, properties);
+        }
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#setterCallback(java.lang.String, java.lang.Object)
+     */
+    public void setterCallback(String fieldName, Object value) {
+        // Verify that the field name correspond to a configurable property
+        for (int i = 0; i < m_configurableProperties.length; i++) {
+            ConfigurableProperty cp = m_configurableProperties[i];
+            if (cp.getName().equals(fieldName)) {
+                // Check if the value has change
+                if (cp.getValue() == null || !cp.getValue().equals(value)) {
+                    cp.setValue(value); // Change the value
+                }
+            }
+        }
+        //Else do nothing
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
+     */
+    public Object getterCallback(String fieldName, Object value) {
+        // Check if the field is a configurable property
+        for (int i = 0; i < m_configurableProperties.length; i++) {
+            if (m_configurableProperties[i].getField().equals(fieldName)) {
+                return m_configurableProperties[i].getValue();
+            }
+        }
+        return value;
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#stateChanged(int)
+     */
+    public void stateChanged(int state) {
+        if (state == ComponentManagerImpl.VALID) {
+            if (m_sr == null) { start(); }
+            return;
+        }
+        if (state == ComponentManagerImpl.INVALID) {
+            if (m_sr != null) { stop(); }
+            return;
+        }
+    }
 
-	/**
-	 * Reference on the component manager.
-	 */
-	private ComponentManager m_manager;
-
-	/**
-	 * List of the configurable fields.
-	 */
-	private ConfigurableProperty[] m_configurableProperties = new ConfigurableProperty[0];
-
-	/**
-	 * ProvidedServiceHandler of the component.
-	 * It is useful to priopagate properties to service registrations.
-	 */
-	private ProvidedServiceHandler m_providedServiceHandler;
-
-	/**
-	 * Properties porpagated at the last "updated".
-	 */
-	private Dictionary m_propagated = new Properties();
-
-	/**
-	 * PID of the component.
-	 */
-	private String m_pid;
-
-	/**
-	 * Service registration of the ManagedService provided by this handler.
-	 */
-	private ServiceRegistration m_sr;
-
-	/**
-	 * @return component manager of this handler.
-	 */
-	protected ComponentManager getComponentManager() { return m_manager; }
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManager, org.apache.felix.ipojo.metadata.Element)
-	 */
-	public void configure(ComponentManager cm, Element metadata) {
-		// Store the component manager
-		m_manager = cm;
-		m_configurableProperties = new ConfigurableProperty[0];
-
-		// Build the hashmap
-		Element[] configurables = metadata.getElements("ConfigurableProperty");
-
-		if (configurables.length > 0) { m_manager.register(this); }
-		else { return; }
-
-		for (int i = 0; i < configurables.length; i++) {
-			String fieldName = configurables[i].getAttribute("field");
-			String name = null;
-			if (configurables[i].containsAttribute("name")) { name = configurables[i].getAttribute("name"); }
-			else { name = fieldName; }
-			String value = null;
-			if (configurables[i].containsAttribute("value")) {
-				value = configurables[i].getAttribute("value");
-			}
-			ConfigurableProperty cp = new ConfigurableProperty(name, fieldName, value, this);
-			addProperty(cp);
-		}
-
-		// Get the PID :
-		if (metadata.containsAttribute("name")) { m_pid = metadata.getAttribute("name"); }
-		else { m_pid = metadata.getAttribute("className"); }
-		m_providedServiceHandler = (ProvidedServiceHandler) m_manager.getHandler(ProvidedServiceHandler.class.getName());
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#stop()
-	 */
-	public void stop() {
-		// Unregister the service
-		if (m_sr != null) {
-			Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] Unregister Managed Service");
-			m_sr.unregister();
-			m_sr = null;
-		}
-
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#start()
-	 */
-	public void start() {
-		// Unregister the service if already registred (it should not happen )
-		if (m_sr != null) { m_sr.unregister(); }
-
-		// Register the ManagedService
-		BundleContext bc = m_manager.getContext();
-		Dictionary properties = new Properties();
-		properties.put(Constants.SERVICE_PID, m_pid);
-
-		Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] Register Managed Service");
-		m_sr = bc.registerService(ManagedService.class.getName(), this, properties);
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#setterCallback(java.lang.String, java.lang.Object)
-	 */
-	public void setterCallback(String fieldName, Object value) {
-		//	Verify that the field name correspond to a configurable property
-		for (int i = 0; i < m_configurableProperties.length; i++) {
-			ConfigurableProperty cp = m_configurableProperties[i];
-			if (cp.getName().equals(fieldName)) {
-				// Check if the value has change
-				if (cp.getValue() == null || !cp.getValue().equals(value)) {
-					cp.setValue(value); // Change the value
-			}
-		}
-		}
-		//Else do nothing
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
-	 */
-	public Object getterCallback(String fieldName, Object value) {
-		// Check if the field is a configurable property
-		for (int i = 0; i < m_configurableProperties.length; i++) {
-			if (m_configurableProperties[i].getField().equals(fieldName)) {
-				return m_configurableProperties[i].getValue();
-			}
-		}
-		return value;
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#isValid()
-	 */
-	public boolean isValid() {
-		return true;
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#stateChanged(int)
-	 */
-	public void stateChanged(int state) {
-		if (state == ComponentManager.VALID) {
-			if (m_sr == null) { start(); }
-			return;
-		}
-		if (state == ComponentManager.INVALID) {
-			if (m_sr != null) { stop(); }
-			return;
-		}
-	}
-
-	/**
-	 * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
-	 */
-	public void updated(Dictionary np) throws ConfigurationException {
-		Properties toPropagate = new Properties();
-		if (np != null) {
-			Enumeration keysEnumeration = np.keys();
-			while (keysEnumeration.hasMoreElements()) {
-				String name = (String)keysEnumeration.nextElement();
-				Object value = np.get(name);
-				boolean find = false;
-				// Check if the field is a configurable property
-				for (int i = 0; !find && i < m_configurableProperties.length; i++) {
-					if (m_configurableProperties[i].getName().equals(name)) {
-						// Check if the value has change
-						if (m_configurableProperties[i].getValue() == null || !m_configurableProperties[i].getValue().equals(value)) {
-							//m_configurableProperties[i].setValue(value); // Useless, the setterCallback will call the setValue
-							m_manager.setterCallback(m_configurableProperties[i].getField(), value); // says that the value has change
-						}
-						find = true;
-						// Else do nothing
-					}
-				}
-				if (!find) {
-					//The property is not a configurable property
-					Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] The property " + name + " will be propagated to service registrations");
-					toPropagate.put(name, value);
-					}
-				}
-			}
-		else { Activator.getLogger().log(Level.WARNING, "[" + m_manager.getComponentMetatada().getClassName() + "] The pushed configuration is null for " + m_pid); }
-
-		// Propagation of the properties to service registrations :
-		if (m_providedServiceHandler != null && !toPropagate.isEmpty()) {
-			Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] Properties will be propagated");
-			m_providedServiceHandler.removeProperties(m_propagated);
-			m_providedServiceHandler.addProperties(toPropagate);
-			m_propagated = toPropagate;
-		}
+    /**
+     * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
+     */
+    public void updated(Dictionary np) throws ConfigurationException {
+        Properties toPropagate = new Properties();
+        if (np != null) {
+            Enumeration keysEnumeration = np.keys();
+            while (keysEnumeration.hasMoreElements()) {
+                String name = (String) keysEnumeration.nextElement();
+                Object value = np.get(name);
+                boolean find = false;
+                // Check if the field is a configurable property
+                for (int i = 0; !find && i < m_configurableProperties.length; i++) {
+                    if (m_configurableProperties[i].getName().equals(name)) {
+                        // Check if the value has change
+                        if (m_configurableProperties[i].getValue() == null || !m_configurableProperties[i].getValue().equals(value)) {
+                            //m_configurableProperties[i].setValue(value); // Useless, the setterCallback will call the setValue
+                            m_manager.setterCallback(m_configurableProperties[i].getField(), value); // says that the value has change
+                        }
+                        find = true;
+                        // Else do nothing
+                    }
+                }
+                if (!find) {
+                    //The property is not a configurable property
+                    Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] The property " + name + " will be propagated to service registrations");
+                    toPropagate.put(name, value);
+                }
+            }
+        }
+        else { Activator.getLogger().log(Level.WARNING, "[" + m_manager.getComponentMetatada().getClassName() + "] The pushed configuration is null for " + m_pid); }
+
+        // Propagation of the properties to service registrations :
+        if (m_providedServiceHandler != null && !toPropagate.isEmpty()) {
+            Activator.getLogger().log(Level.INFO, "[" + m_manager.getComponentMetatada().getClassName() + "] Properties will be propagated");
+            m_providedServiceHandler.removeProperties(m_propagated);
+            m_providedServiceHandler.addProperties(toPropagate);
+            m_propagated = toPropagate;
+        }
 
-	}
+    }
 
-	/**
+    /**
      * Add the given property metadata to the property metadata list.
-	 * @param p : property metdata to add
-	 */
-	protected void addProperty(ConfigurableProperty p) {
+     * @param p : property metdata to add
+     */
+    protected void addProperty(ConfigurableProperty p) {
         for (int i = 0; (m_configurableProperties != null) && (i < m_configurableProperties.length); i++) {
             if (m_configurableProperties[i] == p) { return; }
         }
 
         if (m_configurableProperties.length > 0) {
-        	ConfigurableProperty[] newProp = new ConfigurableProperty[m_configurableProperties.length + 1];
+            ConfigurableProperty[] newProp = new ConfigurableProperty[m_configurableProperties.length + 1];
             System.arraycopy(m_configurableProperties, 0, newProp, 0, m_configurableProperties.length);
             newProp[m_configurableProperties.length] = p;
             m_configurableProperties = newProp;
         }
         else {
-        	m_configurableProperties = new ConfigurableProperty[] {p};
+            m_configurableProperties = new ConfigurableProperty[] {p};
         }
-	}
+    }
 
-	/**
-	 * Check if the liste contains the property.
-	 * @param name : name of the property
-	 * @return true if the property exist in the list
-	 */
-	protected boolean containsProperty(String name) {
-		for (int i = 0; (m_configurableProperties != null) && (i < m_configurableProperties.length); i++) {
+    /**
+     * Check if the liste contains the property.
+     * @param name : name of the property
+     * @return true if the property exist in the list
+     */
+    protected boolean containsProperty(String name) {
+        for (int i = 0; (m_configurableProperties != null) && (i < m_configurableProperties.length); i++) {
             if (m_configurableProperties[i].getName() == name) { return true; }
         }
-		return false;
-	}
+        return false;
+    }
 
 }