diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java index 8eb512b7736..03a3e0ca602 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Continuation.java @@ -19,7 +19,6 @@ package org.eclipse.jetty.continuation; import javax.servlet.FilterChain; -import javax.servlet.Servlet; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.ServletResponseWrapper; @@ -138,8 +137,10 @@ import javax.servlet.ServletResponseWrapper; * * @see ContinuationSupport * @see ContinuationListener - * + * + * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated public interface Continuation { public final static String ATTRIBUTE = "org.eclipse.jetty.continuation"; diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java index 82ed4762bed..cdc9daf3f51 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationFilter.java @@ -48,7 +48,9 @@ import javax.servlet.ServletResponse; * {@link Continuation#complete()} is called.
*Faux continuations are not threadless continuations (they are "faux" - fake - for this reason) * and as such they will scale less than proper continuations.
+ * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated public class ContinuationFilter implements Filter { static boolean _initialized; @@ -60,6 +62,7 @@ public class ContinuationFilter implements Filter public void init(FilterConfig filterConfig) throws ServletException { + filterConfig.getServletContext().log("WARNING: " + this.getClass().getName() + " is now DEPRECATED, use Servlet 3.0 AsyncContext instead."); boolean jetty_7_or_greater="org.eclipse.jetty.servlet".equals(filterConfig.getClass().getPackage().getName()); _context = filterConfig.getServletContext(); diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java index 4c9574e9a57..56ef5c89cdc 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationListener.java @@ -27,7 +27,9 @@ import javax.servlet.ServletRequestListener; ** A ContinuationListener may be registered with a call to * {@link Continuation#addContinuationListener(ContinuationListener)}. + * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated public interface ContinuationListener extends EventListener { /* ------------------------------------------------------------ */ diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java index 4d1270b24ec..ab377be5c52 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java @@ -29,7 +29,9 @@ import javax.servlet.ServletResponse; * * Factory class for accessing Continuation instances, which with either be * a servlet 3.0 or a faux continuation. + * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated public class ContinuationSupport { static final boolean __servlet3; diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationThrowable.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationThrowable.java index 8044dcbbbe6..9f67ef3203e 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationThrowable.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationThrowable.java @@ -41,7 +41,9 @@ package org.eclipse.jetty.continuation; * to be uncaught (or rethrown) by a Filter/Servlet. A ContinuationThrowable * does not represent and error condition. *
+ * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated public class ContinuationThrowable extends Error { public ContinuationThrowable() diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java index 7b07ff80d4e..50e621a8bc9 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/FauxContinuation.java @@ -33,7 +33,9 @@ import org.eclipse.jetty.continuation.ContinuationFilter.FilteredContinuation; * A blocking implementation of Continuation. * This implementation of Continuation is used by the {@link ContinuationFilter} * when there are is no native or asynchronous continuation type available. + * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated class FauxContinuation implements FilteredContinuation { // common exception used for all continuations. diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java index 10ee475d249..6299f9ba6ce 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java @@ -36,7 +36,9 @@ import javax.servlet.ServletResponseWrapper; * This implementation of Continuation is used by {@link ContinuationSupport} * when it detects that the application has been deployed in a Servlet 3 * server. + * @deprecated use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated public class Servlet3Continuation implements Continuation, AsyncListener { // Exception reused for all continuations diff --git a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/package-info.java b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/package-info.java index ab26354b9de..fd9febd0cfc 100644 --- a/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/package-info.java +++ b/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/package-info.java @@ -17,7 +17,8 @@ // /** - * Jetty Continuation : Generic Async Servlet Method + * Jetty Continuation : DEPRECATED: use Servlet 3.0 {@link javax.servlet.AsyncContext} instead */ +@Deprecated package org.eclipse.jetty.continuation; diff --git a/jetty-documentation/src/main/asciidoc/configuring/security/jaas-support.adoc b/jetty-documentation/src/main/asciidoc/configuring/security/jaas-support.adoc index 55fa0399098..1d2dd0b6e1e 100644 --- a/jetty-documentation/src/main/asciidoc/configuring/security/jaas-support.adoc +++ b/jetty-documentation/src/main/asciidoc/configuring/security/jaas-support.adoc @@ -226,10 +226,10 @@ As `LoginModules` are free to use their own implementation of the JAAS Principal ===== Sample LoginModules -* link:{JXURL}/org/eclipse/jetty/jaas/spi/JDBCLoginModule.html[`org.eclipse.jetty.jaas.spi.JDBCLoginModule`] -* link:{JXURL}/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.html[`org.eclipse.jetty.jaas.spi.PropertyFileLoginModule`] -* link:{JXURL}/org/eclipse/jetty/jaas/spi/DataSourceLoginModule.html[`org.eclipse.jetty.jaas.spi.DataSourceLoginModule`] -* link:{JXURL}/org/eclipse/jetty/jaas/spi/LdapLoginModule.html[`org.eclipse.jetty.jaas.ldap.LdapLoginModule`] +* link:{JDURL}/org/eclipse/jetty/jaas/spi/JDBCLoginModule.html[`org.eclipse.jetty.jaas.spi.JDBCLoginModule`] +* link:{JDURL}/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.html[`org.eclipse.jetty.jaas.spi.PropertyFileLoginModule`] +* link:{JDURL}/org/eclipse/jetty/jaas/spi/DataSourceLoginModule.html[`org.eclipse.jetty.jaas.spi.DataSourceLoginModule`] +* link:{JDURL}/org/eclipse/jetty/jaas/spi/LdapLoginModule.html[`org.eclipse.jetty.jaas.ldap.LdapLoginModule`] ____ [NOTE] diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java index 3523b897c33..8dd35b80b39 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java @@ -33,6 +33,8 @@ import org.eclipse.jetty.server.session.UnreadableSessionDataException; import org.eclipse.jetty.server.session.UnwriteableSessionDataException; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -55,6 +57,7 @@ import com.google.cloud.datastore.StructuredQuery.PropertyFilter; * * */ +@ManagedObject public class GCloudSessionDataStore extends AbstractSessionDataStore { private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -410,11 +413,13 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore _namespace = namespace; } + @ManagedAttribute(value="gclound namespace", readonly=true) public String getNamespace () { return _namespace; } + @ManagedAttribute(value="unit in ms of exponential backoff") public int getBackoffMs () { return _backoff; @@ -426,7 +431,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore _maxRetries = retries; } - + @ManagedAttribute(value="max number of retries for failed writes") public int getMaxRetries () { return _maxRetries; @@ -480,6 +485,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore _dsProvided = true; } + @ManagedAttribute(value="max number of results to return from gcloud searches") public int getMaxResults() { return _maxResults; @@ -978,6 +984,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore /** * @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating() */ + @ManagedAttribute(value="does gcloud serialize session data", readonly=true) @Override public boolean isPassivating() { diff --git a/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionDataStore.java b/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionDataStore.java index d50f8883fbf..bf11861aa2e 100644 --- a/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionDataStore.java +++ b/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionDataStore.java @@ -27,6 +27,8 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.server.SessionIdManager; import org.eclipse.jetty.server.session.AbstractSessionDataStore; import org.eclipse.jetty.server.session.SessionData; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.infinispan.commons.api.BasicCache; @@ -36,6 +38,7 @@ import org.infinispan.commons.api.BasicCache; * * */ +@ManagedObject public class InfinispanSessionDataStore extends AbstractSessionDataStore { private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -231,6 +234,7 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore /** * @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating() */ + @ManagedAttribute(value="does store serialize sessions", readonly=true) @Override public boolean isPassivating() { @@ -307,6 +311,8 @@ public class InfinispanSessionDataStore extends AbstractSessionDataStore _infinispanIdleTimeoutSec = sec; } + + @ManagedAttribute(value="infinispan idle timeout sec", readonly=true) public int getInfinispanIdleTimeoutSec () { return _infinispanIdleTimeoutSec; diff --git a/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java b/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java index d0c0198a4e6..4862fe5a450 100644 --- a/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java +++ b/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java @@ -25,6 +25,8 @@ import java.util.List; import org.eclipse.jetty.server.session.SessionContext; import org.eclipse.jetty.server.session.SessionData; import org.eclipse.jetty.server.session.SessionDataMap; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.AbstractLifeCycle; import net.rubyeye.xmemcached.MemcachedClient; @@ -37,6 +39,7 @@ import net.rubyeye.xmemcached.XMemcachedClientBuilder; * * Uses memcached as a cache for SessionData. */ +@ManagedObject public class MemcachedSessionDataMap extends AbstractLifeCycle implements SessionDataMap { public static final String DEFAULT_HOST = "localhost"; @@ -91,8 +94,17 @@ public class MemcachedSessionDataMap extends AbstractLifeCycle implements Sessio _expirySec = sec; } + /** + * Expiry time for memached entries. + * @return memcached expiry time in sec + */ + @ManagedAttribute(value="memcached expiry time in sec", readonly=true) + public int getExpirySec () + { + return _expirySec; + } - + @ManagedAttribute(value="enable memcached heartbeats", readonly=true) public boolean isHeartbeats() { return _heartbeats; diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java index 9ed9e279170..d656cb7f002 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java @@ -44,6 +44,8 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.nosql.NoSqlSessionDataStore; import org.eclipse.jetty.server.session.SessionData; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -96,6 +98,7 @@ import org.eclipse.jetty.util.log.Logger; * * */ +@ManagedObject public class MongoSessionDataStore extends NoSqlSessionDataStore { @@ -171,7 +174,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore _dbSessions = collection; } - + @ManagedAttribute(value="DBCollection", readonly=true) public DBCollection getDBCollection () { return _dbSessions; @@ -695,6 +698,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore /** * @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating() */ + @ManagedAttribute(value="does store serialize sessions", readonly=true) @Override public boolean isPassivating() { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index 20b807746aa..d0d72f3ecc7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -18,9 +18,6 @@ package org.eclipse.jetty.server; -import static javax.servlet.RequestDispatcher.ERROR_EXCEPTION; -import static javax.servlet.RequestDispatcher.ERROR_STATUS_CODE; - import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; @@ -30,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import javax.servlet.DispatcherType; +import javax.servlet.RequestDispatcher; import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.HttpFields; @@ -54,7 +52,6 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Scheduler; - /** * HttpChannel represents a single endpoint for HTTP semantic processing. * The HttpChannel is both a HttpParser.RequestHandler, where it passively receives events from @@ -345,21 +342,15 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor case ERROR_DISPATCH: { - if (_response.isCommitted()) - { - if (LOG.isDebugEnabled()) - LOG.debug("Could not perform Error Dispatch because the response is already committed, aborting"); - _transport.abort((Throwable)_request.getAttribute(ERROR_EXCEPTION)); - } - else + try { _response.reset(); - Integer icode = (Integer)_request.getAttribute(ERROR_STATUS_CODE); + Integer icode = (Integer)_request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); int code = icode != null ? icode : HttpStatus.INTERNAL_SERVER_ERROR_500; _response.setStatus(code); - _request.setAttribute(ERROR_STATUS_CODE,code); + _request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,code); if (icode==null) - _request.setAttribute(ERROR_STATUS_CODE,code); + _request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,code); _request.setHandled(false); _response.getHttpOutput().reopen(); @@ -373,6 +364,12 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor _request.setDispatcherType(null); } } + catch (Throwable x) + { + if (LOG.isDebugEnabled()) + LOG.debug("Could not perform ERROR dispatch, aborting", x); + _transport.abort((Throwable)_request.getAttribute(RequestDispatcher.ERROR_EXCEPTION)); + } break; } @@ -514,36 +511,27 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor } try + { + _state.onError(failure); + } + catch (Throwable e) { try { - _state.onError(failure); + failure.addSuppressed(e); + LOG.warn("ERROR dispatch failed", failure); + // Try to send a minimal response. + Integer code=(Integer)_request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + _response.reset(); + _response.setStatus(code == null ? 500 : code); + _response.flushBuffer(); } - catch (Exception e) + catch (Throwable x) { - LOG.warn(e); - // Error could not be handled, probably due to error thrown from error dispatch - if (_response.isCommitted()) - { - LOG.warn("ERROR Dispatch failed: ",failure); - _transport.abort(failure); - } - else - { - // Minimal response - Integer code=(Integer)_request.getAttribute(ERROR_STATUS_CODE); - _response.reset(); - _response.setStatus(code == null ? 500 : code); - _response.flushBuffer(); - } + failure.addSuppressed(x); + _transport.abort(failure); } } - catch(Exception e) - { - failure.addSuppressed(e); - LOG.warn("ERROR Dispatch failed: ",failure); - _transport.abort(failure); - } } public boolean isExpecting100Continue() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java index 9c14ac573a8..afa00c255a6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java @@ -27,6 +27,8 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.log.Log; @@ -53,6 +55,7 @@ import org.eclipse.jetty.util.thread.Locker.Lock; * passivated before it is evicted from the cache. * */ +@ManagedObject public abstract class AbstractSessionCache extends ContainerLifeCycle implements SessionCache { final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -257,6 +260,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements /** * @see org.eclipse.jetty.server.session.SessionCache#getEvictionPolicy() */ + @ManagedAttribute(value="session eviction policy", readonly=true) public int getEvictionPolicy() { return _evictionPolicy; @@ -275,7 +279,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements _evictionPolicy = evictionTimeout; } - + @ManagedAttribute(value="immediately save new sessions", readonly=true) @Override public boolean isSaveOnCreate() { @@ -293,6 +297,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements /** * @return true if sessions that can't be loaded are deleted from the store */ + @ManagedAttribute(value="delete unreadable stored sessions", readonly=true) @Override public boolean isRemoveUnloadableSessions() { @@ -779,6 +784,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements * * @return true if an inactive session will be saved before being evicted */ + @ManagedAttribute(value="save sessions before evicting from cache", readonly=true) @Override public boolean isSaveOnInactiveEviction () { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStore.java index 4353c136340..8eeff510c51 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionDataStore.java @@ -23,6 +23,8 @@ package org.eclipse.jetty.server.session; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; @@ -33,6 +35,7 @@ import org.eclipse.jetty.util.log.Logger; * * */ +@ManagedObject public abstract class AbstractSessionDataStore extends ContainerLifeCycle implements SessionDataStore { final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -153,7 +156,9 @@ public abstract class AbstractSessionDataStore extends ContainerLifeCycle implem super.doStart(); } - + + + @ManagedAttribute(value="interval in secs to prevent too eager session scavenging", readonly=true) public int getGracePeriodSec() { return _gracePeriodSec; @@ -168,6 +173,7 @@ public abstract class AbstractSessionDataStore extends ContainerLifeCycle implem /** * @return the savePeriodSec */ + @ManagedAttribute(value="min secs between saves", readonly=true) public int getSavePeriodSec() { return _savePeriodSec; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionCache.java index 0fac9027c4b..1f15e9a74db 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionCache.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionCache.java @@ -23,6 +23,9 @@ import java.util.concurrent.ConcurrentHashMap; import javax.servlet.http.HttpServletRequest; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; +import org.eclipse.jetty.util.annotation.ManagedOperation; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.statistic.CounterStatistic; @@ -32,6 +35,7 @@ import org.eclipse.jetty.util.statistic.CounterStatistic; * * A session store that keeps its sessions in memory in a hashmap */ +@ManagedObject public class DefaultSessionCache extends AbstractSessionCache { private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -58,6 +62,7 @@ public class DefaultSessionCache extends AbstractSessionCache /** * @return the number of sessions in the cache */ + @ManagedAttribute(value="current sessions in cache", readonly=true) public long getSessionsCurrent () { return _stats.getCurrent(); @@ -67,6 +72,7 @@ public class DefaultSessionCache extends AbstractSessionCache /** * @return the max number of sessions in the cache */ + @ManagedAttribute(value="max sessions in cache", readonly=true) public long getSessionsMax() { return _stats.getMax(); @@ -76,6 +82,7 @@ public class DefaultSessionCache extends AbstractSessionCache /** * @return a running total of sessions in the cache */ + @ManagedAttribute(value="total sessions in cache", readonly=true) public long getSessionsTotal() { return _stats.getTotal(); @@ -84,6 +91,7 @@ public class DefaultSessionCache extends AbstractSessionCache /** * */ + @ManagedOperation(value="reset statistics", impact="ACTION") public void resetStats() { _stats.reset(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java index 26158ada4f4..550288ec5d7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java @@ -31,6 +31,8 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.SessionIdManager; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -49,6 +51,7 @@ import org.eclipse.jetty.util.log.Logger; * * @see HouseKeeper */ +@ManagedObject public class DefaultSessionIdManager extends ContainerLifeCycle implements SessionIdManager { private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -137,6 +140,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi * @return name or null */ @Override + @ManagedAttribute(value="unique name for this node", readonly=true) public String getWorkerName() { return _workerName; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java index a8a2fac4508..680d54d99af 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/FileSessionDataStore.java @@ -41,6 +41,8 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -49,6 +51,7 @@ import org.eclipse.jetty.util.log.Logger; * * A file-based store of session data. */ +@ManagedObject public class FileSessionDataStore extends AbstractSessionDataStore { private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -70,6 +73,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore super.doStop(); } + @ManagedAttribute(value="dir where sessions are stored", readonly=true) public File getStoreDir() { return _storeDir; @@ -307,6 +311,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore * @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating() */ @Override + @ManagedAttribute(value="are sessions serialized by this store", readonly=true) public boolean isPassivating() { return true; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HouseKeeper.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HouseKeeper.java index 36bbab44f7a..73b35d564cf 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HouseKeeper.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HouseKeeper.java @@ -22,6 +22,8 @@ package org.eclipse.jetty.server.session; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.server.SessionIdManager; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -34,6 +36,7 @@ import org.eclipse.jetty.util.thread.Scheduler; * There is 1 session HouseKeeper per SessionIdManager instance. * */ +@ManagedObject public class HouseKeeper extends AbstractLifeCycle { private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -238,6 +241,7 @@ public class HouseKeeper extends AbstractLifeCycle * * @return the interval (in seconds) */ + @ManagedAttribute(value="secs between scavenge cycles", readonly=true) public long getIntervalSec () { return _intervalMs/1000; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java index d7bcce51c07..944ed1857bf 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java @@ -38,6 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -46,6 +48,7 @@ import org.eclipse.jetty.util.log.Logger; * * Session data stored in database */ +@ManagedObject public class JDBCSessionDataStore extends AbstractSessionDataStore { final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -1020,6 +1023,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore * @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating() */ @Override + @ManagedAttribute(value="does this store serialize sessions", readonly=true) public boolean isPassivating() { return true; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/NullSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/NullSessionDataStore.java index 6fec782a848..e04b7612fa5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/NullSessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/NullSessionDataStore.java @@ -21,11 +21,15 @@ package org.eclipse.jetty.server.session; import java.util.Set; +import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; + /** * NullSessionDataStore * * Does not actually store anything, useful for testing. */ +@ManagedObject public class NullSessionDataStore extends AbstractSessionDataStore { @@ -81,6 +85,7 @@ public class NullSessionDataStore extends AbstractSessionDataStore /** * @see org.eclipse.jetty.server.session.SessionDataStore#isPassivating() */ + @ManagedAttribute(value="does this store serialize sessions", readonly=true) @Override public boolean isPassivating() { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index 894aeb3e903..c48330074c0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -57,6 +57,7 @@ import org.eclipse.jetty.server.handler.ScopedHandler; import org.eclipse.jetty.util.ConcurrentHashSet; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.annotation.ManagedOperation; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -70,6 +71,7 @@ import org.eclipse.jetty.util.thread.Locker.Lock; /** * SessionHandler. */ +@ManagedObject public class SessionHandler extends ScopedHandler { final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/URLStreamHandlerUtil.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/URLStreamHandlerUtil.java index 1960a494c45..aae6de59eed 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/URLStreamHandlerUtil.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/URLStreamHandlerUtil.java @@ -44,7 +44,7 @@ public final class URLStreamHandlerUtil } catch(Throwable ignore) { - ignore.printStackTrace(System.err); + // ignore.printStackTrace(System.err); } } diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderUrlStreamTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderUrlStreamTest.java index 296285052e6..74229a0b0e8 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderUrlStreamTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppClassLoaderUrlStreamTest.java @@ -25,7 +25,9 @@ import java.util.Map; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; +@Ignore("Not suitable for testing on CI (as URL object is modified)") public class WebAppClassLoaderUrlStreamTest extends WebAppClassLoaderTest { public static class URLHandlers implements URLStreamHandlerFactory diff --git a/tests/test-webapps/test-jaas-webapp/src/main/webapp/index.html b/tests/test-webapps/test-jaas-webapp/src/main/webapp/index.html index aa4df43c17a..148e11d8601 100644 --- a/tests/test-webapps/test-jaas-webapp/src/main/webapp/index.html +++ b/tests/test-webapps/test-jaas-webapp/src/main/webapp/index.html @@ -17,11 +17,11 @@To enable JAAS in a base jetty instance do:
$ cd $JETTY_BASE - $ java -jar $JETTY_HOME/start.jar --add-to-startd=jaas + $ java -jar $JETTY_HOME/start.jar --add-to-start=jaas-
This will create a $JETTY_BASE/start.d/jaas.ini file to enable and parameterise JAAS. If the --add-to-start option instead, then the same initialisation will be appended to the - $JETTY_BASE/start.ini file instead. The jetty demo-base already has JAAS enabled in the start.ini file.
+This will create a $JETTY_BASE/start.d/jaas.ini file to enable and parameterize JAAS. If no start.d directory exists, then the same initialisation will be appended to the + $JETTY_BASE/start.ini file. The Jetty demo-base already has JAAS enabled in its start.ini file.
The full source of this demonstration is available here.