felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r702202 [3/4] - in /felix/trunk/ipojo: ant/src/main/java/org/apache/felix/ipojo/task/ core/src/main/java/org/apache/felix/ipojo/ handler/eventadmin/src/main/java/org/apache/felix/ipojo/handlers/event/ handler/eventadmin/src/main/java/org/ap...
Date Mon, 06 Oct 2008 17:08:45 GMT
Modified: felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardManager.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardManager.java (original)
+++ felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardManager.java Mon Oct  6 10:08:45 2008
@@ -1,173 +1,173 @@
-/* 
- * 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.handler.wbp;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.util.Callback;
-import org.apache.felix.ipojo.util.Tracker;
-import org.apache.felix.ipojo.util.TrackerCustomizer;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Manage a white board pattern.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class WhiteBoardManager implements TrackerCustomizer {
-    
-    /**
-     * monitored filter. 
-     */
-    private Filter m_filter;
-    
-    /**
-     * onArrival method. 
-     */
-    private Callback m_onArrival;
-    
-    /**
-     * onDeparture method. 
-     */
-    private Callback m_onDeparture;
-    
-    /**
-     * onModify method. 
-     */
-    private Callback m_onModification;
-    
-    /**
-     * Service Tracker. 
-     */
-    private Tracker m_tracker;
-    
-    /**
-     * Attached handler. 
-     */
-    private PrimitiveHandler m_handler;
-    
-    /**
-     * Constructor.
-     * @param handler : attached handler
-     * @param filter : monitored filter
-     * @param bind : onArrival method
-     * @param unbind : onDeparture method
-     * @param modification : onModify method
-     */
-    public WhiteBoardManager(WhiteBoardPatternHandler handler, Filter filter, String bind, String unbind, String modification) {
-        m_handler = handler;
-        m_onArrival = new Callback(bind, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
-        m_onDeparture = new Callback(unbind, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
-        if (modification != null) {
-            m_onModification = new Callback(modification, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
-        }
-        m_filter = filter;
-        m_tracker = new Tracker(handler.getInstanceManager().getContext(), m_filter, this);
-    }
-    
-    /**
-     * Open the tracker.
-     */
-    public void start() {
-        m_tracker.open();
-    }
-    
-    /**
-     * Close the tracker.
-     */
-    public void stop() {
-        m_tracker.close();
-    }
-
-    /**
-     * A new service was added to the tracker.
-     * @param arg0 : service reference.
-     * @see org.apache.felix.ipojo.util.TrackerCustomizer#addedService(org.osgi.framework.ServiceReference)
-     */
-    public void addedService(ServiceReference arg0) {
-        try {
-            m_onArrival.call(new Object[] {arg0});
-        } catch (NoSuchMethodException e) {
-            m_handler.error("The onArrival method " + m_onArrival.getMethod() + " does not exist in the class", e);
-            m_handler.getInstanceManager().stop();
-        } catch (IllegalAccessException e) {
-            m_handler.error("The onArrival method " + m_onArrival.getMethod() + " cannot be invoked", e);
-            m_handler.getInstanceManager().stop();
-        } catch (InvocationTargetException e) {
-            m_handler.error("The onArrival method " + m_onArrival.getMethod() + " has thrown an exception", e.getTargetException());
-            m_handler.getInstanceManager().stop();
-        }
-    }
-
-    /**
-     * A new service is detected.
-     * @param arg0 : service reference
-     * @return true to add the service
-     * @see org.apache.felix.ipojo.util.TrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
-     */
-    public boolean addingService(ServiceReference arg0) {
-        return true;
-    }
-
-    /**
-     * An existing service was modified.
-     * @param arg0 : service reference
-     * @param arg1 : service object (if already get)
-     * @see org.apache.felix.ipojo.util.TrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
-     */
-    public void modifiedService(ServiceReference arg0, Object arg1) {
-        if (m_onModification != null) {
-            try {
-                m_onModification.call(new Object[] {arg0});
-            } catch (NoSuchMethodException e) {
-                m_handler.error("The onModification method " + m_onModification.getMethod() + " does not exist in the class", e);
-                m_handler.getInstanceManager().stop();
-            } catch (IllegalAccessException e) {
-                m_handler.error("The onModification method " + m_onModification.getMethod() + " cannot be invoked", e);
-                m_handler.getInstanceManager().stop();
-            } catch (InvocationTargetException e) {
-                m_handler.error("The onModification method " + m_onModification.getMethod() + " has thrown an exception", e.getTargetException());
-                m_handler.getInstanceManager().stop();
-            }
-        }
-    }
-
-    /**
-     * A service disappears.
-     * @param arg0 : service reference
-     * @param arg1 : service object (if already get)
-     * @see org.apache.felix.ipojo.util.TrackerCustomizer#removedService(org.osgi.framework.ServiceReference, java.lang.Object)
-     */
-    public void removedService(ServiceReference arg0, Object arg1) {
-        try {
-            m_onDeparture.call(new Object[] {arg0});
-        } catch (NoSuchMethodException e) {
-            m_handler.error("The onDeparture method " + m_onDeparture.getMethod() + " does not exist in the class", e);
-            m_handler.getInstanceManager().stop();
-        } catch (IllegalAccessException e) {
-            m_handler.error("The onDeparture method " + m_onDeparture.getMethod() + " cannot be invoked", e);
-            m_handler.getInstanceManager().stop();
-        } catch (InvocationTargetException e) {
-            m_handler.error("The onDeparture method " + m_onDeparture.getMethod() + " has thrown an exception", e.getTargetException());
-            m_handler.getInstanceManager().stop();
-        }
-    }
-
-}
+/* 
+ * 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.handler.wbp;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.util.Callback;
+import org.apache.felix.ipojo.util.Tracker;
+import org.apache.felix.ipojo.util.TrackerCustomizer;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Manage a white board pattern.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class WhiteBoardManager implements TrackerCustomizer {
+    
+    /**
+     * The monitored filter. 
+     */
+    private Filter m_filter;
+    
+    /**
+     * The onArrival method. 
+     */
+    private Callback m_onArrival;
+    
+    /**
+     * The onDeparture method. 
+     */
+    private Callback m_onDeparture;
+    
+    /**
+     * The onModify method. 
+     */
+    private Callback m_onModification;
+    
+    /**
+     * The service tracker. 
+     */
+    private Tracker m_tracker;
+    
+    /**
+     * The attached handler. 
+     */
+    private PrimitiveHandler m_handler;
+    
+    /**
+     * Constructor.
+     * @param handler the attached handler
+     * @param filter the monitored filter
+     * @param bind the onArrival method
+     * @param unbind the onDeparture method
+     * @param modification the onModify method
+     */
+    public WhiteBoardManager(WhiteBoardPatternHandler handler, Filter filter, String bind, String unbind, String modification) {
+        m_handler = handler;
+        m_onArrival = new Callback(bind, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
+        m_onDeparture = new Callback(unbind, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
+        if (modification != null) {
+            m_onModification = new Callback(modification, new Class[] {ServiceReference.class}, false, m_handler.getInstanceManager());
+        }
+        m_filter = filter;
+        m_tracker = new Tracker(handler.getInstanceManager().getContext(), m_filter, this);
+    }
+    
+    /**
+     * Opens the tracker.
+     */
+    public void start() {
+        m_tracker.open();
+    }
+    
+    /**
+     * Closes the tracker.
+     */
+    public void stop() {
+        m_tracker.close();
+    }
+
+    /**
+     * A new service was added to the tracker.
+     * @param arg0 the service reference.
+     * @see org.apache.felix.ipojo.util.TrackerCustomizer#addedService(org.osgi.framework.ServiceReference)
+     */
+    public void addedService(ServiceReference arg0) {
+        try {
+            m_onArrival.call(new Object[] {arg0});
+        } catch (NoSuchMethodException e) {
+            m_handler.error("The onArrival method " + m_onArrival.getMethod() + " does not exist in the class", e);
+            m_handler.getInstanceManager().stop();
+        } catch (IllegalAccessException e) {
+            m_handler.error("The onArrival method " + m_onArrival.getMethod() + " cannot be invoked", e);
+            m_handler.getInstanceManager().stop();
+        } catch (InvocationTargetException e) {
+            m_handler.error("The onArrival method " + m_onArrival.getMethod() + " has thrown an exception", e.getTargetException());
+            m_handler.getInstanceManager().stop();
+        }
+    }
+
+    /**
+     * A new service is detected.
+     * @param arg0 the service reference
+     * @return {@code true} to add the service.
+     * @see org.apache.felix.ipojo.util.TrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
+     */
+    public boolean addingService(ServiceReference arg0) {
+        return true;
+    }
+
+    /**
+     * An existing service was modified.
+     * @param arg0 the service reference
+     * @param arg1 the service object (if already get)
+     * @see org.apache.felix.ipojo.util.TrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
+     */
+    public void modifiedService(ServiceReference arg0, Object arg1) {
+        if (m_onModification != null) {
+            try {
+                m_onModification.call(new Object[] {arg0});
+            } catch (NoSuchMethodException e) {
+                m_handler.error("The onModification method " + m_onModification.getMethod() + " does not exist in the class", e);
+                m_handler.getInstanceManager().stop();
+            } catch (IllegalAccessException e) {
+                m_handler.error("The onModification method " + m_onModification.getMethod() + " cannot be invoked", e);
+                m_handler.getInstanceManager().stop();
+            } catch (InvocationTargetException e) {
+                m_handler.error("The onModification method " + m_onModification.getMethod() + " has thrown an exception", e.getTargetException());
+                m_handler.getInstanceManager().stop();
+            }
+        }
+    }
+
+    /**
+     * A service disappears.
+     * @param arg0 the service reference
+     * @param arg1 the service object (if already get)
+     * @see org.apache.felix.ipojo.util.TrackerCustomizer#removedService(org.osgi.framework.ServiceReference, java.lang.Object)
+     */
+    public void removedService(ServiceReference arg0, Object arg1) {
+        try {
+            m_onDeparture.call(new Object[] {arg0});
+        } catch (NoSuchMethodException e) {
+            m_handler.error("The onDeparture method " + m_onDeparture.getMethod() + " does not exist in the class", e);
+            m_handler.getInstanceManager().stop();
+        } catch (IllegalAccessException e) {
+            m_handler.error("The onDeparture method " + m_onDeparture.getMethod() + " cannot be invoked", e);
+            m_handler.getInstanceManager().stop();
+        } catch (InvocationTargetException e) {
+            m_handler.error("The onDeparture method " + m_onDeparture.getMethod() + " has thrown an exception", e.getTargetException());
+            m_handler.getInstanceManager().stop();
+        }
+    }
+
+}

Modified: felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java (original)
+++ felix/trunk/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java Mon Oct  6 10:08:45 2008
@@ -1,99 +1,99 @@
-/* 
- * 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.handler.wbp;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.metadata.Element;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * White board pattern handler.
- * This handler aims to automate white board patterns by invoking callback when needed.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class WhiteBoardPatternHandler extends PrimitiveHandler {
-    
-    /**
-     * Handler namespace.
-     */
-    public static final String NAMESPACE = "org.apache.felix.ipojo.white-board-pattern";
-    
-    /**
-     * White board pattern to manage. By default just one. 
-     */
-    private List m_managers = new ArrayList(1);
-
-    /**
-     * Configure method. It will parse metadata to analyze org.apache.felix.ipojo.white-board-pattern:wbp element. 
-     * @param elem : component type description
-     * @param dict : instance description
-     * @throws ConfigurationException : occurs when the description is not valid.
-     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)
-     */
-    public void configure(Element elem, Dictionary dict) throws ConfigurationException {
-        Element[] elems = elem.getElements("wbp", NAMESPACE);
-        for (int i = 0; i < elems.length; i++) {
-            String filter = elems[i].getAttribute("filter");
-            String onArrival = elems[i].getAttribute("onArrival");
-            String onDeparture = elems[i].getAttribute("onDeparture");
-            String onModification = elems[i].getAttribute("onModification");
-            
-            if (filter == null) {
-                throw new ConfigurationException("The white board pattern element requires a filter attribute");
-            }
-            if (onArrival == null || onDeparture == null) {
-                throw new ConfigurationException("The white board pattern element requires the onArrival and onDeparture attributes");
-            }
-            
-            try {
-                WhiteBoardManager wbm = new WhiteBoardManager(this, getInstanceManager().getContext().createFilter(filter), onArrival, onDeparture, onModification);
-                m_managers.add(wbm);
-            } catch (InvalidSyntaxException e) {
-                throw new ConfigurationException("The filter " + filter + " is invalid : " + e);
-            }
-        }
-        
-    }
-
-    /**
-     * Start method : start managers.
-     * @see org.apache.felix.ipojo.Handler#start()
-     */
-    public void start() {
-        for (int i = 0; i < m_managers.size(); i++) {
-            ((WhiteBoardManager) m_managers.get(i)).start();
-        }
-    }
-
-    /**
-     * Stop method : stop managers.
-     * @see org.apache.felix.ipojo.Handler#stop()
-     */
-    public void stop() {
-        for (int i = 0; i < m_managers.size(); i++) {
-            ((WhiteBoardManager) m_managers.get(i)).stop();
-        } 
-    }
-
-}
+/* 
+ * 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.handler.wbp;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.metadata.Element;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * White board pattern handler.
+ * This handler aims to automate white board patterns by invoking callback when needed.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class WhiteBoardPatternHandler extends PrimitiveHandler {
+    
+    /**
+     * The handler namespace.
+     */
+    public static final String NAMESPACE = "org.apache.felix.ipojo.white-board-pattern";
+    
+    /**
+     * The white board pattern to manage. By default just one. 
+     */
+    private List m_managers = new ArrayList(1);
+
+    /**
+     * Configure method. Parses the metadata to analyze white-board-pattern elements. 
+     * @param elem the component type description
+     * @param dict the instance description
+     * @throws ConfigurationException if the description is not valid.
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)
+     */
+    public void configure(Element elem, Dictionary dict) throws ConfigurationException {
+        Element[] elems = elem.getElements("wbp", NAMESPACE);
+        for (int i = 0; i < elems.length; i++) {
+            String filter = elems[i].getAttribute("filter");
+            String onArrival = elems[i].getAttribute("onArrival");
+            String onDeparture = elems[i].getAttribute("onDeparture");
+            String onModification = elems[i].getAttribute("onModification");
+            
+            if (filter == null) {
+                throw new ConfigurationException("The white board pattern element requires a filter attribute");
+            }
+            if (onArrival == null || onDeparture == null) {
+                throw new ConfigurationException("The white board pattern element requires the onArrival and onDeparture attributes");
+            }
+            
+            try {
+                WhiteBoardManager wbm = new WhiteBoardManager(this, getInstanceManager().getContext().createFilter(filter), onArrival, onDeparture, onModification);
+                m_managers.add(wbm);
+            } catch (InvalidSyntaxException e) {
+                throw new ConfigurationException("The filter " + filter + " is invalid : " + e);
+            }
+        }
+        
+    }
+
+    /**
+     * Start method. Starts managers.
+     * @see org.apache.felix.ipojo.Handler#start()
+     */
+    public void start() {
+        for (int i = 0; i < m_managers.size(); i++) {
+            ((WhiteBoardManager) m_managers.get(i)).start();
+        }
+    }
+
+    /**
+     * Stop method. Stops managers.
+     * @see org.apache.felix.ipojo.Handler#stop()
+     */
+    public void stop() {
+        for (int i = 0; i < m_managers.size(); i++) {
+            ((WhiteBoardManager) m_managers.get(i)).stop();
+        } 
+    }
+
+}

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java (original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java Mon Oct  6 10:08:45 2008
@@ -1,381 +1,381 @@
-/* 
- * 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.manipulation.annotations;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.commons.EmptyVisitor;
-
-/**
- * Collect metadata from classes by parsing annotation.
- * This class collects type (i.e.) annotations and create method & field collectors.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class MetadataCollector extends EmptyVisitor implements Opcodes {
-
-    /**
-     * Class name.
-     */
-    private String m_className;
-    
-    /**
-     * Root element of computed metadata.
-     */
-    private Element m_elem = new Element("component", "");
-    
-    /**
-     * True if the visited class is a component type declaration (i.e. contains the @component annotation).
-     */
-    private boolean m_containsAnnotation = false;
-    
-    /**
-     * Map of [element ids, element].
-     * This map is used to easily get an already created element. 
-     */
-    private Map m_ids = new HashMap();
-    
-    /**
-     * Map of [element, referto].
-     * This map is used to recreate the element hierarchie.
-     * Stored element are added under referred element. 
-     */
-    private Map m_elements = new HashMap();
-    
-    public Element getElem() {
-        return m_elem;
-    }
-    
-    public boolean isAnnotated() {
-        return m_containsAnnotation;
-    }
-    
-
-    /**
-     * Start visiting a class.
-     * Initialize the getter/setter generator, add the _cm field, add the pojo interface.
-     * @param version : class version
-     * @param access : class access
-     * @param name : class name 
-     * @param signature : class signature
-     * @param superName : class super class
-     * @param interfaces : implemented interfaces
-     * @see org.objectweb.asm.ClassAdapter#visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
-     */
-    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
-        m_ids = new HashMap();
-        m_elements = new HashMap();
-        m_className = name;
-    }
-
-    
-    /**
-     * Visit class annotations.
-     * This method detects @component, @provides and @Element annotations.
-     * @param desc : annotation descriptor.
-     * @param visible : is the annotation visible at runtime.
-     * @return the annotation visitor.
-     * @see org.objectweb.asm.ClassAdapter#visitAnnotation(java.lang.String, boolean)
-     */
-    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
-        // @Component
-        if (desc.equals("Lorg/apache/felix/ipojo/annotations/Component;")) {
-            // It is a component
-            m_containsAnnotation = true;
-            m_elem.addAttribute(new Attribute("className", m_className.replace('/', '.')));
-            return new ComponentVisitor();
-        }
-        
-        // @Provides
-        if (desc.equals("Lorg/apache/felix/ipojo/annotations/Provides;")) {
-            return new ProvidesVisitor();
-        }
-        
-        if (CustomAnnotationVisitor.isCustomAnnotation(desc)) {
-            Element elem = CustomAnnotationVisitor.buildElement(desc);
-            return new CustomAnnotationVisitor(elem, this, true);
-        }
-        
-        return null;
-    }
-    
-
-
-    /**
-     * Visit a field.
-     * Call the field collector visitor.
-     * @param access : field access.
-     * @param name : field name
-     * @param desc : field descriptor
-     * @param signature : field signature
-     * @param value : field value (static field only)
-     * @return the field visitor.
-     * @see org.objectweb.asm.ClassAdapter#visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
-     */
-    public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
-        return new FieldCollector(name, this);
-    }
-
-    /**
-     * Visit a method.
-     * Call the method collector visitor.
-     * @param access : method access
-     * @param name : method name
-     * @param desc : method descriptor
-     * @param signature : method signature
-     * @param exceptions : method exceptions
-     * @return the Method Visitor.
-     * @see org.objectweb.asm.ClassAdapter#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
-     */
-    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
-        return new MethodCollector(name, this);
-    }
-    
-    /**
-     * End of the visit : compute final elements.
-     * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
-     */
-    public void visitEnd() {
-        // Recompute the tree
-        Set elems = getElements().keySet();
-        Iterator it = elems.iterator();
-        while (it.hasNext()) {
-            Element current = (Element) it.next();
-            String reference = (String) getElements().get(current);
-            if (reference == null) {
-                m_elem.addElement(current);
-            } else {
-                Element ref = (Element) getIds().get(reference);
-                if (ref == null) {
-                    System.err.println("The element " + reference + " is not declared - skip the element " + current.toXMLString());
-                } else {
-                    ref.addElement(current);
-                }
-            }
-        }
-    }
-
-    protected Map getIds() {
-        return m_ids;
-    }
-
-    protected Map getElements() {
-        return m_elements;
-    }
-
-    /**
-     * Parse the @provides annotation.
-     */
-    private class ProvidesVisitor extends EmptyVisitor implements AnnotationVisitor {
-        /**
-         * Provides element.
-         */
-        Element m_prov = new Element("provides", "");
-
-        /**
-         * Visit @provides annotation attributes.
-         * @param arg0 : annotation attribute name
-         * @param arg1 : annotation attribute value
-         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
-         */
-        public void visit(String arg0, Object arg1) {
-            if (arg0.equals("factory")) {
-                m_prov.addAttribute(new Attribute("factory", arg1.toString()));
-            }
-        }
-        
-        /**
-         * Visit specifications array.
-         * @param arg0 : attribute name
-         * @return a visitor visiting each element of the array.
-         * @see org.objectweb.asm.commons.EmptyVisitor#visitArray(java.lang.String)
-         */
-        public AnnotationVisitor visitArray(String arg0) {
-            if (arg0.equals("specifications")) {
-                return new InterfaceArrayVisitor();
-            } else {
-                return null;
-            }
-        }
-        
-        /**
-         * End of the visit.
-         * Append to the parent element the computed "provides" element.
-         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
-         */
-        public void visitEnd() {
-            getIds().put("provides", m_prov);
-            getElements().put(m_prov, null);
-        }
-        
-        private class InterfaceArrayVisitor extends EmptyVisitor {
-            /**
-             * List of parsed interface.
-             */
-            private String m_itfs;
-            
-            /**
-             * Visit one element of the array.
-             * @param arg0 : null
-             * @param arg1 : element value.
-             * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
-             */
-            public void visit(String arg0, Object arg1) {
-                if (m_itfs == null) {
-                    m_itfs = "{" + ((Type) arg1).getClassName();
-                } else {
-                    m_itfs += "," + ((Type) arg1).getClassName();
-                }
-            }
-            
-            /**
-             * End of the array visit.
-             * Add the attribute to 'provides' element.
-             * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
-             */
-            public void visitEnd() {
-                m_prov.addAttribute(new Attribute("interface", m_itfs + "}"));
-            }
-            
-        }
-        
-    }
-    
-    /**
-     * Parse the @component annotation.
-     */
-    private class ComponentVisitor extends EmptyVisitor implements AnnotationVisitor {
-        
-        /**
-         * Factory attribute.
-         */
-        private String m_factory;
-
-        /**
-         * Is the component an immediate component? 
-         */
-        private String m_immediate;
-        
-        /**
-         * Component name (cannot be null). 
-         */
-        private String m_name;
-        
-        /**
-         * Does the component exposes its architecture?
-         */
-        private String m_architecture;
-
-        /**
-         * Does the component propagate configuration to provided services?
-         */
-        private String m_propagation;
-        
-        /**
-         * Managed Service PID.
-         */
-        private String m_managedservice;
-        
-        /**
-         * Element properties.
-         */
-        private Element m_props;
-
-        /**
-         * Visit @component annotation attribute.
-         * @param arg0 : attribute name
-         * @param arg1 : attribute value
-         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
-         */
-        public void visit(String arg0, Object arg1) {
-            if (arg0.equals("public_factory")) {
-                m_factory = arg1.toString();
-                return;
-            }
-            if (arg0.equals("name")) {
-                m_name = arg1.toString();
-                return;
-            }
-            if (arg0.equals("immediate")) {
-                m_immediate = arg1.toString();
-                return;
-            }
-            if (arg0.equals("architecture")) {
-                m_architecture = arg1.toString();
-                return;
-            }
-            if (arg0.equals("propagation")) {
-                m_propagation = arg1.toString();
-                return;
-            }
-            if (arg0.equals("managedservice")) {
-                m_managedservice = arg1.toString();
-                return;
-            }
-        }
-
-        /**
-         * End of the visit.
-         * Append to the "component" element computed attribute.
-         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
-         */
-        public void visitEnd() { 
-            if (m_name == null) {
-                m_name = m_className.replace('/', '.');
-            }
-            m_elem.addAttribute(new Attribute("name", m_name));
-            if (m_factory != null && m_factory.equalsIgnoreCase("false")) {
-                m_elem.addAttribute(new Attribute("public", "false"));
-            } else {
-                m_elem.addAttribute(new Attribute("public", "true")); 
-            }
-            if (m_architecture != null) {
-                m_elem.addAttribute(new Attribute("architecture", m_architecture));
-            }
-            if (m_immediate != null) {
-                m_elem.addAttribute(new Attribute("immediate", m_immediate));
-            }
-            if (m_propagation != null) {
-                if (m_props == null) {
-                    m_props = new Element("properties", "");
-                    getElements().put(m_props, null);
-                    getIds().put("properties", m_props);
-                }
-                m_props.addAttribute(new Attribute("propagation", m_propagation));
-            }
-            if (m_managedservice != null) {
-                if (m_props == null) {
-                    m_props = new Element("properties", "");
-                    getElements().put(m_props, null);
-                    getIds().put("properties", m_props);
-                }
-                m_props.addAttribute(new Attribute("pid", m_managedservice));
-            }
-        }        
-    }
-}
+/* 
+ * 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.manipulation.annotations;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.EmptyVisitor;
+
+/**
+ * Collect metadata from classes by parsing annotation.
+ * This class collects type (i.e.) annotations and create method & field collectors.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class MetadataCollector extends EmptyVisitor implements Opcodes {
+
+    /**
+     * Class name.
+     */
+    private String m_className;
+    
+    /**
+     * Root element of computed metadata.
+     */
+    private Element m_elem = new Element("component", "");
+    
+    /**
+     * True if the visited class is a component type declaration (i.e. contains the @component annotation).
+     */
+    private boolean m_containsAnnotation = false;
+    
+    /**
+     * Map of [element ids, element].
+     * This map is used to easily get an already created element. 
+     */
+    private Map m_ids = new HashMap();
+    
+    /**
+     * Map of [element, referto].
+     * This map is used to recreate the element hierarchie.
+     * Stored element are added under referred element. 
+     */
+    private Map m_elements = new HashMap();
+    
+    public Element getElem() {
+        return m_elem;
+    }
+    
+    public boolean isAnnotated() {
+        return m_containsAnnotation;
+    }
+    
+
+    /**
+     * Start visiting a class.
+     * Initialize the getter/setter generator, add the _cm field, add the pojo interface.
+     * @param version : class version
+     * @param access : class access
+     * @param name : class name 
+     * @param signature : class signature
+     * @param superName : class super class
+     * @param interfaces : implemented interfaces
+     * @see org.objectweb.asm.ClassAdapter#visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+     */
+    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
+        m_ids = new HashMap();
+        m_elements = new HashMap();
+        m_className = name;
+    }
+
+    
+    /**
+     * Visit class annotations.
+     * This method detects @component, @provides and @Element annotations.
+     * @param desc : annotation descriptor.
+     * @param visible : is the annotation visible at runtime.
+     * @return the annotation visitor.
+     * @see org.objectweb.asm.ClassAdapter#visitAnnotation(java.lang.String, boolean)
+     */
+    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+        // @Component
+        if (desc.equals("Lorg/apache/felix/ipojo/annotations/Component;")) {
+            // It is a component
+            m_containsAnnotation = true;
+            m_elem.addAttribute(new Attribute("className", m_className.replace('/', '.')));
+            return new ComponentVisitor();
+        }
+        
+        // @Provides
+        if (desc.equals("Lorg/apache/felix/ipojo/annotations/Provides;")) {
+            return new ProvidesVisitor();
+        }
+        
+        if (CustomAnnotationVisitor.isCustomAnnotation(desc)) {
+            Element elem = CustomAnnotationVisitor.buildElement(desc);
+            return new CustomAnnotationVisitor(elem, this, true);
+        }
+        
+        return null;
+    }
+    
+
+
+    /**
+     * Visit a field.
+     * Call the field collector visitor.
+     * @param access : field access.
+     * @param name : field name
+     * @param desc : field descriptor
+     * @param signature : field signature
+     * @param value : field value (static field only)
+     * @return the field visitor.
+     * @see org.objectweb.asm.ClassAdapter#visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
+     */
+    public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
+        return new FieldCollector(name, this);
+    }
+
+    /**
+     * Visit a method.
+     * Call the method collector visitor.
+     * @param access : method access
+     * @param name : method name
+     * @param desc : method descriptor
+     * @param signature : method signature
+     * @param exceptions : method exceptions
+     * @return the Method Visitor.
+     * @see org.objectweb.asm.ClassAdapter#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+     */
+    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+        return new MethodCollector(name, this);
+    }
+    
+    /**
+     * End of the visit : compute final elements.
+     * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
+     */
+    public void visitEnd() {
+        // Recompute the tree
+        Set elems = getElements().keySet();
+        Iterator it = elems.iterator();
+        while (it.hasNext()) {
+            Element current = (Element) it.next();
+            String reference = (String) getElements().get(current);
+            if (reference == null) {
+                m_elem.addElement(current);
+            } else {
+                Element ref = (Element) getIds().get(reference);
+                if (ref == null) {
+                    System.err.println("The element " + reference + " is not declared - skipping the element " + current.toXMLString());
+                } else {
+                    ref.addElement(current);
+                }
+            }
+        }
+    }
+
+    protected Map getIds() {
+        return m_ids;
+    }
+
+    protected Map getElements() {
+        return m_elements;
+    }
+
+    /**
+     * Parse the @provides annotation.
+     */
+    private class ProvidesVisitor extends EmptyVisitor implements AnnotationVisitor {
+        /**
+         * Provides element.
+         */
+        Element m_prov = new Element("provides", "");
+
+        /**
+         * Visit @provides annotation attributes.
+         * @param arg0 : annotation attribute name
+         * @param arg1 : annotation attribute value
+         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
+         */
+        public void visit(String arg0, Object arg1) {
+            if (arg0.equals("factory")) {
+                m_prov.addAttribute(new Attribute("factory", arg1.toString()));
+            }
+        }
+        
+        /**
+         * Visit specifications array.
+         * @param arg0 : attribute name
+         * @return a visitor visiting each element of the array.
+         * @see org.objectweb.asm.commons.EmptyVisitor#visitArray(java.lang.String)
+         */
+        public AnnotationVisitor visitArray(String arg0) {
+            if (arg0.equals("specifications")) {
+                return new InterfaceArrayVisitor();
+            } else {
+                return null;
+            }
+        }
+        
+        /**
+         * End of the visit.
+         * Append to the parent element the computed "provides" element.
+         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
+         */
+        public void visitEnd() {
+            getIds().put("provides", m_prov);
+            getElements().put(m_prov, null);
+        }
+        
+        private class InterfaceArrayVisitor extends EmptyVisitor {
+            /**
+             * List of parsed interface.
+             */
+            private String m_itfs;
+            
+            /**
+             * Visit one element of the array.
+             * @param arg0 : null
+             * @param arg1 : element value.
+             * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
+             */
+            public void visit(String arg0, Object arg1) {
+                if (m_itfs == null) {
+                    m_itfs = "{" + ((Type) arg1).getClassName();
+                } else {
+                    m_itfs += "," + ((Type) arg1).getClassName();
+                }
+            }
+            
+            /**
+             * End of the array visit.
+             * Add the attribute to 'provides' element.
+             * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
+             */
+            public void visitEnd() {
+                m_prov.addAttribute(new Attribute("interface", m_itfs + "}"));
+            }
+            
+        }
+        
+    }
+    
+    /**
+     * Parse the @component annotation.
+     */
+    private class ComponentVisitor extends EmptyVisitor implements AnnotationVisitor {
+        
+        /**
+         * Factory attribute.
+         */
+        private String m_factory;
+
+        /**
+         * Is the component an immediate component? 
+         */
+        private String m_immediate;
+        
+        /**
+         * Component name (cannot be null). 
+         */
+        private String m_name;
+        
+        /**
+         * Does the component exposes its architecture?
+         */
+        private String m_architecture;
+
+        /**
+         * Does the component propagate configuration to provided services?
+         */
+        private String m_propagation;
+        
+        /**
+         * Managed Service PID.
+         */
+        private String m_managedservice;
+        
+        /**
+         * Element properties.
+         */
+        private Element m_props;
+
+        /**
+         * Visit @component annotation attribute.
+         * @param arg0 : attribute name
+         * @param arg1 : attribute value
+         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
+         */
+        public void visit(String arg0, Object arg1) {
+            if (arg0.equals("public_factory")) {
+                m_factory = arg1.toString();
+                return;
+            }
+            if (arg0.equals("name")) {
+                m_name = arg1.toString();
+                return;
+            }
+            if (arg0.equals("immediate")) {
+                m_immediate = arg1.toString();
+                return;
+            }
+            if (arg0.equals("architecture")) {
+                m_architecture = arg1.toString();
+                return;
+            }
+            if (arg0.equals("propagation")) {
+                m_propagation = arg1.toString();
+                return;
+            }
+            if (arg0.equals("managedservice")) {
+                m_managedservice = arg1.toString();
+                return;
+            }
+        }
+
+        /**
+         * End of the visit.
+         * Append to the "component" element computed attribute.
+         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
+         */
+        public void visitEnd() { 
+            if (m_name == null) {
+                m_name = m_className.replace('/', '.');
+            }
+            m_elem.addAttribute(new Attribute("name", m_name));
+            if (m_factory != null && m_factory.equalsIgnoreCase("false")) {
+                m_elem.addAttribute(new Attribute("public", "false"));
+            } else {
+                m_elem.addAttribute(new Attribute("public", "true")); 
+            }
+            if (m_architecture != null) {
+                m_elem.addAttribute(new Attribute("architecture", m_architecture));
+            }
+            if (m_immediate != null) {
+                m_elem.addAttribute(new Attribute("immediate", m_immediate));
+            }
+            if (m_propagation != null) {
+                if (m_props == null) {
+                    m_props = new Element("properties", "");
+                    getElements().put(m_props, null);
+                    getIds().put("properties", m_props);
+                }
+                m_props.addAttribute(new Attribute("propagation", m_propagation));
+            }
+            if (m_managedservice != null) {
+                if (m_props == null) {
+                    m_props = new Element("properties", "");
+                    getElements().put(m_props, null);
+                    getIds().put("properties", m_props);
+                }
+                m_props.addAttribute(new Attribute("pid", m_managedservice));
+            }
+        }        
+    }
+}

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java (original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java Mon Oct  6 10:08:45 2008
@@ -1,470 +1,470 @@
-/* 
- * 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.manipulation.annotations;
-
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.commons.EmptyVisitor;
-
-/**
- * This class collects method annotations, and give them to the metadata collector. 
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class MethodCollector extends EmptyVisitor {
-
-    /**
-     * Parent collector.
-     */
-    private MetadataCollector m_collector;
-    
-    /**
-     * Method name. 
-     */
-    private String m_name;
-
-    /**
-     * Constructor.
-     * @param name : name of the method.
-     * @param collector : parent collector.
-     */
-    public MethodCollector(String name, MetadataCollector collector) {
-        m_collector = collector;
-        m_name = name;
-    }
-
-    /**
-     * Visit method annotations.
-     * @param arg0 : annotation name.
-     * @param arg1 : is the annotation visible at runtime.
-     * @return the visitor paring the visited annotation.
-     * @see org.objectweb.asm.commons.EmptyVisitor#visitAnnotation(java.lang.String, boolean)
-     */
-    public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
-        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Property;")) {
-            return processProperty();
-        }
-        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/ServiceProperty;")) {
-            return processServiceProperty();
-        }
-        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Validate;")) {
-            return processValidate();
-        }
-        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Invalidate;")) {
-            return processInvalidate();
-        }
-        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Bind;")) {
-            return processBind("bind");
-        }
-        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Unbind;")) {
-            return processBind("unbind");
-        }
-        
-        if (CustomAnnotationVisitor.isCustomAnnotation(arg0)) {
-            Element elem = CustomAnnotationVisitor.buildElement(arg0);
-            elem.addAttribute(new Attribute("method", m_name));
-            return new CustomAnnotationVisitor(elem, m_collector, true);
-        }
-        
-        return null;
-    }
-
-    /**
-     * Process @bind & @unbind.
-     * @param type : bind or unbind
-     * @return the visitor parsing @bind & @unbind annotations.
-     */
-    private AnnotationVisitor processBind(String type) {
-        return new BindAnnotationParser(m_name, type);
-    }
-
-    /**
-     * Process @validate annotation.
-     * @return null.
-     */
-    private AnnotationVisitor processValidate() {
-        Element cb = new Element("callback", "");
-        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("transition", "validate"));
-        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("method", m_name));
-        m_collector.getElements().put(cb, null);
-        return null;
-    }
-
-    /**
-     * Process @invalidate annotation.
-     * @return null.
-     */
-    private AnnotationVisitor processInvalidate() {
-        Element cb = new Element("callback", "");
-        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("transition", "invalidate"));
-        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("method", m_name));
-        m_collector.getElements().put(cb, null);
-        return null;
-    }
-
-    /**
-     * Process @serviceProperty annotation.
-     * @return the visitor parsing the visited annotation.
-     */
-    private AnnotationVisitor processServiceProperty() {
-        if (! m_collector.getIds().containsKey("provides")) {
-            System.err.println("the component does not provide services, skip ServiceProperty for " + m_name);
-            return null;
-        } else {
-            Element provides = (Element) m_collector.getIds().get("provides");
-            return new PropertyAnnotationParser(provides, m_name);
-        }
-    }
-
-    /**
-     * Process @property annotation.
-     * @return the visitor parsing the visited annotation.
-     */
-    private AnnotationVisitor processProperty() {
-        Element prop = null;
-        if (! m_collector.getIds().containsKey("properties")) {
-            prop = new Element("Properties", "");
-            m_collector.getIds().put("properties", prop);
-            m_collector.getElements().put(prop, null);
-        } else {
-            prop = (Element) m_collector.getIds().get("properties");
-        }
-        return new PropertyAnnotationParser(prop, m_name);
-    }
-
-    /**
-     * Parse @bind & @unbind annotations.
-     */
-    private final class BindAnnotationParser extends EmptyVisitor implements AnnotationVisitor {
-
-        /**
-         * Method name.
-         */
-        private String m_name;
-
-        /**
-         * Requirement filter.
-         */
-        private String m_filter;
-
-        /**
-         * Is the requirement optional?
-         */
-        private String m_optional;
-
-        /**
-         * Is the requirement aggregate?
-         */
-        private String m_aggregate;
-
-        /**
-         * Required specification. 
-         */
-        private String m_specification;
-
-        /**
-         * Requirement id.
-         */
-        private String m_id;
-
-        /**
-         * Bind or Unbind method?
-         */
-        private String m_type;
-        
-        /**
-         * Binding policy.
-         */
-        private String m_policy;
-        
-        /**
-         * Comparator.
-         */
-        private String m_comparator;
-        
-        /**
-         * From attribute.
-         */
-        private String m_from;
-
-        /**
-         * Constructor.
-         * @param bind : method name.
-         * @param type : is the callback a bind or an unbind method.
-         */
-        private BindAnnotationParser(String bind, String type) {
-            m_name = bind;
-            m_type = type;
-        }
-
-        /**
-         * Visit annotation attribute.
-         * @param arg0 : annotation name
-         * @param arg1 : annotation value
-         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
-         */
-        public void visit(String arg0, Object arg1) {
-            if (arg0.equals("filter")) {
-                m_filter = arg1.toString();
-                return;
-            }
-            if (arg0.equals("optional")) {
-                m_optional = arg1.toString();
-                return;
-            }
-            if (arg0.equals("aggregate")) {
-                m_aggregate = arg1.toString();
-                return;
-            }
-            if (arg0.equals("specification")) {
-                m_specification = arg1.toString();
-                return;
-            }
-            if (arg0.equals("policy")) {
-                m_policy = arg1.toString();
-                return;
-            }
-            if (arg0.equals("id")) {
-                m_id = arg1.toString();
-                return;
-            }
-            if (arg0.equals("comparator")) {
-                Type type = Type.getType(arg1.toString());
-                m_comparator = type.getClassName();
-                return;
-            }
-            if (arg0.equals("from")) {
-                m_from = arg1.toString();
-                return;
-            }
-            
-        }
-
-        /**
-         * End of the visit.
-         * Create or append the requirement info to a created or already existing "requires" element.
-         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
-         */
-        public void visitEnd() {
-            if (m_id == null) {
-                if (m_name.startsWith("bind")) {
-                    m_id = m_name.substring("bind".length());
-                } else if (m_name.startsWith("unbind")) {
-                    m_id = m_name.substring("unbind".length());
-                } else {
-                    System.err.println("Cannot determine the id of the bind method : " + m_name);
-                    return;
-                }
-            }
-            // Check if it is a full-determined requirement
-            Element req = (Element) m_collector.getIds().get(m_id);
-            if (req == null) {
-                // Add the complete requires
-                req = new Element("requires", "");
-                if (m_specification != null) {
-                    req.addAttribute(new Attribute("specification", m_specification));
-                }
-                if (m_aggregate != null) {
-                    req.addAttribute(new Attribute("aggregate", m_aggregate));
-                }
-                if (m_filter != null) {
-                    req.addAttribute(new Attribute("filter", m_filter));
-                }
-                if (m_optional != null) {
-                    req.addAttribute(new Attribute("optional", m_optional));
-                }
-                if (m_policy != null) {
-                    req.addAttribute(new Attribute("policy", m_policy));
-                }
-                if (m_id != null) {
-                    req.addAttribute(new Attribute("id", m_id));
-                }
-                if (m_comparator != null) {
-                    req.addAttribute(new Attribute("comparator", m_comparator));
-                }
-                if (m_from != null) {
-                    req.addAttribute(new Attribute("from", m_from));
-                }
-            } else {
-                String itf = req.getAttribute("specification");
-                String aggregate = req.getAttribute("aggregate");
-                String optional = req.getAttribute("optional");
-                String filter = req.getAttribute("filter");
-                String policy = req.getAttribute("policy");
-                String comparator = req.getAttribute("comparator");
-                String from = req.getAttribute("from");
-                if (m_specification != null) {
-                    if (itf == null) {
-                        req.addAttribute(new Attribute("specification", m_specification));
-                    } else if (! m_specification.equals(itf)) {
-                        System.err.println("The required specification is not the same than previouly : " + m_specification + " & " + itf);
-                        return;
-                    }
-                }
-                
-                if (m_optional != null) {
-                    if (optional == null) {
-                        req.addAttribute(new Attribute("optional", m_optional));
-                    } else if (! m_optional.equals(optional)) {
-                        System.err.println("The optional attribute is not always the same");
-                        return;
-                    }
-                }
-                
-                if (m_aggregate != null) {
-                    if (aggregate == null) {
-                        req.addAttribute(new Attribute("aggregate", m_aggregate));
-                    } else if (! m_aggregate.equals(aggregate)) {
-                        System.err.println("The aggregate attribute is not always the same");
-                        return;
-                    }
-                }
-                
-                if (m_filter != null) {
-                    if (filter == null) {
-                        req.addAttribute(new Attribute("filter", m_filter));
-                    } else if (! m_filter.equals(filter)) {
-                        System.err.println("The filter attribute is not always the same");
-                        return;
-                    }
-                }
-                
-                if (m_policy != null) {
-                    if (policy == null) {
-                        req.addAttribute(new Attribute("policy", m_policy));
-                    } else if (! m_policy.equals(policy)) {
-                        System.err.println("The policy attribute is not always the same");
-                        return;
-                    }
-                }
-                
-                if (m_comparator != null) {
-                    if (comparator == null) {
-                        req.addAttribute(new Attribute("comparator", m_comparator));
-                    } else if (! m_comparator.equals(comparator)) {
-                        System.err.println("The comparator attribute is not always the same");
-                        return;
-                    }
-                }
-                
-                if (m_from != null) {
-                    if (from == null) {
-                        req.addAttribute(new Attribute("from", m_from));
-                    } else if (! m_from.equals(from)) {
-                        System.err.println("The from attribute is not always the same");
-                        return;
-                    }
-                    
-                }
-                
-            }
-            Element method = new Element("callback", "");
-            method.addAttribute(new Attribute("method", m_name));
-            method.addAttribute(new Attribute("type", m_type));
-            req.addElement(method);
-            m_collector.getIds().put(m_id, req);
-            m_collector.getElements().put(req, null);
-            return;
-        }
-    }
-
-    private final class PropertyAnnotationParser extends EmptyVisitor implements AnnotationVisitor {
-
-        /**
-         * Parent element.
-         */
-        private Element m_parent;
-        
-        /**
-         * Attached method.
-         */
-        private String m_method;
-        
-        /**
-         * Property name. 
-         */
-        private String m_name;
-        
-        /**
-         * Property value. 
-         */
-        private String m_value;
-
-        /**
-         * Constructor.
-         * @param parent : parent element.
-         * @param method : attached method.
-         */
-        private PropertyAnnotationParser(Element parent, String method) {
-            m_parent = parent;
-            m_method = method;
-        }
-
-        /**
-         * Visit annotation attributes.
-         * @param arg0 : annotation name
-         * @param arg1 : annotation value
-         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
-         */
-        public void visit(String arg0, Object arg1) {
-            if (arg0.equals("name")) {
-                m_name = arg1.toString();
-                return;
-            }
-            if (arg0.equals("value")) {
-                m_value = arg1.toString();
-                return;
-            }
-        }
-
-        /**
-         * End of the visit.
-         * Append the computed element to the parent element.
-         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
-         */
-        public void visitEnd() {
-            if (m_name == null && m_method.startsWith("set")) {
-                m_name = m_method.substring("set".length());
-            }
-            Element[] props = m_parent.getElements("Property");
-            Element prop = null;
-            for (int i = 0; props != null && prop == null && i < props.length; i++) {
-                String name = props[i].getAttribute("name");
-                if (name != null && name.equals(m_name)) {
-                    prop = props[i];
-                }
-            }
-
-            if (prop == null) {
-                prop = new Element("property", "");
-                m_parent.addElement(prop);
-                if (m_name != null) {
-                    prop.addAttribute(new Attribute("name", m_name));
-                }
-            }
-
-            prop.addAttribute(new Attribute("method", m_method));
-            if (m_value != null) {
-                prop.addAttribute(new Attribute("value", m_value));
-            }
-
-        }
-    }
-}
+/* 
+ * 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.manipulation.annotations;
+
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.EmptyVisitor;
+
+/**
+ * This class collects method annotations, and give them to the metadata collector. 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class MethodCollector extends EmptyVisitor {
+
+    /**
+     * Parent collector.
+     */
+    private MetadataCollector m_collector;
+    
+    /**
+     * Method name. 
+     */
+    private String m_name;
+
+    /**
+     * Constructor.
+     * @param name : name of the method.
+     * @param collector : parent collector.
+     */
+    public MethodCollector(String name, MetadataCollector collector) {
+        m_collector = collector;
+        m_name = name;
+    }
+
+    /**
+     * Visit method annotations.
+     * @param arg0 : annotation name.
+     * @param arg1 : is the annotation visible at runtime.
+     * @return the visitor paring the visited annotation.
+     * @see org.objectweb.asm.commons.EmptyVisitor#visitAnnotation(java.lang.String, boolean)
+     */
+    public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
+        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Property;")) {
+            return processProperty();
+        }
+        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/ServiceProperty;")) {
+            return processServiceProperty();
+        }
+        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Validate;")) {
+            return processValidate();
+        }
+        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Invalidate;")) {
+            return processInvalidate();
+        }
+        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Bind;")) {
+            return processBind("bind");
+        }
+        if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Unbind;")) {
+            return processBind("unbind");
+        }
+        
+        if (CustomAnnotationVisitor.isCustomAnnotation(arg0)) {
+            Element elem = CustomAnnotationVisitor.buildElement(arg0);
+            elem.addAttribute(new Attribute("method", m_name));
+            return new CustomAnnotationVisitor(elem, m_collector, true);
+        }
+        
+        return null;
+    }
+
+    /**
+     * Process @bind & @unbind.
+     * @param type : bind or unbind
+     * @return the visitor parsing @bind & @unbind annotations.
+     */
+    private AnnotationVisitor processBind(String type) {
+        return new BindAnnotationParser(m_name, type);
+    }
+
+    /**
+     * Process @validate annotation.
+     * @return null.
+     */
+    private AnnotationVisitor processValidate() {
+        Element cb = new Element("callback", "");
+        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("transition", "validate"));
+        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("method", m_name));
+        m_collector.getElements().put(cb, null);
+        return null;
+    }
+
+    /**
+     * Process @invalidate annotation.
+     * @return null.
+     */
+    private AnnotationVisitor processInvalidate() {
+        Element cb = new Element("callback", "");
+        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("transition", "invalidate"));
+        cb.addAttribute(new org.apache.felix.ipojo.metadata.Attribute("method", m_name));
+        m_collector.getElements().put(cb, null);
+        return null;
+    }
+
+    /**
+     * Process @serviceProperty annotation.
+     * @return the visitor parsing the visited annotation.
+     */
+    private AnnotationVisitor processServiceProperty() {
+        if (! m_collector.getIds().containsKey("provides")) {
+            System.err.println("The component does not provide services, skipping ServiceProperty for " + m_name);
+            return null;
+        } else {
+            Element provides = (Element) m_collector.getIds().get("provides");
+            return new PropertyAnnotationParser(provides, m_name);
+        }
+    }
+
+    /**
+     * Process @property annotation.
+     * @return the visitor parsing the visited annotation.
+     */
+    private AnnotationVisitor processProperty() {
+        Element prop = null;
+        if (! m_collector.getIds().containsKey("properties")) {
+            prop = new Element("Properties", "");
+            m_collector.getIds().put("properties", prop);
+            m_collector.getElements().put(prop, null);
+        } else {
+            prop = (Element) m_collector.getIds().get("properties");
+        }
+        return new PropertyAnnotationParser(prop, m_name);
+    }
+
+    /**
+     * Parse @bind & @unbind annotations.
+     */
+    private final class BindAnnotationParser extends EmptyVisitor implements AnnotationVisitor {
+
+        /**
+         * Method name.
+         */
+        private String m_name;
+
+        /**
+         * Requirement filter.
+         */
+        private String m_filter;
+
+        /**
+         * Is the requirement optional?
+         */
+        private String m_optional;
+
+        /**
+         * Is the requirement aggregate?
+         */
+        private String m_aggregate;
+
+        /**
+         * Required specification. 
+         */
+        private String m_specification;
+
+        /**
+         * Requirement id.
+         */
+        private String m_id;
+
+        /**
+         * Bind or Unbind method?
+         */
+        private String m_type;
+        
+        /**
+         * Binding policy.
+         */
+        private String m_policy;
+        
+        /**
+         * Comparator.
+         */
+        private String m_comparator;
+        
+        /**
+         * From attribute.
+         */
+        private String m_from;
+
+        /**
+         * Constructor.
+         * @param bind : method name.
+         * @param type : is the callback a bind or an unbind method.
+         */
+        private BindAnnotationParser(String bind, String type) {
+            m_name = bind;
+            m_type = type;
+        }
+
+        /**
+         * Visit annotation attribute.
+         * @param arg0 : annotation name
+         * @param arg1 : annotation value
+         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
+         */
+        public void visit(String arg0, Object arg1) {
+            if (arg0.equals("filter")) {
+                m_filter = arg1.toString();
+                return;
+            }
+            if (arg0.equals("optional")) {
+                m_optional = arg1.toString();
+                return;
+            }
+            if (arg0.equals("aggregate")) {
+                m_aggregate = arg1.toString();
+                return;
+            }
+            if (arg0.equals("specification")) {
+                m_specification = arg1.toString();
+                return;
+            }
+            if (arg0.equals("policy")) {
+                m_policy = arg1.toString();
+                return;
+            }
+            if (arg0.equals("id")) {
+                m_id = arg1.toString();
+                return;
+            }
+            if (arg0.equals("comparator")) {
+                Type type = Type.getType(arg1.toString());
+                m_comparator = type.getClassName();
+                return;
+            }
+            if (arg0.equals("from")) {
+                m_from = arg1.toString();
+                return;
+            }
+            
+        }
+
+        /**
+         * End of the visit.
+         * Create or append the requirement info to a created or already existing "requires" element.
+         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
+         */
+        public void visitEnd() {
+            if (m_id == null) {
+                if (m_name.startsWith("bind")) {
+                    m_id = m_name.substring("bind".length());
+                } else if (m_name.startsWith("unbind")) {
+                    m_id = m_name.substring("unbind".length());
+                } else {
+                    System.err.println("Cannot determine the id of the bind method : " + m_name);
+                    return;
+                }
+            }
+            // Check if it is a full-determined requirement
+            Element req = (Element) m_collector.getIds().get(m_id);
+            if (req == null) {
+                // Add the complete requires
+                req = new Element("requires", "");
+                if (m_specification != null) {
+                    req.addAttribute(new Attribute("specification", m_specification));
+                }
+                if (m_aggregate != null) {
+                    req.addAttribute(new Attribute("aggregate", m_aggregate));
+                }
+                if (m_filter != null) {
+                    req.addAttribute(new Attribute("filter", m_filter));
+                }
+                if (m_optional != null) {
+                    req.addAttribute(new Attribute("optional", m_optional));
+                }
+                if (m_policy != null) {
+                    req.addAttribute(new Attribute("policy", m_policy));
+                }
+                if (m_id != null) {
+                    req.addAttribute(new Attribute("id", m_id));
+                }
+                if (m_comparator != null) {
+                    req.addAttribute(new Attribute("comparator", m_comparator));
+                }
+                if (m_from != null) {
+                    req.addAttribute(new Attribute("from", m_from));
+                }
+            } else {
+                String itf = req.getAttribute("specification");
+                String aggregate = req.getAttribute("aggregate");
+                String optional = req.getAttribute("optional");
+                String filter = req.getAttribute("filter");
+                String policy = req.getAttribute("policy");
+                String comparator = req.getAttribute("comparator");
+                String from = req.getAttribute("from");
+                if (m_specification != null) {
+                    if (itf == null) {
+                        req.addAttribute(new Attribute("specification", m_specification));
+                    } else if (! m_specification.equals(itf)) {
+                        System.err.println("The required specification is not the same as previouly : " + m_specification + " & " + itf);
+                        return;
+                    }
+                }
+                
+                if (m_optional != null) {
+                    if (optional == null) {
+                        req.addAttribute(new Attribute("optional", m_optional));
+                    } else if (! m_optional.equals(optional)) {
+                        System.err.println("The optional attribute is not always the same");
+                        return;
+                    }
+                }
+                
+                if (m_aggregate != null) {
+                    if (aggregate == null) {
+                        req.addAttribute(new Attribute("aggregate", m_aggregate));
+                    } else if (! m_aggregate.equals(aggregate)) {
+                        System.err.println("The aggregate attribute is not always the same");
+                        return;
+                    }
+                }
+                
+                if (m_filter != null) {
+                    if (filter == null) {
+                        req.addAttribute(new Attribute("filter", m_filter));
+                    } else if (! m_filter.equals(filter)) {
+                        System.err.println("The filter attribute is not always the same");
+                        return;
+                    }
+                }
+                
+                if (m_policy != null) {
+                    if (policy == null) {
+                        req.addAttribute(new Attribute("policy", m_policy));
+                    } else if (! m_policy.equals(policy)) {
+                        System.err.println("The policy attribute is not always the same");
+                        return;
+                    }
+                }
+                
+                if (m_comparator != null) {
+                    if (comparator == null) {
+                        req.addAttribute(new Attribute("comparator", m_comparator));
+                    } else if (! m_comparator.equals(comparator)) {
+                        System.err.println("The comparator attribute is not always the same");
+                        return;
+                    }
+                }
+                
+                if (m_from != null) {
+                    if (from == null) {
+                        req.addAttribute(new Attribute("from", m_from));
+                    } else if (! m_from.equals(from)) {
+                        System.err.println("The from attribute is not always the same");
+                        return;
+                    }
+                    
+                }
+                
+            }
+            Element method = new Element("callback", "");
+            method.addAttribute(new Attribute("method", m_name));
+            method.addAttribute(new Attribute("type", m_type));
+            req.addElement(method);
+            m_collector.getIds().put(m_id, req);
+            m_collector.getElements().put(req, null);
+            return;
+        }
+    }
+
+    private final class PropertyAnnotationParser extends EmptyVisitor implements AnnotationVisitor {
+
+        /**
+         * Parent element.
+         */
+        private Element m_parent;
+        
+        /**
+         * Attached method.
+         */
+        private String m_method;
+        
+        /**
+         * Property name. 
+         */
+        private String m_name;
+        
+        /**
+         * Property value. 
+         */
+        private String m_value;
+
+        /**
+         * Constructor.
+         * @param parent : parent element.
+         * @param method : attached method.
+         */
+        private PropertyAnnotationParser(Element parent, String method) {
+            m_parent = parent;
+            m_method = method;
+        }
+
+        /**
+         * Visit annotation attributes.
+         * @param arg0 : annotation name
+         * @param arg1 : annotation value
+         * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
+         */
+        public void visit(String arg0, Object arg1) {
+            if (arg0.equals("name")) {
+                m_name = arg1.toString();
+                return;
+            }
+            if (arg0.equals("value")) {
+                m_value = arg1.toString();
+                return;
+            }
+        }
+
+        /**
+         * End of the visit.
+         * Append the computed element to the parent element.
+         * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
+         */
+        public void visitEnd() {
+            if (m_name == null && m_method.startsWith("set")) {
+                m_name = m_method.substring("set".length());
+            }
+            Element[] props = m_parent.getElements("Property");
+            Element prop = null;
+            for (int i = 0; props != null && prop == null && i < props.length; i++) {
+                String name = props[i].getAttribute("name");
+                if (name != null && name.equals(m_name)) {
+                    prop = props[i];
+                }
+            }
+
+            if (prop == null) {
+                prop = new Element("property", "");
+                m_parent.addElement(prop);
+                if (m_name != null) {
+                    prop.addAttribute(new Attribute("name", m_name));
+                }
+            }
+
+            prop.addAttribute(new Attribute("method", m_method));
+            if (m_value != null) {
+                prop.addAttribute(new Attribute("value", m_value));
+            }
+
+        }
+    }
+}



Mime
View raw message