geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r559921 - in /geronimo/sandbox/tuscany-integration: geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/ miscellaneous/
Date Thu, 26 Jul 2007 18:16:47 GMT
Author: vamsic007
Date: Thu Jul 26 11:16:46 2007
New Revision: 559921

URL: http://svn.apache.org/viewvc?view=rev&rev=559921
Log:
Eliminated the need for a geronimo specific deployment plan for deploying a tuscany jar

Modified:
    geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/EmbeddedRuntimeGBean.java
    geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/TuscanyBuilder.java
    geronimo/sandbox/tuscany-integration/miscellaneous/tuscany-plugin-1.0.car

Modified: geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/EmbeddedRuntimeGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/EmbeddedRuntimeGBean.java?view=diff&rev=559921&r1=559920&r2=559921
==============================================================================
--- geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/EmbeddedRuntimeGBean.java
(original)
+++ geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/EmbeddedRuntimeGBean.java
Thu Jul 26 11:16:46 2007
@@ -22,9 +22,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -52,38 +49,19 @@
     private SCADomain scaDomain;
     private ServerInfo serverInfo;
     private AbstractName abstractName;
-    private String domainURI;
     private String jarFileName;
-    private String jndiName;
-    private InitialContext ctx;
-//    private static final String jndiPath = "ger:/";
     
-    public EmbeddedRuntimeGBean(EmbeddedSCADomainGBean embeddedSCADomainRef, ClassLoader
classLoader, ServerInfo serverInfo, AbstractName abstractName, String domainURI, String jndiName){
+    public EmbeddedRuntimeGBean(EmbeddedSCADomainGBean embeddedSCADomainRef, ClassLoader
classLoader, ServerInfo serverInfo, AbstractName abstractName){
         this.embeddedSCADomainRef = embeddedSCADomainRef;
         this.classLoader = Thread.currentThread().getContextClassLoader();
-        this.jndiName = jndiName;        
         this.serverInfo = serverInfo;
         this.abstractName = abstractName;
-        this.domainURI = domainURI;        
-        try {
-            ctx = new InitialContext();
-        } catch (NamingException e) {
-            throw new IllegalStateException("JNDI Name service is not properly initialized");
-        }
-        
     }
     
     public EmbeddedRuntimeGBean(){
         this.classLoader = null;                
         this.serverInfo = null;
         this.abstractName = null;
-        this.domainURI = null;
-        this.jndiName = "";
-        try {
-            ctx = new InitialContext();
-        } catch (NamingException e) {
-            throw new IllegalStateException("JNDI Name service is not properly initialized");
-        }
     }
       
     public void doStart() throws Exception {
@@ -139,9 +117,8 @@
                 scaDomain = eScaDomain;
             } else {
                 String[] composites = SCADomainHelper.getDeployableComposites(classLoader,
serverInfo, abstractName, jarFileName);
-                scaDomain = SCADomain.newInstance(domainURI, contributionRoot, composites);
+                scaDomain = SCADomain.newInstance("localhost", contributionRoot, composites);
//FIXME:
             }
-            ctx.bind(jndiName, scaDomain);
         } catch (Throwable e) {
             throw new Exception(e);
         }
@@ -176,19 +153,12 @@
                     }
                 }
             }
-            ctx.unbind(jndiName);
         }        
     }
 
     public void doFail() {
         if (scaDomain != null) {
             scaDomain.close();
-            try {
-                ctx.unbind(jndiName);
-            } catch (NamingException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
         }
     }
 
@@ -197,16 +167,14 @@
             GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(EmbeddedRuntimeGBean.class,NameFactory.GERONIMO_SERVICE);
             infoFactory.addAttribute("classLoader", ClassLoader.class, false);
             infoFactory.addAttribute("abstractName", AbstractName.class, false);
-            infoFactory.addAttribute("domainURI", String.class, true, true);
             infoFactory.addAttribute("jarFileName", String.class, true, true);
             infoFactory.addReference("serverInfo", ServerInfo.class);
             infoFactory.addReference("embeddedSCADomainRef", EmbeddedSCADomainGBean.class);
             infoFactory.addAttribute("SCADomain", "org.apache.tuscany.sca.host.embedded.SCADomain",
false, true);
-            infoFactory.addAttribute("jndiName", String.class, false, true);
             infoFactory.addAttribute("useEmbeddedDomain", boolean.class, true, true);
             infoFactory.addAttribute("startOtherComponents", boolean.class, true, true);
             infoFactory.addInterface(SCADomainInterface.class);
-            infoFactory.setConstructor(new String[]{"embeddedSCADomainRef", "classLoader","serverInfo","abstractName","domainURI","jndiName"});
+            infoFactory.setConstructor(new String[]{"embeddedSCADomainRef", "classLoader","serverInfo","abstractName"});
             GBEAN_INFO = infoFactory.getBeanInfo();
         }
 

Modified: geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/TuscanyBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/TuscanyBuilder.java?view=diff&rev=559921&r1=559920&r2=559921
==============================================================================
--- geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/TuscanyBuilder.java
(original)
+++ geronimo/sandbox/tuscany-integration/geronimo-tuscany/modules/src/main/java/org/apache/geronimo/tuscany/TuscanyBuilder.java
Thu Jul 26 11:16:46 2007
@@ -60,16 +60,9 @@
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.Repository;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.geronimo.tuscany.xmlbeans.ScaDomainDocument;
-import org.apache.geronimo.tuscany.xmlbeans.ScaDomainType;
 
 public class TuscanyBuilder implements ConfigurationBuilder {
 
-    private static final QName COMPOSITES_QNAME = ScaDomainDocument.type.getDocumentElementName();
-
     private final Environment defaultEnvironment;
     private final Collection repositories;
     private final Naming naming;
@@ -104,117 +97,22 @@
         if (planFile == null && jarFile == null) {
             return null;
         }
-
-        try {
-            XmlObject xmlObject;
-            if (planFile != null) {
-                xmlObject = XmlBeansUtil.parse(planFile);
-            } else {
-            	String name = null;
-            	List<String> plans = new ArrayList();
-    		    for (Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) {
-                    JarEntry entry = e.nextElement();
-                    name = entry.getName();            
-    		        if (name.endsWith(".xml")) {					
-    			        plans.add(name);
-    		        }
-    		    }
-    		    //for the case where we use a deployment watcher for deploying tuscany composites
inside an EAR/WAR/JAR. 
-    		    //Can be removed if we are not going to support this.
-    		    if(plans.contains("WEB-INF/geronimo-web.xml") || plans.contains("META-INF/openejb-jar.xml")
|| plans.contains("META-INF/geronimo-application.xml")){
-    		    	return null;
-    		    }
-                URL path = DeploymentUtil.createJarURL(jarFile, "META-INF/geronimo-tuscany.xml");
-                try {
-                    xmlObject = XmlBeansUtil.parse(path,classLoader);
-                } catch (FileNotFoundException e) {
-                    // it's not a tuscany composite deployment
-                    return null;
-                }
-            }
-            if (xmlObject == null) {
-                return null;
-            }
-
-            XmlCursor cursor = xmlObject.newCursor();
-            try {
-                cursor.toFirstChild();
-                if (!COMPOSITES_QNAME.equals(cursor.getName())) {
-                    return null;
-                }
-            } finally {
-                cursor.dispose();
-            }
-            ScaDomainDocument moduleDoc;
-            if (xmlObject instanceof ScaDomainDocument) {
-                moduleDoc = (ScaDomainDocument) xmlObject;
-            } else {
-                moduleDoc = (ScaDomainDocument) xmlObject.changeType(ScaDomainDocument.type);
-            }
-            Collection errors = new ArrayList();
-            if (!moduleDoc.validate(XmlBeansUtil.createXmlOptions(errors))) {
-                throw new DeploymentException("Invalid deployment descriptor: " + errors
+ "\nDescriptor: " + moduleDoc.toString());
-            }            
-            if (jarFile == null && (moduleDoc.getScaDomain().getEnvironment() ==
null ||
-                    moduleDoc.getScaDomain().getEnvironment().getModuleId() == null ||
-                    moduleDoc.getScaDomain().getEnvironment().getModuleId().getArtifactId()
== null)) {
-                if (moduleDoc.getScaDomain().getEnvironment() == null) {
-                    moduleDoc.getScaDomain().addNewEnvironment();
-                }
-                if (moduleDoc.getScaDomain().getEnvironment().getModuleId() == null) {
-                    moduleDoc.getScaDomain().getEnvironment().addNewModuleId();
-                }
-                String name = planFile.getName();
-                int pos = name.lastIndexOf('.');
-                if (pos > -1) {
-                    name = name.substring(0, pos);
-                }
-                moduleDoc.getScaDomain().getEnvironment().getModuleId().setArtifactId(name);
+        
+        // We do not use a geronimo specific plan file any more to identify tuscany artifacts.
+        // Look for any .scdl and .composite files in the jar
+        List<String> probables = new ArrayList<String>();
+        for(Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements(); ){
+            JarEntry entry = e.nextElement();
+            String name = entry.getName();
+            if(name.endsWith(".composite") || name.endsWith(".scdl")){
+                probables.add(name);
             }
-            return moduleDoc.getScaDomain();
-        } catch (XmlException e) {
-            throw new DeploymentException("Could not parse xml in plan", e);
-        } catch (IOException e) {
-            throw new DeploymentException("no plan at " + planFile, e);
         }
-    }
-    
-    public ScaDomainDocument processPlanURL(URL url) throws DeploymentException, IOException
{
-        try {
-            XmlObject xmlObject;
-            try {
-                xmlObject = XmlBeansUtil.parse(url,classLoader);
-            } catch (FileNotFoundException e) {               
-                return null;
-            }
-            if (xmlObject == null) {
-                return null;
-            }
-
-            XmlCursor cursor = xmlObject.newCursor();
-            try {
-                cursor.toFirstChild();
-                if (!COMPOSITES_QNAME.equals(cursor.getName())) {
-                    return null;
-                }
-            } finally {
-                cursor.dispose();
-            }
-            ScaDomainDocument moduleDoc;
-            if (xmlObject instanceof ScaDomainDocument) {
-                moduleDoc = (ScaDomainDocument) xmlObject;
-            } else {
-                moduleDoc = (ScaDomainDocument) xmlObject.changeType(ScaDomainDocument.type);
-            }
-            Collection errors = new ArrayList();
-            if (!moduleDoc.validate(XmlBeansUtil.createXmlOptions(errors))) {
-                throw new DeploymentException("Invalid deployment descriptor: " + errors
+ "\nDescriptor: " + moduleDoc.toString());
-            }
-            return moduleDoc;
-        } catch (XmlException e) {
-            throw new DeploymentException("Could not parse xml in plan", e);
+        if(!probables.isEmpty()) {
+            return probables; // Return anything non null
+        } else {
+            return null;
         }
-
     }
 
     public Environment processEnvironment(EnvironmentType environmentType) {
@@ -222,10 +120,12 @@
     }    
 
     public Artifact getConfigurationID(Object plan, JarFile module, ModuleIDBuilder idBuilder)
throws IOException, DeploymentException {
-        ScaDomainType configType = (ScaDomainType) plan;
-        EnvironmentType environmentType = configType.getEnvironment();
-        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
-        idBuilder.resolve(environment, module == null ? "" : new File(module.getName()).getName(),
"car");
+        /* We do not use a plan file any more */
+        String artifactId = new File(module.getName()).getName();
+        artifactId = artifactId.substring(0, artifactId.indexOf('.'));
+        Artifact configId = new Artifact("TuscanyArtifacts", artifactId, (String)null, "car");
+        Environment environment = new Environment(configId);
+        idBuilder.resolve(environment, artifactId, "car");
         if(!environment.getConfigId().isResolved()) {
             throw new IllegalStateException("Module ID is not fully populated ("+environment.getConfigId()+")");
         }
@@ -234,22 +134,16 @@
 
     public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId,
Object plan, JarFile jar, 
         Collection configurationStores, ArtifactResolver artifactResolver, ConfigurationStore
targetConfigurationStore) throws IOException, DeploymentException {
-        
-    	ScaDomainType configType = (ScaDomainType) plan;
 
-        return buildConfiguration(inPlaceDeployment, configId, configType, jar, configurationStores,
artifactResolver, targetConfigurationStore);
+        return buildConfiguration(inPlaceDeployment, configId, jar, configurationStores,
artifactResolver, targetConfigurationStore);
     }
 
-    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId,
ScaDomainType moduleType, JarFile jar, Collection configurationStores, 
+    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId,
JarFile jar, Collection configurationStores, 
         ArtifactResolver artifactResolver, ConfigurationStore targetConfigurationStore) throws
DeploymentException, IOException {
         
-	    ArtifactType type = moduleType.getEnvironment().isSetModuleId() ? moduleType.getEnvironment().getModuleId()
: moduleType.getEnvironment().addNewModuleId();
-        type.setArtifactId(configId.getArtifactId());
-        type.setGroupId(configId.getGroupId());
-        type.setType(configId.getType());
-        type.setVersion(configId.getVersion().toString());
-        Environment environment = EnvironmentBuilder.buildEnvironment(moduleType.getEnvironment(),
defaultEnvironment);
-        if(!environment.getConfigId().isResolved()) {
+        Environment environment = new Environment(configId);
+        EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+        if(!configId.isResolved()) {
             throw new IllegalStateException("Module ID should be fully resolved by now (not
"+environment.getConfigId()+")");
         }
         File outfile;
@@ -281,7 +175,7 @@
         }
         try {
             ClassLoader cl = context.getConfiguration().getConfigurationClassLoader();  
         
-            addComposite(moduleType.getDomainURI(), moduleType.getJndiName(), cl, moduleName,
context, jarFileName);
+            addComposite(cl, moduleName, context, jarFileName);
             return context;
         } catch (RuntimeException t) {
             context.close();
@@ -292,8 +186,8 @@
         }
     }
 
-    public void addComposite(String domainURI, String name, ClassLoader cl, AbstractName
moduleName, DeploymentContext context, String jarFileName) throws DeploymentException {
-    	GBeanData data = processComposite(domainURI, name, cl, moduleName.getArtifact(),  jarFileName);
+    public void addComposite(ClassLoader cl, AbstractName moduleName, DeploymentContext context,
String jarFileName) throws DeploymentException {
+        GBeanData data = processComposite(cl, moduleName.getArtifact(),  jarFileName);
         try {
             context.addGBean(data);
         } catch (GBeanAlreadyExistsException e) {
@@ -303,18 +197,16 @@
 
    
 
-    public GBeanData processComposite(String domainURI, String jndiName, ClassLoader cl,
Artifact parentModule, String jarFileName) {
+    public GBeanData processComposite(ClassLoader cl, Artifact parentModule, String jarFileName)
{
         GBeanInfo gBeanInfo = GBeanInfo.getGBeanInfo(EmbeddedRuntimeGBean.class.getName(),
cl);
         AbstractName moduleName = naming.createRootName(parentModule, parentModule.toString(),
"ServiceModule");
-        AbstractName abstractName = naming.createChildName(moduleName, domainURI, "GBean");
+        AbstractName abstractName = naming.createChildName(moduleName, "EmbeddedRuntime",
"GBean");
         GBeanData data = new GBeanData(abstractName, gBeanInfo);        
         data.setReferencePattern("embeddedSCADomainRef", embeddedSCADomainQuery);
         data.setReferencePattern("serverInfo", serverInfoQuery);
         data.setAttribute("useEmbeddedDomain", useEmbeddedDomain);
         data.setAttribute("startOtherComponents", startOtherComponents);
-        data.setAttribute("domainURI", domainURI);
         data.setAttribute("jarFileName",jarFileName);
-        data.setAttribute("jndiName",jndiName);
         return data;
     }    
 
@@ -348,4 +240,4 @@
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
     }
-}
\ No newline at end of file
+}

Modified: geronimo/sandbox/tuscany-integration/miscellaneous/tuscany-plugin-1.0.car
URL: http://svn.apache.org/viewvc/geronimo/sandbox/tuscany-integration/miscellaneous/tuscany-plugin-1.0.car?view=diff&rev=559921&r1=559920&r2=559921
==============================================================================
Binary files - no diff available.



Mime
View raw message