Author: kentam
Date: Thu Jan 20 16:26:09 2005
New Revision: 125862

URL: http://svn.apache.org/viewcvs?view=rev&rev=125862
Log:
Updates to assembly to solve JIRA issues 182 and 183 - an implementation of an 
Enterprise app
assembly context, the ability to add the module name (or earName in case of an 
app) to the
context and updating assembly to pass the list of clients to the assembler.

Patch submitted by Lawrence Jones

Tests: passed on Windows (controls DRT)



Added:
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AppAssemblyContext.java
Modified:
   
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java

Modified: 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java?view=diff&rev=125862&p1=incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java&r1=125861&p2=incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java&r2=125862
==============================================================================
--- 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java
       (original)
+++ 
incubator/beehive/trunk/controls/src/api/org/apache/beehive/controls/api/assembly/ControlAssemblyContext.java
       Thu Jan 20 16:26:09 2005
@@ -6,9 +6,9 @@
  * Licensed 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.
@@ -22,6 +22,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Control assemblers are passed a ControlAssemblyContext at the time they are
@@ -42,7 +43,7 @@
     /**
      * Providers of ControlAssemblyContext implementations MUST implement
      * Factory and newInstance to return their implementation.
-     */ 
+     */
     interface Factory
     {
         /**
@@ -52,8 +53,11 @@
          *                         type being assembled
          * @param bindings map of control implementation bindings, null
          *                 means use defaults.
+         * @param clients set of clients that use this control type.
          * @param moduleRoot file root of the J2EE module containing the
          *                   control clients to be assembled
+         * @param moduleName name of the J2EE module containing the
+         *                   control clients to be assembled
          * @param srcOutputRoot file root of a location where assemblers
          *                      should output any sources they create that
          *                      may need further processing before use.
@@ -61,7 +65,9 @@
          */
         ControlAssemblyContext newInstance( Class controlIntfOrExt,
                                             Map<String,String> bindings,
+                                            Set<String> clients,
                                             File moduleRoot,
+                                            String moduleName,
                                             File srcOutputRoot )
             throws ControlAssemblyException;
     }
@@ -142,4 +148,14 @@
      * @return the root of the module for which assembly is taking place.
      */
     File getModuleDir();
+
+    /**
+     * @return the name of the module for which assembly is taking place.
+     */
+    String getModuleName();
+
+    /**
+     * @return the set of clients (by class name) which use the control type
+     */
+    Set<String> getClients();
 }

Added: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AppAssemblyContext.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AppAssemblyContext.java?view=auto&rev=125862
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AppAssemblyContext.java
   Thu Jan 20 16:26:09 2005
@@ -0,0 +1,61 @@
+package org.apache.beehive.controls.runtime.assembly;
+
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+
+import org.apache.beehive.controls.api.assembly.ControlAssemblyContext;
+import org.apache.beehive.controls.api.assembly.ControlAssemblyException;
+
+import java.io.File;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A ControlAssemblyContext implementation supporting standard Enterprise app 
modules
+ */
+public class AppAssemblyContext extends BaseAssemblyContext
+                                implements ControlAssemblyContext.EntAppModule
+{
+    public static class Factory implements ControlAssemblyContext.Factory
+    {
+        public AppAssemblyContext newInstance( Class controlIntfOrExt,
+                                               Map<String,String> bindings,
+                                               Set<String> clients,
+                                               File moduleRoot,
+                                               String moduleName,
+                                               File srcOutputRoot )
+            throws ControlAssemblyException
+        {
+            return new AppAssemblyContext( controlIntfOrExt, bindings, clients,
+                moduleRoot, moduleName, srcOutputRoot );
+        }
+    }
+
+    protected AppAssemblyContext( Class controlIntfOrExt, Map<String,String> 
bindings,
+                                  Set<String> clients, File moduleRoot,
+                                  String moduleName, File srcOutputRoot )
+        throws ControlAssemblyException
+    {
+        super( controlIntfOrExt, bindings, clients, moduleRoot, moduleName, 
srcOutputRoot );
+    }
+
+    public File getApplicationXml()
+    {
+        return new File( getModuleDir(), "META-INF" + File.separator + 
"application.xml" );
+    }
+}

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java?view=diff&rev=125862&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java&r1=125861&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java&r2=125862
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java
 (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/AssembleTask.java
 Thu Jan 20 16:26:09 2005
@@ -24,6 +24,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
+import java.util.TreeSet;
 import java.net.URL;
 import java.net.URLClassLoader;
 
@@ -54,6 +56,11 @@
         _moduleDir = moduleDir;
     }
 
+    public void setModuleName( String moduleName )
+    {
+        _moduleName = moduleName;
+    }
+
     public void setSrcOutputDir( File srcOutputDir )
     {
         _srcOutputDir = srcOutputDir;
@@ -129,13 +136,25 @@
             // Build map of control types to assemble by scanning supplied 
manifests
 
             Map<String,String> controlTypesToImpls = new 
HashMap<String,String>();
+            Map<String,Set<String>> controlTypesToClients =
+                new HashMap<String, Set<String>>();
 
             for ( File mf : manifestFiles )
             {
                 ControlClientManifest ccmf = new ControlClientManifest( mf );
+                String controlClient = ccmf.getControlClient();
                 List<String> controlTypes = ccmf.getControlTypes();
                 for ( String ct : controlTypes )
+                {
                     controlTypesToImpls.put( ct, ccmf.getDefaultImpl( ct ) );
+                    Set<String> clients = controlTypesToClients.get( ct );
+                    if (clients == null)
+                    {
+                        clients = new TreeSet<String>();
+                        controlTypesToClients.put( ct, clients );
+                    }
+                    clients.add( controlClient );
+                }
             }
 
             // Build classloader to do loading
@@ -146,7 +165,8 @@
             String[] classpaths = _classPath == null ? new String[0] : 
_classPath.list();
             ClassLoader cl = buildClassLoader( classpaths, 
Assembler.class.getClassLoader() );
 
-            Assembler.assemble( _moduleDir, _srcOutputDir, 
_contextFactoryClassName, controlTypesToImpls, cl );
+            Assembler.assemble( _moduleDir, _moduleName, _srcOutputDir, 
_contextFactoryClassName,
+                controlTypesToImpls, controlTypesToClients, cl );
         }
         catch (Exception e)
         {
@@ -203,6 +223,7 @@
     // ant parameter values
     protected String  _contextFactoryClassName;
     protected File    _moduleDir;
+    protected String  _moduleName;
     protected File    _srcOutputDir;
     protected File    _bindingFile;
     protected Path    _classPath;

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java?view=diff&rev=125862&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java&r1=125861&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java&r2=125862
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java
    (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/Assembler.java
    Thu Jan 20 16:26:09 2005
@@ -37,17 +37,21 @@
      * create an instance of the assembler and execute it.
      *
      * @param moduleRoot dir root of the module
+     * @param moduleName name of the module
      * @param srcOutputRoot dir where assemblers can output source files
      * @param factoryName name of the ControlAssemblyContext factory to use
      * @param controlTypeToImpl map of control type name to control impl for 
all control types to be assembled in this module
+     * @param controlTypeToClients map of control type name to a set of 
control clients (in this module) that use this type
      * @param cl classloader used to load factories and assemblers
      * @throws ControlAssemblyException
      * @throws IOException
      */
     public static void assemble( File moduleRoot,
+                                 String moduleName,
                                  File srcOutputRoot,
                                  String factoryName,
                                  Map<String,String> controlTypeToImpl,
+                                 Map<String,Set<String>> controlTypeToClients,
                                  ClassLoader cl )
         throws ControlAssemblyException, IOException
     {
@@ -86,7 +90,9 @@
                 if ( !assemblerClass.equals(DefaultControlAssembler.class) )
                 {
                     ControlAssembler assembler = assemblerClass.newInstance();
-                    ControlAssemblyContext cac = factory.newInstance( 
cl.loadClass(ct), null, moduleRoot, srcOutputRoot );
+                    Set<String> clients = controlTypeToClients.get( ct );
+                    ControlAssemblyContext cac = factory.newInstance(
+                        cl.loadClass(ct), null, clients, moduleRoot, 
moduleName, srcOutputRoot );
                     assembler.assemble( cac );
                 }
             }

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java?view=diff&rev=125862&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java&r1=125861&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java&r2=125862
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java
  (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/BaseAssemblyContext.java
  Thu Jan 20 16:26:09 2005
@@ -34,12 +34,15 @@
 public abstract class BaseAssemblyContext implements ControlAssemblyContext
 {
     protected BaseAssemblyContext( Class controlIntfOrExt, Map<String,String> 
bindings,
-                                   File moduleRoot, File srcOutputRoot )
+                                   Set<String> clients, File moduleRoot,
+                                   String moduleName, File srcOutputRoot )
         throws ControlAssemblyException
     {
         _controlIntfOrExt = controlIntfOrExt;
         _bindings = bindings;
+        _clients = clients;
         _moduleRoot = moduleRoot;
+        _moduleName = moduleName;
         _srcOutputRoot = srcOutputRoot;
 
         // Compute and cache "most derived ControlInterface"
@@ -126,10 +129,22 @@
         return _moduleRoot;
     }
 
+    public String getModuleName()
+    {
+        return _moduleName;
+    }
+
+    public Set<String> getClients()
+    {
+        return _clients;
+    }
+
     private File _moduleRoot;
+    private String _moduleName;
     private File _srcOutputRoot;
     private Class _controlIntfOrExt;
     private Map<String,String> _bindings;
+    private Set<String> _clients;
 
     private Class _controlMostDerivedIntf;
 }

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java?view=diff&rev=125862&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java&r1=125861&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java&r2=125862
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java
   (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/assembly/EJBAssemblyContext.java
   Thu Jan 20 16:26:09 2005
@@ -23,6 +23,7 @@
 
 import java.io.File;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * A ControlAssemblyContext implementation supporting standard EJB modules
@@ -34,19 +35,23 @@
     {
         public EJBAssemblyContext newInstance( Class controlIntfOrExt,
                                                Map<String,String> bindings,
+                                               Set<String> clients,
                                                File moduleRoot,
+                                               String moduleName,
                                                File srcOutputRoot )
             throws ControlAssemblyException
         {
-            return new EJBAssemblyContext( controlIntfOrExt, bindings, 
moduleRoot, srcOutputRoot );
+            return new EJBAssemblyContext( controlIntfOrExt, bindings, clients,
+                moduleRoot, moduleName, srcOutputRoot );
         }
     }
 
     protected EJBAssemblyContext( Class controlIntfOrExt, Map<String,String> 
bindings,
-                                  File moduleRoot, File srcOutputRoot )
+                                  Set<String> clients, File moduleRoot,
+                                  String moduleName, File srcOutputRoot )
         throws ControlAssemblyException
     {
-        super( controlIntfOrExt, bindings, moduleRoot, srcOutputRoot );
+        super( controlIntfOrExt, bindings, clients, moduleRoot, moduleName, 
srcOutputRoot );
     }
 
     public File getEjbJarXml()

Reply via email to