geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r921247 [3/11] - in /geronimo/devtools/eclipse-plugin/trunk: ./ features/org.apache.geronimo.v30.feature/ plugins/org.apache.geronimo.runtime.v30/ plugins/org.apache.geronimo.runtime.v30/META-INF/ plugins/org.apache.geronimo.st.v30.core/ pl...
Date Wed, 10 Mar 2010 08:31:32 GMT
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,265 @@
+/*
+ * 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;
+
+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.Environment;
+import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.web.WebApp;
+import org.apache.geronimo.st.core.GeronimoUtils;
+import org.apache.geronimo.st.core.internal.Trace;
+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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoV21Utils extends GeronimoUtils {
+
+    public static JAXBElement getDeploymentPlan(IFile file) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getDeploymentPlan", file);
+
+        if (!file.exists()) {
+            return null;
+        }
+
+        if (file.getName().equals(GeronimoUtils.APP_PLAN_NAME))
+            return getApplicationDeploymentPlan(file);
+        else if (file.getName().equals(GeronimoUtils.OPENEJB_PLAN_NAME))
+            return getOpenEjbDeploymentPlan(file);
+        else if (file.getName().equals(GeronimoUtils.WEB_PLAN_NAME))
+            return getWebDeploymentPlan(file);
+        else if (file.getName().equals(GeronimoUtils.CONNECTOR_PLAN_NAME))
+            return getConnectorDeploymentPlan(file);
+        else if (file.getName().equals(GeronimoUtils.APP_CLIENT_PLAN_NAME))
+            return getApplicationClientDeploymentPlan(file);
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getDeploymentPlan", null);
+        return null;
+    }
+
+    //public static String getConfigId2(IModule module) {
+    //    Trace.tracePoint("ENTRY", "GeronimoV21Utils.getConfigId2", module);
+
+    //    IFile planFile = null;
+    //   IVirtualComponent comp = ComponentCore.createComponent(module.getProject());
+    //    if (isWebModule(module)) {
+    //        planFile = GeronimoUtils.getWebDeploymentPlanFile(comp);
+    //   }
+    //    else if (isEjbJarModule(module)) {
+    //        planFile = GeronimoUtils.getOpenEjbDeploymentPlanFile(comp);
+    //    }
+    //    else if (isEarModule(module)) {
+    //       planFile = GeronimoUtils.getApplicationDeploymentPlanFile(comp);
+    //    }
+    //    else if (isRARModule(module)) {
+    //        planFile = GeronimoUtils.getConnectorDeploymentPlanFile(comp);
+    //    }
+
+    //    if (planFile != null) {
+    //       try {
+    //            XmlObject xmlObject = XmlBeansUtil.parse(planFile.getLocation().toFile());
+    //            XmlCursor cursor = xmlObject.newCursor();
+    //            cursor.toFirstChild();
+    //            xmlObject = cursor.getObject();
+    //            XmlObject result[] = xmlObject.selectChildren(QNameSet.singleton(EnvironmentDocument.type.getDocumentElementName()));
+    //            if (result != null && result.length > 0) {
+    //                org.apache.geronimo.deployment.xbeans.EnvironmentType env = (org.apache.geronimo.deployment.xbeans.EnvironmentType) result[0].changeType(org.apache.geronimo.deployment.xbeans.EnvironmentType.type);
+    //                org.apache.geronimo.deployment.xbeans.ArtifactType moduleId = env.getModuleId();
+    //                Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId2", getQualifiedConfigID(moduleId));
+    //                return getQualifiedConfigID(moduleId);
+    //            }
+    //            else {
+                    // 
+                    // FIXME -- Once GERONIMODEVTOOLS-263 is resolved
+                    // 
+    //                String id = getConfigId(module);
+    //                Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId2", id);
+    //                return id;
+    //            }
+    //        }
+    //        catch (IOException e) {
+    //            e.printStackTrace();
+    //        }
+    //        catch (XmlException e) {
+    //            e.printStackTrace();
+    //        }
+    //    }
+
+    //    Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId2", null);
+    //    return null;
+    //}
+
+    public static String getConfigId(IModule module) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getConfigId", module);
+
+        Environment environment = null;
+        if (isWebModule(module)) {
+            if (getWebDeploymentPlan(module)!=null) {
+            	WebApp plan = getWebDeploymentPlan(module).getValue();
+            	if (plan != null)
+            		environment = plan.getEnvironment();
+            }
+        }
+        else if (isEjbJarModule(module)) {
+        	   if (getOpenEjbDeploymentPlan(module)!=null) {
+		            OpenejbJar plan = getOpenEjbDeploymentPlan(module).getValue();
+		            if (plan != null)
+		            	environment = plan.getEnvironment();
+        	   }
+        }
+        else if (isEarModule(module)) {
+        	if (getApplicationDeploymentPlan(module)!=null) {
+        		Application plan = getApplicationDeploymentPlan(module).getValue();
+        		if (plan != null)
+        			environment = plan.getEnvironment();
+        	}
+        }
+        else if (isRARModule(module)) {
+        	if (getConnectorDeploymentPlan(module)!=null) {
+	            Connector plan = getConnectorDeploymentPlan(module).getValue();
+	            if (plan != null)
+	                environment = plan.getEnvironment();
+        	}
+        }
+
+        if (environment != null
+            && environment.getModuleId() != null) {
+            Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId", getQualifiedConfigID(environment.getModuleId()));
+            return getQualifiedConfigID(environment.getModuleId());
+        }
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId", getId(module));
+        return getId(module);
+    }
+
+    public static String getQualifiedConfigID(Artifact artifact) {
+        return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
+    }
+
+    //public static String getQualifiedConfigID(org.apache.geronimo.deployment.xbeans.ArtifactType artifact) {
+    //    return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
+    //}
+
+    public static String getContextRoot(IModule module) throws Exception {
+        String contextRoot = null;
+
+        WebApp deploymentPlan = getWebDeploymentPlan(module).getValue();
+        if (deploymentPlan != null)
+            contextRoot = deploymentPlan.getContextRoot();
+
+        if (contextRoot == null)
+            contextRoot = GeronimoUtils.getContextRoot(module);
+
+        return contextRoot;
+    }
+
+    public static JAXBElement<WebApp> getWebDeploymentPlan(IModule module) throws Exception {
+        return getWebDeploymentPlan(getVirtualComponent(module));
+    }
+
+    public static JAXBElement<Application> getApplicationDeploymentPlan(IModule module) throws Exception {
+        return getApplicationDeploymentPlan(getVirtualComponent(module));
+    }
+
+    public static JAXBElement<OpenejbJar> getOpenEjbDeploymentPlan(IModule module) throws Exception {
+        return getOpenEjbDeploymentPlan(getVirtualComponent(module));
+    }
+
+    public static JAXBElement<Connector> getConnectorDeploymentPlan(IModule module) throws Exception {
+        return getConnectorDeploymentPlan(getVirtualComponent(module));
+    }
+
+    public static JAXBElement getApplicationDeploymentPlan(IVirtualComponent comp) throws Exception {
+        return getApplicationDeploymentPlan(getApplicationDeploymentPlanFile(comp));
+    }
+
+    public static JAXBElement getWebDeploymentPlan(IVirtualComponent comp) throws Exception {
+        return getWebDeploymentPlan(getWebDeploymentPlanFile(comp));
+    }
+
+    public static JAXBElement getOpenEjbDeploymentPlan(IVirtualComponent comp) throws Exception {
+        return getOpenEjbDeploymentPlan(getOpenEjbDeploymentPlanFile(comp));
+    }
+
+    public static JAXBElement getConnectorDeploymentPlan(IVirtualComponent comp) throws Exception {
+        return getConnectorDeploymentPlan(getConnectorDeploymentPlanFile(comp));
+    }
+
+    public static JAXBElement getApplicationDeploymentPlan(IFile file) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getApplicationDeploymentPlan", file);
+
+        if (file.getName().equals(APP_PLAN_NAME) && file.exists()) {
+        	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+        }
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getApplicationDeploymentPlan", null);
+        return null;
+    }
+
+    public static JAXBElement getApplicationClientDeploymentPlan(IFile file) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getApplicationClientDeploymentPlan", file);
+
+        if (file.getName().equals(APP_CLIENT_PLAN_NAME) && file.exists()) {
+        	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+        }
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getApplicationClientDeploymentPlan", null);
+        return null;
+    }
+
+    public static JAXBElement getWebDeploymentPlan(IFile file) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getWebDeploymentPlan", file);
+
+        if (file.getName().equals(WEB_PLAN_NAME) && file.exists()) {
+        	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+        }
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getWebDeploymentPlan", null);
+        return null;
+    }
+
+    public static JAXBElement getOpenEjbDeploymentPlan(IFile file) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getOpenEjbDeploymentPlan", file);
+
+        if (file.getName().equals(OPENEJB_PLAN_NAME) && file.exists()) {
+        	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+        }
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getOpenEjbDeploymentPlan", null);
+        return null;
+    }
+
+    public static JAXBElement getConnectorDeploymentPlan(IFile file) throws Exception {
+        Trace.tracePoint("ENTRY", "GeronimoV21Utils.getConnectorDeploymentPlan", file);
+
+        if (file.getName().equals(CONNECTOR_PLAN_NAME) && file.exists()) {
+        	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+        }
+
+        Trace.tracePoint("EXIT", "GeronimoV21Utils.getConnectorDeploymentPlan", null);
+        return null;
+    }
+    
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21Utils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
+import org.apache.geronimo.st.core.IGeronimoVersionHandler;
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoV21VersionHandler implements IGeronimoVersionHandler {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#getConfigID(org.eclipse.wst.server.core.IModule)
+	 */
+	public String getConfigID(IModule module) throws Exception {
+		return GeronimoV21Utils.getConfigId(module);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#createTargetModuleId(java.lang.String)
+	 */
+	public TargetModuleID createTargetModuleId(String configId) {
+		return new TargetModuleIDImpl(null, configId);
+	}
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV21VersionHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java Wed Mar 10 08:31:28 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.internal;
+
+import org.apache.geronimo.st.v21.core.Activator;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * Helper class to route trace output.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Trace {
+
+    /**
+     * Finest trace event.
+     */
+    public static byte INFO = 0;
+
+    /**
+     * Warning trace event.
+     */
+    public static byte WARNING = 1;
+
+    /**
+     * Severe trace event.
+     */
+    public static byte SEVERE = 2;
+
+    /**
+     * Trace constructor comment.
+     */
+    private Trace() {
+        super();
+    }
+
+    /**
+     * Trace the given text.
+     * 
+     * @param level
+     *            the trace level
+     * @param s
+     *            a message
+     */
+    public static void trace(byte level, String s) {
+        trace(level, s, null);
+    }
+
+    /**
+     * Trace the given message and exception.
+     * 
+     * @param level
+     *            the trace level
+     * @param s
+     *            a message
+     * @param t
+     *            a throwable
+     */
+    public static void trace(byte level, String s, Throwable t) {
+        if (!Activator.getDefault().isDebugging())
+            return;
+
+        System.out.println(Activator.PLUGIN_ID + ":  " + s);
+        if (t != null)
+            t.printStackTrace();
+        
+    }
+
+    /**
+     * Trace the given message 
+     * 
+     * @param tracePoint
+     *            The trace point (e.g., "Exit", "Entry", "Constructor", etc....
+     *            
+     * @param classDotMethod
+     *            The class name + method name (e.g., "Class.method()")
+     *            
+     * @param parms
+     *            Method parameter(s) if the trace point is an "Entry"
+     *            or
+     *            Return value if the trace point is an "Exit"
+     */
+    public static void tracePoint(String tracePoint, String classDotMethod) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "()" );
+    }   
+    public static void tracePoint(String tracePoint, String classDotMethod, Object... parms) {
+        if ( parms == null ) {
+            trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( null )" );
+        }
+        else {
+            trace(Trace.INFO, tracePoint + ": " + classDotMethod + "(" );
+            for ( int ii=0; ii<parms.length; ii++) {
+                Object parm = parms[ii];
+                trace(Trace.INFO, "    parm" + (ii+1) + "=[" + (parm == null ? null : parm.toString()) + "]" );
+            }
+            trace(Trace.INFO, ")" );
+        }
+    }   
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Trace.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,184 @@
+/*
+ * 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.List;
+
+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.Environment;
+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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXBModelUtils {
+	
+    
+    public static Security getSecurity (JAXBElement element) {
+        Object plan = element.getValue();
+        if (WebApp.class.isInstance (plan)) {
+            if (((WebApp)plan).getSecurity() == null) {
+                return null;
+            }
+            Security security = (Security)((WebApp)plan).getSecurity().getValue();
+            return security;
+        } else if (Application.class.isInstance (plan)) {
+            if (((Application)plan).getSecurity() == null) {
+            	return null;
+            }
+            Security security = (Security)((Application)plan).getSecurity().getValue();
+            return security;
+        } else if (OpenejbJar.class.isInstance (plan)) {
+            if (((OpenejbJar)plan).getSecurity() == null) {
+            	return null;
+            }
+            Security security = (Security)((OpenejbJar)plan).getSecurity().getValue();
+            return security;
+        }
+        return null;
+    }
+    
+    public static void setSecurity (JAXBElement element, Security security) {
+        Object plan = element.getValue();
+        if (WebApp.class.isInstance (plan)) {
+            ((WebApp)plan).setSecurity((new org.apache.geronimo.jee.security.ObjectFactory()).createSecurity( security ) );
+        } else if (Application.class.isInstance(plan)) {
+            ((Application)plan).setSecurity((new org.apache.geronimo.jee.security.ObjectFactory()).createSecurity( security ) );
+        } else if (OpenejbJar.class.isInstance(plan)) {
+            ((OpenejbJar)plan).setSecurity((new org.apache.geronimo.jee.security.ObjectFactory()).createSecurity( security ) );
+        }
+    }
+
+    public static Environment getEnvironment(JAXBElement element) {
+        return getEnvironment (element, true);
+    }
+
+    public static Environment getEnvironment(JAXBElement element, boolean serverEnvironment) {
+        Object plan = element.getValue();
+        if (serverEnvironment == true) {
+            if (WebApp.class.isInstance (plan)) {
+                return ((WebApp)plan).getEnvironment();
+            } else if (Application.class.isInstance (plan)) {
+                return ((Application)plan).getEnvironment();
+            } else if (OpenejbJar.class.isInstance (plan)) {
+                return ((OpenejbJar)plan).getEnvironment();
+            } else if (Connector.class.isInstance (plan)) {
+                return ((Connector)plan).getEnvironment();
+            } else if (ApplicationClient.class.isInstance (plan)) {
+                return ((ApplicationClient)plan).getServerEnvironment();
+            }
+        } else {
+            if (ApplicationClient.class.isInstance (plan)) {
+                return ((ApplicationClient)plan).getClientEnvironment();
+            }
+        }
+        return null;
+    }
+
+    public static void setEnvironment (JAXBElement element, Environment environment) {
+        setEnvironment (element, environment, true);
+    }
+
+    public static void setEnvironment (JAXBElement element, Environment environment, boolean serverEnvironment) {
+        Object plan = element.getValue();
+        if (serverEnvironment == true) {
+            if (WebApp.class.isInstance (plan)) {
+                ((WebApp)plan).setEnvironment (environment);
+            } else if (Application.class.isInstance (plan)) {
+                ((Application)plan).setEnvironment (environment);
+            } else if (OpenejbJar.class.isInstance (plan)) {
+                ((OpenejbJar)plan).setEnvironment (environment);
+            } else if (Connector.class.isInstance (plan)) {
+                ((Connector)plan).setEnvironment (environment);
+            } else if (ApplicationClient.class.isInstance (plan)) {
+                ((ApplicationClient)plan).setServerEnvironment (environment);
+            }
+        } else {
+            if (ApplicationClient.class.isInstance (plan)) {
+                ((ApplicationClient)plan).setClientEnvironment (environment);
+            }
+        }
+    }
+
+    public static List getGbeans (JAXBElement element) {
+        Object plan = element.getValue();
+        if (WebApp.class.isInstance (plan)) {
+            return ((WebApp)plan).getServiceOrPersistence();
+        } else if (Application.class.isInstance (plan)) {
+            return ((Application)plan).getService();
+        } else if (OpenejbJar.class.isInstance (plan)) {
+            return ((OpenejbJar)plan).getService();
+        } else if (Connector.class.isInstance (plan)) {
+            return ((Connector)plan).getService();
+        } else if (ApplicationClient.class.isInstance (plan)) {
+            return ((ApplicationClient)plan).getService();
+        }
+        return null;
+    }
+
+    public static List getGbeanRefs (JAXBElement element) {
+        Object plan = element.getValue();
+        if (ApplicationClient.class.isInstance (plan)) {
+            return ((ApplicationClient)plan).getGbeanRef();
+        } else if (WebApp.class.isInstance (plan)) {
+            return ((WebApp)plan).getAbstractNamingEntry();
+        }
+        return null;
+    }
+
+    public static List getServiceRefs (JAXBElement element) {
+        Object plan = element.getValue();
+        if (WebApp.class.isInstance (plan)) {
+            return ((WebApp)plan).getServiceRef();
+        }
+        return null;
+    }
+
+    public static List getEjbRelationships (JAXBElement element) {
+        Object plan = element.getValue();
+        if (OpenejbJar.class.isInstance (plan)) {
+            return ((OpenejbJar)plan).getRelationships() == null ? null : ((OpenejbJar)plan).getRelationships().getEjbRelation();
+        }
+        return null;
+    }
+    
+    public static void setEjbRelationships (JAXBElement element, Relationships relationships ) {
+        Object plan = element.getValue();
+        if (OpenejbJar.class.isInstance (plan)) {
+            ((OpenejbJar)plan).setRelationships(relationships);
+        }
+    }
+    
+    public static List getMessageDestinations (JAXBElement element) {
+        Object plan = element.getValue();
+        if (WebApp.class.isInstance (plan)) {
+            return ((WebApp)plan).getMessageDestination();
+        } else if (OpenejbJar.class.isInstance (plan)) {
+            return ((OpenejbJar)plan).getMessageDestination();
+        } else if (ApplicationClient.class.isInstance (plan)) {
+            return ((ApplicationClient)plan).getMessageDestination();
+        }
+        return null;
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBModelUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,168 @@
+/*
+ * 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 org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
+import org.apache.geronimo.jee.application.ExtModule;
+import org.apache.geronimo.jee.application.Module;
+import org.apache.geronimo.jee.application.Path;
+import org.apache.geronimo.jee.connector.Adminobject;
+import org.apache.geronimo.jee.connector.AdminobjectInstance;
+import org.apache.geronimo.jee.connector.ConfigPropertySetting;
+import org.apache.geronimo.jee.deployment.Artifact;
+import org.apache.geronimo.jee.deployment.Attribute;
+import org.apache.geronimo.jee.deployment.ClassFilter;
+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.Gbean;
+import org.apache.geronimo.jee.deployment.Reference;
+import org.apache.geronimo.jee.naming.EjbRef;
+import org.apache.geronimo.jee.naming.EjbLocalRef;
+import org.apache.geronimo.jee.naming.GbeanRef;
+import org.apache.geronimo.jee.naming.MessageDestination;
+import org.apache.geronimo.jee.naming.PersistenceContextRef;
+import org.apache.geronimo.jee.naming.PersistenceUnitRef;
+import org.apache.geronimo.jee.naming.Port;
+import org.apache.geronimo.jee.naming.PortCompletion;
+import org.apache.geronimo.jee.naming.Property;
+import org.apache.geronimo.jee.naming.ServiceCompletion;
+import org.apache.geronimo.jee.naming.ResourceEnvRef;
+import org.apache.geronimo.jee.naming.ResourceRef;
+import org.apache.geronimo.jee.naming.ServiceRef;
+import org.apache.geronimo.jee.openejb.EjbRelation;
+import org.apache.geronimo.jee.openejb.EjbRelationshipRole;
+import org.apache.geronimo.jee.openejb.Relationships;
+import org.apache.geronimo.jee.security.Description;
+import org.apache.geronimo.jee.security.DistinguishedName;
+import org.apache.geronimo.jee.security.LoginDomainPrincipal;
+import org.apache.geronimo.jee.security.Principal;
+import org.apache.geronimo.jee.security.RealmPrincipal;
+import org.apache.geronimo.jee.security.RoleMappings;
+import org.apache.geronimo.jee.security.Role;
+import org.apache.geronimo.jee.security.Security;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXBObjectFactoryImpl implements JAXBObjectFactory {
+
+    private static JAXBObjectFactoryImpl instance = new JAXBObjectFactoryImpl();
+    
+    private JAXBObjectFactoryImpl() {
+        
+    }
+    
+    public static JAXBObjectFactoryImpl getInstance() {
+        return instance;
+    }
+    
+    public Object create(Class type) {
+        if ( type.equals( ResourceRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createResourceRef();
+        } else if ( type.equals( ResourceEnvRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createResourceEnvRef();
+        } else if ( type.equals( EjbRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createEjbRef();
+        } else if ( type.equals( GbeanRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createGbeanRef();
+        } else if ( type.equals( PersistenceContextRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPersistenceContextRef();
+        } else if ( type.equals( PersistenceUnitRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPersistenceUnitRef();
+        } else if ( type.equals( MessageDestination.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createMessageDestination();
+        } else if ( type.equals( org.apache.geronimo.jee.naming.Pattern.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPattern();
+        } else if ( type.equals( Port.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPort();
+        } else if ( type.equals( PortCompletion.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPortCompletion();
+        } else if ( type.equals( Property.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createProperty();
+        } else if ( type.equals( ServiceCompletion.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createServiceCompletion();
+        } else if ( type.equals( ServiceRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createServiceRef();
+        } else if ( type.equals( EjbLocalRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createEjbLocalRef();
+        } else if ( type.equals( Security.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createSecurity();
+        } else if ( type.equals( RoleMappings.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createRoleMappings();
+        } else if ( type.equals( Description.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createDescription();
+        } else if ( type.equals( Role.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createRole();
+        } else if ( type.equals( DistinguishedName.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createDistinguishedName();
+        } else if ( type.equals( Principal.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createPrincipal();
+        } else if ( type.equals( LoginDomainPrincipal.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createLoginDomainPrincipal();
+        } else if ( type.equals( RealmPrincipal.class ) ) {
+            return (new org.apache.geronimo.jee.security.ObjectFactory()).createRealmPrincipal();
+        } else if ( type.equals( Gbean.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createGbean();
+        } else if ( type.equals( Artifact.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createArtifact();
+        } else if ( type.equals( ClassFilter.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createClassFilter();
+        } else if ( type.equals( Dependencies.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createDependencies();
+        } else if ( type.equals( Dependency.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createDependency();
+        } else if ( type.equals( Environment.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createEnvironment();
+        } else if ( type.equals( org.apache.geronimo.jee.deployment.Pattern.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createPattern();
+        } else if ( type.equals( Attribute.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createAttribute();
+        } else if ( type.equals( Reference.class ) ) {
+            return (new org.apache.geronimo.jee.deployment.ObjectFactory()).createReference();
+        } else if ( type.equals( ExtModule.class ) ) {
+            return (new org.apache.geronimo.jee.application.ObjectFactory()).createExtModule();
+        } else if ( type.equals( Module.class ) ) {
+            return (new org.apache.geronimo.jee.application.ObjectFactory()).createModule();
+        } else if ( type.equals( Path.class ) ) {
+            return (new org.apache.geronimo.jee.application.ObjectFactory()).createPath();
+        } else if ( type.equals( EjbRelation.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelation();
+        } else if ( type.equals( EjbRelationshipRole.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRole();
+        } else if ( type.equals( EjbRelationshipRole.RelationshipRoleSource.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleRelationshipRoleSource();
+        } else if ( type.equals( EjbRelationshipRole.CmrField.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleCmrField();
+        } else if ( type.equals( EjbRelationshipRole.RoleMapping.CmrFieldMapping.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleRoleMappingCmrFieldMapping();
+        } else if ( type.equals( EjbRelationshipRole.RoleMapping.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleRoleMapping();
+        } else if ( type.equals( Relationships.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createRelationships();
+        } else if ( type.equals( Adminobject.class ) ) {
+            return (new org.apache.geronimo.jee.connector.ObjectFactory()).createAdminobject();
+        } else if ( type.equals( AdminobjectInstance.class ) ) {
+            return (new org.apache.geronimo.jee.connector.ObjectFactory()).createAdminobjectInstance();
+        } else if ( type.equals( ConfigPropertySetting.class ) ) {
+            return (new org.apache.geronimo.jee.connector.ObjectFactory()).createConfigPropertySetting();
+        }
+        
+        return null;
+    }
+
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/jaxb/JAXBObjectFactoryImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,761 @@
+/*
+ * 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.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.management.MBeanServerConnection;
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
+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.core.jaxb.JAXBUtils;
+import org.apache.geronimo.st.v21.core.internal.Trace;
+import org.apache.geronimo.system.jmx.KernelDelegate;
+import org.apache.geronimo.system.plugin.PluginInstaller;
+import org.apache.geronimo.system.plugin.model.ArtifactType;
+import org.apache.geronimo.system.plugin.model.DependencyType;
+import org.apache.geronimo.system.plugin.model.ObjectFactory;
+import org.apache.geronimo.system.plugin.model.PluginArtifactType;
+import org.apache.geronimo.system.plugin.model.PluginListType;
+import org.apache.geronimo.system.plugin.model.PluginType;
+import org.apache.geronimo.system.plugin.model.PrerequisiteType;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoServerPluginManager {
+
+    private IServer server;
+    private PluginListType data;
+    private List<String> pluginList;
+    private Kernel kernel;
+    private PluginInstaller pluginInstaller;
+
+    // The ServerWorkingCopy is passed in, not the IServer itself
+    public GeronimoServerPluginManager (IServer aServer) {
+        ServerWorkingCopy copy = (ServerWorkingCopy)aServer;
+        server = copy.getOriginal();
+        try {
+            if (server != null) {
+                GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) server
+                    .getAdapter(GeronimoServerBehaviourDelegate.class);
+                if (delegate != null) {
+                    MBeanServerConnection connection = delegate.getServerConnection();
+                    if (connection != null) {
+                        kernel = new KernelDelegate(connection);
+                    }
+                    pluginInstaller = getPluginInstaller();                
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            Trace.trace(Trace.WARNING, "Kernel connection failed. "
+                + e.getMessage());
+        }
+        Trace.tracePoint("Constructor", "GeronimoServerPluginManager");
+    }
+    
+    private PluginInstaller getPluginInstaller() {
+        Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
+        for (AbstractName name : set) {
+            return (PluginInstaller) kernel.getProxyManager().createProxy(name, PluginInstaller.class);
+        }
+        throw new IllegalStateException("No plugin installer found");
+    }
+    
+    public List<String> getPluginList () {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.getPluginList");
+
+        String name;
+        boolean added;
+        if (pluginInstaller != null){
+            try {
+                data = pluginInstaller.createPluginListForRepositories(null);
+
+                List<PluginType> aList = data.getPlugin();
+                pluginList = new ArrayList<String>(aList.size());
+                for (int i = 0; i < aList.size(); i++) {
+                    name = aList.get(i).getName();
+                    added = false;
+                    for (int j = 0; j < pluginList.size() && added == false; j++) {
+                        if (name.compareTo(pluginList.get(j)) < 0) {
+                            pluginList.add(j, name);
+                            added = true;
+                        }
+                    }
+                    if (added == false) {
+                        pluginList.add(name);
+                    }
+                }
+            } catch (Throwable e) {
+                e.printStackTrace();
+            }
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.getPluginList", pluginList);
+        return pluginList;
+    }
+
+    // mimics org.apache.geronimo.console.car.AssemblyViewHandler.actionAfterView
+    public void assembleServer (String group, String artifact, String version,
+                        String format, String relativeServerPath, int[] selected) {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.assembleServer",
+                group, artifact, version, format);
+
+        PluginListType selectedPlugins = new PluginListType();
+        String name;
+        boolean found;
+
+        for (int i = 0; i < selected.length; i++) {
+            name = pluginList.get(selected[i]);
+            found = false;
+            for (int j = 0 ; j < data.getPlugin().size() && found == false; j++) {
+                if (name.equals(data.getPlugin().get(j).getName())) {
+                    selectedPlugins.getPlugin().add(data.getPlugin().get(j));
+                    found = true;
+                }
+            }
+        }
+
+        try {
+            GeronimoConnectionFactory gcFactory = GeronimoConnectionFactory.getInstance();
+            RemoteDeploymentManager remoteDM = (RemoteDeploymentManager)gcFactory.getDeploymentManager(server);
+            remoteDM.installPluginList("repository", relativeServerPath, selectedPlugins);
+            remoteDM.archive(relativeServerPath, "var/temp", new Artifact(group, artifact, (String)version, format));
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.assembleServer");
+    }
+
+    // mimics org.apache.geronimo.console.util.KernelManagementHelper.getConfigurations()
+    public List<String> getConfigurationList () {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.getConfigurationList");
+
+        ConfigurationManager mgr = getConfigurationManager();
+        List<AbstractName> stores = mgr.listStores();
+        List<String> results = new ArrayList<String>();
+        for (AbstractName storeName : stores) {
+            try {
+                List<ConfigurationInfo> infos = mgr.listConfigurations(storeName);
+                for (ConfigurationInfo info : infos) {
+                    if (info.getConfigID().getType().equalsIgnoreCase("car"))
+                    {
+                       results.add(info.getConfigID().toString());
+                    }
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(CommonMessages.badConfigId, e);
+            }
+        }
+        Collections.sort(results);
+
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.getConfigurationList", results);
+        return results;
+    }
+
+    public PluginType getPluginMetadata (String configId) {
+        Artifact artifact = Artifact.create(configId);
+        PluginType metadata = null;
+        if (pluginInstaller != null)
+            metadata = pluginInstaller.getPluginMetadata(artifact);
+        return metadata;
+    }
+
+    // mimics org.apache.geronimo.system.plugin.PluginInstallerGBean.updatePluginMetadata
+    // but puts the metadata in our local directory
+    public void savePluginXML (String configId, PluginType metadata) {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.savePluginXML", configId, metadata);
+
+        Artifact artifact = Artifact.create(configId);
+        File dir = new File (getArtifactLocation(artifact));
+
+        if (!dir.isDirectory()) { // must be a packed (JAR-formatted) plugin
+            try {
+                File temp = new File(dir.getParentFile(), dir.getName() + ".temp");
+                JarFile input = new JarFile(dir);
+                Manifest manifest = input.getManifest();
+                JarOutputStream out = manifest == null ? new JarOutputStream(
+                        new BufferedOutputStream(new FileOutputStream(temp)))
+                        : new JarOutputStream(new BufferedOutputStream(new FileOutputStream(temp)), manifest);
+                Enumeration en = input.entries();
+                byte[] buf = new byte[4096];
+                int count;
+                while (en.hasMoreElements()) {
+                    JarEntry entry = (JarEntry) en.nextElement();
+                    if (entry.getName().equals("META-INF/geronimo-plugin.xml")) {
+                        entry = new JarEntry(entry.getName());
+                        out.putNextEntry(entry);
+                        writePluginMetadata(metadata, out);
+                    } else if (entry.getName().equals("META-INF/MANIFEST.MF")) {
+                        // do nothing, already passed in a manifest
+                    } else {
+                        out.putNextEntry(entry);
+                        InputStream in = input.getInputStream(entry);
+                        while ((count = in.read(buf)) > -1) {
+                            out.write(buf, 0, count);
+                        }
+                        in.close();
+                        out.closeEntry();
+                    }
+                }
+                out.flush();
+                out.close();
+                input.close();
+                if (!dir.delete()) {
+                    String message = CommonMessages.bind(CommonMessages.errorDeletePlugin, dir.getAbsolutePath());
+                    Trace.tracePoint("Throw", "GeronimoServerPluginManager.savePluginXML", message);
+                    throw new Exception(message);
+                }
+                if (!temp.renameTo(dir)) {
+                    String message = CommonMessages.bind(CommonMessages.errorMovePlugin, temp.getAbsolutePath(), dir.getAbsolutePath());
+                    Trace.tracePoint("Throw", "GeronimoServerPluginManager.savePluginXML", message);
+                    throw new Exception(message);
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(CommonMessages.errorUpdateMetadata, e);
+            }
+        } else {
+            File meta = new File(addFilename(dir.getAbsolutePath(), artifact), "META-INF");
+            if (!meta.isDirectory() || !meta.canRead()) {
+                String message = CommonMessages.bind(CommonMessages.badPlugin, artifact);
+                Trace.tracePoint("Throw", "GeronimoServerPluginManager.savePluginXML", message);
+                throw new IllegalArgumentException(message);
+            }
+            File xml = new File(meta, "geronimo-plugin.xml");
+            FileOutputStream fos = null;
+            try {
+                if (!xml.isFile()) {
+                    if (!xml.createNewFile()) {
+                        String message = CommonMessages.bind(CommonMessages.errorCreateMetadata, artifact);
+                        Trace.tracePoint("Throw", "GeronimoServerPluginManager.savePluginXML", message);
+                        throw new RuntimeException(message);
+                    }
+                }
+                fos = new FileOutputStream(xml);
+                writePluginMetadata(metadata, fos);
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (fos != null) {
+                    try {
+                        fos.close();
+                    } catch (Exception ignored) {
+                        ignored.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.savePluginXML");
+    }
+
+    // mimics org.apache.geronimo.system.configuration.RepositoryConfigurationStore.exportConfiguration
+    public void exportCAR (String localRepoDir, String configId) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.exportCAR", localRepoDir, configId);
+
+        Artifact artifact = Artifact.create(configId);
+        String filename = createDirectoryStructure (localRepoDir, artifact);
+        File outputDir = new File (filename);
+
+        File serverArtifact = new File(getArtifactLocation (artifact));
+        writeToDirectory(serverArtifact, outputDir);
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.exportCAR");
+    }
+
+    private void writeToDirectory(File inputDir, File outputDir) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.writeToZip", inputDir);
+
+        outputDir.mkdirs();
+        File[] all = inputDir.listFiles();
+        for (File file : all) {
+            if (file.isDirectory()) {
+                String oDir = outputDir.getAbsolutePath() + File.separator + file.getName();
+                File temp = new File (oDir);
+                writeToDirectory(file, temp);
+            } else {
+                File entry = new File(outputDir + File.separator + file.getName());
+                FileOutputStream out = new FileOutputStream (entry);
+                FileInputStream in = new FileInputStream(file);
+                byte[] buf = new byte[10240];
+                int count;
+                try {
+                    while ((count = in.read(buf, 0, buf.length)) > -1) {
+                        out.write(buf, 0, count);
+                    }
+                } finally {
+                    in.close();
+                    out.flush();
+                    out.close();
+                }
+            }
+        }
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.writeToZip");
+    }
+
+    public void updatePluginList (String localRepoDir, PluginType metadata) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.updatePluginList", localRepoDir, metadata);
+
+        PluginListType pluginList = readPluginList(localRepoDir);
+        File listFile = new File (localRepoDir, "geronimo-plugins.xml");
+
+        // if this plugin exists, remove it from the list
+        PluginType plugin;
+        for (int i = 0; i < pluginList.getPlugin().size(); i++) {
+            plugin = pluginList.getPlugin().get(i);
+            if (metadata.getName().equals(plugin.getName()) &&
+                metadata.getCategory().equals(plugin.getCategory())) {
+                pluginList.getPlugin().remove(i);
+                break;
+            }
+        }
+
+        // add the current plugin to the list
+        pluginList.getPlugin().add(metadata);
+
+        // write the file
+        FileOutputStream fos = null;
+        try {
+            fos = new FileOutputStream(listFile);
+            writePluginList(pluginList, fos);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (Exception ignored) {
+                    ignored.printStackTrace();
+                }
+            }
+        }
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.updatePluginList");
+    }
+
+    public PluginListType readPluginList (String localRepoDir) {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.readPluginList", localRepoDir);
+
+        PluginListType pluginList = null;
+        File listFile = new File (localRepoDir, "geronimo-plugins.xml");
+        if (listFile.exists() && listFile.exists()) {
+            InputStream in = null;
+            try {
+                in = new FileInputStream(listFile);
+                pluginList = loadPluginList(in);
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (in != null) {
+                    try {
+                        in.close();
+                    } catch (Exception e) {}
+                }
+            }
+        }
+        if (pluginList == null) {
+            ObjectFactory factory = new ObjectFactory();
+            pluginList = factory.createPluginListType();
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.readPluginList", pluginList);
+        return pluginList;
+    }
+
+    public PluginListType loadPluginList (InputStream in) {
+        try {
+            JAXBElement pluginListElement = JAXBUtils.unmarshalPlugin(in);
+            return (PluginListType)pluginListElement.getValue();
+        }
+        catch (Throwable e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private void writePluginList (PluginListType pluginList, OutputStream out) {
+        try {
+            ObjectFactory jeeFactory = new ObjectFactory();
+            JAXBElement element = jeeFactory.createGeronimoPluginList(pluginList);
+            JAXBUtils.marshalPlugin(element, out);
+        }
+        catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void writePluginMetadata (PluginType metadata, OutputStream out) {
+        try {
+            ObjectFactory jeeFactory = new ObjectFactory();
+            JAXBElement element = jeeFactory.createGeronimoPlugin(metadata);
+            JAXBUtils.marshalPlugin(element, out);
+        }
+        catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+
+    private String getArtifactLocation (Artifact artifact) {
+        String ch = File.separator;
+        String temp = server.getRuntime().getLocation().toOSString() + ch + "repository" + ch;
+        String group = artifact.getGroupId();
+        int pos = group.indexOf(".");
+        while (pos > -1) {
+            group = group.substring(0, pos) + ch + group.substring(pos + 1);
+            pos = group.indexOf(".");
+        }
+        temp += group + ch + artifact.getArtifactId() + ch + artifact.getVersion().toString() + ch;
+        return temp;
+    }
+
+    private String addFilename (String path, Artifact artifact) {
+        if (!path.endsWith("/") && !path.endsWith("\\")) {
+            path += "/";
+        }
+        return path + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType();
+    }
+
+    private String createDirectoryStructure (String rootPath, Artifact artifact) {
+        String fileName = rootPath;
+        if (!fileName.endsWith("/") && !fileName.endsWith("\\")) {
+            fileName += "/";
+        }
+
+        String group = artifact.getGroupId();
+        int pos = group.indexOf(".");
+        while (pos > -1) {
+            group = group.substring(0, pos) + File.separator + group.substring(pos + 1);
+            pos = group.indexOf(".");
+        }
+        fileName += group + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/";
+        File temp = new File (fileName);
+        if (!temp.exists()) {
+            temp.mkdirs();
+        }
+
+        return fileName;
+    }
+
+    private ConfigurationManager getConfigurationManager () {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.getConfigurationManager");
+
+        if (kernel != null) {
+            Trace.tracePoint("Exit", "GeronimoServerPluginManager.getConfigurationManager");
+            return ConfigurationUtil.getEditableConfigurationManager(kernel);
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.getConfigurationManager returns null");
+        return null;
+    }
+
+    public ArtifactType toArtifactType(String configId) {
+        return toArtifactType (Artifact.create(configId));
+    }
+
+    public ArtifactType toArtifactType(Artifact id) {
+        ArtifactType artifact = new ArtifactType();
+        artifact.setGroupId(id.getGroupId());
+        artifact.setArtifactId(id.getArtifactId());
+        artifact.setVersion(id.getVersion() == null ? null : id.getVersion().toString());
+        artifact.setType(id.getType());
+        return artifact;
+    }
+
+    public Artifact toArtifact(ArtifactType id) {
+        return new Artifact (id.getGroupId(), id.getArtifactId(), id.getVersion(), id.getType());
+    }
+
+    public void addGeronimoDependencies(ConfigurationData data, List<DependencyType> deps, boolean includeVersion) {
+        processDependencyList(data.getEnvironment().getDependencies(), deps, includeVersion);
+        Map<String, ConfigurationData> children = data.getChildConfigurations();
+        for (ConfigurationData child : children.values()) {
+            processDependencyList(child.getEnvironment().getDependencies(), deps, includeVersion);
+        }
+    }
+
+    private void processDependencyList(List<Dependency> real, List<DependencyType> deps, boolean includeVersion) {
+        for (Dependency dep : real) {
+            DependencyType dependency = toDependencyType(dep, includeVersion);
+            if (!deps.contains(dependency)) {
+                deps.add(dependency);
+            }
+        }
+    }
+
+    public DependencyType toDependencyType(String configId) {
+        return toDependencyType(new Dependency(Artifact.create(configId), ImportType.ALL), true);
+    }
+
+    public DependencyType toDependencyType(Dependency dep, boolean includeVersion) {
+        Artifact id = dep.getArtifact();
+        DependencyType dependency = new DependencyType();
+        dependency.setGroupId(id.getGroupId());
+        dependency.setArtifactId(id.getArtifactId());
+        if (includeVersion) {
+            dependency.setVersion(id.getVersion() == null ? null : id.getVersion().toString());
+        }
+        dependency.setType(id.getType());
+        return dependency;
+    }
+
+    public boolean validatePlugin (PluginType plugin) {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.validatePlugin", plugin);
+        boolean valid = true;
+        try {
+            pluginInstaller.validatePlugin(plugin);
+        } catch (Exception e) {
+            e.printStackTrace();
+            valid = false;
+        }
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.validatePlugin", valid);
+        return valid;
+    }
+
+    // mimics org.apache.geronimo.system.plugin.PluginInstallerGbean.install
+    // but uses our local directory to get the plugins
+    public ArrayList<String> installPlugins (String localRepoDir, List<PluginType> pluginList) {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.installPlugins", localRepoDir, pluginList);
+        ArrayList<String> eventLog = new ArrayList<String>();
+
+        //List<Artifact> downloadedArtifacts = new ArrayList<Artifact>();
+        try {
+            ConfigurationManager configManager = getConfigurationManager();
+            Map<Artifact, PluginType> metaMap = new HashMap<Artifact, PluginType>();
+            // Step 1: validate everything
+            List<PluginType> toInstall = new ArrayList<PluginType>();
+            for (PluginType metadata : pluginList) {
+                try {
+                    validatePlugin(metadata);
+                    verifyPrerequisites(metadata);
+
+                    PluginArtifactType instance = metadata.getPluginArtifact().get(0);
+
+                    if (instance.getModuleId() != null) {
+                        metaMap.put(toArtifact(instance.getModuleId()), metadata);
+                    }
+                    toInstall.add(metadata);
+                } catch (Exception e) {
+                }
+            }
+
+            // Step 2: everything is valid, do the installation
+            for (PluginType metadata : toInstall) {
+                // 2. Unload obsoleted configurations
+                if (!validatePlugin(metadata)) {
+                    // metadata exists
+                    PluginArtifactType instance = metadata.getPluginArtifact()
+                            .get(0);
+                    List<Artifact> obsoletes = new ArrayList<Artifact>();
+                    for (ArtifactType obs : instance.getObsoletes()) {
+                        Artifact obsolete = toArtifact(obs);
+                        if (configManager.isLoaded(obsolete)) {
+                            if (configManager.isRunning(obsolete)) {
+                                configManager.stopConfiguration(obsolete);
+                                eventLog.add(obsolete.toString() + " stopped");
+                            }
+                            configManager.unloadConfiguration(obsolete);
+                            obsoletes.add(obsolete);
+                        }
+                    }
+
+                    // 4. Uninstall obsolete configurations
+                    for (Artifact artifact : obsoletes) {
+                        configManager.uninstallConfiguration(artifact);
+                    }
+                }
+            }
+            
+            // Step 3: Start anything that's marked accordingly
+            if (configManager.isOnline()) {
+                for (int i = 0; i < toInstall.size(); i++) {
+                    Artifact artifact = toArtifact(toInstall.get(i).getPluginArtifact().get(0).getModuleId());
+                    if (!configManager.isRunning(artifact)) {
+                        if (!configManager.isLoaded(artifact)) {
+                            File serverArtifact = new File(getArtifactLocation (artifact));
+                            File localDir = new File (createDirectoryStructure(localRepoDir, artifact));
+                            writeToRepository(localDir, serverArtifact);
+                            configManager.loadConfiguration(artifact);
+                        }
+                        configManager.startConfiguration(artifact);
+                        eventLog.add(artifact.toString() + " started");
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.installPlugins", eventLog.toString());
+        return eventLog;
+    }
+
+    // mimics org.apache.geronimo.system.plugin.PluginInstallerGbean.verifyPrerequisistes
+    private void verifyPrerequisites(PluginType plugin) throws Exception {
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.verifyPrerequisites", plugin);
+        List<Dependency> missingPrereqs = getMissingPrerequisites(plugin);
+        if (!missingPrereqs.isEmpty()) {
+            PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
+            Artifact moduleId = toArtifact(metadata.getModuleId());
+            StringBuffer buf = new StringBuffer();
+            buf.append(moduleId.toString()).append(CommonMessages.requires);
+            Iterator<Dependency> iter = missingPrereqs.iterator();
+            while (iter.hasNext()) {
+                buf.append(iter.next().getArtifact().toString());
+                if (iter.hasNext()) {
+                    buf.append(", ");
+                }
+            }
+            buf.append(CommonMessages.installed);
+            Trace.tracePoint("Throw", "GeronimoServerPluginManager.verifyPrerequisites", buf.toString());
+            throw new Exception(buf.toString());
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.verifyPrerequisites");
+    }
+
+    // mimics org.apache.geronimo.system.plugin.PluginInstallerGbean.getMissingPrerequisistes
+    private List<Dependency> getMissingPrerequisites(PluginType plugin) {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.getMissingPrerequisites", plugin);
+
+        if (plugin.getPluginArtifact().size() != 1) {
+            String message = CommonMessages.bind(CommonMessages.configSizeMismatch, plugin.getPluginArtifact().size());
+            Trace.tracePoint("Throw", "GeronimoServerPluginManager.getMissingPrerequisites", message);
+            throw new IllegalArgumentException(message);
+        }
+
+        PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
+        List<PrerequisiteType> prereqs = metadata.getPrerequisite();
+
+        ArrayList<Dependency> missingPrereqs = new ArrayList<Dependency>();
+        for (PrerequisiteType prereq : prereqs) {
+            Artifact artifact = toArtifact(prereq.getId());
+            try {
+                if (getConfigurationManager().getArtifactResolver().queryArtifacts(artifact).length == 0) {
+                    missingPrereqs.add(new Dependency(artifact, ImportType.ALL));
+                }
+            } catch (Exception e) {
+                Trace.tracePoint("Throw", "GeronimoServerPluginManager.getMissingPrerequisites", CommonMessages.noDefaultServer);
+                throw new RuntimeException(CommonMessages.noDefaultServer);
+            }
+        }
+
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.getMissingPrerequisites", missingPrereqs);
+        return missingPrereqs;
+    }
+    
+    //Extract the car file
+    private void writeToRepository(File inputDir, File outputDir) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerPluginManager.writeToRepository", inputDir,outputDir);
+
+        outputDir.mkdirs();
+        File[] all = inputDir.listFiles();
+        for (File file : all) {
+            if (file.isDirectory()) {
+                String oDir = outputDir.getAbsolutePath() + File.separator + file.getName();
+                File temp = new File (oDir);
+                writeToRepository(file, temp);
+            }else if(file.getName().toLowerCase().endsWith(".car"))
+            {
+               String oDir = outputDir.getAbsolutePath() + File.separator + file.getName();
+                File temp = new File (oDir);
+                
+                ZipInputStream in=new ZipInputStream(new FileInputStream(file));            
+                try {
+                    byte[] buffer = new byte[10240];
+                    for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) {
+                        File zipFile = new File(temp, entry.getName());
+                        if (entry.isDirectory()) {
+                           zipFile.mkdirs();
+                        } else {
+                            if (!entry.getName().equals("META-INF/startup-jar")) {
+                               zipFile.getParentFile().mkdirs();
+                                OutputStream out = new FileOutputStream(zipFile);
+                                try {
+                                    int count;
+                                    while ((count = in.read(buffer)) > 0) {
+                                        out.write(buffer, 0, count);                                    
+                                    }
+                                } finally {                                 
+                                    out.close();
+                                }
+                                in.closeEntry();
+                            }
+                        }
+                    }
+                } catch (IOException e) {               
+                    throw e;
+                } finally {
+                    in.close();          
+                }
+            }
+            else {
+                File entry = new File(outputDir + File.separator + file.getName());
+                FileOutputStream out = new FileOutputStream (entry);
+                FileInputStream in = new FileInputStream(file);
+                byte[] buf = new byte[10240];
+                int count;
+                try {
+                    while ((count = in.read(buf, 0, buf.length)) > -1) {
+                        out.write(buf, 0, count);
+                    }
+                } finally {
+                    in.close();
+                    out.flush();
+                    out.close();
+                }
+            }
+        }
+        Trace.tracePoint("Exit", "GeronimoServerPluginManager.writeToRepository");
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,42 @@
+/*
+ * 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.core.GeronimoFacetInstallDelegate;
+import org.apache.geronimo.st.v21.core.internal.Trace;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.common.project.facet.JavaProjectFacetCreationDataModelProvider;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoV21FacetInstallDelegate extends GeronimoFacetInstallDelegate {
+
+	public IDataModelOperation createDeploymentPlanCreationOp(IProject project, Object config) {
+		Trace.tracePoint("Entry", "GeronimoV21FacetInstallDelegate.createDeploymentPlanCreationOp", project, config);
+		
+		IDataModel model = DataModelFactory.createDataModel(new JavaProjectFacetCreationDataModelProvider());
+		model.setStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project.getName());
+		
+		Trace.tracePoint("Exit ", "GeronimoV21FacetInstallDelegate.createDeploymentPlanCreationOp");
+		return new V21DeploymentPlanCreationOperation(model, config);		
+	}
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoV21FacetInstallDelegate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message