You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2007/08/22 17:21:28 UTC

svn commit: r568653 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr: ComponentActorThread.java ComponentMetadata.java ComponentRegistry.java DependencyManager.java XmlHandler.java

Author: fmeschbe
Date: Wed Aug 22 08:21:27 2007
New Revision: 568653

URL: http://svn.apache.org/viewvc?rev=568653&view=rev
Log:
Remove "this." prefixing and apply Felix Coding Standards

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java?rev=568653&r1=568652&r2=568653&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java Wed Aug 22 08:21:27 2007
@@ -38,7 +38,7 @@
     ComponentActorThread()
     {
         super( "SCR Component Actor" );
-        this.tasks = new LinkedList();
+        tasks = new LinkedList();
     }
 
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java?rev=568653&r1=568652&r2=568653&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java Wed Aug 22 08:21:27 2007
@@ -18,7 +18,11 @@
  */
 package org.apache.felix.scr;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
 
 import org.osgi.service.component.ComponentException;
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java?rev=568653&r1=568652&r2=568653&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java Wed Aug 22 08:21:27 2007
@@ -77,7 +77,7 @@
     public void configurationEvent( ConfigurationEvent configEvent )
     {
         String pid = configEvent.getPid();
-        ComponentManager cm = this.getComponent( pid );
+        ComponentManager cm = getComponent( pid );
         if ( cm != null )
         {
             cm.reconfigure();

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java?rev=568653&r1=568652&r2=568653&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java Wed Aug 22 08:21:27 2007
@@ -85,7 +85,7 @@
             filterString );
         for ( int i = 0; refs != null && i < refs.length; i++ )
         {
-            this.addingService( refs[i] );
+            addingService( refs[i] );
         }
     }
 
@@ -97,14 +97,14 @@
         switch ( event.getType() )
         {
             case ServiceEvent.REGISTERED:
-                this.addingService( event.getServiceReference() );
+                addingService( event.getServiceReference() );
                 break;
             case ServiceEvent.MODIFIED:
-                this.removedService( event.getServiceReference() );
-                this.addingService( event.getServiceReference() );
+                removedService( event.getServiceReference() );
+                addingService( event.getServiceReference() );
                 break;
             case ServiceEvent.UNREGISTERING:
-                this.removedService( event.getServiceReference() );
+                removedService( event.getServiceReference() );
                 break;
         }
     }
@@ -243,7 +243,7 @@
      */
     boolean isValid()
     {
-        return this.size() > 0 || m_dependencyMetadata.isOptional();
+        return size() > 0 || m_dependencyMetadata.isOptional();
     }
 
 
@@ -257,7 +257,7 @@
     {
         // If no references were received, we have to check if the dependency
         // is optional, if it is not then the dependency is invalid
-        if ( !this.isValid() )
+        if ( !isValid() )
         {
             return false;
         }
@@ -270,7 +270,7 @@
         }
 
         // Get service references
-        ServiceReference refs[] = this.getServiceReferences();
+        ServiceReference refs[] = getServiceReferences();
 
         // refs can be null if the dependency is optional
         if ( refs != null )
@@ -285,7 +285,7 @@
 
             for ( int index = 0; index < max; index++ )
             {
-                retval = this.invokeBindMethod( instance, refs[index], this.getService( refs[index] ) );
+                retval = invokeBindMethod( instance, refs[index], getService( refs[index] ) );
                 if ( retval == false && ( max == 1 ) )
                 {
                     // There was an exception when calling the bind method
@@ -313,14 +313,14 @@
             return;
         }
 
-        ServiceReference[] allrefs = this.getServiceReferences();
+        ServiceReference[] allrefs = getServiceReferences();
 
         if ( allrefs == null )
             return;
 
         for ( int i = 0; i < allrefs.length; i++ )
         {
-            this.invokeUnbindMethod( instance, allrefs[i], this.getService( allrefs[i] ) );
+            invokeUnbindMethod( instance, allrefs[i], getService( allrefs[i] ) );
         }
     }
 
@@ -459,7 +459,7 @@
                 // Get the bind method
                 Activator.trace( "getting bind: " + m_dependencyMetadata.getBind(), m_componentManager
                     .getComponentMetadata() );
-                Method bindMethod = this.getBindingMethod( m_dependencyMetadata.getBind(), implementationObject.getClass(),
+                Method bindMethod = getBindingMethod( m_dependencyMetadata.getBind(), implementationObject.getClass(),
                     m_dependencyMetadata.getInterface() );
 
                 if ( bindMethod == null )
@@ -488,7 +488,7 @@
                 bindMethod.invoke( implementationObject, new Object[]
                     { parameter } );
 
-                Activator.trace( "bound: " + this.getName(), m_componentManager.getComponentMetadata() );
+                Activator.trace( "bound: " + getName(), m_componentManager.getComponentMetadata() );
 
                 return true;
             }
@@ -539,7 +539,7 @@
             {
                 Activator.trace( "getting unbind: " + m_dependencyMetadata.getUnbind(), m_componentManager
                     .getComponentMetadata() );
-                Method unbindMethod = this.getBindingMethod( m_dependencyMetadata.getUnbind(), implementationObject
+                Method unbindMethod = getBindingMethod( m_dependencyMetadata.getUnbind(), implementationObject
                     .getClass(), m_dependencyMetadata.getInterface() );
 
                 // Recover the object that is bound from the map.
@@ -568,7 +568,7 @@
                 unbindMethod.invoke( implementationObject, new Object[]
                     { parameter } );
 
-                Activator.trace( "unbound: " + this.getName(), m_componentManager.getComponentMetadata() );
+                Activator.trace( "unbound: " + getName(), m_componentManager.getComponentMetadata() );
 
                 return true;
             }
@@ -612,7 +612,7 @@
         }
 
         // forward the event if in event handling state
-        if ( this.handleServiceEvent() )
+        if ( handleServiceEvent() )
         {
 
             // the component is UNSATISFIED if enabled but any of the references
@@ -634,9 +634,9 @@
                 // Otherwise only bind if bind services is zero, which
                 // captures the 0..1 case
                 // (size is still zero as we are called for the first service)
-                if ( m_dependencyMetadata.isMultiple() || this.size() == 0 )
+                if ( m_dependencyMetadata.isMultiple() || size() == 0 )
                 {
-                    this.invokeBindMethod( m_componentManager.getInstance(), reference, service );
+                    invokeBindMethod( m_componentManager.getInstance(), reference, service );
                 }
             }
         }
@@ -658,7 +658,7 @@
             return;
         }
 
-        if ( this.handleServiceEvent() )
+        if ( handleServiceEvent() )
         {
             // A static dependency is broken the instance manager will
             // be invalidated
@@ -684,7 +684,7 @@
                 // method
                 // and eventually request service unregistration
                 Object instance = m_componentManager.getInstance();
-                this.invokeUnbindMethod( instance, reference, service );
+                invokeUnbindMethod( instance, reference, service );
 
                 // The only thing we need to do here is check if we can
                 // reinitialize
@@ -695,10 +695,10 @@
                 // In the case of aggregates, this will only invalidate
                 // them since they
                 // can't be repaired.
-                if ( this.size() == 0 )
+                if ( size() == 0 )
                 {
                     // try to reinitialize
-                    if ( !this.bind( instance ) )
+                    if ( !bind( instance ) )
                     {
                         if ( !m_dependencyMetadata.isOptional() )
                         {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java?rev=568653&r1=568652&r2=568653&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java Wed Aug 22 08:21:27 2007
@@ -18,18 +18,21 @@
  */
 package org.apache.felix.scr;
 
-import java.util.Properties;
+
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.felix.scr.parser.KXml2SAXHandler;
 import org.apache.felix.scr.parser.ParseException;
 
+
 /**
  *
  *
  */
-public class XmlHandler implements KXml2SAXHandler {
+public class XmlHandler implements KXml2SAXHandler
+{
 
     public static final String NAMESPACE_URI = "http://www.osgi.org/xmlns/scr/v1.0.0";
 
@@ -51,6 +54,7 @@
     /** Override namespace. */
     protected String overrideNamespace;
 
+
     /**
      * Method called when a tag opens
      *
@@ -59,130 +63,152 @@
      * @param   attrib
      * @exception   ParseException
     **/
-    public void startElement(String uri, String localName, Properties attrib)
-    throws ParseException {
+    public void startElement( String uri, String localName, Properties attrib ) throws ParseException
+    {
         // according to the spec, the elements should have the namespace,
         // except when the root element is the "component" element
         // So we check this for the first element, we receive.
-        if ( this.firstElement ) {
-            this.firstElement = false;
-            if ( localName.equals("component") && "".equals(uri) ) {
-                this.overrideNamespace = NAMESPACE_URI;
+        if ( firstElement )
+        {
+            firstElement = false;
+            if ( localName.equals( "component" ) && "".equals( uri ) )
+            {
+                overrideNamespace = NAMESPACE_URI;
             }
         }
 
-        if ( this.overrideNamespace != null && "".equals(uri) ) {
-            uri = this.overrideNamespace;
+        if ( overrideNamespace != null && "".equals( uri ) )
+        {
+            uri = overrideNamespace;
         }
-        if ( NAMESPACE_URI.equals(uri) ) {
-        	try {
+        if ( NAMESPACE_URI.equals( uri ) )
+        {
+            try
+            {
+
+                // 112.4.3 Component Element
+                if ( localName.equals( "component" ) )
+                {
+
+                    // Create a new ComponentMetadata
+                    m_currentComponent = new ComponentMetadata();
+
+                    // name attribute is mandatory
+                    m_currentComponent.setName( attrib.getProperty( "name" ) );
+
+                    // enabled attribute is optional
+                    if ( attrib.getProperty( "enabled" ) != null )
+                    {
+                        m_currentComponent.setEnabled( attrib.getProperty( "enabled" ).equals( "true" ) );
+                    }
 
-    	    	// 112.4.3 Component Element
-    	        if (localName.equals("component")) {
+                    // immediate attribute is optional
+                    if ( attrib.getProperty( "immediate" ) != null )
+                    {
+                        m_currentComponent.setImmediate( attrib.getProperty( "immediate" ).equals( "true" ) );
+                    }
 
-    	        	// Create a new ComponentMetadata
-    	        	this.m_currentComponent = new ComponentMetadata();
-
-    	        	// name attribute is mandatory
-    	        	this.m_currentComponent.setName(attrib.getProperty("name"));
-
-    	        	// enabled attribute is optional
-    	        	if(attrib.getProperty("enabled") != null) {
-    	        		this.m_currentComponent.setEnabled(attrib.getProperty("enabled").equals("true"));
-    	        	}
-
-    	        	// immediate attribute is optional
-    	        	if(attrib.getProperty("immediate") != null) {
-    	        		this.m_currentComponent.setImmediate(attrib.getProperty("immediate").equals("true"));
-    	        	}
-
-    	        	// factory attribute is optional
-    	        	if(attrib.getProperty("factory") != null) {
-    	        		this.m_currentComponent.setFactoryIdentifier(attrib.getProperty("factory"));
-    	        	}
-
-    	        	// Add this component to the list
-    	            this.m_components.add(this.m_currentComponent);
-    	        }
-
-    	        // 112.4.4 Implementation
-    	        else if (localName.equals("implementation"))
-    	        {
-    	        	// Set the implementation class name (mandatory)
-    	        	this.m_currentComponent.setImplementationClassName(attrib.getProperty("class"));
-    	        }
-    	        // 112.4.5 Properties and Property Elements
-    	        else if (localName.equals("property")) {
+                    // factory attribute is optional
+                    if ( attrib.getProperty( "factory" ) != null )
+                    {
+                        m_currentComponent.setFactoryIdentifier( attrib.getProperty( "factory" ) );
+                    }
+
+                    // Add this component to the list
+                    m_components.add( m_currentComponent );
+                }
+
+                // 112.4.4 Implementation
+                else if ( localName.equals( "implementation" ) )
+                {
+                    // Set the implementation class name (mandatory)
+                    m_currentComponent.setImplementationClassName( attrib.getProperty( "class" ) );
+                }
+                // 112.4.5 Properties and Property Elements
+                else if ( localName.equals( "property" ) )
+                {
                     PropertyMetadata prop = new PropertyMetadata();
 
                     // name attribute is mandatory
-                    prop.setName(attrib.getProperty("name"));
+                    prop.setName( attrib.getProperty( "name" ) );
 
                     // type attribute is optional
-                    if(attrib.getProperty("type") != null) {
-                        prop.setType(attrib.getProperty("type"));
+                    if ( attrib.getProperty( "type" ) != null )
+                    {
+                        prop.setType( attrib.getProperty( "type" ) );
                     }
 
                     // 112.4.5: If the value attribute is specified, the body of the element is ignored.
-    	        	if( attrib.getProperty("value") != null) {
-            			prop.setValue(attrib.getProperty("value"));
-    	            	this.m_currentComponent.addProperty(prop);
-    	        	}
-    	        	else {
-    	        		// hold the metadata pending
-                        this.m_pendingProperty = prop;
-    	        	}
-    	        	// TODO: treat the case where a properties file name is provided (p. 292)
-    	        }
-    	        else if(localName.equals("properties")) {
-    	        	// TODO: implement the properties tag
-    	        }
-    	        // 112.4.6 Service Element
-    	        else if (localName.equals("service")) {
-
-    	        	this.m_currentService = new ServiceMetadata();
-
-    	        	// servicefactory attribute is optional
-    	        	if(attrib.getProperty("servicefactory") != null) {
-    	        		this.m_currentService.setServiceFactory(attrib.getProperty("servicefactory").equals("true"));
-    	        	}
-
-    	            this.m_currentComponent.setService(this.m_currentService);
-    	        }
-    	        else if (localName.equals("provide")) {
-    	            this.m_currentService.addProvide(attrib.getProperty("interface"));
-    	        }
-
-    	        // 112.4.7 Reference element
-    	        else if (localName.equals("reference")) {
-    	            ReferenceMetadata ref=new ReferenceMetadata ();
-    	            ref.setName(attrib.getProperty("name"));
-    	            ref.setInterface(attrib.getProperty("interface"));
-
-    	            // Cardinality
-    	            if(attrib.getProperty("cardinality")!= null) {
-    	            	ref.setCardinality(attrib.getProperty("cardinality"));
-    	            }
-
-    	            if(attrib.getProperty("policy") != null) {
-    	            	ref.setPolicy(attrib.getProperty("policy"));
-    	            }
-
-    	            //if
-    	            ref.setTarget(attrib.getProperty("target"));
-    	            ref.setBind(attrib.getProperty("bind"));
-    	            ref.setUnbind(attrib.getProperty("unbind"));
-
-    	            this.m_currentComponent.addDependency(ref);
-    	        }
-        	}
-        	catch(Exception ex) {
-        		ex.printStackTrace();
-        		throw new ParseException("Exception during parsing",ex);
-        	}
+                    if ( attrib.getProperty( "value" ) != null )
+                    {
+                        prop.setValue( attrib.getProperty( "value" ) );
+                        m_currentComponent.addProperty( prop );
+                    }
+                    else
+                    {
+                        // hold the metadata pending
+                        m_pendingProperty = prop;
+                    }
+                    // TODO: treat the case where a properties file name is provided (p. 292)
+                }
+                else if ( localName.equals( "properties" ) )
+                {
+                    // TODO: implement the properties tag
+                }
+                // 112.4.6 Service Element
+                else if ( localName.equals( "service" ) )
+                {
+
+                    m_currentService = new ServiceMetadata();
+
+                    // servicefactory attribute is optional
+                    if ( attrib.getProperty( "servicefactory" ) != null )
+                    {
+                        m_currentService.setServiceFactory( attrib.getProperty( "servicefactory" ).equals( "true" ) );
+                    }
+
+                    m_currentComponent.setService( m_currentService );
+                }
+                else if ( localName.equals( "provide" ) )
+                {
+                    m_currentService.addProvide( attrib.getProperty( "interface" ) );
+                }
+
+                // 112.4.7 Reference element
+                else if ( localName.equals( "reference" ) )
+                {
+                    ReferenceMetadata ref = new ReferenceMetadata();
+                    ref.setName( attrib.getProperty( "name" ) );
+                    ref.setInterface( attrib.getProperty( "interface" ) );
+
+                    // Cardinality
+                    if ( attrib.getProperty( "cardinality" ) != null )
+                    {
+                        ref.setCardinality( attrib.getProperty( "cardinality" ) );
+                    }
+
+                    if ( attrib.getProperty( "policy" ) != null )
+                    {
+                        ref.setPolicy( attrib.getProperty( "policy" ) );
+                    }
+
+                    //if
+                    ref.setTarget( attrib.getProperty( "target" ) );
+                    ref.setBind( attrib.getProperty( "bind" ) );
+                    ref.setUnbind( attrib.getProperty( "unbind" ) );
+
+                    m_currentComponent.addDependency( ref );
+                }
+            }
+            catch ( Exception ex )
+            {
+                ex.printStackTrace();
+                throw new ParseException( "Exception during parsing", ex );
+            }
         }
     }
 
+
     /**
     * Method called when a tag closes
     *
@@ -190,27 +216,32 @@
     * @param   localName
     * @exception   ParseException
     */
-    public void endElement(String uri, String localName) throws ParseException
+    public void endElement( String uri, String localName )
     {
-        if ( this.overrideNamespace != null && "".equals(uri) ) {
-            uri = this.overrideNamespace;
+        if ( overrideNamespace != null && "".equals( uri ) )
+        {
+            uri = overrideNamespace;
         }
 
-        if ( NAMESPACE_URI.equals(uri) ) {
-            if (localName.equals("component"))
+        if ( NAMESPACE_URI.equals( uri ) )
+        {
+            if ( localName.equals( "component" ) )
+            {
+                // When the closing tag for a component is found, the component is validated to check if
+                // the implementation class has been set
+                m_currentComponent.validate();
+            }
+            else if ( localName.equals( "property" ) && m_pendingProperty != null )
             {
-            	// When the closing tag for a component is found, the component is validated to check if
-            	// the implementation class has been set
-            	this.m_currentComponent.validate();
-            } else if (localName.equals("property") && this.m_pendingProperty != null) {
                 // 112.4.5 body expected to contain property value
                 // if so, the m_pendingProperty field would be null
                 // currently, we just ignore this situation
-                this.m_pendingProperty = null;
+                m_pendingProperty = null;
             }
         }
     }
 
+
     /**
     * Called to retrieve the service descriptors
     *
@@ -218,42 +249,48 @@
     */
     List getComponentMetadataList()
     {
-        return this.m_components;
+        return m_components;
     }
 
-	/**
-	 * @see org.apache.felix.scr.parser.KXml2SAXHandler#characters(java.lang.String)
-	 */
-	public void characters( String text ) throws ParseException
+
+    /**
+     * @see org.apache.felix.scr.parser.KXml2SAXHandler#characters(java.lang.String)
+     */
+    public void characters( String text )
     {
         // 112.4.5 If the value attribute is not specified, the body must contain one or more values
-        if ( this.m_pendingProperty != null )
+        if ( m_pendingProperty != null )
         {
-            this.m_pendingProperty.setValues( text );
-            this.m_currentComponent.addProperty( this.m_pendingProperty );
-            this.m_pendingProperty = null;
+            m_pendingProperty.setValues( text );
+            m_currentComponent.addProperty( m_pendingProperty );
+            m_pendingProperty = null;
         }
     }
 
-	/**
-	 * @see org.apache.felix.scr.parser.KXml2SAXHandler#processingInstruction(java.lang.String, java.lang.String)
-	 */
-	public void processingInstruction(String target, String data) throws ParseException {
-		// Not used
-	}
-
-	/**
-	 * @see org.apache.felix.scr.parser.KXml2SAXHandler#setLineNumber(int)
-	 */
-	public void setLineNumber(int lineNumber) {
-		// Not used
-	}
-
-	/**
-	 * @see org.apache.felix.scr.parser.KXml2SAXHandler#setColumnNumber(int)
-	 */
-	public void setColumnNumber(int columnNumber) {
-		// Not used
-	}
-}
 
+    /**
+     * @see org.apache.felix.scr.parser.KXml2SAXHandler#processingInstruction(java.lang.String, java.lang.String)
+     */
+    public void processingInstruction( String target, String data )
+    {
+        // Not used
+    }
+
+
+    /**
+     * @see org.apache.felix.scr.parser.KXml2SAXHandler#setLineNumber(int)
+     */
+    public void setLineNumber( int lineNumber )
+    {
+        // Not used
+    }
+
+
+    /**
+     * @see org.apache.felix.scr.parser.KXml2SAXHandler#setColumnNumber(int)
+     */
+    public void setColumnNumber( int columnNumber )
+    {
+        // Not used
+    }
+}