geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r952535 [21/26] - in /geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins: org.apache.geronimo.j2ee.v11.jaxbmodel/ org.apache.geronimo.j2ee.v11.jaxbmodel/META-INF/ org.apache.geronimo.j2ee.v11.jaxbmodel/src/main/java/org/apache/geronimo...
Date Tue, 08 Jun 2010 04:40:28 GMT
Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,712 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.v21.core.internal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.application.Application;
+import org.apache.geronimo.jee.applicationclient.ApplicationClient;
+import org.apache.geronimo.jee.connector.Connector;
+import org.apache.geronimo.jee.deployment.Artifact;
+import org.apache.geronimo.jee.deployment.Dependencies;
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.deployment.Environment;
+import org.apache.geronimo.jee.deployment.ObjectFactory;
+import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.web.WebApp;
+import org.apache.geronimo.st.v21.core.DeploymentUtils;
+import org.apache.geronimo.st.v21.core.GeronimoUtils;
+import org.apache.geronimo.st.v21.core.internal.DependencyManager;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+
+/**
+ * <b>DependencyHelper</b> is a helper class with various methods to aid in the discovery of
+ * inter-dependencies between modules being deployed from the GEP to the Geronimo server. It
+ * performs the following capabilities:
+ * <ol>
+ *      <li>Discovery of dependencies between modules<p>
+ *      <li>Provides the proper publishing ordering of the modules based on the discovered
+ *          dependencies<p>
+ *      <li><b>TODO:</b> Query the server searching for missing dependencies
+ * </ol>
+ * 
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class DependencyHelper {
+
+    private DependencyManager dm = new DependencyManager();
+    private ObjectFactory deploymentFactory = new ObjectFactory();
+    private List inputModules = new ArrayList();
+    private List inputDeltaKind = new ArrayList();
+    private List reorderedModules = new ArrayList();
+    private List reorderedKinds  = new ArrayList();
+    private List<JAXBElement> inputJAXBElements = new ArrayList();
+    private List<JAXBElement> reorderedJAXBElements = new ArrayList();
+
+
+    /**
+     * Reorder the publish order of the modules based on any discovered dependencies
+     * 
+     * @param modules   Modules to be published to the Geronimo server
+     * @param deltaKind Publish kind constant for each module
+     * 
+     * @return List of reordered modules and deltaKind (or input if no change)
+     */
+    public List reorderModules(IServer server, List modules, List deltaKind ) {
+        Trace.tracePoint("Entry", "DependencyHelper.reorderModules", modules, deltaKind);
+
+        if (modules.size() == 0) {
+            List reorderedLists = new ArrayList(2);
+            reorderedLists.add(modules);
+            reorderedLists.add(deltaKind);
+            Trace.tracePoint("Exit ", "DependencyHelper.reorderModules", reorderedLists);
+            return reorderedLists;
+        }
+
+        inputModules = modules;
+        inputDeltaKind = deltaKind;
+
+        // 
+        // Iterate through all the modules and register the dependencies
+        // 
+        for (int ii=0; ii<modules.size(); ii++) {
+            IModule[] module = (IModule[]) modules.get(ii);
+            int moduleDeltaKind = ((Integer)deltaKind.get(ii)).intValue();
+            if (moduleDeltaKind != ServerBehaviourDelegate.REMOVED) {
+            	//GERONIMODEVTOOLS-361
+            	for (IModule singleModule:module){
+            		Environment environment = getEnvironment(singleModule);
+	                if (environment != null) {
+	                    Artifact child = environment.getModuleId();
+	                    Dependencies dependencies = environment.getDependencies();
+	                    if (dependencies != null) {
+	                        List<Dependency> depList = dependencies.getDependency();
+	                        for ( Dependency dep : depList) {
+	                            Artifact parent = deploymentFactory.createArtifact();
+	                            parent.setGroupId( dep.getGroupId() );
+	                            parent.setArtifactId( dep.getArtifactId() );
+	                            parent.setVersion( dep.getVersion() );
+	                            parent.setType( dep.getType() );
+	                            
+	                            StringBuilder configId = new StringBuilder();
+	                            if (dep.getGroupId()!=null)
+	                            	configId.append(dep.getGroupId());
+	                            configId.append("/");
+	                            if (dep.getArtifactId()!=null)
+	                            	configId.append(dep.getArtifactId());
+	                            configId.append("/");
+	                            if (dep.getVersion()!=null)
+	                            	configId.append(dep.getVersion());
+	                            configId.append("/");
+	                            if (dep.getType()!=null)
+	                            	configId.append(dep.getType());
+	                            
+	                            if (!DeploymentUtils.isInstalledModule(server,configId.toString()))
+	                               	dm.addDependency(child, parent );
+	                        }
+	                    }
+	                }
+            	}
+            }
+        }
+
+        // 
+        // Iterate through all the modules again and reorder as necessary
+        // 
+        for (int ii=0; ii<modules.size(); ii++) {
+            IModule[] module = (IModule[]) modules.get(ii);
+            int moduleDeltaKind = ((Integer)deltaKind.get(ii)).intValue();
+            if (module!=null && !reorderedModules.contains(module)) {
+                // Not already moved 
+                if (moduleDeltaKind == ServerBehaviourDelegate.REMOVED) {
+                    // Move module if going to be removed 
+                    reorderedModules.add(module);
+                    reorderedKinds.add(moduleDeltaKind);
+                }
+                else {
+                    Environment environment = getEnvironment(module[0]);
+                    if (environment != null) {
+                        Artifact artifact = environment.getModuleId();
+                        if (artifact == null) {
+                            // Move if null (nothing can be done)
+                            if (!reorderedModules.contains(module)) {
+                                reorderedModules.add(module);
+                                reorderedKinds.add(moduleDeltaKind);
+                            }
+                        }
+                        else if (dm.getParents(artifact).contains(artifact) ||   
+                                 dm.getChildren(artifact).contains(artifact)) {
+                            // Move if a tight circular dependency (nothing can be done)
+                            if (!reorderedModules.contains(module)) {
+                                reorderedModules.add(module);
+                                reorderedKinds.add(moduleDeltaKind);
+                            }
+                        }
+                        else if (dm.getParents(artifact).size() == 0) {
+                            // Move if no parents (nothing to do)
+                            if (!reorderedModules.contains(module)) {
+                                reorderedModules.add(module);
+                                reorderedKinds.add(moduleDeltaKind);
+                            }
+                        }
+                        else if (dm.getParents(artifact).size() > 0) {
+                            // Move parents first
+                            processParents(dm.getParents(artifact), artifact);
+                            // Move self 
+                            if (!reorderedModules.contains(module)) {
+                                reorderedModules.add(module);
+                                reorderedKinds.add(moduleDeltaKind);
+                            }
+                        }
+                    }else {
+                    	//no environment defined, do just as no parents
+                        if (!reorderedModules.contains(module)) {
+                            reorderedModules.add(module);
+                            reorderedKinds.add(moduleDeltaKind);
+                        }
+                    }
+                }
+            }
+        }
+
+        // 
+        // Ensure return lists are exactly the same size as the input lists 
+        // 
+        assert reorderedModules.size() == modules.size();
+        assert reorderedKinds.size() == deltaKind.size();
+
+        // 
+        // Return List of lists
+        // 
+        List reorderedLists = new ArrayList(2);
+        reorderedLists.add(reorderedModules);
+        reorderedLists.add(reorderedKinds);
+
+        Trace.tracePoint("Exit ", "DependencyHelper.reorderModules", reorderedLists);
+        return reorderedLists;
+    }
+
+
+    /**
+     * Reorder the list of JAXBElements based on any discovered dependencies
+     * 
+     * @param jaxbElements
+     * 
+     * @return List of JAXBElements (or input if no change)
+     */
+    public List<JAXBElement> reorderJAXBElements( List<JAXBElement> jaxbElements ) {
+        Trace.tracePoint("Entry", "DependencyHelper.reorderModules", jaxbElements);
+
+        if (jaxbElements.size() == 0) {
+            Trace.tracePoint("Exit ", "DependencyHelper.reorderModules", jaxbElements);
+            return jaxbElements;
+        }
+
+        inputJAXBElements = jaxbElements;
+
+        // 
+        // Iterate through all the JAXBElements and register the dependencies
+        // 
+        for (JAXBElement jaxbElement : jaxbElements) {
+            Environment environment = getEnvironment(jaxbElement);
+            if (environment != null) {
+                Artifact child = environment.getModuleId();
+                if (child != null) {
+                    Dependencies dependencies = environment.getDependencies();
+                    if (dependencies != null) {
+                        List<Dependency> depList = dependencies.getDependency();
+                        if (depList != null) {
+                            for ( Dependency dep : depList) {
+                                Artifact parent = deploymentFactory.createArtifact();
+                                parent.setGroupId( dep.getGroupId() );
+                                parent.setArtifactId( dep.getArtifactId() );
+                                parent.setVersion( dep.getVersion() );
+                                parent.setType( dep.getType() );
+                                dm.addDependency( child, parent );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        // 
+        // Iterate through all the JAXBElements again and reorder as necessary
+        // 
+        for (JAXBElement jaxbElement : jaxbElements) {
+            if (!reorderedJAXBElements.contains(jaxbElement)) {
+                // Not already moved
+                Environment environment = getEnvironment(jaxbElement);
+                if (environment != null) {
+                    Artifact artifact = environment.getModuleId();
+                    if (artifact == null) {
+                        // Move if null (nothing can be done)
+                        if (!reorderedJAXBElements.contains(jaxbElement)) {
+                            reorderedJAXBElements.add(jaxbElement);
+                        }
+                    }
+                    else if (dm.getParents(artifact).contains(artifact) ||  
+                             dm.getChildren(artifact).contains(artifact)) {
+                        // Move if a tight circular dependency (nothing can be done)
+                        if (!reorderedJAXBElements.contains(jaxbElement)) {
+                            reorderedJAXBElements.add(jaxbElement);
+                        }
+                    }
+                    else if (dm.getParents(artifact).size() == 0) {
+                        // Move if no parents (nothing to do)
+                        if (!reorderedJAXBElements.contains(jaxbElement)) {
+                            reorderedJAXBElements.add(jaxbElement);
+                        }
+                    }
+                    else if (dm.getParents(artifact).size() > 0) {
+                        // Move parents first
+                        processJaxbParents(dm.getParents(artifact), artifact);
+                        // Move self 
+                        if (!reorderedJAXBElements.contains(jaxbElement)) {
+                            reorderedJAXBElements.add(jaxbElement);
+                        }
+                    }
+                }
+            }
+        }
+
+        // 
+        // Ensure return list is exactly the same size as the input list 
+        // 
+        assert reorderedJAXBElements.size() == jaxbElements.size();
+
+        // 
+        // Return List of JAXBElements
+        // 
+        Trace.tracePoint("Exit ", "DependencyHelper.reorderModules", reorderedJAXBElements);
+        return reorderedJAXBElements;
+    }
+
+
+    /**
+     *
+     */
+    public void close() {
+        dm.close();
+    }
+
+
+    /*--------------------------------------------------------------------------------------------*\
+    |                                                                                              |
+    |  Private method(s)                                                                           | 
+    |                                                                                              |
+    \*--------------------------------------------------------------------------------------------*/
+
+    /**
+     * Process the parents for a given artifact. The terminatingArtifact parameter will be used as
+     * the terminating condition to ensure there will not be an infinite loop (i.e., if
+     * terminatingArtifact is encountered again there is a circular dependency).
+     * 
+     * @param parents
+     * @param terminatingArtifact
+     */
+    private void processParents(Set parents, Artifact terminatingArtifact) {
+        Trace.tracePoint("Enter", "DependencyHelper.processParents", parents, terminatingArtifact );
+
+        if (parents == null) {
+            Trace.tracePoint("Exit ", "DependencyHelper.processParents", null);
+            return;
+        }
+        for (Iterator ii = parents.iterator(); ii.hasNext();) {
+            Artifact artifact = (Artifact)ii.next();
+            if (dm.getParents(artifact).size() > 0 && !artifact.equals(terminatingArtifact) &&
+                !dm.getParents(artifact).contains(artifact) && !dm.getChildren(artifact).contains(artifact)) {
+                // Keep processing parents (as long as no circular dependencies)
+                processParents(dm.getParents(artifact), terminatingArtifact);
+                // Move self 
+                IModule[] module = getModule(artifact);
+                int moduleDeltaKind = getDeltaKind(artifact);
+                if (module!=null && !reorderedModules.contains(module)) {
+                    reorderedModules.add(module);
+                    reorderedKinds.add(moduleDeltaKind);
+                }
+            }
+            else {
+                // Move parent
+                IModule[] module = getModule(artifact);
+                int moduleDeltaKind = getDeltaKind(artifact);
+                if (module!=null && !reorderedModules.contains(module)) {
+                    reorderedModules.add(module);
+                    reorderedKinds.add(moduleDeltaKind);
+                }
+            }
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.processParents");
+    }
+
+
+    /**
+     * Returns the Environment for the given IModule
+     * 
+     * @param module IModule to be published
+     * 
+     * @return Environment
+     */
+    private Environment getEnvironment(IModule module) {
+        Trace.tracePoint("Enter", "DependencyHelper.getEnvironment", module);
+
+        Environment environment = null;
+        if (GeronimoUtils.isWebModule(module)) {
+            if (getWebDeploymentPlan(module) != null) {
+                WebApp plan = getWebDeploymentPlan(module).getValue();
+                if (plan != null)
+                    environment = plan.getEnvironment();
+            }
+        }
+        else if (GeronimoUtils.isEjbJarModule(module)) {
+            if (getOpenEjbDeploymentPlan(module) != null) {
+                OpenejbJar plan = getOpenEjbDeploymentPlan(module).getValue();
+                if (plan != null)
+                    environment = plan.getEnvironment();
+            }
+        }
+        else if (GeronimoUtils.isEarModule(module)) {
+            if (getApplicationDeploymentPlan(module) != null) {
+                Application plan = getApplicationDeploymentPlan(module).getValue();
+                if (plan != null)
+                    environment = plan.getEnvironment();
+            }
+        }
+        else if (GeronimoUtils.isRARModule(module)) {
+            if (getConnectorDeploymentPlan(module) != null) {
+                Connector plan = getConnectorDeploymentPlan(module).getValue();
+                if (plan != null)
+                    environment = plan.getEnvironment();
+            }
+        }else if (GeronimoUtils.isAppClientModule(module)) {
+            if (getAppClientDeploymentPlan(module) != null) {
+                ApplicationClient plan = getAppClientDeploymentPlan(module).getValue();
+                if (plan != null)
+                    environment = plan.getServerEnvironment();
+            }
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment);
+        return environment;
+    }
+
+
+    /**
+     * Return the IModule[] for a given artifact
+     * 
+     * @param artifact
+     * 
+     * @return IModule[]
+     */
+    private IModule[] getModule(Artifact artifact) {
+        Trace.tracePoint("Enter", "DependencyHelper.getModule", artifact);
+
+        for (int ii=0; ii<inputModules.size(); ii++) {
+            IModule[] module = (IModule[]) inputModules.get(ii);
+            int moduleDeltaKind = ((Integer)inputDeltaKind.get(ii)).intValue();
+            Environment environment = getEnvironment(module[0]);
+            if (environment != null) {
+                Artifact moduleArtifact = environment.getModuleId();
+                if (artifact.equals(moduleArtifact)) {
+                    Trace.tracePoint("Exit ", "DependencyHelper.getModule", module);
+                    return module;
+                }
+            }
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getModule", null);
+        return null;
+    }
+
+
+    /**
+     * Return the deltaKind array index for a given artifact
+     * 
+     * @param artifact
+     * 
+     * @return int
+     */
+    private int getDeltaKind(Artifact artifact) {
+        Trace.tracePoint("Enter", "DependencyHelper.getDeltaKind", artifact);
+
+        for (int ii=0; ii<inputModules.size(); ii++) {
+            IModule[] module = (IModule[]) inputModules.get(ii);
+            int moduleDeltaKind = ((Integer)inputDeltaKind.get(ii)).intValue();
+            Environment environment = getEnvironment(module[0]);
+            if (environment != null) {
+                Artifact moduleArtifact = environment.getModuleId();
+                if (artifact.equals(moduleArtifact)) {
+                    Trace.tracePoint("Exit ", "DependencyHelper.getDeltaKind", moduleDeltaKind);
+                    return moduleDeltaKind;
+                }
+            }
+        }
+        Trace.tracePoint("Exit ", "DependencyHelper.getDeltaKind", 0);
+        return 0;
+    }
+
+
+    /**
+     * Returns the WebApp for the given IModule
+     * 
+     * @param module IModule to be published
+     * 
+     * @return WebApp
+     */
+    private JAXBElement<WebApp> getWebDeploymentPlan(IModule module) {
+        Trace.tracePoint("Enter", "DependencyHelper.getWebDeploymentPlan", module);
+
+        IVirtualComponent comp = GeronimoUtils.getVirtualComponent(module);
+        IFile file = GeronimoUtils.getWebDeploymentPlanFile(comp);
+        if (file.getName().equals(GeronimoUtils.WEB_PLAN_NAME) && file.exists()) {
+            try {
+				Trace.tracePoint("Exit ", "DependencyHelper.getWebDeploymentPlan", JAXBUtils.unmarshalFilterDeploymentPlan(file));
+				 return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+			} catch (Exception e) {
+				//ignore it, just indicate error by returning null
+			}
+           
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getWebDeploymentPlan", null);
+        return null;
+    }
+
+
+    /**
+     * Returns the OpenEjbJar for the given IModule
+     * 
+     * @param module IModule to be published
+     * 
+     * @return OpenEjbJar
+     */
+    private JAXBElement<OpenejbJar> getOpenEjbDeploymentPlan(IModule module) {
+        Trace.tracePoint("Enter", "DependencyHelper.getOpenEjbDeploymentPlan", module);
+
+        IVirtualComponent comp = GeronimoUtils.getVirtualComponent(module);
+        IFile file = GeronimoUtils.getOpenEjbDeploymentPlanFile(comp);
+        if (file.getName().equals(GeronimoUtils.OPENEJB_PLAN_NAME) && file.exists()) {
+            try {
+				Trace.tracePoint("Exit ", "DependencyHelper.getOpenEjbDeploymentPlan", JAXBUtils.unmarshalFilterDeploymentPlan(file));
+			} catch (Exception e) {
+				//ignore it, just indicate error by returning null
+			}
+            try {
+				return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+			} catch (Exception e) {
+				//ignore it, just indicate error by returning null
+			}
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getOpenEjbDeploymentPlan", null);
+        return null;
+    }
+
+    /**
+     * Returns the ApplicationClient for the given IModule
+     * 
+     * @param module IModule to be published
+     * 
+     * @return ApplicationClient
+     */
+    private JAXBElement<ApplicationClient> getAppClientDeploymentPlan(IModule module) {
+        Trace.tracePoint("Enter", "DependencyHelper.getWebDeploymentPlan", module);
+
+        IVirtualComponent comp = GeronimoUtils.getVirtualComponent(module);
+        IFile file = GeronimoUtils.getApplicationClientDeploymentPlanFile(comp);
+        if (file.getName().equals(GeronimoUtils.APP_CLIENT_PLAN_NAME) && file.exists()) {
+            try {
+				Trace.tracePoint("Exit ", "DependencyHelper.getWebDeploymentPlan", JAXBUtils.unmarshalFilterDeploymentPlan(file));
+				 return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+			} catch (Exception e) {
+				//ignore it, just indicate error by returning null
+			}
+           
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getWebDeploymentPlan", null);
+        return null;
+    }
+    
+    /**
+     * Returns the Application for the given IModule
+     * 
+     * @param module IModule to be published
+     * 
+     * @return Application
+     */
+    private JAXBElement<Application> getApplicationDeploymentPlan(IModule module) {
+        Trace.tracePoint("Enter", "DependencyHelper.getApplicationDeploymentPlan", module);
+
+        IVirtualComponent comp = GeronimoUtils.getVirtualComponent(module);
+        IFile file = GeronimoUtils.getApplicationDeploymentPlanFile(comp);
+        if (file.getName().equals(GeronimoUtils.APP_PLAN_NAME) && file.exists()) {
+            try {
+				Trace.tracePoint("Exit ", "DependencyHelper.getApplicationDeploymentPlan", JAXBUtils.unmarshalFilterDeploymentPlan(file));
+				  return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+			} catch (Exception e) {
+				//ignore it, just indicate error by returning null
+			}
+          
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getApplicationDeploymentPlan", null);
+        return null;
+    }
+
+
+    /**
+     * Returns the Connector for the given IModule
+     * 
+     * @param module IModule to be published
+     * 
+     * @return Application
+     */
+    private JAXBElement<Connector> getConnectorDeploymentPlan(IModule module) {
+        Trace.tracePoint("Enter", "DependencyHelper.getConnectorDeploymentPlan", module);
+
+        IVirtualComponent comp = GeronimoUtils.getVirtualComponent(module);
+        IFile file = GeronimoUtils.getConnectorDeploymentPlanFile(comp);
+        if (file.getName().equals(GeronimoUtils.CONNECTOR_PLAN_NAME) && file.exists()) {
+            try {
+				Trace.tracePoint("Exit ", "DependencyHelper.getConnectorDeploymentPlan", JAXBUtils.unmarshalFilterDeploymentPlan(file));
+				 return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+			} catch (Exception e) {
+				//ignore it, just indicate error by returning null
+			}
+           
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getConnectorDeploymentPlan", null);
+        return null;
+    }
+
+
+    /**
+     * Process the parents for a given artifact. The terminatingArtifact parameter will be used as
+     * the terminating condition to ensure there will not be an infinite loop (i.e., if
+     * terminatingArtifact is encountered again there is a circular dependency).
+     * 
+     * @param parents
+     * @param terminatingArtifact
+     */
+    private void processJaxbParents(Set parents, Artifact terminatingArtifact) {
+        Trace.tracePoint("Enter", "DependencyHelper.processJaxbParents", parents, terminatingArtifact );
+
+        if (parents == null) {
+            Trace.tracePoint("Exit ", "DependencyHelper.processJaxbParents", null);
+            return;
+        }
+        for (Iterator ii = parents.iterator(); ii.hasNext();) {
+            Artifact artifact = (Artifact)ii.next();
+            if (dm.getParents(artifact).size() > 0 && !artifact.equals(terminatingArtifact) &&
+                !dm.getParents(artifact).contains(artifact) && !dm.getChildren(artifact).contains(artifact)) {
+                // Keep processing parents (as long as no circular dependencies)
+                processJaxbParents(dm.getParents(artifact), terminatingArtifact);
+                // Move self 
+                JAXBElement jaxbElement = getJaxbElement(artifact);
+                if (jaxbElement != null) {
+                    if (!reorderedJAXBElements.contains(jaxbElement)) {
+                        reorderedJAXBElements.add(jaxbElement);
+                    }
+                }
+            }
+            else {
+                // Move parent
+                JAXBElement jaxbElement = getJaxbElement(artifact);
+                if (jaxbElement != null) {
+                    if (!reorderedJAXBElements.contains(jaxbElement)) {
+                        reorderedJAXBElements.add(jaxbElement);
+                    }
+                }
+            }
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.processJaxbParents");
+    }
+
+
+    /**
+     * Returns the Environment for the given JAXBElement plan
+     * 
+     * @param jaxbElement JAXBElement plan
+     * 
+     * @return Environment
+     */
+    private Environment getEnvironment(JAXBElement jaxbElement) {
+        Trace.tracePoint("Enter", "DependencyHelper.getEnvironment", jaxbElement);
+
+        Environment environment = null;
+        Object plan = jaxbElement.getValue();
+        if (plan != null) {
+            if (WebApp.class.isInstance(plan)) {
+                environment = ((WebApp)plan).getEnvironment();
+            }
+            else if (OpenejbJar.class.isInstance(plan)) {
+                environment = ((OpenejbJar)plan).getEnvironment();
+            }
+            else if (Application.class.isInstance(plan)) {
+                environment = ((Application)plan).getEnvironment();
+            }
+            else if (Connector.class.isInstance(plan)) {
+                environment = ((Connector)plan).getEnvironment();
+            }
+        }
+
+        Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment);
+        return environment;
+    }
+
+
+    /**
+     * Return the JAXBElement for a given artifact
+     * 
+     * @param artifact
+     * 
+     * @return JAXBElement
+     */
+    private JAXBElement getJaxbElement(Artifact artifact) {
+        Trace.tracePoint("Enter", "DependencyHelper.getJaxbElement", artifact);
+
+        for (JAXBElement jaxbElement : inputJAXBElements) {
+            Environment environment = getEnvironment(jaxbElement);
+            if (environment != null) {
+                Artifact jaxbArtifact = environment.getModuleId();
+                if (artifact.equals(jaxbArtifact)) {
+                    Trace.tracePoint("Exit ", "DependencyHelper.getJaxbElement", jaxbElement);
+                    return jaxbElement;
+                }
+            }
+        }
+
+        // TODO: Query the server searching for missing dependencies
+        Trace.tracePoint("Exit ", "DependencyHelper.getJaxbElement", null);
+        return null;
+    }
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyManager.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyManager.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyManager.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.v21.core.internal;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geronimo.jee.deployment.Artifact;
+
+/**
+ * <b>DependencyManager</b> is very closely-based on the similar class in the Geronimo server.
+ * DependencyManager is the record keeper of the dependencies in the Geronimo Eclipse Plugin. The
+ * DependencyManager does not enforce any dependencies, it is simply a place where components can
+ * register their intent to be dependent on another component, and where other components can query
+ * those dependencies.
+ * 
+ * <p>Like the DependencyManager in the Geronimo server, it uses the nomenclature of parent-child
+ * where a child is dependent on a parent. The names parent and child have no other meaning are just
+ * a convenience to make the code readable.
+ * 
+ * <p>The initial usage of this DependencyManager in the GEP is somewhat limited but other usages 
+ * are possible<p>
+ * 
+ * @version $Rev: 680897 $ $Date: 2008-07-30 09:18:42 +0800 (Wed, 30 Jul 2008) $
+ */
+public class DependencyManager {
+
+    //
+    // Map from child to a list of parents
+    //
+    private final Map childToParentMap = new HashMap();
+
+    //
+    // Map from parent back to a list of its children
+    //
+    private final Map parentToChildMap = new HashMap();
+
+
+    /**
+     *
+     */
+    public void close() {
+        childToParentMap.clear();
+        parentToChildMap.clear();
+    }
+
+
+    /**
+     * Declares a dependency from a child to a parent.
+     *
+     * @param child the dependent component
+     * @param parent the component the child is depending on
+     */
+    public void addDependency(Artifact child, Artifact parent) {
+        Trace.tracePoint("Entry", "DependencyManager.addDependency", child, parent);
+
+        Set parents = (Set) childToParentMap.get(child);
+        if (parents == null) {
+            parents = new LinkedHashSet();
+            childToParentMap.put(child, parents);
+        }
+        parents.add(parent);
+
+        Set children = (Set) parentToChildMap.get(parent);
+        if (children == null) {
+            children = new LinkedHashSet();
+            parentToChildMap.put(parent, children);
+        }
+        children.add(child);
+
+        Trace.tracePoint("Exit ", "DependencyManager.addDependency", childToParentMap.size() );
+        Trace.tracePoint("Exit ", "DependencyManager.addDependency", parentToChildMap.size() );
+    }
+
+
+    /**
+     * Removes a dependency from a child to a parent
+     *
+     * @param child the dependnet component
+     * @param parent the component that the child wil no longer depend on
+     */
+    public void removeDependency(Artifact child, Artifact parent) {
+        Trace.tracePoint("Entry", "DependencyManager.removeDependency", child, parent);
+
+        Set parents = (Set) childToParentMap.get(child);
+        if (parents != null) {
+            parents.remove(parent);
+        }
+
+        Set children = (Set) parentToChildMap.get(parent);
+        if (children != null) {
+            children.remove(child);
+        }
+
+        Trace.tracePoint("Exit ", "DependencyManager.addDependency");
+    }
+
+
+    /**
+     * Removes all dependencies for a child
+     *
+     * @param child the component that will no longer depend on anything
+     */
+    public void removeAllDependencies(Artifact child) {
+        Trace.tracePoint("Entry", "DependencyManager.removeAllDependencies", child);
+
+        Set parents = (Set) childToParentMap.remove(child);
+        if (parents == null) {
+            return;
+        }
+
+        for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+            Artifact parent = (Artifact) iterator.next();
+            Set children = (Set) parentToChildMap.get(parent);
+            if (children != null) {
+                children.remove(child);
+            }
+        }
+
+        Trace.tracePoint("Exit ", "DependencyManager.removeAllDependencies");
+    }
+
+
+    /**
+     * Adds dependencies from the child to every parent in the parents set
+     *
+     * @param child the dependent component
+     * @param parents the set of components the child is depending on
+     */
+    public void addDependencies(Artifact child, Set parents) {
+        Trace.tracePoint("Entry", "DependencyManager.addDependencies", child, parents);
+
+        Set existingParents = (Set) childToParentMap.get(child);
+        if (existingParents == null) {
+            existingParents = new LinkedHashSet(parents);
+            childToParentMap.put(child, existingParents);
+        }
+        else {
+            existingParents.addAll(parents);
+        }
+
+        for (Iterator i = parents.iterator(); i.hasNext();) {
+            Object startParent = i.next();
+            Set children = (Set) parentToChildMap.get(startParent);
+            if (children == null) {
+                children = new LinkedHashSet();
+                parentToChildMap.put(startParent, children);
+            }
+            children.add(child);
+        }
+
+        Trace.tracePoint("Exit ", "DependencyManager.addDependencies");
+    }
+
+
+    /**
+     * Gets the set of parents that the child is depending on
+     *
+     * @param child the dependent component
+     * @return a collection containing all of the components the child depends on; will never be null
+     */
+    public Set getParents(Artifact child) {
+        Trace.tracePoint("Entry", "DependencyManager.getParents", child);
+
+        Set parents = (Set) childToParentMap.get(child);
+        if (parents == null) {
+            Trace.tracePoint("Exit", "DependencyManager.getParents", 0);
+            return Collections.EMPTY_SET;
+        }
+
+        Trace.tracePoint("Exit", "DependencyManager.getParents", parents.size() );
+        return new LinkedHashSet(parents);
+    }
+
+
+    /**
+     * Gets all of the children that have a dependency on the specified parent.
+     *
+     * @param parent the component the returned childen set depend on
+     * @return a collection containing all of the components that depend on the parent; will never be null
+     */
+    public Set getChildren(Artifact parent) {
+        Trace.tracePoint("Entry", "DependencyManager.getChildren", parent);
+
+        Set children = (Set) parentToChildMap.get(parent);
+        if (children == null) {
+            Trace.tracePoint("Exit ", "DependencyManager.getChildren", 0);
+            return Collections.EMPTY_SET;
+        }
+
+        Trace.tracePoint("Exit ", "DependencyManager.getChildren", children.size() );
+        return new LinkedHashSet(children);
+    }
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/JAXB21Utils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/JAXB21Utils.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/JAXB21Utils.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/JAXB21Utils.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.core.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+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 javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.geronimo.st.core.Activator;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.apache.geronimo.st.core.jaxb.IJAXBUtilsProvider;
+import org.apache.geronimo.st.core.jaxb.NamespaceFilter;
+import org.apache.geronimo.st.v21.core.jaxb.MarshallerListener;
+import org.apache.geronimo.st.v21.core.jaxb.NamespacePrefix;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class JAXB21Utils implements IJAXBUtilsProvider{
+
+    // JAXBContext instantiation is costly - must be done only once!
+    private static final JAXBContext jaxbContext = newJAXBContext();
+    private static final JAXBContext jaxbPluginContext = newJAXBPluginContext();
+    private static final MarshallerListener marshallerListener = new MarshallerListener();
+    //private static JAXB21Utils _instance = new JAXB21Utils();
+    
+    private static JAXBContext newJAXBContext() {
+        try {
+            return JAXBContext.newInstance( 
+                    "org.apache.geronimo.jee.connector:" +
+                    "org.apache.geronimo.jee.loginconfig:" +
+                    "org.apache.geronimo.jee.openejb:" +
+                    "org.apache.geronimo.jee.web:" +
+                    "org.apache.geronimo.jee.application:" +
+                    "org.apache.geronimo.jee.applicationclient:" +
+                    "org.apache.geronimo.jee.deployment:" +
+                    "org.apache.geronimo.jee.naming:" +
+                    "org.apache.geronimo.jee.security:", Activator.class.getClassLoader() );
+        } catch (JAXBException e) {
+            Trace.tracePoint("JAXBException", "JAXBContext.newInstance");
+            e.printStackTrace();
+        }
+        return null;
+    }
+    
+    /*private JAXB21Utils(){
+    }
+    
+    public static JAXB21Utils getInstance(){
+    	return _instance;
+    }*/
+    
+    public JAXBContext getJAXBContext(){
+        return jaxbContext;
+    }
+
+    private static JAXBContext newJAXBPluginContext() {
+        try {
+            return JAXBContext.newInstance( 
+                    "org.apache.geronimo.system.plugin.model", Activator.class.getClassLoader() );
+        } catch (JAXBException e) {
+            Trace.tracePoint("JAXBException", "JAXBContext.newInstance");
+            e.printStackTrace();
+        }
+        return null;
+    }
+    
+    public void marshalDeploymentPlan(JAXBElement jaxbElement, IFile file) throws Exception {
+        try {
+            Marshaller marshaller = jaxbContext.createMarshaller();
+            marshaller.setListener(marshallerListener);
+
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            Document doc = db.newDocument(); 
+
+            marshaller.marshal(jaxbElement, doc);
+
+            TransformerFactory xf = TransformerFactory.newInstance();
+            try {
+            	xf.setAttribute("indent-number", new Integer(4));
+            } catch (IllegalArgumentException iae) {
+                //ignore this. http://forums.sun.com/thread.jspa?threadID=562510&messageID=2841867
+            }
+            Transformer xformer = xf.newTransformer();
+            xformer.setOutputProperty(OutputKeys.METHOD, "xml");
+            xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            xformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "4"); 
+
+            ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
+            Result out = new StreamResult(new OutputStreamWriter(outBuffer,"UTF-8"));
+            NamespacePrefix.processPrefix(doc);
+
+            xformer.transform(new DOMSource(doc), out);
+            ByteArrayInputStream inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
+            if(file.exists()) {
+                file.setContents(inBuffer, true, false, null);
+            } else {
+                prepareFolder(file.getParent());
+                file.create(inBuffer, true, null);
+            }
+        } catch (JAXBException jaxbException) {
+            Trace.tracePoint("JAXBException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
+            throw jaxbException;
+        } catch (CoreException coreException) {
+            Trace.tracePoint("CoreException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
+            throw coreException;
+        } catch (ParserConfigurationException e) {
+        	Trace.tracePoint("ParserConfigurationException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
+        	throw e;
+		} catch (TransformerConfigurationException e) {
+			Trace.tracePoint("TransformerConfigurationException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
+			throw e;
+		} catch (UnsupportedEncodingException e) {
+			Trace.tracePoint("UnsupportedEncodingException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
+			throw e;
+		} catch (TransformerException e) {
+			Trace.tracePoint("TransformerException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
+			throw e;
+		}
+    }
+
+    public JAXBElement unmarshalFilterDeploymentPlan(IFile file) throws Exception {
+        try {
+            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            factory.setValidating(false);
+            SAXParser parser = factory.newSAXParser();
+            NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
+            SAXSource source = new SAXSource(xmlFilter, new InputSource(file.getContents()));
+            JAXBElement plan = (JAXBElement) unmarshaller.unmarshal(source);
+            return plan;
+        } catch (JAXBException e) {
+            Trace.tracePoint("JAXBException", "JAXBUtils.unmarshalFilterDeploymentPlan()", file.getFullPath());
+            throw e;
+        } catch (CoreException e) {
+            Trace.tracePoint("CoreException", "JAXBUtils.unmarshalFilterDeploymentPlan()", file.getFullPath());
+            throw e;
+        } catch (ParserConfigurationException e) {
+            Trace.tracePoint("ParserConfigurationException", "JAXBUtils.unmarshalFilterDeploymentPlan()", file.getFullPath());
+            throw e;
+        } catch (SAXException e) {
+            Trace.tracePoint("SAXException", "JAXBUtils.unmarshalFilterDeploymentPlan()", file.getFullPath());
+            throw e;
+        }
+    }
+
+    public void marshalPlugin(JAXBElement jaxbElement, OutputStream outputStream) throws Exception {
+        try {
+            Marshaller marshaller = jaxbPluginContext.createMarshaller();
+            marshaller.setListener(marshallerListener);
+
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            Document doc = db.newDocument(); 
+
+            marshaller.marshal(jaxbElement, doc);
+
+            TransformerFactory xf = TransformerFactory.newInstance();
+            try {
+                xf.setAttribute("indent-number", new Integer(4));
+            } catch (IllegalArgumentException iae) {
+                //ignore this. http://forums.sun.com/thread.jspa?threadID=562510&messageID=2841867
+            }
+            Transformer xformer = xf.newTransformer();
+            xformer.setOutputProperty(OutputKeys.METHOD, "xml");
+            xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            xformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "4"); 
+
+            ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
+            Result out = new StreamResult(new OutputStreamWriter(outBuffer,"UTF-8"));
+
+            xformer.transform(new DOMSource(doc), out);
+            ByteArrayInputStream inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
+            outputStream.write(outBuffer.toByteArray());
+        } catch (JAXBException jaxbException) {
+            Trace.tracePoint("JAXBException", "JAXBUtils.marshalDeploymentPlan()");
+            throw jaxbException;
+        } catch (IOException coreException) {
+            Trace.tracePoint("IOException", "JAXBUtils.marshalDeploymentPlan()");
+            throw coreException;
+        } catch (ParserConfigurationException e) {
+            Trace.tracePoint("ParserConfigurationException", "JAXBUtils.marshalDeploymentPlan()");
+            throw e;
+        } catch (TransformerConfigurationException e) {
+            Trace.tracePoint("TransformerConfigurationException", "JAXBUtils.marshalDeploymentPlan()");
+            throw e;
+        } catch (TransformerException e) {
+            Trace.tracePoint("TransformerException", "JAXBUtils.marshalDeploymentPlan()");
+            throw e;
+        }
+    }
+
+    public JAXBElement unmarshalPlugin(InputStream inputStream) {
+        try {
+            Unmarshaller unmarshaller = jaxbPluginContext.createUnmarshaller();
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            factory.setValidating(false);
+            SAXParser parser = factory.newSAXParser();
+            NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
+            SAXSource source = new SAXSource(xmlFilter, new InputSource(inputStream));
+            JAXBElement plan = (JAXBElement) unmarshaller.unmarshal(source);
+            return plan;
+        } catch (JAXBException e) {
+            Trace.tracePoint("JAXBException", "JAXBUtils.unmarshalFilterDeploymentPlan()");
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            Trace.tracePoint("ParserConfigurationException", "JAXBUtils.unmarshalFilterDeploymentPlan()");
+            e.printStackTrace();
+        } catch (SAXException e) {
+            Trace.tracePoint("SAXException", "JAXBUtils.unmarshalFilterDeploymentPlan()");
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private void prepareFolder(IContainer folder) throws CoreException {
+        if (folder.exists() || !(folder instanceof IFolder)) {
+            return;
+        }
+        // prepare the upper level folders recursively
+        prepareFolder(folder.getParent());
+        ((IFolder) folder).create(true, true, null);
+    }
+
+    public Object getValue( Object element, String name ) throws Exception {
+        try {
+            if (String.class.isInstance(element))
+                return (String)element;
+            Method method = element.getClass().getMethod( "get" + name, null);
+            return method.invoke(element, null);
+        } catch ( Exception e ) {
+            throw e;
+        }
+    }
+    
+    public void setValue( Object element, String name, Object value ) throws Exception {
+        try {
+            Method[] methods = element.getClass().getMethods();
+            for ( Method method: methods) {
+                if ( method.getName().equals( "set" + name ) ) {
+                    method.invoke( element, value );
+                    return;
+                }
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        System.out.println( "============== No such method set" + name + " in class " + element.getClass().getName() );
+    }
+}

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/Trace.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/Trace.java?rev=952535&r1=952534&r2=952535&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/Trace.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/Trace.java Tue Jun  8 04:40:16 2010
@@ -71,8 +71,9 @@ public class Trace {
      *            a throwable
      */
     public static void trace(byte level, String s, Throwable t) {
-        if (!Activator.getDefault().isDebugging())
-            return;
+    	if (Activator.getDefault() == null
+				|| !Activator.getDefault().isDebugging())
+			return;
 
         System.out.println(Activator.PLUGIN_ID + ":  " + s);
         if (t != null)

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/MarshallerListener.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/MarshallerListener.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/MarshallerListener.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/MarshallerListener.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.core.jaxb;
+
+import javax.xml.bind.Marshaller;
+
+import org.apache.geronimo.jee.naming.GbeanLocator;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.jee.naming.PersistenceContextRef;
+import org.apache.geronimo.jee.naming.ResourceLocator;
+import org.apache.geronimo.jee.openejb.EjbRelationshipRole;
+import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.openejb.Relationships;
+import org.apache.geronimo.jee.security.Security;
+import org.apache.geronimo.jee.web.WebApp;
+
+public class MarshallerListener extends Marshaller.Listener{
+
+    @Override
+    public void beforeMarshal(Object source) {
+        if (source instanceof Security) {
+            Security security = (Security)source;
+            if (security.getRoleMappings() != null && security.getRoleMappings().getRole().size() == 0) {
+                security.setRoleMappings(null);
+            } 
+        } else if (source instanceof WebApp) {
+            WebApp webapp = (WebApp)source;
+            GbeanLocator gbeanlocator = webapp.getWebContainer();
+            if (gbeanlocator != null && isEmpty(gbeanlocator.getGbeanLink()) && isEmpty(gbeanlocator.getPattern())) {
+                webapp.setWebContainer(null);
+            }
+        } else if (source instanceof OpenejbJar) {
+            OpenejbJar openejb = (OpenejbJar)source;
+            ResourceLocator locator = openejb.getCmpConnectionFactory();
+            if (locator != null && isEmpty(locator.getResourceLink()) && isEmpty(locator.getUrl()) && isEmpty(locator.getPattern())) {
+                openejb.setCmpConnectionFactory(null);
+            }
+            Relationships relationships = openejb.getRelationships();
+            if (relationships != null && relationships.getEjbRelation().size() == 0) {
+                openejb.setRelationships(null);
+            }
+        } else if (source instanceof PersistenceContextRef) {
+            PersistenceContextRef contextRef = (PersistenceContextRef)source;
+            if (contextRef.getPattern() != null && isEmpty(contextRef.getPattern())) {
+                contextRef.setPattern(null);
+            }
+        } else if (source instanceof EjbRelationshipRole) {
+            EjbRelationshipRole role = (EjbRelationshipRole)source;
+            if (role.getRoleMapping() != null && role.getRoleMapping().getCmrFieldMapping().size() == 0) {
+                role.setRoleMapping(null);
+            }
+        }
+    }
+        
+    private boolean isEmpty(Pattern pattern) {
+        if ( pattern == null ) {
+            return true;
+        }
+        if ( isEmpty(pattern.getGroupId()) && isEmpty(pattern.getArtifactId()) &&
+                isEmpty(pattern.getModule()) && isEmpty(pattern.getName()) &&
+                isEmpty(pattern.getVersion()) ) {
+            return true;
+        }
+        return false;
+    }
+    
+    private boolean isEmpty(String value) {
+        
+        return (value == null || value.trim().equals(""));
+    }
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/NamespacePrefix.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/NamespacePrefix.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/NamespacePrefix.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/NamespacePrefix.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.st.v21.core.jaxb;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
+
+/**
+ * @version $Rev: 815171 $ $Date: 2009-09-15 14:55:16 +0800 (Tue, 15 Sep 2009) $ 
+ */
+public class NamespacePrefix extends NamespacePrefixMapper{
+
+    private static Map<String, String> prefixMap = new HashMap<String, String>();
+
+    static {
+        prefixMap.put("http://geronimo.apache.org/xml/ns/deployment-1.2", "dep");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/j2ee/application-2.0", "app");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0", "client");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/j2ee/connector-1.2", "conn");
+        prefixMap.put("http://openejb.apache.org/xml/ns/openejb-jar-2.2", "ejb");
+        prefixMap.put("http://java.sun.com/xml/ns/persistence", "pers");
+        prefixMap.put("http://openejb.apache.org/xml/ns/pkgen-2.1", "pkgen");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/naming-1.2", "name");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/security-2.0", "sec");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1", "web");
+        prefixMap.put("http://geronimo.apache.org/xml/ns/loginconfig-2.0", "log");
+    }
+	
+	public static void processPrefix( Node parent ) {
+		NodeList nl = parent.getChildNodes();
+		
+		if ( parent instanceof Element ) {
+			updatePrefix( (Element)parent );
+		}
+		
+		for ( int i = 0; i <= nl.getLength(); i ++ ) {
+			Node node = nl.item(i);
+			if ( node instanceof Element ) {
+				processPrefix( node );
+			}
+		}
+
+	}
+	
+	private static void updatePrefix( Element element ) {
+		NamedNodeMap mnm = element.getAttributes();
+		
+		ArrayList<Attr> attributes = new ArrayList<Attr>();
+		for ( int j = 0; j <= mnm.getLength(); j ++ ) { 
+			Attr attr = (Attr)mnm.item(j);
+			if ( attr != null && attr.getOwnerElement() != null && getPrefix( attr.getNodeValue() ) != null ) {
+				attributes.add((Attr)attr.cloneNode(false));
+			}
+		}
+		for ( int j = 0; j < attributes.size(); j ++ ) {
+			Attr tempAttr = attributes.get(j);
+			Attr attr = element.getAttributeNode(tempAttr.getName());
+			Element owner = (Element)attr.getOwnerElement();
+			owner.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + getPrefix( attr.getNodeValue() ), attr.getNodeValue());
+			owner.removeAttributeNode(attr);
+		}
+		String prefix = getPrefix( element.getNamespaceURI() );
+		if ( prefix != null ) {
+		    element.setPrefix( prefix );
+		}
+	}
+
+	private static String getPrefix(String namespaceURI) {
+        if (prefixMap.containsKey(namespaceURI))
+            return prefixMap.get(namespaceURI);
+		return null;
+	}
+
+	@Override
+	public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
+
+        if (prefixMap.containsKey(namespaceUri))
+            return prefixMap.get(namespaceUri);
+
+        return suggestion;
+    }
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/DeploymentPlanCreationOperation.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/DeploymentPlanCreationOperation.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/DeploymentPlanCreationOperation.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/DeploymentPlanCreationOperation.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.core.operations;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.core.operations.AbstractGeronimoJ2EEComponentOperation;
+import org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp;
+import org.apache.geronimo.st.v21.core.Activator;
+import org.apache.geronimo.st.v21.core.GeronimoUtils;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public abstract class DeploymentPlanCreationOperation extends
+		AbstractGeronimoJ2EEComponentOperation implements
+		IDeploymentPlanCreationOp {
+	
+	protected Object config;
+
+	public DeploymentPlanCreationOperation(IDataModel model, Object config) {
+		super(model);
+		this.config = config;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
+	 *      org.eclipse.core.runtime.IAdaptable)
+	 */
+	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+			throws ExecutionException {
+		try {
+			execute();
+		}catch (Exception e){
+			return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Error in creating deployment plan",e);
+		}
+		return Status.OK_STATUS;
+	}
+
+	public void execute() throws Exception {
+		IVirtualComponent comp = ComponentCore.createComponent(getProject());
+
+		String type = J2EEProjectUtilities.getJ2EEProjectType(getProject());
+
+		if (IModuleConstants.JST_WEB_MODULE.equals(type)) {
+			createGeronimoWebDeploymentPlan(GeronimoUtils.getWebDeploymentPlanFile(comp));			
+		} else if (IModuleConstants.JST_EJB_MODULE.equals(type)) {
+			createOpenEjbDeploymentPlan(GeronimoUtils.getOpenEjbDeploymentPlanFile(comp));
+		} else if (IModuleConstants.JST_EAR_MODULE.equals(type)) {
+			createGeronimoApplicationDeploymentPlan(GeronimoUtils.getApplicationDeploymentPlanFile(comp));
+		} else if (IModuleConstants.JST_APPCLIENT_MODULE.equals(type)) {
+			createGeronimoApplicationClientDeploymentPlan(GeronimoUtils.getApplicationClientDeploymentPlanFile(comp));
+		} else if (IModuleConstants.JST_CONNECTOR_MODULE.equals(type)) {
+			createConnectorDeploymentPlan(GeronimoUtils.getConnectorDeploymentPlanFile(comp));
+		} else if (IModuleConstants.JST_UTILITY_MODULE.equals(type)) {
+			createServiceDeploymentPlan(GeronimoUtils.getServiceDeploymentPlanFile(comp));
+		}
+	}
+
+	
+	public JAXBElement createOpenEjbDeploymentPlan(IFile file) throws Exception {
+		return null;
+	}
+
+	public JAXBElement createGeronimoWebDeploymentPlan(IFile file) throws Exception {
+		return null;
+	}
+
+	public JAXBElement createGeronimoApplicationDeploymentPlan(IFile file) throws Exception {
+		return null;
+	}
+
+	public JAXBElement createGeronimoApplicationClientDeploymentPlan(IFile file) throws Exception{
+		return null;
+	}
+
+	public JAXBElement createConnectorDeploymentPlan(IFile file) throws Exception{
+		return null;
+	}
+	
+
+	public JAXBElement createServiceDeploymentPlan(IFile file) throws Exception{
+		return null;
+	}
+}

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java?rev=952535&r1=952534&r2=952535&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerPluginManager.java Tue Jun  8 04:40:16 2010
@@ -53,8 +53,8 @@ import org.apache.geronimo.kernel.reposi
 import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.st.core.CommonMessages;
-import org.apache.geronimo.st.core.GeronimoConnectionFactory;
-import org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v21.core.GeronimoConnectionFactory;
+import org.apache.geronimo.st.v21.core.GeronimoServerBehaviourDelegate;
 import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.st.v21.core.internal.Trace;
 import org.apache.geronimo.system.jmx.KernelDelegate;

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanDataModelProvider.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanDataModelProvider.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanDataModelProvider.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanDataModelProvider.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.core.operations;
+
+import java.util.Set;
+
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+/**
+ * @version $Rev: 471551 $ $Date: 2006-11-06 06:47:11 +0800 (Mon, 06 Nov 2006) $
+ */
+public class ImportDeploymentPlanDataModelProvider extends AbstractDataModelProvider {
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider#getPropertyNames()
+	 */
+	public Set getPropertyNames() {
+		Set names = super.getPropertyNames();
+		names.add(IFacetDataModelProperties.FACET_PROJECT_NAME);
+		names.add(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
+		return names;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider#getDefaultOperation()
+	 */
+	public IDataModelOperation getDefaultOperation() {
+		return new ImportDeploymentPlanOperation(model);
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanOperation.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanOperation.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanOperation.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/ImportDeploymentPlanOperation.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.core.operations;
+
+import org.apache.geronimo.st.v21.core.GeronimoUtils;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.apache.geronimo.st.core.jaxb.ConversionHelper;
+import org.apache.geronimo.st.core.operations.AbstractGeronimoJ2EEComponentOperation;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+/**
+ * @version $Rev: 650735 $ $Date: 2008-04-23 11:35:03 +0800 (Wed, 23 Apr 2008) $
+ */
+public class ImportDeploymentPlanOperation extends AbstractGeronimoJ2EEComponentOperation {
+
+    /**
+     * 
+     */
+    public ImportDeploymentPlanOperation() {
+        super();
+        Trace.tracePoint("Constructor", "ImportDeploymentPlanOperation");
+    }
+
+    /**
+     * @param model
+     */
+    public ImportDeploymentPlanOperation(IDataModel model) {
+        super(model);
+        Trace.tracePoint("Constructor", "ImportDeploymentPlanOperation", model);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
+     *      org.eclipse.core.runtime.IAdaptable)
+     */
+    public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+        Trace.tracePoint("Entry", "ImportDeploymentPlanOperation.execute", monitor, info);
+
+        if (!isGeronimoRuntimeTarget())
+            return Status.OK_STATUS;
+
+        IVirtualComponent comp = ComponentCore.createComponent(getProject());
+        String type = J2EEProjectUtilities.getJ2EEProjectType(getProject());
+
+        IFile planFile = null;
+
+        try {
+            if (type.equals(IModuleConstants.JST_WEB_MODULE)) {
+                planFile = GeronimoUtils.getWebDeploymentPlanFile(comp);
+                ConversionHelper.convertGeronimoWebFile(planFile);    
+            }
+            else if (type.equals(IModuleConstants.JST_EJB_MODULE)) {
+                planFile = GeronimoUtils.getOpenEjbDeploymentPlanFile(comp);
+                ConversionHelper.convertOpenEjbJarFile(planFile);
+            }
+            else if (type.equals(IModuleConstants.JST_EAR_MODULE)) {
+                planFile = GeronimoUtils.getApplicationDeploymentPlanFile(comp);
+                ConversionHelper.convertGeronimoApplicationFile(planFile);
+            }
+            else if (type.equals(IModuleConstants.JST_CONNECTOR_MODULE)) {
+                planFile = GeronimoUtils.getConnectorDeploymentPlanFile(comp);
+                ConversionHelper.convertGeronimoRaFile(planFile);
+            }
+            else if (type.equals(IModuleConstants.JST_APPCLIENT_MODULE)) {
+                planFile = GeronimoUtils.getApplicationClientDeploymentPlanFile(comp);
+                ConversionHelper.convertGeronimoApplicationClientFile(planFile);
+            }
+        }
+        catch (Exception e) {
+            throw new ExecutionException("ImportDeploymentPlanOperation.execute(): Error converting plan: " + planFile.getFullPath() );
+        }
+
+        Trace.tracePoint("Exit ", "ImportDeploymentPlanOperation.execute", Status.OK_STATUS);
+        return Status.OK_STATUS;
+    }
+}



Mime
View raw message