Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 818 invoked from network); 18 Jul 2008 20:48:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 20:48:11 -0000 Received: (qmail 15877 invoked by uid 500); 18 Jul 2008 20:48:11 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 15830 invoked by uid 500); 18 Jul 2008 20:48:11 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 15821 invoked by uid 99); 18 Jul 2008 20:48:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 13:48:11 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 20:46:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7FAB2238896E; Fri, 18 Jul 2008 13:46:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r678032 - /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java Date: Fri, 18 Jul 2008 20:46:00 -0000 To: scm@geronimo.apache.org From: mcconne@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080718204600.7FAB2238896E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mcconne Date: Fri Jul 18 13:46:00 2008 New Revision: 678032 URL: http://svn.apache.org/viewvc?rev=678032&view=rev Log: GERONIMODEVTOOLS-427 Remove hard-coded service-ref-name in geronimo-application-client.xml generated XML. Thanks to BJ for this patch !! Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java?rev=678032&r1=678031&r2=678032&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/V21DeploymentPlanCreationOperation.java Fri Jul 18 13:46:00 2008 @@ -1,268 +1,258 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.geronimo.st.v21.core.operations; - -import javax.xml.bind.JAXBElement; - -import org.apache.geronimo.jee.application.Application; -import org.apache.geronimo.jee.applicationclient.ApplicationClient; -import org.apache.geronimo.jee.connector.Connector; -import org.apache.geronimo.jee.connector.Resourceadapter; -import org.apache.geronimo.jee.deployment.Artifact; -import org.apache.geronimo.jee.deployment.Dependencies; -import org.apache.geronimo.jee.deployment.Dependency; -import org.apache.geronimo.jee.deployment.Environment; -import org.apache.geronimo.jee.naming.ServiceRef; -import org.apache.geronimo.jee.openejb.OpenejbJar; -import org.apache.geronimo.jee.web.WebApp; -import org.apache.geronimo.st.core.jaxb.JAXBUtils; -import org.apache.geronimo.st.core.operations.DeploymentPlanCreationOperation; -import org.apache.geronimo.st.v21.core.DeploymentPlanInstallConfig; -import org.apache.geronimo.st.v21.core.internal.Trace; -import org.eclipse.core.resources.IFile; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * V21DeploymentPlanCreationOperation - * is invoked when projects are created that are to be deployment on the 2.1 - * version of the Geronimo server. One of these Geronimo-specific deployment - * plans is created as a result and is inserted into the user's Eclipse workspace in - * the appropriate folder: - * - *
    - *
  1. geronimo-application.xml - *
  2. geronimo-application-client.xml - *
  3. geronimo-ra.xml - *
  4. geronimo-service.xml - *
  5. geronimo-web.xml - *
  6. openejb-jar.xml - *
- * - * @version $Rev: 509704 $ $Date: 2007-02-20 13:42:24 -0500 (Tue, 20 Feb 2007) $ - */ -public class V21DeploymentPlanCreationOperation extends DeploymentPlanCreationOperation { - - DeploymentPlanInstallConfig cfg; - - public V21DeploymentPlanCreationOperation(IDataModel model, Object config) { - super(model, config); - Trace.tracePoint("Constructor", "V21DeploymentPlanCreationOperation", model, config); - } - - - /* - * (non-Javadoc) - * - * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoApplicationDeploymentPlan(org.eclipse.core.resources.IFile) - */ - public JAXBElement createGeronimoApplicationDeploymentPlan(IFile dpFile) { - Trace.tracePoint("Entry", - "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", dpFile); - - org.apache.geronimo.jee.application.ObjectFactory applicationFactory = new org.apache.geronimo.jee.application.ObjectFactory(); - Application application = applicationFactory.createApplication(); - - application.setApplicationName(getProject().getName()); - application.setEnvironment(getConfigEnvironment()); - - JAXBElement jaxbElement = applicationFactory.createApplication(application); - JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", - applicationFactory.createApplication(application)); - return applicationFactory.createApplication(application); - } - - - /* - * (non-Javadoc) - * - * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoWebDeploymentPlan(org.eclipse.core.resources.IFile) - */ - public JAXBElement createGeronimoWebDeploymentPlan(IFile dpFile) { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", - dpFile, dpFile.getFullPath()); - - org.apache.geronimo.jee.web.ObjectFactory webFactory = new org.apache.geronimo.jee.web.ObjectFactory(); - WebApp web = webFactory.createWebApp(); - - web.setContextRoot("/" + getProject().getName()); - web.setEnvironment(getConfigEnvironment()); - - JAXBElement jaxbElement = webFactory.createWebApp(web); - JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", jaxbElement); - return jaxbElement; - } - - - /* - * (non-Javadoc) - * - * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createOpenEjbDeploymentPlan(org.eclipse.core.resources.IFile) - */ - public JAXBElement createOpenEjbDeploymentPlan(IFile dpFile) { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", dpFile); - - org.apache.geronimo.jee.openejb.ObjectFactory ejbFactory = new org.apache.geronimo.jee.openejb.ObjectFactory(); - OpenejbJar ejbJar = ejbFactory.createOpenejbJar(); - - ejbJar.setEnvironment(getConfigEnvironment()); - - JAXBElement jaxbElement = ejbFactory.createOpenejbJar(ejbJar); - JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", jaxbElement); - return jaxbElement; - } - - - /* - * (non-Javadoc) - * - * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createConnectorDeploymentPlan(org.eclipse.core.resources.IFile) - */ - public JAXBElement createConnectorDeploymentPlan(IFile dpFile) { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", dpFile); - - org.apache.geronimo.jee.connector.ObjectFactory connectorFactory = new org.apache.geronimo.jee.connector.ObjectFactory(); - Connector connector = connectorFactory.createConnector(); - Resourceadapter resourceadapter = connectorFactory.createResourceadapter(); - - connector.setEnvironment(getConfigEnvironment()); - connector.getResourceadapter().add(resourceadapter); - - JAXBElement jaxbElement = connectorFactory.createConnector(connector); - JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", jaxbElement); - return jaxbElement; - } - - - /* - * (non-Javadoc) - * - * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoApplicationDeploymentPlan(org.eclipse.core.resources.IFile) - */ - public JAXBElement createGeronimoApplicationClientDeploymentPlan(IFile dpFile) { - Trace.tracePoint("Entry","V21DeploymentPlanCreationOperation.createGeronimoApplicationClientDeploymentPlan", dpFile); - - org.apache.geronimo.jee.applicationclient.ObjectFactory applicationClientFactory = new org.apache.geronimo.jee.applicationclient.ObjectFactory(); - ApplicationClient applicationClient = applicationClientFactory.createApplicationClient(); - - applicationClient.setServerEnvironment(getConfigEnvironment()); - applicationClient.setClientEnvironment(getConfigEnvironment()); - - // - // Add a ServiceRef - // - org.apache.geronimo.jee.naming.ObjectFactory namingFactory = new org.apache.geronimo.jee.naming.ObjectFactory(); - ServiceRef serviceRef = namingFactory.createServiceRef(); - serviceRef.setServiceRefName("ServiceRefName"); - - applicationClient.getServiceRef().add(serviceRef); - - JAXBElement jaxbElement = applicationClientFactory.createApplicationClient(applicationClient); - JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoApplicationClientDeploymentPlan", applicationClientFactory.createApplicationClient(applicationClient)); - return applicationClientFactory.createApplicationClient(applicationClient); - } - - - public Environment getConfigEnvironment() { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.getConfigEnvironment"); - - if (config != null && config instanceof DeploymentPlanInstallConfig) { - cfg = (DeploymentPlanInstallConfig) config; - } - - String groupId = cfg != null && hasValue(cfg.getGroupId()) ? cfg.getGroupId() - : "default"; - String artifactId = cfg != null && hasValue(cfg.getArtifactId()) ? cfg.getArtifactId() - : getProject().getName(); - String version = cfg != null && hasValue(cfg.getVersion()) ? cfg.getVersion() - : "1.0"; - String type = cfg != null && hasValue(cfg.getType()) ? cfg.getType() - : "car"; - - Artifact artifact = createArtifact(groupId, artifactId, version, type); - org.apache.geronimo.jee.deployment.ObjectFactory serviceFactory = new org.apache.geronimo.jee.deployment.ObjectFactory(); - - Environment env = serviceFactory.createEnvironment(); - env.setModuleId(artifact); - - if (cfg != null && cfg.isSharedLib()) { - Dependencies dt = serviceFactory.createDependencies(); - Dependency sharedLib = createDependency("org.apache.geronimo.configs", "sharedlib", null, "car"); - dt.getDependency().add(sharedLib); - env.setDependencies(dt); - } - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.getConfigEnvironment", env); - return env; - } - - - public static Artifact createArtifact(String groupId, String artifactId, String version, String type) { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createArtifact", groupId, artifactId, version, type); - - org.apache.geronimo.jee.deployment.ObjectFactory serviceFactory = new org.apache.geronimo.jee.deployment.ObjectFactory(); - Artifact artifact = serviceFactory.createArtifact(); - - if (groupId != null) - artifact.setGroupId(groupId); - if (artifactId != null) - artifact.setArtifactId(artifactId); - if (version != null) - artifact.setVersion(version); - artifact.setType(type); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createArtifact", artifact); - return artifact; - } - - - public static Dependency createDependency(String groupId, String artifactId, String version, String type) { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createDependency", groupId, artifactId, version, type); - - org.apache.geronimo.jee.deployment.ObjectFactory serviceFactory = new org.apache.geronimo.jee.deployment.ObjectFactory(); - Dependency dependency = serviceFactory.createDependency(); - if (groupId != null) - dependency.setGroupId(groupId); - if (artifactId != null) - dependency.setArtifactId(artifactId); - if (version != null) - dependency.setVersion(version); - dependency.setType(type); - - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createDependency", dependency); - return dependency; - } - - - private static boolean hasValue(String attribute) { - Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.hasValue", attribute); - Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.hasValue", (attribute != null && attribute.trim().length() != 0) ); - - return attribute != null && attribute.trim().length() != 0; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.st.v21.core.operations; + +import javax.xml.bind.JAXBElement; + +import org.apache.geronimo.jee.application.Application; +import org.apache.geronimo.jee.applicationclient.ApplicationClient; +import org.apache.geronimo.jee.connector.Connector; +import org.apache.geronimo.jee.connector.Resourceadapter; +import org.apache.geronimo.jee.deployment.Artifact; +import org.apache.geronimo.jee.deployment.Dependencies; +import org.apache.geronimo.jee.deployment.Dependency; +import org.apache.geronimo.jee.deployment.Environment; +import org.apache.geronimo.jee.openejb.OpenejbJar; +import org.apache.geronimo.jee.web.WebApp; +import org.apache.geronimo.st.core.jaxb.JAXBUtils; +import org.apache.geronimo.st.core.operations.DeploymentPlanCreationOperation; +import org.apache.geronimo.st.v21.core.DeploymentPlanInstallConfig; +import org.apache.geronimo.st.v21.core.internal.Trace; +import org.eclipse.core.resources.IFile; +import org.eclipse.wst.common.frameworks.datamodel.IDataModel; + + +/** + * V21DeploymentPlanCreationOperation + * is invoked when projects are created that are to be deployment on the 2.1 + * version of the Geronimo server. One of these Geronimo-specific deployment + * plans is created as a result and is inserted into the user's Eclipse workspace in + * the appropriate folder: + * + *
    + *
  1. geronimo-application.xml + *
  2. geronimo-application-client.xml + *
  3. geronimo-ra.xml + *
  4. geronimo-service.xml + *
  5. geronimo-web.xml + *
  6. openejb-jar.xml + *
+ * + * @version $Rev: 509704 $ $Date: 2007-02-20 13:42:24 -0500 (Tue, 20 Feb 2007) $ + */ +public class V21DeploymentPlanCreationOperation extends DeploymentPlanCreationOperation { + + DeploymentPlanInstallConfig cfg; + + public V21DeploymentPlanCreationOperation(IDataModel model, Object config) { + super(model, config); + Trace.tracePoint("Constructor", "V21DeploymentPlanCreationOperation", model, config); + } + + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoApplicationDeploymentPlan(org.eclipse.core.resources.IFile) + */ + public JAXBElement createGeronimoApplicationDeploymentPlan(IFile dpFile) { + Trace.tracePoint("Entry", + "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", dpFile); + + org.apache.geronimo.jee.application.ObjectFactory applicationFactory = new org.apache.geronimo.jee.application.ObjectFactory(); + Application application = applicationFactory.createApplication(); + + application.setApplicationName(getProject().getName()); + application.setEnvironment(getConfigEnvironment()); + + JAXBElement jaxbElement = applicationFactory.createApplication(application); + JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", + applicationFactory.createApplication(application)); + return applicationFactory.createApplication(application); + } + + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoWebDeploymentPlan(org.eclipse.core.resources.IFile) + */ + public JAXBElement createGeronimoWebDeploymentPlan(IFile dpFile) { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", + dpFile, dpFile.getFullPath()); + + org.apache.geronimo.jee.web.ObjectFactory webFactory = new org.apache.geronimo.jee.web.ObjectFactory(); + WebApp web = webFactory.createWebApp(); + + web.setContextRoot("/" + getProject().getName()); + web.setEnvironment(getConfigEnvironment()); + + JAXBElement jaxbElement = webFactory.createWebApp(web); + JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoWebDeploymentPlan", jaxbElement); + return jaxbElement; + } + + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createOpenEjbDeploymentPlan(org.eclipse.core.resources.IFile) + */ + public JAXBElement createOpenEjbDeploymentPlan(IFile dpFile) { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", dpFile); + + org.apache.geronimo.jee.openejb.ObjectFactory ejbFactory = new org.apache.geronimo.jee.openejb.ObjectFactory(); + OpenejbJar ejbJar = ejbFactory.createOpenejbJar(); + + ejbJar.setEnvironment(getConfigEnvironment()); + + JAXBElement jaxbElement = ejbFactory.createOpenejbJar(ejbJar); + JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createOpenEjbDeploymentPlan", jaxbElement); + return jaxbElement; + } + + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createConnectorDeploymentPlan(org.eclipse.core.resources.IFile) + */ + public JAXBElement createConnectorDeploymentPlan(IFile dpFile) { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", dpFile); + + org.apache.geronimo.jee.connector.ObjectFactory connectorFactory = new org.apache.geronimo.jee.connector.ObjectFactory(); + Connector connector = connectorFactory.createConnector(); + Resourceadapter resourceadapter = connectorFactory.createResourceadapter(); + + connector.setEnvironment(getConfigEnvironment()); + connector.getResourceadapter().add(resourceadapter); + + JAXBElement jaxbElement = connectorFactory.createConnector(connector); + JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createConnectorDeploymentPlan", jaxbElement); + return jaxbElement; + } + + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoApplicationDeploymentPlan(org.eclipse.core.resources.IFile) + */ + public JAXBElement createGeronimoApplicationClientDeploymentPlan(IFile dpFile) { + Trace.tracePoint("Entry","V21DeploymentPlanCreationOperation.createGeronimoApplicationClientDeploymentPlan", dpFile); + + org.apache.geronimo.jee.applicationclient.ObjectFactory applicationClientFactory = new org.apache.geronimo.jee.applicationclient.ObjectFactory(); + ApplicationClient applicationClient = applicationClientFactory.createApplicationClient(); + + applicationClient.setServerEnvironment(getConfigEnvironment()); + applicationClient.setClientEnvironment(getConfigEnvironment()); + + JAXBElement jaxbElement = applicationClientFactory.createApplicationClient(applicationClient); + JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createGeronimoApplicationClientDeploymentPlan", applicationClientFactory.createApplicationClient(applicationClient)); + return applicationClientFactory.createApplicationClient(applicationClient); + } + + + public Environment getConfigEnvironment() { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.getConfigEnvironment"); + + if (config != null && config instanceof DeploymentPlanInstallConfig) { + cfg = (DeploymentPlanInstallConfig) config; + } + + String groupId = cfg != null && hasValue(cfg.getGroupId()) ? cfg.getGroupId() + : "default"; + String artifactId = cfg != null && hasValue(cfg.getArtifactId()) ? cfg.getArtifactId() + : getProject().getName(); + String version = cfg != null && hasValue(cfg.getVersion()) ? cfg.getVersion() + : "1.0"; + String type = cfg != null && hasValue(cfg.getType()) ? cfg.getType() + : "car"; + + Artifact artifact = createArtifact(groupId, artifactId, version, type); + org.apache.geronimo.jee.deployment.ObjectFactory serviceFactory = new org.apache.geronimo.jee.deployment.ObjectFactory(); + + Environment env = serviceFactory.createEnvironment(); + env.setModuleId(artifact); + + if (cfg != null && cfg.isSharedLib()) { + Dependencies dt = serviceFactory.createDependencies(); + Dependency sharedLib = createDependency("org.apache.geronimo.configs", "sharedlib", null, "car"); + dt.getDependency().add(sharedLib); + env.setDependencies(dt); + } + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.getConfigEnvironment", env); + return env; + } + + + public static Artifact createArtifact(String groupId, String artifactId, String version, String type) { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createArtifact", groupId, artifactId, version, type); + + org.apache.geronimo.jee.deployment.ObjectFactory serviceFactory = new org.apache.geronimo.jee.deployment.ObjectFactory(); + Artifact artifact = serviceFactory.createArtifact(); + + if (groupId != null) + artifact.setGroupId(groupId); + if (artifactId != null) + artifact.setArtifactId(artifactId); + if (version != null) + artifact.setVersion(version); + artifact.setType(type); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createArtifact", artifact); + return artifact; + } + + + public static Dependency createDependency(String groupId, String artifactId, String version, String type) { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.createDependency", groupId, artifactId, version, type); + + org.apache.geronimo.jee.deployment.ObjectFactory serviceFactory = new org.apache.geronimo.jee.deployment.ObjectFactory(); + Dependency dependency = serviceFactory.createDependency(); + if (groupId != null) + dependency.setGroupId(groupId); + if (artifactId != null) + dependency.setArtifactId(artifactId); + if (version != null) + dependency.setVersion(version); + dependency.setType(type); + + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.createDependency", dependency); + return dependency; + } + + + private static boolean hasValue(String attribute) { + Trace.tracePoint("Entry", "V21DeploymentPlanCreationOperation.hasValue", attribute); + Trace.tracePoint("Exit ", "V21DeploymentPlanCreationOperation.hasValue", (attribute != null && attribute.trim().length() != 0) ); + + return attribute != null && attribute.trim().length() != 0; + } + +}