Save This Page
Home » geronimo-eclipse-plugin-2.2-source-release » org.apache.geronimo.st.v21.core » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *    http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.geronimo.st.v21.core;
   18   
   19   import javax.xml.bind.JAXBElement;
   20   
   21   import org.apache.geronimo.jee.application.Application;
   22   import org.apache.geronimo.jee.applicationclient.ApplicationClient;
   23   import org.apache.geronimo.jee.connector.Connector;
   24   import org.apache.geronimo.jee.deployment.Artifact;
   25   import org.apache.geronimo.jee.deployment.Environment;
   26   import org.apache.geronimo.jee.openejb.OpenejbJar;
   27   import org.apache.geronimo.jee.web.WebApp;
   28   import org.apache.geronimo.st.core.GeronimoUtils;
   29   import org.apache.geronimo.st.core.internal.Trace;
   30   import org.apache.geronimo.st.core.jaxb.JAXBUtils;
   31   import org.eclipse.core.resources.IFile;
   32   import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
   33   import org.eclipse.wst.server.core.IModule;
   34   
   35   /**
   36    * @version $Rev: 533836 $ $Date: 2007-04-30 15:39:14 -0400 (Mon, 30 Apr 2007) $
   37    */
   38   public class GeronimoV21Utils extends GeronimoUtils {
   39   
   40       public static JAXBElement getDeploymentPlan(IFile file) throws Exception {
   41           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getDeploymentPlan", file);
   42   
   43           if (!file.exists()) {
   44               return null;
   45           }
   46   
   47           if (file.getName().equals(GeronimoUtils.APP_PLAN_NAME))
   48               return getApplicationDeploymentPlan(file);
   49           else if (file.getName().equals(GeronimoUtils.OPENEJB_PLAN_NAME))
   50               return getOpenEjbDeploymentPlan(file);
   51           else if (file.getName().equals(GeronimoUtils.WEB_PLAN_NAME))
   52               return getWebDeploymentPlan(file);
   53           else if (file.getName().equals(GeronimoUtils.CONNECTOR_PLAN_NAME))
   54               return getConnectorDeploymentPlan(file);
   55           else if (file.getName().equals(GeronimoUtils.APP_CLIENT_PLAN_NAME))
   56               return getApplicationClientDeploymentPlan(file);
   57   
   58           Trace.tracePoint("EXIT", "GeronimoV21Utils.getDeploymentPlan", null);
   59           return null;
   60       }
   61   
   62       //public static String getConfigId2(IModule module) {
   63       //    Trace.tracePoint("ENTRY", "GeronimoV21Utils.getConfigId2", module);
   64   
   65       //    IFile planFile = null;
   66       //   IVirtualComponent comp = ComponentCore.createComponent(module.getProject());
   67       //    if (isWebModule(module)) {
   68       //        planFile = GeronimoUtils.getWebDeploymentPlanFile(comp);
   69       //   }
   70       //    else if (isEjbJarModule(module)) {
   71       //        planFile = GeronimoUtils.getOpenEjbDeploymentPlanFile(comp);
   72       //    }
   73       //    else if (isEarModule(module)) {
   74       //       planFile = GeronimoUtils.getApplicationDeploymentPlanFile(comp);
   75       //    }
   76       //    else if (isRARModule(module)) {
   77       //        planFile = GeronimoUtils.getConnectorDeploymentPlanFile(comp);
   78       //    }
   79   
   80       //    if (planFile != null) {
   81       //       try {
   82       //            XmlObject xmlObject = XmlBeansUtil.parse(planFile.getLocation().toFile());
   83       //            XmlCursor cursor = xmlObject.newCursor();
   84       //            cursor.toFirstChild();
   85       //            xmlObject = cursor.getObject();
   86       //            XmlObject result[] = xmlObject.selectChildren(QNameSet.singleton(EnvironmentDocument.type.getDocumentElementName()));
   87       //            if (result != null && result.length > 0) {
   88       //                org.apache.geronimo.deployment.xbeans.EnvironmentType env = (org.apache.geronimo.deployment.xbeans.EnvironmentType) result[0].changeType(org.apache.geronimo.deployment.xbeans.EnvironmentType.type);
   89       //                org.apache.geronimo.deployment.xbeans.ArtifactType moduleId = env.getModuleId();
   90       //                Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId2", getQualifiedConfigID(moduleId));
   91       //                return getQualifiedConfigID(moduleId);
   92       //            }
   93       //            else {
   94                       // 
   95                       // FIXME -- Once GERONIMODEVTOOLS-263 is resolved
   96                       // 
   97       //                String id = getConfigId(module);
   98       //                Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId2", id);
   99       //                return id;
  100       //            }
  101       //        }
  102       //        catch (IOException e) {
  103       //            e.printStackTrace();
  104       //        }
  105       //        catch (XmlException e) {
  106       //            e.printStackTrace();
  107       //        }
  108       //    }
  109   
  110       //    Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId2", null);
  111       //    return null;
  112       //}
  113   
  114       public static String getConfigId(IModule module) throws Exception {
  115           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getConfigId", module);
  116   
  117           Environment environment = null;
  118           if (isWebModule(module)) {
  119               if (getWebDeploymentPlan(module)!=null) {
  120               	WebApp plan = getWebDeploymentPlan(module).getValue();
  121               	if (plan != null)
  122               		environment = plan.getEnvironment();
  123               }
  124           }
  125           else if (isEjbJarModule(module)) {
  126           	   if (getOpenEjbDeploymentPlan(module)!=null) {
  127   		            OpenejbJar plan = getOpenEjbDeploymentPlan(module).getValue();
  128   		            if (plan != null)
  129   		            	environment = plan.getEnvironment();
  130           	   }
  131           }
  132           else if (isEarModule(module)) {
  133           	if (getApplicationDeploymentPlan(module)!=null) {
  134           		Application plan = getApplicationDeploymentPlan(module).getValue();
  135           		if (plan != null)
  136           			environment = plan.getEnvironment();
  137           	}
  138           }
  139           else if (isRARModule(module)) {
  140           	if (getConnectorDeploymentPlan(module)!=null) {
  141   	            Connector plan = getConnectorDeploymentPlan(module).getValue();
  142   	            if (plan != null)
  143   	                environment = plan.getEnvironment();
  144           	}
  145           }
  146   
  147           if (environment != null
  148               && environment.getModuleId() != null) {
  149               Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId", getQualifiedConfigID(environment.getModuleId()));
  150               return getQualifiedConfigID(environment.getModuleId());
  151           }
  152   
  153           Trace.tracePoint("EXIT", "GeronimoV21Utils.getConfigId", getId(module));
  154           return getId(module);
  155       }
  156   
  157       public static String getQualifiedConfigID(Artifact artifact) {
  158           return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
  159       }
  160   
  161       //public static String getQualifiedConfigID(org.apache.geronimo.deployment.xbeans.ArtifactType artifact) {
  162       //    return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
  163       //}
  164   
  165       public static String getContextRoot(IModule module) throws Exception {
  166           String contextRoot = null;
  167   
  168           WebApp deploymentPlan = getWebDeploymentPlan(module).getValue();
  169           if (deploymentPlan != null)
  170               contextRoot = deploymentPlan.getContextRoot();
  171   
  172           if (contextRoot == null)
  173               contextRoot = GeronimoUtils.getContextRoot(module);
  174   
  175           return contextRoot;
  176       }
  177   
  178       public static JAXBElement<WebApp> getWebDeploymentPlan(IModule module) throws Exception {
  179           return getWebDeploymentPlan(getVirtualComponent(module));
  180       }
  181   
  182       public static JAXBElement<Application> getApplicationDeploymentPlan(IModule module) throws Exception {
  183           return getApplicationDeploymentPlan(getVirtualComponent(module));
  184       }
  185   
  186       public static JAXBElement<OpenejbJar> getOpenEjbDeploymentPlan(IModule module) throws Exception {
  187           return getOpenEjbDeploymentPlan(getVirtualComponent(module));
  188       }
  189   
  190       public static JAXBElement<Connector> getConnectorDeploymentPlan(IModule module) throws Exception {
  191           return getConnectorDeploymentPlan(getVirtualComponent(module));
  192       }
  193   
  194       public static JAXBElement getApplicationDeploymentPlan(IVirtualComponent comp) throws Exception {
  195           return getApplicationDeploymentPlan(getApplicationDeploymentPlanFile(comp));
  196       }
  197   
  198       public static JAXBElement getWebDeploymentPlan(IVirtualComponent comp) throws Exception {
  199           return getWebDeploymentPlan(getWebDeploymentPlanFile(comp));
  200       }
  201   
  202       public static JAXBElement getOpenEjbDeploymentPlan(IVirtualComponent comp) throws Exception {
  203           return getOpenEjbDeploymentPlan(getOpenEjbDeploymentPlanFile(comp));
  204       }
  205   
  206       public static JAXBElement getConnectorDeploymentPlan(IVirtualComponent comp) throws Exception {
  207           return getConnectorDeploymentPlan(getConnectorDeploymentPlanFile(comp));
  208       }
  209   
  210       public static JAXBElement getApplicationDeploymentPlan(IFile file) throws Exception {
  211           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getApplicationDeploymentPlan", file);
  212   
  213           if (file.getName().equals(APP_PLAN_NAME) && file.exists()) {
  214           	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
  215           }
  216   
  217           Trace.tracePoint("EXIT", "GeronimoV21Utils.getApplicationDeploymentPlan", null);
  218           return null;
  219       }
  220   
  221       public static JAXBElement getApplicationClientDeploymentPlan(IFile file) throws Exception {
  222           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getApplicationClientDeploymentPlan", file);
  223   
  224           if (file.getName().equals(APP_CLIENT_PLAN_NAME) && file.exists()) {
  225           	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
  226           }
  227   
  228           Trace.tracePoint("EXIT", "GeronimoV21Utils.getApplicationClientDeploymentPlan", null);
  229           return null;
  230       }
  231   
  232       public static JAXBElement getWebDeploymentPlan(IFile file) throws Exception {
  233           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getWebDeploymentPlan", file);
  234   
  235           if (file.getName().equals(WEB_PLAN_NAME) && file.exists()) {
  236           	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
  237           }
  238   
  239           Trace.tracePoint("EXIT", "GeronimoV21Utils.getWebDeploymentPlan", null);
  240           return null;
  241       }
  242   
  243       public static JAXBElement getOpenEjbDeploymentPlan(IFile file) throws Exception {
  244           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getOpenEjbDeploymentPlan", file);
  245   
  246           if (file.getName().equals(OPENEJB_PLAN_NAME) && file.exists()) {
  247           	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
  248           }
  249   
  250           Trace.tracePoint("EXIT", "GeronimoV21Utils.getOpenEjbDeploymentPlan", null);
  251           return null;
  252       }
  253   
  254       public static JAXBElement getConnectorDeploymentPlan(IFile file) throws Exception {
  255           Trace.tracePoint("ENTRY", "GeronimoV21Utils.getConnectorDeploymentPlan", file);
  256   
  257           if (file.getName().equals(CONNECTOR_PLAN_NAME) && file.exists()) {
  258           	return JAXBUtils.unmarshalFilterDeploymentPlan(file);
  259           }
  260   
  261           Trace.tracePoint("EXIT", "GeronimoV21Utils.getConnectorDeploymentPlan", null);
  262           return null;
  263       }
  264       
  265   }

Save This Page
Home » geronimo-eclipse-plugin-2.2-source-release » org.apache.geronimo.st.v21.core » [javadoc | source]