geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r240209 - in /geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core: internal/ operations/
Date Fri, 26 Aug 2005 11:37:55 GMT
Author: geirm
Date: Fri Aug 26 04:37:49 2005
New Revision: 240209

URL: http://svn.apache.org/viewcvs?rev=240209&view=rev
Log:
GERONIMIO-919


Modified:
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/DeploymentPlanCreationOperation.java
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/ExportDeploymentPlanOperation.java
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/IExportDeploymentPlanDataModelProperties.java

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/DeploymentPlanCreationOperation.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/DeploymentPlanCreationOperation.java?rev=240209&r1=240208&r2=240209&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/DeploymentPlanCreationOperation.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/DeploymentPlanCreationOperation.java
Fri Aug 26 04:37:49 2005
@@ -19,20 +19,15 @@
 import java.util.Collections;
 
 import org.apache.geronimo.xml.ns.j2ee.application.ApplicationFactory;
-import org.apache.geronimo.xml.ns.j2ee.application.ApplicationPackage;
 import org.apache.geronimo.xml.ns.j2ee.application.ApplicationType;
-import org.apache.geronimo.xml.ns.j2ee.application.util.ApplicationResourceFactoryImpl;
 import org.apache.geronimo.xml.ns.web.DocumentRoot;
 import org.apache.geronimo.xml.ns.web.WebAppType;
 import org.apache.geronimo.xml.ns.web.WebFactory;
-import org.apache.geronimo.xml.ns.web.WebPackage;
-import org.apache.geronimo.xml.ns.web.util.WebResourceFactoryImpl;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -45,25 +40,15 @@
 import org.eclipse.wst.common.componentcore.ComponentCore;
 import org.eclipse.wst.common.componentcore.datamodel.properties.IComponentCreationDataModelProperties;
 import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
-import org.eclipse.wst.common.componentcore.resources.IFlexibleProject;
 import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
 import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
 import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
 import org.eclipse.wst.common.frameworks.datamodel.properties.IFlexibleProjectCreationDataModelProperties;
-import org.eclipse.wst.server.core.IModule;
 import org.openejb.xml.ns.openejb.jar.JarFactory;
-import org.openejb.xml.ns.openejb.jar.JarPackage;
 import org.openejb.xml.ns.openejb.jar.OpenejbJarType;
-import org.openejb.xml.ns.openejb.jar.util.JarResourceFactoryImpl;
 
 public class DeploymentPlanCreationOperation extends AbstractDataModelOperation {
 
-    public static final String WEB_DEP_PLAN_NAME = "geronimo-web.xml";
-
-    public static final String EJB_DEP_PLAN_NAME = "openejb-jar.xml";
-
-    public static final String APP_DEP_PLAN_NAME = "geronimo-application.xml";
-
     public DeploymentPlanCreationOperation() {
     }
 
@@ -81,13 +66,16 @@
 
             if (comp.getComponentTypeId().equals(
                     IModuleConstants.JST_WEB_MODULE)) {
-                createGeronimoWebDeploymentPlan(comp);
+                createGeronimoWebDeploymentPlan(GeronimoUtils
+                        .getWebDeploymentPlanFile(comp));
             } else if (comp.getComponentTypeId().equals(
                     IModuleConstants.JST_EJB_MODULE)) {
-                createOpenEjbDeploymentPlan(comp);
+                createOpenEjbDeploymentPlan(GeronimoUtils
+                        .getOpenEjbDeploymentPlanFile(comp));
             } else if (comp.getComponentTypeId().equals(
                     IModuleConstants.JST_EAR_MODULE)) {
-                createGeronimoApplicationDeploymentPlan(comp);
+                createGeronimoApplicationDeploymentPlan(GeronimoUtils
+                        .getApplicationDeploymentPlanFile(comp));
             }
         }
 
@@ -95,40 +83,12 @@
 
     }
 
-    public ApplicationType createGeronimoApplicationDeploymentPlan(
-            IVirtualComponent comp) {
-        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
-                .getProjectRelativePath().append("META-INF").append(
-                        APP_DEP_PLAN_NAME);
-
-        IFile planFile = getProject().getFile(deployPlanPath);
-        return createGeronimoApplicationDeploymentPlan(planFile);
-    }
-
-    public WebAppType createGeronimoWebDeploymentPlan(IVirtualComponent comp) {
-        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
-                .getProjectRelativePath().append("WEB-INF").append(
-                        WEB_DEP_PLAN_NAME);
-
-        IFile planFile = getProject().getFile(deployPlanPath);
-        return createGeronimoWebDeploymentPlan(planFile);
-    }
-
-    public OpenejbJarType createOpenEjbDeploymentPlan(IVirtualComponent comp) {
-        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
-                .getProjectRelativePath().append("META-INF").append(
-                        EJB_DEP_PLAN_NAME);
-
-        IFile planFile = getProject().getFile(deployPlanPath);
-        return createOpenEjbDeploymentPlan(planFile);
-    }
-
     public ApplicationType createGeronimoApplicationDeploymentPlan(IFile dpFile) {
         URI uri = URI
                 .createPlatformResourceURI(dpFile.getFullPath().toString());
 
         ResourceSet resourceSet = new ResourceSetImpl();
-        // registerForWeb(resourceSet);
+        GeronimoUtils.registerAppFactoryAndPackage(resourceSet);
 
         Resource resource = resourceSet.createResource(uri);
         org.apache.geronimo.xml.ns.j2ee.application.DocumentRoot documentRoot = ApplicationFactory.eINSTANCE
@@ -153,7 +113,7 @@
                 .createPlatformResourceURI(dpFile.getFullPath().toString());
 
         ResourceSet resourceSet = new ResourceSetImpl();
-        registerForWeb(resourceSet);
+        GeronimoUtils.registerWebFactoryAndPackage(resourceSet);
 
         Resource resource = resourceSet.createResource(uri);
         DocumentRoot documentRoot = WebFactory.eINSTANCE.createDocumentRoot();
@@ -176,61 +136,21 @@
                 .createPlatformResourceURI(dpFile.getFullPath().toString());
 
         ResourceSet resourceSet = new ResourceSetImpl();
-        registerForWeb(resourceSet);
+        GeronimoUtils.registerEjbFactoryAndPackage(resourceSet);
 
         Resource resource = resourceSet.createResource(uri);
-        org.openejb.xml.ns.openejb.jar.DocumentRoot documentRoot = JarFactory.eINSTANCE.createDocumentRoot();
+        org.openejb.xml.ns.openejb.jar.DocumentRoot documentRoot = JarFactory.eINSTANCE
+                .createDocumentRoot();
         OpenejbJarType root = JarFactory.eINSTANCE.createOpenejbJarType();
-        
+
         root.setConfigId(getProject().getName() + "/" + getComponentName());
-       
+
         documentRoot.setOpenejbJar(root);
         resource.getContents().add(documentRoot);
 
         doSave(resource);
 
         return root;
-    }
-
-    public static void registerForWeb(ResourceSet resourceSet) {
-        // Register the appropriate resource factory to handle all file
-        // extentions.
-        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
-                .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
-                        new WebResourceFactoryImpl());
-
-        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
-                .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
-                        new ApplicationResourceFactoryImpl());
-
-        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
-                .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
-                        new JarResourceFactoryImpl());
-
-        // Register the package to ensure it is available during loading.
-        resourceSet.getPackageRegistry().put(JarPackage.eNS_URI,
-                JarPackage.eINSTANCE);
-
-        resourceSet.getPackageRegistry().put(WebPackage.eNS_URI,
-                WebPackage.eINSTANCE);
-
-        resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_URI,
-                ApplicationPackage.eINSTANCE);
-    }
-
-    public static IFile getGeronimoWebDeploymentPlanFile(IModule module) {
-        IProject project = module.getProject();
-
-        IFlexibleProject flexProject = ComponentCore
-                .createFlexibleProject(project);
-        IVirtualComponent component = flexProject
-                .getComponent(module.getName());
-        IPath deployPlanPath = component.getRootFolder().getUnderlyingFolder()
-                .getProjectRelativePath().append("WEB-INF").append(
-                        WEB_DEP_PLAN_NAME);
-
-        IFile planFile = project.getFile(deployPlanPath);
-        return planFile;
     }
 
     public boolean isGeronimoRuntimeTarget() {

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java?rev=240209&r1=240208&r2=240209&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java
Fri Aug 26 04:37:49 2005
@@ -15,17 +15,20 @@
  */
 package org.apache.geronimo.core.internal;
 
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.MalformedURLException;
 
 import javax.enterprise.deploy.shared.ModuleType;
 
+import org.apache.geronimo.xml.ns.j2ee.application.ApplicationPackage;
+import org.apache.geronimo.xml.ns.j2ee.application.ApplicationType;
+import org.apache.geronimo.xml.ns.j2ee.application.util.ApplicationResourceFactoryImpl;
 import org.apache.geronimo.xml.ns.web.DocumentRoot;
 import org.apache.geronimo.xml.ns.web.WebAppType;
+import org.apache.geronimo.xml.ns.web.WebPackage;
+import org.apache.geronimo.xml.ns.web.util.WebResourceFactoryImpl;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.resource.Resource;
@@ -40,186 +43,271 @@
 import org.eclipse.wst.common.componentcore.resources.IFlexibleProject;
 import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
 import org.eclipse.wst.server.core.IModule;
+import org.openejb.xml.ns.openejb.jar.JarPackage;
 import org.openejb.xml.ns.openejb.jar.OpenejbJarType;
+import org.openejb.xml.ns.openejb.jar.util.JarResourceFactoryImpl;
 
 public class GeronimoUtils {
 
-	public static String getConfigId(IModule module) {
+    public static final String WEB_PLAN_NAME = "geronimo-web.xml";
 
-		String configId = null;
+    public static final String OPENEJB_PLAN_NAME = "openejb-jar.xml";
 
-		if (isWebModule(module)) {			
-			WebAppType deploymentPlan = getWebDeploymentPlan(module);
+    public static final String APP_PLAN_NAME = "geronimo-application.xml";
 
-			if (deploymentPlan != null)
-				configId = deploymentPlan.getConfigId();
-
-			if (configId == null)
-				configId = getId(module);
-		} else if (isEjbJarModule(module)) {
-			configId = getId(module);
-		}
-
-		return configId;
-	}
-
-	public static boolean isWebModule(IModule module) {
-		return "j2ee.web".equals(module.getModuleType().getId());
-	}
-
-	public static boolean isEjbJarModule(IModule module) {
-		return "j2ee.ejb".equals(module.getModuleType().getId());
-	}
-
-	public static ModuleType getJSR88ModuleType(IModule module) {
-		if (isWebModule(module)) {
-			return ModuleType.WAR;
-		} else if (isEjbJarModule(module)) {
-			return ModuleType.EJB;
-		}
-		return null;
-	}
-
-	public static String getContextRoot(IModule module) {
-		String contextRoot = null;
-		
-		WebAppType deploymentPlan = getWebDeploymentPlan(module);
-		if (deploymentPlan != null)
-			contextRoot = deploymentPlan.getContextRoot();
-
-		if (contextRoot == null)
-			contextRoot = getId(module);
-
-		return contextRoot;
-	}
-
-	public static String getId(IModule module) {
-		// use the module ID
-		String moduleId = module.getId();
-
-		IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, null);
-		if (j2eeModule != null && j2eeModule instanceof J2EEFlexProjDeployable) {
-			J2EEFlexProjDeployable j2eeFlex = (J2EEFlexProjDeployable) j2eeModule;
-			// j2eeFlex
-			ArtifactEdit edit = null;
-
-			try {
-				edit = ArtifactEdit.getArtifactEditForRead(j2eeFlex.getComponentHandle());
-				XMIResource res = (XMIResource) edit.getContentModelRoot().eResource();
-				moduleId = res.getID(edit.getContentModelRoot());
-			} finally {
-				if (edit != null)
-					edit.dispose();
-			}
-		}
-
-		if (moduleId != null && moduleId.length() > 0)
-			return moduleId;
-
-		// ...but if there is no defined module ID, pick the best alternative
-
-		IPath moduleLocation = j2eeModule.getLocation();
-		if (moduleLocation != null) {
-			moduleId = moduleLocation.removeFileExtension().lastSegment();
-		}
-
-		if (j2eeModule instanceof IWebModule) {
-			// A better choice is to use the context root
-			// For wars most appservers use the module name
-			// as the context root
-			String contextRoot = ((IWebModule) j2eeModule).getContextRoot();
-			if (contextRoot.charAt(0) == '/')
-				moduleId = contextRoot.substring(1);
-		}
-
-		return moduleId;
-	}
-
-	// Temporary workaround - ensure the .deployable copy
-	// of the file is also updated (WTP should be doing this)
-	public static void copyDeploymentPlanToDeployable(IModule module) {
-		IFile planFile = DeploymentPlanCreationOperation.getGeronimoWebDeploymentPlanFile(module);
-		if (planFile.exists()) {
-			try {
-				IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, null);
-				File deployableFile = j2eeModule.getLocation().addTrailingSeparator().append(
-						"WEB-INF").addTrailingSeparator().append(DeploymentPlanCreationOperation.WEB_DEP_PLAN_NAME).toFile();
-				InputStream input = planFile.getContents();
-				FileOutputStream output = new FileOutputStream(deployableFile);
-				byte[] buffer = new byte[1000];
-				int bytesRead = 0;
-				while (bytesRead > -1) {
-					bytesRead = input.read(buffer);
-					if (bytesRead > 0)
-						output.write(buffer, 0, bytesRead);
-				}
-				output.close();
-				input.close();
-			} catch (Exception e) {
-				Trace.trace(Trace.SEVERE, "Error copying deployment plan", e);
-			}
-		}
-	}
-
-	private static Resource load(IFile dpFile) {
-		try {
-			ResourceSet resourceSet = new ResourceSetImpl();
-            DeploymentPlanCreationOperation.registerForWeb(resourceSet);
-				
-			URI uri = URI.createPlatformResourceURI(dpFile.getFullPath().toString());
-			
-			Resource resource = resourceSet.createResource(uri);
-			if (!resource.isLoaded()) {
-				resource.load(null);
-			}
-			return resource;
-		} catch (MalformedURLException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-    
-    public static WebAppType getWebDeploymentPlan(IFile dpFile) {       
-        if (dpFile.exists()) {
-            Resource resource = load(dpFile);
+    public static String getConfigId(IModule module) {
+
+        String configId = null;
+
+        if (isWebModule(module)) {
+            WebAppType deploymentPlan = getWebDeploymentPlan(module);
+
+            if (deploymentPlan != null)
+                configId = deploymentPlan.getConfigId();
+
+            if (configId == null)
+                configId = getId(module);
+        } else if (isEjbJarModule(module)) {
+            configId = getId(module);
+        }
+
+        return configId;
+    }
+
+    public static boolean isWebModule(IModule module) {
+        return "j2ee.web".equals(module.getModuleType().getId());
+    }
+
+    public static boolean isEjbJarModule(IModule module) {
+        return "j2ee.ejb".equals(module.getModuleType().getId());
+    }
+
+    public static ModuleType getJSR88ModuleType(IModule module) {
+        if (isWebModule(module)) {
+            return ModuleType.WAR;
+        } else if (isEjbJarModule(module)) {
+            return ModuleType.EJB;
+        }
+        return null;
+    }
+
+    public static String getContextRoot(IModule module) {
+        String contextRoot = null;
+
+        WebAppType deploymentPlan = getWebDeploymentPlan(module);
+        if (deploymentPlan != null)
+            contextRoot = deploymentPlan.getContextRoot();
+
+        if (contextRoot == null)
+            contextRoot = getId(module);
+
+        return contextRoot;
+    }
+
+    public static String getId(IModule module) {
+        // use the module ID
+        String moduleId = module.getId();
+
+        IJ2EEModule j2eeModule = (IJ2EEModule) module.loadAdapter(
+                IJ2EEModule.class, null);
+        if (j2eeModule != null && j2eeModule instanceof J2EEFlexProjDeployable) {
+            J2EEFlexProjDeployable j2eeFlex = (J2EEFlexProjDeployable) j2eeModule;
+            // j2eeFlex
+            ArtifactEdit edit = null;
+
+            try {
+                edit = ArtifactEdit.getArtifactEditForRead(j2eeFlex
+                        .getComponentHandle());
+                XMIResource res = (XMIResource) edit.getContentModelRoot()
+                        .eResource();
+                moduleId = res.getID(edit.getContentModelRoot());
+            } finally {
+                if (edit != null)
+                    edit.dispose();
+            }
+        }
+
+        if (moduleId != null && moduleId.length() > 0)
+            return moduleId;
+
+        // ...but if there is no defined module ID, pick the best alternative
+
+        IPath moduleLocation = j2eeModule.getLocation();
+        if (moduleLocation != null) {
+            moduleId = moduleLocation.removeFileExtension().lastSegment();
+        }
+
+        if (j2eeModule instanceof IWebModule) {
+            // A better choice is to use the context root
+            // For wars most appservers use the module name
+            // as the context root
+            String contextRoot = ((IWebModule) j2eeModule).getContextRoot();
+            if (contextRoot.charAt(0) == '/')
+                moduleId = contextRoot.substring(1);
+        }
+
+        return moduleId;
+    }
+
+    public static ApplicationType getApplicationDeploymentPlan(
+            IVirtualComponent comp) {
+        IFile dpPlan = getApplicationDeploymentPlanFile(comp);
+        return getApplicationDeploymentPlan(dpPlan);
+    }
+
+    public static WebAppType getWebDeploymentPlan(IVirtualComponent comp) {
+        IFile dpPlan = getWebDeploymentPlanFile(comp);
+        return getWebDeploymentPlan(dpPlan);
+    }
+
+    public static OpenejbJarType getOpenEjbDeploymentPlan(IVirtualComponent comp) {
+        IFile dpPlan = getOpenEjbDeploymentPlanFile(comp);
+        return getOpenEjbDeploymentPlan(dpPlan);
+    }
+
+    public static ApplicationType getApplicationDeploymentPlan(IFile file) {
+        if (file.getName().equals(APP_PLAN_NAME) && file.exists()) {
+            ResourceSet resourceSet = new ResourceSetImpl();
+            registerAppFactoryAndPackage(resourceSet);
+            Resource resource = load(file, resourceSet);
+            if (resource != null) {
+                return ((org.apache.geronimo.xml.ns.j2ee.application.DocumentRoot) resource
+                        .getContents().get(0)).getApplication();
+            }
+
+        }
+        return null;
+    }
+
+    public static WebAppType getWebDeploymentPlan(IFile file) {
+        if (file.getName().equals(WEB_PLAN_NAME) && file.exists()) {
+            ResourceSet resourceSet = new ResourceSetImpl();
+            registerWebFactoryAndPackage(resourceSet);
+            Resource resource = load(file, resourceSet);
             if (resource != null) {
-                return ((DocumentRoot) resource.getContents().get(0)).getWebApp();
+                return ((DocumentRoot) resource.getContents().get(0))
+                        .getWebApp();
             }
-        } 
+
+        }
         return null;
     }
-    
-    public static OpenejbJarType getOpenEjbDeploymentPlan(IFile dpFile) {       
-        if (dpFile.exists()) {
-            Resource resource = load(dpFile);
+
+    public static OpenejbJarType getOpenEjbDeploymentPlan(IFile file) {
+        if (file.getName().equals(OPENEJB_PLAN_NAME) && file.exists()) {
+            ResourceSet resourceSet = new ResourceSetImpl();
+            registerEjbFactoryAndPackage(resourceSet);
+            Resource resource = load(file, resourceSet);
             if (resource != null) {
-                return ((org.openejb.xml.ns.openejb.jar.DocumentRoot) resource.getContents().get(0)).getOpenejbJar();
+                return ((org.openejb.xml.ns.openejb.jar.DocumentRoot) resource
+                        .getContents().get(0)).getOpenejbJar();
             }
-        } 
+        }
         return null;
     }
 
-	private static WebAppType getWebDeploymentPlan(IModule module) {
-        IFile dpFile = DeploymentPlanCreationOperation.getGeronimoWebDeploymentPlanFile(module);
-		if (dpFile.exists()) {
-			Resource resource = load(dpFile);
-			if (resource != null) {
-				return ((DocumentRoot) resource.getContents().get(0)).getWebApp();
-			}
-		} else {
-			if (module != null) {
-				return createWebDeploymentPlan(module);
-			}
-		}
-		return null;
-	}
-    
-    private static WebAppType createWebDeploymentPlan(IModule module) {
-        IFlexibleProject flexProject = ComponentCore.createFlexibleProject(module.getProject());
-        IVirtualComponent component = flexProject.getComponent(module.getName());
-        DeploymentPlanCreationOperation op = new DeploymentPlanCreationOperation();
-        return op.createGeronimoWebDeploymentPlan(component);
+    public static IFile getWebDeploymentPlanFile(IVirtualComponent comp) {
+        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
+                .getProjectRelativePath().append("WEB-INF").append(
+                        WEB_PLAN_NAME);
+        return comp.getProject().getFile(deployPlanPath);
+
+    }
+
+    public static IFile getOpenEjbDeploymentPlanFile(IVirtualComponent comp) {
+        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
+                .getProjectRelativePath().append("META-INF").append(
+                        OPENEJB_PLAN_NAME);
+        return comp.getProject().getFile(deployPlanPath);
+
+    }
+
+    public static IFile getApplicationDeploymentPlanFile(IVirtualComponent comp) {
+        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
+                .getProjectRelativePath().append("META-INF").append(
+                        APP_PLAN_NAME);
+        return comp.getProject().getFile(deployPlanPath);
+
+    }
+
+    public static WebAppType getWebDeploymentPlan(IModule module) {
+        return getWebDeploymentPlan(getVirtualComponent(module));
     }
+
+    private static IVirtualComponent getVirtualComponent(IModule module) {
+        IProject project = module.getProject();
+
+        IFlexibleProject flexProject = ComponentCore
+                .createFlexibleProject(project);
+        IVirtualComponent component = flexProject
+                .getComponent(module.getName());
+        return component;
+    }
+
+    private static Resource load(IFile dpFile, ResourceSet resourceSet) {
+        try {
+
+            URI uri = URI.createPlatformResourceURI(dpFile.getFullPath()
+                    .toString());
+
+            Resource resource = resourceSet.createResource(uri);
+            if (!resource.isLoaded()) {
+                resource.load(null);
+            }
+            return resource;
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * Register the appropriate resource factory to handle all file extentions.
+     * Register the package to ensure it is available during loading.
+     * 
+     * @param resourceSet
+     */
+    public static void registerWebFactoryAndPackage(ResourceSet resourceSet) {
+        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+                .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
+                        new WebResourceFactoryImpl());
+
+        resourceSet.getPackageRegistry().put(WebPackage.eNS_URI,
+                WebPackage.eINSTANCE);
+
+    }
+
+    /**
+     * Register the appropriate resource factory to handle all file extentions.
+     * Register the package to ensure it is available during loading.
+     * 
+     * @param resourceSet
+     */
+    public static void registerEjbFactoryAndPackage(ResourceSet resourceSet) {
+        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+                .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
+                        new JarResourceFactoryImpl());
+        resourceSet.getPackageRegistry().put(JarPackage.eNS_URI,
+                JarPackage.eINSTANCE);
+
+    }
+
+    /**
+     * Register the appropriate resource factory to handle all file extentions.
+     * Register the package to ensure it is available during loading.
+     * 
+     * @param resourceSet
+     */
+    public static void registerAppFactoryAndPackage(ResourceSet resourceSet) {
+        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+                .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
+                        new ApplicationResourceFactoryImpl());
+
+        resourceSet.getPackageRegistry().put(ApplicationPackage.eNS_URI,
+                ApplicationPackage.eINSTANCE);
+
+    }
+
 }

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/ExportDeploymentPlanOperation.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/ExportDeploymentPlanOperation.java?rev=240209&r1=240208&r2=240209&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/ExportDeploymentPlanOperation.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/ExportDeploymentPlanOperation.java
Fri Aug 26 04:37:49 2005
@@ -15,22 +15,13 @@
  */
 package org.apache.geronimo.core.operations;
 
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.apache.geronimo.core.internal.DeploymentPlanCreationOperation;
+import org.apache.geronimo.core.internal.GeronimoUtils;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
 import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
 import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
 import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
@@ -95,30 +86,23 @@
     // TODO
     private void addToGeronimoApplicationPlan(EObject eObject,
             IVirtualComponent component) {
-
     }
 
     private EObject getDeploymentPlanForComponent(IVirtualComponent comp) {
-        if (comp.getComponentTypeId().equals(EJBArtifactEdit.TYPE_ID)) {
-            return getWebDeploymentPlan(comp);
+        
+        if (comp.getComponentTypeId().equals(EARArtifactEdit.TYPE_ID)) {
+            return GeronimoUtils.getApplicationDeploymentPlan(comp);
         }
-
+        
         if (comp.getComponentTypeId().equals(WebArtifactEdit.TYPE_ID)) {
-            return getWebDeploymentPlan(comp);
+            return GeronimoUtils.getWebDeploymentPlan(comp);
+        }
+        
+        if (comp.getComponentTypeId().equals(EJBArtifactEdit.TYPE_ID)) {
+            return GeronimoUtils.getOpenEjbDeploymentPlan(comp);
         }
         return null;
-    }
-
-    private EObject getWebDeploymentPlan(IVirtualComponent comp) {
-        IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder()
-                .getProjectRelativePath().append("WEB-INF").append(
-                        WEB_PLAN_NAME);        
-        return load(comp.getProject().getFile(deployPlanPath));
-    }
-
-    private EObject getOpenEjbDeploymentPlan(IVirtualComponent comp) {
-        return null;
-    }
+    } 
 
     /*
      * (non-Javadoc)
@@ -128,7 +112,6 @@
      */
     public IStatus redo(IProgressMonitor monitor, IAdaptable info)
             throws ExecutionException {
-        // TODO Auto-generated method stub
         return null;
     }
 
@@ -140,29 +123,6 @@
      */
     public IStatus undo(IProgressMonitor monitor, IAdaptable info)
             throws ExecutionException {
-        return null;
-    }
-
-    public EObject load(IFile file) {
-        if (file.exists()) {
-            try {
-                ResourceSet resourceSet = new ResourceSetImpl();
-                DeploymentPlanCreationOperation.registerForWeb(resourceSet);
-
-                URI uri = URI.createPlatformResourceURI(file.getFullPath()
-                        .toString());
-
-                Resource resource = resourceSet.createResource(uri);
-                if (!resource.isLoaded()) {
-                    resource.load(null);
-                }
-                return (EObject) resource.getContents().get(0);
-            } catch (MalformedURLException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
         return null;
     }
 

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/IExportDeploymentPlanDataModelProperties.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/IExportDeploymentPlanDataModelProperties.java?rev=240209&r1=240208&r2=240209&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/IExportDeploymentPlanDataModelProperties.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.core/src/org/apache/geronimo/core/operations/IExportDeploymentPlanDataModelProperties.java
Fri Aug 26 04:37:49 2005
@@ -1,13 +1,12 @@
 package org.apache.geronimo.core.operations;
 
+
 public interface IExportDeploymentPlanDataModelProperties {
 
     public static final String PROJECT_NAME = "IExportDeploymentPlanDataModelProperties.PROJECT_NAME";
 
     public static final String COMPONENT_NAME = "IExportDeploymentPlanDataModelProperties.COMPONENT_NAME";
-    
+
     public static final String EXPORT_LOCATION = "IExportDeploymentPlanDataModelProperties.EXPORT_LOCATION";
-    
-    public static final String WEB_PLAN_NAME = "geronimo-web.xml";
 
 }



Mime
View raw message