Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-01-06 16:30:43 +0000
committerSimone Bordet2015-01-06 16:30:43 +0000
commit379f9f6c432a0a1b2e0b93d93b98197489752ddd (patch)
tree397df6579685a38a1114ec1e0de272df221da9d0
parent200b3a3e6440cf45506b0c206aa395baaadc9df6 (diff)
parent3abfbe26b391a7486fd3eb68586dad981bf77de8 (diff)
downloadorg.eclipse.jetty.project-379f9f6c432a0a1b2e0b93d93b98197489752ddd.tar.gz
org.eclipse.jetty.project-379f9f6c432a0a1b2e0b93d93b98197489752ddd.tar.xz
org.eclipse.jetty.project-379f9f6c432a0a1b2e0b93d93b98197489752ddd.zip
Merged branch 'jetty-9.2.x' into 'master'.
-rw-r--r--jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java12
-rw-r--r--jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml30
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java31
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java22
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java4
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java14
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java4
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java9
8 files changed, 106 insertions, 20 deletions
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java
index c0a742d2e1..b018deb25f 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.annotations;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -726,7 +727,15 @@ public class AnnotationConfiguration extends AbstractConfiguration
public Resource getJarFor (ServletContainerInitializer service)
throws MalformedURLException, IOException
{
- String loadingJarName = Thread.currentThread().getContextClassLoader().getResource(service.getClass().getName().replace('.','/')+".class").toString();
+ //try the thread context classloader to get the jar that loaded the class
+ URL jarURL = Thread.currentThread().getContextClassLoader().getResource(service.getClass().getName().replace('.','/')+".class");
+
+ //if for some reason that failed (eg we're in osgi and the TCCL does not know about the service) try the classloader that
+ //loaded the class
+ if (jarURL == null)
+ jarURL = service.getClass().getClassLoader().getResource(service.getClass().getName().replace('.','/')+".class");
+
+ String loadingJarName = jarURL.toString();
int i = loadingJarName.indexOf(".jar");
if (i < 0)
@@ -830,7 +839,6 @@ public class AnnotationConfiguration extends AbstractConfiguration
{
ArrayList<ServletContainerInitializer> nonExcludedInitializers = new ArrayList<ServletContainerInitializer>();
-
//We use the ServiceLoader mechanism to find the ServletContainerInitializer classes to inspect
long start = 0;
diff --git a/jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
new file mode 100644
index 0000000000..dd49e82257
--- /dev/null
+++ b/jetty-jspc-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -0,0 +1,30 @@
+<!-- ======================================================================== -->
+<!-- Copyright (c) 1995-2015 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. -->
+<!-- ======================================================================== -->
+
+<lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <goals>
+ <goal>jspc</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+</lifecycleMappingMetadata>
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java
index eab610f066..46af4885d9 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiDeployer.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.osgi.boot;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.bindings.StandardDeployer;
import org.eclipse.jetty.deploy.graph.Node;
+import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
import org.eclipse.jetty.osgi.boot.utils.EventSender;
@@ -34,6 +35,15 @@ import org.eclipse.jetty.osgi.boot.utils.EventSender;
public class OSGiDeployer extends StandardDeployer
{
+ private ServerInstanceWrapper _server;
+
+ /* ------------------------------------------------------------ */
+ public OSGiDeployer (ServerInstanceWrapper server)
+ {
+ _server = server;
+ }
+
+
/* ------------------------------------------------------------ */
public void processBinding(Node node, App app) throws Exception
{
@@ -41,14 +51,14 @@ public class OSGiDeployer extends StandardDeployer
//OSGi Enterprise Spec only wants an event sent if its a webapp bundle (ie not a ContextHandler)
if (!(app instanceof AbstractOSGiApp))
{
- super.processBinding(node,app);
+ doProcessBinding(node,app);
}
else
{
EventSender.getInstance().send(EventSender.DEPLOYING_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath());
try
{
- super.processBinding(node,app);
+ doProcessBinding(node,app);
((AbstractOSGiApp)app).registerAsOSGiService();
EventSender.getInstance().send(EventSender.DEPLOYED_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath());
}
@@ -58,6 +68,21 @@ public class OSGiDeployer extends StandardDeployer
throw e;
}
}
-
+ }
+
+
+ /* ------------------------------------------------------------ */
+ protected void doProcessBinding (Node node, App app) throws Exception
+ {
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(_server.getParentClassLoaderForWebapps());
+ try
+ {
+ super.processBinding(node,app);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(old);
+ }
}
}
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java
index 314a87a0ce..645723af5a 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiUndeployer.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.osgi.boot;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.bindings.StandardUndeployer;
import org.eclipse.jetty.deploy.graph.Node;
+import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
import org.eclipse.jetty.osgi.boot.utils.EventSender;
@@ -35,11 +36,30 @@ import org.eclipse.jetty.osgi.boot.utils.EventSender;
*/
public class OSGiUndeployer extends StandardUndeployer
{
+ private ServerInstanceWrapper _server;
+
+
+ /* ------------------------------------------------------------ */
+ public OSGiUndeployer (ServerInstanceWrapper server)
+ {
+ _server = server;
+ }
+
+
/* ------------------------------------------------------------ */
public void processBinding(Node node, App app) throws Exception
{
EventSender.getInstance().send(EventSender.UNDEPLOYING_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath());
- super.processBinding(node,app);
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(_server.getParentClassLoaderForWebapps());
+ try
+ {
+ super.processBinding(node,app);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(old);
+ }
EventSender.getInstance().send(EventSender.UNDEPLOYED_EVENT, ((AbstractOSGiApp)app).getBundle(), app.getContextPath());
((AbstractOSGiApp)app).deregisterAsOSGiService();
}
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java
index dc94d6d2f5..e142d39116 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java
@@ -376,10 +376,10 @@ public class ServerInstanceWrapper
_deploymentManager.setUseStandardBindings(false);
List<AppLifeCycle.Binding> deploymentLifeCycleBindings = new ArrayList<AppLifeCycle.Binding>();
- deploymentLifeCycleBindings.add(new OSGiDeployer());
+ deploymentLifeCycleBindings.add(new OSGiDeployer(this));
deploymentLifeCycleBindings.add(new StandardStarter());
deploymentLifeCycleBindings.add(new StandardStopper());
- deploymentLifeCycleBindings.add(new OSGiUndeployer());
+ deploymentLifeCycleBindings.add(new OSGiUndeployer(this));
_deploymentManager.setLifeCycleBindings(deploymentLifeCycleBindings);
if (!providerClassNames.contains(BundleWebAppProvider.class.getName()))
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java
index 6db338eacc..fc5b5ef380 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java
@@ -185,26 +185,20 @@ public class EnvConfiguration extends AbstractConfiguration
@Override
public void destroy (WebAppContext context) throws Exception
{
- ClassLoader old_loader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(context.getClassLoader());
- ContextFactory.associateClassLoader(context.getClassLoader());
-
try
{
- //unbind any NamingEntries that were configured in this webapp's name space
-
+ //unbind any NamingEntries that were configured in this webapp's name space
NamingContext scopeContext = (NamingContext)NamingEntryUtil.getContextForScope(context);
scopeContext.getParent().destroySubcontext(scopeContext.getName());
}
catch (NameNotFoundException e)
{
LOG.ignore(e);
- LOG.debug("No naming entries configured in environment for webapp "+context);
+ LOG.debug("No jndi entries scoped to webapp {}", context);
}
- finally
+ catch (NamingException e)
{
- ContextFactory.disassociateClassLoader();
- Thread.currentThread().setContextClassLoader(old_loader);
+ LOG.debug("Error unbinding jndi entries scoped to webapp "+context, e);
}
}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java
index 79ac67b6c4..44271cbb13 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java
@@ -268,7 +268,7 @@ public class SslContextFactory extends AbstractLifeCycle
}
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
- SSLContext context = SSLContext.getInstance(_sslProtocol);
+ SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider);
context.init(null, trust_managers, secureRandom);
_context = context;
}
@@ -309,7 +309,7 @@ public class SslContextFactory extends AbstractLifeCycle
TrustManager[] trustManagers = getTrustManagers(trustStore,crls);
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
- SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol,_sslProvider);
+ SSLContext context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider);
context.init(keyManagers,trustManagers,secureRandom);
_context = context;
}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
index b395e72526..57cbc71ea4 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
@@ -406,6 +406,15 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
}
/**
+ * @return The number of busy threads in the pool
+ */
+ @ManagedAttribute("total number of busy threads in the pool")
+ public int getBusyThreads()
+ {
+ return getThreads() - getIdleThreads();
+ }
+
+ /**
* @return True if the pool is at maxThreads and there are not more idle threads than queued jobs
*/
@Override

Back to the top