Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 18215 invoked from network); 21 Apr 2006 14:11:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Apr 2006 14:11:23 -0000 Received: (qmail 26585 invoked by uid 500); 21 Apr 2006 14:10:36 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 26499 invoked by uid 500); 21 Apr 2006 14:10:33 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 26450 invoked by uid 99); 21 Apr 2006 14:10:32 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Apr 2006 07:10:31 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 21 Apr 2006 07:10:28 -0700 Received: (qmail 16306 invoked by uid 65534); 21 Apr 2006 14:10:07 -0000 Message-ID: <20060421141007.16282.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r395891 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.ui/META-INF/ org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ org.apache.gero... Date: Fri, 21 Apr 2006 14:09:12 -0000 To: scm@geronimo.apache.org From: sppatel@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sppatel Date: Fri Apr 21 07:09:10 2006 New Revision: 395891 URL: http://svn.apache.org/viewcvs?rev=395891&view=rev Log: refactor for 1.1 Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java (with props) geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java (with props) geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java (with props) geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java (with props) geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java (with props) geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java (with props) geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml (with props) Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.java geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/META-INF/MANIFEST.MF geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/META-INF/MANIFEST.MF geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/build.properties Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GenericGeronimoServerRuntime.java Fri Apr 21 07:09:10 2006 @@ -15,17 +15,55 @@ */ package org.apache.geronimo.st.core; +import java.io.File; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; + import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime; -public class GenericGeronimoServerRuntime extends GenericServerRuntime implements - IGeronimoRuntime { - - /* (non-Javadoc) +public class GenericGeronimoServerRuntime extends GenericServerRuntime + implements IGeronimoRuntime { + + /* + * (non-Javadoc) + * * @see org.eclipse.wst.server.core.model.RuntimeDelegate#validate() */ public IStatus validate() { + String version = detectVersion(); + if (!getRuntime().getRuntimeType().getVersion().equals(version)) + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, null, null); return super.validate(); } + public String detectVersion() { + File libDir = getRuntime().getLocation().append("lib").toFile(); + if (libDir.exists()) { + File[] libs = libDir.listFiles(); + URL systemjarURL = null; + 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(); + } + } + } + URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL }); + try { + Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants"); + Method method = clazz.getMethod("getVersion", new Class[] {}); + return (String) method.invoke(null, null); + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } } Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/META-INF/MANIFEST.MF Fri Apr 21 07:09:10 2006 @@ -22,7 +22,9 @@ org.eclipse.ui.workbench.texteditor, org.eclipse.jst.server.generic.core, org.eclipse.wst.server.ui, - org.eclipse.core.commands + org.eclipse.core.commands, + org.eclipse.jst.server.generic.ui, + org.eclipse.jst.server.core Eclipse-AutoStart: true Export-Package: org.apache.geronimo.st.ui, org.apache.geronimo.st.ui.actions, Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java Fri Apr 21 07:09:10 2006 @@ -0,0 +1,75 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.ui.internal; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +public class ConfirmInstallDialog extends Dialog { + + private String installPath = null; + + public ConfirmInstallDialog(Shell parentShell, String installPath) { + super(parentShell); + this.installPath = installPath; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(Messages.installTitle); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { // create a + // composite with + // standard margins + // and spacing + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); + layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setFont(parent.getFont()); + Label label = new Label(composite, SWT.WRAP); + label.setText(NLS.bind(Messages.installMessage, new String[] { installPath })); + GridData data = new GridData(); + data.widthHint = 400; + label.setLayoutData(data); + Dialog.applyDialogFont(composite); + return composite; + } + +} Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/ConfirmInstallDialog.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java Fri Apr 21 07:09:10 2006 @@ -0,0 +1,422 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.ui.internal; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.geronimo.st.ui.Activator; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.launching.IVMInstall; +import org.eclipse.jdt.launching.IVMInstall2; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime; +import org.eclipse.jst.server.generic.servertype.definition.Property; +import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; +import org.eclipse.jst.server.generic.ui.internal.GenericServerComposite; +import org.eclipse.jst.server.generic.ui.internal.GenericServerCompositeDecorator; +import org.eclipse.jst.server.generic.ui.internal.GenericServerUIMessages; +import org.eclipse.jst.server.generic.ui.internal.JRESelectDecorator; +import org.eclipse.jst.server.generic.ui.internal.SWTUtil; +import org.eclipse.jst.server.generic.ui.internal.ServerDefinitionTypeAwareWizardFragment; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.wst.server.core.IRuntime; +import org.eclipse.wst.server.core.IRuntimeType; +import org.eclipse.wst.server.core.IRuntimeWorkingCopy; +import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.TaskModel; +import org.eclipse.wst.server.core.internal.IInstallableRuntime; +import org.eclipse.wst.server.core.internal.ServerPlugin; +import org.eclipse.wst.server.core.model.RuntimeDelegate; +import org.eclipse.wst.server.ui.wizard.IWizardHandle; + +public class GeronimoServerRuntimeWizardFragment extends + ServerDefinitionTypeAwareWizardFragment { + + private static final String G_WITH_TOMCAT_ID = "org.apache.geronimo.runtime.tomcat.10"; + private static final String G_WITH_JETTY_ID = "org.apache.geronimo.runtime.jetty.10"; + + private GenericServerCompositeDecorator[] fDecorators; + protected Text installDir; + + private Button tomcat; + private Button jetty; + + private Group group; + + public GeronimoServerRuntimeWizardFragment() { + super(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jst.server.generic.ui.internal.ServerDefinitionTypeAwareWizardFragment#description() + */ + public String description() { + return Messages.serverWizardDescription; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jst.server.generic.ui.internal.ServerDefinitionTypeAwareWizardFragment#title() + */ + public String title() { + return GenericServerUIMessages.bind(GenericServerUIMessages.runtimeWizardTitle, getRuntimeName()); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jst.server.generic.ui.internal.ServerDefinitionTypeAwareWizardFragment#createContent(org.eclipse.swt.widgets.Composite, + * org.eclipse.wst.server.ui.wizard.IWizardHandle) + */ + public void createContent(Composite parent, IWizardHandle handle) { + + getWizard().setImageDescriptor(Activator.getImageDescriptor(Activator.IMG_WIZ_GERONIMO)); + + fDecorators = new GenericServerCompositeDecorator[1]; + fDecorators[0] = new GeronimoJRESelectDecorator(getRuntimeDelegate()); + GenericServerComposite composite = new GenericServerComposite(parent, fDecorators); + + Label label = new Label(composite, SWT.NONE); + label.setText(Messages.installDir); + GridData data = new GridData(); + data.horizontalSpan = 3; + label.setLayoutData(data); + label.setToolTipText(Messages.tooltipLoc); + + installDir = new Text(composite, SWT.BORDER); + + IPath currentLocation = getRuntimeDelegate().getRuntimeWorkingCopy().getLocation(); + if (currentLocation != null) { + installDir.setText(currentLocation.toOSString()); + } + + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + installDir.setLayoutData(data); + installDir.setToolTipText(Messages.tooltipLoc); + installDir.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + getRuntimeDelegate().getRuntimeWorkingCopy().setLocation(new Path(installDir.getText())); + validate(); + } + }); + + final Composite browseComp = composite; + Button browse = SWTUtil.createButton(composite, Messages.browse); + browse.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent se) { + DirectoryDialog dialog = new DirectoryDialog(browseComp.getShell()); + dialog.setMessage(Messages.installDir); + dialog.setFilterPath(installDir.getText()); + String selectedDirectory = dialog.open(); + if (selectedDirectory != null) + installDir.setText(selectedDirectory); + } + }); + + data = new GridData(); + data = new GridData(GridData.FILL_BOTH); + data.horizontalSpan = 3; + + final IInstallableRuntime gWithTomcat = ServerPlugin.findInstallableRuntime(G_WITH_TOMCAT_ID); + final IInstallableRuntime gWithJetty = ServerPlugin.findInstallableRuntime(G_WITH_JETTY_ID); + + if (gWithTomcat != null && gWithJetty != null) { + group = new Group(composite, SWT.NONE); + group.setText(Messages.downloadOptions); + group.setLayoutData(data); + group.setLayout(composite.getLayout()); + group.setEnabled(false); + + Label webContainer = new Label(group, SWT.NONE); + webContainer.setText(Messages.chooseWebContainer); + data = new GridData(); + data.horizontalSpan = 3; + webContainer.setLayoutData(data); + + tomcat = new Button(group, SWT.RADIO); + tomcat.setSelection(true); + tomcat.setText(Messages.gWithTomcat); + data = new GridData(); + data.horizontalSpan = 3; + tomcat.setLayoutData(data); + tomcat.setToolTipText(Messages.tooltipTomcat); + + jetty = new Button(group, SWT.RADIO); + jetty.setText(Messages.gWithJetty); + data = new GridData(); + data.horizontalSpan = 3; + jetty.setLayoutData(data); + jetty.setToolTipText(Messages.tooltipJetty); + + Button install = SWTUtil.createButton(group, Messages.install); + data = new GridData(); + data.horizontalSpan = 3; + install.setLayoutData(data); + install.setToolTipText(Messages.tooltipInstall); + install.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent se) { + if (installDir != null && isValidLocation()) { + Shell shell = installDir.getShell(); + ConfirmInstallDialog dialog = new ConfirmInstallDialog(shell, installDir.getText()); + dialog.open(); + if (dialog.getReturnCode() == IDialogConstants.OK_ID) { + + final IInstallableRuntime installable = tomcat.getSelection() ? gWithTomcat + : gWithJetty; + final Path installPath = new Path(installDir.getText()); + IRunnableWithProgress runnable = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) + throws InvocationTargetException, + InterruptedException { + try { + installable.install(installPath, monitor); + } catch (CoreException e) { + Trace.trace(Trace.SEVERE, "Error installing runtime", e); + } + } + }; + + try { + getWizard().run(true, false, runnable); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error installing runtime", e); + } + + updateInstallDir(installPath); + + } + } + } + + boolean isValidLocation() { + return true; + } + + void updateInstallDir(IPath installPath) { + installPath = installPath.append("geronimo-1.0"); + installDir.setText(installPath.toOSString()); + } + }); + } + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.ui.wizard.WizardFragment#isComplete() + */ + public boolean isComplete() { + IRuntimeWorkingCopy runtimeWC = getRuntimeDelegate().getRuntimeWorkingCopy(); + IStatus status = runtimeWC.validate(null); + return status == null || status.isOK(); + } + + protected void validate() { + + IRuntime runtime = getRuntimeDelegate().getRuntime(); + + if (runtime == null) { + getWizard().setMessage("", IMessageProvider.ERROR); + return; + } + + IRuntimeWorkingCopy runtimeWC = getRuntimeDelegate().getRuntimeWorkingCopy(); + getRuntimeDelegate().setServerDefinitionId(runtime.getRuntimeType().getId()); + getRuntimeDelegate().setServerInstanceProperties(getValues()); + + if (installDir.getText() == null || installDir.getText().length() == 0) { + // installDir field has not been entered + getWizard().setMessage(Messages.installDirInfo, IMessageProvider.ERROR); + } else { + IStatus status = runtimeWC.validate(null); + if (status == null || status.isOK()) { + getWizard().setMessage(null, IMessageProvider.NONE); + group.setEnabled(false); + } else { + File file = new Path(installDir.getText()).toFile(); + if (file.isDirectory()) { + boolean canWrite = file.canWrite(); + String message = canWrite ? Messages.noImageFound + : Messages.cannotInstallAtLocation; + if (canWrite) + group.setEnabled(true); + getWizard().setMessage(message, IMessageProvider.ERROR); + } else { + group.setEnabled(false); + getWizard().setMessage(Messages.noSuchDir, IMessageProvider.ERROR); + } + return; + } + + if (!isValidVM()) { + getWizard().setMessage(Messages.jvmWarning, IMessageProvider.WARNING); + return; + } + + getWizard().setMessage(null, IMessageProvider.NONE); + } + + // validateDecorators(); + } + + private boolean isValidVM() { + String javaVersion = null; + IVMInstall vmInstall = getRuntimeDelegate().getVMInstall(); + if (vmInstall instanceof IVMInstall2) + javaVersion = ((IVMInstall2) vmInstall).getJavaVersion(); + return javaVersion != null && javaVersion.startsWith("1.4"); + //This returns false on MacOSX due to do no IVMInstall2.getJavaVersion() implementation + //on Mac, fixed in Eclipse 3.2 + } + + private void validateDecorators() { + for (int i = 0; i < fDecorators.length; i++) { + if (fDecorators[i].validate()) + return; + } + } + + private Map getValues() { + Map propertyMap = new HashMap(); + if (getRuntimeDelegate() != null) { + ServerRuntime definition = getServerTypeDefinition(getServerDefinitionId(), getRuntimeDelegate().getServerInstanceProperties()); + if (definition != null) { + List properties = definition.getProperty(); + for (int i = 0; i < properties.size(); i++) { + Property property = (Property) properties.get(i); + if (Property.CONTEXT_RUNTIME.equals(property.getContext())) { + if (Property.TYPE_DIRECTORY.equals(property.getType())) { + propertyMap.put(property.getId(), installDir.getText()); + } + } + } + } + } + return propertyMap; + } + + private String getServerDefinitionId() { + String currentDefinition = null; + if (getRuntimeDelegate() != null) + currentDefinition = getRuntimeDelegate().getRuntime().getRuntimeType().getId(); + if (currentDefinition != null && currentDefinition.length() > 0) { + return currentDefinition; + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.ui.wizard.WizardFragment#enter() + */ + public void enter() { + if (getRuntimeDelegate() != null) + getRuntimeDelegate().getRuntimeWorkingCopy().setName(createName()); + validate(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.ui.wizard.WizardFragment#exit() + */ + public void exit() { + validate(); + } + + private GenericServerRuntime getRuntimeDelegate() { + IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); + if (wc == null) + return null; + return (GenericServerRuntime) wc.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor()); + } + + private String createName() { + RuntimeDelegate dl = getRuntimeDelegate(); + IRuntimeType runtimeType = dl.getRuntime().getRuntimeType(); + String name = GenericServerUIMessages.bind(GenericServerUIMessages.runtimeName, runtimeType.getName()); + IRuntime[] list = ServerCore.getRuntimes(); + int suffix = 1; + String suffixName = name; + for (int i = 0; i < list.length; i++) { + if ((list[i].getName().equals(name) || list[i].getName().equals(suffixName)) + && !list[i].equals(dl.getRuntime())) + suffix++; + suffixName = name + " " + suffix; + } + + if (suffix > 1) + return suffixName; + return name; + } + + private String getRuntimeName() { + if (getRuntimeDelegate() != null + && getRuntimeDelegate().getRuntime() != null) + return getRuntimeDelegate().getRuntime().getName(); + return null; + } + + private class GeronimoJRESelectDecorator extends JRESelectDecorator { + public GeronimoJRESelectDecorator(GenericServerRuntime runtime) { + super(runtime); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jst.server.generic.ui.internal.GenericServerCompositeDecorator#validate() + */ + public boolean validate() { + GeronimoServerRuntimeWizardFragment.this.validate(); + return true; + } + } + +} Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/GeronimoServerRuntimeWizardFragment.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.java?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.java (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.java Fri Apr 21 07:09:10 2006 @@ -160,6 +160,10 @@ public static String serverWizardDescription; public static String browse; public static String installDir; + public static String installDirInfo; + public static String noSuchDir; + public static String noImageFound; + public static String cannotInstallAtLocation; public static String downloadOptions; public static String chooseWebContainer; public static String gWithTomcat; Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/internal/Messages.properties Fri Apr 21 07:09:10 2006 @@ -159,6 +159,10 @@ serverWizardDescription=Specify the location of an existing 1.0 Geronimo installation. If none exists, specify an install location and press 'Download and Install'. browse=Browse installDir=Application Server Installation Directory: +installDirInfo=Please enter the directory where Geronimo is currently installed or where you would like it to be installed. +noSuchDir=The specified directory does not exist. +noImageFound=A Geronimo installation does not exist at this location. +cannotInstallAtLocation=A Geronimo installation does not exist and cannot be installed at this location. downloadOptions=Download Options chooseWebContainer=Select a web container: gWithTomcat=Geronimo with Tomcat Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/META-INF/MANIFEST.MF?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/META-INF/MANIFEST.MF (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/META-INF/MANIFEST.MF Fri Apr 21 07:09:10 2006 @@ -12,8 +12,15 @@ org.apache.geronimo.st.core, org.eclipse.wst.server.core, org.eclipse.debug.core, - com.ibm.etools.emf.event, org.apache.geronimo.v11.deployment.model, org.eclipse.wst.common.modulecore, - org.eclipse.core.resources + org.eclipse.core.resources, + org.eclipse.jst.j2ee, + org.eclipse.wst.rdb.models.sql.edit, + org.eclipse.wst.rdb.models.sql, + org.eclipse.wst.rdb.models.dbdefinition, + org.apache.geronimo.v11.deployment.model.edit, + org.apache.geronimo.runtime.v1, + org.apache.geronimo.deployment.model.edit, + org.apache.geronimo.deployment.model Eclipse-AutoStart: true Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java Fri Apr 21 07:09:10 2006 @@ -0,0 +1,116 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.v11.core; + +import javax.enterprise.deploy.spi.DeploymentManager; + +import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager; +import org.apache.geronimo.st.core.GenericGeronimoServer; +import org.apache.geronimo.st.core.IGeronimoVersionHandler; +import org.eclipse.core.runtime.IPath; +import org.eclipse.wst.server.core.IModule; + +public class GeronimoServer extends GenericGeronimoServer { + + private static IGeronimoVersionHandler versionHandler = null; + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.GenericGeronimoServer#getContextRoot(org.eclipse.wst.server.core.IModule) + */ + public String getContextRoot(IModule module) { + return GeronimoV11Utils.getContextRoot(module); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.GenericGeronimoServer#getAdminID() + */ + public String getAdminID() { + return (String) getServerInstanceProperties().get(PROPERTY_ADMIN_ID); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.GenericGeronimoServer#getAdminPassword() + */ + public String getAdminPassword() { + return (String) getServerInstanceProperties().get(PROPERTY_ADMIN_PW); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.GenericGeronimoServer#getRMINamingPort() + */ + public String getRMINamingPort() { + return (String) getServerInstanceProperties().get(PROPERTY_RMI_PORT); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.IGeronimoServer#getDeployerURL() + */ + public String getDeployerURL() { + return "deployer:geronimo:jmx://" + getServer().getHost() + ":" + + getRMINamingPort(); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.IGeronimoServer#getJMXServiceURL() + */ + public String getJMXServiceURL() { + String host = getServer().getHost(); + return "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + + getRMINamingPort() + "/JMXConnector"; + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.IGeronimoServer#getJSR88DeployerJar() + */ + public IPath getJSR88DeployerJar() { + return getServer().getRuntime().getLocation().append("/lib/geronimo-deploy-jsr88-1.1-SNAPSHOT.jar"); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.IGeronimoServer#configureDeploymentManager(javax.enterprise.deploy.spi.DeploymentManager) + */ + public void configureDeploymentManager(DeploymentManager dm) { + ((JMXDeploymentManager) dm).setLogConfiguration(true, true); + } + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.IGeronimoServer#getVersionHandler() + */ + public IGeronimoVersionHandler getVersionHandler() { + if (versionHandler == null) + versionHandler = new GeronimoV11VersionHandler(); + return versionHandler; + } + +} \ No newline at end of file Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java Fri Apr 21 07:09:10 2006 @@ -0,0 +1,445 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.v11.core; + +import java.net.MalformedURLException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Timer; + +import javax.enterprise.deploy.spi.DeploymentManager; +import javax.enterprise.deploy.spi.TargetModuleID; +import javax.management.MBeanServerConnection; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; +import javax.naming.directory.NoSuchAttributeException; + +import org.apache.geronimo.gbean.AbstractName; +import org.apache.geronimo.gbean.AbstractNameQuery; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.kernel.GBeanAlreadyExistsException; +import org.apache.geronimo.kernel.GBeanNotFoundException; +import org.apache.geronimo.kernel.InternalKernelException; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.config.PersistentConfigurationList; +import org.apache.geronimo.kernel.jmx.KernelDelegate; +import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.st.core.DeploymentUtils; +import org.apache.geronimo.st.core.GenericGeronimoServerBehaviour; +import org.apache.geronimo.st.core.GeronimoConnectionFactory; +import org.apache.geronimo.st.core.IGeronimoServer; +import org.apache.geronimo.st.core.PingThread; +import org.apache.geronimo.st.core.UpdateServerStateTask; +import org.apache.geronimo.st.core.commands.DeploymentCommandFactory; +import org.apache.geronimo.st.core.commands.IDeploymentCommand; +import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException; +import org.apache.geronimo.st.v11.core.internal.Messages; +import org.apache.geronimo.st.v11.core.internal.Trace; +import org.apache.geronimo.st.v11.core.internal.WorkspaceConfigurationStore; +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.ILaunchConfigurationWorkingCopy; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.jst.server.generic.core.internal.CorePlugin; +import org.eclipse.jst.server.generic.core.internal.GenericServerCoreMessages; +import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerListener; +import org.eclipse.wst.server.core.ServerEvent; +import org.eclipse.wst.server.core.ServerPort; +import org.eclipse.wst.server.core.util.SocketUtil; + +public class GeronimoServerBehaviour extends GenericGeronimoServerBehaviour { + + private static final String ATTR_STOP = "stop-server"; + + private static final int TIMER_TASK_INTERVAL = 10; + + private IProgressMonitor _monitor = null; + + private Kernel kernel = null; + + private Timer timer = null; + PingThread pingThread; + + public GeronimoServerBehaviour() { + super(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#stop(boolean) + */ + public synchronized void stop(boolean force) { + + Trace.trace(Trace.INFO, "--> stop()"); + + if (getServer().getServerState() != IServer.STATE_STOPPED) { + setServerState(IServer.STATE_STOPPING); + if (kernel != null) { + kernel.shutdown(); + } + } + + GeronimoConnectionFactory.getInstance().destroy(getServer()); + kernel = null; + + // kill the process + super.stop(true); + + Trace.trace(Trace.INFO, "<-- stop()"); + } + + private Kernel getKernel() throws SecurityException { + + if (kernel == null) { + Map map = new HashMap(); + String user = getGeronimoServer().getAdminID(); + String password = getGeronimoServer().getAdminPassword(); + map.put("jmx.remote.credentials", new String[] { user, password }); + try { + String url = getGeronimoServer().getJMXServiceURL(); + Trace.trace(Trace.INFO, "URL = " + url); + if (url == null) + return null; + JMXServiceURL address = new JMXServiceURL(url); + try { + JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); + MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection(); + kernel = new KernelDelegate(mbServerConnection); + Trace.trace(Trace.INFO, "Connected to kernel."); + } catch (SecurityException e) { + throw e; + } catch (Exception e) { + Trace.trace(Trace.WARNING, "Kernel connection failed."); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + + return kernel; + } + + public boolean isKernelAlive() { + try { + return getKernel() != null && kernel.isRunning(); + } catch (SecurityException e) { + Activator.log(Status.ERROR, "Invalid username and/or password.", e); + pingThread.interrupt(); + if (getServer().getServerState() != IServer.STATE_STOPPED) { + stop(true); + } + } catch (Exception e) { + Activator.log(Status.WARNING, "Geronimo Server may have been terminated manually outside of workspace.", e); + kernel = null; + } + return false; + } + + 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.eclipse.wst.server.core.model.ServerBehaviourDelegate#publishModule(int, + * int, org.eclipse.wst.server.core.IModule[], + * org.eclipse.core.runtime.IProgressMonitor) + */ + public void publishModule(int kind, int deltaKind, IModule[] module, + IProgressMonitor monitor) throws CoreException { + + Trace.trace(Trace.INFO, ">> publishModule(), deltaKind = " + deltaKind); + Trace.trace(Trace.INFO, Arrays.asList(module).toString()); + _monitor = monitor; + + if (module.length == 1 && (deltaKind == ADDED || deltaKind == REMOVED)) { + invokeCommand(deltaKind, module[0]); + } else if (deltaKind == CHANGED) { + // TODO This case is flawed due to WTP Bugzilla 123676 + invokeCommand(deltaKind, module[0]); + } + + setModulePublishState(module, IServer.PUBLISH_STATE_NONE); + + Trace.trace(Trace.INFO, "<< publishModule()"); + } + + private void invokeCommand(int deltaKind, IModule module) + throws CoreException { + try { + switch (deltaKind) { + case ADDED: { + doDeploy(module); + break; + } + case CHANGED: { + doRedeploy(module); + break; + } + case REMOVED: { + doUndeploy(module); + break; + } + default: + throw new IllegalArgumentException(); + } + } catch (CoreException e) { + throw e; + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void doDeploy(IModule module) throws Exception { + Trace.trace(Trace.INFO, ">> doDeploy() " + module.toString()); + + DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(getServer()); + + if (!DeploymentUtils.configurationExists(module, dm)) { + IStatus status = distribute(module); + if (!status.isOK()) { + doFail(status, Messages.DISTRIBUTE_FAIL); + } + + status = start(module); + if (!status.isOK()) { + doFail(status, Messages.START_FAIL); + } + } else { + String id = GeronimoV11Utils.getConfigId(module); + String message = id + + "already exists. Existing configuration will be overwritten."; + Activator.log(Status.ERROR, message, null); + doRedeploy(module); + } + + Trace.trace(Trace.INFO, "<< doDeploy() " + module.toString()); + } + + private void doRedeploy(IModule module) throws Exception { + Trace.trace(Trace.INFO, ">> doRedeploy() " + module.toString()); + + try { + IStatus status = reDeploy(module); + if (!status.isOK()) { + doFail(status, Messages.REDEPLOY_FAIL); + } + } catch (TargetModuleIdNotFoundException e) { + Activator.log(Status.WARNING, "Module may have been uninstalled outside the workspace.", e); + doDeploy(module); + } + + Trace.trace(Trace.INFO, "<< doRedeploy() " + module.toString()); + } + + private void doUndeploy(IModule module) throws Exception { + Trace.trace(Trace.INFO, ">> doUndeploy() " + module.toString()); + + IStatus status = stop(module); + if (!status.isOK()) { + doFail(status, Messages.STOP_FAIL); + } + + status = unDeploy(module); + if (!status.isOK()) { + doFail(status, Messages.UNDEPLOY_FAIL); + } + + Trace.trace(Trace.INFO, "<< doUndeploy()" + module.toString()); + } + + private void doRestart(IModule module) throws Exception { + Trace.trace(Trace.INFO, ">> doRestart() " + module.toString()); + + IStatus status = stop(module); + if (!status.isOK()) { + doFail(status, Messages.STOP_FAIL); + } + + status = start(module); + if (!status.isOK()) { + doFail(status, Messages.START_FAIL); + } + + Trace.trace(Trace.INFO, ">> doRestart() " + module.toString()); + } + + private void doFail(IStatus status, String message) throws CoreException { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, message, new Exception(status.getMessage()))); + } + + private IStatus distribute(IModule module) throws Exception { + IDeploymentCommand cmd = DeploymentCommandFactory.createDistributeCommand(module, getServer()); + return cmd.execute(_monitor); + } + + private IStatus start(IModule module) throws Exception { + TargetModuleID id = DeploymentUtils.getTargetModuleID(module, DeploymentCommandFactory.getDeploymentManager(getServer())); + IDeploymentCommand cmd = DeploymentCommandFactory.createStartCommand(new TargetModuleID[] { id }, module, getServer()); + return cmd.execute(_monitor); + } + + private IStatus stop(IModule module) throws Exception { + IDeploymentCommand cmd = DeploymentCommandFactory.createStopCommand(module, getServer()); + return cmd.execute(_monitor); + } + + private IStatus unDeploy(IModule module) throws Exception { + IDeploymentCommand cmd = DeploymentCommandFactory.createUndeployCommand(module, getServer()); + return cmd.execute(_monitor); + } + + private IStatus reDeploy(IModule module) throws Exception { + IDeploymentCommand cmd = DeploymentCommandFactory.createRedeployCommand(module, getServer()); + return cmd.execute(_monitor); + } + + public Map getServerInstanceProperties() { + return getRuntimeDelegate().getServerInstanceProperties(); + } + + public IGeronimoServer getGeronimoServer() { + return (IGeronimoServer) getServer().loadAdapter(IGeronimoServer.class, null); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#setupLaunchConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, + * org.eclipse.core.runtime.IProgressMonitor) + */ + public void setupLaunchConfiguration( + ILaunchConfigurationWorkingCopy workingCopy, + IProgressMonitor monitor) throws CoreException { + String defaultArgs = getServerDefinition().getResolver().resolveProperties(getServerDefinition().getStart().getProgramArgumentsAsString()); + String existingPrgArgs = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, defaultArgs); + super.setupLaunchConfiguration(workingCopy, monitor); + if (existingPrgArgs != null) { + workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, existingPrgArgs); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jst.server.generic.core.internal.GenericServerBehaviour#setupLaunch(org.eclipse.debug.core.ILaunch, + * java.lang.String, org.eclipse.core.runtime.IProgressMonitor) + */ + protected void setupLaunch(ILaunch launch, String launchMode, + IProgressMonitor monitor) throws CoreException { + Trace.trace(Trace.INFO, "--> GeronimoServerBehavior.setupLaunch()"); + + if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false"))) + return; + + if (!SocketUtil.isLocalhost(getServer().getHost())) + return; + + ServerPort[] ports = getServer().getServerPorts(null); + for (int i = 0; i < ports.length; i++) { + ServerPort sp = ports[i]; + if (SocketUtil.isPortInUse(ports[i].getPort(), 5)) + throw new CoreException(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, GenericServerCoreMessages.bind(GenericServerCoreMessages.errorPortInUse, Integer.toString(sp.getPort()), sp.getName()), null)); + } + + stopUpdateServerStateTask(); + setServerState(IServer.STATE_STARTING); + setMode(launchMode); + + IServerListener listener = new IServerListener() { + public void serverChanged(ServerEvent event) { + int eventKind = event.getKind(); + if (eventKind == (ServerEvent.SERVER_CHANGE | ServerEvent.STATE_CHANGE)) { + IServer server = event.getServer(); + int state = server.getServerState(); + if (state == IServer.STATE_STARTED + || state == IServer.STATE_STOPPED) { + GeronimoServerBehaviour.this.getServer().removeServerListener(this); + startUpdateServerStateTask(); + } + } + } + }; + + getServer().addServerListener(listener); + pingThread = new PingThread(this, getServer()); + pingThread.start(); + Trace.trace(Trace.INFO, "<-- GeronimoServerBehavior.setupLaunch()"); + } + + private void startUpdateServerStateTask() { + Trace.trace(Trace.INFO, "startUpdateServerStateTask() " + + getServer().getName()); + timer = new Timer(true); + timer.schedule(new UpdateServerStateTask(this, getServer()), 10000, TIMER_TASK_INTERVAL * 1000); + } + + private void stopUpdateServerStateTask() { + Trace.trace(Trace.INFO, "stopUpdateServerStateTask() " + + getServer().getName()); + if (timer != null) + timer.cancel(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#initialize(org.eclipse.core.runtime.IProgressMonitor) + */ + protected void initialize(IProgressMonitor monitor) { + Trace.trace(Trace.INFO, "GeronimoServerBehavior.initialize()"); + startUpdateServerStateTask(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#dispose() + */ + public void dispose() { + stopUpdateServerStateTask(); + } + +} \ No newline at end of file Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java Fri Apr 21 07:09:10 2006 @@ -0,0 +1,172 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.v11.core; + +import org.apache.geronimo.st.core.GeronimoUtils; +import org.apache.geronimo.xml.ns.deployment.ArtifactType; +import org.apache.geronimo.xml.ns.deployment.DeploymentPackage; +import org.apache.geronimo.xml.ns.deployment.EnvironmentType; +import org.apache.geronimo.xml.ns.j2ee.application.ApplicationPackage; +import org.apache.geronimo.xml.ns.j2ee.application.ApplicationType; +import org.apache.geronimo.xml.ns.j2ee.application.util.ApplicationResourceFactoryImpl; +import org.apache.geronimo.xml.ns.j2ee.connector.ConnectorPackage; +import org.apache.geronimo.xml.ns.j2ee.connector.ConnectorType; +import org.apache.geronimo.xml.ns.j2ee.connector.util.ConnectorResourceFactoryImpl; +import org.apache.geronimo.xml.ns.j2ee.web.DocumentRoot; +import org.apache.geronimo.xml.ns.j2ee.web.WebAppType; +import org.apache.geronimo.xml.ns.j2ee.web.WebPackage; +import org.apache.geronimo.xml.ns.j2ee.web.util.WebResourceFactoryImpl; +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; +import org.eclipse.wst.server.core.IModule; +import org.openejb.xml.ns.openejb.jar.JarPackage; +import org.openejb.xml.ns.openejb.jar.OpenejbJarType; +import org.openejb.xml.ns.openejb.jar.util.JarResourceFactoryImpl; + +public class GeronimoV11Utils extends GeronimoUtils { + + public static String getConfigId(IModule module) { + + EnvironmentType environment = null; + if (isWebModule(module)) { + WebAppType plan = getWebDeploymentPlan(module); + if (plan != null) + environment = plan.getEnvironment(); + } else if (isEjbJarModule(module)) { + OpenejbJarType plan = getOpenEjbDeploymentPlan(module); + if (plan != null) + environment = plan.getEnvironment(); + } else if (isEarModule(module)) { + ApplicationType plan = getApplicationDeploymentPlan(module); + if (plan != null) + environment = plan.getEnvironment(); + } else if (isRARModule(module)) { + ConnectorType plan = getConnectorDeploymentPlan(module); + if (plan != null) + environment = plan.getEnvironment(); + } + + if (environment != null + && environment.eIsSet(DeploymentPackage.eINSTANCE.getEnvironmentType_ConfigId())) { + return getQualifiedConfigID(environment.getConfigId()); + } + + return getId(module); + } + + public static String getQualifiedConfigID(ArtifactType artifact) { + return artifact.getGroupId() + "/" + artifact.getArtifactId() + "/" + + artifact.getVersion() + "/" + artifact.getType(); + } + + public static String getContextRoot(IModule module) { + String contextRoot = null; + + WebAppType deploymentPlan = getWebDeploymentPlan(module); + if (deploymentPlan != null) + contextRoot = deploymentPlan.getContextRoot(); + + if (contextRoot == null) + contextRoot = GeronimoUtils.getContextRoot(module); + + return contextRoot; + } + + public static WebAppType getWebDeploymentPlan(IModule module) { + return getWebDeploymentPlan(getVirtualComponent(module)); + } + + public static ApplicationType getApplicationDeploymentPlan(IModule module) { + return getApplicationDeploymentPlan(getVirtualComponent(module)); + } + + public static OpenejbJarType getOpenEjbDeploymentPlan(IModule module) { + return getOpenEjbDeploymentPlan(getVirtualComponent(module)); + } + + public static ConnectorType getConnectorDeploymentPlan(IModule module) { + return getConnectorDeploymentPlan(getVirtualComponent(module)); + } + + public static ApplicationType getApplicationDeploymentPlan( + IVirtualComponent comp) { + return getApplicationDeploymentPlan(getApplicationDeploymentPlanFile(comp)); + } + + public static WebAppType getWebDeploymentPlan(IVirtualComponent comp) { + return getWebDeploymentPlan(getWebDeploymentPlanFile(comp)); + } + + public static OpenejbJarType getOpenEjbDeploymentPlan(IVirtualComponent comp) { + return getOpenEjbDeploymentPlan(getOpenEjbDeploymentPlanFile(comp)); + } + + public static ConnectorType getConnectorDeploymentPlan( + IVirtualComponent comp) { + return getConnectorDeploymentPlan(getConnectorDeploymentPlanFile(comp)); + } + + public static ApplicationType getApplicationDeploymentPlan(IFile file) { + if (file.getName().equals(APP_PLAN_NAME) && file.exists()) { + ResourceSet resourceSet = new ResourceSetImpl(); + register(resourceSet, new ApplicationResourceFactoryImpl(), ApplicationPackage.eINSTANCE, ApplicationPackage.eNS_URI); + Resource resource = load(file, resourceSet); + if (resource != null) { + return ((org.apache.geronimo.xml.ns.j2ee.application.DocumentRoot) resource.getContents().get(0)).getApplication(); + } + } + return null; + } + + public static WebAppType getWebDeploymentPlan(IFile file) { + if (file.getName().equals(WEB_PLAN_NAME) && file.exists()) { + ResourceSet resourceSet = new ResourceSetImpl(); + register(resourceSet, new WebResourceFactoryImpl(), WebPackage.eINSTANCE, WebPackage.eNS_URI); + Resource resource = load(file, resourceSet); + if (resource != null) { + return ((DocumentRoot) resource.getContents().get(0)).getWebApp(); + } + } + return null; + } + + public static OpenejbJarType getOpenEjbDeploymentPlan(IFile file) { + if (file.getName().equals(OPENEJB_PLAN_NAME) && file.exists()) { + ResourceSet resourceSet = new ResourceSetImpl(); + register(resourceSet, new JarResourceFactoryImpl(), JarPackage.eINSTANCE, JarPackage.eNS_URI); + Resource resource = load(file, resourceSet); + if (resource != null) { + return ((org.openejb.xml.ns.openejb.jar.DocumentRoot) resource.getContents().get(0)).getOpenejbJar(); + } + } + return null; + } + + public static ConnectorType getConnectorDeploymentPlan(IFile file) { + if (file.getName().equals(CONNECTOR_PLAN_NAME) && file.exists()) { + ResourceSet resourceSet = new ResourceSetImpl(); + register(resourceSet, new ConnectorResourceFactoryImpl(), ConnectorPackage.eINSTANCE, ConnectorPackage.eNS_URI); + Resource resource = load(file, resourceSet); + if (resource != null) { + return ((org.apache.geronimo.xml.ns.j2ee.connector.DocumentRoot) resource.getContents().get(0)).getConnector(); + } + } + return null; + } +} Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java Fri Apr 21 07:09:10 2006 @@ -0,0 +1,31 @@ +/** + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed 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.v11.core; + +import org.apache.geronimo.st.core.IGeronimoVersionHandler; +import org.eclipse.wst.server.core.IModule; + +public class GeronimoV11VersionHandler implements IGeronimoVersionHandler { + + /* + * (non-Javadoc) + * + * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#getConfigID(org.eclipse.wst.server.core.IModule) + */ + public String getConfigID(IModule module) { + return GeronimoV11Utils.getConfigId(module); + } +} Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/META-INF/MANIFEST.MF?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/META-INF/MANIFEST.MF (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/META-INF/MANIFEST.MF Fri Apr 21 07:09:10 2006 @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Geronimo Server Tools V11 UI Plug-in -Bundle-SymbolicName: org.apache.geronimo.st.v11.ui +Bundle-SymbolicName: org.apache.geronimo.st.v11.ui;singleton:=true Bundle-Version: 1.0.0 Bundle-Activator: org.apache.geronimo.st.v11.ui.Activator Bundle-Vendor: Apache Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/build.properties URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/build.properties?rev=395891&r1=395890&r2=395891&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/build.properties (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/build.properties Fri Apr 21 07:09:10 2006 @@ -1,4 +1,5 @@ source.. = src/ output.. = target/classes/ bin.includes = META-INF/,\ - . + .,\ + plugin.xml Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml?rev=395891&view=auto ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml (added) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml Fri Apr 21 07:09:10 2006 @@ -0,0 +1,13 @@ + + + + + + + + + Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/plugin.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml