You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by sh...@apache.org on 2008/03/25 18:48:23 UTC

svn commit: r640912 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/ org.apache.geronimo.st.core/META-INF/ org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/ org.apache.geronimo.st.ui/src/main/...

Author: shivahr
Date: Tue Mar 25 10:48:05 2008
New Revision: 640912

URL: http://svn.apache.org/viewvc?rev=640912&view=rev
Log:
JAXB marshal/unmarshal - 'Resource Out of Sync' messages - Use Eclipse IResource interfaces to create/update G plans.

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/pom.xml
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoFormContentLoader.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20Utils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.ui/src/main/java/org/apache/geronimo/st/v20/ui/editors/GeronimoFormContentLoader.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21Utils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/editors/GeronimoFormContentLoader.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF Tue Mar 25 10:48:05 2008
@@ -23,7 +23,8 @@
  org.eclipse.debug.core,
  org.eclipse.wst.web,
  org.eclipse.jem.util,
- org.apache.geronimo.runtime.common
+ org.apache.geronimo.runtime.common,
+ org.apache.geronimo.deployment.v21.jaxbmodel
 Eclipse-LazyStart: true
 Export-Package: org,
  org.apache,

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/pom.xml?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/pom.xml Tue Mar 25 10:48:05 2008
@@ -94,5 +94,10 @@
             <artifactId>org.apache.geronimo.runtime.common</artifactId>
             <version>${version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.devtools</groupId>
+            <artifactId>org.apache.geronimo.deployment.v21.jaxbmodel</artifactId>
+            <version>${version}</version>
+        </dependency>
     </dependencies>
 </project>

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java Tue Mar 25 10:48:05 2008
@@ -16,13 +16,72 @@
  */
 package org.apache.geronimo.st.core.jaxb;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.geronimo.st.core.Activator;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+
 /**
  * @version $Rev$ $Date$
  */
 public class JAXBUtils {
+
+	// JAXBContext instantiation is costly - must be done only once!
+	private static JAXBContext jaxbContext;
+	{
+		try {
+			jaxbContext = JAXBContext.newInstance("org.apache.geronimo.xml.ns.j2ee.web_2_0:"
+					+ "org.apache.geronimo.xml.ns.j2ee.application_2:"
+					+ "org.apache.geronimo.xml.ns.deployment_1:" + "org.apache.geronimo.xml.ns.naming_1:"
+					+ "org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader());
+		} catch (JAXBException e) {
+			Trace.tracePoint("JAXBException", "JAXBContext.newInstance");
+			e.printStackTrace();
+		}
+	}
+
+	public static void marshalDeploymentPlan(JAXBElement jaxbElement, IFile file) {
+		try {
+			Marshaller marshaller = jaxbContext.createMarshaller();
+			marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+			marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+			ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+			marshaller.marshal(jaxbElement, buffer);
+			file.setContents(new ByteArrayInputStream(buffer.toByteArray()), IFile.FORCE, null);
+		} catch (JAXBException jaxbException) {
+			Trace.tracePoint("JAXBException", "JAXBUtils.marshallToIFile()", file.getFullPath());
+			jaxbException.printStackTrace();
+		} catch (CoreException coreException) {
+			Trace.tracePoint("CoreException", "JAXBUtils.marshallToIFile()", file.getFullPath());
+			coreException.printStackTrace();
+		}
+	}
+
+	public static JAXBElement unmarshalDeploymentPlan(IFile file) {
+		try {
+			Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+			JAXBElement plan = (JAXBElement) unmarshaller.unmarshal(file.getContents());
+			return plan;
+		} catch (JAXBException e) {
+			e.printStackTrace();
+		} catch (CoreException e) {
+			e.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
 
 	public static Object getValue( Object element, String name ) {
 		try {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoFormContentLoader.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoFormContentLoader.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoFormContentLoader.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/editors/AbstractGeronimoFormContentLoader.java Tue Mar 25 10:48:05 2008
@@ -16,7 +16,14 @@
  */
 package org.apache.geronimo.st.ui.editors;
 
+import java.io.IOException;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+
 import org.apache.geronimo.st.core.GeronimoUtils;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.PartInitException;
@@ -53,4 +60,9 @@
 	abstract public void addConnectorPlanPages(FormEditor editor) throws PartInitException;
 	
 	abstract public void addApplicationPlanPages(FormEditor editor) throws PartInitException;
+
+	public void saveDeploymentPlan(JAXBElement deploymentPlan, IFile file) throws IOException, JAXBException {
+		JAXBUtils.marshalDeploymentPlan(deploymentPlan, file);
+	}
+
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java Tue Mar 25 10:48:05 2008
@@ -16,12 +16,10 @@
  */
 package org.apache.geronimo.st.v11.core;
 
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 
 import org.apache.geronimo.st.core.GeronimoUtils;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.xml.ns.deployment_1.ArtifactType;
 import org.apache.geronimo.xml.ns.deployment_1.EnvironmentType;
 import org.apache.geronimo.xml.ns.j2ee.application_1.ApplicationType;
@@ -210,7 +208,7 @@
 //			if (resource != null) {
 //				return ((org.openejb.xml.ns.openejb.jar.DocumentRoot) resource.getContents().get(0)).getOpenejbJar();
 //			}
-			return unmarshalDeploymentPlan( file );
+			return JAXBUtils.unmarshalDeploymentPlan(file);
 		}
 		return null;
 	}
@@ -223,19 +221,7 @@
 //			if (resource != null) {
 //				return ((org.apache.geronimo.xml.ns.j2ee.connector.DocumentRoot) resource.getContents().get(0)).getConnector();
 //			}
-			return unmarshalDeploymentPlan( file );
-		}
-		return null;
-	}
-	
-	private static JAXBElement unmarshalDeploymentPlan( IFile file ) {
-		try {
-	    	JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_1:org.apache.geronimo.xml.ns.j2ee.application_1:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1" );
-	    	Unmarshaller ums = jb.createUnmarshaller();
-	    	JAXBElement plan = (JAXBElement)ums.unmarshal( file.getFullPath().toFile() );
-	    	return plan;
-		} catch ( JAXBException e ) {
-			e.printStackTrace();
+			return JAXBUtils.unmarshalDeploymentPlan(file);
 		}
 		return null;
 	}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20Utils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20Utils.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20Utils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.core/src/main/java/org/apache/geronimo/st/v20/core/GeronimoV20Utils.java Tue Mar 25 10:48:05 2008
@@ -22,6 +22,7 @@
 import javax.xml.bind.Unmarshaller;
 
 import org.apache.geronimo.st.core.GeronimoUtils;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.xml.ns.deployment_1.ArtifactType;
 import org.apache.geronimo.xml.ns.deployment_1.EnvironmentType;
 import org.apache.geronimo.xml.ns.j2ee.application_2.ApplicationType;
@@ -180,7 +181,7 @@
 //			if (resource != null) {
 //				return ((org.apache.geronimo.xml.ns.j2ee.application.DocumentRoot) resource.getContents().get(0)).getApplication();
 //			}
-			return unmarshalDeploymentPlan( file );
+			return JAXBUtils.unmarshalDeploymentPlan(file);
 		}
 		return null;
 	}
@@ -193,7 +194,7 @@
 //			if (resource != null) {
 //				return ((DocumentRoot) resource.getContents().get(0)).getWebApp();
 //			}
-			return unmarshalDeploymentPlan( file );
+			return JAXBUtils.unmarshalDeploymentPlan(file);
 		}
 		return null;
 	}
@@ -206,7 +207,7 @@
 //			if (resource != null) {
 //				return ((org.openejb.xml.ns.openejb.jar.DocumentRoot) resource.getContents().get(0)).getOpenejbJar();
 //			}
-			return unmarshalDeploymentPlan( file );
+			return JAXBUtils.unmarshalDeploymentPlan(file);
 		}
 		return null;
 	}
@@ -219,21 +220,7 @@
 //			if (resource != null) {
 //				return ((org.apache.geronimo.xml.ns.j2ee.connector.DocumentRoot) resource.getContents().get(0)).getConnector();
 //			}
-			return unmarshalDeploymentPlan( file );
-		}
-		return null;
-	}
-	
-	private static JAXBElement unmarshalDeploymentPlan( IFile file ) {
-		try {
-	    	JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-	    	Unmarshaller ums = jb.createUnmarshaller();
-	    	JAXBElement plan = (JAXBElement)ums.unmarshal( file.getContents() );
-	    	return plan;
-		} catch ( JAXBException e ) {
-			e.printStackTrace();
-		} catch ( CoreException e ) {
-			e.printStackTrace();
+			return JAXBUtils.unmarshalDeploymentPlan(file);
 		}
 		return null;
 	}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.ui/src/main/java/org/apache/geronimo/st/v20/ui/editors/GeronimoFormContentLoader.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.ui/src/main/java/org/apache/geronimo/st/v20/ui/editors/GeronimoFormContentLoader.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.ui/src/main/java/org/apache/geronimo/st/v20/ui/editors/GeronimoFormContentLoader.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v20.ui/src/main/java/org/apache/geronimo/st/v20/ui/editors/GeronimoFormContentLoader.java Tue Mar 25 10:48:05 2008
@@ -16,18 +16,11 @@
  */
 package org.apache.geronimo.st.v20.ui.editors;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
 
 import org.apache.geronimo.st.ui.CommonMessages;
 import org.apache.geronimo.st.ui.editors.AbstractGeronimoFormContentLoader;
 import org.apache.geronimo.st.v20.core.GeronimoV20Utils;
-import org.apache.geronimo.st.v20.ui.Activator;
 import org.apache.geronimo.st.v20.ui.pages.AppGeneralPage;
 import org.apache.geronimo.st.v20.ui.pages.ConnectorOverviewPage;
 import org.apache.geronimo.st.v20.ui.pages.DeploymentPage;
@@ -94,12 +87,6 @@
 	 */
 	public JAXBElement loadDeploymentPlan(IFile file) {
 		return GeronimoV20Utils.getDeploymentPlan(file);
-	}
-	
-	public void saveDeploymentPlan(JAXBElement deploymentPlan, IFile file) throws IOException, JAXBException {
-		JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-//		jb.createMarshaller().marshal( deploymentPlan, new File( file.getLocationURI().toURL().getFile()) );
-		jb.createMarshaller().marshal( deploymentPlan, new FileOutputStream( new File( file.getLocationURI().toURL().getFile()) ) );
 	}
 	
 	protected FormPage getWebNamingPage(FormEditor editor) {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21Utils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21Utils.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21Utils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoV21Utils.java Tue Mar 25 10:48:05 2008
@@ -20,7 +20,7 @@
 
 import org.apache.geronimo.st.core.GeronimoUtils;
 import org.apache.geronimo.st.core.internal.Trace;
-import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.xml.ns.deployment_1.ArtifactType;
 import org.apache.geronimo.xml.ns.deployment_1.EnvironmentType;
 import org.apache.geronimo.xml.ns.j2ee.application_2.ApplicationType;
@@ -206,7 +206,7 @@
 //            if (resource != null) {
 //                return((org.apache.geronimo.xml.ns.j2ee.application.DocumentRoot) resource.getContents().get(0)).getApplication();
 //            }
-        	return JAXBModelUtils.unmarshalDeploymentPlan( file );
+        	return JAXBUtils.unmarshalDeploymentPlan(file);
         }
 
         Trace.tracePoint("EXIT", "GeronimoV21Utils.getApplicationDeploymentPlan", null);
@@ -223,7 +223,7 @@
 //            if (resource != null) {
 //                return((DocumentRoot) resource.getContents().get(0)).getWebApp();
 //            }
-            return JAXBModelUtils.unmarshalDeploymentPlan( file );
+            return JAXBUtils.unmarshalDeploymentPlan(file);
         }
 
         Trace.tracePoint("EXIT", "GeronimoV21Utils.getWebDeploymentPlan", null);
@@ -240,7 +240,7 @@
 //            if (resource != null) {
 //                return((org.openejb.xml.ns.openejb.jar.DocumentRoot) resource.getContents().get(0)).getOpenejbJar();
 //            }
-        	return JAXBModelUtils.unmarshalDeploymentPlan( file );
+        	return JAXBUtils.unmarshalDeploymentPlan(file);
         }
 
         Trace.tracePoint("EXIT", "GeronimoV21Utils.getOpenEjbDeploymentPlan", null);
@@ -257,7 +257,7 @@
 //            if (resource != null) {
 //                return((org.apache.geronimo.xml.ns.j2ee.connector.DocumentRoot) resource.getContents().get(0)).getConnector();
 //            }
-        	return JAXBModelUtils.unmarshalDeploymentPlan( file );
+        	return JAXBUtils.unmarshalDeploymentPlan(file);
         }
 
         Trace.tracePoint("EXIT", "GeronimoV21Utils.getConnectorDeploymentPlan", null);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java Tue Mar 25 10:48:05 2008
@@ -18,17 +18,11 @@
 
 import java.util.List;
 
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
 
-import org.apache.geronimo.st.v21.core.Activator;
 import org.apache.geronimo.xml.ns.deployment_1.EnvironmentType;
 import org.apache.geronimo.xml.ns.j2ee.web_2_0.WebAppType;
 import org.apache.geronimo.xml.ns.security_2.SecurityType;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 
 /**
  * @version $Rev$ $Date$
@@ -74,20 +68,5 @@
 		}
 		return null;
 	}
-	
-	public static JAXBElement unmarshalDeploymentPlan( IFile file ) {
-		try {
-	    	JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-	    	Unmarshaller ums = jb.createUnmarshaller();
-	    	JAXBElement plan = (JAXBElement)ums.unmarshal( file.getContents() );
-	    	return plan;
-		} catch ( JAXBException e ) {
-			e.printStackTrace();
-		} catch ( CoreException e ) {
-			e.printStackTrace();
-		} catch ( Exception e ) {
-			e.printStackTrace();
-		}
-		return null;
-	}
+
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java Tue Mar 25 10:48:05 2008
@@ -16,18 +16,10 @@
  */
 package org.apache.geronimo.st.v21.core.operations;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.net.MalformedURLException;
-
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
 
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.st.core.operations.DeploymentPlanCreationOperation;
-import org.apache.geronimo.st.v21.core.Activator;
 import org.apache.geronimo.st.v21.core.DeploymentPlanInstallConfig;
 import org.apache.geronimo.st.v21.core.internal.Trace;
 import org.apache.geronimo.xml.ns.deployment_1.ArtifactType;
@@ -44,9 +36,9 @@
 
 /**
  * <strong>V21DeploymentPlanCreationOperation</strong>
- * is invoked when projects are created the are to be deployment on the 2.1
+ * is invoked when projects are created that are to be deployed on the 2.1
  * version of the Geronimo server. One of these Geronimo-specific deployment
- * plans is created as a result is inserted into the user's Eclipse workspace in
+ * plans is created as a result and is inserted into the user's Eclipse workspace in
  * the appropriate folder:
  * 
  * <ol>
@@ -59,10 +51,6 @@
  * Remaining TODO Task(s):
  * 
  * <ol>
- *      <li>Use the Eclipse framework IResource interface to create the files
- *      above -- otherwise the user will have to refresh their workspace for the
- *      contents of the file to display, and an "Out of sync" message will be
- *      displayed.
  *      <li>JUnit testcases
  *      <li>How to invoke Service Deployment Plan
  *      <li>How to invoke App Client Deployment Plan
@@ -78,7 +66,7 @@
 		super(model, config);
   		Trace.tracePoint("Constructor Entry/Exit", "V21DeploymentPlanCreationOperation", model, config);
 	}
-	
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -89,31 +77,10 @@
 		
 		org.apache.geronimo.xml.ns.j2ee.application_2.ObjectFactory applicationFactory = new org.apache.geronimo.xml.ns.j2ee.application_2.ObjectFactory();
 		ApplicationType application = applicationFactory.createApplicationType();
-		
 		application.setApplicationName(getProject().getName());
 		application.setEnvironment(getConfigEnvironment());
-		
-		JAXBElement jaxbElement = null;
-		try {
-			JAXBContext jaxbContext = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-			jaxbElement = applicationFactory.createApplication(application);
-			Marshaller marshaller = jaxbContext.createMarshaller();
-            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-            marshaller.marshal(jaxbElement, new FileOutputStream( new File( dpFile.getLocationURI().toURL().getFile() )));
-		}
-		catch( JAXBException jaxbException ) {
-			Trace.tracePoint("JAXBException", "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", dpFile.getFullPath() );
-			jaxbException.printStackTrace();
-		}
-		catch( FileNotFoundException fileNotFoundException ) {
-			Trace.tracePoint("FileNotFoundException", "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", dpFile.getFullPath() );
-			fileNotFoundException.printStackTrace();
-		}
-		catch( MalformedURLException malformedURLException ) {
-			Trace.tracePoint("MalformedURLException", "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", dpFile.getFullPath() );
-			malformedURLException.printStackTrace();
-		}
+		JAXBElement jaxbElement = applicationFactory.createApplication(application);
+		JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile);
 		
 		Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", applicationFactory.createApplication(application));
 		return applicationFactory.createApplication(application);
@@ -134,27 +101,8 @@
 		web.setContextRoot( "/" + getProject().getName() );
 		web.setEnvironment(	getConfigEnvironment() );
 		
-		JAXBElement jaxbElement = null;
-		try {
-			JAXBContext jaxbContext = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-			jaxbElement = webFactory.createWebApp(web);
-			Marshaller marshaller = jaxbContext.createMarshaller();
-            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-            marshaller.marshal(jaxbElement, new FileOutputStream( new File( dpFile.getLocationURI().toURL().getFile() )));
-		}
-		catch( JAXBException jaxbException ) {
-			Trace.tracePoint("JAXBException", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", dpFile.getFullPath() );
-			jaxbException.printStackTrace();
-		}
-		catch( FileNotFoundException fileNotFoundException ) {
-			Trace.tracePoint("FileNotFoundException", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", dpFile.getFullPath() );
-			fileNotFoundException.printStackTrace();
-		}
-		catch( MalformedURLException malformedURLException ) {
-			Trace.tracePoint("MalformedURLException", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", dpFile.getFullPath() );
-			malformedURLException.printStackTrace();
-		}
+		JAXBElement jaxbElement = webFactory.createWebApp(web);
+		JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile);
 	
 		Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", jaxbElement);
 		return jaxbElement;
@@ -174,31 +122,11 @@
 
 		ejbJar.setEnvironment(getConfigEnvironment());
 		
-		JAXBElement jaxbElement = null;
-		try {
-			JAXBContext jaxbContext = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.ejb.openejb_2:org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-			jaxbElement = ejbFactory.createEjbJar(ejbJar);
-			Marshaller marshaller = jaxbContext.createMarshaller();
-            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-            marshaller.marshal(jaxbElement, new FileOutputStream( new File( dpFile.getLocationURI().toURL().getFile() )));
-		}
-		catch( JAXBException jaxbException ) {
-			Trace.tracePoint("JAXBException", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", dpFile.getFullPath() );
-			jaxbException.printStackTrace();
-		}
-		catch( FileNotFoundException fileNotFoundException ) {
-			Trace.tracePoint("FileNotFoundException", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", dpFile.getFullPath() );
-			fileNotFoundException.printStackTrace();
-		}
-		catch( MalformedURLException malformedURLException ) {
-			Trace.tracePoint("MalformedURLException", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", dpFile.getFullPath() );
-			malformedURLException.printStackTrace();
-		}
+		JAXBElement jaxbElement = ejbFactory.createEjbJar(ejbJar);
+		JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile);
 		
 		Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", jaxbElement);
 		return jaxbElement;
-		
 	}
 
 	
@@ -215,27 +143,8 @@
 		
 		connector.setEnvironment(getConfigEnvironment());
 		
-		JAXBElement jaxbElement = null;
-		try {
-			JAXBContext jaxbContext = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.connector_1:org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-			jaxbElement = connectorFactory.createConnector(connector);
-			Marshaller marshaller = jaxbContext.createMarshaller();
-            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-            marshaller.marshal(jaxbElement, new FileOutputStream( new File( dpFile.getLocationURI().toURL().getFile() )));
-		}
-		catch( JAXBException jaxbException ) {
-			Trace.tracePoint("JAXBException", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", dpFile.getFullPath() );
-			jaxbException.printStackTrace();
-		}
-		catch( FileNotFoundException fileNotFoundException ) {
-			Trace.tracePoint("FileNotFoundException", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", dpFile.getFullPath() );
-			fileNotFoundException.printStackTrace();
-		}
-		catch( MalformedURLException malformedURLException ) {
-			Trace.tracePoint("MalformedURLException", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", dpFile.getFullPath() );
-			malformedURLException.printStackTrace();
-		}
+		JAXBElement jaxbElement = connectorFactory.createConnector(connector);
+		JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile);
 		
 		Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", jaxbElement);
 		return jaxbElement;
@@ -251,27 +160,8 @@
 		
 		module.setEnvironment(getConfigEnvironment());
 		
-		JAXBElement jaxbElement = null;
-		try {
-			JAXBContext jaxbContext = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-			jaxbElement = serviceFactory.createModule(module);
-			Marshaller marshaller = jaxbContext.createMarshaller();
-            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-            marshaller.marshal(jaxbElement, new FileOutputStream( new File( dpFile.getLocationURI().toURL().getFile() )));
-		}
-		catch( JAXBException jaxbException ) {
-			Trace.tracePoint("JAXBException", "V21DeploymentPlanCreationOperation.createServiceDeploymentPlan", dpFile.getFullPath() );
-			jaxbException.printStackTrace();
-		}
-		catch( FileNotFoundException fileNotFoundException ) {
-			Trace.tracePoint("FileNotFoundException", "V21DeploymentPlanCreationOperation.createServiceDeploymentPlan", dpFile.getFullPath() );
-			fileNotFoundException.printStackTrace();
-		}
-		catch( MalformedURLException malformedURLException ) {
-			Trace.tracePoint("MalformedURLException", "V21DeploymentPlanCreationOperation.createServiceDeploymentPlan", dpFile.getFullPath() );
-			malformedURLException.printStackTrace();
-		}
+		JAXBElement jaxbElement = serviceFactory.createModule(module);
+		JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile);
 		
 		Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createServiceDeploymentPlan", jaxbElement);
 		return jaxbElement;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/editors/GeronimoFormContentLoader.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/editors/GeronimoFormContentLoader.java?rev=640912&r1=640911&r2=640912&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/editors/GeronimoFormContentLoader.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/editors/GeronimoFormContentLoader.java Tue Mar 25 10:48:05 2008
@@ -16,20 +16,13 @@
  */
 package org.apache.geronimo.st.v21.ui.editors;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.FileOutputStream;
-
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
 
 import org.apache.geronimo.st.ui.CommonMessages;
 import org.apache.geronimo.st.ui.editors.AbstractGeronimoDeploymentPlanEditor;
 import org.apache.geronimo.st.ui.editors.AbstractGeronimoFormContentLoader;
 import org.apache.geronimo.st.v21.core.GeronimoV21Utils;
 import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
-import org.apache.geronimo.st.v21.ui.Activator;
 import org.apache.geronimo.st.v21.ui.pages.AppGeneralPage;
 import org.apache.geronimo.st.v21.ui.pages.ConnectorOverviewPage;
 import org.apache.geronimo.st.v21.ui.pages.DeploymentPage;
@@ -101,12 +94,6 @@
 		return GeronimoV21Utils.getDeploymentPlan(file);
 	}
 	
-	public void saveDeploymentPlan(JAXBElement deploymentPlan, IFile file) throws IOException, JAXBException {
-		JAXBContext jb = JAXBContext.newInstance( "org.apache.geronimo.xml.ns.j2ee.web_2_0:org.apache.geronimo.xml.ns.j2ee.application_2:org.apache.geronimo.xml.ns.deployment_1:org.apache.geronimo.xml.ns.naming_1:org.apache.geronimo.xml.ns.security_2", Activator.class.getClassLoader() );
-		jb.createMarshaller().marshal( deploymentPlan, new FileOutputStream( new File( file.getLocationURI().toURL().getFile()) ) );
-		//jb.createMarshaller().marshal( deploymentPlan, new File( file.getLocationURI().toURL().getFile()) );
-	}
-
 	protected FormPage getWebNamingPage(FormEditor editor) {
 		NamingFormPage formPage = createNamingFormPage(editor);
 //		WebPackage pkg = null; //WebFactory.eINSTANCE.getWebPackage();