moved CQ-3581 plugins to own project root
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1026 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
060cf5a91d
commit
268926b31f
|
@ -1,12 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: OSGi HttpService provided by equinox HttpServiceServlet deployed on jetty
|
||||
Bundle-SymbolicName: org.eclipse.jetty.osgi.httpservice
|
||||
Bundle-Version: 7.0.1.qualifier
|
||||
Bundle-Vendor: Intalio Inc
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Import-Package: javax.servlet;version="2.5.0",
|
||||
javax.servlet.http;version="2.5.0",
|
||||
org.osgi.service.http;version="1.2.0",
|
||||
org.eclipse.equinox.http.servlet
|
||||
Jetty-ContextFilePath: contexts/httpservice.xml
|
|
@ -1,4 +0,0 @@
|
|||
source.. = src/main/java/
|
||||
output.. = target/classes/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
|
||||
<!-- this servlet provides the OSGi HTTP Service once it is initialized -->
|
||||
<Call name="addServlet">
|
||||
<Arg>org.eclipse.jetty.osgi.httpservice.HttpServiceServletX</Arg>
|
||||
<Arg>/*</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -1,28 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.httpservice;
|
||||
|
||||
import org.eclipse.equinox.http.servlet.HttpServiceServlet;
|
||||
|
||||
/**
|
||||
* Once this servlet is initialized, it provides the OSGi HttpService.
|
||||
* Compliments of equinox. Currently has no added value.
|
||||
*/
|
||||
public class HttpServiceServletX extends HttpServiceServlet
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Eclipse PDE Run Configuration
|
||||
Bundle-SymbolicName: org.eclipse.jetty.osgi.pde.launch;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.jetty.osgi.pde.launch.JettyOSGiPDEPlugin
|
||||
Bundle-Vendor: Intalio Inc
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.debug.core;bundle-version="3.5.0",
|
||||
org.eclipse.pde.ui;bundle-version="3.5.0",
|
||||
org.eclipse.debug.ui;bundle-version="3.5.0",
|
||||
org.eclipse.core.variables;bundle-version="3.2.200",
|
||||
org.eclipse.jdt.debug.ui;bundle-version="3.4.1"
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ActivationPolicy: lazy
|
|
@ -1,5 +0,0 @@
|
|||
source.. = src/main/java/
|
||||
output.. = target/classes/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
Binary file not shown.
Before Width: | Height: | Size: 815 B |
|
@ -1,97 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
-->
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.debug.core.launchConfigurationTypes">
|
||||
<launchConfigurationType
|
||||
delegate="org.eclipse.jetty.osgi.pde.launch.ui.JettyEquinoxLaunchConfiguration"
|
||||
delegateDescription="Launch Jetty in OSGi"
|
||||
delegateName="%PDELaunchDelegate.name"
|
||||
id="org.eclipse.jetty.osgi.pde.launch.ui.jettyosgilaunch"
|
||||
migrationDelegate="org.eclipse.pde.internal.ui.launcher.OSGiMigrationDelegate"
|
||||
modes="run, debug"
|
||||
name="Launch Jetty in OSGi"
|
||||
sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"
|
||||
sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer">
|
||||
</launchConfigurationType>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
|
||||
<launchConfigurationTypeImage
|
||||
icon="$nl$/icons/jetty.png"
|
||||
configTypeID="org.eclipse.jetty.osgi.pde.launch.ui.jettyosgilaunch"
|
||||
id="org.eclipse.jetty.osgi.pde.launch.jettyLaunchImage">
|
||||
</launchConfigurationTypeImage>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchShortcuts">
|
||||
<shortcut
|
||||
label="Jetty on OSGi"
|
||||
icon="$nl$/icons/jetty.png"
|
||||
modes="run, debug"
|
||||
class="org.eclipse.jetty.osgi.pde.launch.ui.JettyLaunchShortcut"
|
||||
id="org.eclipse.jetty.osgi.pde.launch.runjetty">
|
||||
<contextualLaunch>
|
||||
<enablement>
|
||||
<with variable="selection">
|
||||
<count value="1"/>
|
||||
<iterate>
|
||||
<and>
|
||||
<instanceof value="org.eclipse.core.runtime.IAdaptable"/>
|
||||
<test property="org.eclipse.debug.ui.projectNature" value="org.eclipse.pde.PluginNature"/>
|
||||
<or>
|
||||
<adapt type="org.eclipse.core.resources.IProject"/>
|
||||
<test property="org.eclipse.debug.ui.matchesPattern" value="MANIFEST.MF"/>
|
||||
</or>
|
||||
</and>
|
||||
</iterate>
|
||||
</with>
|
||||
</enablement>
|
||||
</contextualLaunch>
|
||||
<configurationType
|
||||
id="org.eclipse.jetty.osgi.pde.launch.ui.jettyosgilaunch">
|
||||
</configurationType>
|
||||
<description
|
||||
description="Lauch jetty in OSGi and deploy the OSGi webapps"
|
||||
mode="run">
|
||||
</description>
|
||||
<description
|
||||
description="Debug jetty in OSGi and the OSGi webapps"
|
||||
mode="debug">
|
||||
</description>
|
||||
</shortcut>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||
<launchConfigurationTabGroup
|
||||
type="org.eclipse.jetty.osgi.pde.launch.ui.jettyosgilaunch"
|
||||
class="org.eclipse.jetty.osgi.pde.launch.ui.JettyOSGiLauncherTabGroup"
|
||||
id="org.eclipse.jetty.osgi.pde.launch.ui.EquinoxLauncherTabGroup">
|
||||
<launchMode
|
||||
description="Create a configuration to launch Jetty in OSGi in debug mode"
|
||||
perspective="org.eclipse.debug.ui.DebugPerspective"
|
||||
mode="debug">
|
||||
</launchMode>
|
||||
<launchMode
|
||||
description="Create a configuration to launch Jetty in OSGi in run mode"
|
||||
mode="run">
|
||||
</launchMode>
|
||||
</launchConfigurationTabGroup>
|
||||
</extension>
|
||||
</plugin>
|
|
@ -1,28 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch;
|
||||
|
||||
/**
|
||||
* Configuration constants.
|
||||
*/
|
||||
public class JettyConfigurationConstants
|
||||
{
|
||||
private static final String PLUGIN_ID = JettyOSGiPDEPlugin.PLUGIN_ID;
|
||||
|
||||
/** Points to the jetty home folder */
|
||||
public static final String ATTR_JETTY_HOME = PLUGIN_ID + ".jettyhome";
|
||||
public static final String JETTY_HOME_DEFAULT = "${workspace_loc}/jettyhome";
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* NLS
|
||||
*/
|
||||
public class JettyLauncherMessages extends NLS
|
||||
{
|
||||
private static final String BUNDLE_NAME = "org.eclipse.jetty.osgi.pde.launch.JettyLauncherMessages";//$NON-NLS-1$
|
||||
|
||||
public static String JettyConfigurationLaunchTab_JettyConfigurationTitle;
|
||||
public static String JettyConfigurationLaunchTab_VariablesButtonLabel;
|
||||
|
||||
public static String JettyXmlBlock_JettyConfigurationBlockTitle;
|
||||
public static String JettyXmlBlock_JettyConfigurationBlockLabel;
|
||||
public static String JettyXmlBlock_VariablesButtonLabel;
|
||||
|
||||
public static String JettyXmlEditDialog_Cancel;
|
||||
public static String JettyXmlEditDialog_OK;
|
||||
public static String JettyXmlEditDialog_Apply;
|
||||
public static String JettyXmlEditDialog_Edit_jetty_xml;
|
||||
public static String JettyXmlEditDialog_Edit_jetty_xml_title;
|
||||
|
||||
static {
|
||||
// load message values from bundle file
|
||||
NLS.initializeMessages(BUNDLE_NAME, JettyLauncherMessages.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
# ========================================================================
|
||||
# Copyright (c) 2009 Intalio, Inc.
|
||||
# ------------------------------------------------------------------------
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Apache License v2.0 which accompanies this distribution.
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
# The Apache License v2.0 is available at
|
||||
# http://www.opensource.org/licenses/apache2.0.php
|
||||
# Contributors:
|
||||
# Hugues Malphettes - initial API and implementation
|
||||
# You may elect to redistribute this code under either of these licenses.
|
||||
# ========================================================================
|
||||
JettyConfigurationLaunchTab_JettyConfigurationTitle=Jetty &Configuration
|
||||
JettyConfigurationLaunchTab_VariablesButtonLabel=Var&iables...
|
||||
JettyXmlBlock_JettyConfigurationBlockTitle=jetty.xml configuration file:
|
||||
JettyXmlBlock_JettyConfigurationBlockLabel=jetty.xml &configuration file:
|
||||
JettyXmlBlock_VariablesButtonLabel=Variable&s
|
||||
JettyXmlEditDialog_Cancel=Cancel
|
||||
JettyXmlEditDialog_OK=OK
|
||||
JettyXmlEditDialog_Apply=Apply
|
||||
JettyXmlEditDialog_Edit_jetty_xml_title=Edit jetty.xml
|
||||
JettyXmlEditDialog_Edit_jetty_xml=Edit jetty.xml in ${0}
|
|
@ -1,71 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class JettyOSGiPDEPlugin extends AbstractUIPlugin
|
||||
{
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.jetty.osgi.pde.core";
|
||||
|
||||
// The shared instance
|
||||
private static JettyOSGiPDEPlugin plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public JettyOSGiPDEPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception
|
||||
{
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception
|
||||
{
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static JettyOSGiPDEPlugin getDefault()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,471 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.internal;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.variables.IStringVariableManager;
|
||||
import org.eclipse.core.variables.VariablesPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
* Utility methods related to jetty home and jetty.xml.
|
||||
* Default will be something like this:
|
||||
* ${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Jetty in OSGi
|
||||
*/
|
||||
public class JettyHomeHelper
|
||||
{
|
||||
/**
|
||||
* Helper
|
||||
* @return The bundle that is in charge of starting jetty in OSGi.
|
||||
*/
|
||||
private static Bundle getJettyOSGiBootBundle()
|
||||
{
|
||||
return Platform.getBundle("org.eclipse.jetty.osgi.boot");
|
||||
}
|
||||
|
||||
private static String resolveVariables(String target) {
|
||||
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
try
|
||||
{
|
||||
return manager.performStringSubstitution(target, false);
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves strings that start with "${workspace_loc:"
|
||||
* or "${workspace}"
|
||||
* Useful as the default configuration area used by pde is:
|
||||
* ${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/${name_of_configuration}
|
||||
* @see IStringVariableManager
|
||||
* @see org.eclipse.pde.internal.ui.launcher.ConfigurationTemplateBlock
|
||||
* @return The container
|
||||
*/
|
||||
public static IContainer getContainerFromWorkspace(String path)
|
||||
{
|
||||
// /.../theworkspace/.metadata/.plugins/org.eclipse.pde.core/Launch Jetty in OSGi/jettyhome
|
||||
if (path == null || path.trim().length() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
if (path.startsWith("${workspace_loc:"))
|
||||
{
|
||||
path = resolveVariables(path);
|
||||
return root.getContainerForLocation(new Path(path).makeAbsolute());
|
||||
}
|
||||
else if (path.startsWith("${workspace_loc}"))
|
||||
{
|
||||
path = path.substring("${workspace_loc}".length());
|
||||
path = resolveVariables(path);
|
||||
IFolder f = root.getFolder(new Path(path).makeAbsolute());
|
||||
if (f.getRawLocation() == null) {
|
||||
IContainer c = root.getContainerForLocation(new Path(path).makeAbsolute());
|
||||
if (c != null) {
|
||||
return c;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
IResource res = root.findMember(path);
|
||||
if (res instanceof IContainer)
|
||||
{
|
||||
return (IContainer) res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolves strings and try to make it a file in the filesystem.
|
||||
* @see IStringVariableManager
|
||||
* @see org.eclipse.pde.internal.ui.launcher.ConfigurationTemplateBlock
|
||||
* @return The container
|
||||
*/
|
||||
public static File getFileOutsideOfWorkspace(String path)
|
||||
{
|
||||
if (path == null || path.trim().length() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new File(resolveVariables(path));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The current content of jettyXml
|
||||
*/
|
||||
public static String getCurrentJettyXml(String jettyHomePath, boolean returnNullIfJettyXmlIsNull)
|
||||
{
|
||||
IContainer container = JettyHomeHelper.getContainerFromWorkspace(jettyHomePath);
|
||||
if (container != null)
|
||||
{
|
||||
IFile jettyXml = container.getFile(new Path("jettyhome/etc/jetty.xml"));
|
||||
if (!jettyXml.exists()) {
|
||||
//does not exist at this point:
|
||||
//just read the one in the bundle directly.
|
||||
return returnNullIfJettyXmlIsNull ? null : JettyHomeHelper.getJettyXmlInsideBootBundle();
|
||||
} else {
|
||||
//return the one that exists already.
|
||||
return JettyHomeHelper.loadIFileAsString(jettyXml);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
File configArea = JettyHomeHelper.getFileOutsideOfWorkspace(jettyHomePath);
|
||||
File jettyXml = new File(configArea, "jettyhome/etc/jetty.xml");
|
||||
if (jettyXml.exists()) {
|
||||
return JettyHomeHelper.loadFileAsString(jettyXml);
|
||||
} else {
|
||||
//does not exist at this point:
|
||||
//just read the one in the bundle directly.
|
||||
return returnNullIfJettyXmlIsNull ? null : JettyHomeHelper.getJettyXmlInsideBootBundle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return The content of jetty.xml inside the boot bundle.
|
||||
*/
|
||||
public static String getJettyXmlInsideBootBundle()
|
||||
{
|
||||
Bundle b = getJettyOSGiBootBundle();
|
||||
try
|
||||
{
|
||||
InputStream is = b.getEntry("/jettyhome/etc/jetty.xml").openStream();
|
||||
return loadInputAsString(is);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Something really straight forward to read the content of the file.
|
||||
* It is just jetty.xml: no need to be really fast and optimized here.
|
||||
*/
|
||||
public static String loadFileAsString(File jettyXml)
|
||||
{
|
||||
try
|
||||
{
|
||||
return loadInputAsString(new FileInputStream(jettyXml));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Something really straight forward to read the content of the file.
|
||||
* It is just jetty.xml: no need to be really fast and optimized here.
|
||||
*/
|
||||
public static String loadIFileAsString(IFile jettyXml)
|
||||
{
|
||||
try
|
||||
{
|
||||
return loadInputAsString(jettyXml.getContents());
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Something really straight forward to read the content of the file.
|
||||
* It is just jetty.xml: no need to be really fast and optimized here.
|
||||
*/
|
||||
public static String loadInputAsString(InputStream is)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8")); //$NON-NLS-1$
|
||||
String newline = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
sb.append(line + newline);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static File resolveJettyHome(String jettyHomeInConfig) {
|
||||
IContainer container = JettyHomeHelper.getContainerFromWorkspace(jettyHomeInConfig);
|
||||
if (container != null)
|
||||
{
|
||||
URI rawURI = container.getRawLocationURI();
|
||||
if (rawURI != null) {
|
||||
//it is null when the folder is not inside a project.
|
||||
return new File(rawURI);
|
||||
}
|
||||
}
|
||||
return JettyHomeHelper.getFileOutsideOfWorkspace(jettyHomeInConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the jettyhome folder.
|
||||
* If empty or it does not exist, extract the default one from the boot.
|
||||
*
|
||||
*
|
||||
* @param jettyXml custom content for jetty.xml or null if we keep the default one.
|
||||
* @param jettyHomePath path to jettyhome as set by the user.
|
||||
*/
|
||||
public static void setupJettyHomeAndJettyXML(String jettyXml, String jettyHomePath,
|
||||
boolean doNothingIfJettyHomeExists)
|
||||
throws IOException
|
||||
{
|
||||
File jettyhome = resolveJettyHome(jettyHomePath);
|
||||
if (jettyhome == null)
|
||||
{//we probably have a problem now.
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to resolve jettyhome " + jettyHomePath);
|
||||
}
|
||||
if (!jettyhome.exists())
|
||||
{
|
||||
//does not exist at this point: extract the default one:
|
||||
installDefaultJettyHome(jettyhome);
|
||||
}
|
||||
else if (doNothingIfJettyHomeExists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//check jetty.xml exists.
|
||||
File jettyXmlFile = new File(jettyhome, "etc/jetty.xml");
|
||||
if (!jettyXmlFile.exists())
|
||||
{//we probably have a problem now.
|
||||
throw new IllegalArgumentException(
|
||||
"The jetty configuration file must exist: '"
|
||||
+ jettyXmlFile.getAbsolutePath());
|
||||
}
|
||||
if (jettyXml != null) {
|
||||
//override the current jettyxml:
|
||||
FileOutputStream out = null;
|
||||
try
|
||||
{
|
||||
out = new FileOutputStream(jettyXmlFile);
|
||||
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
||||
writer.append(jettyXml);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (out != null) try { out.close(); } catch (IOException ioee) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually creates the jettyhome folder template in the location set
|
||||
* for the user.
|
||||
* Currently unzips the jettyhome folder located in the
|
||||
* org.eclipse.jetty.osgi.boot bundle.
|
||||
*/
|
||||
public static void installDefaultJettyHome(File jettyhomeFolder) throws IOException
|
||||
{
|
||||
jettyhomeFolder.mkdirs();
|
||||
Bundle bootBundle = getJettyOSGiBootBundle();
|
||||
File bootBundleFile = FileLocator.getBundleFile(bootBundle);
|
||||
|
||||
if (bootBundleFile.getName().endsWith(".jar"))
|
||||
{
|
||||
//unzip it.
|
||||
unzipJettyHomeIntoDirectory(bootBundleFile, jettyhomeFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
//copy the folders.
|
||||
copyDirectory(new File(bootBundleFile, "jettyhome"), jettyhomeFolder);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @param zipFile
|
||||
* The current jar file for this bundle. contains an archive of
|
||||
* the default jettyhome
|
||||
* @param parentOfMagicJettyHome
|
||||
* The folder inside which jettyhome is created.
|
||||
*/
|
||||
private static void unzipJettyHomeIntoDirectory(File thisbundlejar,
|
||||
File parentOfMagicJettyHome) throws IOException
|
||||
{
|
||||
ZipFile zipFile = null;
|
||||
try
|
||||
{
|
||||
zipFile = new ZipFile(thisbundlejar);
|
||||
Enumeration<? extends ZipEntry> files = zipFile.entries();
|
||||
File f = null;
|
||||
FileOutputStream fos = null;
|
||||
|
||||
while (files.hasMoreElements())
|
||||
{
|
||||
try
|
||||
{
|
||||
ZipEntry entry = files.nextElement();
|
||||
String entryName = entry.getName();
|
||||
if (!entryName.startsWith("jettyhome"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
InputStream eis = zipFile.getInputStream(entry);
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead = 0;
|
||||
f = new File(parentOfMagicJettyHome,entry.getName());
|
||||
|
||||
if (entry.isDirectory())
|
||||
{
|
||||
f.mkdirs();
|
||||
}
|
||||
else
|
||||
{
|
||||
f.getParentFile().mkdirs();
|
||||
f.createNewFile();
|
||||
fos = new FileOutputStream(f);
|
||||
while ((bytesRead = eis.read(buffer)) != -1)
|
||||
{
|
||||
fos.write(buffer,0,bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fos != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fos.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
fos = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (zipFile != null) try { zipFile.close(); } catch (Throwable t) {}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyDirectory(File sourceFile, File destFile) throws IOException
|
||||
{
|
||||
if (sourceFile.isDirectory())
|
||||
{
|
||||
if (!destFile.exists())
|
||||
{
|
||||
destFile.mkdir();
|
||||
}
|
||||
String files[] = sourceFile.list();
|
||||
for (int i = 0; i < files.length; i++)
|
||||
{
|
||||
copyDirectory(new File(sourceFile,files[i]),new File(destFile,files[i]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sourceFile.exists())
|
||||
{
|
||||
//humf
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
copyFile(sourceFile,destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyFile(File sourceFile, File destFile) throws IOException
|
||||
{
|
||||
if (!destFile.exists())
|
||||
{
|
||||
destFile.createNewFile();
|
||||
}
|
||||
|
||||
FileChannel source = null;
|
||||
FileChannel destination = null;
|
||||
try
|
||||
{
|
||||
source = new FileInputStream(sourceFile).getChannel();
|
||||
destination = new FileOutputStream(destFile).getChannel();
|
||||
destination.transferFrom(source,0,source.size());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (source != null) { source.close(); }
|
||||
if (destination != null) { destination.close(); }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui;
|
||||
|
||||
/**
|
||||
* Object that can read the value of the osgi.config.area property that will be
|
||||
* used when the OSGi app is launched.
|
||||
*/
|
||||
public interface IConfigurationAreaSettingHolder
|
||||
{
|
||||
/**
|
||||
* @return the string entered in the settings tab that defines the
|
||||
* value o osgi.config.area.
|
||||
*/
|
||||
public String getConfigurationAreaLocation();
|
||||
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
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.jetty.osgi.pde.launch.JettyConfigurationConstants;
|
||||
import org.eclipse.jetty.osgi.pde.launch.JettyOSGiPDEPlugin;
|
||||
import org.eclipse.jetty.osgi.pde.launch.internal.JettyHomeHelper;
|
||||
import org.eclipse.pde.internal.ui.launcher.LaunchConfigurationHelper;
|
||||
import org.eclipse.pde.ui.launcher.EquinoxLaunchConfiguration;
|
||||
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JettyEquinoxLaunchConfiguration extends EquinoxLaunchConfiguration
|
||||
{
|
||||
|
||||
/** The configuration type as declared in the extension point's plugin.xml */
|
||||
public static final String ID = "org.eclipse.jetty.osgi.pde.launch.ui.jettyosgilaunch";
|
||||
|
||||
@Override
|
||||
protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException
|
||||
{
|
||||
if (!configuration.getAttribute(IPDELauncherConstants.DOCLEAR, false))
|
||||
{
|
||||
super.preLaunchCheck(configuration,launch,monitor);
|
||||
//make sure jettyhome exists and set it up if it does not:
|
||||
File jettyHome = resolveJettyHome(configuration);
|
||||
if (jettyHome != null && !jettyHome.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
JettyHomeHelper.setupJettyHomeAndJettyXML(null, jettyHome.getAbsolutePath(), true);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new CoreException(new Status(IStatus.ERROR,
|
||||
JettyOSGiPDEPlugin.PLUGIN_ID,"Unable to setup jettyhome", e));
|
||||
}
|
||||
}
|
||||
return;//nothing else to do.
|
||||
}
|
||||
//this will wipe the workspace if it was configured that way.
|
||||
//it means we must setup jettyhome and jettyxml immediately after
|
||||
//if indeed it was wiped:
|
||||
String jettyHomePath = resolveJettyHome(configuration).getAbsolutePath();
|
||||
String jettyXml = JettyHomeHelper.getCurrentJettyXml(jettyHomePath, true);
|
||||
super.preLaunchCheck(configuration,launch,monitor);
|
||||
try
|
||||
{
|
||||
JettyHomeHelper.setupJettyHomeAndJettyXML(jettyXml, jettyHomePath, true);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new CoreException(new Status(IStatus.ERROR,
|
||||
JettyOSGiPDEPlugin.PLUGIN_ID,"Unable to setup jettyhome", e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append -Djetty.home
|
||||
*/
|
||||
@Override
|
||||
public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException
|
||||
{
|
||||
String[] args = super.getVMArguments(configuration);
|
||||
for (int i = 0; i < args.length ;i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith("-Djetty.home=")) {
|
||||
//overridden by the arg nothing to change (?)
|
||||
return args;
|
||||
}
|
||||
}
|
||||
String jettyHomePath = configuration.getAttribute(JettyConfigurationConstants.ATTR_JETTY_HOME, "");
|
||||
File jettyHome = resolveJettyHome(configuration);
|
||||
if (jettyHome == null || !jettyHome.exists())
|
||||
{
|
||||
//err?
|
||||
System.err.println("could not resolve jettyhome; "
|
||||
+ jettyHomePath + " -> " + jettyHome);
|
||||
return args;
|
||||
}
|
||||
String[] newArgs = new String[args.length+1];
|
||||
System.arraycopy(args, 0, newArgs, 0, args.length);
|
||||
newArgs[args.length] = "-Djetty.home=\""+jettyHome.getAbsolutePath()+"\"";
|
||||
return newArgs;
|
||||
}
|
||||
|
||||
private File resolveJettyHome(ILaunchConfiguration configuration) throws CoreException
|
||||
{
|
||||
String jettyHomePath = configuration.getAttribute(JettyConfigurationConstants.ATTR_JETTY_HOME, "");
|
||||
if (jettyHomePath == null || jettyHomePath.length() == 0)
|
||||
{
|
||||
File configArea = LaunchConfigurationHelper.getConfigurationArea(configuration);
|
||||
return new File(configArea, "jettyhome");
|
||||
}
|
||||
else
|
||||
{
|
||||
return JettyHomeHelper.resolveJettyHome(jettyHomePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui;
|
||||
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.pde.ui.launcher.AbstractLaunchShortcut;
|
||||
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
|
||||
/**
|
||||
* Shortcut to launch Jetty on osgi.
|
||||
*/
|
||||
public class JettyLaunchShortcut extends AbstractLaunchShortcut
|
||||
{
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
|
||||
*/
|
||||
public void launch(ISelection selection, String mode)
|
||||
{
|
||||
launch(mode);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
|
||||
*/
|
||||
public void launch(IEditorPart editor, String mode)
|
||||
{
|
||||
launch(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the launch configuration type name.
|
||||
*
|
||||
* @return the launch configuration type name
|
||||
*/
|
||||
protected String getLaunchConfigurationTypeName()
|
||||
{
|
||||
return JettyEquinoxLaunchConfiguration.ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize launch attributes on the new launch configuration. Must be overridden by subclasses.
|
||||
*
|
||||
* @param wc
|
||||
* the launch configuration working copy to be initialize
|
||||
*
|
||||
* @see IPDELauncherConstants
|
||||
*/
|
||||
protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc)
|
||||
{
|
||||
JettyOSGiLaunchConfigurationInitializer confInitializer = new JettyOSGiLaunchConfigurationInitializer();
|
||||
confInitializer.initialize(wc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a given launch configuration is a good match given the
|
||||
* current application or framework being launched. This method must be overridden
|
||||
* by subclasses. Its purpose is to add criteria on what makes a good match or not.
|
||||
*
|
||||
* @param configuration
|
||||
* the launch configuration being evaluated
|
||||
* @return <code>true</code> if the launch configuration is a good match
|
||||
* for the application or framework being launched,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
protected boolean isGoodMatch(ILaunchConfiguration configuration)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,203 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
|
||||
import org.eclipse.pde.core.plugin.IPluginModelBase;
|
||||
import org.eclipse.pde.core.plugin.PluginRegistry;
|
||||
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
|
||||
import org.eclipse.pde.internal.ui.launcher.EquinoxInitializer;
|
||||
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
|
||||
|
||||
/**
|
||||
* In charge of selecting the proper default bundles to load and to make sure
|
||||
* that the jetty.osgi.boot bundle will in fact start.
|
||||
* <p>
|
||||
* The default behavior of OSGi run configuration is to select everything.
|
||||
* This is overwhelming for the web-app developer.
|
||||
* This run configuration initializer will select the minimum set of plugins to run jetty.
|
||||
* </p>
|
||||
*/
|
||||
public class JettyOSGiLaunchConfigurationInitializer extends EquinoxInitializer
|
||||
{
|
||||
|
||||
/** well known bundles that jetty depends on, often optional dependency. */
|
||||
private static final Set<String> BUNDLE_DEPENDENCIES = new HashSet<String>();
|
||||
/** well known bundles required to support headles jdt */
|
||||
private static final Set<String> JDT_HEADLESS_DEPENDENCIES = new HashSet<String>();
|
||||
|
||||
private static final Set<String> ALL_BUNDLE_DEPS = new HashSet<String>();
|
||||
|
||||
|
||||
/** we don't know the bundle but if we find a bundle that exports this package */
|
||||
private static final Set<String> PACKAGES_DEPENDENCIES = new HashSet<String>();
|
||||
|
||||
private static final String JETTY_BUNDLES_PREFIX = "org.eclipse.jetty.";
|
||||
private static final String JETTY_JSP_BUNDLES_PREFIX = "org.mortbay.jetty.jsp-";
|
||||
static {
|
||||
BUNDLE_DEPENDENCIES.add("javax.servlet");
|
||||
BUNDLE_DEPENDENCIES.add("org.eclipse.osgi");
|
||||
BUNDLE_DEPENDENCIES.add("org.eclipse.osgi.services");
|
||||
BUNDLE_DEPENDENCIES.add("org.objectweb.asm");
|
||||
|
||||
PACKAGES_DEPENDENCIES.add("javax.mail");
|
||||
PACKAGES_DEPENDENCIES.add("javax.transaction");
|
||||
PACKAGES_DEPENDENCIES.add("javax.activation");
|
||||
PACKAGES_DEPENDENCIES.add("javax.annotation");
|
||||
|
||||
//now add the headless jdt:
|
||||
//no more ecj: we use jdt.core instead that contains ecj.
|
||||
// BUNDLE_DEPENDENCIES.add("org.eclipse.jdt.core.compiler.batch");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.commands");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.contenttype");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.expressions");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.filessytem");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.jobs");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.resources");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.runtime");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.core.variables");
|
||||
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.debug.core");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.equinox.app");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.equinox.common");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.equinox.preferences");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.equinox.registry");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.equinox.app");
|
||||
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.jdt.core");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.jdt.debug");
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.jdt.launching");
|
||||
|
||||
JDT_HEADLESS_DEPENDENCIES.add("org.eclipse.text");
|
||||
|
||||
|
||||
ALL_BUNDLE_DEPS.addAll(JDT_HEADLESS_DEPENDENCIES);
|
||||
ALL_BUNDLE_DEPS.addAll(BUNDLE_DEPENDENCIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the default behavior which consists of selecting every bundle.
|
||||
* Here we select only the jetty and jdt-headless bundles from the platform
|
||||
* By default we continue to select all the bundles located in the workspace.
|
||||
*
|
||||
* @param configuration the launch configuration
|
||||
*/
|
||||
@Override
|
||||
protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration)
|
||||
{
|
||||
List<IPluginModelBase> bundlesInPlatform = new ArrayList<IPluginModelBase>();
|
||||
List<IPluginModelBase> bundlesInWorkspace = new ArrayList<IPluginModelBase>();
|
||||
selectBundles(bundlesInPlatform, bundlesInWorkspace);
|
||||
|
||||
configuration.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, createBundleList(bundlesInWorkspace));
|
||||
configuration.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, createBundleList(bundlesInPlatform));
|
||||
configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The list of bundles to install along with their start level in the format expected by
|
||||
* equinox for the config.ini file. For example:
|
||||
* <code>osgi.bundles=org.eclipse.equinox.common@2:start, org.eclipse.update.configurator@3:start</code>
|
||||
*
|
||||
* (As documented here: http://www.eclipse.org/equinox/documents/quickstart.php)
|
||||
*/
|
||||
private String createBundleList(List<IPluginModelBase> bundlesInPlatform)
|
||||
{
|
||||
StringBuilder bundlesInPlatformString = new StringBuilder();
|
||||
String sep = "";
|
||||
for (IPluginModelBase bundleModel : bundlesInPlatform)
|
||||
{
|
||||
String id = bundleModel.getPluginBase().getId();
|
||||
bundlesInPlatformString.append(sep
|
||||
+ BundleLauncherHelper.writeBundleEntry(bundleModel,
|
||||
getStartLevel(id), getAutoStart(id)));
|
||||
sep = ",";
|
||||
}
|
||||
return bundlesInPlatformString.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we are doing something else than the default OSGi launch configuration initializer.
|
||||
* We select only the jetty plugins, their dependencies and the jdt-headless plugins
|
||||
* if we want to launch the ability to debug the java projects too.
|
||||
*
|
||||
* @param bundlesInPlatformCollector Where the bundles that belong to the platform are collected.
|
||||
* @param bundlesInWorkspaceCollector Where the bundles that belong to the workspace are collected.
|
||||
*/
|
||||
private void selectBundles(List<IPluginModelBase> bundlesInPlatformCollector,
|
||||
List<IPluginModelBase> bundlesInWorkspaceCollector)
|
||||
{
|
||||
for (IPluginModelBase pluginModel : PluginRegistry.getActiveModels())
|
||||
{
|
||||
String symbName = pluginModel.getBundleDescription().getSymbolicName();
|
||||
if (pluginModel.getUnderlyingResource() != null)
|
||||
{
|
||||
//all bundles in the workspace are added by default.
|
||||
bundlesInWorkspaceCollector.add(pluginModel);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (symbName.startsWith(JETTY_BUNDLES_PREFIX))
|
||||
{
|
||||
if (symbName.startsWith("org.eclipse.jetty.osgi.pde"))
|
||||
{
|
||||
// don't select the SDK PDE plugins for running jetty!
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (symbName.startsWith(JETTY_JSP_BUNDLES_PREFIX))
|
||||
{
|
||||
//let's add them.
|
||||
bundlesInPlatformCollector.add(pluginModel);
|
||||
}
|
||||
else if (!ALL_BUNDLE_DEPS.contains(symbName))
|
||||
{
|
||||
ExportPackageDescription[] exPacks =
|
||||
pluginModel.getBundleDescription().getExportPackages();
|
||||
for (int j = 0; j < exPacks.length; j++)
|
||||
{
|
||||
ExportPackageDescription xp = exPacks[j];
|
||||
if (PACKAGES_DEPENDENCIES.contains(xp.getName()))
|
||||
{
|
||||
bundlesInPlatformCollector.add(pluginModel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the default behavior: we need to make sure that
|
||||
* org.eclipse.jetty.osgi.boot has its autostart level set to 'true'
|
||||
*/
|
||||
@Override
|
||||
protected String getAutoStart(String bundleID)
|
||||
{
|
||||
if (bundleID.equals("org.eclipse.jetty.osgi.boot"))
|
||||
{
|
||||
return Boolean.TRUE.toString();
|
||||
}
|
||||
return super.getAutoStart(bundleID);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.jetty.osgi.pde.launch.ui.tabs.JettyConfigurationLaunchTab;
|
||||
import org.eclipse.pde.ui.launcher.OSGiLauncherTabGroup;
|
||||
import org.eclipse.pde.ui.launcher.OSGiSettingsTab;
|
||||
|
||||
/**
|
||||
* Customizes the OSGi configuration UI.
|
||||
* <p>
|
||||
* Make sure that new default configurations select all the jetty bundles
|
||||
* and deselect the rest of the platform.
|
||||
* </p>
|
||||
* <p>
|
||||
* Insert a new tab for the configuration of jetty home and the ability to edit
|
||||
* jetty.xml
|
||||
* </p>
|
||||
*/
|
||||
public class JettyOSGiLauncherTabGroup extends AbstractLaunchConfigurationTabGroup
|
||||
implements IConfigurationAreaSettingHolder
|
||||
{
|
||||
|
||||
/**
|
||||
* Use the same tabs than the OSGi lauch.
|
||||
* Add one first tab to give access to the jetty configuration.
|
||||
* For now we will simply display the jetty.xml file in a text editor.
|
||||
*/
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode)
|
||||
{
|
||||
ILaunchConfigurationTab[] tabs = createOSGiLaunchTabs(dialog, mode);
|
||||
ILaunchConfigurationTab[] newtabs = new ILaunchConfigurationTab[tabs.length+1];
|
||||
newtabs[0] = new JettyConfigurationLaunchTab(this);
|
||||
System.arraycopy(tabs, 0, newtabs, 1, tabs.length);
|
||||
super.setTabs(newtabs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dialog
|
||||
* @param mode
|
||||
* @return The tabs created for an OSGi Launch
|
||||
*/
|
||||
private ILaunchConfigurationTab[] createOSGiLaunchTabs(ILaunchConfigurationDialog dialog, String mode)
|
||||
{
|
||||
OSGiLauncherTabGroup osgiTabsFactory = new OSGiLauncherTabGroup();
|
||||
osgiTabsFactory.createTabs(dialog, mode);
|
||||
return osgiTabsFactory.getTabs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to read the setting "Configuration Area" in the Settings tab
|
||||
* that will become the folder pointed by the system property osgi.config.area
|
||||
* when the app is run.
|
||||
* <p>
|
||||
* Painful to access it.
|
||||
* </p>
|
||||
*/
|
||||
public String getConfigurationAreaLocation()
|
||||
{
|
||||
OSGiSettingsTab settingsTab = null;
|
||||
for (ILaunchConfigurationTab t : getTabs())
|
||||
{
|
||||
if (t instanceof OSGiSettingsTab) {
|
||||
settingsTab = (OSGiSettingsTab)t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (settingsTab == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//OSGisettingsTab contains org.eclipse.pde.internal.ui.launcher.ConfigurationAreaBlock
|
||||
//it is a private field called "fConfigurationBlock"
|
||||
//that object contains the private string "fLastEnteredConfigArea"
|
||||
//which is what we want.
|
||||
//we must access it from there as we need the value "live"
|
||||
return getfLastEnteredConfigArea(getfConfigurationBlock(settingsTab));
|
||||
}
|
||||
|
||||
//introspection tricks..
|
||||
private static Field fConfigurationBlock;
|
||||
private static Field fLastEnteredConfigArea;
|
||||
|
||||
private static synchronized Object getfConfigurationBlock(OSGiSettingsTab settingsTab)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fConfigurationBlock == null)
|
||||
{
|
||||
fConfigurationBlock = OSGiSettingsTab.class.getDeclaredField("fConfigurationBlock");
|
||||
fConfigurationBlock.setAccessible(true);
|
||||
}
|
||||
return fConfigurationBlock.get(settingsTab);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static synchronized String getfLastEnteredConfigArea(Object configurationBlock)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fLastEnteredConfigArea == null)
|
||||
{
|
||||
fLastEnteredConfigArea = configurationBlock.getClass().getDeclaredField("fLastEnteredConfigArea");
|
||||
fLastEnteredConfigArea.setAccessible(true);
|
||||
}
|
||||
return (String)fLastEnteredConfigArea.get(configurationBlock);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui.tabs;
|
||||
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.jetty.osgi.pde.launch.JettyLauncherMessages;
|
||||
import org.eclipse.jetty.osgi.pde.launch.ui.IConfigurationAreaSettingHolder;
|
||||
import org.eclipse.jetty.osgi.pde.launch.ui.JettyOSGiLaunchConfigurationInitializer;
|
||||
import org.eclipse.pde.ui.launcher.AbstractLauncherTab;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
* Choose a jetty.home.
|
||||
* Edit the jetty.xml file.
|
||||
* <p>
|
||||
* Similar to org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab
|
||||
* </p>
|
||||
*/
|
||||
public class JettyConfigurationLaunchTab extends AbstractLauncherTab
|
||||
{
|
||||
protected JettyHomeBlock _jettyHomeBlock;
|
||||
|
||||
public JettyConfigurationLaunchTab(IConfigurationAreaSettingHolder configAreaHolder)
|
||||
{
|
||||
_jettyHomeBlock = new JettyHomeBlock(configAreaHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently does not do any validation.
|
||||
*/
|
||||
public void validateTab()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite)
|
||||
*/
|
||||
public void createControl(Composite parent)
|
||||
{
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
comp.setLayout(layout);
|
||||
comp.setFont(parent.getFont());
|
||||
|
||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||
comp.setLayoutData(gd);
|
||||
setControl(comp);
|
||||
|
||||
_jettyHomeBlock.doCreateControl(comp);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return JettyLauncherMessages.JettyConfigurationLaunchTab_JettyConfigurationTitle;
|
||||
}
|
||||
|
||||
public void initializeFrom(ILaunchConfiguration configuration)
|
||||
{
|
||||
_jettyHomeBlock.initializeFrom(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void performApply(ILaunchConfigurationWorkingCopy configuration)
|
||||
{
|
||||
_jettyHomeBlock.performApply(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we initialize the selected bundles by default.
|
||||
*/
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration)
|
||||
{
|
||||
_jettyHomeBlock.setDefaults(configuration);
|
||||
JettyOSGiLaunchConfigurationInitializer confInitializer =
|
||||
new JettyOSGiLaunchConfigurationInitializer();
|
||||
confInitializer.initialize(configuration);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui.tabs;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.ui.WorkingDirectoryBlock;
|
||||
import org.eclipse.jetty.osgi.pde.launch.JettyConfigurationConstants;
|
||||
import org.eclipse.jetty.osgi.pde.launch.internal.JettyHomeHelper;
|
||||
import org.eclipse.jetty.osgi.pde.launch.ui.IConfigurationAreaSettingHolder;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
|
||||
/**
|
||||
* Choose the jettyhome folder. A bit of a stretch to reuse the WorkingDirectoryBlock
|
||||
* but it does save us a lot of UI development.
|
||||
*/
|
||||
public class JettyHomeBlock extends WorkingDirectoryBlock
|
||||
{
|
||||
private Button _editJettyXml;
|
||||
private String _editedJettyXml;
|
||||
private IConfigurationAreaSettingHolder _configAreaHolder;
|
||||
private boolean _initializing = true;
|
||||
|
||||
/**
|
||||
* Constructs a new working directory block.
|
||||
*/
|
||||
public JettyHomeBlock(IConfigurationAreaSettingHolder configAreaHolder)
|
||||
{
|
||||
super(JettyConfigurationConstants.ATTR_JETTY_HOME);
|
||||
_configAreaHolder = configAreaHolder;
|
||||
setDirty(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null We don't use this in the context of a java project.
|
||||
*/
|
||||
protected IProject getProject(ILaunchConfiguration configuration)
|
||||
throws CoreException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For now just dumpt the stack trace on the console
|
||||
*/
|
||||
protected void log(CoreException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls create control of the super (which is final)
|
||||
* then go an tweak the created control so that its purpose is for jetty home
|
||||
* instead of a working directory selection.
|
||||
*/
|
||||
protected void doCreateControl(Composite parent)
|
||||
{
|
||||
super.createControl(parent);
|
||||
Group grp = (Group)super.getControl();
|
||||
grp.setText("Jetty &Home:");
|
||||
|
||||
//ok now a bit painful: get the composite inside which the buttons are
|
||||
//add a column to the grid layout and place a button.
|
||||
Button fSysButton = getfFileSystemButton();
|
||||
Composite compButtons = fSysButton.getParent();
|
||||
GridLayout gLayout = (GridLayout) compButtons.getLayout();
|
||||
gLayout.numColumns = gLayout.numColumns+1;
|
||||
_editJettyXml = createPushButton(compButtons, "Edit jetty.xml", null);
|
||||
_editJettyXml.addSelectionListener(new SelectionListener()
|
||||
{
|
||||
public void widgetSelected(SelectionEvent e)
|
||||
{
|
||||
//open a text editor for jetty.xml inside a popup window.
|
||||
//we are using a cheap popup.
|
||||
JettyXmlEditDialog diag = new JettyXmlEditDialog(_editJettyXml.getShell(),
|
||||
getCurrentJettyXml());
|
||||
if (diag.open() == Window.OK) {
|
||||
_editedJettyXml = diag.getNewJettyXml();
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void widgetDefaultSelected(SelectionEvent e)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value for this field: not related to the working directory.
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaultWorkingDir()
|
||||
{
|
||||
//the problem is that at this point, the settings tab is not configured yet...
|
||||
//so we delay the configuration of this one:
|
||||
getShell().getDisplay().asyncExec(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
setDefaultWorkingDirectoryText(
|
||||
_configAreaHolder.getConfigurationAreaLocation()
|
||||
+ File.separator + "jettyhome"); //$NON-NLS-1$
|
||||
_initializing = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The current content of jettyXml
|
||||
*/
|
||||
protected String getCurrentJettyXml()
|
||||
{
|
||||
return JettyHomeHelper.getCurrentJettyXml(getWorkingDirectoryText(), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void performApply(ILaunchConfigurationWorkingCopy configuration)
|
||||
{
|
||||
super.performApply(configuration);
|
||||
String jettyHome = getWorkingDirectoryText();
|
||||
if (_initializing || jettyHome == null || jettyHome.length() == 0) {
|
||||
//we are only interested in the case where the user really did press on
|
||||
//Apply or "Run". furthermore before the conf area is set
|
||||
//we will not be able to locate the default jettyhome.
|
||||
_initializing = false;
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
JettyHomeHelper.setupJettyHomeAndJettyXML(
|
||||
_editedJettyXml, getWorkingDirectoryText(), false);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//introspection trick to be able to insert a button.
|
||||
private static Field fFileSystemButton_field;
|
||||
private Button getfFileSystemButton()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fFileSystemButton_field == null)
|
||||
{
|
||||
fFileSystemButton_field = WorkingDirectoryBlock.class.getDeclaredField("fFileSystemButton");
|
||||
fFileSystemButton_field.setAccessible(true);
|
||||
}
|
||||
return (Button)fFileSystemButton_field.get(this);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,175 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.launch.ui.tabs;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.jetty.osgi.pde.launch.JettyLauncherMessages;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
* A dialog that displays the content of jetty.xml
|
||||
* <p>
|
||||
* If someone knows how to open a standard editor provided by the IDE
|
||||
* inside a popup from a modal dialog please let us know:
|
||||
* that would be so much better than the simple SWT Text widget!
|
||||
* </p>
|
||||
*/
|
||||
public class JettyXmlEditDialog extends Dialog
|
||||
{
|
||||
|
||||
/** The text area to edit the contents of jetty.xml file */
|
||||
protected Text _textField;
|
||||
private Button _okButton;
|
||||
/** Status label. */
|
||||
private Label _statusLabel;
|
||||
|
||||
private boolean _isDirty = false;;
|
||||
private String _lastValidatedString;
|
||||
private String _jettyHome;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param scope The scope in which the variable is created/edited
|
||||
* @param parentShell The parent shell
|
||||
* @param initValue The initial name of the variable
|
||||
* before the edit. Or null if it is a bran new variable.
|
||||
*/
|
||||
public JettyXmlEditDialog(Shell parentShell, String currentJettyXml)
|
||||
{
|
||||
super(parentShell);
|
||||
setShellStyle(SWT.SHELL_TRIM
|
||||
| getDefaultOrientation() | SWT.RESIZE);
|
||||
setBlockOnOpen(true);
|
||||
_lastValidatedString = currentJettyXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the "OK" button
|
||||
*/
|
||||
public Button getGoForItButton() {
|
||||
return _okButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The new jetty.xml contents or null if there was no modification.
|
||||
*/
|
||||
protected String getNewJettyXml() {
|
||||
return _isDirty ? _lastValidatedString : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked to update UI based on user input.
|
||||
*
|
||||
*/
|
||||
protected void validateInput() {
|
||||
String text = _textField.getText();
|
||||
if (text.equals(_lastValidatedString)) {
|
||||
return;
|
||||
}
|
||||
_isDirty = true;
|
||||
_lastValidatedString = text;
|
||||
Button ok = getGoForItButton();
|
||||
ok.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void configureShell(Shell newShell, String jettyHome) {
|
||||
super.configureShell(newShell);
|
||||
_jettyHome = jettyHome;
|
||||
newShell.setText(JettyLauncherMessages.JettyXmlEditDialog_Edit_jetty_xml_title);
|
||||
newShell.setSize(600, 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
Composite composite = (Composite)super.createDialogArea(parent);
|
||||
GridLayout gridLayout = new GridLayout();
|
||||
gridLayout.numColumns = 1;
|
||||
composite.setLayout(gridLayout);
|
||||
Label label = new Label(composite, SWT.NONE);
|
||||
String msg = JettyLauncherMessages.bind(
|
||||
JettyLauncherMessages.JettyXmlEditDialog_Edit_jetty_xml,
|
||||
_jettyHome + File.separatorChar + "etc" + File.separatorChar + "jetty.xml");
|
||||
label.setText(msg);
|
||||
|
||||
_textField = new Text(composite, SWT.MULTI | SWT.BORDER /*| SWT.WRAP*/ | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
_textField.addKeyListener(new KeyListener() {
|
||||
public void keyReleased(KeyEvent e) {
|
||||
validateInput();
|
||||
}
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
if (_lastValidatedString != null) {
|
||||
_textField.setText(_lastValidatedString);
|
||||
}
|
||||
GridData gridData = new GridData();
|
||||
gridData.horizontalAlignment = GridData.FILL;
|
||||
gridData.verticalAlignment = GridData.FILL;
|
||||
gridData.grabExcessHorizontalSpace = true;
|
||||
gridData.grabExcessVerticalSpace = true;
|
||||
_textField.setLayoutData(gridData);
|
||||
// _textField.setSize(500, 500);
|
||||
// status label
|
||||
_statusLabel = new Label(composite, SWT.NONE);
|
||||
_statusLabel.setText(" "); //$NON-NLS-1$
|
||||
gridData = new GridData();
|
||||
gridData.horizontalAlignment = GridData.FILL;
|
||||
gridData.grabExcessHorizontalSpace = true;
|
||||
_statusLabel.setLayoutData(gridData);
|
||||
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
createButton(parent, IDialogConstants.CANCEL_ID, JettyLauncherMessages.JettyXmlEditDialog_Cancel, false);
|
||||
_okButton = createButton(parent, IDialogConstants.OK_ID,
|
||||
JettyLauncherMessages.JettyXmlEditDialog_OK, true);
|
||||
_okButton.setEnabled(false);
|
||||
|
||||
//call validate input before the user has to type something.
|
||||
//it will decide on the state of the create button.
|
||||
validateInput();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean close() {
|
||||
// _text = getText();
|
||||
// return super.close();
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Projecttemplate
|
||||
Bundle-SymbolicName: org.eclipse.jetty.osgi.pde.templates;singleton:=true
|
||||
Bundle-Version: 7.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.jetty.osgi.pde.templates.JettyProjectTemplateActivator
|
||||
Bundle-Vendor: Intalio Inc
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.pde.ui;bundle-version="3.5.0",
|
||||
org.eclipse.pde.ui.templates;bundle-version="3.4.100",
|
||||
org.eclipse.core.resources;bundle-version="3.5.0"
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ActivationPolicy: lazy
|
|
@ -1,7 +0,0 @@
|
|||
source.. = src/main/java/
|
||||
output.. = target/classes/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
templates_3.4/,\
|
||||
icons/
|
Binary file not shown.
Before Width: | Height: | Size: 815 B |
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
-->
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.pde.ui.pluginContent">
|
||||
<wizard
|
||||
class="org.eclipse.jetty.osgi.pde.templates.HelloRFC66WebappNewWizard"
|
||||
icon="$nl$/icons/jetty.png"
|
||||
id="org.eclipse.jetty.osgi.pde.templates.HelloRFC66WebappNewWizard"
|
||||
java="true"
|
||||
name="Hello RFC-66 Web-application"
|
||||
pureOSGi="true"
|
||||
rcp="false"
|
||||
requiresActivator="false"
|
||||
ui-content="false">
|
||||
<description>
|
||||
Simple web-application embedded inside an OSGi bundle.
|
||||
A single servlet declared in /WEB-INF/web.xml
|
||||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
class="org.eclipse.jetty.osgi.pde.templates.TwoWebappsOneServletHandlerNewWizard"
|
||||
icon="$nl$/icons/jetty.png"
|
||||
id="org.eclipse.jetty.osgi.pde.templates.TwoWebappsOneServletHandlerNewWizard"
|
||||
java="true"
|
||||
name="Multiple Jetty webapps embedded in an OSGi bundle"
|
||||
pureOSGi="true"
|
||||
rcp="false"
|
||||
requiresActivator="false"
|
||||
ui-content="false">
|
||||
<description>
|
||||
Two webapps and one servlet handler configured via 3 jetty context files.
|
||||
</description>
|
||||
</wizard>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -1,109 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.pde.core.plugin.IPluginReference;
|
||||
import org.eclipse.pde.ui.templates.OptionTemplateSection;
|
||||
|
||||
/**
|
||||
* Simple abstract implementation of OptionTemplateSection suitable for templates defined
|
||||
* in this bundle.
|
||||
*/
|
||||
public abstract class AbstractJettyPDETemplateSection extends OptionTemplateSection
|
||||
{
|
||||
|
||||
public AbstractJettyPDETemplateSection()
|
||||
{
|
||||
super.setPageCount(getNumberOfPagesToCreateCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The location of the installation of this current bundle.
|
||||
*/
|
||||
protected URL getInstallURL() {
|
||||
return JettyProjectTemplateActivator.getDefault().getBundle().getEntry("/");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The properties files for this bundle.
|
||||
*/
|
||||
protected ResourceBundle getPluginResourceBundle() {
|
||||
return Platform.getResourceBundle(
|
||||
JettyProjectTemplateActivator.getDefault().getBundle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls internalAddPages.
|
||||
* Takes care of calling markPagesAdded as required by the super implementation.
|
||||
*/
|
||||
public final void addPages(Wizard wizard)
|
||||
{
|
||||
super.markPagesAdded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually add the pages to the wizard here.
|
||||
* @param wizard
|
||||
*/
|
||||
protected abstract void internalAddPages(Wizard wizard);
|
||||
|
||||
/**
|
||||
* @return the number of pages that will be added here. By default 1.
|
||||
*/
|
||||
protected int getNumberOfPagesToCreateCount()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null By default we don't declare extension points.
|
||||
* This is for OSGi bundles not eclipse plugins.
|
||||
*/
|
||||
public String getUsedExtensionPoint()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true: inherit from parent wizard
|
||||
*/
|
||||
public boolean isDependentOnParentWizard()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 1 by default we don't not do anything fancy with the progress monitors.
|
||||
*/
|
||||
public int getNumberOfWorkUnits()
|
||||
{
|
||||
return super.getNumberOfWorkUnits() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false by default we don't generate multiple projects at once right now.
|
||||
*/
|
||||
public IPluginReference[] getDependencies(String schemaVersion)
|
||||
{
|
||||
return new IPluginReference[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import org.eclipse.pde.ui.IFieldData;
|
||||
import org.eclipse.pde.ui.templates.NewPluginTemplateWizard;
|
||||
|
||||
/**
|
||||
* Base template wizard: set the Import-Packages header in the generated MANIFEST.MF
|
||||
* to import the javax.servlet and javax.servlet.http
|
||||
*/
|
||||
public abstract class AbstractOSGiWebappNewWizard extends NewPluginTemplateWizard
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.AbstractNewPluginTemplateWizard#init(org.eclipse.pde.ui.IFieldData)
|
||||
*/
|
||||
public void init(IFieldData data)
|
||||
{
|
||||
super.init(data);
|
||||
setWindowTitle("Webapp(s) embedded in an OSGi bundle");
|
||||
}
|
||||
|
||||
/**
|
||||
* In these default examples, the only dependency are the servlet's packages.
|
||||
*/
|
||||
public String[] getImportPackages()
|
||||
{
|
||||
return new String[] {"javax.servlet;version=\"2.5.0\"", //$NON-NLS-1$
|
||||
"javax.servlet.http;version=\"2.5.0\""}; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import org.eclipse.pde.ui.IFieldData;
|
||||
import org.eclipse.pde.ui.templates.ITemplateSection;
|
||||
import org.eclipse.pde.ui.templates.NewPluginTemplateWizard;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HelloRFC66WebappNewWizard extends AbstractOSGiWebappNewWizard
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.AbstractNewPluginTemplateWizard#init(org.eclipse.pde.ui.IFieldData)
|
||||
*/
|
||||
public void init(IFieldData data) {
|
||||
super.init(data);
|
||||
setWindowTitle("Basic webapp embedded in an OSGi bundle");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.NewPluginTemplateWizard#createTemplateSections()
|
||||
*/
|
||||
public ITemplateSection[] createTemplateSections() {
|
||||
return new ITemplateSection[] {new HelloRFC66WebappTemplate()};
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
|
||||
/**
|
||||
* Template to generate a simple hello wold webapp embedded in an OSGi bundle.
|
||||
*/
|
||||
public class HelloRFC66WebappTemplate extends AbstractJettyPDETemplateSection
|
||||
{
|
||||
|
||||
public static final String GREETINGS = "greetings";
|
||||
public static final String CONTEXT_PATH = "contextPath"; //$NON-NLS-1$
|
||||
|
||||
public HelloRFC66WebappTemplate()
|
||||
{
|
||||
addOption(GREETINGS,"Greetings message", "Howdy!",0);
|
||||
addOption(CONTEXT_PATH,"Web-ContextPath","/hello",0); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected void internalAddPages(Wizard wizard)
|
||||
{
|
||||
WizardPage page = createPage(0, null);//no help for now
|
||||
page.setTitle("Hello World RFC66 Webapp");
|
||||
page.setDescription("Creates a webapp embedded in an OSGi bundle");
|
||||
wizard.addPage(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 'helloRFC66Webapp' used to locate the base folder that
|
||||
* contains the template files.
|
||||
*/
|
||||
public String getSectionId()
|
||||
{
|
||||
return "helloRFC66Webapp"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the Web-ContextPath to the MANIFEST.MF as required by RFC66
|
||||
*/
|
||||
protected void updateModel(IProgressMonitor monitor)
|
||||
{
|
||||
setManifestHeader("Web-ContextPath", String.valueOf(getOptions(0)[1].getValue())); //$NON-NLS-1$ //$NON-NLS-2$]
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.ITemplateSection#getFoldersToInclude()
|
||||
*/
|
||||
public String[] getNewFiles() {
|
||||
return new String[] {"WEB-INF/web.xml"};
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class JettyProjectTemplateActivator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.jetty.osgi.pde.projecttemplate";
|
||||
|
||||
// The shared instance
|
||||
private static JettyProjectTemplateActivator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public JettyProjectTemplateActivator()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception
|
||||
{
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception
|
||||
{
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static JettyProjectTemplateActivator getDefault()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import org.eclipse.pde.ui.IFieldData;
|
||||
import org.eclipse.pde.ui.templates.ITemplateSection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TwoWebappsOneServletHandlerNewWizard extends AbstractOSGiWebappNewWizard
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.AbstractNewPluginTemplateWizard#init(org.eclipse.pde.ui.IFieldData)
|
||||
*/
|
||||
public void init(IFieldData data) {
|
||||
super.init(data);
|
||||
setWindowTitle("Two Webapps and one servlet embedded in an OSGi bundle");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.NewPluginTemplateWizard#createTemplateSections()
|
||||
*/
|
||||
public ITemplateSection[] createTemplateSections() {
|
||||
return new ITemplateSection[] {new TwoWebappsOneServletHandlerTemplate()};
|
||||
}
|
||||
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// Contributors:
|
||||
// Hugues Malphettes - initial API and implementation
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.pde.templates;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
|
||||
/**
|
||||
* Template that generates jetty webapps.
|
||||
*/
|
||||
public class TwoWebappsOneServletHandlerTemplate extends AbstractJettyPDETemplateSection
|
||||
{
|
||||
|
||||
public static final String GREETINGS = "greetings"; //$NON-NLS-1$
|
||||
public static final String CONTEXT_PATH_APP_1 = "contextPathApp1"; //$NON-NLS-1$
|
||||
public static final String CONTEXT_PATH_APP_2 = "contextPathApp2"; //$NON-NLS-1$
|
||||
|
||||
public TwoWebappsOneServletHandlerTemplate()
|
||||
{
|
||||
addOption(GREETINGS,"Greetings message", "Howdy!",0);
|
||||
addOption(CONTEXT_PATH_APP_1,"Webapp 1 Context Path","/app1",0); //$NON-NLS-1$
|
||||
addOption(CONTEXT_PATH_APP_2,"Webapp 2 Context Path","/app2",0); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void internalAddPages(Wizard wizard)
|
||||
{
|
||||
WizardPage page = createPage(0, null);
|
||||
page.setTitle("Two webapps and one servlet in an OSGi bundle");
|
||||
page.setDescription("Creates multiple jetty webapps embedded in an OSGi bundle");
|
||||
wizard.addPage(page);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.pde.ui.templates.OptionTemplateSection#getSectionId()
|
||||
*/
|
||||
public String getSectionId()
|
||||
{
|
||||
return "twoWebappsOneServletHandler"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the Jetty-ContextFilePath to the MANIFEST.MF as required for
|
||||
* jetty-osgi to be able to identify the embedded webapps.
|
||||
*/
|
||||
protected void updateModel(IProgressMonitor monitor)
|
||||
{
|
||||
setManifestHeader("Jetty-ContextFilePath",
|
||||
"jettycontexts/myservlet.xml, " + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"jettycontexts/app1.xml, jettycontexts/app2.xml"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.pde.ui.templates.ITemplateSection#getFoldersToInclude()
|
||||
*/
|
||||
public String[] getNewFiles() {
|
||||
return new String[] {"war1/WEB-INF/web.xml",
|
||||
"war2/WEB-INF/web.xml", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"jettycontexts/app1.xml", "jettycontexts/app2.xml", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"jettycontexts/myservlet.xml"}; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<web-app
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<display-name>Hello Webapp</display-name>
|
||||
<servlet>
|
||||
<servlet-name>theservlet</servlet-name>
|
||||
<servlet-class>$packageName$.Servlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>theservlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
|
@ -1,24 +0,0 @@
|
|||
package $packageName$;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class $activator$ implements BundleActivator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
System.out.println("$startMessage$");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
System.out.println("$stopMessage$");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package $packageName$;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class Servlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void service(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
resp.getWriter().write("$greetings$");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package $packageName$;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class $activator$ implements BundleActivator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
System.out.println("$startMessage$");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
System.out.println("$stopMessage$");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package $packageName$;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class Servlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void service(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
resp.getWriter().write(req.getContextPath() + ": $greetings$");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">$contextPathApp1$</Set>
|
||||
<Set name="war"><Property name="this.bundle.install"/>/war2</Set>
|
||||
</Configure>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">$contextPathApp2$</Set>
|
||||
<Set name="war"><Property name="this.bundle.install"/>/war2</Set>
|
||||
</Configure>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
|
||||
<Call name="addServlet">
|
||||
<Arg>$packageName$.Servlet</Arg>
|
||||
<Arg>/theservlet</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<web-app
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<display-name>Hello Webapp</display-name>
|
||||
<servlet>
|
||||
<servlet-name>theservlet</servlet-name>
|
||||
<servlet-class>$packageName$.Servlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>theservlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<web-app
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<display-name>Hello Webapp</display-name>
|
||||
<servlet>
|
||||
<servlet-name>theservlet</servlet-name>
|
||||
<servlet-class>$packageName$.Servlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>theservlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
Loading…
Reference in New Issue