felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1399617 - in /felix/trunk/metatype/src/main/java/org/apache/felix/metatype: MetaData.java MetaDataReader.java internal/MetaTypeInformationImpl.java
Date Thu, 18 Oct 2012 12:31:58 GMT
Author: fmeschbe
Date: Thu Oct 18 12:31:58 2012
New Revision: 1399617

URL: http://svn.apache.org/viewvc?rev=1399617&view=rev
Log:
FELIX-3720 Apply slightly modified patch by Alexander Berger (thanks alot)

Modified:
    felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaData.java
    felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
    felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java

Modified: felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaData.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaData.java?rev=1399617&r1=1399616&r2=1399617&view=diff
==============================================================================
--- felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaData.java (original)
+++ felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaData.java Thu Oct 18
12:31:58 2012
@@ -87,7 +87,14 @@ public class MetaData extends OptionalAt
                 designates = new HashMap();
             }
 
-            designates.put( designate.getPid(), designate );
+            if ( designate.getFactoryPid() != null )
+            {
+                designates.put( designate.getFactoryPid(), designate );
+            }
+            else
+            {
+                designates.put( designate.getPid(), designate );
+            }
         }
     }
 

Modified: felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java?rev=1399617&r1=1399616&r2=1399617&view=diff
==============================================================================
--- felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java (original)
+++ felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java Thu Oct
18 12:31:58 2012
@@ -84,7 +84,7 @@ public class MetaDataReader
     private final Set DESIGNATEOBJECT_ATTRIBUTES = new HashSet(Arrays.asList(new String[]
{ "ocdref" }));
     private final Set METADATA_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "localization"
}));
     private final Set OCD_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "name", "description",
"id" }));
-    
+
 
     /**
      * Parses the XML document provided by the <code>url</code>. The XML document
@@ -196,7 +196,7 @@ public class MetaDataReader
         return mti;
     }
 
-    
+
     private void readOptionalAttributes(OptionalAttributes entity, Set attributes) {
         int count = this.parser.getAttributeCount();
         for (int i = 0; i < count; i++)
@@ -209,13 +209,13 @@ public class MetaDataReader
             }
         }
     }
-    
+
 
     private MetaData readMetaData() throws IOException, XmlPullParserException
     {
         MetaData mti = this.createMetaData();
         mti.setLocalePrefix( this.getOptionalAttribute( "localization" ) );
-        
+
         readOptionalAttributes(mti, METADATA_ATTRIBUTES);
 
         int eventType = this.parser.next();
@@ -258,7 +258,7 @@ public class MetaDataReader
         ocd.setId( this.getRequiredAttribute( "id" ) );
         ocd.setName( this.getRequiredAttribute( "name" ) );
         ocd.setDescription( this.getOptionalAttribute( "description" ) );
-        
+
         readOptionalAttributes(ocd, OCD_ATTRIBUTES);
 
         int eventType = this.parser.next();
@@ -310,13 +310,20 @@ public class MetaDataReader
 
     private Designate readDesignate() throws IOException, XmlPullParserException
     {
+        final String pid = this.getOptionalAttribute( "pid" );
+        final String factoryPid = this.getOptionalAttribute( "factoryPid" );
+        if ( pid == null && factoryPid == null )
+        {
+            missingAttribute( "pid or factoryPid" );
+        }
+
         Designate designate = this.createDesignate();
-        designate.setPid( this.getRequiredAttribute( "pid" ) );
-        designate.setFactoryPid( this.getOptionalAttribute( "factoryPid" ) );
+        designate.setPid( pid );
+        designate.setFactoryPid( factoryPid );
         designate.setBundleLocation( this.getOptionalAttribute( "bundle" ) );
         designate.setOptional( this.getOptionalAttribute( "optional", false ) );
         designate.setMerge( this.getOptionalAttribute( "merge", false ) );
-        
+
         readOptionalAttributes(designate, DESIGNATE_ATTRIBUTES);
 
         int eventType = this.parser.next();
@@ -363,7 +370,7 @@ public class MetaDataReader
         ad.setRequired( this.getOptionalAttribute( "required", true ) );
 
         readOptionalAttributes(ad, AD_ATTRIBUTES);
-        
+
         Map options = new LinkedHashMap();
         int eventType = this.parser.next();
         while ( eventType != XmlPullParser.END_DOCUMENT )
@@ -405,7 +412,7 @@ public class MetaDataReader
     {
         DesignateObject oh = this.createDesignateObject();
         oh.setOcdRef( this.getRequiredAttribute( "ocdref" ) );
-        
+
         readOptionalAttributes(oh, DESIGNATEOBJECT_ATTRIBUTES);
 
         int eventType = this.parser.next();

Modified: felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java?rev=1399617&r1=1399616&r2=1399617&view=diff
==============================================================================
--- felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
(original)
+++ felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
Thu Oct 18 12:31:58 2012
@@ -179,15 +179,17 @@ public class MetaTypeInformationImpl imp
                     continue;
                 }
 
-                // gather pids and factory pids
-                if (designate.getFactoryPid() != null) {
+                // gather pids and factory pids and register provider
+                if ( designate.getFactoryPid() != null )
+                {
                     this.factoryPids.add( designate.getFactoryPid() );
-                } else {
-                    this.pids.add(designate.getPid());
+                    this.addMetaTypeProvider( designate.getFactoryPid(), dmtp );
+                }
+                else
+                {
+                    this.pids.add( designate.getPid() );
+                    this.addMetaTypeProvider( designate.getPid(), dmtp );
                 }
-
-                // register a metatype provider for the pid
-                this.addMetaTypeProvider(designate.getPid(), dmtp);
             }
         }
     }



Mime
View raw message