You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by go...@apache.org on 2012/07/10 04:08:21 UTC

svn commit: r1359458 - in /felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture: ComponentTypeDescription.java CustomHandlerInfo.java

Author: gokturk
Date: Tue Jul 10 02:08:21 2012
New Revision: 1359458

URL: http://svn.apache.org/viewvc?rev=1359458&view=rev
Log:
Fix for Felix-3560

* New class CustomHandlerInfo is added for custom handlers to embed their custom information into ComponentTypeDescription for both later retrieval and contribution to description output in Arch commands.

* ComponentTypeDescription is extended to accept CustomHandlerInfo and dump it as output in getDescription()

Added:
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/CustomHandlerInfo.java   (with props)
Modified:
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java?rev=1359458&r1=1359457&r2=1359458&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java (original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java Tue Jul 10 02:08:21 2012
@@ -19,6 +19,8 @@
 package org.apache.felix.ipojo.architecture;
 
 import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
 import java.util.Properties;
 
 import org.apache.felix.ipojo.ComponentFactory;
@@ -45,6 +47,11 @@ public class ComponentTypeDescription {
      * Configuration Properties accepted by the component type.
      */
     private PropertyDescription[] m_properties = new PropertyDescription[0];
+    
+    /*
+     * Used by custom handlers to keep and retrieve custom info.
+     */
+    private Dictionary m_handlerInfoSlot = new Hashtable();
 
     /**
      * Represented factory.
@@ -140,6 +147,32 @@ public class ComponentTypeDescription {
         newProps[m_properties.length] = pd;
         m_properties = newProps;
     }
+    
+    /**
+     * Adds the HandlerInfo for specified handler.
+     * @param handlerNs Handler's namespace
+     * @param handlerName Handler's name
+     * @param info HandlerInfo associated with the given custom handler.
+     */
+    public void setHandlerInfo(String handlerNs, String handlerName, CustomHandlerInfo info)
+    {
+    	String fullHandlerName = handlerNs + ":" + handlerName;
+    	
+    	if(info == null)
+    	{
+    		m_handlerInfoSlot.remove(fullHandlerName);
+    	}
+    	else
+    	{
+    		m_handlerInfoSlot.put(fullHandlerName, info);
+    	}
+    }
+    
+    public CustomHandlerInfo getHandlerInfo(String handlerNs, String handlerName)
+    {
+    	String fullHandlerName = handlerNs + ":" + handlerName;    	
+    	return (CustomHandlerInfo)m_handlerInfoSlot.get(fullHandlerName);
+    }
 
     /**
      * Gets the list of provided service offered by instances of this type.
@@ -255,6 +288,19 @@ public class ComponentTypeDescription {
             }
             desc.addElement(prop);
         }
+        
+        if(m_handlerInfoSlot.size() > 0)
+        {        	
+        	Enumeration keys = m_handlerInfoSlot.keys();
+            
+            while(keys.hasMoreElements())
+            {
+            	String fullHandlerName = (String) keys.nextElement();
+            	
+            	CustomHandlerInfo handlerInfo = (CustomHandlerInfo)m_handlerInfoSlot.get(fullHandlerName);
+            	desc.addElement( handlerInfo.getDescription() );
+            }
+        }
 
         return desc;
     }

Added: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/CustomHandlerInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/CustomHandlerInfo.java?rev=1359458&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/CustomHandlerInfo.java (added)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/CustomHandlerInfo.java Tue Jul 10 02:08:21 2012
@@ -0,0 +1,37 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.architecture;
+
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.metadata.Element;
+
+/**
+ * Information slot for custom {@link Handler}s to put their own custom 
+ * information into {@link ComponentTypeDescription} 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface CustomHandlerInfo 
+{
+	/**
+	 * Returns the custom handler information in readable
+	 * format to be displayed in ComponentTypeDescription.
+	 * @return Custom Handler information
+	 */
+	Element getDescription();
+}

Propchange: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/architecture/CustomHandlerInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain