You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mc...@apache.org on 2010/04/29 02:45:15 UTC
svn commit: r939145 [7/7] - in
/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core:
./ META-INF/ src/main/java/org/apache/geronimo/st/v30/core/
src/main/java/org/apache/geronimo/st/v30/core/commands/
src/main/java/org/apache...
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/DeploymentPlanCreationOperation.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/DeploymentPlanCreationOperation.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/DeploymentPlanCreationOperation.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/DeploymentPlanCreationOperation.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,307 @@
+/*
+ * 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.v30.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.Dependency;
+import org.apache.geronimo.jee.deployment.Dependencies;
+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.v30.core.Activator;
+import org.apache.geronimo.st.v30.core.GeronimoUtils;
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.apache.geronimo.st.v30.core.jaxb.JAXBUtils;
+import org.apache.geronimo.st.v30.core.DeploymentPlanInstallConfig;
+import org.apache.geronimo.st.v30.core.operations.DeploymentPlanCreationOperation;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+
+/**
+ * <strong>DeploymentPlanCreationOperation</strong>
+ * 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:
+ *
+ * <ol>
+ * <li>geronimo-application.xml
+ * <li>geronimo-application-client.xml
+ * <li>geronimo-ra.xml
+ * <li>geronimo-service.xml
+ * <li>geronimo-web.xml
+ * <li>openejb-jar.xml
+ * </ol>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DeploymentPlanCreationOperation extends
+ AbstractGeronimoJ2EEComponentOperation implements
+ IDeploymentPlanCreationOp {
+
+ DeploymentPlanInstallConfig cfg;
+
+ public DeploymentPlanCreationOperation(IDataModel model, Object config) {
+ super(model);
+ this.cfg = (DeploymentPlanInstallConfig) config;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ try {
+ execute();
+ }catch (Exception e){
+ return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Error in creating deployment plan",e);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public void execute() throws Exception {
+ IVirtualComponent comp = ComponentCore.createComponent(getProject());
+
+ String type = J2EEProjectUtilities.getJ2EEProjectType(getProject());
+
+ if (IModuleConstants.JST_WEB_MODULE.equals(type)) {
+ createGeronimoWebDeploymentPlan(GeronimoUtils.getWebDeploymentPlanFile(comp));
+ } else if (IModuleConstants.JST_EJB_MODULE.equals(type)) {
+ createOpenEjbDeploymentPlan(GeronimoUtils.getOpenEjbDeploymentPlanFile(comp));
+ } else if (IModuleConstants.JST_EAR_MODULE.equals(type)) {
+ createGeronimoApplicationDeploymentPlan(GeronimoUtils.getApplicationDeploymentPlanFile(comp));
+ } else if (IModuleConstants.JST_APPCLIENT_MODULE.equals(type)) {
+ createGeronimoApplicationClientDeploymentPlan(GeronimoUtils.getApplicationClientDeploymentPlanFile(comp));
+ } else if (IModuleConstants.JST_CONNECTOR_MODULE.equals(type)) {
+ createConnectorDeploymentPlan(GeronimoUtils.getConnectorDeploymentPlanFile(comp));
+ } else if (IModuleConstants.JST_UTILITY_MODULE.equals(type)) {
+ createServiceDeploymentPlan(GeronimoUtils.getServiceDeploymentPlanFile(comp));
+ }
+ }
+
+
+ public JAXBElement createServiceDeploymentPlan(IFile file) throws Exception{
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.core.operations.IDeploymentPlanCreationOp#createGeronimoApplicationDeploymentPlan(org.eclipse.core.resources.IFile)
+ */
+ public JAXBElement createGeronimoApplicationDeploymentPlan(IFile dpFile) throws Exception {
+ Trace.tracePoint("Entry",
+ "DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.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) throws Exception {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.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) throws Exception {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.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) throws Exception {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.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) throws Exception {
+ Trace.tracePoint("Entry","DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.createGeronimoApplicationClientDeploymentPlan", applicationClientFactory.createApplicationClient(applicationClient));
+ return applicationClientFactory.createApplicationClient(applicationClient);
+ }
+
+
+ public Environment getConfigEnvironment() {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.getConfigEnvironment");
+
+ 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 ", "DeploymentPlanCreationOperation.getConfigEnvironment", env);
+ return env;
+ }
+
+
+ public static Artifact createArtifact(String groupId, String artifactId, String version, String type) {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.createArtifact", artifact);
+ return artifact;
+ }
+
+
+ public static Dependency createDependency(String groupId, String artifactId, String version, String type) {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.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 ", "DeploymentPlanCreationOperation.createDependency", dependency);
+ return dependency;
+ }
+
+
+ private static boolean hasValue(String attribute) {
+ Trace.tracePoint("Entry", "DeploymentPlanCreationOperation.hasValue", attribute);
+ Trace.tracePoint("Exit ", "DeploymentPlanCreationOperation.hasValue", (attribute != null && attribute.trim().length() != 0) );
+
+ return attribute != null && attribute.trim().length() != 0;
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/DeploymentPlanCreationOperation.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/DeploymentPlanCreationOperation.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/DeploymentPlanCreationOperation.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/GeronimoAccountManager.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/GeronimoAccountManager.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoAccountManager.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoAccountManager.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,164 @@
+/*
+ * 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.v30.core.operations;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.wst.server.core.IRuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+//currently, only geronimo-admin with properties file realm is supported
+public class GeronimoAccountManager {
+ private Properties userProperties;
+ private Properties groupProperties;
+
+ private String securityPath;
+ private static final String userPropertiesFile = "users.properties";
+ private static final String groupPropertiesFile = "groups.properties";
+
+ public GeronimoAccountManager(IRuntime runtime){
+ if (runtime!=null){
+ securityPath = runtime.getLocation().toOSString()+"/var/security";
+ }
+ }
+
+ public void init() throws Exception{
+ userProperties = new Properties();
+ groupProperties= new Properties();
+ try {
+ FileInputStream fis = new FileInputStream(new File(securityPath,userPropertiesFile));
+ userProperties.load(fis);
+ fis.close();
+
+ fis = new FileInputStream(new File(securityPath,groupPropertiesFile));
+ groupProperties.load(fis);
+ fis.close();
+ } catch (FileNotFoundException e) {
+ Trace.trace(Trace.SEVERE, e.getMessage());
+ throw e;
+ } catch (IOException e) {
+ Trace.trace(Trace.SEVERE, e.getMessage());
+ throw e;
+ }
+ }
+
+ public String[] getUserList(){
+ return userProperties.keySet().toArray(new String[0]);
+ }
+
+ public String[] getGroupList(){
+ return groupProperties.keySet().toArray(new String[0]);
+ }
+
+ public boolean modifyUser(String oldName, String newName,String newGroup, String passwd){
+ boolean operationResult = false;
+
+ operationResult = true;
+ return operationResult;
+ }
+
+ private void addUserIntoGroup(String groupName,String userName){
+ String userList = groupProperties.getProperty(groupName);
+ int index = getIndexOfUser(userName,userList);
+ if (index!=-1){
+ //user already exists
+ return;
+ }else {
+ userList = userList.concat(",").concat(userName);
+ }
+ groupProperties.setProperty(groupName, userList);
+ }
+
+ private void delUserFromGroup(String groupName,String userName){
+ String userList = groupProperties.getProperty(groupName);
+ int index = getIndexOfUser(userName,userList);
+ if (index == -1) return;
+ else{
+ userList = removeUser(userList,index);
+ }
+ groupProperties.setProperty(groupName, userList);
+ }
+
+ private String removeUser(String userList, int index) {
+ String[] users = userList.split(",");
+ StringBuilder usersStr = new StringBuilder();
+ for (int i=0;i<users.length;i++){
+ if (i!=index) {
+ usersStr.append(users[i].concat(","));
+ }
+ }
+ //delete last comma
+ usersStr.deleteCharAt(usersStr.length()-1);
+
+ return usersStr.toString();
+ }
+
+ public void delUser(String userName){
+ String password = userProperties.getProperty(userName);
+ if (password!=null) {
+ userProperties.remove(userName);
+ }
+
+ Set<Object> groupSet = groupProperties.keySet();
+ for (Object group:groupSet){
+ delUserFromGroup((String)group,userName);
+ }
+ }
+
+
+ public void addUser(String userName,String groupName,String password){
+ userProperties.setProperty(userName, password);
+ addUserIntoGroup(groupName,userName);
+ }
+
+ public void persist() throws Exception, IOException{
+ try{
+ FileOutputStream fos = new FileOutputStream(new File(securityPath,groupPropertiesFile));
+ groupProperties.store(fos, "");
+ fos.close();
+
+ fos = new FileOutputStream(new File(securityPath,userPropertiesFile));
+ userProperties.store(fos, "");
+ fos.close();
+ } catch (FileNotFoundException e) {
+ Trace.trace(Trace.SEVERE, e.getMessage());
+ throw e;
+ } catch (IOException e) {
+ Trace.trace(Trace.SEVERE, e.getMessage());
+ throw e;
+ }
+ }
+
+ private int getIndexOfUser(String username,String userList){
+ String[] users = userList.split(",");
+ for (int i=0;i<users.length;i++){
+ if (users[i].equalsIgnoreCase(username))
+ return i;
+ }
+ return -1;
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoAccountManager.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/GeronimoAccountManager.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/GeronimoAccountManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: 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=939145&r1=939144&r2=939145&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java Thu Apr 29 00:45:13 2010
@@ -52,10 +52,10 @@ import org.apache.geronimo.kernel.config
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.v30.core.CommonMessages;
+import org.apache.geronimo.st.v30.core.GeronimoConnectionFactory;
+import org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v30.core.jaxb.JAXBUtils;
import org.apache.geronimo.st.v30.core.internal.Trace;
import org.apache.geronimo.system.jmx.KernelDelegate;
import org.apache.geronimo.system.plugin.PluginInstaller;
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/IDeploymentPlanCreationOp.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/IDeploymentPlanCreationOp.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/IDeploymentPlanCreationOp.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/IDeploymentPlanCreationOp.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,36 @@
+/*
+ * 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.v30.core.operations;
+
+import javax.xml.bind.JAXBElement;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface IDeploymentPlanCreationOp {
+
+ public JAXBElement createOpenEjbDeploymentPlan(IFile file) throws Exception;
+
+ public JAXBElement createGeronimoWebDeploymentPlan(IFile file) throws Exception;
+
+ public JAXBElement createGeronimoApplicationDeploymentPlan(IFile file) throws Exception;
+
+ public JAXBElement createConnectorDeploymentPlan(IFile file) throws Exception;
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/IDeploymentPlanCreationOp.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/IDeploymentPlanCreationOp.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/IDeploymentPlanCreationOp.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/ISharedLibEntryCreationDataModelProperties.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/ISharedLibEntryCreationDataModelProperties.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ISharedLibEntryCreationDataModelProperties.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ISharedLibEntryCreationDataModelProperties.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,29 @@
+/*
+ * 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.v30.core.operations;
+
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ISharedLibEntryCreationDataModelProperties extends IDataModelProperties {
+
+ public static final String MODULES = "ISharedLibEntryCreationDataModelProperties.MODULE"; //array of IModules
+ public static final String SERVER = "ISharedLibEntryCreationDataModelProperties.SERVER"; //IServer
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ISharedLibEntryCreationDataModelProperties.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/ISharedLibEntryCreationDataModelProperties.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/ISharedLibEntryCreationDataModelProperties.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/ImportDeploymentPlanDataModelProvider.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/ImportDeploymentPlanDataModelProvider.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ImportDeploymentPlanDataModelProvider.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ImportDeploymentPlanDataModelProvider.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v30.core.operations;
+
+import java.util.Set;
+
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImportDeploymentPlanDataModelProvider extends AbstractDataModelProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider#getPropertyNames()
+ */
+ public Set getPropertyNames() {
+ Set names = super.getPropertyNames();
+ names.add(IFacetDataModelProperties.FACET_PROJECT_NAME);
+ names.add(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
+ return names;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider#getDefaultOperation()
+ */
+ public IDataModelOperation getDefaultOperation() {
+ return new ImportDeploymentPlanOperation(model);
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ImportDeploymentPlanDataModelProvider.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/ImportDeploymentPlanDataModelProvider.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/ImportDeploymentPlanDataModelProvider.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/ImportDeploymentPlanOperation.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/ImportDeploymentPlanOperation.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ImportDeploymentPlanOperation.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ImportDeploymentPlanOperation.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,101 @@
+/*
+ * 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.v30.core.operations;
+
+import org.apache.geronimo.st.v30.core.GeronimoUtils;
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.apache.geronimo.st.v30.core.jaxb.ConversionHelper;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImportDeploymentPlanOperation extends AbstractGeronimoJ2EEComponentOperation {
+
+ /**
+ *
+ */
+ public ImportDeploymentPlanOperation() {
+ super();
+ Trace.tracePoint("Constructor", "ImportDeploymentPlanOperation");
+ }
+
+ /**
+ * @param model
+ */
+ public ImportDeploymentPlanOperation(IDataModel model) {
+ super(model);
+ Trace.tracePoint("Constructor", "ImportDeploymentPlanOperation", model);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Trace.tracePoint("Entry", "ImportDeploymentPlanOperation.execute", monitor, info);
+
+ if (!isGeronimoRuntimeTarget())
+ return Status.OK_STATUS;
+
+ IVirtualComponent comp = ComponentCore.createComponent(getProject());
+ String type = J2EEProjectUtilities.getJ2EEProjectType(getProject());
+
+ IFile planFile = null;
+
+ try {
+ if (type.equals(IModuleConstants.JST_WEB_MODULE)) {
+ planFile = GeronimoUtils.getWebDeploymentPlanFile(comp);
+ ConversionHelper.convertGeronimoWebFile(planFile);
+ }
+ else if (type.equals(IModuleConstants.JST_EJB_MODULE)) {
+ planFile = GeronimoUtils.getOpenEjbDeploymentPlanFile(comp);
+ ConversionHelper.convertOpenEjbJarFile(planFile);
+ }
+ else if (type.equals(IModuleConstants.JST_EAR_MODULE)) {
+ planFile = GeronimoUtils.getApplicationDeploymentPlanFile(comp);
+ ConversionHelper.convertGeronimoApplicationFile(planFile);
+ }
+ else if (type.equals(IModuleConstants.JST_CONNECTOR_MODULE)) {
+ planFile = GeronimoUtils.getConnectorDeploymentPlanFile(comp);
+ ConversionHelper.convertGeronimoRaFile(planFile);
+ }
+ else if (type.equals(IModuleConstants.JST_APPCLIENT_MODULE)) {
+ planFile = GeronimoUtils.getApplicationClientDeploymentPlanFile(comp);
+ ConversionHelper.convertGeronimoApplicationClientFile(planFile);
+ }
+ }
+ catch (Exception e) {
+ throw new ExecutionException("ImportDeploymentPlanOperation.execute(): Error converting plan: " + planFile.getFullPath() );
+ }
+
+ Trace.tracePoint("Exit ", "ImportDeploymentPlanOperation.execute", Status.OK_STATUS);
+ return Status.OK_STATUS;
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/ImportDeploymentPlanOperation.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/ImportDeploymentPlanOperation.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/ImportDeploymentPlanOperation.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/SharedLibEntryCreationOperation.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/SharedLibEntryCreationOperation.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/SharedLibEntryCreationOperation.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/SharedLibEntryCreationOperation.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,439 @@
+/*
+ * 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.v30.core.operations;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.DeploymentStatus;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.st.v30.core.Activator;
+import org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v30.core.GeronimoUtils;
+import org.apache.geronimo.st.v30.core.commands.DeploymentCommandFactory;
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ProgressUtil;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SharedLibEntryCreationOperation extends AbstractDataModelOperation implements ISharedLibEntryCreationDataModelProperties {
+
+ private TargetModuleID sharedLibTarget;
+ private IServer server;
+ private IProgressMonitor monitor;
+ private IPath sharedLibLocation;
+ private static final IPath TEMP_LOCATION = Activator.getDefault().getStateLocation().append("shared-lib-temp");
+
+ public SharedLibEntryCreationOperation() {
+ }
+
+ /**
+ * @param model
+ */
+ public SharedLibEntryCreationOperation(IDataModel model) {
+ super(model);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Trace.trace(Trace.INFO, ">> SharedLibEntryCreationOperation.execute()");
+
+ this.monitor = ProgressUtil.getMonitorFor(monitor);
+ this.monitor.beginTask("Processing in-place shared libraries.", 100);
+
+ IModule[] modules = (IModule[]) model.getProperty(MODULES);
+ this.server = (IServer) model.getProperty(SERVER);
+
+ HashMap<File, File> addList = new HashMap<File, File>();
+ List<File> deleteList = new ArrayList<File>();
+
+ try {
+ String sharedLibPath = getSharedLibPath();
+ if(sharedLibPath == null)
+ return Status.CANCEL_STATUS;
+
+ sharedLibLocation = server.getRuntime().getLocation().append(sharedLibPath);
+
+ for(int i = 0; i < modules.length; i++) {
+ IModule module = modules[i];
+ IProject project = module.getProject();
+
+ File dummyJarFile = sharedLibLocation.append(project.getName() + ".eclipse.jar").toFile();
+ // delete the dummy jar if module no longer associated with server
+ if (!ServerUtil.containsModule(server, module, monitor) && dummyJarFile.exists()) {
+ deleteList.add(dummyJarFile);
+ } else {
+ HashSet entries = new HashSet();
+ J2EEFlexProjDeployable j2eeModule = (J2EEFlexProjDeployable) module.loadAdapter(J2EEFlexProjDeployable.class, null);
+ if(GeronimoUtils.isEarModule(module)) {
+ IModule[] childModules = j2eeModule.getChildModules();
+ for(int j = 0; j < modules.length; j++) {
+ entries.addAll(processModule(childModules[i]));
+ }
+ } else {
+ entries.addAll(processModule(module));
+ }
+
+ // regen the jar only if required
+ if (regenerate(dummyJarFile, entries)) {
+ TEMP_LOCATION.toFile().mkdirs();
+ File temp = TEMP_LOCATION.append(project.getName() + ".eclipse.jar").toFile();
+ Trace.trace(Trace.INFO, "Updating external sharedlib entries for " + module.getName());
+ if(temp.exists())
+ delete(temp);
+ Manifest manifest = new Manifest();
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ attributes.put(Attributes.Name.CLASS_PATH, getCPEntriesAsString(entries));
+ JarOutputStream os = new JarOutputStream(new FileOutputStream(temp), manifest);
+ os.flush();
+ os.close();
+ addList.put(temp, dummyJarFile);
+ }
+ }
+ }
+
+ updateAndRecycleSharedLib(addList, deleteList);
+
+ }catch (CoreException e){
+ IStatus status = e.getStatus();
+ Trace.trace(Trace.SEVERE, status.getMessage(), e);
+ throw new ExecutionException(status.getMessage(), e);
+ }catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Failure in updating shared library.", e);
+ throw new ExecutionException("Failure in updating shared library", e);
+ } finally {
+ monitor.done();
+ }
+
+ Trace.trace(Trace.INFO, "<< SharedLibEntryCreationOperation.execute()");
+ return Status.OK_STATUS;
+ }
+
+ private void updateAndRecycleSharedLib(HashMap addList, List deleteList) throws Exception {
+ if(addList.size() > 0 || deleteList.size() > 0) {
+ stopSharedLib();
+ for(int i = 0; i < deleteList.size(); i++) {
+ File file = (File) deleteList.get(i);
+ delete(file);
+ }
+ Iterator i = addList.keySet().iterator();
+ while(i.hasNext()) {
+ File src = (File) i.next();
+ File dest = (File) addList.get(src);
+ if(dest.exists()) {
+ delete(dest);
+ }
+ copy(src, dest);
+ }
+ startSharedLib();
+ }
+ }
+
+ private void copy(File src, File dest) throws Exception {
+ try {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dest);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ } catch (Exception e) {
+ throw e;
+ }
+ Trace.trace(Trace.INFO, "Created " + dest.getAbsolutePath());
+ }
+
+ private String getSharedLibPath() throws Exception {
+ // locate the path of the first sharedlib library folder
+ GeronimoServerBehaviourDelegate gsDelegate = (GeronimoServerBehaviourDelegate) server.getAdapter(GeronimoServerBehaviourDelegate.class);
+ MBeanServerConnection connection = gsDelegate.getServerConnection();
+ Set result = connection.queryMBeans(new ObjectName("*:j2eeType=GBean,name=SharedLib,*"), null);
+ if (!result.isEmpty()) {
+ ObjectInstance instance = (ObjectInstance) result.toArray()[0];
+ String[] libDirs = (String[]) connection.getAttribute(instance.getObjectName(),"libDirs");
+ if (libDirs != null && libDirs.length > 0) {
+ return libDirs[0];
+ }
+ }
+ return null;
+ }
+
+ private HashSet processModule(IModule module) throws Exception {
+ Trace.trace(Trace.INFO, "SharedLibEntryCreationOperation.process() " + module.getName());
+
+ IProject project = module.getProject();
+ // filter the cp entries needed to be added to the dummy shared lib
+ // jar
+ HashSet entries = new HashSet();
+ processJavaProject(project, entries, false);
+
+ // add output locations of referenced projects excluding non-child
+ // projects
+ ModuleDelegate delegate = (ModuleDelegate) module.loadAdapter(ModuleDelegate.class, null);
+ if(delegate != null) {
+ IProject[] refs = project.getReferencedProjects();
+ for(int i = 0; i < refs.length; i++) {
+ boolean found = false;
+ IModule[] children = delegate.getChildModules();
+ for(int j = 0; j < children.length; j++) {
+ if(children[j].getProject().equals(refs[i])) {
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ processJavaProject(refs[i], entries, true);
+ }
+ }
+ }
+ return entries;
+ }
+
+ private void delete(File dummyJarFile) throws CoreException {
+ if(dummyJarFile.delete()) {
+ Trace.trace(Trace.INFO, dummyJarFile.getAbsolutePath() + " deleted sucessfully.");
+ } else {
+ Trace.trace(Trace.SEVERE, "Failed to delete " + dummyJarFile.getAbsolutePath(), null);
+ throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Failed to delete " + dummyJarFile.getAbsolutePath(),null));
+ }
+ }
+
+ private void processJavaProject(IProject project, HashSet entries, boolean includeOutputLocations) throws JavaModelException {
+ IJavaProject jp = JavaCore.create(project);
+ IClasspathEntry[] cp = jp.getRawClasspath();
+ for (int i = 0; i < cp.length; i++) {
+ IClasspathEntry entry = cp[i];
+ int kind = entry.getEntryKind();
+ String path = null;
+ if(kind == IClasspathEntry.CPE_CONTAINER) {
+ if("org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER".equals(entry.getPath().toString())) {
+ IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), jp);
+ IClasspathEntry[] containerEntries = container.getClasspathEntries();
+ for(int j = 0; j < containerEntries.length; j++) {
+ addEntry(entries, resolveVarOrLibEntry(containerEntries[j]));
+ }
+ }
+ } else if (kind == IClasspathEntry.CPE_PROJECT) {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().segment(0));
+ IJavaProject ref = JavaCore.create(p);
+ path = p.getLocation().removeLastSegments(1).append(ref.getOutputLocation()).addTrailingSeparator().toOSString();
+ } else if (kind == IClasspathEntry.CPE_SOURCE) {
+ // this if not combined with parent statement to filter out
+ // CPE_SOURCE entries from following else statement
+ // if no outputlocation, output path will get picked up by
+ // default output path
+ if(includeOutputLocations && entry.getOutputLocation() != null) {
+ path = project.getLocation().append(entry.getOutputLocation().removeFirstSegments(1)).addTrailingSeparator().toOSString();
+ }
+ } else {
+ path = resolveVarOrLibEntry(entry);
+ }
+ addEntry(entries, path);
+ }
+
+ if(includeOutputLocations) {
+ String path = project.getLocation().append(jp.getOutputLocation().removeFirstSegments(1)).addTrailingSeparator().toOSString();
+ addEntry(entries, path);
+ }
+ }
+
+ private String resolveVarOrLibEntry(IClasspathEntry entry) {
+ IClasspathEntry resolved = JavaCore.getResolvedClasspathEntry(entry);
+ IPath resolvedPath = resolved.getPath().makeAbsolute();
+ IProject candiate = ResourcesPlugin.getWorkspace().getRoot().getProject(resolvedPath.segment(0));
+ // check if resolvedPath is a project resource
+ if(candiate.exists(resolvedPath.removeFirstSegments(1))) {
+ return candiate.getLocation().append(resolvedPath.removeFirstSegments(1)).toOSString();
+ } else {
+ return resolvedPath.toOSString();
+ }
+ }
+
+ private void addEntry(HashSet entries, String path) {
+ if(path != null) {
+ File f = new File(path);
+ try {
+ String url = f.toURL().toExternalForm();
+ if (!entries.contains(url)) {
+ Trace.trace(Trace.INFO, "Adding " + url);
+ monitor.subTask("Linking " + url + " to shared lib.");
+ entries.add(url);
+ }
+ } catch (MalformedURLException e1) {
+ Trace.trace(Trace.INFO, "Failed to add " + path);
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * @param entries
+ * @return
+ */
+ private String getCPEntriesAsString(Set entries) {
+ StringBuffer buffer = new StringBuffer();
+ Iterator i = entries.iterator();
+ while (i.hasNext()) {
+ String cpEntry = (String) i.next();
+ buffer.append(cpEntry);
+ if (i.hasNext()) {
+ buffer.append(" ");
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * @param jarPath
+ * @param entries
+ * @return
+ * @throws Exception
+ */
+ private boolean regenerate(File jarFile, Set entries) throws Exception {
+ if (jarFile.exists()) {
+ if (entries.isEmpty()) {
+ // go ahead and return if zero entires, dummy jar will be
+ // deleted
+ return true;
+ } else {
+ JarFile jar = new JarFile(jarFile);
+ Manifest manifest = jar.getManifest();
+ Attributes attributes = manifest.getMainAttributes();
+ String value = attributes.getValue(Attributes.Name.CLASS_PATH);
+ jar.close();
+
+ Set currentEntries = new HashSet();
+ if (value != null) {
+ StringTokenizer tokenizer = new StringTokenizer(value);
+ while (tokenizer.hasMoreTokens()) {
+ currentEntries.add(tokenizer.nextToken());
+ }
+ }
+ // regen dummy jar if old and new entries don't match
+ return !entries.equals(currentEntries);
+ }
+ }
+
+ return !entries.isEmpty();
+ }
+
+ private void stopSharedLib() throws Exception {
+ DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(server);
+ TargetModuleID id = getSharedLibTargetModuleID();
+ TargetModuleID[] ids = new TargetModuleID[]{id};
+ ProgressObject po = dm.stop(ids);
+ waitForProgress(po);
+ if(po.getDeploymentStatus().isFailed()) {
+ throw new Exception(po.getDeploymentStatus().getMessage());
+ }
+ }
+
+ private void startSharedLib() throws Exception {
+ DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(server);
+ TargetModuleID id = getSharedLibTargetModuleID();
+ ProgressObject po = dm.start(new TargetModuleID[]{id});
+ waitForProgress(po);
+ if(po.getDeploymentStatus().isFailed()) {
+ throw new Exception(po.getDeploymentStatus().getMessage());
+ }
+ }
+
+ private TargetModuleID getSharedLibTargetModuleID() throws Exception {
+ if(sharedLibTarget == null) {
+ DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(server);
+ TargetModuleID[] ids = dm.getAvailableModules(null, dm.getTargets());
+ for(int i = 0; i < ids.length; i++) {
+ if(ids[i].getModuleID().indexOf("sharedlib") > 0) {
+ sharedLibTarget = ids[i];
+ break;
+ }
+ }
+ }
+
+ if(sharedLibTarget == null) {
+ throw new Exception("Could not determine SharedLib TargetModuleID.");
+ }
+
+ return sharedLibTarget;
+ }
+
+ private void waitForProgress(ProgressObject po) {
+ while (po.getDeploymentStatus().isRunning()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ DeploymentStatus status = po.getDeploymentStatus();
+ String command = status.getCommand().toString();
+ String state = status.getState().toString();
+ Trace.trace(Trace.INFO, "SharedLib " + " " + command + " " + state);
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/SharedLibEntryCreationOperation.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/SharedLibEntryCreationOperation.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/SharedLibEntryCreationOperation.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/SharedLibEntryDataModelProvider.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/SharedLibEntryDataModelProvider.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/SharedLibEntryDataModelProvider.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/SharedLibEntryDataModelProvider.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.v30.core.operations;
+
+import java.util.Set;
+
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SharedLibEntryDataModelProvider extends AbstractDataModelProvider implements ISharedLibEntryCreationDataModelProperties {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider#getPropertyNames()
+ */
+ public Set getPropertyNames() {
+ Set names = super.getPropertyNames();
+ names.add(MODULES);
+ names.add(SERVER);
+ return names;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider#getDefaultOperation()
+ */
+ public IDataModelOperation getDefaultOperation() {
+ return new SharedLibEntryCreationOperation(model);
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/SharedLibEntryDataModelProvider.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/SharedLibEntryDataModelProvider.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/SharedLibEntryDataModelProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain