aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1152159 - in /aries/trunk/application: application-api/src/main/java/org/apache/aries/application/modelling/ application-modeller/src/main/java/org/apache/aries/application/modelling/impl/ application-modeller/src/main/resources/OSGI-INF/b...
Date Fri, 29 Jul 2011 10:32:25 GMT
Author: timothyjward
Date: Fri Jul 29 10:32:24 2011
New Revision: 1152159

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

Added:
    aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/ServiceModeller.java
Modified:
    aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java
    aries/trunk/application/application-modeller/src/main/resources/OSGI-INF/blueprint/app-modeller.xml

Added: aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/ServiceModeller.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/ServiceModeller.java?rev=1152159&view=auto
==============================================================================
--- aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/ServiceModeller.java
(added)
+++ aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/ServiceModeller.java
Fri Jul 29 10:32:24 2011
@@ -0,0 +1,35 @@
+/*
+ * 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 WARRANTIESOR 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.aries.application.modelling;
+
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.manifest.BundleManifest;
+
+public interface ServiceModeller {
+
+  /**
+   * Determine whether any additional services will be imported or exported 
+   * by this bundle. For example as EJBs, Declarative Services etc
+   *
+   * @param bundle
+   * @return
+   */
+  public ParsedServiceElements modelServices(BundleManifest manifest, IDirectory bundle);
+  
+}

Modified: aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java?rev=1152159&r1=1152158&r2=1152159&view=diff
==============================================================================
--- aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java
(original)
+++ aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java
Fri Jul 29 10:32:24 2011
@@ -45,8 +45,11 @@ import org.apache.aries.application.mode
 import org.apache.aries.application.modelling.ModellingManager;
 import org.apache.aries.application.modelling.ParsedServiceElements;
 import org.apache.aries.application.modelling.ParserProxy;
+import org.apache.aries.application.modelling.ServiceModeller;
 import org.apache.aries.application.modelling.internal.BundleBlueprintParser;
 import org.apache.aries.application.modelling.internal.MessageUtil;
+import org.apache.aries.util.filesystem.FileSystem;
+import org.apache.aries.util.filesystem.ICloseableDirectory;
 import org.apache.aries.util.filesystem.IDirectory;
 import org.apache.aries.util.filesystem.IFile;
 import org.apache.aries.util.io.IOUtils;
@@ -60,6 +63,11 @@ public class ModelledResourceManagerImpl
   private final Logger _logger = LoggerFactory.getLogger(ModelledResourceManagerImpl.class);
   private ParserProxy _parserProxy;
   private ModellingManager _modellingManager;
+  private Collection<ServiceModeller> modellingPlugins;
+
+  public void setModellingPlugins(Collection<ServiceModeller> modellingPlugins) {
+    this.modellingPlugins = modellingPlugins;
+  }
 
   public void setModellingManager (ModellingManager m) { 
     _modellingManager = m;
@@ -73,8 +81,6 @@ public class ModelledResourceManagerImpl
     return _parserProxy;
   }
 
-
-
   /**
    * For a given file, which we know to be a bundle, parse out all the
    * service, reference and reference-list elements. This method will return
@@ -92,23 +98,40 @@ public class ModelledResourceManagerImpl
   
   @Override
   public ParsedServiceElements getServiceElements(InputStreamProvider archive) throws ModellerException
{
+      ICloseableDirectory dir = null;
       try {
-          BundleManifest bm = BundleManifest.fromBundle(archive.open());
-          return getServiceElements(bm, findBlueprints(bm, archive.open()));
+          dir = FileSystem.getFSRoot(archive.open());
+          BundleManifest bm = BundleManifest.fromBundle(dir);
+          return getServiceElements(bm, dir);
       } catch (IOException e) {
           throw new ModellerException(e);
+      } finally {
+          IOUtils.close(dir);
       }
   }
   
   private ParsedServiceElements getServiceElements (BundleManifest bundleMf, IDirectory archive)
throws ModellerException { 
+      
+      Set<ExportedService> services = new HashSet<ExportedService>();
+      Set<ImportedService> references = new HashSet<ImportedService>();
+    
       try {
-        return getServiceElements(bundleMf, findBlueprints(bundleMf, archive));
-    } catch (IOException e) {
-        throw new ModellerException(e);
-    }
+          ParsedServiceElements pse = getBlueprintServiceElements(bundleMf, 
+                      findBlueprints(bundleMf, archive));
+          services.addAll(pse.getServices());
+          references.addAll(pse.getReferences());
+          for (ServiceModeller sm : modellingPlugins) {
+            pse = sm.modelServices(bundleMf, archive);
+            services.addAll(pse.getServices());
+            references.addAll(pse.getReferences());
+          }
+          return new ParsedServiceElementsImpl(services, references);
+      } catch (Exception e) {
+          throw new ModellerException(e);
+      }
   }
   
-  private ParsedServiceElements getServiceElements (BundleManifest bundleMf, Iterable<InputStream>
blueprints) throws ModellerException { 
+  private ParsedServiceElements getBlueprintServiceElements (BundleManifest bundleMf, Iterable<InputStream>
blueprints) throws ModellerException { 
     _logger.debug(LOG_ENTRY,"getServiceElements", new Object[] {bundleMf, blueprints} );
 
     Set<ExportedService> services = new HashSet<ExportedService>();
@@ -119,11 +142,8 @@ public class ModelledResourceManagerImpl
           ParsedServiceElements pse = getParserProxy().parseAllServiceElements(is);
           services.addAll(pse.getServices());
           references.addAll(pse.getReferences());
-
         } finally {
-          if (is != null) {
-            is.close();
-          }
+          IOUtils.close(is);
         }
       }
     } catch (Exception e) {
@@ -149,12 +169,14 @@ public class ModelledResourceManagerImpl
 
   @Override
   public ModelledResource getModelledResource(String uri, InputStreamProvider bundle) throws
ModellerException {
+      ICloseableDirectory dir = null;
       try {
-          BundleManifest bm = BundleManifest.fromBundle(bundle.open());
-          ParsedServiceElements pse = getServiceElements(bm, findBlueprints(bm, bundle.open()));
-          return model(uri, bm, pse);
+          dir = FileSystem.getFSRoot(bundle.open());
+          return getModelledResource(uri, dir);
       } catch (IOException e) {
           throw new ModellerException(e);
+      } finally {
+          IOUtils.close(dir);
       }
   }
   

Modified: aries/trunk/application/application-modeller/src/main/resources/OSGI-INF/blueprint/app-modeller.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-modeller/src/main/resources/OSGI-INF/blueprint/app-modeller.xml?rev=1152159&r1=1152158&r2=1152159&view=diff
==============================================================================
--- aries/trunk/application/application-modeller/src/main/resources/OSGI-INF/blueprint/app-modeller.xml
(original)
+++ aries/trunk/application/application-modeller/src/main/resources/OSGI-INF/blueprint/app-modeller.xml
Fri Jul 29 10:32:24 2011
@@ -21,6 +21,7 @@
   <bean id="modelledResourceManager" class="org.apache.aries.application.modelling.impl.ModelledResourceManagerImpl">
     <property name="modellingManager" ref="modellingManager"/>
     <property name="parserProxy" ref="parserProxy"/>
+    <property name="modellingPlugins" ref="modellingPlugins"/>
   </bean>
   <service id = "modelledResourceManagerService" ref="modelledResourceManager" interface="org.apache.aries.application.modelling.ModelledResourceManager"/>
 
@@ -38,4 +39,5 @@
   <bean id="modellingHelper" class="org.apache.aries.application.modelling.utils.impl.ModellingHelperImpl"/>
   <service id="modellingHelperService" ref="modellingHelper" interface="org.apache.aries.application.modelling.utils.ModellingHelper"/>
   
+  <reference-list id="modellingPlugins" interface="org.apache.aries.application.modelling.ServiceModeller"
availability="optional"/>
 </blueprint>
\ No newline at end of file



Mime
View raw message