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 [2/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/GeronimoFacetInstallDelegate.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/GeronimoFacetInstallDelegate.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/GeronimoFacetInstallDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoFacetInstallDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.apache.geronimo.st.v30.core.operations.DeploymentPlanCreationOperation;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.common.project.facet.JavaProjectFacetCreationDataModelProvider;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoFacetInstallDelegate implements IDelegate {
+
+ public static final String FACET_ID = "org.apache.geronimo.facet";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject,
+ * org.eclipse.wst.common.project.facet.core.IProjectFacetVersion,
+ * java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
+
+ try {
+ createDeploymentPlanCreationOp(project, config).execute(monitor, null);
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+
+ IProject[] ears = J2EEProjectUtilities.getReferencingEARProjects(project);
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet(FACET_ID);
+ for (int i = 0; i < ears.length; i++) {
+ IFacetedProject fp = ProjectFacetsManager.create(ears[i]);
+ if (!fp.hasProjectFacet(facet)) {
+ try {
+ createDeploymentPlanCreationOp(ears[i], config).execute(monitor, null);
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public IDataModelOperation createDeploymentPlanCreationOp(IProject project, Object config) {
+ Trace.tracePoint("Entry", "GeronimoFacetInstallDelegate.createDeploymentPlanCreationOp", project, config);
+
+ IDataModel model = DataModelFactory.createDataModel(new JavaProjectFacetCreationDataModelProvider());
+ model.setStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project.getName());
+
+ Trace.tracePoint("Exit ", "GeronimoFacetInstallDelegate.createDeploymentPlanCreationOp");
+ return new DeploymentPlanCreationOperation(model, config);
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoFacetInstallDelegate.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/GeronimoFacetInstallDelegate.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/GeronimoFacetInstallDelegate.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/GeronimoLaunchConfigurationDelegate.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/GeronimoLaunchConfigurationDelegate.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/GeronimoLaunchConfigurationDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,122 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.geronimo.st.v30.core.internal.Messages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.ExecutionArguments;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.jst.server.core.ServerProfilerDelegate;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
+ * java.lang.String, org.eclipse.debug.core.ILaunch,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+ if (configuration.hasAttribute(GeronimoServerBehaviourDelegate.ERROR_SETUP_LAUNCH_CONFIGURATION)){
+ //get error flag from configuration if it's set in setLaunchConfiguration
+ String errorMessage = configuration.getAttribute(GeronimoServerBehaviourDelegate.ERROR_SETUP_LAUNCH_CONFIGURATION,"");
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, errorMessage, null));
+ }
+
+ IServer server = ServerUtil.getServer(configuration);
+ if (server == null) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, Messages.missingServer, null));
+ }
+ GeronimoServerBehaviourDelegate geronimoServer = (GeronimoServerBehaviourDelegate) server.loadAdapter(GeronimoServerBehaviourDelegate.class, null);
+ geronimoServer.setupLaunch(launch, mode, monitor);
+
+ if (geronimoServer.isRemote()) {
+ // no support for launching remote servers
+ return;
+ }
+
+ String mainTypeName = geronimoServer.getRuntimeClass();
+ IVMInstall vm = verifyVMInstall(configuration);
+ IVMRunner runner = vm.getVMRunner(mode);
+
+ if(runner == null && ILaunchManager.PROFILE_MODE.equals(mode)){
+ runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
+ }
+
+ File workingDir = verifyWorkingDirectory(configuration);
+ String workingDirName = null;
+ if (workingDir != null)
+ workingDirName = workingDir.getAbsolutePath();
+
+ String pgmArgs = getProgramArguments(configuration);
+ String vmArgs = getVMArguments(configuration);
+ String[] envp = getEnvironment(configuration);
+
+ ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
+ Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
+ String[] classpath = getClasspath(configuration);
+
+ // Create VM config
+ VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
+ runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
+ runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+ runConfig.setWorkingDirectory(workingDirName);
+ runConfig.setEnvironment(envp);
+ runConfig.setVMSpecificAttributesMap(vmAttributesMap);
+
+ // Bootpath
+ String[] bootpath = getBootpath(configuration);
+ if (bootpath != null && bootpath.length > 0)
+ runConfig.setBootClassPath(bootpath);
+
+ setDefaultSourceLocator(launch, configuration);
+
+ if (ILaunchManager.PROFILE_MODE.equals(mode)) {
+ try {
+ ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
+ } catch (CoreException ce) {
+ geronimoServer.stopImpl();
+ throw ce;
+ }
+ }
+
+ geronimoServer.startPingThread();
+ runner.run(runConfig, launch, monitor);
+ geronimoServer.setProcess(launch.getProcesses()[0]);
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.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/GeronimoLaunchConfigurationDelegate.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/GeronimoLaunchConfigurationDelegate.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/GeronimoLaunchableAdapterDelegate.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/GeronimoLaunchableAdapterDelegate.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/GeronimoLaunchableAdapterDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchableAdapterDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,89 @@
+/*
+ * 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;
+
+import java.net.URL;
+
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.server.core.Servlet;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IURLProvider;
+import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+import org.eclipse.wst.server.core.util.HttpLaunchable;
+import org.eclipse.wst.server.core.util.WebResource;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoLaunchableAdapterDelegate extends LaunchableAdapterDelegate {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.server.core.model.LaunchableAdapterDelegate#getLaunchable(org.eclipse.wst.server.core.IServer,
+ * org.eclipse.wst.server.core.IModuleArtifact)
+ */
+ public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
+
+ GeronimoServerDelegate delegate = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+ if (delegate == null)
+ delegate = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
+ if (delegate == null)
+ return null;
+
+ if ((moduleArtifact instanceof Servlet)
+ || (moduleArtifact instanceof WebResource))
+ return getHttpLaunchable(moduleArtifact, delegate);
+
+ return null;
+ }
+
+ private Object getHttpLaunchable(IModuleArtifact moduleObject, ServerDelegate delegate) throws CoreException {
+ URL url = ((IURLProvider) delegate).getModuleRootURL(moduleObject.getModule());
+ try {
+ if (moduleObject instanceof Servlet) {
+ Servlet servlet = (Servlet) moduleObject;
+ if (servlet.getAlias() != null) {
+ String path = servlet.getAlias();
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ url = new URL(url, path);
+ } else
+ url = new URL(url, "servlet/"
+ + servlet.getServletClassName());
+ } else if (moduleObject instanceof WebResource) {
+ WebResource resource = (WebResource) moduleObject;
+ String path = resource.getPath().toString();
+ if (path != null && path.startsWith("/") && path.length() > 0)
+ path = path.substring(1);
+ if (path != null && path.length() > 0)
+ url = new URL(url, path);
+ }
+ return new HttpLaunchable(url);
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Error getting URL for " + moduleObject, e);
+ throw new CoreException (new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Error getting URL for " + moduleObject,e));
+ }
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchableAdapterDelegate.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/GeronimoLaunchableAdapterDelegate.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/GeronimoLaunchableAdapterDelegate.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/GeronimoRuntime.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/GeronimoRuntime.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/GeronimoRuntime.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntime.java Thu Apr 29 00:45:13 2010
@@ -16,7 +16,7 @@
*/
package org.apache.geronimo.st.v30.core;
-import org.apache.geronimo.st.core.GeronimoRuntimeDelegate;
+import org.apache.geronimo.st.v30.core.GeronimoRuntimeDelegate;
/**
* @version $Rev$ $Date$
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.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/GeronimoRuntimeDelegate.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/GeronimoRuntimeDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,399 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.geronimo.st.v30.core.internal.Messages;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMInstallType;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.model.RuntimeDelegate;
+
+/**
+ * @version $Rev$ $Date$
+ */
+abstract public class GeronimoRuntimeDelegate extends RuntimeDelegate implements IGeronimoRuntime {
+
+ private static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id";
+
+ private static final String PROP_VM_INSTALL_ID = "vm-install-id";
+
+ public static final String SERVER_INSTANCE_PROPERTIES = "geronimo_server_instance_properties";
+
+ public static final String RUNTIME_SOURCE= "runtime.source";
+
+ public static final int NO_IMAGE = 0;
+
+ public static final int INCORRECT_VERSION = 1;
+
+ public static final int PARTIAL_IMAGE = 2;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jst.server.core.IJavaRuntime#getVMInstall()
+ */
+ public IVMInstall getVMInstall() {
+ if (getVMInstallTypeId() == null)
+ return JavaRuntime.getDefaultVMInstall();
+ try {
+ IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
+ IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
+ int size = vmInstalls.length;
+ String id = getVMInstallId();
+ for (int i = 0; i < size; i++) {
+ if (id.equals(vmInstalls[i].getId()))
+ return vmInstalls[i];
+ }
+ }
+ catch (Exception e) {
+ // ignore
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.server.core.model.RuntimeDelegate#validate()
+ */
+ public IStatus validate() {
+ IStatus status = super.validate();
+
+ if (!status.isOK()) {
+ return status;
+ }
+
+ if (getVMInstall() == null)
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.errorJRE, null);
+
+ IPath runtimeLoc = getRuntime().getLocation();
+
+ // check for server file structure
+ String version = getRuntime().getRuntimeType().getVersion();
+ int count = 0;
+ int limit = 4;
+ if (version.startsWith("3")){
+ //for version 3.0+
+
+ count = runtimeLoc.append("lib").toFile().exists() ? ++count : count;
+ count = runtimeLoc.append("repository").toFile().exists() ? ++count : count;
+
+ limit = 2;
+
+ }else{
+ //for version before 3.0
+ count = runtimeLoc.append("bin/server.jar").toFile().exists() ? ++count : count;
+ count = runtimeLoc.append("bin/deployer.jar").toFile().exists() ? ++count : count;
+ count = runtimeLoc.append("lib").toFile().exists() ? ++count : count;
+ count = runtimeLoc.append("repository").toFile().exists() ? ++count : count;
+
+ }
+
+ if (count == 0) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NO_IMAGE, "", null);
+ }
+
+ if (count < limit) {
+
+ // part of a server image was found, don't let install happen
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ PARTIAL_IMAGE, Messages.bind(Messages.missingContent,
+ getRuntime().getName()), null);
+ }
+
+
+
+ String detectedVersion = detectVersion();
+ if (detectedVersion == null) {
+ return new Status(IStatus.WARNING, Activator.PLUGIN_ID,
+ INCORRECT_VERSION, Messages.bind(Messages.noVersion,
+ getRuntime().getName()), null);
+ }
+
+ if (!detectedVersion.startsWith(getRuntime().getRuntimeType()
+ .getVersion())) {
+ String runtimeVersion = getRuntime().getRuntimeType().getVersion();
+ String message = NLS.bind(Messages.incorrectVersion,
+ new String[] { getRuntime().getName(),
+ runtimeVersion,
+ detectedVersion });
+ // GD332 allow version > if it's a SNAPSHOT
+ int severity = IStatus.ERROR;
+ if (detectedVersion.endsWith("-SNAPSHOT")
+ && detectedVersion.compareTo(runtimeVersion) >= 0) {
+ severity = IStatus.WARNING;
+ }
+ return new Status(severity, Activator.PLUGIN_ID, INCORRECT_VERSION,
+ message, null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.server.core.model.RuntimeDelegate#setDefaults(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void setDefaults(IProgressMonitor monitor) {
+ IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
+ setVMInstall(vmInstall.getVMInstallType().getId(), vmInstall.getId());
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.geronimo.st.v30.core.IGeronimoRuntime#getRuntimeSourceLocation()
+ */
+ public IPath getRuntimeSourceLocation() {
+ String source = (String) getServerInstanceProperties().get(RUNTIME_SOURCE);
+ if (source != null) {
+ return new Path(source);
+ }
+ return null;
+ }
+
+ public void setRuntimeSourceLocation(String path) {
+ setInstanceProperty(RUNTIME_SOURCE, path);
+ }
+
+ /**
+ * @return
+ */
+ public String detectVersion() {
+
+ URL systemjarURL = null;
+
+ //
+ // Check lib directory first
+ //
+ File libDir = getRuntime().getLocation().append("lib").toFile();
+ if (libDir.exists()) {
+ File[] libs = libDir.listFiles();
+ for (int i = 0; i < libs.length; i++) {
+ if (libs[i].getName().startsWith("geronimo-system")) {
+ try {
+ systemjarURL = libs[i].toURL();
+ break;
+ }
+ catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ //
+ // Check pre-2.1 repository if necessary
+ //
+ if (systemjarURL == null) {
+ File systemDir = getRuntime().getLocation().append("repository/org/apache/geronimo/modules/geronimo-system").toFile();
+ if (systemDir.exists() && systemDir.isDirectory() && systemDir.canRead()) {
+ List<File> dirFiles = scanDirectory(systemDir);
+ for (File jarFile : dirFiles) {
+ if (jarFile.getName().startsWith("geronimo-system") && jarFile.getName().endsWith("jar")) {
+ try {
+ systemjarURL = jarFile.toURL();
+ break;
+ }
+ catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ //
+ // Check 2.1 repository if necessary
+ //
+ if (systemjarURL == null) {
+ File systemDir = getRuntime().getLocation().append("repository/org/apache/geronimo/framework/geronimo-system").toFile();
+ if (systemDir.exists() && systemDir.isDirectory() && systemDir.canRead()) {
+ List<File> dirFiles = scanDirectory(systemDir);
+ for (File jarFile : dirFiles) {
+ if (jarFile.getName().startsWith("geronimo-system") && jarFile.getName().endsWith("jar")) {
+ try {
+ systemjarURL = jarFile.toURL();
+ break;
+ }
+ catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ if (systemjarURL != null) {
+ try {
+ String version = null;
+ JarFile jar = new JarFile(systemjarURL.getFile());
+ Enumeration<JarEntry> entries = jar.entries();
+ while(entries.hasMoreElements()){
+ JarEntry entry = entries.nextElement();
+ if (entry.getName().indexOf("geronimo-version.properties")!=-1 ||
+ entry.getName().indexOf("server-version.properties")!=-1 ){
+ InputStream is = jar.getInputStream(entry);
+ Properties properties = new Properties();
+ properties.load(is);
+ version = properties.getProperty("version");
+ is.close();
+ }
+ }
+ jar.close();
+ return version;
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ public String getInstallableTomcatRuntimeId() {
+ return "org.apache.geronimo.runtime.tomcat." + getRuntime().getRuntimeType().getVersion().replaceAll("\\.", "");
+ }
+
+ /**
+ * @return
+ */
+ public String getInstallableJettyRuntimeId() {
+ return "org.apache.geronimo.runtime.jetty." + getRuntime().getRuntimeType().getVersion().replaceAll("\\.", "");
+ }
+
+ /**
+ * @return
+ */
+ public Map getServerInstanceProperties() {
+ return getAttribute(SERVER_INSTANCE_PROPERTIES, new HashMap());
+ }
+
+ /**
+ * @param map
+ */
+ public void setServerInstanceProperties(Map map) {
+ setAttribute(SERVER_INSTANCE_PROPERTIES, map);
+ }
+
+ /**
+ * @param name
+ * @return
+ */
+ public String getInstanceProperty(String name) {
+ return(String) getServerInstanceProperties().get(name);
+ }
+
+ /**
+ * @param name
+ * @param value
+ */
+ public void setInstanceProperty(String name, String value) {
+ Map map = getServerInstanceProperties();
+ map.put(name, value);
+ setServerInstanceProperties(map);
+ }
+
+ /**
+ * @param vmInstall
+ */
+ public void setVMInstall(IVMInstall vmInstall) {
+ if (vmInstall == null) {
+ setVMInstall(null, null);
+ }
+ else
+ setVMInstall(vmInstall.getVMInstallType().getId(), vmInstall.getId());
+ }
+
+ /**
+ * @param typeId
+ * @param id
+ */
+ public void setVMInstall(String typeId, String id) {
+ if (typeId == null)
+ setAttribute(PROP_VM_INSTALL_TYPE_ID, (String) null);
+ else
+ setAttribute(PROP_VM_INSTALL_TYPE_ID, typeId);
+
+ if (id == null)
+ setAttribute(PROP_VM_INSTALL_ID, (String) null);
+ else
+ setAttribute(PROP_VM_INSTALL_ID, id);
+ }
+
+ /**
+ * @return
+ */
+ public String getVMInstallTypeId() {
+ return getAttribute(PROP_VM_INSTALL_TYPE_ID, (String) null);
+ }
+
+ /**
+ * @return
+ */
+ public String getVMInstallId() {
+ return getAttribute(PROP_VM_INSTALL_ID, (String) null);
+ }
+
+ /**
+ * @return
+ */
+ public boolean isUsingDefaultJRE() {
+ return getVMInstallTypeId() == null;
+ }
+
+ private static List<File> scanDirectory(File dir) {
+ List<File> dirFiles = new ArrayList<File>();
+ scanDirectory(dir, dirFiles);
+ return dirFiles;
+ }
+
+ private static void scanDirectory(File dir, List<File> dirFiles) {
+ File[] files = dir.listFiles();
+ for (int ii = 0; ii < files.length; ii++) {
+ if (files[ii].isDirectory()) {
+ scanDirectory(files[ii], dirFiles);
+ }
+ else {
+ dirFiles.add(files[ii]);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.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/GeronimoRuntimeDelegate.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/GeronimoRuntimeDelegate.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/GeronimoSchemaNS.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/GeronimoSchemaNS.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/GeronimoSchemaNS.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSchemaNS.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoSchemaNS {
+
+ private GeronimoSchemaNS() {
+ }
+
+ public static final String GERONIMO_APP_NS_1_0 = "http://geronimo.apache.org/xml/ns/j2ee/application-1.0";
+ public static final String GERONIMO_WEB_NS_1_0 = "http://geronimo.apache.org/xml/ns/j2ee/web-1.0";
+ public static final String GERONIMO_OPENEJB_NS_2_0 = "http://www.openejb.org/xml/ns/openejb-jar-2.0";
+ public static final String GERONIMO_CONNECTOR_NS_1_0 = "http://geronimo.apache.org/xml/ns/j2ee/connector-1.0";
+ public static final String GERONIMO_NAMING_NS_1_0 = "http://geronimo.apache.org/xml/ns/naming-1.0";
+ public static final String GERONIMO_SECURITY_NS_1_1 = "http://geronimo.apache.org/xml/ns/security-1.1";
+ public static final String GERONIMO_DEPLOYMENT_NS_1_0 = "http://geronimo.apache.org/xml/ns/deployment-1.0";
+ public static final String GERONIMO_PKGEN_NS_2_0 = "http://www.openejb.org/xml/ns/pkgen-2.0";
+
+ public static final String GERONIMO_APP_NS_1_1 = "http://geronimo.apache.org/xml/ns/j2ee/application-1.1";
+ public static final String GERONIMO_WEB_NS_1_1 = "http://geronimo.apache.org/xml/ns/j2ee/web-1.1";
+ public static final String GERONIMO_OPENEJB_NS_2_1 = "http://www.openejb.org/xml/ns/openejb-jar-2.1";
+ public static final String GERONIMO_OPENEJB_NS_2_2 = "http://www.openejb.org/xml/ns/openejb-jar-2.2";
+ public static final String GERONIMO_CONNECTOR_NS_1_1 = "http://geronimo.apache.org/xml/ns/j2ee/connector-1.1";
+ public static final String GERONIMO_NAMING_NS_1_1 = "http://geronimo.apache.org/xml/ns/naming-1.1";
+ public static final String GERONIMO_DEPLOYMENT_NS_1_1 = "http://geronimo.apache.org/xml/ns/deployment-1.1";
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSchemaNS.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/GeronimoSchemaNS.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/GeronimoSchemaNS.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/GeronimoServer.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/GeronimoServer.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/GeronimoServer.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServer.java Thu Apr 29 00:45:13 2010
@@ -24,9 +24,9 @@ import javax.enterprise.deploy.spi.facto
import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
-import org.apache.geronimo.st.core.GeronimoRuntimeDelegate;
-import org.apache.geronimo.st.core.GeronimoServerDelegate;
-import org.apache.geronimo.st.core.IGeronimoVersionHandler;
+import org.apache.geronimo.st.v30.core.GeronimoRuntimeDelegate;
+import org.apache.geronimo.st.v30.core.GeronimoServerDelegate;
+import org.apache.geronimo.st.v30.core.IGeronimoVersionHandler;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -53,16 +53,16 @@ public class GeronimoServer extends Gero
}
/* (non-Javadoc)
- * @see org.apache.geronimo.st.core.GenericGeronimoServer#getContextRoot(org.eclipse.wst.server.core.IModule)
+ * @see org.apache.geronimo.st.v30.core.GenericGeronimoServer#getContextRoot(org.eclipse.wst.server.core.IModule)
*/
public String getContextRoot(IModule module) throws Exception {
- return GeronimoV30Utils.getContextRoot(module);
+ return GeronimoUtils.getContextRoot(module);
}
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.IGeronimoServer#getDeployerURL()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#getDeployerURL()
*/
public String getDeployerURL() {
return "deployer:geronimo:jmx://" + getServer().getHost() + ":" + getRMINamingPort();
@@ -127,7 +127,7 @@ public class GeronimoServer extends Gero
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.IGeronimoServer#getJMXServiceURL()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#getJMXServiceURL()
*/
public String getJMXServiceURL() {
String host = getServer().getHost();
@@ -137,7 +137,7 @@ public class GeronimoServer extends Gero
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.IGeronimoServer#getJSR88DeployerJar()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#getJSR88DeployerJar()
*/
public IPath getJSR88DeployerJar() {
return getServer().getRuntime().getLocation().append("/lib/jsr88-deploymentfactory.jar");
@@ -146,7 +146,7 @@ public class GeronimoServer extends Gero
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.IGeronimoServer#getDeploymentFactory()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#getDeploymentFactory()
*/
public DeploymentFactory getDeploymentFactory() {
return deploymentFactory;
@@ -155,7 +155,7 @@ public class GeronimoServer extends Gero
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.IGeronimoServer#configureDeploymentManager(javax.enterprise.deploy.spi.DeploymentManager)
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#configureDeploymentManager(javax.enterprise.deploy.spi.DeploymentManager)
*/
public void configureDeploymentManager(DeploymentManager dm) {
((JMXDeploymentManager) dm).setLogConfiguration(true, true);
@@ -166,11 +166,11 @@ public class GeronimoServer extends Gero
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.IGeronimoServer#getVersionHandler()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#getVersionHandler()
*/
public IGeronimoVersionHandler getVersionHandler() {
if (versionHandler == null)
- versionHandler = new GeronimoV30VersionHandler();
+ versionHandler = new GeronimoVersionHandler();
return versionHandler;
}
@@ -179,14 +179,14 @@ public class GeronimoServer extends Gero
}
/* (non-Javadoc)
- * @see org.apache.geronimo.st.core.IGeronimoServer#isInPlace()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#isInPlace()
*/
public boolean isInPlaceSharedLib() {
return getAttribute(PROPERTY_IN_PLACE_SHARED_LIB, false);
}
/* (non-Javadoc)
- * @see org.apache.geronimo.st.core.IGeronimoServer#isRunFromWorkspace()
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServer#isRunFromWorkspace()
*/
public boolean isRunFromWorkspace() {
return getAttribute(PROPERTY_RUN_FROM_WORKSPACE, false);
@@ -201,7 +201,7 @@ public class GeronimoServer extends Gero
}
/* (non-Javadoc)
- * @see org.apache.geronimo.st.core.GeronimoServerDelegate#setDefaults(org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.apache.geronimo.st.v30.core.GeronimoServerDelegate#setDefaults(org.eclipse.core.runtime.IProgressMonitor)
*/
public void setDefaults(IProgressMonitor monitor) {
super.setDefaults(monitor);
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.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/GeronimoServerBehaviour.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/GeronimoServerBehaviour.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java Thu Apr 29 00:45:13 2010
@@ -33,9 +33,9 @@ import org.apache.geronimo.kernel.config
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.st.core.Activator;
-import org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate;
-import org.apache.geronimo.st.core.internal.DependencyHelper;
+import org.apache.geronimo.st.v30.core.Activator;
+import org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v30.core.internal.DependencyHelper;
import org.apache.geronimo.st.v30.core.internal.Trace;
import org.apache.geronimo.system.jmx.KernelDelegate;
import org.eclipse.core.runtime.IPath;
@@ -54,181 +54,181 @@ import org.eclipse.wst.server.core.inter
*/
public class GeronimoServerBehaviour extends GeronimoServerBehaviourDelegate implements IModulePublishHelper {
- private Kernel kernel = null;
+ private Kernel kernel = null;
- public GeronimoServerBehaviour() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#stopKernel()
- */
- protected void stopKernel() {
- if (kernel != null) {
- kernel.shutdown();
- kernel = null;
- }
- }
-
- /**
- * @return
- * @throws SecurityException
- */
- protected Kernel getKernel() throws SecurityException {
- if (kernel == null) {
- try {
- MBeanServerConnection connection = getServerConnection();
- if (connection != null)
- kernel = new KernelDelegate(connection);
- } catch (SecurityException e) {
- throw e;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Kernel connection failed. "
- + e.getMessage());
- }
- }
- return kernel;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.core.IGeronimoServerBehavior#isKernelAlive()
- */
- public boolean isKernelAlive() {
- try {
- return getKernel() != null && kernel.isRunning();
- } catch (SecurityException e) {
- Trace.trace(Trace.SEVERE, "Invalid username and/or password.", e);
-
- pingThread.interrupt();
- if (getServer().getServerState() != IServer.STATE_STOPPED) {
- forceStopJob(true,e);
-
- }
- } catch (Exception e) {
- Activator.log(Status.WARNING, "Geronimo Server may have been terminated manually outside of workspace.", e);
- kernel = null;
- }
- return false;
- }
-
- private void forceStopJob(boolean b, final SecurityException e) {
- /*
- *
- * Currently, there is another Status is returned by StartJob in Server.
- * The message doesn't contain reason for the exception.
- * So this job is created to show a message(Invalid username and/or password) to user.
- *
- * TODO: Need a method to remove the error message thrown by StartJob in Server.
- *
- */
-
- String jobName = NLS.bind(org.eclipse.wst.server.core.internal.Messages.errorStartFailed, getServer().getName());
-
- //This message has different variable names in WTP 3.0 and 3.1, so we define it here instead of using that in WTP
- final String jobStartingName = NLS.bind("Starting {0}", getServer().getName());
-
- new Job(jobName){
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, 0, jobStartingName, null);
- multiStatus.add(new Status(IStatus.ERROR,Activator.PLUGIN_ID,0,"Invalid username and/or password.",e));
- try{
- GeronimoServerBehaviour.this.stop(true);
- }catch (Exception e){
- multiStatus.add(new Status(IStatus.ERROR,Activator.PLUGIN_ID,0,"Failed to stop server",e));
- }
-
- return multiStatus;
- }
- }.schedule();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.core.IGeronimoServerBehavior#isFullyStarted()
- */
- public boolean isFullyStarted() {
- if (isKernelAlive()) {
- AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName());
- Set configLists = kernel.listGBeans(query);
- if (!configLists.isEmpty()) {
- AbstractName on = (AbstractName) configLists.toArray()[0];
- try {
- Boolean b = (Boolean) kernel.getAttribute(on, "kernelFullyStarted");
- return b.booleanValue();
- } catch (GBeanNotFoundException e) {
- // ignore
- } catch (NoSuchAttributeException e) {
- // ignore
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- Trace.trace(Trace.INFO, "configLists is empty");
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#getRuntimeClass()
- */
- public String getRuntimeClass() {
- return "org.apache.geronimo.cli.daemon.DaemonCLI";
- }
-
- public IPath getPublishDirectory(IModule[] module) {
- if (module == null || module.length == 0)
- return null;
-
- if (getGeronimoServer().isRunFromWorkspace()) {
- // TODO fix me, see if project root, component root, or output
- // container should be returned
- return module[module.length - 1].getProject().getLocation();
- } else {
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(getContextClassLoader());
- String configId = getConfigId(module[0]);
- Artifact artifact = Artifact.create(configId);
- AbstractName name = Configuration.getConfigurationAbstractName(artifact);
- GBeanData data = kernel.getGBeanData(name);
- URL url = (URL) data.getAttribute("baseURL");
- return getModulePath(module, url);
- } catch (InvalidConfigException e) {
- e.printStackTrace();
- } catch (GBeanNotFoundException e) {
- e.printStackTrace();
- } catch (InternalKernelException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- Thread.currentThread().setContextClassLoader(old);
- }
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.core.GenericGeronimoServerBehaviour#getContextClassLoader()
- */
- protected ClassLoader getContextClassLoader() {
- return Kernel.class.getClassLoader();
- }
+ public GeronimoServerBehaviour() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate#stopKernel()
+ */
+ protected void stopKernel() {
+ if (kernel != null) {
+ kernel.shutdown();
+ kernel = null;
+ }
+ }
+
+ /**
+ * @return
+ * @throws SecurityException
+ */
+ protected Kernel getKernel() throws SecurityException {
+ if (kernel == null) {
+ try {
+ MBeanServerConnection connection = getServerConnection();
+ if (connection != null)
+ kernel = new KernelDelegate(connection);
+ } catch (SecurityException e) {
+ throw e;
+ } catch (Exception e) {
+ Trace.trace(Trace.WARNING, "Kernel connection failed. "
+ + e.getMessage());
+ }
+ }
+ return kernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServerBehavior#isKernelAlive()
+ */
+ public boolean isKernelAlive() {
+ try {
+ return getKernel() != null && kernel.isRunning();
+ } catch (SecurityException e) {
+ Trace.trace(Trace.SEVERE, "Invalid username and/or password.", e);
+
+ pingThread.interrupt();
+ if (getServer().getServerState() != IServer.STATE_STOPPED) {
+ forceStopJob(true,e);
+
+ }
+ } catch (Exception e) {
+ Activator.log(Status.WARNING, "Geronimo Server may have been terminated manually outside of workspace.", e);
+ kernel = null;
+ }
+ return false;
+ }
+
+ private void forceStopJob(boolean b, final SecurityException e) {
+ /*
+ *
+ * Currently, there is another Status is returned by StartJob in Server.
+ * The message doesn't contain reason for the exception.
+ * So this job is created to show a message(Invalid username and/or password) to user.
+ *
+ * TODO: Need a method to remove the error message thrown by StartJob in Server.
+ *
+ */
+
+ String jobName = NLS.bind(org.eclipse.wst.server.core.internal.Messages.errorStartFailed, getServer().getName());
+
+ //This message has different variable names in WTP 3.0 and 3.1, so we define it here instead of using that in WTP
+ final String jobStartingName = NLS.bind("Starting {0}", getServer().getName());
+
+ new Job(jobName){
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, 0, jobStartingName, null);
+ multiStatus.add(new Status(IStatus.ERROR,Activator.PLUGIN_ID,0,"Invalid username and/or password.",e));
+ try{
+ GeronimoServerBehaviour.this.stop(true);
+ }catch (Exception e){
+ multiStatus.add(new Status(IStatus.ERROR,Activator.PLUGIN_ID,0,"Failed to stop server",e));
+ }
+
+ return multiStatus;
+ }
+ }.schedule();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.v30.core.IGeronimoServerBehavior#isFullyStarted()
+ */
+ public boolean isFullyStarted() {
+ if (isKernelAlive()) {
+ AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName());
+ Set configLists = kernel.listGBeans(query);
+ if (!configLists.isEmpty()) {
+ AbstractName on = (AbstractName) configLists.toArray()[0];
+ try {
+ Boolean b = (Boolean) kernel.getAttribute(on, "kernelFullyStarted");
+ return b.booleanValue();
+ } catch (GBeanNotFoundException e) {
+ // ignore
+ } catch (NoSuchAttributeException e) {
+ // ignore
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ Trace.trace(Trace.INFO, "configLists is empty");
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate#getRuntimeClass()
+ */
+ public String getRuntimeClass() {
+ return "org.apache.geronimo.cli.daemon.DaemonCLI";
+ }
+
+ public IPath getPublishDirectory(IModule[] module) {
+ if (module == null || module.length == 0)
+ return null;
+
+ if (getGeronimoServer().isRunFromWorkspace()) {
+ // TODO fix me, see if project root, component root, or output
+ // container should be returned
+ return module[module.length - 1].getProject().getLocation();
+ } else {
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getContextClassLoader());
+ String configId = getConfigId(module[0]);
+ Artifact artifact = Artifact.create(configId);
+ AbstractName name = Configuration.getConfigurationAbstractName(artifact);
+ GBeanData data = kernel.getGBeanData(name);
+ URL url = (URL) data.getAttribute("baseURL");
+ return getModulePath(module, url);
+ } catch (InvalidConfigException e) {
+ e.printStackTrace();
+ } catch (GBeanNotFoundException e) {
+ e.printStackTrace();
+ } catch (InternalKernelException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.geronimo.st.v30.core.GenericGeronimoServerBehaviour#getContextClassLoader()
+ */
+ protected ClassLoader getContextClassLoader() {
+ return Kernel.class.getClassLoader();
+ }
- @Override
+ @Override
protected List getOrderedModules(IServer server, List modules,
List deltaKind) {
- DependencyHelper dh = new DependencyHelper();
+ DependencyHelper dh = new DependencyHelper();
List list = dh.reorderModules(this.getServer(),modules, deltaKind);
return list;
}