felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r469182 [5/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...
Date Mon, 30 Oct 2006 16:36:06 GMT
Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.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.lifecycle.callback;
 
@@ -60,7 +62,7 @@
      * @throws IllegalAccessException : The method can not be invoked
      */
     protected void call() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-    	m_callback.call();
+        m_callback.call();
     }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java Mon Oct 30 08:36:04 2006
@@ -1,51 +1,54 @@
-/*
- *   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.lifecycle.callback;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.Dictionary;
 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.ComponentManagerImpl;
+import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.metadata.Element;
 
 /**
  * Lifecycle callback handler.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class LifecycleCallbackHandler implements Handler {
+public class LifecycleCallbackHandler extends Handler {
 
-	/**
-	 * The list of the callback of the component.
-	 */
-	private LifecycleCallback[] m_callbacks = new LifecycleCallback[0];
-
-	/**
-	 * State of the component manager (unresolved at the beginning).
-	 */
-	private int m_state = ComponentManager.INVALID;
-
-	/**
-	 * The component manager.
-	 */
-	private ComponentManager m_componentManager;
+    /**
+     * The list of the callback of the component.
+     */
+    private LifecycleCallback[] m_callbacks = new LifecycleCallback[0];
+
+    /**
+     * State of the component manager (unresolved at the beginning).
+     */
+    private int m_state = ComponentManagerImpl.INVALID;
 
-	 /**
+    /**
+     * The component manager.
+     */
+    private ComponentManagerImpl m_componentManager;
+
+    /**
      * Add the given Hook to the hook list.
      * @param hk : the element to add
      */
@@ -61,100 +64,74 @@
             m_callbacks = newHk;
         }
         else {
-        	m_callbacks = new LifecycleCallback[] {hk};
+            m_callbacks = new LifecycleCallback[] {hk};
         }
 
     }
 
-	/**
-	 * @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) {
-		m_componentManager = cm;
-		m_callbacks = new LifecycleCallback[0];
-
-		Element[] hooksMetadata = metadata.getElements("callback");
-		for (int i = 0; i < hooksMetadata.length; i++) {
-			// Create an HookMetadata object
-			String initialState = hooksMetadata[i].getAttribute("initial");
-			String finalState = hooksMetadata[i].getAttribute("final");
-			String method = hooksMetadata[i].getAttribute("method");
-			boolean isStatic = false;
-			if (hooksMetadata[i].containsAttribute("isStatic") && hooksMetadata[i].getAttribute("isStatic").equals("true")) { isStatic = true; }
-
-			LifecycleCallbackMetadata hm = new LifecycleCallbackMetadata(initialState, finalState, method, isStatic);
-
-			LifecycleCallback hk = new LifecycleCallback(this, hm);
-			addCallback(hk);
-		}
-		if (m_callbacks.length > 0) { m_componentManager.register(this); }
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#stop()
-	 */
-	public void stop() {
-		m_state = ComponentManager.INVALID;
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#start()
-	 */
-	public void start() {
-		Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Start the life cycle callback handler");
-	}
-
-	/**
-	 * Do nothing.
-	 * @see org.apache.felix.ipojo.Handler#setterCallback(java.lang.String, java.lang.Object)
-	 */
-	public void setterCallback(String fieldName, Object value) {
-		// Do nothing
-	}
-
-	/**
-	 * Do nothing, return the initial value.
-	 * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
-	 */
-	public Object getterCallback(String fieldName, Object value) {
-		return value;
-	}
-
-	/**
-	 * Return true.
-	 * @see org.apache.felix.ipojo.Handler#isValid()
-	 */
-	public boolean isValid() {
-		return true;
-	}
-
-	/**
-	 * @return the component manager
-	 */
-	protected ComponentManager getComponentManager() { return m_componentManager; }
-
-	/**
-	 * When the state change call the associated hooks.
-	 * @see org.apache.felix.ipojo.Handler#stateChanged(int)
-	 */
-	public void stateChanged(int state) {
-		Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] State changed in callback handler, check " + m_callbacks.length + " callbacks. Transition : " + m_state + " -> " + state);
-		for (int i = 0; i < m_callbacks.length; i++) {
-			if (m_callbacks[i].getMetadata().getInitialState() == m_state && m_callbacks[i].getMetadata().getFinalState() == state) {
-				try {
-					Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Call the callback : " + m_callbacks[i].getMetadata().getMethod());
-					m_callbacks[i].call();
-				} catch (NoSuchMethodException e) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " is not found : " + e.getMessage());
-				} catch (IllegalAccessException e) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " is not accessible : " + e.getMessage());
-				} catch (InvocationTargetException e) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " has throws an exception : " + e.getMessage() + " -> " + e.getCause());
-				}
-			}
-		}
-		// Update to internal state
-		m_state = state;
-	}
+    /**
+     * @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) {
+        m_componentManager = cm;
+        m_callbacks = new LifecycleCallback[0];
+
+        Element[] hooksMetadata = metadata.getElements("callback");
+        for (int i = 0; i < hooksMetadata.length; i++) {
+            // Create an HookMetadata object
+            String initialState = hooksMetadata[i].getAttribute("initial");
+            String finalState = hooksMetadata[i].getAttribute("final");
+            String method = hooksMetadata[i].getAttribute("method");
+            boolean isStatic = false;
+            if (hooksMetadata[i].containsAttribute("isStatic") && hooksMetadata[i].getAttribute("isStatic").equals("true")) { isStatic = true; }
+
+            LifecycleCallbackMetadata hm = new LifecycleCallbackMetadata(initialState, finalState, method, isStatic);
+
+            LifecycleCallback hk = new LifecycleCallback(this, hm);
+            addCallback(hk);
+        }
+        if (m_callbacks.length > 0) { m_componentManager.register(this); }
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#start()
+     */
+    public void start() { } //Do nothing during the start
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#stop()
+     */
+    public void stop() {
+        m_state = ComponentManagerImpl.INVALID;
+    }
+
+    /**
+     * @return the component manager
+     */
+    protected ComponentManagerImpl getComponentManager() { return m_componentManager; }
+
+    /**
+     * When the state change call the associated hooks.
+     * @see org.apache.felix.ipojo.Handler#stateChanged(int)
+     */
+    public void stateChanged(int state) {
+        Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] State changed in callback handler, check " + m_callbacks.length + " callbacks. Transition : " + m_state + " -> " + state);
+        for (int i = 0; i < m_callbacks.length; i++) {
+            if (m_callbacks[i].getMetadata().getInitialState() == m_state && m_callbacks[i].getMetadata().getFinalState() == state) {
+                try {
+                    Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Call the callback : " + m_callbacks[i].getMetadata().getMethod());
+                    m_callbacks[i].call();
+                } catch (NoSuchMethodException e) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " is not found : " + e.getMessage());
+                } catch (IllegalAccessException e) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " is not accessible : " + e.getMessage());
+                } catch (InvocationTargetException e) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " has throws an exception : " + e.getMessage() + " -> " + e.getCause());
+                }
+            }
+        }
+        // Update to internal state
+        m_state = state;
+    }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackMetadata.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackMetadata.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackMetadata.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackMetadata.java Mon Oct 30 08:36:04 2006
@@ -1,22 +1,24 @@
-/*
- *   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.lifecycle.callback;
 
-import org.apache.felix.ipojo.ComponentManager;
+import org.apache.felix.ipojo.ComponentManagerImpl;
 
 /**
  * Lifecycle callback metadata.
@@ -24,73 +26,73 @@
  */
 public class LifecycleCallbackMetadata {
 
-	/**
-	 * Initial state of the transition.
-	 */
-	private int m_initialState;
-
-	/**
-	 * Final state of the transition.
-	 */
-	private int m_finalState;
-
-	/**
-	 * Method to call.
-	 */
-	private String m_method;
-
-	/**
-	 * is the method a static method ?
-	 */
-	private boolean m_isStatic;
+    /**
+     * Initial state of the transition.
+     */
+    private int m_initialState;
+
+    /**
+     * Final state of the transition.
+     */
+    private int m_finalState;
+
+    /**
+     * Method to call.
+     */
+    private String m_method;
+
+    /**
+     * is the method a static method ?
+     */
+    private boolean m_isStatic;
 
-	// Constructor
+    // Constructor
 
-	/**
+    /**
      * Constructor.
-	 * @param initialState : initial state
-	 * @param finalState : final state
-	 * @param method : method name
-	 * @param isStatic : is the method a static method ?
-	 */
-	public LifecycleCallbackMetadata(String initialState, String finalState, String method, boolean isStatic) {
-		if (initialState.equals("VALID")) { m_initialState = ComponentManager.VALID; }
-		if (initialState.equals("INVALID")) { m_initialState = ComponentManager.INVALID; }
-		if (finalState.equals("VALID")) { m_finalState = ComponentManager.VALID; }
-		if (finalState.equals("INVALID")) { m_finalState = ComponentManager.INVALID; }
-
-		m_method = method;
-		m_isStatic = isStatic;
-	}
-
-	// Getters
-
-	/**
-	 * @return Returns the m_finalState.
-	 */
-	public int getFinalState() {
-		return m_finalState;
-	}
-
-	/**
-	 * @return Returns the m_initialState.
-	 */
-	public int getInitialState() {
-		return m_initialState;
-	}
-
-	/**
-	 * @return Returns the m_isStatic.
-	 */
-	public boolean isStatic() {
-		return m_isStatic;
-	}
-
-	/**
-	 * @return Returns the m_method.
-	 */
-	public String getMethod() {
-		return m_method;
-	}
+     * @param initialState : initial state
+     * @param finalState : final state
+     * @param method : method name
+     * @param isStatic : is the method a static method ?
+     */
+    public LifecycleCallbackMetadata(String initialState, String finalState, String method, boolean isStatic) {
+        if (initialState.equals("VALID")) { m_initialState = ComponentManagerImpl.VALID; }
+        if (initialState.equals("INVALID")) { m_initialState = ComponentManagerImpl.INVALID; }
+        if (finalState.equals("VALID")) { m_finalState = ComponentManagerImpl.VALID; }
+        if (finalState.equals("INVALID")) { m_finalState = ComponentManagerImpl.INVALID; }
+
+        m_method = method;
+        m_isStatic = isStatic;
+    }
+
+    // Getters
+
+    /**
+     * @return Returns the m_finalState.
+     */
+    public int getFinalState() {
+        return m_finalState;
+    }
+
+    /**
+     * @return Returns the m_initialState.
+     */
+    public int getInitialState() {
+        return m_initialState;
+    }
+
+    /**
+     * @return Returns the m_isStatic.
+     */
+    public boolean isStatic() {
+        return m_isStatic;
+    }
+
+    /**
+     * @return Returns the m_method.
+     */
+    public String getMethod() {
+        return m_method;
+    }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.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.providedservice;
 
@@ -56,25 +58,25 @@
      * @param pm : metadata of the property
      */
     public Property(ProvidedService ps, PropertyMetadata pm) {
-    	m_providedService = ps;
-    	m_metadata = pm;
+        m_providedService = ps;
+        m_metadata = pm;
 
-    	// Fix the type of the property if null
-    	if (pm.getType() == null) {
-    		// If the type is not found, it is a dynamic property
-    		Element manipulation = m_providedService.getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
-        	String type = null;
-        	String field = m_metadata.getField();
-        	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;
-        		}
-        	}
-    		pm.setType(type);
-    	}
+        // Fix the type of the property if null
+        if (pm.getType() == null) {
+            // If the type is not found, it is a dynamic property
+            Element manipulation = m_providedService.getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
+            String type = null;
+            String field = m_metadata.getField();
+            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;
+                }
+            }
+            pm.setType(type);
+        }
 
-    	if (pm.getValue() != null) { setValue(pm.getValue()); }
+        if (pm.getValue() != null) { setValue(pm.getValue()); }
     }
 
     /**
@@ -85,9 +87,9 @@
      * @param value : the value of the property
      */
     public Property(ProvidedService ps, String name, Object value) {
-    	m_providedService = ps;
-    	m_metadata = new PropertyMetadata(name, null, value.getClass().getName(), null);
-    	m_value = value;
+        m_providedService = ps;
+        m_metadata = new PropertyMetadata(name, null, value.getClass().getName(), null);
+        m_value = value;
     }
 
     /**
@@ -105,7 +107,7 @@
      * @return the property metadata.
      */
     public PropertyMetadata getMetadata() {
-    	return m_metadata;
+        return m_metadata;
     }
 
     /**
@@ -141,19 +143,20 @@
      * @param value : value of the property (String)
      */
     private void setValue(String value) {
-    	String type = m_metadata.getType();
+        String type = m_metadata.getType();
+
+        Activator.getLogger().log(Level.INFO, "[" + m_providedService.getComponentManager().getComponentMetatada().getClassName() + "] Set the value of the property " + m_metadata.getName() + " [" + m_metadata.getType() + "] " + " with the value : " + value);
 
-    	// Array :
-    	if (type.endsWith("[]")) {
-    		String internalType = type.substring(0, type.length() - 2);
-    		value = value.substring(1, value.length() - 1);
-    		String[] values = value.split(",");
-    		setArrayValue(internalType, values);
-    		return;
-    	}
+        // Array :
+        if (type.endsWith("[]")) {
+            String internalType = type.substring(0, type.length() - 2);
+            value = value.substring(1, value.length() - 1);
+            String[] values = value.split(",");
+            setArrayValue(internalType, values);
+            return;
+        }
 
-    	// Simple :
-    	Activator.getLogger().log(Level.INFO, "[" + m_providedService.getComponentManager().getComponentMetatada().getClassName() + "] Set the value of the property " + m_metadata.getName() + " [" + m_metadata.getType() + "] " + " with the value : " + value);
+        // Simple :
 
         if (type.equals("string") || type.equals("String")) { m_value = new String(value); return; }
         if (type.equals("boolean")) { m_value = new Boolean(value); return; }
@@ -192,82 +195,87 @@
         }
     }
 
+    /**
+     * Set a array value to the current property.
+     * @param internalType : internal array type
+     * @param values : the new value
+     */
     private void setArrayValue(String internalType, String[] values) {
-    	 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("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].trim()).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;
+            byte[] byt = new byte[values.length];
+            for (int i = 0; i < values.length; i++) { byt[i] = new Byte(values[i].trim()).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].trim()).shortValue(); }
+            m_value = shor;
+            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;
+        if (internalType.equals("int")) {
+            int[] in = new int[values.length];
+            for (int i = 0; i < values.length; i++) { in[i] = new Integer(values[i].trim()).intValue(); }
+            m_value = in;
+            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;
+        if (internalType.equals("long")) {
+            long[] ll = new long[values.length];
+            for (int i = 0; i < values.length; i++) { ll[i] = new Long(values[i].trim()).longValue(); }
+            m_value = ll;
+            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;
+        if (internalType.equals("float")) {
+            float[] fl = new float[values.length];
+            for (int i = 0; i < values.length; i++) { fl[i] = new Float(values[i].trim()).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].trim()).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 {
+            Class c = m_providedService.getComponentManager().getContext().getBundle().loadClass(internalType);
+            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].trim()});
+            }
+            m_value = ob;
+            return;
+        } catch (ClassNotFoundException e) {
+            System.err.println("Class not found exception in setValue on " + internalType);
+            e.printStackTrace();
+        } catch (SecurityException e) {
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            System.err.println("Constructor not found exeption in setValue on " + internalType);
+            e.printStackTrace();
+        } catch (IllegalArgumentException e) {
+            System.err.println("Argument problem to call the constructor of the type " + internalType);
+            e.printStackTrace();
+        } catch (InstantiationException e) {
+            System.err.println("Instantiation problem  " + internalType);
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            System.err.println("Invocation problem " + internalType);
+            e.printStackTrace();
         }
-         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; }
-         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; }
-
-         // 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_providedService.getComponentManager().getContext().getBundle().loadClass(internalType);
-             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]});
-             }
-             m_value = ob;
-             return;
-         } catch (ClassNotFoundException e) {
-             System.err.println("Class not found exception in setValue on " + internalType);
-             e.printStackTrace();
-         } catch (SecurityException e) {
-             e.printStackTrace();
-         } catch (NoSuchMethodException e) {
-             System.err.println("Constructor not found exeption in setValue on " + internalType);
-             e.printStackTrace();
-         } catch (IllegalArgumentException e) {
-             System.err.println("Argument problem to call the constructor of the type " + internalType);
-             e.printStackTrace();
-         } catch (InstantiationException e) {
-             System.err.println("Instantiation problem  " + internalType);
-             e.printStackTrace();
-         } catch (IllegalAccessException e) {
-             e.printStackTrace();
-         } catch (InvocationTargetException e) {
-             System.err.println("Invocation problem " + internalType);
-             e.printStackTrace();
-         }
-	}
+    }
 
-	/**
+    /**
      * @return the value of the property.
      */
     public Object getValue() { return m_value; }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/PropertyMetadata.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/PropertyMetadata.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/PropertyMetadata.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/PropertyMetadata.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.providedservice;
 
@@ -22,72 +24,72 @@
  */
 public class PropertyMetadata {
 
-	/**
-	 * Field of the property.
-	 */
-	private String m_field;
-
-	/**
-	 * Name of the property.
-	 */
-	private String m_name;
-
-	/**
-	 * Type of the property.
-	 */
-	private String m_type;
-
-	/**
-	 * String value of the property (initial value).
-	 */
-	private String m_value;
+    /**
+     * Field of the property.
+     */
+    private String m_field;
+
+    /**
+     * Name of the property.
+     */
+    private String m_name;
+
+    /**
+     * Type of the property.
+     */
+    private String m_type;
+
+    /**
+     * String value of the property (initial value).
+     */
+    private String m_value;
 
-	//Constructor
+    //Constructor
 
-	/**
+    /**
      * Constructor.
-	 * @param name : name of the property
-	 * @param field : field of the property
-	 * @param type : type of the property
-	 * @param value : initial value of the property
-	 */
-	public PropertyMetadata(String name, String field, String type, String value) {
-		m_name = name;
-		m_field = field;
-		m_type = type;
-		m_value = value;
-
-		// Dynamic property case :
-		if (m_field != null) {
-			if (m_name == null) { m_name = m_field; }
-		}
-	}
-
-	/**
-	 * @return the field name.
-	 */
-	public String getField() { return m_field; };
-
-	/**
-	 * @return the property name.
-	 */
-	public String getName() { return m_name; };
-
-	/**
-	 * @return the type of the property.
-	 */
-	public String getType() { return m_type; };
-
-	/**
-	 * @return the initial value.
-	 */
-	public String getValue() { return m_value; }
+     * @param name : name of the property
+     * @param field : field of the property
+     * @param type : type of the property
+     * @param value : initial value of the property
+     */
+    public PropertyMetadata(String name, String field, String type, String value) {
+        m_name = name;
+        m_field = field;
+        m_type = type;
+        m_value = value;
+
+        // Dynamic property case :
+        if (m_field != null) {
+            if (m_name == null) { m_name = m_field; }
+        }
+    }
+
+    /**
+     * @return the field name.
+     */
+    public String getField() { return m_field; };
+
+    /**
+     * @return the property name.
+     */
+    public String getName() { return m_name; };
+
+    /**
+     * @return the type of the property.
+     */
+    public String getType() { return m_type; };
+
+    /**
+     * @return the initial value.
+     */
+    public String getValue() { return m_value; }
 
-	/**
+    /**
      * Set the type of the property (dynamic property only).
-	 * @param type : the type of the property.
-	 */
-	public void setType(String type) { m_type = type; }
+     * @param type : the type of the property.
+     */
+    public void setType(String type) { m_type = type; }
 
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.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.providedservice;
 
@@ -21,7 +23,7 @@
 import java.util.Properties;
 import java.util.logging.Level;
 
-import org.apache.felix.ipojo.ComponentManager;
+import org.apache.felix.ipojo.ComponentManagerImpl;
 import org.apache.felix.ipojo.Activator;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceFactory;
@@ -56,12 +58,6 @@
     public static final int SERVICE_FACTORY = 1;
 
     /**
-     * Factory policy : COMPONENT_FACTORY.
-     * TODO : Component_factory behavior
-     */
-    public static final int COMPONENT_FACTORY = 2;
-
-    /**
      * The service registration.
      * is null when the service is not registred.
      * m_serviceRegistration : ServiceRegistration
@@ -99,8 +95,8 @@
         m_handler = handler;
         m_metadata = psm;
         for (int i = 0; i < psm.getProperties().length; i++) {
-        	Property prop = new Property(this, ((PropertyMetadata)psm.getProperties()[i]));
-        	addProperty(prop);
+            Property prop = new Property(this, ((PropertyMetadata) psm.getProperties()[i]));
+            addProperty(prop);
         }
     }
 
@@ -122,30 +118,34 @@
         else { m_properties = new Property[] {p}; }
     }
 
+    /**
+     * Remove a property.
+     * @param name : the property to remove
+     */
     private synchronized void removeProperty(String name) {
-    	 int idx = -1;
-         for (int i = 0; i < m_properties.length; i++) {
-             if (m_properties[i].getMetadata().getName() == name) { idx = i; break; }
-         }
-
-         if (idx >= 0) {
-             if ((m_properties.length - 1) == 0) { m_properties = new Property[0]; }
-             else {
-            	 Property[] newPropertiesList = new Property[m_properties.length - 1];
-                 System.arraycopy(m_properties, 0, newPropertiesList, 0, idx);
-                 if (idx < newPropertiesList.length) {
-                     System.arraycopy(m_properties, idx + 1, newPropertiesList, idx, newPropertiesList.length - idx); }
-                 m_properties = newPropertiesList;
-             }
-         }
+        int idx = -1;
+        for (int i = 0; i < m_properties.length; i++) {
+            if (m_properties[i].getMetadata().getName() == name) { idx = i; break; }
+        }
+
+        if (idx >= 0) {
+            if ((m_properties.length - 1) == 0) { m_properties = new Property[0]; }
+            else {
+                Property[] newPropertiesList = new Property[m_properties.length - 1];
+                System.arraycopy(m_properties, 0, newPropertiesList, 0, idx);
+                if (idx < newPropertiesList.length) {
+                    System.arraycopy(m_properties, idx + 1, newPropertiesList, idx, newPropertiesList.length - idx); }
+                m_properties = newPropertiesList;
+            }
+        }
     }
 
     /**
      * @return the service reference of the provided service (null if the service is not published).
      */
     public ServiceReference getServiceReference() {
-    	if (m_serviceRegistration != null) { return m_serviceRegistration.getReference(); }
-    	else { return null; }
+        if (m_serviceRegistration != null) { return m_serviceRegistration.getReference(); }
+        else { return null; }
     }
 
     /**
@@ -157,22 +157,18 @@
      */
     public Object getService(Bundle bundle, ServiceRegistration registration) {
 
-    	switch(m_metadata.getFactoryPolicy()) {
+        switch(m_metadata.getFactoryPolicy()) {
 
-    	case SINGLETON_FACTORY :
-            return m_handler.getComponentManager().getInstance();
+            case SINGLETON_FACTORY :
+                return m_handler.getComponentManager().getInstance();
 
-    	case SERVICE_FACTORY :
-    		return m_handler.getComponentManager().createInstance();
+            case SERVICE_FACTORY :
+                return m_handler.getComponentManager().createInstance();
 
-    	case COMPONENT_FACTORY :
-    		//TODO Component Factory Behavior
-    		return null;
-
-    	default :
-    		Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Unknown factory policy for " + m_metadata.getServiceSpecification() + " : " + m_metadata.getFactoryPolicy());
-    		return null;
-    	}
+            default :
+                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Unknown factory policy for " + m_metadata.getServiceSpecification() + " : " + m_metadata.getFactoryPolicy());
+            return null;
+        }
 
     }
 
@@ -187,23 +183,23 @@
         //Nothing to do
     }
 
-//    /**
-//     * Validate the service dependencies of the current provided service.
-//     * @return true if the service dependencies are valid
-//     */
-//    public boolean validate() {
-//        boolean valide = true;
-//        for (int i = 0; i < m_dependencies.length; i++) {
-//            Dependency dep = m_dependencies[i];
-//            valide = valide & dep.isSatisfied();
-//            if (!valide) {
-//                ComponentManager.getLogger().log(Level.INFO, "Service Dependency  for " + m_interface + " not valid : " + dep.getInterface());
-//                return false;
-//            }
-//        }
-//        ComponentManager.getLogger().log(Level.INFO, "Service dependencies for " + m_interface + " are valid");
-//        return valide;
-//    }
+//  /**
+//  * Validate the service dependencies of the current provided service.
+//  * @return true if the service dependencies are valid
+//  */
+//  public boolean validate() {
+//  boolean valide = true;
+//  for (int i = 0; i < m_dependencies.length; i++) {
+//  Dependency dep = m_dependencies[i];
+//  valide = valide & dep.isSatisfied();
+//  if (!valide) {
+//  ComponentManager.getLogger().log(Level.INFO, "Service Dependency  for " + m_interface + " not valid : " + dep.getInterface());
+//  return false;
+//  }
+//  }
+//  ComponentManager.getLogger().log(Level.INFO, "Service dependencies for " + m_interface + " are valid");
+//  return valide;
+//  }
 
     /**
      * Register the service.
@@ -211,35 +207,35 @@
      * To avoid cycle in Check Context, the registred service is set to registred before the real registration.
      */
     protected void registerService() {
-    	if (m_state != REGISTERED) {
+        if (m_state != REGISTERED) {
             String spec = "";
             for (int i = 0; i < m_metadata.getServiceSpecification().length; i++) {
                 spec = spec + m_metadata.getServiceSpecification()[i] + ", ";
             }
-    			Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Register the service : " + spec);
-    			// Contruct the service properties list
-    			Properties serviceProperties = getServiceProperties();
-
-    			m_state = REGISTERED;
-                synchronized (this) {
-                    m_serviceRegistration =
-                        m_handler.getComponentManager().getContext().registerService(
+            Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Register the service : " + spec);
+            // Contruct the service properties list
+            Properties serviceProperties = getServiceProperties();
+
+            m_state = REGISTERED;
+            synchronized (this) {
+                m_serviceRegistration =
+                    m_handler.getComponentManager().getContext().registerService(
                             m_metadata.getServiceSpecification(), this, serviceProperties);
-                }
-    	}
+            }
+        }
     }
 
     /**
      * Unregister the service.
      */
     protected void unregisterService() {
-    	if (m_state == REGISTERED) {
-    		try {
-    			m_serviceRegistration.unregister();
-    			m_serviceRegistration = null;
-    		} catch (Exception e) { return; }
-			m_state = UNREGISTERED;
-    	}
+        if (m_state == REGISTERED) {
+            try {
+                m_serviceRegistration.unregister();
+                m_serviceRegistration = null;
+            } catch (Exception e) { return; }
+            m_state = UNREGISTERED;
+        }
     }
 
     /**
@@ -252,8 +248,8 @@
     /**
      * @return the component manager.
      */
-    protected ComponentManager getComponentManager() {
-    	return m_handler.getComponentManager();
+    protected ComponentManagerImpl getComponentManager() {
+        return m_handler.getComponentManager();
     }
 
     /**
@@ -280,11 +276,10 @@
     }
 
     /**
-     * Update refresh the service properties.
+     * Update the service properties.
      * The new list of properties is sended to the service registry.
      */
     public void update() {
-        // Update the service properties
 
         // Contruct the service properties list
         Properties serviceProperties = getServiceProperties();
@@ -297,39 +292,39 @@
         }
     }
 
-	/**
-	 * @return the propvided service metadata.
-	 */
-	public ProvidedServiceMetadata getMetadata() {
-		return m_metadata;
-	}
-
-	/**
-	 * Add properties to the list.
-	 * @param props : properties to add
-	 */
-	protected void addProperties(Dictionary props) {
-		Enumeration keys = props.keys();
-		while (keys.hasMoreElements()) {
-			String key = (String) keys.nextElement();
-			Object value = props.get(key);
-			Property prop = new Property(this, key, value);
-			addProperty(prop);
-		}
-		update();
-	}
-
-	/**
-	 * Remove properties from the list.
-	 * @param props : properties to remove
-	 */
-	protected void deleteProperties(Dictionary props) {
-		Enumeration keys = props.keys();
-		while (keys.hasMoreElements()) {
-			String key = (String) keys.nextElement();
-			removeProperty(key);
-		}
-		update();
-	}
+    /**
+     * @return the propvided service metadata.
+     */
+    public ProvidedServiceMetadata getMetadata() {
+        return m_metadata;
+    }
+
+    /**
+     * Add properties to the list.
+     * @param props : properties to add
+     */
+    protected void addProperties(Dictionary props) {
+        Enumeration keys = props.keys();
+        while (keys.hasMoreElements()) {
+            String key = (String) keys.nextElement();
+            Object value = props.get(key);
+            Property prop = new Property(this, key, value);
+            addProperty(prop);
+        }
+        update();
+    }
+
+    /**
+     * Remove properties from the list.
+     * @param props : properties to remove
+     */
+    protected void deleteProperties(Dictionary props) {
+        Enumeration keys = props.keys();
+        while (keys.hasMoreElements()) {
+            String key = (String) keys.nextElement();
+            removeProperty(key);
+        }
+        update();
+    }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java Mon Oct 30 08:36:04 2006
@@ -1,81 +1,92 @@
-/*
- *   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.providedservice;
 
 import java.util.Dictionary;
 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.ComponentInfo;
+import org.apache.felix.ipojo.ComponentManagerImpl;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.PropertyInfo;
 import org.apache.felix.ipojo.metadata.Element;
 
 /**
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class ProvidedServiceHandler implements Handler {
+public class ProvidedServiceHandler extends Handler {
 
 
-	/**
-	 * The list of the provided service.
-	 */
-	private ProvidedService[] m_providedServices = new ProvidedService[0];
-
-	/**
-	 * The component manager.
-	 */
-	private ComponentManager m_componentManager;
-
-	private void addProvidedService(ProvidedService ps) {
-	        //  Verify that the provided service is not already in the array.
-	        for (int i = 0; (m_providedServices != null) && (i < m_providedServices.length); i++) {
-	            if (m_providedServices[i] == ps) { return; }
-	        }
-
-	        if (m_providedServices.length > 0) {
-	            ProvidedService[] newPS = new ProvidedService[m_providedServices.length + 1];
-	            System.arraycopy(m_providedServices, 0, newPS, 0, m_providedServices.length);
-	            newPS[m_providedServices.length] = ps;
-	            m_providedServices = newPS;
-	        }
-	        else { m_providedServices = new ProvidedService[] {ps}; }
-	}
-
-	/**
-	 * @return the component manager.
-	 */
-	public ComponentManager getComponentManager() { return m_componentManager; }
-
-	/**
-	 * @return the list of the provided service.
-	 */
-	public ProvidedService[] getProvidedService() { return m_providedServices; }
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManager, org.apache.felix.ipojo.metadata.Element)
-	 */
-	public void configure(ComponentManager cm, Element componentMetadata) {
-		// Fix the component managert & clean the provided service list
-		m_componentManager = cm;
-		m_providedServices = new ProvidedService[0];
-		// Create the dependency according to the component metadata
-		Element[] providedServices = componentMetadata.getElements("Provides");
-		for (int i = 0; i < providedServices.length; i++) {
-			// Create a ProvidedServiceMetadata object
+    /**
+     * The list of the provided service.
+     */
+    private ProvidedService[] m_providedServices = new ProvidedService[0];
+
+    /**
+     * The component manager.
+     */
+    private ComponentManagerImpl m_componentManager;
+
+    /**
+     * Add a provided service to the list .
+     * @param ps : the provided service to add
+     */
+    private void addProvidedService(ProvidedService ps) {
+        //  Verify that the provided service is not already in the array.
+        for (int i = 0; (m_providedServices != null) && (i < m_providedServices.length); i++) {
+            if (m_providedServices[i] == ps) { return; }
+        }
+
+        if (m_providedServices.length > 0) {
+            ProvidedService[] newPS = new ProvidedService[m_providedServices.length + 1];
+            System.arraycopy(m_providedServices, 0, newPS, 0, m_providedServices.length);
+            newPS[m_providedServices.length] = ps;
+            m_providedServices = newPS;
+        }
+        else { m_providedServices = new ProvidedService[] {ps}; }
+    }
+
+    /**
+     * @return the component manager.
+     */
+    public ComponentManagerImpl getComponentManager() { return m_componentManager; }
+
+    /**
+     * @return the list of the provided service.
+     */
+    public ProvidedService[] getProvidedService() { return m_providedServices; }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManagerImpl, org.apache.felix.ipojo.metadata.Element)
+     */
+    public void configure(ComponentManagerImpl cm, Element componentMetadata, Dictionary configuration) {
+        // Fix the component manager & clean the provided service list
+        m_componentManager = cm;
+
+        ComponentInfo ci = cm.getComponentInfo();
+
+        m_providedServices = new ProvidedService[0];
+        // Create the dependency according to the component metadata
+        Element[] providedServices = componentMetadata.getElements("Provides");
+        for (int i = 0; i < providedServices.length; i++) {
+            // Create a ProvidedServiceMetadata object
 
             // First : create the serviceSpecification array
             String[] serviceSpecification = new String[0];
@@ -86,84 +97,101 @@
                 serviceSpecification = new String[spec.length];
                 for (int j = 0; j < spec.length; j++) { serviceSpecification[j] = spec[j].trim(); }
             } else {
-            	Element manipulation = m_componentManager.getComponentMetatada().getMetadata().getElements("Manipulation")[0];
-            	serviceSpecification = new String[manipulation.getElements("Interface").length];
-            	for (int j = 0; j < manipulation.getElements("Interface").length; j++) {
-            		serviceSpecification[j] = manipulation.getElements("Interface")[j].getAttribute("name");
-            	}
+                Element manipulation = m_componentManager.getComponentMetatada().getMetadata().getElements("Manipulation")[0];
+                serviceSpecification = new String[manipulation.getElements("Interface").length];
+                for (int j = 0; j < manipulation.getElements("Interface").length; j++) {
+                    serviceSpecification[j] = manipulation.getElements("Interface")[j].getAttribute("name");
+                }
             }
 
             // Get the factory policy
-			int factory = ProvidedServiceMetadata.SINGLETON_FACTORY;
-			if (providedServices[i].containsAttribute("factory") && providedServices[i].getAttribute("factory").equals("service")) { factory = ProvidedService.SERVICE_FACTORY; }
+            int factory = ProvidedServiceMetadata.SINGLETON_FACTORY;
+            if (providedServices[i].containsAttribute("factory") && providedServices[i].getAttribute("factory").equals("service")) { factory = ProvidedService.SERVICE_FACTORY; }
+
+            // Then create the provided service metadata
+            ProvidedServiceMetadata psm = new ProvidedServiceMetadata(serviceSpecification, factory);
 
-			// Then create the provided service metadata
-			ProvidedServiceMetadata psm = new ProvidedServiceMetadata(serviceSpecification, factory);
+            Element[] props = providedServices[i].getElements("Property");
+            for (int j = 0; j < props.length; j++) {
+                String name = null;
+                if (props[j].containsAttribute("name")) { name = props[j].getAttribute("name"); }
+                String value = null;
+                if (props[j].containsAttribute("value")) { value = props[j].getAttribute("value"); }
+                String type = null;
+                if (props[j].containsAttribute("type")) { type = props[j].getAttribute("type"); }
+                String field = null;
+                if (props[j].containsAttribute("field")) { field = props[j].getAttribute("field"); }
+
+                if (name != null && configuration.get(name) != null && configuration.get(name) instanceof String) { value = (String) configuration.get(name); }
+                else { if (field != null &&  configuration.get(field) != null && configuration.get(field) instanceof String) { value = (String) configuration.get(field); } }
+
+                PropertyMetadata pm = new PropertyMetadata(name, field, type, value);
+                psm.addProperty(pm);
+            }
 
-			// Create properties
-			Element[] dynamicProps = providedServices[i].getElements("DynamicProperty");
-			Element[] staticProps = providedServices[i].getElements("StaticProperty");
-			Element[] props = providedServices[i].getElements("Property");
-			for (int j = 0; j < dynamicProps.length; j++) {
-				Activator.getLogger().log(Level.WARNING, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Please use property instead of dynamic property");
-				String name = null;
-				if (dynamicProps[j].containsAttribute("name")) { name = dynamicProps[j].getAttribute("name"); }
-				String field = dynamicProps[j].getAttribute("field");
-				String value = null;
-				if (dynamicProps[j].containsAttribute("value")) { value = dynamicProps[j].getAttribute("value"); }
-				String type = null;
-				if (dynamicProps[j].containsAttribute("type")) { type = dynamicProps[j].getAttribute("type"); }
-				PropertyMetadata pm = new PropertyMetadata(name, field, type, value);
-				psm.addProperty(pm);
-			}
-			for (int j = 0; j < staticProps.length; j++) {
-				Activator.getLogger().log(Level.WARNING, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Please use property instead of static property");
-				String name = staticProps[j].getAttribute("name");
-				String value = staticProps[j].getAttribute("value");
-				String type = staticProps[j].getAttribute("type");
-				PropertyMetadata pm = new PropertyMetadata(name, null, type, value);
-				psm.addProperty(pm);
-			}
-			for (int j = 0; j < props.length; j++) {
-				String name = null;
-				if (props[j].containsAttribute("name")) { name = props[j].getAttribute("name"); }
-				String value = null;
-				if (props[j].containsAttribute("value")) { value = props[j].getAttribute("value"); }
-				String type = null;
-				if (props[j].containsAttribute("type")) { type = props[j].getAttribute("type"); }
-				String field = null;
-				if (props[j].containsAttribute("field")) { field = props[j].getAttribute("field"); }
-				PropertyMetadata pm = new PropertyMetadata(name, field, type, value);
-				psm.addProperty(pm);
-			}
-
-			// Create the provided service object
-			ProvidedService ps = new ProvidedService(this, psm);
-			if (checkProvidedService(ps)) { addProvidedService(ps); }
-			else {
+            // Create the provided service object
+            ProvidedService ps = new ProvidedService(this, psm);
+            if (checkProvidedService(ps)) {
+                addProvidedService(ps);
+                // Change ComponentInfo
+                for (int k = 0; k < ps.getMetadata().getServiceSpecification().length; k++) { ci.addProvidedServiceSpecification(ps.getMetadata().getServiceSpecification()[k]); }
+                for (int k = 0; k < ps.getMetadata().getProperties().length; k++) { ci.addProperty(new PropertyInfo(ps.getMetadata().getProperties()[k].getName(), ps.getMetadata().getProperties()[k].getType(), ps.getMetadata().getProperties()[k].getValue())); }
+            }
+            else {
                 String itfs = "";
                 for (int j = 0; j < serviceSpecification.length; j++) {
                     itfs = itfs + " " + serviceSpecification[j];
                 }
-				Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The provided service" + itfs + " is not valid, it will be removed");
-				ps = null;
-			}
-		}
-
-		if (providedServices.length > 0) { m_componentManager.register(this); }
-	}
-
-	private boolean containsInterface(String s) {
-		Element manipulation = m_componentManager.getComponentMetatada().getMetadata().getElements("Manipulation")[0];
-		for (int i = 0; i < manipulation.getElements("Interface").length; i++) {
-			if (manipulation.getElements("Interface")[i].getAttribute("name").equals(s)) {
-				return true;
-			}
-		}
-		return false;
-	}
+                Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The provided service" + itfs + " is not valid, it will be removed");
+                ps = null;
+            }
+
+        }
+
+        if (providedServices.length > 0) {
+            String[] fields = new String[0];
+            for (int i = 0; i < m_providedServices.length; i++) {
+                ProvidedService ps = m_providedServices[i];
+                for (int j = 0; j < ps.getProperties().length; j++) {
+                    Property prop = ps.getProperties()[j];
+
+                    // Check if the instance configuration has a value for this property
+                    if (prop.getMetadata().getName() != null && configuration.get(prop.getMetadata().getName()) != null && !(configuration.get(prop.getMetadata().getName()) instanceof String)) { prop.set(configuration.get(prop.getMetadata().getName())); }
+                    else { if (prop.getMetadata().getField() != null && configuration.get(prop.getMetadata().getField()) != null && !(configuration.get(prop.getMetadata().getField()) instanceof String)) { prop.set(configuration.get(prop.getMetadata().getField())); } }
+
+                    if (prop.getMetadata().getField() != null) {
+                        String[] newFields = new String[fields.length + 1];
+                        System.arraycopy(fields, 0, newFields, 0, fields.length);
+                        newFields[fields.length] = prop.getMetadata().getField();
+                        fields = newFields;
+                    }
+                }
+            }
 
-	private boolean checkProvidedService(ProvidedService ps) {
+            m_componentManager.register(this, fields); }
+    }
+
+    /**
+     * Is the specicifaction s in the list ?
+     * @param s : the specitication to search
+     * @return true if s is in the list
+     */
+    private boolean containsInterface(String s) {
+        Element manipulation = m_componentManager.getComponentMetatada().getMetadata().getElements("Manipulation")[0];
+        for (int i = 0; i < manipulation.getElements("Interface").length; i++) {
+            if (manipulation.getElements("Interface")[i].getAttribute("name").equals(s)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Check the provided service given in argument in the sense that the metadata are consistent.
+     * @param ps : the provided service to check
+     * @return true if the provided service is correct
+     */
+    private boolean checkProvidedService(ProvidedService ps) {
 
         for (int i = 0; i < ps.getMetadata().getServiceSpecification().length; i++) {
             if (!containsInterface(ps.getMetadata().getServiceSpecification()[i])) {
@@ -172,154 +200,145 @@
             }
         }
 
-		// Fix internal property type
-		for (int i = 0; i < ps.getProperties().length; i++) {
-			Property prop = ps.getProperties()[i];
-			String field = prop.getMetadata().getField();
-
-			if (field == null) {
-				// Static dependency -> Nothing to check
-				return true;
-			} else {
-				Element manipulation = getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
-	        	String type = null;
-	        	for (int j = 0; j < manipulation.getElements("Field").length; j++) {
-	        		if (field.equals(manipulation.getElements("Field")[j].getAttribute("name"))) {
-	        			type = manipulation.getElements("Field")[j].getAttribute("type");
-	        			break;
-	        		}
-	        	}
-				if (type == null) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] A declared property was not found in the class : " + prop.getMetadata().getField());
-					return false;
-				}
-
-				if (type != null) {
-//					if (type.endsWith("[]")) {
-//						Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] An array property was found in the class [Not implemented yet] : " + prop.getMetadata().getField());
-//						return false;
-//					}
-
-					if (prop.getMetadata().getType() == null) { prop.getMetadata().setType(type); }
-
-					if (!prop.getMetadata().getType().equals(type)) {
-						Activator.getLogger().log(Level.WARNING, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The field type [" + type + "] and the declared type [" + prop.getMetadata().getType() + "] are not the same for " + prop.getMetadata().getField());
-						prop.getMetadata().setType(type);
-					}
-				}
-				else {
-					Activator.getLogger().log(Level.WARNING, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The declared property " + prop.getMetadata().getField() + "  does not exist in the code");
-				}
-			}
-		}
-		return true;
-	}
-
-	/**
-	 * Stop the provided service handler : unregister all provided services.
-	 * @see org.apache.felix.ipojo.Handler#stop()
-	 */
-	public void stop() {
-		for (int i = 0; i < m_providedServices.length; i++) {
-			m_providedServices[i].unregisterService();
-		}
-	}
-
-	/**
-	 * Start the provided service handler : register the service if the component is resolved.
-	 * Else do nothing and whait for a component state change event
-	 * @see org.apache.felix.ipojo.Handler#start()
-	 */
-	public void start() {
-		Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Start the provided service handler");
-			for (int i = 0; (m_componentManager.getState() == ComponentManager.VALID) && i < m_providedServices.length; i++) {
-				m_providedServices[i].registerService();
-			}
-	}
-
-	/**
-	 * @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 coreespond to a dependency
-		for (int i = 0; i < m_providedServices.length; i++) {
-			ProvidedService ps = m_providedServices[i];
-			for (int j = 0; j < ps.getProperties().length; j++) {
-				Property prop = ps.getProperties()[j];
-				if (fieldName.equals(prop.getMetadata().getField())) {
-					// it is the associated property
-					prop.set(value);
-				}
-			}
-		}
-		//Else do nothing
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
-	 */
-	public Object getterCallback(String fieldName, Object value) {
-		for (int i = 0; i < m_providedServices.length; i++) {
-			ProvidedService ps = m_providedServices[i];
-			for (int j = 0; j < ps.getProperties().length; j++) {
-				Property prop = ps.getProperties()[j];
-				if (fieldName.equals(prop.getMetadata().getField())) {
-					// it is the associated property
-					return prop.get();
-				}
-			}
-		}
-		// Else it is not a property
-		return value;
-	}
-
-	/**
-	 * @see org.apache.felix.ipojo.Handler#isValid()
-	 */
-	public boolean isValid() {
-		// The provided service handler does not need to manipulate the field
-		// Return always true
-		return true;
-	}
-
-	/**
-	 * Register the services if the new state is VALID.
-	 * Unregister the services if the new state is UNRESOLVED.
-	 * @see org.apache.felix.ipojo.Handler#stateChanged(int)
-	 */
-	public void stateChanged(int state) {
-		// If the new state is UNRESOLVED => unregister all the services
-		if (state == ComponentManager.INVALID) {
-			stop();
-			return;
-		}
-
-		// If the new state is VALID => regiter all the services
-		if (state == ComponentManager.VALID) {
-			start();
-			return;
-		}
-
-	}
-
-	/**
-	 * Add properties to all provided services.
-	 * @param dict : dictionary fo properties to add
-	 */
-	public void addProperties(Dictionary dict) {
-		for (int i = 0; i < m_providedServices.length; i++) {
-			m_providedServices[i].addProperties(dict);
-		}
-	}
-
-	/**
-	 * Remove properties form all provided services.
-	 * @param dict : dictionary of properties to delete.
-	 */
-	public void removeProperties(Dictionary dict) {
-		for (int i = 0; i < m_providedServices.length; i++) {
-			m_providedServices[i].deleteProperties(dict);
-		}
-	}
+        // Fix internal property type
+        for (int i = 0; i < ps.getProperties().length; i++) {
+            Property prop = ps.getProperties()[i];
+            String field = prop.getMetadata().getField();
+
+            if (field == null) {
+                // Static dependency -> Nothing to check
+                return true;
+            } else {
+                Element manipulation = getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
+                String type = null;
+                for (int j = 0; j < manipulation.getElements("Field").length; j++) {
+                    if (field.equals(manipulation.getElements("Field")[j].getAttribute("name"))) {
+                        type = manipulation.getElements("Field")[j].getAttribute("type");
+                        break;
+                    }
+                }
+                if (type == null) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] A declared property was not found in the class : " + prop.getMetadata().getField());
+                    return false;
+                }
+
+                if (type != null) {
+//                  if (type.endsWith("[]")) {
+//                  Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] An array property was found in the class [Not implemented yet] : " + prop.getMetadata().getField());
+//                  return false;
+//                  }
+
+                    if (prop.getMetadata().getType() == null) { prop.getMetadata().setType(type); }
+
+                    if (!prop.getMetadata().getType().equals(type)) {
+                        Activator.getLogger().log(Level.WARNING, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The field type [" + type + "] and the declared type [" + prop.getMetadata().getType() + "] are not the same for " + prop.getMetadata().getField());
+                        prop.getMetadata().setType(type);
+                    }
+                }
+                else {
+                    Activator.getLogger().log(Level.WARNING, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The declared property " + prop.getMetadata().getField() + "  does not exist in the code");
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Stop the provided service handler : unregister all provided services.
+     * @see org.apache.felix.ipojo.Handler#stop()
+     */
+    public void stop() {
+        for (int i = 0; i < m_providedServices.length; i++) {
+            m_providedServices[i].unregisterService();
+        }
+    }
+
+    /**
+     * Start the provided service handler : register the service if the component is resolved.
+     * Else do nothing and whait for a component state change event
+     * @see org.apache.felix.ipojo.Handler#start()
+     */
+    public void start() {
+        Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Start the provided service handler");
+        for (int i = 0; (m_componentManager.getState() == ComponentManagerImpl.VALID) && i < m_providedServices.length; i++) {
+            m_providedServices[i].registerService();
+        }
+    }
+
+    /**
+     * @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 coreespond to a dependency
+        for (int i = 0; i < m_providedServices.length; i++) {
+            ProvidedService ps = m_providedServices[i];
+            for (int j = 0; j < ps.getProperties().length; j++) {
+                Property prop = ps.getProperties()[j];
+                if (fieldName.equals(prop.getMetadata().getField())) {
+                    // it is the associated property
+                    prop.set(value);
+                }
+            }
+        }
+        //Else do nothing
+    }
+
+    /**
+     * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
+     */
+    public Object getterCallback(String fieldName, Object value) {
+        for (int i = 0; i < m_providedServices.length; i++) {
+            ProvidedService ps = m_providedServices[i];
+            for (int j = 0; j < ps.getProperties().length; j++) {
+                Property prop = ps.getProperties()[j];
+                if (fieldName.equals(prop.getMetadata().getField())) {
+                    // it is the associated property
+                    return prop.get();
+                }
+            }
+        }
+        // Else it is not a property
+        return value;
+    }
+
+    /**
+     * Register the services if the new state is VALID.
+     * Unregister the services if the new state is UNRESOLVED.
+     * @see org.apache.felix.ipojo.Handler#stateChanged(int)
+     */
+    public void stateChanged(int state) {
+        // If the new state is UNRESOLVED => unregister all the services
+        if (state == ComponentManagerImpl.INVALID) {
+            stop();
+            return;
+        }
+
+        // If the new state is VALID => regiter all the services
+        if (state == ComponentManagerImpl.VALID) {
+            start();
+            return;
+        }
+
+    }
+
+    /**
+     * Add properties to all provided services.
+     * @param dict : dictionary fo properties to add
+     */
+    public void addProperties(Dictionary dict) {
+        for (int i = 0; i < m_providedServices.length; i++) {
+            m_providedServices[i].addProperties(dict);
+        }
+    }
+
+    /**
+     * Remove properties form all provided services.
+     * @param dict : dictionary of properties to delete.
+     */
+    public void removeProperties(Dictionary dict) {
+        for (int i = 0; i < m_providedServices.length; i++) {
+            m_providedServices[i].deleteProperties(dict);
+        }
+    }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceMetadata.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceMetadata.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceMetadata.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceMetadata.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.providedservice;
 
@@ -23,7 +25,7 @@
  */
 public class ProvidedServiceMetadata {
 
-	 /**
+    /**
      * Factory Policy : SINGLETON_FACTORY.
      */
     public static final int SINGLETON_FACTORY = 0;
@@ -34,63 +36,57 @@
     public static final int SERVICE_FACTORY = 1;
 
     /**
-     * Factory policy : COMPONENT_FACTORY.
-     * TODO : Component_factory behavior
+     * At this time, it is only the java interface full name.
      */
-    public static final int COMPONENT_FACTORY = 2;
+    private String[] m_serviceSpecification = new String[0];
 
-	/**
-	 * At this time, it is only the java interface full name.
-	 */
-	private String[] m_serviceSpecification = new String[0];
-
-	/**
-	 * List of proeprty metadata.
-	 */
-	private PropertyMetadata[] m_properties = new PropertyMetadata[0];
+    /**
+     * List of proeprty metadata.
+     */
+    private PropertyMetadata[] m_properties = new PropertyMetadata[0];
 
-	/**
-	 * Foactory policy.
-	 */
-	private int m_factoryPolicy = SINGLETON_FACTORY;
+    /**
+     * Foactory policy.
+     */
+    private int m_factoryPolicy = SINGLETON_FACTORY;
 
-	//CONSTRUCTOR :
+    //CONSTRUCTOR :
 
-	/**
+    /**
      * Constructor.
-	 * @param specification : service specification (i.e. the interface)
-	 * @param factoryPolicy : the facotry policy.
-	 */
-	public ProvidedServiceMetadata(String[] specification, int factoryPolicy) {
-		m_serviceSpecification = specification;
-		m_factoryPolicy = factoryPolicy;
-	}
-
-	// GETTERS :
-
-
-	/**
-	 * @return the service specification (i.e. the interface)
-	 */
-	public String[] getServiceSpecification() { return m_serviceSpecification; }
-
-	/**
-	 * @return the property metadata list.
-	 */
-	public PropertyMetadata[] getProperties() { return m_properties; }
-
-	/**
-	 * @return the factory policy.
-	 */
-	public int getFactoryPolicy() { return m_factoryPolicy; }
+     * @param specification : service specification (i.e. the interface)
+     * @param factoryPolicy : the facotry policy.
+     */
+    public ProvidedServiceMetadata(String[] specification, int factoryPolicy) {
+        m_serviceSpecification = specification;
+        m_factoryPolicy = factoryPolicy;
+    }
+
+    // GETTERS :
+
 
-	// SETTERS  :
+    /**
+     * @return the service specification (i.e. the interface)
+     */
+    public String[] getServiceSpecification() { return m_serviceSpecification; }
+
+    /**
+     * @return the property metadata list.
+     */
+    public PropertyMetadata[] getProperties() { return m_properties; }
+
+    /**
+     * @return the factory policy.
+     */
+    public int getFactoryPolicy() { return m_factoryPolicy; }
+
+    // SETTERS  :
 
-	/**
+    /**
      * Add the given property metadata to the property metadata list.
-	 * @param p : property metdata to add
-	 */
-	protected void addProperty(PropertyMetadata p) {
+     * @param p : property metdata to add
+     */
+    protected void addProperty(PropertyMetadata p) {
         for (int i = 0; (m_properties != null) && (i < m_properties.length); i++) {
             if (m_properties[i] == p) { return; }
         }
@@ -101,8 +97,6 @@
             newProp[m_properties.length] = p;
             m_properties = newProp;
         }
-        else {
-        	m_properties = new PropertyMetadata[] {p};
-        }
-	}
+        else { m_properties = new PropertyMetadata[] {p}; }
+    }
 }



Mime
View raw message