aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1152296 - /aries/trunk/application/application-modeller-standalone/src/main/java/org/apache/aries/application/modelling/standalone/OfflineModellingFactory.java
Date Fri, 29 Jul 2011 16:31:24 GMT
Author: timothyjward
Date: Fri Jul 29 16:31:23 2011
New Revision: 1152296

URL: http://svn.apache.org/viewvc?rev=1152296&view=rev
Log:
ARIES-716 : Allow extensions to the modelling code

Modified:
    aries/trunk/application/application-modeller-standalone/src/main/java/org/apache/aries/application/modelling/standalone/OfflineModellingFactory.java

Modified: aries/trunk/application/application-modeller-standalone/src/main/java/org/apache/aries/application/modelling/standalone/OfflineModellingFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-modeller-standalone/src/main/java/org/apache/aries/application/modelling/standalone/OfflineModellingFactory.java?rev=1152296&r1=1152295&r2=1152296&view=diff
==============================================================================
--- aries/trunk/application/application-modeller-standalone/src/main/java/org/apache/aries/application/modelling/standalone/OfflineModellingFactory.java
(original)
+++ aries/trunk/application/application-modeller-standalone/src/main/java/org/apache/aries/application/modelling/standalone/OfflineModellingFactory.java
Fri Jul 29 16:31:23 2011
@@ -1,10 +1,14 @@
 package org.apache.aries.application.modelling.standalone;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.Set;
 
@@ -12,6 +16,7 @@ import javax.xml.validation.Schema;
 
 import org.apache.aries.application.modelling.ModelledResourceManager;
 import org.apache.aries.application.modelling.ParserProxy;
+import org.apache.aries.application.modelling.ServiceModeller;
 import org.apache.aries.application.modelling.impl.AbstractParserProxy;
 import org.apache.aries.application.modelling.impl.ModelledResourceManagerImpl;
 import org.apache.aries.application.modelling.impl.ModellingManagerImpl;
@@ -108,6 +113,27 @@ public class OfflineModellingFactory {
 		result.setModellingManager(modellingManager);
 		result.setParserProxy(parserProxy);
 		
+		List<ServiceModeller> plugins = new ArrayList<ServiceModeller>();
+		
+    ClassLoader cl = OfflineModellingFactory.class.getClassLoader();
+		try {
+      Enumeration<URL> e = cl.getResources(
+          "META-INF/services/" + ServiceModeller.class.getName());
+      
+      while(e.hasMoreElements()) {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                e.nextElement().openStream()));
+        try {
+          plugins.add((ServiceModeller) Class.forName(reader.readLine(), true, cl).newInstance());
+        } catch (Exception e1) {
+          e1.printStackTrace(System.err);
+        }
+      }
+    } catch (IOException e) {
+      e.printStackTrace(System.err);
+    }
+
+    result.setModellingPlugins(plugins);
 		return result;
 	}
 }



Mime
View raw message