From d36646f37f2b51a8d7eaf7dbb60e8965ab61362c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= Date: Sun, 1 Oct 2023 23:05:29 +0200 Subject: [PATCH 1/2] Convert to LF and ensure LF at EOF in o.e.equinox.http.servlet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was achieved by running: find . -type f -print0 | \ xargs -r0 perl -le 'for (@ARGV) { print if -f && -T }' | \ xargs -rd'\n' dos2unix -e Signed-off-by: Torbjörn SVENSSON --- ...inox.http.servlet.internal.multipart.MultipartSupportFactory | 2 +- bundles/org.eclipse.equinox.http.servlet/about.html | 2 +- .../equinox/http/servlet/dto/ExtendedFailedServletDTO.java | 2 +- .../eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java | 2 +- .../org/eclipse/equinox/http/servlet/internal/Activator.java | 2 +- .../http/servlet/internal/DefaultServletContextHelper.java | 2 +- .../servlet/internal/DefaultServletContextHelperFactory.java | 2 +- .../http/servlet/internal/context/ContextController.java | 2 +- .../equinox/http/servlet/internal/context/DispatchTargets.java | 2 +- .../equinox/http/servlet/internal/context/ServiceHolder.java | 2 +- .../http/servlet/internal/context/WrappedHttpContext.java | 2 +- .../customizer/RegistrationServiceTrackerCustomizer.java | 2 +- .../servlet/internal/error/HttpWhiteboardFailureException.java | 2 +- .../servlet/internal/error/IllegalContextNameException.java | 2 +- .../servlet/internal/error/IllegalContextPathException.java | 2 +- .../internal/error/NullServletContextHelperException.java | 2 +- .../http/servlet/internal/error/PatternInUseException.java | 2 +- .../internal/error/RegisteredServletContextHelperException.java | 2 +- .../internal/error/ServletAlreadyRegisteredException.java | 2 +- .../http/servlet/internal/multipart/MultipartSupport.java | 2 +- .../servlet/internal/multipart/MultipartSupportFactory.java | 2 +- .../servlet/internal/multipart/MultipartSupportFactoryImpl.java | 2 +- .../http/servlet/internal/multipart/MultipartSupportImpl.java | 2 +- .../servlet/internal/registration/ListenerRegistration.java | 2 +- .../internal/servlet/HttpServletResponseWrapperImpl.java | 2 +- .../http/servlet/internal/servlet/HttpSessionTracker.java | 2 +- .../internal/servlet/IncludeDispatchResponseWrapper.java | 2 +- .../eclipse/equinox/http/servlet/internal/util/BooleanPlus.java | 2 +- .../equinox/http/servlet/internal/util/EventListeners.java | 2 +- .../eclipse/equinox/http/servlet/internal/util/HttpTuple.java | 2 +- .../org/eclipse/equinox/http/servlet/internal/util/Path.java | 2 +- .../equinox/http/servlet/internal/util/ServiceReferenceMap.java | 2 +- .../eclipse/equinox/http/servlet/internal/util/StringPlus.java | 2 +- .../org/eclipse/equinox/http/servlet/internal/util/Throw.java | 2 +- .../equinox/http/servlet/internal/util/UMDictionaryMap.java | 2 +- .../equinox/http/servlet/internal/util/UMMapDictionary.java | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/bundles/org.eclipse.equinox.http.servlet/META-INF/services/org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportFactory b/bundles/org.eclipse.equinox.http.servlet/META-INF/services/org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportFactory index 28ed86bab6d..a9d6601e767 100644 --- a/bundles/org.eclipse.equinox.http.servlet/META-INF/services/org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportFactory +++ b/bundles/org.eclipse.equinox.http.servlet/META-INF/services/org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportFactory @@ -1 +1 @@ -org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportFactoryImpl \ No newline at end of file +org.eclipse.equinox.http.servlet.internal.multipart.MultipartSupportFactoryImpl diff --git a/bundles/org.eclipse.equinox.http.servlet/about.html b/bundles/org.eclipse.equinox.http.servlet/about.html index 164f781a8fd..8eee37d4705 100644 --- a/bundles/org.eclipse.equinox.http.servlet/about.html +++ b/bundles/org.eclipse.equinox.http.servlet/about.html @@ -33,4 +33,4 @@

License

- \ No newline at end of file + diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java index 99aba1f1bef..b53cb174cd1 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java @@ -23,4 +23,4 @@ @Deprecated public class ExtendedFailedServletDTO extends FailedServletDTO { // ignore -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java index e1fd833f9c4..3e9ace5b30f 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java @@ -23,4 +23,4 @@ @Deprecated public class ExtendedServletDTO extends ServletDTO { // deprecated -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java index 8907e3ed720..041b0d049b0 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java @@ -350,4 +350,4 @@ private void processRegistrations() { } } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java index 04fc3e6db1b..06f4bda5845 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java @@ -40,4 +40,4 @@ public URL getResource(String name) { return null; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java index ba1358b78d4..d4527589325 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java @@ -33,4 +33,4 @@ public void ungetService( ServletContextHelper service) { // do nothing } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java index 705022249fc..56860324920 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java @@ -1474,4 +1474,4 @@ else if (!(contextPathObj instanceof String)) { private final ServiceTracker> listenerServiceTracker; private final ServiceTracker> resourceServiceTracker; private final ServiceTracker> servletServiceTracker; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java index 54f114b588e..b4ae180c3d7 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java @@ -277,4 +277,4 @@ public void close() { private final Map specialOverides = new ConcurrentHashMap<>(); private String string; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java index e82c1569ab7..f23acfa487a 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java @@ -107,4 +107,4 @@ public int compareTo(ServiceHolder o) { } return 1; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java index d1aae696ade..6ace6548a6d 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java @@ -73,4 +73,4 @@ public Set getResourcePaths(String path) { return result; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java index b974df1f66e..92a14e7c744 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java @@ -72,4 +72,4 @@ public void removedService( protected final ContextController contextController; protected final HttpServiceRuntimeImpl httpServiceRuntime; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/HttpWhiteboardFailureException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/HttpWhiteboardFailureException.java index 95a0ce9abdf..a019d3bc954 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/HttpWhiteboardFailureException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/HttpWhiteboardFailureException.java @@ -35,4 +35,4 @@ public int getFailureReason() { private final int failureReason; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextNameException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextNameException.java index cd1e2c1b820..676ed6dcbe4 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextNameException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextNameException.java @@ -25,4 +25,4 @@ public IllegalContextNameException(String message, int failureReason) { super(message, failureReason); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextPathException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextPathException.java index 65791c40d6c..66091a17dbb 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextPathException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/IllegalContextPathException.java @@ -25,4 +25,4 @@ public IllegalContextPathException(String message, int failureReason) { super(message, failureReason); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/NullServletContextHelperException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/NullServletContextHelperException.java index 87f5e8bdd89..3d8bc1c4f83 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/NullServletContextHelperException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/NullServletContextHelperException.java @@ -25,4 +25,4 @@ public NullServletContextHelperException() { super("ServletContexHelper cannot be null."); //$NON-NLS-1$ } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/PatternInUseException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/PatternInUseException.java index 9fb53303f74..91ed0f9f36c 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/PatternInUseException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/PatternInUseException.java @@ -26,4 +26,4 @@ public class PatternInUseException extends NamespaceException { public PatternInUseException(String pattern) { super("Pattern already in use: " + pattern); //$NON-NLS-1$ } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java index 3d0aba89022..a2a786e87eb 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java @@ -28,4 +28,4 @@ public RegisteredServletContextHelperException() { super("ServletContextHelper has already been registered."); //$NON-NLS-1$ } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/ServletAlreadyRegisteredException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/ServletAlreadyRegisteredException.java index 522bd554840..f44b07260e6 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/ServletAlreadyRegisteredException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/ServletAlreadyRegisteredException.java @@ -28,4 +28,4 @@ public ServletAlreadyRegisteredException(Servlet servlet) { super("Servlet has already been registered: " + servlet); //$NON-NLS-1$ } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java index fe7acd0a094..fccff6a6e61 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupport.java @@ -24,4 +24,4 @@ public interface MultipartSupport { public List parseRequest(HttpServletRequest request) throws IOException, ServletException; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactory.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactory.java index 0d7066edc16..86d25d11e58 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactory.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactory.java @@ -20,4 +20,4 @@ public interface MultipartSupportFactory { MultipartSupport newInstance(ServletDTO servletDTO, ServletContext servletContext); -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java index d60a08fe6f6..22d0b038a0d 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java @@ -27,4 +27,4 @@ public MultipartSupport newInstance(ServletDTO servletDTO, ServletContext servle return new MultipartSupportImpl(servletDTO, servletContext); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java index e51ca697bb7..60273890db7 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java @@ -113,4 +113,4 @@ public List parseRequest(HttpServletRequest request) throws IOException, S private final ServletFileUpload upload; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java index a8da0978e48..afc99697be2 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java @@ -163,4 +163,4 @@ public Object invoke(Object theProxy, Method method, Object[] args) } } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java index 07b8cc3200a..99e1e45bdf2 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java @@ -241,4 +241,4 @@ public void write(String s) { } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java index 02d12eac174..bbeaf26ee03 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java @@ -116,4 +116,4 @@ public boolean removeHttpSessionAdaptor( new ConcurrentHashMap<>(); private final HttpServiceRuntimeImpl httpServiceRuntime; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/IncludeDispatchResponseWrapper.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/IncludeDispatchResponseWrapper.java index 5fe6d023569..6110a054b0d 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/IncludeDispatchResponseWrapper.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/IncludeDispatchResponseWrapper.java @@ -117,4 +117,4 @@ public void setBufferSize(int size) { return; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java index e852c933f2e..1eb228062a1 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java @@ -36,4 +36,4 @@ else if (Boolean.FALSE.toString().equalsIgnoreCase((String)object)) { return defaultValue; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java index 03c45eab19f..5283c6b4697 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java @@ -118,4 +118,4 @@ public int size() { private List list; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java index b7183c9f172..16541967601 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java @@ -50,4 +50,4 @@ public void destroy() { final ServiceRegistration hsrRegistration; final ProxyServlet proxyServlet; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java index 8d538a5ecdb..50a27390e10 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java @@ -67,4 +67,4 @@ public String getExtension() { private final String _queryString; private final String _extension; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java index e108b194747..2cbbdb9aa34 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java @@ -69,4 +69,4 @@ public String getKey() { } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java index fb00024e6fa..403cd775cfc 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java @@ -42,4 +42,4 @@ else if (Collection.class.isInstance(object)) { return Collections.emptyList(); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Throw.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Throw.java index 9979256f479..be41dfc1183 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Throw.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Throw.java @@ -24,4 +24,4 @@ private static T unchecked0(Throwable throwable) throws throw (E) throwable; } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java index 7bcdc9bf10b..73fe4385bb3 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java @@ -97,4 +97,4 @@ public Set> entrySet() { private final Map _map; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java index 42c007ccd4b..24c5d05c0f4 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java @@ -72,4 +72,4 @@ public V remove(Object key) { private final Enumeration _elements; private final Map _map; -} \ No newline at end of file +} From 5913daaab8d57b0742b557e582c539d851df7478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= Date: Sun, 1 Oct 2023 23:05:35 +0200 Subject: [PATCH 2/2] Format java files in o.e.equinox.http.servlet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was achieved by running: eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \ -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d` Signed-off-by: Torbjörn SVENSSON --- .../http/servlet/ExtendedHttpService.java | 53 +- .../http/servlet/HttpServiceServlet.java | 10 +- .../RangeAwareServletContextHelper.java | 7 +- .../context/ContextPathCustomizer.java | 52 +- .../servlet/dto/ExtendedFailedServletDTO.java | 4 +- .../http/servlet/dto/ExtendedServletDTO.java | 4 +- .../http/servlet/internal/Activator.java | 136 ++--- .../internal/DefaultServletContextHelper.java | 1 + .../DefaultServletContextHelperFactory.java | 10 +- .../servlet/internal/HttpServiceFactory.java | 10 +- .../servlet/internal/HttpServiceImpl.java | 49 +- .../HttpServiceObjectRegistration.java | 6 +- .../internal/HttpServiceRuntimeImpl.java | 421 ++++++------- .../internal/PreprocessorCustomizer.java | 68 +-- .../internal/context/ContextController.java | 578 ++++++++---------- .../internal/context/DispatchTargets.java | 67 +- .../internal/context/ProxyContext.java | 39 +- .../internal/context/ServiceHolder.java | 10 +- .../internal/context/WrappedHttpContext.java | 7 +- .../ContextErrorPageTrackerCustomizer.java | 51 +- .../ContextFilterTrackerCustomizer.java | 62 +- .../ContextListenerTrackerCustomizer.java | 63 +- .../ContextResourceTrackerCustomizer.java | 59 +- .../ContextServletTrackerCustomizer.java | 48 +- .../RegistrationServiceTrackerCustomizer.java | 18 +- ...gisteredServletContextHelperException.java | 3 +- .../MultipartSupportFactoryImpl.java | 3 +- .../multipart/MultipartSupportImpl.java | 13 +- .../multipart/MultipartSupportPart.java | 3 +- .../registration/EndpointRegistration.java | 30 +- .../registration/ErrorPageRegistration.java | 10 +- .../registration/FilterRegistration.java | 60 +- .../registration/ListenerRegistration.java | 38 +- .../registration/MatchableRegistration.java | 21 +- .../PreprocessorRegistration.java | 20 +- .../internal/registration/Registration.java | 15 +- .../registration/ResourceRegistration.java | 7 +- .../registration/ServletRegistration.java | 15 +- .../internal/servlet/FilterChainImpl.java | 5 +- .../internal/servlet/FilterConfigImpl.java | 7 +- .../HttpServletRequestWrapperImpl.java | 114 ++-- .../HttpServletResponseWrapperImpl.java | 12 +- .../internal/servlet/HttpSessionAdaptor.java | 54 +- .../internal/servlet/HttpSessionTracker.java | 40 +- .../servlet/PreprocessorChainImpl.java | 11 +- .../internal/servlet/ProxyServlet.java | 50 +- .../servlet/RequestDispatcherAdaptor.java | 19 +- .../internal/servlet/ResourceServlet.java | 30 +- .../servlet/ResponseStateHandler.java | 112 ++-- .../internal/servlet/ServletConfigImpl.java | 7 +- .../servlet/ServletContextAdaptor.java | 132 ++-- .../servlet/internal/util/BooleanPlus.java | 11 +- .../http/servlet/internal/util/DTOUtil.java | 177 +++--- .../servlet/internal/util/EventListeners.java | 24 +- .../servlet/internal/util/HttpStatus.java | 2 +- .../http/servlet/internal/util/HttpTuple.java | 9 +- .../http/servlet/internal/util/Params.java | 7 +- .../http/servlet/internal/util/Path.java | 9 +- .../internal/util/ServiceProperties.java | 20 +- .../internal/util/ServiceReferenceMap.java | 3 +- .../servlet/internal/util/StringPlus.java | 17 +- .../internal/util/UMDictionaryMap.java | 2 +- .../internal/util/UMMapDictionary.java | 5 +- .../session/HttpSessionInvalidator.java | 20 +- 64 files changed, 1303 insertions(+), 1667 deletions(-) diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java index 98a285efb5d..a9a7105ea58 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java @@ -28,45 +28,48 @@ public interface ExtendedHttpService extends HttpService { /** - * @param alias name in the URI namespace at which the filter is registered - * @param filter the filter object to register + * @param alias name in the URI namespace at which the filter is registered + * @param filter the filter object to register * @param initparams initialization arguments for the filter or - * null if there are none. This argument is used by the - * filter's FilterConfig object. - * @param context the HttpContext object for the registered - * filter, or null if a default HttpContext is - * to be created and used. - * @throws javax.servlet.ServletException if the filter's init - * method throws an exception, or the given filter object has - * already been registered at a different alias. + * null if there are none. This argument is used + * by the filter's FilterConfig object. + * @param context the HttpContext object for the registered + * filter, or null if a default + * HttpContext is to be created and used. + * @throws javax.servlet.ServletException if the filter's init + * method throws an exception, or the + * given filter object has already + * been registered at a different + * alias. * @throws java.lang.IllegalArgumentException if any of the arguments are - * invalid + * invalid */ - public void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext context) throws ServletException, NamespaceException; + public void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext context) + throws ServletException, NamespaceException; /** * Unregisters a previous filter registration done by the * registerFilter methods. * *

- * After this call, the registered filter will no - * longer be available. The Http Service must call the destroy - * method of the filter before returning. + * After this call, the registered filter will no longer be available. The Http + * Service must call the destroy method of the filter before + * returning. *

* If the bundle which performed the registration is stopped or otherwise - * "unget"s the Http Service without calling {@link #unregisterFilter} then the Http - * Service must automatically unregister the filter registration. However, the - * destroy method of the filter will not be called in this case since - * the bundle may be stopped. - * {@link #unregisterFilter} must be explicitly called to cause the - * destroy method of the filter to be called. This can be done - * in the BundleActivator.stop method of the + * "unget"s the Http Service without calling {@link #unregisterFilter} then the + * Http Service must automatically unregister the filter registration. However, + * the destroy method of the filter will not be called in this case + * since the bundle may be stopped. {@link #unregisterFilter} must be explicitly + * called to cause the destroy method of the filter to be called. + * This can be done in the BundleActivator.stop method of the * bundle registering the filter. * * @param filter the filter object to unregister - * @throws java.lang.IllegalArgumentException if there is no registration - * for the filter or the calling bundle was not the bundle which - * registered the filter. + * @throws java.lang.IllegalArgumentException if there is no registration for + * the filter or the calling bundle + * was not the bundle which + * registered the filter. */ public void unregisterFilter(Filter filter); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java index 9ccce24ce0a..12529e4b7c8 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java @@ -18,10 +18,12 @@ import org.eclipse.equinox.http.servlet.internal.servlet.ProxyServlet; /** - * The HttpServiceServlet is the "public" side of a Servlet that when registered (and init() called) in a servlet container - * will in-turn register and provide an OSGi Http Service implementation. - * This class is not meant for extending or even using directly and is purely meant for registering - * in a servlet container. + * The HttpServiceServlet is the "public" side of a Servlet that when registered + * (and init() called) in a servlet container will in-turn register and provide + * an OSGi Http Service implementation. This class is not meant for extending or + * even using directly and is purely meant for registering in a servlet + * container. + * * @noextend This class is not intended to be subclassed by clients. */ public class HttpServiceServlet extends ProxyServlet { diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/RangeAwareServletContextHelper.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/RangeAwareServletContextHelper.java index 726f87addd7..939e7865790 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/RangeAwareServletContextHelper.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/RangeAwareServletContextHelper.java @@ -19,8 +19,9 @@ import org.osgi.service.http.context.ServletContextHelper; /** - * A custom servlet context helper type providing support for predicting the need - * for ranged content responses based on the content type and the user agent. + * A custom servlet context helper type providing support for predicting the + * need for ranged content responses based on the content type and the user + * agent. * * @since 1.5 */ @@ -43,7 +44,7 @@ public RangeAwareServletContextHelper(Bundle bundle) { * for a known ranged content type. * * @param contentType the content type of the request - * @param userAgent the value obtained from the "User-Agent" header + * @param userAgent the value obtained from the "User-Agent" header */ public boolean rangeableContentType(String contentType, String userAgent) { return false; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/context/ContextPathCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/context/ContextPathCustomizer.java index 064cfe21a3f..719485a95ce 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/context/ContextPathCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/context/ContextPathCustomizer.java @@ -20,47 +20,53 @@ /** * A customizer that is called by the Http Whiteboard runtime in order to allow - * customization of context path used for servlets, resources and filters. - * There are two types of customizations that are allowed. + * customization of context path used for servlets, resources and filters. There + * are two types of customizations that are allowed. *

    - *
  1. Control the default selection filter used when no "osgi.http.whiteboard.context.select" - * is specified.
  2. - *
  3. Provide a prefix to the context path "osgi.http.whiteboard.context.path" - * specified by ServletContextHelper registrations.
  4. + *
  5. Control the default selection filter used when no + * "osgi.http.whiteboard.context.select" is specified.
  6. + *
  7. Provide a prefix to the context path + * "osgi.http.whiteboard.context.path" specified by + * ServletContextHelper registrations.
  8. *
*

- * Registering a customizer results in re-initializing all existing ServletContextHelper registrations. - * This should not be done often. Only the highest ranked customizer is used the runtime. + * Registering a customizer results in re-initializing all existing + * ServletContextHelper registrations. This should not be done often. Only the + * highest ranked customizer is used the runtime. *

*

- * Note: This class is part of an interim SPI that is still under - * development and expected to change significantly before reaching stability. - * It is being made available at this early stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this SPI will almost certainly - * be broken (repeatedly) as the SPI evolves. + * Note: This class is part of an interim SPI that is still under + * development and expected to change significantly before reaching stability. + * It is being made available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this SPI + * will almost certainly be broken (repeatedly) as the SPI evolves. *

+ * * @since 1.2 */ public abstract class ContextPathCustomizer { /** - * Returns a service filter that is used to select the default ServletContextHelper when no - * selection filter is specified by the whiteboard service. This method is only - * called if the supplied whiteboard service does not provide the - * "osgi.http.whiteboard.context.select" service property. + * Returns a service filter that is used to select the default + * ServletContextHelper when no selection filter is specified by the whiteboard + * service. This method is only called if the supplied whiteboard service does + * not provide the "osgi.http.whiteboard.context.select" service + * property. + * * @param httpWhiteBoardService - * @return a service filter that is used to select the default SErvletContextHelper for the - * specified whiteboard service. + * @return a service filter that is used to select the default + * SErvletContextHelper for the specified whiteboard service. */ public String getDefaultContextSelectFilter(ServiceReference httpWhiteBoardService) { return null; } /** - * Returns a prefix that is prepended to the context path value - * specified by the supplied helper's "osgi.http.whiteboard.context.path" - * service property. + * Returns a prefix that is prepended to the context path value specified by the + * supplied helper's "osgi.http.whiteboard.context.path" service + * property. + * * @param helper the helper for which the context path will be prepended to - * @return the prefix to prepend to the context path + * @return the prefix to prepend to the context path */ public String getContextPathPrefix(ServiceReference helper) { return null; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java index b53cb174cd1..e07a33a0c9e 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedFailedServletDTO.java @@ -17,8 +17,8 @@ import org.osgi.service.http.runtime.dto.FailedServletDTO; /** - * This type may become irrelevant if the properties appear as part of a - * future OSGi Http Whiteboard specification. + * This type may become irrelevant if the properties appear as part of a future + * OSGi Http Whiteboard specification. */ @Deprecated public class ExtendedFailedServletDTO extends FailedServletDTO { diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java index 3e9ace5b30f..38a4e7c717e 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/dto/ExtendedServletDTO.java @@ -17,8 +17,8 @@ import org.osgi.service.http.runtime.dto.ServletDTO; /** - * This type may become irrelevant if the properties appear as part of a - * future OSGi Http Whiteboard specification. + * This type may become irrelevant if the properties appear as part of a future + * OSGi Http Whiteboard specification. */ @Deprecated public class ExtendedServletDTO extends ServletDTO { diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java index 041b0d049b0..e02eda056fb 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java @@ -32,8 +32,7 @@ import org.osgi.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; -public class Activator - implements BundleActivator, ServiceTrackerCustomizer { +public class Activator implements BundleActivator, ServiceTrackerCustomizer { /** * @@ -43,32 +42,26 @@ public class Activator private static final String DEFAULT_SERVICE_VENDOR = "Eclipse.org"; //$NON-NLS-1$ private static final String PROP_GLOBAL_WHITEBOARD = "equinox.http.global.whiteboard"; //$NON-NLS-1$ public static final String UNIQUE_SERVICE_ID = "equinox.http.id"; //$NON-NLS-1$ - private static final String[] HTTP_SERVICES_CLASSES = new String[] { - HttpService.class.getName(), ExtendedHttpService.class.getName() - }; + private static final String[] HTTP_SERVICES_CLASSES = new String[] { HttpService.class.getName(), + ExtendedHttpService.class.getName() }; private static volatile BundleContext context; - private static ConcurrentMap registrations = - new ConcurrentHashMap<>(); + private static ConcurrentMap registrations = new ConcurrentHashMap<>(); private ServiceTracker serviceTracker; public static void addProxyServlet(ProxyServlet proxyServlet) { - Object previousRegistration = registrations.putIfAbsent( - proxyServlet, proxyServlet); + Object previousRegistration = registrations.putIfAbsent(proxyServlet, proxyServlet); BundleContext currentContext = context; try { - if (!(previousRegistration instanceof ServiceRegistration) && - (currentContext != null)) { - ServiceRegistration serviceRegistration = - currentContext.registerService( - HttpServlet.class, proxyServlet, - new Hashtable()); + if (!(previousRegistration instanceof ServiceRegistration) && (currentContext != null)) { + ServiceRegistration serviceRegistration = currentContext.registerService(HttpServlet.class, + proxyServlet, new Hashtable()); registrations.put(proxyServlet, serviceRegistration); } } catch (IllegalStateException ex) { - //If the currentContext is no longer valid. + // If the currentContext is no longer valid. return; } } @@ -77,8 +70,7 @@ public static void unregisterHttpService(ProxyServlet proxyServlet) { Object registration = registrations.remove(proxyServlet); if (registration instanceof ServiceRegistration) { - ServiceRegistration serviceRegistration = - (ServiceRegistration)registration; + ServiceRegistration serviceRegistration = (ServiceRegistration) registration; serviceRegistration.unregister(); } @@ -89,8 +81,7 @@ public void start(BundleContext bundleContext) throws Exception { processRegistrations(); - serviceTracker = new ServiceTracker<>( - bundleContext, HttpServlet.class, this); + serviceTracker = new ServiceTracker<>(bundleContext, HttpServlet.class, this); serviceTracker.open(); } @@ -101,8 +92,7 @@ public void stop(BundleContext bundleContext) throws Exception { context = null; } - public HttpTuple addingService( - ServiceReference serviceReference) { + public HttpTuple addingService(ServiceReference serviceReference) { BundleContext currentContext = context; if (currentContext == null) { return null; @@ -116,60 +106,51 @@ public HttpTuple addingService( return null; } - ProxyServlet proxyServlet = (ProxyServlet)httpServlet; + ProxyServlet proxyServlet = (ProxyServlet) httpServlet; ServletConfig servletConfig = proxyServlet.getServletConfig(); ServletContext servletContext = servletConfig.getServletContext(); - Dictionary serviceProperties = - new Hashtable<>(3); + Dictionary serviceProperties = new Hashtable<>(3); - Enumeration initparameterNames = - servletConfig.getInitParameterNames(); + Enumeration initparameterNames = servletConfig.getInitParameterNames(); while (initparameterNames.hasMoreElements()) { String name = initparameterNames.nextElement(); - serviceProperties.put( - name, servletConfig.getInitParameter(name)); + serviceProperties.put(name, servletConfig.getInitParameter(name)); } if (serviceProperties.get(Constants.SERVICE_VENDOR) == null) { - serviceProperties.put( - Constants.SERVICE_VENDOR, DEFAULT_SERVICE_VENDOR); + serviceProperties.put(Constants.SERVICE_VENDOR, DEFAULT_SERVICE_VENDOR); } if (serviceProperties.get(Constants.SERVICE_DESCRIPTION) == null) { - serviceProperties.put( - Constants.SERVICE_DESCRIPTION, DEFAULT_SERVICE_DESCRIPTION); + serviceProperties.put(Constants.SERVICE_DESCRIPTION, DEFAULT_SERVICE_DESCRIPTION); } Object httpServiceEndpointObj = serviceProperties.get(HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT); if (httpServiceEndpointObj == null) { - String[] httpServiceEndpoints = getHttpServiceEndpoints( - serviceProperties, servletContext, servletConfig.getServletName()); + String[] httpServiceEndpoints = getHttpServiceEndpoints(serviceProperties, servletContext, + servletConfig.getServletName()); - serviceProperties.put( - HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT, - httpServiceEndpoints); - } - else { + serviceProperties.put(HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT, httpServiceEndpoints); + } else { List httpServiceEndpoints = new ArrayList<>(); String contextPath = servletContext.getContextPath(); for (String httpServiceEndpoint : StringPlus.from(httpServiceEndpointObj)) { - if (!httpServiceEndpoint.startsWith(Const.HTTP.concat(":")) && !httpServiceEndpoint.startsWith(contextPath)) { //$NON-NLS-1$ + if (!httpServiceEndpoint.startsWith(Const.HTTP.concat(":")) //$NON-NLS-1$ + && !httpServiceEndpoint.startsWith(contextPath)) { httpServiceEndpoint = contextPath + httpServiceEndpoint; } httpServiceEndpoints.add(httpServiceEndpoint); } - serviceProperties.put( - HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT, - httpServiceEndpoints); + serviceProperties.put(HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT, httpServiceEndpoints); } // need a unique id for our service to match old HttpService HttpContext @@ -177,9 +158,11 @@ public HttpTuple addingService( // white board support // determine if the system bundle context should be used: boolean useSystemContext = Boolean.valueOf(currentContext.getProperty(PROP_GLOBAL_WHITEBOARD)); - BundleContext trackingContext = useSystemContext ? currentContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext() : currentContext; - HttpServiceRuntimeImpl httpServiceRuntime = new HttpServiceRuntimeImpl( - trackingContext, currentContext, servletContext, serviceProperties); + BundleContext trackingContext = useSystemContext + ? currentContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext() + : currentContext; + HttpServiceRuntimeImpl httpServiceRuntime = new HttpServiceRuntimeImpl(trackingContext, currentContext, + servletContext, serviceProperties); httpServiceRuntime.open(); proxyServlet.setHttpServiceRuntimeImpl(httpServiceRuntime); @@ -187,79 +170,73 @@ public HttpTuple addingService( // imperative API support; // the http service must be registered first so we can get its service id HttpServiceFactory httpServiceFactory = new HttpServiceFactory(httpServiceRuntime); - ServiceRegistration hsfRegistration = currentContext.registerService( - HTTP_SERVICES_CLASSES, httpServiceFactory, serviceProperties); + ServiceRegistration hsfRegistration = currentContext.registerService(HTTP_SERVICES_CLASSES, + httpServiceFactory, serviceProperties); - serviceProperties.put(HttpServiceRuntimeConstants.HTTP_SERVICE_ID, Collections.singletonList(hsfRegistration.getReference().getProperty(Constants.SERVICE_ID))); + serviceProperties.put(HttpServiceRuntimeConstants.HTTP_SERVICE_ID, + Collections.singletonList(hsfRegistration.getReference().getProperty(Constants.SERVICE_ID))); - ServiceRegistration hsrRegistration = - currentContext.registerService( - HttpServiceRuntime.class, httpServiceRuntime, - serviceProperties); + ServiceRegistration hsrRegistration = currentContext + .registerService(HttpServiceRuntime.class, httpServiceRuntime, serviceProperties); httpServiceRuntime.setHsrRegistration(hsrRegistration); - return new HttpTuple( - proxyServlet, httpServiceFactory, hsfRegistration, - httpServiceRuntime, hsrRegistration); + return new HttpTuple(proxyServlet, httpServiceFactory, hsfRegistration, httpServiceRuntime, + hsrRegistration); } catch (IllegalStateException ex) { - //If the currentContext is no longer valid. + // If the currentContext is no longer valid. return null; } } - public void modifiedService( - ServiceReference serviceReference, HttpTuple httpTuple) { + public void modifiedService(ServiceReference serviceReference, HttpTuple httpTuple) { removedService(serviceReference, httpTuple); addingService(serviceReference); } - public void removedService( - ServiceReference serviceReference, HttpTuple httpTuple) { + public void removedService(ServiceReference serviceReference, HttpTuple httpTuple) { BundleContext currentContext = context; if (currentContext != null) { try { currentContext.ungetService(serviceReference); httpTuple.destroy(); } catch (IllegalStateException ex) { - //If the currentContext is no longer valid. + // If the currentContext is no longer valid. return; } } } - private String[] getHttpServiceEndpoints( - Dictionary serviceProperties, ServletContext servletContext, String servletName) { + private String[] getHttpServiceEndpoints(Dictionary serviceProperties, + ServletContext servletContext, String servletName) { List httpServiceEndpoints = new ArrayList<>(); - String contextPath = (String)serviceProperties.get(Const.CONTEXT_PATH); + String contextPath = (String) serviceProperties.get(Const.CONTEXT_PATH); if ((contextPath != null)) { - String httpHost = (String)serviceProperties.get(Const.HTTP_HOST); - String httpPort = (String)serviceProperties.get(Const.HTTP_PORT); + String httpHost = (String) serviceProperties.get(Const.HTTP_HOST); + String httpPort = (String) serviceProperties.get(Const.HTTP_PORT); if (httpPort != null) { if (httpHost == null) { String endpoint = assembleEndpoint(Const.HTTP, Const.LOCALHOST, httpPort, contextPath); httpServiceEndpoints.add(endpoint); - } - else { + } else { String endpoint = assembleEndpoint(Const.HTTP, httpHost, httpPort, contextPath); httpServiceEndpoints.add(endpoint); } } - String httpsHost = (String)serviceProperties.get(Const.HTTPS_HOST); - String httpsPort = (String)serviceProperties.get(Const.HTTPS_PORT); + String httpsHost = (String) serviceProperties.get(Const.HTTPS_HOST); + String httpsPort = (String) serviceProperties.get(Const.HTTPS_PORT); if (httpsPort != null) { if (httpsHost == null) { String endpoint = assembleEndpoint(Const.HTTPS, Const.LOCALHOST, httpsPort, contextPath); httpServiceEndpoints.add(endpoint); - } - else { + } else { String endpoint = assembleEndpoint(Const.HTTPS, httpHost, httpsPort, contextPath); httpServiceEndpoints.add(endpoint); } @@ -296,8 +273,7 @@ private String[] getHttpServiceEndpoints( if (mapping.charAt(mapping.length() - 1) == '*') { mapping = mapping.substring(0, mapping.length() - 1); - if ((mapping.length() > 1) && - (mapping.charAt(mapping.length() - 1) != '/')) { + if ((mapping.length() > 1) && (mapping.charAt(mapping.length() - 1) != '/')) { mapping += '/'; } @@ -336,15 +312,13 @@ private void processRegistrations() { try { if (!(value instanceof ServiceRegistration)) { - ServiceRegistration serviceRegistration = - currentContext.registerService( - HttpServlet.class, proxyServlet, - new Hashtable()); + ServiceRegistration serviceRegistration = currentContext + .registerService(HttpServlet.class, proxyServlet, new Hashtable()); entry.setValue(serviceRegistration); } } catch (IllegalStateException ex) { - //If the currentContext is no longer valid. + // If the currentContext is no longer valid. return; } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java index 06f4bda5845..32bddd37ce0 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelper.java @@ -23,6 +23,7 @@ public class DefaultServletContextHelper extends ServletContextHelper implements HttpContext { private final Bundle bundle; + public DefaultServletContextHelper(Bundle bundle) { super(bundle); this.bundle = bundle; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java index d4527589325..e62e222661f 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultServletContextHelperFactory.java @@ -20,17 +20,13 @@ public class DefaultServletContextHelperFactory implements ServiceFactory { @Override - public ServletContextHelper getService( - Bundle bundle, - ServiceRegistration registration) { + public ServletContextHelper getService(Bundle bundle, ServiceRegistration registration) { return new DefaultServletContextHelper(bundle); } @Override - public void ungetService( - Bundle bundle, - ServiceRegistration registration, - ServletContextHelper service) { + public void ungetService(Bundle bundle, ServiceRegistration registration, + ServletContextHelper service) { // do nothing } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java index 01676407f19..13afc3336e2 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java @@ -30,17 +30,15 @@ public HttpServiceFactory(HttpServiceRuntimeImpl httpServiceRuntime) { this.httpServiceRuntime = httpServiceRuntime; } - public HttpService getService( - Bundle bundle, ServiceRegistration serviceRegistration) { + public HttpService getService(Bundle bundle, ServiceRegistration serviceRegistration) { return new HttpServiceImpl(bundle, httpServiceRuntime); } - public void ungetService( - Bundle bundle, ServiceRegistration serviceRegistration, - HttpService httpService) { + public void ungetService(Bundle bundle, ServiceRegistration serviceRegistration, + HttpService httpService) { - HttpServiceImpl httpServiceImpl = (HttpServiceImpl)httpService; + HttpServiceImpl httpServiceImpl = (HttpServiceImpl) httpService; httpServiceImpl.shutdown(); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java index a97c8743f1f..c08c46a6161 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java @@ -37,12 +37,12 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService { private static AtomicLong legacyIdGenerator = new AtomicLong(0); - final Bundle bundle; //The bundle associated with this instance of http service + final Bundle bundle; // The bundle associated with this instance of http service final HttpServiceRuntimeImpl httpServiceRuntime; - private volatile boolean shutdown = false; // We prevent use of this instance if HttpServiceFactory.ungetService has called unregisterAliases. + private volatile boolean shutdown = false; // We prevent use of this instance if HttpServiceFactory.ungetService has + // called unregisterAliases. - public HttpServiceImpl( - Bundle bundle, HttpServiceRuntimeImpl httpServiceRuntime) { + public HttpServiceImpl(Bundle bundle, HttpServiceRuntimeImpl httpServiceRuntime) { this.bundle = bundle; this.httpServiceRuntime = httpServiceRuntime; @@ -59,25 +59,22 @@ public synchronized HttpContext createDefaultHttpContext() { /** * @throws ServletException - * @see ExtendedHttpService#registerFilter(String, Filter, Dictionary, HttpContext) + * @see ExtendedHttpService#registerFilter(String, Filter, Dictionary, + * HttpContext) */ @Override - public synchronized void registerFilter( - final String alias, final Filter filter, - final Dictionary initparams, - HttpContext httpContext) - throws ServletException { + public synchronized void registerFilter(final String alias, final Filter filter, + final Dictionary initparams, HttpContext httpContext) throws ServletException { checkShutdown(); - + final HttpContextHolder httpContextHolder = getHttpContextHolder(httpContext); try { AccessController.doPrivileged((PrivilegedExceptionAction) () -> { httpServiceRuntime.registerHttpServiceFilter(bundle, alias, filter, initparams, httpContextHolder); return null; }); - } - catch (PrivilegedActionException e) { + } catch (PrivilegedActionException e) { Throw.unchecked(e.getException()); } @@ -95,9 +92,8 @@ private HttpContextHolder getHttpContextHolder(HttpContext httpContext) { * @throws NamespaceException * @see HttpService#registerResources(String, String, HttpContext) */ - public synchronized void registerResources( - final String alias, final String name, HttpContext httpContext) - throws NamespaceException { + public synchronized void registerResources(final String alias, final String name, HttpContext httpContext) + throws NamespaceException { checkShutdown(); final HttpContextHolder httpContextHolder = getHttpContextHolder(httpContext); @@ -117,10 +113,8 @@ public synchronized void registerResources( * @throws NamespaceException * @see HttpService#registerServlet(String, Servlet, Dictionary, HttpContext) */ - public synchronized void registerServlet( - final String alias, final Servlet servlet, - final Dictionary initparams, HttpContext httpContext) - throws ServletException, NamespaceException { + public synchronized void registerServlet(final String alias, final Servlet servlet, + final Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException { checkShutdown(); final HttpContextHolder httpContextHolder = getHttpContextHolder(httpContext); @@ -128,7 +122,8 @@ public synchronized void registerServlet( AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override public Void run() throws NamespaceException, ServletException { - httpServiceRuntime.registerHttpServiceServlet(bundle, alias, servlet, initparams, httpContextHolder); + httpServiceRuntime.registerHttpServiceServlet(bundle, alias, servlet, initparams, + httpContextHolder); return null; } }); @@ -156,7 +151,7 @@ public synchronized void unregisterFilter(Filter filter) { httpServiceRuntime.unregisterHttpServiceFilter(bundle, filter); } - //Clean up method + // Clean up method synchronized void shutdown() { httpServiceRuntime.unregisterHttpServiceObjects(bundle); @@ -165,8 +160,7 @@ synchronized void shutdown() { private void checkShutdown() { if (shutdown) { - throw new IllegalStateException( - "Service instance is already shutdown"); //$NON-NLS-1$ + throw new IllegalStateException("Service instance is already shutdown"); //$NON-NLS-1$ } } @@ -178,7 +172,8 @@ private HttpContext registerContext(HttpContext httpContext) { HttpContextHolder httpContextHolder = httpServiceRuntime.legacyContextMap.get(httpContext); if (httpContextHolder == null) { - String legacyId= httpContext.getClass().getName().replaceAll("[^a-zA-Z_0-9\\-]", "_") + "-" + generateLegacyId(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String legacyId = httpContext.getClass().getName().replaceAll("[^a-zA-Z_0-9\\-]", "_") + "-" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + generateLegacyId(); Dictionary props = new Hashtable<>(); props.put(HTTP_WHITEBOARD_CONTEXT_NAME, legacyId); props.put(HTTP_WHITEBOARD_CONTEXT_PATH, "/"); //$NON-NLS-1$ @@ -188,7 +183,9 @@ private HttpContext registerContext(HttpContext httpContext) { props.put(Const.EQUINOX_LEGACY_HTTP_CONTEXT_INITIATING_ID, bundle.getBundleId()); @SuppressWarnings("unchecked") - ServiceRegistration registration = (ServiceRegistration)bundle.getBundleContext().registerService(ServletContextHelper.class.getName(), new WrappedHttpContext(httpContext, bundle), props); + ServiceRegistration registration = (ServiceRegistration) bundle + .getBundleContext().registerService(ServletContextHelper.class.getName(), + new WrappedHttpContext(httpContext, bundle), props); httpContextHolder = new HttpContextHolder(httpContext, registration); httpContextHolder.incrementUseCount(); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceObjectRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceObjectRegistration.java index 7a56eadb6d9..97ef18f6a5b 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceObjectRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceObjectRegistration.java @@ -24,9 +24,9 @@ public class HttpServiceObjectRegistration { public final ServiceRegistration registration; public final HttpContextHolder httpContextHolder; public final Bundle bundle; - public HttpServiceObjectRegistration( - Object serviceKey, ServiceRegistration registration, - HttpContextHolder httpContextHolder, Bundle bundle) { + + public HttpServiceObjectRegistration(Object serviceKey, ServiceRegistration registration, + HttpContextHolder httpContextHolder, Bundle bundle) { this.serviceKey = serviceKey; this.registration = registration; this.httpContextHolder = httpContextHolder; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java index 57cf8dcd511..3ee3ea8078f 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java @@ -55,14 +55,11 @@ /** * @author Raymond Augé */ -public class HttpServiceRuntimeImpl - implements - HttpServiceRuntime, +public class HttpServiceRuntimeImpl implements HttpServiceRuntime, ServiceTrackerCustomizer> { - public HttpServiceRuntimeImpl( - BundleContext trackingContext, BundleContext consumingContext, - ServletContext parentServletContext, Dictionary attributes) { + public HttpServiceRuntimeImpl(BundleContext trackingContext, BundleContext consumingContext, + ServletContext parentServletContext, Dictionary attributes) { this.trackingContext = trackingContext; this.consumingContext = consumingContext; @@ -75,37 +72,39 @@ public HttpServiceRuntimeImpl( this.parentServletContext = parentServletContext; this.attributes = new UMDictionaryMap<>(attributes); - this.targetFilter = "(" + Activator.UNIQUE_SERVICE_ID + "=" + this.attributes.get(Activator.UNIQUE_SERVICE_ID) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + this.targetFilter = "(" + Activator.UNIQUE_SERVICE_ID + "=" + this.attributes.get(Activator.UNIQUE_SERVICE_ID) //$NON-NLS-1$ //$NON-NLS-2$ + + ")"; //$NON-NLS-1$ this.httpSessionTracker = new HttpSessionTracker(this); - this.invalidatorReg = trackingContext.registerService(HttpSessionInvalidator.class, this.httpSessionTracker, attributes); + this.invalidatorReg = trackingContext.registerService(HttpSessionInvalidator.class, this.httpSessionTracker, + attributes); + + loggerFactoryTracker = new ServiceTracker<>(consumingContext, LoggerFactory.class, + new ServiceTrackerCustomizer() { + @Override + public Logger addingService(ServiceReference reference) { + return getConsumingContext().getService(reference).getLogger(HttpServiceRuntimeImpl.class); + } - loggerFactoryTracker = new ServiceTracker<>(consumingContext, LoggerFactory.class, new ServiceTrackerCustomizer() { - @Override - public Logger addingService(ServiceReference reference) { - return getConsumingContext().getService(reference).getLogger(HttpServiceRuntimeImpl.class); - } - @Override - public void modifiedService(ServiceReference reference, Logger service) { - // ignore - } - @Override - public void removedService(ServiceReference reference, Logger service) { - // ignore - } - }); + @Override + public void modifiedService(ServiceReference reference, Logger service) { + // ignore + } + + @Override + public void removedService(ServiceReference reference, Logger service) { + // ignore + } + }); loggerFactoryTracker.open(); - contextServiceTracker = - new ServiceTracker<>( - trackingContext, ServletContextHelper.class, this); + contextServiceTracker = new ServiceTracker<>(trackingContext, ServletContextHelper.class, this); - preprocessorServiceTracker = - new ServiceTracker<>( - trackingContext, Preprocessor.class, new PreprocessorCustomizer(this)); + preprocessorServiceTracker = new ServiceTracker<>(trackingContext, Preprocessor.class, + new PreprocessorCustomizer(this)); contextPathCustomizerHolder = new ContextPathCustomizerHolder(consumingContext, contextServiceTracker); - contextPathAdaptorTracker = new ServiceTracker<>( - consumingContext, ContextPathCustomizer.class, contextPathCustomizerHolder); + contextPathAdaptorTracker = new ServiceTracker<>(consumingContext, ContextPathCustomizer.class, + contextPathCustomizerHolder); Hashtable defaultContextProps = new Hashtable<>(); defaultContextProps.put(HTTP_WHITEBOARD_CONTEXT_NAME, HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME); @@ -113,8 +112,8 @@ public void removedService(ServiceReference reference, Logger ser defaultContextProps.put(HTTP_WHITEBOARD_CONTEXT_PATH, Const.SLASH); defaultContextProps.put(HTTP_WHITEBOARD_TARGET, this.targetFilter); defaultContextProps.put(Const.EQUINOX_HTTP_WHITEBOARD_CONTEXT_HELPER_DEFAULT, Boolean.TRUE); - defaultContextReg = consumingContext.registerService( - ServletContextHelper.class, new DefaultServletContextHelperFactory(), defaultContextProps); + defaultContextReg = consumingContext.registerService(ServletContextHelper.class, + new DefaultServletContextHelperFactory(), defaultContextProps); } public synchronized void open() { @@ -125,7 +124,7 @@ public synchronized void open() { @Override public synchronized AtomicReference addingService( - ServiceReference serviceReference) { + ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!matches(serviceReference)) { @@ -133,24 +132,21 @@ public synchronized AtomicReference addingService( } try { - ContextController contextController = new ContextController( - trackingContext, consumingContext, serviceReference, parentServletContext, this); + ContextController contextController = new ContextController(trackingContext, consumingContext, + serviceReference, parentServletContext, this); controllerMap.put(serviceReference, contextController); result.set(contextController); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { debug(hwfe.getMessage(), hwfe); recordFailedServletContextDTO(serviceReference, 0, hwfe.getFailureReason()); - } - catch (Throwable t) { + } catch (Throwable t) { error(t.getMessage(), t); recordFailedServletContextDTO(serviceReference, 0, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { incrementServiceChangecount(); } @@ -190,8 +186,10 @@ public String getDefaultContextSelectFilter(ServiceReference httpWhiteBoardSe public boolean isDefaultContext(ContextController contextController) { ServiceReference thisReference = defaultContextReg.getReference(); ServiceReference contextReference = contextController.getServiceReference(); - if (thisReference == null) throw new NullPointerException("Default Context Service reference is null. " + this); //$NON-NLS-1$ - if (contextReference == null) throw new NullPointerException("Context Service reference is null. " + contextController); //$NON-NLS-1$ + if (thisReference == null) + throw new NullPointerException("Default Context Service reference is null. " + this); //$NON-NLS-1$ + if (contextReference == null) + throw new NullPointerException("Context Service reference is null. " + contextController); //$NON-NLS-1$ return thisReference.equals(contextReference); } @@ -215,8 +213,7 @@ public synchronized RequestInfoDTO calculateRequestInfoDTO(String path) { try { getDispatchTargets(path, requestInfoDTO); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } @@ -228,8 +225,7 @@ public synchronized void destroy() { try { defaultContextReg.unregister(); - } - catch (IllegalStateException ise) { + } catch (IllegalStateException ise) { // ignore } @@ -256,8 +252,7 @@ public synchronized void destroy() { loggerFactoryTracker.close(); } - public DispatchTargets getDispatchTargets( - String pathString, RequestInfoDTO requestInfoDTO) { + public DispatchTargets getDispatchTargets(String pathString, RequestInfoDTO requestInfoDTO) { Path path = new Path(pathString); @@ -265,37 +260,33 @@ public DispatchTargets getDispatchTargets( String requestURI = path.getRequestURI(); // perfect match - DispatchTargets dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.EXACT, requestInfoDTO); + DispatchTargets dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.EXACT, + requestInfoDTO); if (dispatchTargets == null) { // extension match - dispatchTargets = getDispatchTargets( - requestURI, path.getExtension(), queryString, Match.EXTENSION, - requestInfoDTO); + dispatchTargets = getDispatchTargets(requestURI, path.getExtension(), queryString, Match.EXTENSION, + requestInfoDTO); } if (dispatchTargets == null) { // regex match - dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.REGEX, requestInfoDTO); + dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.REGEX, requestInfoDTO); } if (dispatchTargets == null) { // handle with servlet mapped to '/' - // the servletpath is the requestURI minus the contextpath and the pathinfo is null - dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.DEFAULT_SERVLET, - requestInfoDTO); + // the servletpath is the requestURI minus the contextpath and the pathinfo is + // null + dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.DEFAULT_SERVLET, requestInfoDTO); } if (dispatchTargets == null && Const.SLASH.equals(pathString)) { // handle with servlet mapped to '' (empty string) - // the pathinfo is '/' and the servletpath and contextpath are the empty string ("") - dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.CONTEXT_ROOT, - requestInfoDTO); + // the pathinfo is '/' and the servletpath and contextpath are the empty string + // ("") + dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.CONTEXT_ROOT, requestInfoDTO); } return dispatchTargets; @@ -318,8 +309,7 @@ public ServletContext getParentServletContext() { } public List getHttpServiceEndpoints() { - return StringPlus.from( - attributes.get(HTTP_SERVICE_ENDPOINT)); + return StringPlus.from(attributes.get(HTTP_SERVICE_ENDPOINT)); } @Override @@ -369,8 +359,7 @@ public void debug(String message) { Logger logger = loggerFactoryTracker.getService(); if (logger == null) { parentServletContext.log(String.valueOf(message)); - } - else { + } else { logger.debug(String.valueOf(message)); } } @@ -379,8 +368,7 @@ public void debug(String message, Throwable t) { Logger logger = loggerFactoryTracker.getService(); if (logger == null) { parentServletContext.log(String.valueOf(message), t); - } - else { + } else { logger.debug(String.valueOf(message), t); } } @@ -389,14 +377,13 @@ public void error(String message, Throwable t) { Logger logger = loggerFactoryTracker.getService(); if (logger == null) { parentServletContext.log(String.valueOf(message), t); - } - else { + } else { logger.error(String.valueOf(message), t); } } public boolean matches(ServiceReference serviceReference) { - String target = (String)serviceReference.getProperty(HTTP_WHITEBOARD_TARGET); + String target = (String) serviceReference.getProperty(HTTP_WHITEBOARD_TARGET); if (target == null) { return true; @@ -406,8 +393,7 @@ public boolean matches(ServiceReference serviceReference) { try { whiteboardTargetFilter = FrameworkUtil.createFilter(target); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } @@ -428,9 +414,8 @@ public boolean matchesAnyContext(ServiceReference serviceReference) { } @Override - public synchronized void modifiedService( - ServiceReference serviceReference, - AtomicReference contextController) { + public synchronized void modifiedService(ServiceReference serviceReference, + AtomicReference contextController) { removedService(serviceReference, contextController); AtomicReference added = addingService(serviceReference); @@ -438,14 +423,14 @@ public synchronized void modifiedService( } @Override - public synchronized void removedService( - ServiceReference serviceReference, - AtomicReference contextControllerRef) { + public synchronized void removedService(ServiceReference serviceReference, + AtomicReference contextControllerRef) { try { ContextController contextController = contextControllerRef.get(); if (contextController != null) { - Iterator, ExtendedFailedServletContextDTO>> iterator = failedServletContextDTOs.entrySet().iterator(); + Iterator, ExtendedFailedServletContextDTO>> iterator = failedServletContextDTOs + .entrySet().iterator(); while (iterator.hasNext()) { if (iterator.next().getValue().shadowingServiceId == contextController.getServiceId()) { iterator.remove(); @@ -456,8 +441,7 @@ public synchronized void removedService( failedServletContextDTOs.remove(serviceReference); controllerMap.remove(serviceReference); trackingContext.ungetService(serviceReference); - } - finally { + } finally { incrementServiceChangecount(); } } @@ -486,8 +470,7 @@ Collection getContextControllers(String requestURI) { } break; - } - while (true); + } while (true); return null; } @@ -496,19 +479,16 @@ public Collection getContextControllers() { return controllerMap.values(); } - public DispatchTargets getDispatchTargets( - String requestURI, String extension, String queryString, Match match, - RequestInfoDTO requestInfoDTO) { + public DispatchTargets getDispatchTargets(String requestURI, String extension, String queryString, Match match, + RequestInfoDTO requestInfoDTO) { - Collection contextControllers = getContextControllers( - requestURI); + Collection contextControllers = getContextControllers(requestURI); if ((contextControllers == null) || contextControllers.isEmpty()) { return null; } - String contextPath = - contextControllers.iterator().next().getContextPath(); + String contextPath = contextControllers.iterator().next().getContextPath(); requestURI = requestURI.substring(contextPath.length()); @@ -524,10 +504,8 @@ public DispatchTargets getDispatchTargets( do { for (ContextController contextController : contextControllers) { - DispatchTargets dispatchTargets = - contextController.getDispatchTargets( - null, requestURI, servletPath, pathInfo, - extension, queryString, match, requestInfoDTO); + DispatchTargets dispatchTargets = contextController.getDispatchTargets(null, requestURI, servletPath, + pathInfo, extension, queryString, match, requestInfoDTO); if (dispatchTargets != null) { return dispatchTargets; @@ -548,8 +526,7 @@ public DispatchTargets getDispatchTargets( } break; - } - while (true); + } while (true); return null; } @@ -650,8 +627,8 @@ public Map, PreprocessorRegistration> getPreproce return preprocessorMap; } - public void registerHttpServiceFilter( - Bundle bundle, String alias, Filter filter, Dictionary initparams, HttpContextHolder httpContextHolder) { + public void registerHttpServiceFilter(Bundle bundle, String alias, Filter filter, + Dictionary initparams, HttpContextHolder httpContextHolder) { if (alias == null) { throw new IllegalArgumentException("Alias cannot be null"); //$NON-NLS-1$ @@ -662,8 +639,10 @@ public void registerHttpServiceFilter( ContextController.checkPattern(alias); - // need to make sure exact matching aliases are converted to wildcard pattern matches - if (!alias.endsWith(Const.SLASH_STAR) && !alias.startsWith(Const.STAR_DOT) && !alias.contains(Const.SLASH_STAR_DOT)) { + // need to make sure exact matching aliases are converted to wildcard pattern + // matches + if (!alias.endsWith(Const.SLASH_STAR) && !alias.startsWith(Const.STAR_DOT) + && !alias.contains(Const.SLASH_STAR_DOT)) { if (alias.endsWith(Const.SLASH)) { alias = alias + '*'; } else { @@ -724,9 +703,7 @@ public void registerHttpServiceFilter( } } - private void fillInitParams( - Dictionary props, - Dictionary initparams, String prefix) { + private void fillInitParams(Dictionary props, Dictionary initparams, String prefix) { if (initparams != null) { for (Enumeration eKeys = initparams.keys(); eKeys.hasMoreElements();) { String key = String.valueOf(eKeys.nextElement()); @@ -754,18 +731,16 @@ private static int findFilterPriority(Dictionary initparams) { if (result >= -1000 && result <= 1000) { return result; } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // fall through } - throw new IllegalArgumentException( - "filter-priority must be an integer between -1000 and 1000 but " + //$NON-NLS-1$ + throw new IllegalArgumentException("filter-priority must be an integer between -1000 and 1000 but " + //$NON-NLS-1$ "was: " + filterPriority); //$NON-NLS-1$ } - public void registerHttpServiceResources( - Bundle bundle, String alias, String name, HttpContextHolder httpContextHolder) throws NamespaceException { + public void registerHttpServiceResources(Bundle bundle, String alias, String name, + HttpContextHolder httpContextHolder) throws NamespaceException { if (alias == null) { throw new IllegalArgumentException("Alias cannot be null"); //$NON-NLS-1$ } @@ -776,8 +751,10 @@ public void registerHttpServiceResources( if (pattern.startsWith(Const.SLASH_STAR_DOT)) { pattern = pattern.substring(1); } - // need to make sure exact matching aliases are converted to wildcard pattern matches - if (!pattern.endsWith(Const.SLASH_STAR) && !pattern.startsWith(Const.STAR_DOT) && !pattern.contains(Const.SLASH_STAR_DOT)) { + // need to make sure exact matching aliases are converted to wildcard pattern + // matches + if (!pattern.endsWith(Const.SLASH_STAR) && !pattern.startsWith(Const.STAR_DOT) + && !pattern.contains(Const.SLASH_STAR_DOT)) { if (pattern.endsWith(Const.SLASH)) { pattern = pattern + '*'; } else { @@ -805,7 +782,8 @@ public void registerHttpServiceResources( props.put(Const.EQUINOX_LEGACY_TCCL_PROP, Thread.currentThread().getContextClassLoader()); registration = bundle.getBundleContext().registerService(String.class, "resource", props); //$NON-NLS-1$ - objectRegistration = new HttpServiceObjectRegistration(fullAlias, registration, httpContextHolder, bundle); + objectRegistration = new HttpServiceObjectRegistration(fullAlias, registration, httpContextHolder, + bundle); Set objectRegistrations = bundleRegistrations.get(bundle); if (objectRegistrations == null) { @@ -835,12 +813,13 @@ public void registerHttpServiceResources( } private Object getFilter(ServiceReference serviceReference) { - String ctxName = (String)serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_NAME); - return String.format("(&(%s=%s)(%s=%s))", HTTP_SERVICE_CONTEXT_PROPERTY, ctxName, HTTP_WHITEBOARD_CONTEXT_NAME, ctxName); //$NON-NLS-1$ + String ctxName = (String) serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_NAME); + return String.format("(&(%s=%s)(%s=%s))", HTTP_SERVICE_CONTEXT_PROPERTY, ctxName, HTTP_WHITEBOARD_CONTEXT_NAME, //$NON-NLS-1$ + ctxName); } - public void registerHttpServiceServlet( - Bundle bundle, String alias, Servlet servlet, Dictionary initparams, HttpContextHolder httpContextHolder) throws NamespaceException, ServletException{ + public void registerHttpServiceServlet(Bundle bundle, String alias, Servlet servlet, Dictionary initparams, + HttpContextHolder httpContextHolder) throws NamespaceException, ServletException { if (alias == null) { throw new IllegalArgumentException("Alias cannot be null"); //$NON-NLS-1$ } @@ -852,12 +831,14 @@ public void registerHttpServiceServlet( ContextController.checkPattern(alias); Object pattern = alias; - // need to make sure exact matching aliases are converted to exact matching + wildcard pattern matching - if (!alias.endsWith(Const.SLASH_STAR) && !alias.startsWith(Const.STAR_DOT) && !alias.contains(Const.SLASH_STAR_DOT)) { + // need to make sure exact matching aliases are converted to exact matching + + // wildcard pattern matching + if (!alias.endsWith(Const.SLASH_STAR) && !alias.startsWith(Const.STAR_DOT) + && !alias.contains(Const.SLASH_STAR_DOT)) { if (alias.endsWith(Const.SLASH)) { - pattern = new String[] {alias, alias + '*'}; + pattern = new String[] { alias, alias + '*' }; } else { - pattern = new String[] {alias, alias + Const.SLASH_STAR}; + pattern = new String[] { alias, alias + Const.SLASH_STAR }; } } @@ -893,7 +874,8 @@ public void registerHttpServiceServlet( // check that init got called and did not throw an exception legacyServlet.checkForError(); - objectRegistration = new HttpServiceObjectRegistration(fullAlias, registration, httpContextHolder, bundle); + objectRegistration = new HttpServiceObjectRegistration(fullAlias, registration, httpContextHolder, + bundle); Set objectRegistrations = bundleRegistrations.get(bundle); if (objectRegistrations == null) { @@ -925,7 +907,8 @@ public void registerHttpServiceServlet( private String getFullAlias(String alias, HttpContextHolder httpContextHolder) { @SuppressWarnings("unchecked") - AtomicReference controllerRef = contextServiceTracker.getService((ServiceReference)httpContextHolder.getServiceReference()); + AtomicReference controllerRef = contextServiceTracker + .getService((ServiceReference) httpContextHolder.getServiceReference()); if (controllerRef != null) { ContextController controller = controllerRef.get(); if (controller != null) { @@ -947,8 +930,7 @@ public void unregisterHttpServiceAlias(Bundle bundle, String alias) { throw new IllegalArgumentException("No registration found for alias: " + alias); //$NON-NLS-1$ } Set objectRegistrations = bundleRegistrations.get(bundle); - if (objectRegistrations == null || !objectRegistrations.remove(objectRegistration)) - { + if (objectRegistrations == null || !objectRegistrations.remove(objectRegistration)) { throw new IllegalArgumentException("The bundle did not register the alias: " + alias); //$NON-NLS-1$ } @@ -970,8 +952,7 @@ public void unregisterHttpServiceFilter(Bundle bundle, Filter filter) { throw new IllegalArgumentException("No registration found for filter: " + filter); //$NON-NLS-1$ } Set objectRegistrations = bundleRegistrations.get(bundle); - if (objectRegistrations == null || !objectRegistrations.remove(objectRegistration)) - { + if (objectRegistrations == null || !objectRegistrations.remove(objectRegistration)) { throw new IllegalArgumentException("The bundle did not register the filter: " + filter); //$NON-NLS-1$ } try { @@ -1019,8 +1000,7 @@ private static org.osgi.framework.Filter createErrorPageFilter(BundleContext con try { return context.createFilter(sb.toString()); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } } @@ -1036,8 +1016,7 @@ private static org.osgi.framework.Filter createResourceFilter(BundleContext cont try { return context.createFilter(sb.toString()); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } } @@ -1055,8 +1034,7 @@ private static org.osgi.framework.Filter createServletFilter(BundleContext conte try { return context.createFilter(sb.toString()); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } } @@ -1076,13 +1054,13 @@ private static org.osgi.framework.Filter createFilterFilter(BundleContext contex try { return context.createFilter(sb.toString()); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } } - private static org.osgi.framework.Filter createListenerFilter(BundleContext context, ServletContext servletContext) { + private static org.osgi.framework.Filter createListenerFilter(BundleContext context, + ServletContext servletContext) { StringBuilder sb = new StringBuilder(); sb.append("(&"); //$NON-NLS-1$ @@ -1100,8 +1078,7 @@ private static org.osgi.framework.Filter createListenerFilter(BundleContext cont try { return context.createFilter(sb.toString()); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } } @@ -1126,9 +1103,7 @@ public org.osgi.framework.Filter getResourceFilter() { return resourceServiceFilter; } - public void recordFailedErrorPageDTO( - ServiceReference serviceReference, - FailedErrorPageDTO failedErrorPageDTO) { + public void recordFailedErrorPageDTO(ServiceReference serviceReference, FailedErrorPageDTO failedErrorPageDTO) { if (failedErrorPageDTOs.containsKey(serviceReference)) { return; @@ -1137,9 +1112,7 @@ public void recordFailedErrorPageDTO( failedErrorPageDTOs.put(serviceReference, failedErrorPageDTO); } - public void recordFailedFilterDTO( - ServiceReference serviceReference, - FailedFilterDTO failedFilterDTO) { + public void recordFailedFilterDTO(ServiceReference serviceReference, FailedFilterDTO failedFilterDTO) { if (failedFilterDTOs.containsKey(serviceReference)) { return; @@ -1148,9 +1121,8 @@ public void recordFailedFilterDTO( failedFilterDTOs.put(serviceReference, failedFilterDTO); } - public void recordFailedListenerDTO( - ServiceReference serviceReference, - FailedListenerDTO failedListenerDTO) { + public void recordFailedListenerDTO(ServiceReference serviceReference, + FailedListenerDTO failedListenerDTO) { if (failedListenerDTOs.containsKey(serviceReference)) { return; @@ -1159,8 +1131,7 @@ public void recordFailedListenerDTO( failedListenerDTOs.put(serviceReference, failedListenerDTO); } - public void recordFailedResourceDTO( - ServiceReference serviceReference, FailedResourceDTO failedResourceDTO) { + public void recordFailedResourceDTO(ServiceReference serviceReference, FailedResourceDTO failedResourceDTO) { if (failedResourceDTOs.containsKey(serviceReference)) { return; @@ -1169,31 +1140,30 @@ public void recordFailedResourceDTO( failedResourceDTOs.put(serviceReference, failedResourceDTO); } - public void recordFailedServletContextDTO( - ServiceReference serviceReference, long shadowingServiceId, int failureReason) { + public void recordFailedServletContextDTO(ServiceReference serviceReference, + long shadowingServiceId, int failureReason) { ExtendedFailedServletContextDTO failedServletContextDTO = new ExtendedFailedServletContextDTO(); failedServletContextDTO.attributes = Collections.emptyMap(); - failedServletContextDTO.contextPath = String.valueOf(serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_PATH)); + failedServletContextDTO.contextPath = String + .valueOf(serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_PATH)); failedServletContextDTO.errorPageDTOs = new ExtendedErrorPageDTO[0]; failedServletContextDTO.failureReason = failureReason; failedServletContextDTO.filterDTOs = new FilterDTO[0]; - failedServletContextDTO.initParams = ServiceProperties.parseInitParams( - serviceReference, HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX); + failedServletContextDTO.initParams = ServiceProperties.parseInitParams(serviceReference, + HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX); failedServletContextDTO.listenerDTOs = new ListenerDTO[0]; failedServletContextDTO.name = String.valueOf(serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_NAME)); failedServletContextDTO.resourceDTOs = new ResourceDTO[0]; - failedServletContextDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + failedServletContextDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); failedServletContextDTO.servletDTOs = new ServletDTO[0]; failedServletContextDTO.shadowingServiceId = shadowingServiceId; failedServletContextDTOs.put(serviceReference, failedServletContextDTO); } - public void recordFailedServletDTO( - ServiceReference serviceReference, - FailedServletDTO failedServletDTO) { + public void recordFailedServletDTO(ServiceReference serviceReference, FailedServletDTO failedServletDTO) { if (failedServletDTOs.containsKey(serviceReference)) { return; @@ -1202,9 +1172,8 @@ public void recordFailedServletDTO( failedServletDTOs.put(serviceReference, failedServletDTO); } - public void recordFailedPreprocessorDTO( - ServiceReference serviceReference, - FailedPreprocessorDTO failedPreprocessorDTO) { + public void recordFailedPreprocessorDTO(ServiceReference serviceReference, + FailedPreprocessorDTO failedPreprocessorDTO) { if (failedPreprocessorDTOs.containsKey(serviceReference)) { return; @@ -1213,38 +1182,32 @@ public void recordFailedPreprocessorDTO( failedPreprocessorDTOs.put(serviceReference, failedPreprocessorDTO); } - public void removeFailedErrorPageDTO( - ServiceReference serviceReference) { + public void removeFailedErrorPageDTO(ServiceReference serviceReference) { failedErrorPageDTOs.remove(serviceReference); } - public void removeFailedFilterDTO( - ServiceReference serviceReference) { + public void removeFailedFilterDTO(ServiceReference serviceReference) { failedFilterDTOs.remove(serviceReference); } - public void removeFailedListenerDTO( - ServiceReference serviceReference) { + public void removeFailedListenerDTO(ServiceReference serviceReference) { failedListenerDTOs.remove(serviceReference); } - public void removeFailedResourceDTO( - ServiceReference serviceReference) { + public void removeFailedResourceDTO(ServiceReference serviceReference) { failedResourceDTOs.remove(serviceReference); } - public void removeFailedServletDTO( - ServiceReference serviceReference) { + public void removeFailedServletDTO(ServiceReference serviceReference) { failedServletDTOs.remove(serviceReference); } - public void removeFailedPreprocessorDTO( - ServiceReference serviceReference) { + public void removeFailedPreprocessorDTO(ServiceReference serviceReference) { failedPreprocessorDTOs.remove(serviceReference); } @@ -1285,8 +1248,7 @@ Semaphore getSemaphore() { private String decode(String urlEncoded) { try { return URLDecoder.decode(urlEncoded, StandardCharsets.UTF_8.name()); - } - catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException e) { return urlEncoded; } } @@ -1304,34 +1266,25 @@ private String decode(String urlEncoded) { private final org.osgi.framework.Filter listenerServiceFilter; // BEGIN of old HttpService support - final ConcurrentMap legacyContextMap = - new ConcurrentHashMap<>(); - private final Map legacyMappings = - Collections.synchronizedMap(new HashMap()); - private final Map> bundleRegistrations = - new HashMap<>(); + final ConcurrentMap legacyContextMap = new ConcurrentHashMap<>(); + private final Map legacyMappings = Collections + .synchronizedMap(new HashMap()); + private final Map> bundleRegistrations = new HashMap<>(); private final Map> bundleAliasCustomizations = new HashMap<>(); // END of old HttpService support - private final ConcurrentMap, ContextController> controllerMap = - new ConcurrentSkipListMap<>(Collections.reverseOrder()); - private final ConcurrentMap, PreprocessorRegistration> preprocessorMap = - new ConcurrentSkipListMap<>(Collections.reverseOrder()); - - final ConcurrentMap, FailedErrorPageDTO> failedErrorPageDTOs = - new ConcurrentHashMap<>(); - final ConcurrentMap, FailedFilterDTO> failedFilterDTOs = - new ConcurrentHashMap<>(); - final ConcurrentMap, FailedListenerDTO> failedListenerDTOs = - new ConcurrentHashMap<>(); - final ConcurrentMap, FailedResourceDTO> failedResourceDTOs = - new ConcurrentHashMap<>(); - final ConcurrentMap, ExtendedFailedServletContextDTO> failedServletContextDTOs = - new ConcurrentHashMap<>(); - final ConcurrentMap, FailedServletDTO> failedServletDTOs = - new ConcurrentHashMap<>(); - final ConcurrentMap, FailedPreprocessorDTO> failedPreprocessorDTOs = - new ConcurrentHashMap<>(); + private final ConcurrentMap, ContextController> controllerMap = new ConcurrentSkipListMap<>( + Collections.reverseOrder()); + private final ConcurrentMap, PreprocessorRegistration> preprocessorMap = new ConcurrentSkipListMap<>( + Collections.reverseOrder()); + + final ConcurrentMap, FailedErrorPageDTO> failedErrorPageDTOs = new ConcurrentHashMap<>(); + final ConcurrentMap, FailedFilterDTO> failedFilterDTOs = new ConcurrentHashMap<>(); + final ConcurrentMap, FailedListenerDTO> failedListenerDTOs = new ConcurrentHashMap<>(); + final ConcurrentMap, FailedResourceDTO> failedResourceDTOs = new ConcurrentHashMap<>(); + final ConcurrentMap, ExtendedFailedServletContextDTO> failedServletContextDTOs = new ConcurrentHashMap<>(); + final ConcurrentMap, FailedServletDTO> failedServletDTOs = new ConcurrentHashMap<>(); + final ConcurrentMap, FailedPreprocessorDTO> failedPreprocessorDTOs = new ConcurrentHashMap<>(); private final Set registeredObjects = Collections.newSetFromMap(new ConcurrentHashMap()); private final ServiceTracker loggerFactoryTracker; @@ -1351,19 +1304,20 @@ class ChangeCountTimer implements Callable { @Override public Void call() { try { - Dictionary properties = getHsrRegistration().getReference().getProperties(); + Dictionary properties = getHsrRegistration().getReference().getProperties(); properties.put(Constants.SERVICE_CHANGECOUNT, getServiceChangecount()); getHsrRegistration().setProperties(properties); return null; - } - finally { + } finally { getSemaphore().release(); } } } static class LegacyServiceObject { - final AtomicReference error = new AtomicReference<>(new ServletException("The init() method was never called.")); //$NON-NLS-1$ + final AtomicReference error = new AtomicReference<>( + new ServletException("The init() method was never called.")); //$NON-NLS-1$ + public void checkForError() { Exception result = error.get(); if (result != null) { @@ -1385,15 +1339,17 @@ public Filter getService(Bundle bundle, ServiceRegistration registration } @Override - public void ungetService( - Bundle bundle, ServiceRegistration registration, Filter service) { + public void ungetService(Bundle bundle, ServiceRegistration registration, Filter service) { // do nothing } - // NOTE we do not do the same equals check here for filter that we do for servlet + // NOTE we do not do the same equals check here for filter that we do for + // servlet // this is because we must allow filter to be applied to all context helpers - // TODO this means it is still possible that init() will get called if the same filter - // is registered multiple times. This is unfortunate but is an error case on the client anyway. + // TODO this means it is still possible that init() will get called if the same + // filter + // is registered multiple times. This is unfortunate but is an error case on the + // client anyway. class LegacyFilter implements Filter { /** * @throws ServletException @@ -1403,16 +1359,15 @@ public void init(FilterConfig filterConfig) throws ServletException { try { filter.init(filterConfig); error.set(null); - } catch (Exception e){ + } catch (Exception e) { error.set(e); Throw.unchecked(e); } } @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { filter.doFilter(request, response, chain); } @@ -1434,12 +1389,11 @@ public LegacyServlet(Servlet servlet) { * @throws ServletException */ @Override - public void init(ServletConfig config) - throws ServletException { + public void init(ServletConfig config) throws ServletException { try { servlet.init(config); error.set(null); - } catch (Exception e){ + } catch (Exception e) { error.set(e); Throw.unchecked(e); } @@ -1451,9 +1405,7 @@ public ServletConfig getServletConfig() { } @Override - public void - service(ServletRequest req, ServletResponse res) - throws ServletException, IOException { + public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { servlet.service(req, res); } @@ -1481,23 +1433,22 @@ public boolean equals(Object other) { } } - static class ContextPathCustomizerHolder implements ServiceTrackerCustomizer { + static class ContextPathCustomizerHolder + implements ServiceTrackerCustomizer { private final BundleContext context; private final ServiceTracker> contextServiceTracker; - private final NavigableMap, ContextPathCustomizer> pathCustomizers = - new TreeMap<>(Collections.reverseOrder()); + private final NavigableMap, ContextPathCustomizer> pathCustomizers = new TreeMap<>( + Collections.reverseOrder()); - public ContextPathCustomizerHolder( - BundleContext context, - ServiceTracker> contextServiceTracker) { + public ContextPathCustomizerHolder(BundleContext context, + ServiceTracker> contextServiceTracker) { super(); this.context = context; this.contextServiceTracker = contextServiceTracker; } @Override - public ContextPathCustomizer addingService( - ServiceReference reference) { + public ContextPathCustomizer addingService(ServiceReference reference) { ContextPathCustomizer service = context.getService(reference); boolean reset = false; synchronized (pathCustomizers) { @@ -1512,16 +1463,13 @@ public ContextPathCustomizer addingService( } @Override - public void modifiedService( - ServiceReference reference, - ContextPathCustomizer service) { + public void modifiedService(ServiceReference reference, ContextPathCustomizer service) { removedService(reference, service); addingService(reference); } + @Override - public void removedService( - ServiceReference reference, - ContextPathCustomizer service) { + public void removedService(ServiceReference reference, ContextPathCustomizer service) { boolean reset = false; synchronized (pathCustomizers) { ServiceReference currentFirst = pathCustomizers.firstKey(); @@ -1540,7 +1488,8 @@ public void removedService( ContextPathCustomizer getHighestRanked() { synchronized (pathCustomizers) { - Map.Entry, ContextPathCustomizer> firstEntry = pathCustomizers.firstEntry(); + Map.Entry, ContextPathCustomizer> firstEntry = pathCustomizers + .firstEntry(); return firstEntry == null ? null : firstEntry.getValue(); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/PreprocessorCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/PreprocessorCustomizer.java index 4f7942228de..71ba14be4cd 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/PreprocessorCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/PreprocessorCustomizer.java @@ -35,15 +35,14 @@ * @author Raymond Augé */ public class PreprocessorCustomizer - implements ServiceTrackerCustomizer> { + implements ServiceTrackerCustomizer> { public PreprocessorCustomizer(HttpServiceRuntimeImpl httpServiceRuntime) { this.httpServiceRuntime = httpServiceRuntime; } @Override - public AtomicReference addingService( - ServiceReference serviceReference) { + public AtomicReference addingService(ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!httpServiceRuntime.matches(serviceReference)) { @@ -54,18 +53,15 @@ public AtomicReference addingService( removeFailed(serviceReference); result.set(addPreprocessorRegistration(serviceReference)); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { httpServiceRuntime.debug(hwfe.getMessage(), hwfe); recordFailed(serviceReference, hwfe.getFailureReason()); - } - catch (Exception e) { + } catch (Exception e) { httpServiceRuntime.error(e.getMessage(), e); recordFailed(serviceReference, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } @@ -73,8 +69,8 @@ public AtomicReference addingService( } @Override - public void modifiedService( - ServiceReference serviceReference, AtomicReference reference) { + public void modifiedService(ServiceReference serviceReference, + AtomicReference reference) { removedService(serviceReference, reference); AtomicReference added = addingService(serviceReference); @@ -82,8 +78,8 @@ public void modifiedService( } @Override - public void removedService( - ServiceReference serviceReference, AtomicReference reference) { + public void removedService(ServiceReference serviceReference, + AtomicReference reference) { try { PreprocessorRegistration registration = reference.get(); if (registration != null) { @@ -91,8 +87,7 @@ public void removedService( } removeFailed(serviceReference); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } } @@ -101,23 +96,23 @@ void removeFailed(ServiceReference serviceReference) { httpServiceRuntime.removeFailedPreprocessorDTO(serviceReference); } - private void recordFailed( - ServiceReference serviceReference, int failureReason) { + private void recordFailed(ServiceReference serviceReference, int failureReason) { FailedPreprocessorDTO failedPreprocessorDTO = new FailedPreprocessorDTO(); failedPreprocessorDTO.failureReason = failureReason; - failedPreprocessorDTO.initParams = ServiceProperties.parseInitParams( - serviceReference, HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX); - failedPreprocessorDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + failedPreprocessorDTO.initParams = ServiceProperties.parseInitParams(serviceReference, + HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX); + failedPreprocessorDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); httpServiceRuntime.recordFailedPreprocessorDTO(serviceReference, failedPreprocessorDTO); } - private PreprocessorRegistration addPreprocessorRegistration( - ServiceReference preprocessorRef) throws ServletException { + private PreprocessorRegistration addPreprocessorRegistration(ServiceReference preprocessorRef) + throws ServletException { - ServiceHolder preprocessorHolder = new ServiceHolder<>(httpServiceRuntime.getConsumingContext().getServiceObjects(preprocessorRef)); + ServiceHolder preprocessorHolder = new ServiceHolder<>( + httpServiceRuntime.getConsumingContext().getServiceObjects(preprocessorRef)); Preprocessor preprocessor = preprocessorHolder.get(); PreprocessorRegistration registration = null; boolean addedRegisteredObject = false; @@ -127,7 +122,10 @@ private PreprocessorRegistration addPreprocessorRegistration( } addedRegisteredObject = httpServiceRuntime.getRegisteredObjects().add(preprocessor); if (!addedRegisteredObject) { - throw new HttpWhiteboardFailureException("Multiple registration of instance detected. Prototype scope is recommended: " + preprocessorRef, DTOConstants.FAILURE_REASON_SERVICE_IN_USE); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException( + "Multiple registration of instance detected. Prototype scope is recommended: " //$NON-NLS-1$ + + preprocessorRef, + DTOConstants.FAILURE_REASON_SERVICE_IN_USE); } registration = doAddPreprocessorRegistration(preprocessorHolder, preprocessorRef); } finally { @@ -141,26 +139,24 @@ private PreprocessorRegistration addPreprocessorRegistration( return registration; } - private PreprocessorRegistration doAddPreprocessorRegistration( - ServiceHolder preprocessorHolder, - ServiceReference preprocessorRef) throws ServletException { + private PreprocessorRegistration doAddPreprocessorRegistration(ServiceHolder preprocessorHolder, + ServiceReference preprocessorRef) throws ServletException { PreprocessorDTO preprocessorDTO = new PreprocessorDTO(); - preprocessorDTO.initParams = ServiceProperties.parseInitParams( - preprocessorRef, HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX); + preprocessorDTO.initParams = ServiceProperties.parseInitParams(preprocessorRef, + HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX); preprocessorDTO.serviceId = preprocessorHolder.getServiceId(); - PreprocessorRegistration newRegistration = new PreprocessorRegistration( - preprocessorHolder, preprocessorDTO, httpServiceRuntime); - FilterConfig filterConfig = new FilterConfigImpl( - preprocessorHolder.get().getClass().getCanonicalName(), - preprocessorDTO.initParams, - httpServiceRuntime.getParentServletContext()); + PreprocessorRegistration newRegistration = new PreprocessorRegistration(preprocessorHolder, preprocessorDTO, + httpServiceRuntime); + FilterConfig filterConfig = new FilterConfigImpl(preprocessorHolder.get().getClass().getCanonicalName(), + preprocessorDTO.initParams, httpServiceRuntime.getParentServletContext()); newRegistration.init(filterConfig); - httpServiceRuntime.getPreprocessorRegistrations().put(preprocessorHolder.getServiceReference(), newRegistration); + httpServiceRuntime.getPreprocessorRegistrations().put(preprocessorHolder.getServiceReference(), + newRegistration); return newRegistration; } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java index 56860324920..bcbfb10bae0 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java @@ -47,10 +47,9 @@ */ public class ContextController { - public ContextController( - BundleContext trackingContextParam, BundleContext consumingContext, - ServiceReference serviceReference, - ServletContext parentServletContext, HttpServiceRuntimeImpl httpServiceRuntime) { + public ContextController(BundleContext trackingContextParam, BundleContext consumingContext, + ServiceReference serviceReference, ServletContext parentServletContext, + HttpServiceRuntimeImpl httpServiceRuntime) { this.trackingContext = trackingContextParam; this.consumingContext = consumingContext; @@ -59,44 +58,34 @@ public ContextController( this.contextName = validateName(); this.contextPath = validatePath(); this.proxyContext = new ProxyContext(contextName, parentServletContext); - this.contextServiceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + this.contextServiceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); this.servletContextHelperRefFilter = createFilter(contextServiceId); - this.initParams = ServiceProperties.parseInitParams( - serviceReference, HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX, parentServletContext); + this.initParams = ServiceProperties.parseInitParams(serviceReference, HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX, + parentServletContext); - listenerServiceTracker = new ServiceTracker<>( - trackingContext, httpServiceRuntime.getListenerFilter(), - new ContextListenerTrackerCustomizer( - trackingContext, httpServiceRuntime, this)); + listenerServiceTracker = new ServiceTracker<>(trackingContext, httpServiceRuntime.getListenerFilter(), + new ContextListenerTrackerCustomizer(trackingContext, httpServiceRuntime, this)); listenerServiceTracker.open(); - filterServiceTracker = new ServiceTracker<>( - trackingContext, httpServiceRuntime.getFilterFilter(), - new ContextFilterTrackerCustomizer( - trackingContext, httpServiceRuntime, this)); + filterServiceTracker = new ServiceTracker<>(trackingContext, httpServiceRuntime.getFilterFilter(), + new ContextFilterTrackerCustomizer(trackingContext, httpServiceRuntime, this)); filterServiceTracker.open(); - errorPageServiceTracker = new ServiceTracker<>( - trackingContext, httpServiceRuntime.getErrorPageFilter(), - new ContextErrorPageTrackerCustomizer( - trackingContext, httpServiceRuntime, this)); + errorPageServiceTracker = new ServiceTracker<>(trackingContext, httpServiceRuntime.getErrorPageFilter(), + new ContextErrorPageTrackerCustomizer(trackingContext, httpServiceRuntime, this)); errorPageServiceTracker.open(); - servletServiceTracker = new ServiceTracker<>( - trackingContext, httpServiceRuntime.getServletFilter(), - new ContextServletTrackerCustomizer( - trackingContext, httpServiceRuntime, this)); + servletServiceTracker = new ServiceTracker<>(trackingContext, httpServiceRuntime.getServletFilter(), + new ContextServletTrackerCustomizer(trackingContext, httpServiceRuntime, this)); servletServiceTracker.open(); - resourceServiceTracker = new ServiceTracker<>( - trackingContext, httpServiceRuntime.getResourceFilter(), - new ContextResourceTrackerCustomizer( - trackingContext, httpServiceRuntime, this)); + resourceServiceTracker = new ServiceTracker<>(trackingContext, httpServiceRuntime.getResourceFilter(), + new ContextResourceTrackerCustomizer(trackingContext, httpServiceRuntime, this)); resourceServiceTracker.open(); } @@ -105,60 +94,62 @@ public ErrorPageRegistration addErrorPageRegistration(ServiceReference ServiceHolder servletHolder = new ServiceHolder<>(consumingContext.getServiceObjects(servletRef)); Servlet servlet = servletHolder.get(); ErrorPageRegistration registration = null; - //boolean addedRegisteredObject = false; + // boolean addedRegisteredObject = false; try { if (servlet == null) { throw new IllegalArgumentException("Servlet cannot be null"); //$NON-NLS-1$ } - //addedRegisteredObject = httpServiceRuntime.getRegisteredObjects().add(servlet); - //if (!addedRegisteredObject) { - // throw new HttpWhiteboardFailureException("Multiple registration of instance detected. Prototype scope is recommended: " + servletRef, DTOConstants.FAILURE_REASON_SERVICE_IN_USE); //$NON-NLS-1$ - //} + // addedRegisteredObject = + // httpServiceRuntime.getRegisteredObjects().add(servlet); + // if (!addedRegisteredObject) { + // throw new HttpWhiteboardFailureException("Multiple registration of instance + // detected. Prototype scope is recommended: " + servletRef, + // DTOConstants.FAILURE_REASON_SERVICE_IN_USE); //$NON-NLS-1$ + // } registration = doAddErrorPageRegistration(servletHolder, servletRef); } finally { if (registration == null) { // Always attempt to release here; even though destroy() may have been called - // on the registration while failing to add. There are cases where no + // on the registration while failing to add. There are cases where no // ServletRegistration may have even been created at all to call destory() on. - // Also, addedRegisteredObject may be false which means we never call doAddServletRegistration + // Also, addedRegisteredObject may be false which means we never call + // doAddServletRegistration servletHolder.release(); - //if (addedRegisteredObject) { - // httpServiceRuntime.getRegisteredObjects().remove(servlet); - //} + // if (addedRegisteredObject) { + // httpServiceRuntime.getRegisteredObjects().remove(servlet); + // } } } return registration; } - private ErrorPageRegistration doAddErrorPageRegistration(ServiceHolder servletHolder, ServiceReference servletRef) { + private ErrorPageRegistration doAddErrorPageRegistration(ServiceHolder servletHolder, + ServiceReference servletRef) { ExtendedErrorPageDTO errorPageDTO = DTOUtil.assembleErrorPageDTO(servletRef, getServiceId(), true); errorPageDTO.servletInfo = servletHolder.get().getServletInfo(); errorPageDTO.serviceId = servletHolder.getServiceId(); - if (((errorPageDTO.errorCodes == null) || (errorPageDTO.errorCodes.length == 0)) && - ((errorPageDTO.exceptions == null) || (errorPageDTO.exceptions.length == 0))) { + if (((errorPageDTO.errorCodes == null) || (errorPageDTO.errorCodes.length == 0)) + && ((errorPageDTO.exceptions == null) || (errorPageDTO.exceptions.length == 0))) { - throw new HttpWhiteboardFailureException("'errorPage' expects String, String[] or Collection.", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("'errorPage' expects String, String[] or Collection.", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } if (errorPageDTO.name == null) { errorPageDTO.name = servletHolder.get().getClass().getName(); } - ServletContextHelper curServletContextHelper = getServletContextHelper( - servletHolder.getBundle()); + ServletContextHelper curServletContextHelper = getServletContextHelper(servletHolder.getBundle()); - ServletContext servletContext = createServletContext( - servletHolder.getBundle(), curServletContextHelper); - ErrorPageRegistration errorPageRegistration = new ErrorPageRegistration( - servletHolder, errorPageDTO, curServletContextHelper, this); - ServletConfig servletConfig = new ServletConfigImpl( - errorPageDTO.name, errorPageDTO.initParams, servletContext); + ServletContext servletContext = createServletContext(servletHolder.getBundle(), curServletContextHelper); + ErrorPageRegistration errorPageRegistration = new ErrorPageRegistration(servletHolder, errorPageDTO, + curServletContextHelper, this); + ServletConfig servletConfig = new ServletConfigImpl(errorPageDTO.name, errorPageDTO.initParams, servletContext); try { errorPageRegistration.init(servletConfig); - } - catch (Throwable t) { + } catch (Throwable t) { errorPageRegistration.destroy(); return Throw.unchecked(t); @@ -182,7 +173,9 @@ public FilterRegistration addFilterRegistration(ServiceReference filterR } addedRegisteredObject = httpServiceRuntime.getRegisteredObjects().add(filter); if (!addedRegisteredObject) { - throw new HttpWhiteboardFailureException("Multiple registration of instance detected. Prototype scope is recommended: " + filterRef, DTOConstants.FAILURE_REASON_SERVICE_IN_USE); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException( + "Multiple registration of instance detected. Prototype scope is recommended: " + filterRef, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_SERVICE_IN_USE); } registration = doAddFilterRegistration(filterHolder, filterRef); } finally { @@ -196,43 +189,33 @@ public FilterRegistration addFilterRegistration(ServiceReference filterR return registration; } - private FilterRegistration doAddFilterRegistration(ServiceHolder filterHolder, ServiceReference filterRef) throws ServletException { - boolean asyncSupported = ServiceProperties.parseBoolean( - filterRef, HTTP_WHITEBOARD_FILTER_ASYNC_SUPPORTED); + private FilterRegistration doAddFilterRegistration(ServiceHolder filterHolder, + ServiceReference filterRef) throws ServletException { + boolean asyncSupported = ServiceProperties.parseBoolean(filterRef, HTTP_WHITEBOARD_FILTER_ASYNC_SUPPORTED); - List dispatcherList = StringPlus.from( - filterRef.getProperty( - HTTP_WHITEBOARD_FILTER_DISPATCHER)); + List dispatcherList = StringPlus.from(filterRef.getProperty(HTTP_WHITEBOARD_FILTER_DISPATCHER)); String[] dispatchers = dispatcherList.toArray(new String[0]); - Integer filterPriority = (Integer)filterRef.getProperty( - Constants.SERVICE_RANKING); + Integer filterPriority = (Integer) filterRef.getProperty(Constants.SERVICE_RANKING); if (filterPriority == null) { filterPriority = Integer.valueOf(0); } - Map filterInitParams = ServiceProperties.parseInitParams( - filterRef, HTTP_WHITEBOARD_FILTER_INIT_PARAM_PREFIX); - List patternList = StringPlus.from( - filterRef.getProperty( - HTTP_WHITEBOARD_FILTER_PATTERN)); + Map filterInitParams = ServiceProperties.parseInitParams(filterRef, + HTTP_WHITEBOARD_FILTER_INIT_PARAM_PREFIX); + List patternList = StringPlus.from(filterRef.getProperty(HTTP_WHITEBOARD_FILTER_PATTERN)); String[] patterns = patternList.toArray(new String[0]); - List regexList = StringPlus.from( - filterRef.getProperty( - HTTP_WHITEBOARD_FILTER_REGEX)); + List regexList = StringPlus.from(filterRef.getProperty(HTTP_WHITEBOARD_FILTER_REGEX)); String[] regexs = regexList.toArray(new String[0]); - List servletList = StringPlus.from( - filterRef.getProperty( - HTTP_WHITEBOARD_FILTER_SERVLET)); + List servletList = StringPlus.from(filterRef.getProperty(HTTP_WHITEBOARD_FILTER_SERVLET)); String[] servletNames = servletList.toArray(new String[0]); - String name = ServiceProperties.parseName(filterRef.getProperty( - HTTP_WHITEBOARD_FILTER_NAME), filterHolder.get()); + String name = ServiceProperties.parseName(filterRef.getProperty(HTTP_WHITEBOARD_FILTER_NAME), + filterHolder.get()); - if (((patterns == null) || (patterns.length == 0)) && - ((regexs == null) || (regexs.length == 0)) && - ((servletNames == null) || (servletNames.length == 0))) { + if (((patterns == null) || (patterns.length == 0)) && ((regexs == null) || (regexs.length == 0)) + && ((servletNames == null) || (servletNames.length == 0))) { - throw new HttpWhiteboardFailureException( - "Patterns, regex or servletNames must contain a value.", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Patterns, regex or servletNames must contain a value.", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } if (patterns != null) { @@ -267,15 +250,11 @@ private FilterRegistration doAddFilterRegistration(ServiceHolder filterH filterDTO.servletContextId = contextServiceId; filterDTO.servletNames = sort(servletNames); - ServletContextHelper curServletContextHelper = getServletContextHelper( - filterHolder.getBundle()); + ServletContextHelper curServletContextHelper = getServletContextHelper(filterHolder.getBundle()); - ServletContext servletContext = createServletContext( - filterHolder.getBundle(), curServletContextHelper); - FilterRegistration newRegistration = new FilterRegistration( - filterHolder, filterDTO, filterPriority, this); - FilterConfig filterConfig = new FilterConfigImpl( - name, filterInitParams, servletContext); + ServletContext servletContext = createServletContext(filterHolder.getBundle(), curServletContextHelper); + FilterRegistration newRegistration = new FilterRegistration(filterHolder, filterDTO, filterPriority, this); + FilterConfig filterConfig = new FilterConfigImpl(name, filterInitParams, servletContext); newRegistration.init(filterConfig); @@ -283,8 +262,10 @@ private FilterRegistration doAddFilterRegistration(ServiceHolder filterH return newRegistration; } - public ListenerRegistration addListenerRegistration(ServiceReference listenerRef) throws ServletException { - ServiceHolder listenerHolder = new ServiceHolder<>(consumingContext.getServiceObjects(listenerRef)); + public ListenerRegistration addListenerRegistration(ServiceReference listenerRef) + throws ServletException { + ServiceHolder listenerHolder = new ServiceHolder<>( + consumingContext.getServiceObjects(listenerRef)); EventListener listener = listenerHolder.get(); ListenerRegistration registration = null; try { @@ -300,22 +281,19 @@ public ListenerRegistration addListenerRegistration(ServiceReference listenerHolder, - ServiceReference listenerRef) throws ServletException { + private ListenerRegistration doAddListenerRegistration(ServiceHolder listenerHolder, + ServiceReference listenerRef) throws ServletException { EventListener eventListener = listenerHolder.get(); List> classes = getListenerClasses(listenerRef); if (classes.isEmpty()) { - throw new IllegalArgumentException( - "EventListener does not implement a supported type."); //$NON-NLS-1$ + throw new IllegalArgumentException("EventListener does not implement a supported type."); //$NON-NLS-1$ } for (ListenerRegistration listenerRegistration : listenerRegistrations) { if (listenerRegistration.getT().equals(eventListener)) { - throw new ServletException( - "EventListener has already been registered."); //$NON-NLS-1$ + throw new ServletException("EventListener has already been registered."); //$NON-NLS-1$ } } @@ -325,20 +303,16 @@ private ListenerRegistration doAddListenerRegistration( listenerDTO.servletContextId = contextServiceId; listenerDTO.types = asStringArray(classes); - ServletContextHelper curServletContextHelper = getServletContextHelper( - listenerHolder.getBundle()); + ServletContextHelper curServletContextHelper = getServletContextHelper(listenerHolder.getBundle()); - ServletContext servletContext = createServletContext( - listenerHolder.getBundle(), curServletContextHelper); - ListenerRegistration listenerRegistration = new ListenerRegistration( - listenerHolder, classes, listenerDTO, servletContext, this); + ServletContext servletContext = createServletContext(listenerHolder.getBundle(), curServletContextHelper); + ListenerRegistration listenerRegistration = new ListenerRegistration(listenerHolder, classes, listenerDTO, + servletContext, this); if (classes.contains(ServletContextListener.class)) { - ServletContextListener servletContextListener = - (ServletContextListener)listenerRegistration.getT(); + ServletContextListener servletContextListener = (ServletContextListener) listenerRegistration.getT(); - servletContextListener.contextInitialized( - new ServletContextEvent(servletContext)); + servletContextListener.contextInitialized(new ServletContextEvent(servletContext)); } listenerRegistrations.add(listenerRegistration); @@ -349,32 +323,30 @@ private ListenerRegistration doAddListenerRegistration( } public ResourceRegistration addResourceRegistration(ServiceReference resourceRef) { - ClassLoader legacyTCCL = (ClassLoader)resourceRef.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP); + ClassLoader legacyTCCL = (ClassLoader) resourceRef.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP); Integer rankProp = (Integer) resourceRef.getProperty(Constants.SERVICE_RANKING); int serviceRanking = rankProp == null ? 0 : rankProp.intValue(); Object patternObj = resourceRef.getProperty(HTTP_WHITEBOARD_RESOURCE_PATTERN); - if (!(patternObj instanceof String) && - !(patternObj instanceof String[]) && - !(patternObj instanceof Collection)) { - throw new HttpWhiteboardFailureException("Expect pattern to be String+ (String | String[] | Collection)", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + if (!(patternObj instanceof String) && !(patternObj instanceof String[]) + && !(patternObj instanceof Collection)) { + throw new HttpWhiteboardFailureException( + "Expect pattern to be String+ (String | String[] | Collection)", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } List patternList = StringPlus.from(patternObj); String[] patterns = patternList.toArray(new String[0]); - Long serviceId = (Long)resourceRef.getProperty( - Constants.SERVICE_ID); + Long serviceId = (Long) resourceRef.getProperty(Constants.SERVICE_ID); if (legacyTCCL != null) { // this is a legacy registration; use a negative id for the DTO serviceId = -serviceId; } - Object prefixObj = resourceRef.getProperty( - HTTP_WHITEBOARD_RESOURCE_PREFIX); + Object prefixObj = resourceRef.getProperty(HTTP_WHITEBOARD_RESOURCE_PREFIX); checkPrefix(prefixObj); - String prefix = (String)prefixObj; + String prefix = (String) prefixObj; if ((patterns == null) || (patterns.length < 1)) { - throw new IllegalArgumentException( - "Patterns must contain a value."); //$NON-NLS-1$ + throw new IllegalArgumentException("Patterns must contain a value."); //$NON-NLS-1$ } for (String pattern : patterns) { @@ -382,10 +354,8 @@ public ResourceRegistration addResourceRegistration(ServiceReference resource } Bundle bundle = resourceRef.getBundle(); - ServletContextHelper curServletContextHelper = getServletContextHelper( - bundle); - Servlet servlet = new ResourceServlet( - prefix, curServletContextHelper, AccessController.getContext()); + ServletContextHelper curServletContextHelper = getServletContextHelper(bundle); + Servlet servlet = new ResourceServlet(prefix, curServletContextHelper, AccessController.getContext()); ResourceDTO resourceDTO = new ResourceDTO(); @@ -394,19 +364,16 @@ public ResourceRegistration addResourceRegistration(ServiceReference resource resourceDTO.serviceId = serviceId; resourceDTO.servletContextId = contextServiceId; - ServletContext servletContext = createServletContext( - bundle, curServletContextHelper); - ResourceRegistration resourceRegistration = new ResourceRegistration( - resourceRef, new ServiceHolder<>(servlet, bundle, serviceId, serviceRanking, legacyTCCL), - resourceDTO, curServletContextHelper, this); - ServletConfig servletConfig = new ServletConfigImpl( - resourceRegistration.getName(), new HashMap(), - servletContext); + ServletContext servletContext = createServletContext(bundle, curServletContextHelper); + ResourceRegistration resourceRegistration = new ResourceRegistration(resourceRef, + new ServiceHolder<>(servlet, bundle, serviceId, serviceRanking, legacyTCCL), resourceDTO, + curServletContextHelper, this); + ServletConfig servletConfig = new ServletConfigImpl(resourceRegistration.getName(), + new HashMap(), servletContext); try { resourceRegistration.init(servletConfig); - } - catch (Throwable t) { + } catch (Throwable t) { resourceRegistration.destroy(); return Throw.unchecked(t); @@ -430,15 +397,18 @@ public ServletRegistration addServletRegistration(ServiceReference serv } addedRegisteredObject = httpServiceRuntime.getRegisteredObjects().add(servlet); if (!addedRegisteredObject) { - throw new HttpWhiteboardFailureException("Multiple registration of instance detected. Prototype scope is recommended: " + servletRef, DTOConstants.FAILURE_REASON_SERVICE_IN_USE); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException( + "Multiple registration of instance detected. Prototype scope is recommended: " + servletRef, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_SERVICE_IN_USE); } registration = doAddServletRegistration(servletHolder, servletRef); } finally { if (registration == null) { // Always attempt to release here; even though destroy() may have been called - // on the registration while failing to add. There are cases where no + // on the registration while failing to add. There are cases where no // ServletRegistration may have even been created at all to call destory() on. - // Also, addedRegisteredObject may be false which means we never call doAddServletRegistration + // Also, addedRegisteredObject may be false which means we never call + // doAddServletRegistration servletHolder.release(); if (addedRegisteredObject) { httpServiceRuntime.getRegisteredObjects().remove(servlet); @@ -448,13 +418,13 @@ public ServletRegistration addServletRegistration(ServiceReference serv return registration; } - private ServletRegistration doAddServletRegistration(ServiceHolder servletHolder, ServiceReference servletRef) { + private ServletRegistration doAddServletRegistration(ServiceHolder servletHolder, + ServiceReference servletRef) { ServletDTO servletDTO = DTOUtil.assembleServletDTO(servletRef, getServiceId(), true); servletDTO.servletInfo = servletHolder.get().getServletInfo(); servletDTO.serviceId = servletHolder.getServiceId(); - if (((servletDTO.patterns == null) || (servletDTO.patterns.length == 0)) && - (servletDTO.name == null)) { + if (((servletDTO.patterns == null) || (servletDTO.patterns.length == 0)) && (servletDTO.name == null)) { StringBuilder sb = new StringBuilder(); sb.append("One of the service properties "); //$NON-NLS-1$ @@ -470,21 +440,16 @@ private ServletRegistration doAddServletRegistration(ServiceHolder serv servletDTO.name = servletHolder.get().getClass().getName(); } - ServletContextHelper curServletContextHelper = getServletContextHelper( - servletHolder.getBundle()); + ServletContextHelper curServletContextHelper = getServletContextHelper(servletHolder.getBundle()); - ServletContext servletContext = createServletContext( - servletHolder.getBundle(), curServletContextHelper); - ServletRegistration servletRegistration = new ServletRegistration( - servletHolder, servletDTO, curServletContextHelper, this, - servletContext); - ServletConfig servletConfig = new ServletConfigImpl( - servletDTO.name, servletDTO.initParams, servletContext); + ServletContext servletContext = createServletContext(servletHolder.getBundle(), curServletContextHelper); + ServletRegistration servletRegistration = new ServletRegistration(servletHolder, servletDTO, + curServletContextHelper, this, servletContext); + ServletConfig servletConfig = new ServletConfigImpl(servletDTO.name, servletDTO.initParams, servletContext); try { servletRegistration.init(servletConfig); - } - catch (Throwable t) { + } catch (Throwable t) { servletRegistration.destroy(); return Throw.unchecked(t); @@ -511,17 +476,19 @@ private void recordEndpointShadowing(EndpointRegistration newRegistration) { else { shadowedRegs.add(newRegistration); } - // notice that we keep checking all the existing regs. more than one could be shadowed because reg's multi patterns + // notice that we keep checking all the existing regs. more than one could be + // shadowed because reg's multi patterns } } } } for (EndpointRegistration shadowedReg : shadowedRegs) { if (shadowedReg instanceof ServletRegistration) { - recordFailedServletDTO(shadowedReg.getServiceReference(), (ServletDTO)shadowedReg.getD(), DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); - } - else { - recordFailedResourceDTO(shadowedReg.getServiceReference(), (ResourceDTO)shadowedReg.getD(), DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); + recordFailedServletDTO(shadowedReg.getServiceReference(), (ServletDTO) shadowedReg.getD(), + DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); + } else { + recordFailedResourceDTO(shadowedReg.getServiceReference(), (ResourceDTO) shadowedReg.getD(), + DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); } } } @@ -532,14 +499,17 @@ private void recordErrorPageShadowing(ErrorPageRegistration newRegistration) { if (!(existingRegistration instanceof ErrorPageRegistration)) { continue; } - ErrorPageRegistration existingSRegistration = (ErrorPageRegistration)existingRegistration; + ErrorPageRegistration existingSRegistration = (ErrorPageRegistration) existingRegistration; ExtendedErrorPageDTO existingErrorPageDTO = existingSRegistration.getD(); - if ((existingErrorPageDTO == null) || - (((existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_4XX) || (existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_5XX)) && (newRegistration.getD().errorCodeType == ErrorCodeType.SPECIFIC))) { + if ((existingErrorPageDTO == null) || (((existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_4XX) + || (existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_5XX)) + && (newRegistration.getD().errorCodeType == ErrorCodeType.SPECIFIC))) { continue; } - if (((existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_4XX) && (newRegistration.getD().errorCodeType == ErrorCodeType.RANGE_4XX)) || - ((existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_5XX) && (newRegistration.getD().errorCodeType == ErrorCodeType.RANGE_5XX))) { + if (((existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_4XX) + && (newRegistration.getD().errorCodeType == ErrorCodeType.RANGE_4XX)) + || ((existingErrorPageDTO.errorCodeType == ErrorCodeType.RANGE_5XX) + && (newRegistration.getD().errorCodeType == ErrorCodeType.RANGE_5XX))) { if (newRegistration.compareTo(existingSRegistration) < 0) { shadowedEPs.add(existingSRegistration); } @@ -560,7 +530,8 @@ private void recordErrorPageShadowing(ErrorPageRegistration newRegistration) { else { shadowedEPs.add(newRegistration); } - // notice that we keep checking all the existing regs. more than one could be shadowed because reg's multi patterns + // notice that we keep checking all the existing regs. more than one could be + // shadowed because reg's multi patterns } } } @@ -575,13 +546,15 @@ private void recordErrorPageShadowing(ErrorPageRegistration newRegistration) { else { shadowedEPs.add(newRegistration); } - // notice that we keep checking all the existing regs. more than one could be shadowed because reg's multi patterns + // notice that we keep checking all the existing regs. more than one could be + // shadowed because reg's multi patterns } } } } for (ErrorPageRegistration shadowedReg : shadowedEPs) { - recordFailedErrorPageDTO(shadowedReg.getServiceReference(), shadowedReg.getD(), DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); + recordFailedErrorPageDTO(shadowedReg.getServiceReference(), shadowedReg.getD(), + DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); } } @@ -626,8 +599,7 @@ public String getContextPath() { return contextPath; } - public DispatchTargets getDispatchTargets( - String pathString, RequestInfoDTO requestInfoDTO) { + public DispatchTargets getDispatchTargets(String pathString, RequestInfoDTO requestInfoDTO) { Path path = new Path(pathString); @@ -635,36 +607,31 @@ public DispatchTargets getDispatchTargets( String requestURI = path.getRequestURI(); // perfect match - DispatchTargets dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.EXACT, requestInfoDTO); + DispatchTargets dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.EXACT, + requestInfoDTO); if (dispatchTargets == null) { // extension match - dispatchTargets = getDispatchTargets( - requestURI, path.getExtension(), queryString, Match.EXTENSION, - requestInfoDTO); + dispatchTargets = getDispatchTargets(requestURI, path.getExtension(), queryString, Match.EXTENSION, + requestInfoDTO); } if (dispatchTargets == null) { // regex match - dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.REGEX, requestInfoDTO); + dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.REGEX, requestInfoDTO); } if (dispatchTargets == null) { // handle '/' aliases - dispatchTargets = getDispatchTargets( - requestURI, null, queryString, Match.DEFAULT_SERVLET, - requestInfoDTO); + dispatchTargets = getDispatchTargets(requestURI, null, queryString, Match.DEFAULT_SERVLET, requestInfoDTO); } return dispatchTargets; } - private DispatchTargets getDispatchTargets( - String requestURI, String extension, String queryString, Match match, - RequestInfoDTO requestInfoDTO) { + private DispatchTargets getDispatchTargets(String requestURI, String extension, String queryString, Match match, + RequestInfoDTO requestInfoDTO) { int pos = requestURI.lastIndexOf('/'); @@ -677,9 +644,8 @@ private DispatchTargets getDispatchTargets( } do { - DispatchTargets dispatchTargets = getDispatchTargets( - null, requestURI, servletPath, pathInfo, - extension, queryString, match, requestInfoDTO); + DispatchTargets dispatchTargets = getDispatchTargets(null, requestURI, servletPath, pathInfo, extension, + queryString, match, requestInfoDTO); if (dispatchTargets != null) { return dispatchTargets; @@ -699,16 +665,13 @@ private DispatchTargets getDispatchTargets( } break; - } - while (true); + } while (true); return null; } - public DispatchTargets getDispatchTargets( - String servletName, String requestURI, String servletPath, - String pathInfo, String extension, String queryString, Match match, - RequestInfoDTO requestInfoDTO) { + public DispatchTargets getDispatchTargets(String servletName, String requestURI, String servletPath, + String pathInfo, String extension, String queryString, Match match, RequestInfoDTO requestInfoDTO) { checkShutdown(); @@ -730,13 +693,11 @@ public DispatchTargets getDispatchTargets( pathInfo = null; } - addEnpointRegistrationsToRequestInfo( - endpointRegistration, requestInfoDTO); + addEnpointRegistrationsToRequestInfo(endpointRegistration, requestInfoDTO); if (filterRegistrations.isEmpty()) { - return new DispatchTargets( - this, endpointRegistration, servletName, requestURI, servletPath, - pathInfo, queryString); + return new DispatchTargets(this, endpointRegistration, servletName, requestURI, servletPath, pathInfo, + queryString); } if (requestURI != null) { @@ -747,29 +708,23 @@ public DispatchTargets getDispatchTargets( } } - List matchingFilterRegistrations = - new ArrayList<>(); + List matchingFilterRegistrations = new ArrayList<>(); - collectFilters( - matchingFilterRegistrations, endpointRegistration.getName(), requestURI, - servletPath, pathInfo, extension); + collectFilters(matchingFilterRegistrations, endpointRegistration.getName(), requestURI, servletPath, pathInfo, + extension); - addFilterRegistrationsToRequestInfo( - matchingFilterRegistrations, requestInfoDTO); + addFilterRegistrationsToRequestInfo(matchingFilterRegistrations, requestInfoDTO); - return new DispatchTargets( - this, endpointRegistration, matchingFilterRegistrations, servletName, - requestURI, servletPath, pathInfo, queryString); + return new DispatchTargets(this, endpointRegistration, matchingFilterRegistrations, servletName, requestURI, + servletPath, pathInfo, queryString); } - private void collectFilters( - List matchingFilterRegistrations, - String servletName, String requestURI, String servletPath, String pathInfo, String extension) { + private void collectFilters(List matchingFilterRegistrations, String servletName, + String requestURI, String servletPath, String pathInfo, String extension) { for (FilterRegistration filterRegistration : filterRegistrations) { - if ((filterRegistration.match( - servletName, requestURI, extension, null) != null) && - !matchingFilterRegistrations.contains(filterRegistration)) { + if ((filterRegistration.match(servletName, requestURI, extension, null) != null) + && !matchingFilterRegistrations.contains(filterRegistration)) { matchingFilterRegistrations.add(filterRegistration); } @@ -800,7 +755,7 @@ public String getFullContextPath() { return fullContextPath = getFullContextPath0(); } - private String getFullContextPath0() { + private String getFullContextPath0() { List endpoints = httpServiceRuntime.getHttpServiceEndpoints(); if (endpoints.isEmpty()) { @@ -843,7 +798,7 @@ public long getServiceId() { return contextServiceId; } - public synchronized ServletContextDTO getServletContextDTO(){ + public synchronized ServletContextDTO getServletContextDTO() { ServletContextDTO servletContextDTO = new ServletContextDTO(); ServletContext servletContext = proxyContext.getServletContext(); @@ -862,15 +817,15 @@ public synchronized ServletContextDTO getServletContextDTO(){ } public boolean matches(ServiceReference whiteBoardService) { - // make sure the context helper is either one of the built-in ones registered by this http whiteboard implementation; + // make sure the context helper is either one of the built-in ones registered by + // this http whiteboard implementation; // or is visible to the whiteboard registering bundle. if (!visibleContextHelper(whiteBoardService)) { return false; } - String contextSelector = (String) whiteBoardService.getProperty( - HTTP_WHITEBOARD_CONTEXT_SELECT); + String contextSelector = (String) whiteBoardService.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT); // custom equinox behaviour if (contextName.equals(contextSelector)) { @@ -881,8 +836,8 @@ public boolean matches(ServiceReference whiteBoardService) { contextSelector = httpServiceRuntime.getDefaultContextSelectFilter(whiteBoardService); if (contextSelector == null) { contextSelector = "(" + //$NON-NLS-1$ - HTTP_WHITEBOARD_CONTEXT_NAME + "=" //$NON-NLS-1$ - + HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME + ")"; //$NON-NLS-1$ + HTTP_WHITEBOARD_CONTEXT_NAME + "=" //$NON-NLS-1$ + + HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME + ")"; //$NON-NLS-1$ } } @@ -891,8 +846,7 @@ public boolean matches(ServiceReference whiteBoardService) { try { targetFilter = FrameworkUtil.createFilter(contextSelector); - } - catch (InvalidSyntaxException ise) { + } catch (InvalidSyntaxException ise) { throw new IllegalArgumentException(ise); } @@ -906,17 +860,18 @@ public boolean matches(ServiceReference whiteBoardService) { private boolean visibleContextHelper(ServiceReference whiteBoardService) { if (consumingContext.getBundle().equals(serviceReference.getBundle())) { - Boolean defaultContextHelper = (Boolean) serviceReference.getProperty(Const.EQUINOX_HTTP_WHITEBOARD_CONTEXT_HELPER_DEFAULT); + Boolean defaultContextHelper = (Boolean) serviceReference + .getProperty(Const.EQUINOX_HTTP_WHITEBOARD_CONTEXT_HELPER_DEFAULT); if (defaultContextHelper == null) { return true; } } try { - if (whiteBoardService.getBundle().getBundleContext().getAllServiceReferences(ServletContextHelper.class.getName(), servletContextHelperRefFilter) != null) { + if (whiteBoardService.getBundle().getBundleContext().getAllServiceReferences( + ServletContextHelper.class.getName(), servletContextHelperRefFilter) != null) { return true; } - } - catch (InvalidSyntaxException e) { + } catch (InvalidSyntaxException e) { // ignore } return false; @@ -939,9 +894,8 @@ public String toString() { return value; } - private void addEnpointRegistrationsToRequestInfo( - EndpointRegistration endpointRegistration, - RequestInfoDTO requestInfoDTO) { + private void addEnpointRegistrationsToRequestInfo(EndpointRegistration endpointRegistration, + RequestInfoDTO requestInfoDTO) { if (requestInfoDTO == null) { return; @@ -950,18 +904,14 @@ private void addEnpointRegistrationsToRequestInfo( requestInfoDTO.servletContextId = getServiceId(); if (endpointRegistration instanceof ResourceRegistration) { - requestInfoDTO.resourceDTO = - (ResourceDTO)endpointRegistration.getD(); - } - else { - requestInfoDTO.servletDTO = - (ServletDTO)endpointRegistration.getD(); + requestInfoDTO.resourceDTO = (ResourceDTO) endpointRegistration.getD(); + } else { + requestInfoDTO.servletDTO = (ServletDTO) endpointRegistration.getD(); } } - private void addFilterRegistrationsToRequestInfo( - List matchedFilterRegistrations, - RequestInfoDTO requestInfoDTO) { + private void addFilterRegistrationsToRequestInfo(List matchedFilterRegistrations, + RequestInfoDTO requestInfoDTO) { if (requestInfoDTO == null) { return; @@ -978,8 +928,7 @@ private void addFilterRegistrationsToRequestInfo( requestInfoDTO.filterDTOs = filterDTOs.toArray(new FilterDTO[0]); } - private String[] asStringArray( - List> clazzes) { + private String[] asStringArray(List> clazzes) { String[] classesArray = new String[clazzes.size()]; @@ -1000,10 +949,9 @@ private String[] checkDispatcher(String[] dispatcher) { for (String type : dispatcher) { try { DispatcherType.valueOf(type); - } - catch (IllegalArgumentException iae) { - throw new HttpWhiteboardFailureException( - "Invalid dispatcher '" + type + "'", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (IllegalArgumentException iae) { + throw new HttpWhiteboardFailureException("Invalid dispatcher '" + type + "'", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } } @@ -1014,7 +962,8 @@ private String[] checkDispatcher(String[] dispatcher) { public static void checkPattern(String pattern) { if (pattern == null) { - throw new HttpWhiteboardFailureException("Pattern cannot be null", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Pattern cannot be null", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } if (pattern.indexOf("*.") == 0) { //$NON-NLS-1$ @@ -1029,45 +978,45 @@ public static void checkPattern(String pattern) { return; } - if (!pattern.startsWith(Const.SLASH) || - (pattern.endsWith(Const.SLASH) && !pattern.equals(Const.SLASH)) || - pattern.contains("**")) { //$NON-NLS-1$ + if (!pattern.startsWith(Const.SLASH) || (pattern.endsWith(Const.SLASH) && !pattern.equals(Const.SLASH)) + || pattern.contains("**")) { //$NON-NLS-1$ - throw new HttpWhiteboardFailureException( - "Invalid pattern '" + pattern + "'", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ //$NON-NLS-2$ + throw new HttpWhiteboardFailureException("Invalid pattern '" + pattern + "'", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } } private static void checkPrefix(Object prefixObj) { if (prefixObj == null) { - throw new HttpWhiteboardFailureException("Prefix cannot be null.", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Prefix cannot be null.", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } if (!(prefixObj instanceof String)) { - throw new HttpWhiteboardFailureException("Prefix must be String.", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Prefix must be String.", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - String prefix = (String)prefixObj; + String prefix = (String) prefixObj; if (prefix.endsWith(Const.SLASH) && !prefix.equals(Const.SLASH)) { - throw new HttpWhiteboardFailureException("Invalid prefix '" + prefix + "'", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ //$NON-NLS-2$ + throw new HttpWhiteboardFailureException("Invalid prefix '" + prefix + "'", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } } private static void checkRegex(String regex) { try { Pattern.compile(regex); - } - catch (PatternSyntaxException pse) { - throw new HttpWhiteboardFailureException( - "Invalid regex '" + regex + "'", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (PatternSyntaxException pse) { + throw new HttpWhiteboardFailureException("Invalid regex '" + regex + "'", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } } public synchronized void checkShutdown() { if (shutdown) { - throw new IllegalStateException( - "Context is already shutdown"); //$NON-NLS-1$ + throw new IllegalStateException("Context is already shutdown"); //$NON-NLS-1$ } } @@ -1081,18 +1030,15 @@ private static String createFilter(long contextServiceId) { return filterBuilder.toString(); } - private ServletContext createServletContext( - Bundle curBundle, ServletContextHelper curServletContextHelper) { + private ServletContext createServletContext(Bundle curBundle, ServletContextHelper curServletContextHelper) { - ServletContextAdaptor adaptor = new ServletContextAdaptor( - this, curBundle, curServletContextHelper, eventListeners, - AccessController.getContext()); + ServletContextAdaptor adaptor = new ServletContextAdaptor(this, curBundle, curServletContextHelper, + eventListeners, AccessController.getContext()); return adaptor.createServletContext(); } - private void collectEndpointDTOs( - ServletContextDTO servletContextDTO) { + private void collectEndpointDTOs(ServletContextDTO servletContextDTO) { List errorPageDTOs = new ArrayList<>(); List resourceDTOs = new ArrayList<>(); @@ -1101,17 +1047,15 @@ private void collectEndpointDTOs( for (EndpointRegistration endpointRegistration : endpointRegistrations) { if (endpointRegistration instanceof ResourceRegistration) { if (!httpServiceRuntime.isFailedResourceDTO(endpointRegistration.getServiceReference())) { - resourceDTOs.add(DTOUtil.clone((ResourceDTO)endpointRegistration.getD())); + resourceDTOs.add(DTOUtil.clone((ResourceDTO) endpointRegistration.getD())); } - } - else if (endpointRegistration instanceof ErrorPageRegistration) { + } else if (endpointRegistration instanceof ErrorPageRegistration) { if (!httpServiceRuntime.isFailedErrorPageDTO(endpointRegistration.getServiceReference())) { - errorPageDTOs.add(DTOUtil.clone((ExtendedErrorPageDTO)endpointRegistration.getD())); + errorPageDTOs.add(DTOUtil.clone((ExtendedErrorPageDTO) endpointRegistration.getD())); } - } - else { + } else { if (!httpServiceRuntime.isFailedServletDTO(endpointRegistration.getServiceReference())) { - servletDTOs.add(DTOUtil.clone((ServletDTO)endpointRegistration.getD())); + servletDTOs.add(DTOUtil.clone((ServletDTO) endpointRegistration.getD())); } } } @@ -1121,8 +1065,7 @@ else if (endpointRegistration instanceof ErrorPageRegistration) { servletContextDTO.servletDTOs = servletDTOs.toArray(new ServletDTO[0]); } - private void collectFilterDTOs( - ServletContextDTO servletContextDTO) { + private void collectFilterDTOs(ServletContextDTO servletContextDTO) { List filterDTOs = new ArrayList<>(); @@ -1133,8 +1076,7 @@ private void collectFilterDTOs( servletContextDTO.filterDTOs = filterDTOs.toArray(new FilterDTO[0]); } - private void collectListenerDTOs( - ServletContextDTO servletContextDTO) { + private void collectListenerDTOs(ServletContextDTO servletContextDTO) { List listenerDTOs = new ArrayList<>(); @@ -1148,8 +1090,7 @@ private void collectListenerDTOs( private Map getDTOAttributes(ServletContext servletContext) { Map map = new HashMap<>(); - for (Enumeration names = servletContext.getAttributeNames(); - names.hasMoreElements();) { + for (Enumeration names = servletContext.getAttributeNames(); names.hasMoreElements();) { String name = names.nextElement(); @@ -1159,13 +1100,11 @@ private Map getDTOAttributes(ServletContext servletContext) { return Collections.unmodifiableMap(map); } - private List> getListenerClasses( - ServiceReference listenerReference) { + private List> getListenerClasses(ServiceReference listenerReference) { List objectClassList = StringPlus.from(listenerReference.getProperty(Constants.OBJECTCLASS)); - List> classes = - new ArrayList<>(); + List> classes = new ArrayList<>(); if (objectClassList.contains(ServletContextListener.class.getName())) { classes.add(ServletContextListener.class); @@ -1224,8 +1163,7 @@ private String[] sort(String[] values) { } private void flushActiveSessions() { - Collection httpSessionAdaptors = - activeSessions.values(); + Collection httpSessionAdaptors = activeSessions.values(); Iterator iterator = httpSessionAdaptors.iterator(); @@ -1255,7 +1193,8 @@ public void fireSessionIdChanged(String oldSessionId) { return; } - List listeners = eventListeners.get(javax.servlet.http.HttpSessionIdListener.class); + List listeners = eventListeners + .get(javax.servlet.http.HttpSessionIdListener.class); if (listeners.isEmpty()) { return; @@ -1269,8 +1208,7 @@ public void fireSessionIdChanged(String oldSessionId) { } } - public HttpSessionAdaptor getSessionAdaptor( - HttpSession session, ServletContext servletContext) { + public HttpSessionAdaptor getSessionAdaptor(HttpSession session, ServletContext servletContext) { String sessionId = session.getId(); @@ -1280,11 +1218,9 @@ public HttpSessionAdaptor getSessionAdaptor( return httpSessionAdaptor; } - httpSessionAdaptor = HttpSessionAdaptor.createHttpSessionAdaptor( - session, servletContext, this); + httpSessionAdaptor = HttpSessionAdaptor.createHttpSessionAdaptor(session, servletContext, this); - HttpSessionAdaptor previousHttpSessionAdaptor = - addSessionAdaptor(sessionId, httpSessionAdaptor); + HttpSessionAdaptor previousHttpSessionAdaptor = addSessionAdaptor(sessionId, httpSessionAdaptor); if (previousHttpSessionAdaptor != null) { return previousHttpSessionAdaptor; @@ -1296,8 +1232,7 @@ public HttpSessionAdaptor getSessionAdaptor( return httpSessionAdaptor; } - HttpSessionEvent httpSessionEvent = new HttpSessionEvent( - httpSessionAdaptor); + HttpSessionEvent httpSessionEvent = new HttpSessionEvent(httpSessionAdaptor); for (HttpSessionListener listener : listeners) { listener.sessionCreated(httpSessionEvent); @@ -1306,11 +1241,9 @@ public HttpSessionAdaptor getSessionAdaptor( return httpSessionAdaptor; } - public HttpSessionAdaptor addSessionAdaptor( - String sessionId, HttpSessionAdaptor httpSessionAdaptor) { + public HttpSessionAdaptor addSessionAdaptor(String sessionId, HttpSessionAdaptor httpSessionAdaptor) { - HttpSessionAdaptor previousHttpSessionAdaptor = - activeSessions.putIfAbsent(sessionId, httpSessionAdaptor); + HttpSessionAdaptor previousHttpSessionAdaptor = activeSessions.putIfAbsent(sessionId, httpSessionAdaptor); if (previousHttpSessionAdaptor != null) { return previousHttpSessionAdaptor; @@ -1321,8 +1254,8 @@ public HttpSessionAdaptor addSessionAdaptor( return null; } - public void recordFailedErrorPageDTO( - ServiceReference servletReference, ExtendedErrorPageDTO errorPageDTO, int failureReason) { + public void recordFailedErrorPageDTO(ServiceReference servletReference, ExtendedErrorPageDTO errorPageDTO, + int failureReason) { FailedErrorPageDTO failedErrorPageDTO = new FailedErrorPageDTO(); failedErrorPageDTO.asyncSupported = errorPageDTO.asyncSupported; @@ -1338,8 +1271,8 @@ public void recordFailedErrorPageDTO( getHttpServiceRuntime().recordFailedErrorPageDTO(servletReference, failedErrorPageDTO); } - public void recordFailedResourceDTO( - ServiceReference resourceReference, ResourceDTO resourceDTO, int failureReason) { + public void recordFailedResourceDTO(ServiceReference resourceReference, ResourceDTO resourceDTO, + int failureReason) { FailedResourceDTO failedResourceDTO = new FailedResourceDTO(); failedResourceDTO.failureReason = failureReason; @@ -1375,33 +1308,32 @@ private String validateName() { Object contextNameObj = serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_NAME); if (contextNameObj == null) { - throw new IllegalContextNameException( - HTTP_WHITEBOARD_CONTEXT_NAME + " is null. Ignoring!", //$NON-NLS-1$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); - } - else if (!(contextNameObj instanceof String)) { - throw new IllegalContextNameException( - HTTP_WHITEBOARD_CONTEXT_NAME + " is not String. Ignoring!", //$NON-NLS-1$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + throw new IllegalContextNameException(HTTP_WHITEBOARD_CONTEXT_NAME + " is null. Ignoring!", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + } else if (!(contextNameObj instanceof String)) { + throw new IllegalContextNameException(HTTP_WHITEBOARD_CONTEXT_NAME + " is not String. Ignoring!", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - String name = (String)contextNameObj; + String name = (String) contextNameObj; if (!contextNamePattern.matcher(name).matches()) { throw new IllegalContextNameException( - "The context name '" + name + "' does not follow Bundle-SymbolicName syntax.", //$NON-NLS-1$ //$NON-NLS-2$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + "The context name '" + name + "' does not follow Bundle-SymbolicName syntax.", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } // Now check for naming conflicts for (ContextController existingContext : httpServiceRuntime.getContextControllers()) { if (name.equals(existingContext.getContextName())) { if (serviceReference.compareTo(existingContext.serviceReference) < 0) { - throw new HttpWhiteboardFailureException("Context with same name exists. " + serviceReference, DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Context with same name exists. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - httpServiceRuntime.recordFailedServletContextDTO( - existingContext.serviceReference, (Long)serviceReference.getProperty(Constants.SERVICE_ID), DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); + httpServiceRuntime.recordFailedServletContextDTO(existingContext.serviceReference, + (Long) serviceReference.getProperty(Constants.SERVICE_ID), + DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE); } } @@ -1412,26 +1344,21 @@ private String validatePath() { Object contextPathObj = serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_PATH); if (contextPathObj == null) { - throw new IllegalContextPathException( - HTTP_WHITEBOARD_CONTEXT_PATH + " is null. Ignoring!", //$NON-NLS-1$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); - } - else if (!(contextPathObj instanceof String)) { - throw new IllegalContextPathException( - HTTP_WHITEBOARD_CONTEXT_PATH + " is not String. Ignoring!", //$NON-NLS-1$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + throw new IllegalContextPathException(HTTP_WHITEBOARD_CONTEXT_PATH + " is null. Ignoring!", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + } else if (!(contextPathObj instanceof String)) { + throw new IllegalContextPathException(HTTP_WHITEBOARD_CONTEXT_PATH + " is not String. Ignoring!", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - String path = (String)contextPathObj; + String path = (String) contextPathObj; try { @SuppressWarnings("unused") URI uri = new URI(Const.HTTP, Const.LOCALHOST, path, null); - } - catch (URISyntaxException use) { - throw new IllegalContextPathException( - "The context path '" + path + "' is not valid URI path syntax.", //$NON-NLS-1$ //$NON-NLS-2$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + } catch (URISyntaxException use) { + throw new IllegalContextPathException("The context path '" + path + "' is not valid URI path syntax.", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } path = httpServiceRuntime.adaptContextPath(path, serviceReference); @@ -1442,8 +1369,7 @@ else if (!(contextPathObj instanceof String)) { return path; } - private static final String[] DISPATCHER = - new String[] {DispatcherType.REQUEST.toString()}; + private static final String[] DISPATCHER = new String[] { DispatcherType.REQUEST.toString() }; private static final String SIMPLE_NAME = ContextController.class.getSimpleName(); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java index b4ae180c3d7..762b0f809dc 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java @@ -33,22 +33,16 @@ */ public class DispatchTargets { - public DispatchTargets( - ContextController contextController, - EndpointRegistration endpointRegistration, String servletName, - String requestURI, String servletPath, String pathInfo, String queryString) { - - this( - contextController, endpointRegistration, - Collections.emptyList(), servletName, requestURI, - servletPath, pathInfo, queryString); + public DispatchTargets(ContextController contextController, EndpointRegistration endpointRegistration, + String servletName, String requestURI, String servletPath, String pathInfo, String queryString) { + + this(contextController, endpointRegistration, Collections.emptyList(), servletName, + requestURI, servletPath, pathInfo, queryString); } - public DispatchTargets( - ContextController contextController, - EndpointRegistration endpointRegistration, - List matchingFilterRegistrations, String servletName, - String requestURI, String servletPath, String pathInfo, String queryString) { + public DispatchTargets(ContextController contextController, EndpointRegistration endpointRegistration, + List matchingFilterRegistrations, String servletName, String requestURI, + String servletPath, String pathInfo, String queryString) { this.contextController = contextController; this.endpointRegistration = endpointRegistration; @@ -64,15 +58,14 @@ public void addRequestParameters(HttpServletRequest request) { currentRequest = request; } - public void doDispatch( - HttpServletRequest originalRequest, HttpServletResponse response, - String path, DispatcherType requestedDispatcherType) - throws ServletException, IOException { + public void doDispatch(HttpServletRequest originalRequest, HttpServletResponse response, String path, + DispatcherType requestedDispatcherType) throws ServletException, IOException { setDispatcherType(requestedDispatcherType); HttpServletRequest request = originalRequest; - HttpServletRequestWrapperImpl requestWrapper = HttpServletRequestWrapperImpl.findHttpRuntimeRequest(originalRequest); + HttpServletRequestWrapperImpl requestWrapper = HttpServletRequestWrapperImpl + .findHttpRuntimeRequest(originalRequest); HttpServletResponseWrapper responseWrapper = HttpServletResponseWrapperImpl.findHttpRuntimeResponse(response); boolean includeWrapperAdded = false; @@ -84,8 +77,7 @@ public void doDispatch( setter.setAttribute(RequestDispatcher.INCLUDE_QUERY_STRING, getQueryString()); setter.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI, getRequestURI()); setter.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, getServletPath()); - } - else if (dispatcherType == DispatcherType.FORWARD) { + } else if (dispatcherType == DispatcherType.FORWARD) { response.resetBuffer(); setter.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH, originalRequest.getContextPath()); @@ -107,20 +99,24 @@ else if (dispatcherType == DispatcherType.FORWARD) { requestWrapper.push(this); - if ((dispatcherType == DispatcherType.INCLUDE) && !(responseWrapper.getResponse() instanceof IncludeDispatchResponseWrapper)) { + if ((dispatcherType == DispatcherType.INCLUDE) + && !(responseWrapper.getResponse() instanceof IncludeDispatchResponseWrapper)) { // add the include wrapper to avoid header and status writes - responseWrapper.setResponse(new IncludeDispatchResponseWrapper((HttpServletResponse)responseWrapper.getResponse())); + responseWrapper.setResponse( + new IncludeDispatchResponseWrapper((HttpServletResponse) responseWrapper.getResponse())); includeWrapperAdded = true; } ResponseStateHandler responseStateHandler = new ResponseStateHandler(request, response, this); responseStateHandler.processRequest(); - } - finally { - if ((dispatcherType == DispatcherType.INCLUDE) && (responseWrapper.getResponse() instanceof IncludeDispatchResponseWrapper) && includeWrapperAdded) { + } finally { + if ((dispatcherType == DispatcherType.INCLUDE) + && (responseWrapper.getResponse() instanceof IncludeDispatchResponseWrapper) + && includeWrapperAdded) { // remove the include wrapper we added - responseWrapper.setResponse(((IncludeDispatchResponseWrapper)responseWrapper.getResponse()).getResponse()); + responseWrapper + .setResponse(((IncludeDispatchResponseWrapper) responseWrapper.getResponse()).getResponse()); } requestWrapper.pop(); @@ -199,7 +195,8 @@ public String toString() { String value = string; if (value == null) { - value = SIMPLE_NAME + '[' + contextController.getFullContextPath() + requestURI + (queryString != null ? '?' + queryString : "") + ", " + endpointRegistration.toString() + ']'; //$NON-NLS-1$ //$NON-NLS-2$ + value = SIMPLE_NAME + '[' + contextController.getFullContextPath() + requestURI + + (queryString != null ? '?' + queryString : "") + ", " + endpointRegistration.toString() + ']'; //$NON-NLS-1$ //$NON-NLS-2$ string = value; } @@ -217,18 +214,21 @@ private static Map queryStringToParameterMap(String queryStrin String[] parameters = queryString.split(Const.AMP); for (String parameter : parameters) { int index = parameter.indexOf('='); - String name = (index > 0) ? URLDecoder.decode(parameter.substring(0, index), StandardCharsets.UTF_8.name()) : parameter; + String name = (index > 0) + ? URLDecoder.decode(parameter.substring(0, index), StandardCharsets.UTF_8.name()) + : parameter; String[] values = parameterMap.get(name); if (values == null) { values = new String[0]; } - String value = ((index > 0) && (parameter.length() > index + 1)) ? URLDecoder.decode(parameter.substring(index + 1), StandardCharsets.UTF_8.name()) : ""; //$NON-NLS-1$ + String value = ((index > 0) && (parameter.length() > index + 1)) + ? URLDecoder.decode(parameter.substring(index + 1), StandardCharsets.UTF_8.name()) + : ""; //$NON-NLS-1$ values = Params.append(values, value); parameterMap.put(name, values); } return parameterMap; - } - catch (UnsupportedEncodingException unsupportedEncodingException) { + } catch (UnsupportedEncodingException unsupportedEncodingException) { throw new RuntimeException(unsupportedEncodingException); } } @@ -253,8 +253,7 @@ public void close() { for (Map.Entry oldValue : oldValues.entrySet()) { if (oldValue.getValue() == null) { servletRequest.removeAttribute(oldValue.getKey()); - } - else { + } else { servletRequest.setAttribute(oldValue.getKey(), oldValue.getValue()); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java index 98fb3a5e5ad..97c576a4fd1 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java @@ -25,18 +25,21 @@ import org.eclipse.equinox.http.servlet.internal.util.Const; /** - * The ProxyContext provides something similar to a ServletContext for all servlets and resources under a particular ProxyServlet. - * In particular it holds and represent the concept of "context path" through the Proxy Servlets servlet path. - * The Http Service also requires a ServletContext namespaced by each individual HttpContext. The ProxyContext provides support for the - * attribute map of a ServletContext again namespaced by HttpContext as specified in the Http Service specification. The ContextAttributes - * are reference counted so that when the HttpContext is no longer referenced the associated context attributes can be - * garbage collected and the context temp dir deleteted. + * The ProxyContext provides something similar to a ServletContext for all + * servlets and resources under a particular ProxyServlet. In particular it + * holds and represent the concept of "context path" through the Proxy Servlets + * servlet path. The Http Service also requires a ServletContext namespaced by + * each individual HttpContext. The ProxyContext provides support for the + * attribute map of a ServletContext again namespaced by HttpContext as + * specified in the Http Service specification. The ContextAttributes are + * reference counted so that when the HttpContext is no longer referenced the + * associated context attributes can be garbage collected and the context temp + * dir deleteted. */ public class ProxyContext { private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$ - private final ConcurrentMap attributesMap = - new ConcurrentHashMap<>(); + private final ConcurrentMap attributesMap = new ConcurrentHashMap<>(); File proxyContextTempDir; private ServletContext servletContext; @@ -60,8 +63,7 @@ public String getServletPath() { return Const.BLANK; } - public void createContextAttributes( - ContextController controller) { + public void createContextAttributes(ContextController controller) { synchronized (attributesMap) { ContextAttributes contextAttributes = attributesMap.get(controller); @@ -76,8 +78,7 @@ public void createContextAttributes( } } - public void destroyContextAttributes( - ContextController controller) { + public void destroyContextAttributes(ContextController controller) { synchronized (attributesMap) { ContextAttributes contextAttributes = attributesMap.get(controller); @@ -93,8 +94,7 @@ public void destroyContextAttributes( } } - public Dictionary getContextAttributes( - ContextController controller) { + public Dictionary getContextAttributes(ContextController controller) { return attributesMap.get(controller); } @@ -105,6 +105,7 @@ public ServletContext getServletContext() { /** * deleteDirectory is a convenience method to recursively delete a directory + * * @param directory - the directory to delete. * @return was the delete succesful */ @@ -122,17 +123,14 @@ protected static boolean deleteDirectory(File directory) { return directory.delete(); } - public static class ContextAttributes - extends Dictionary implements Serializable { + public static class ContextAttributes extends Dictionary implements Serializable { private static final long serialVersionUID = 1916670423277243587L; private final AtomicInteger referenceCount = new AtomicInteger(); public ContextAttributes(ContextController controller, File proxyContextTempDir) { if (proxyContextTempDir != null) { - File contextTempDir = new File( - proxyContextTempDir, - "hc_" + controller.hashCode()); //$NON-NLS-1$ + File contextTempDir = new File(proxyContextTempDir, "hc_" + controller.hashCode()); //$NON-NLS-1$ contextTempDir.mkdirs(); @@ -193,8 +191,7 @@ public int size() { return _map.size(); } - private final Map _map = - new ConcurrentHashMap<>(); + private final Map _map = new ConcurrentHashMap<>(); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java index f23acfa487a..d4df9892e58 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ServiceHolder.java @@ -32,15 +32,16 @@ public ServiceHolder(ServiceObjects serviceObjects) { this.serviceObjects = serviceObjects; this.bundle = serviceObjects.getServiceReference().getBundle(); this.service = serviceObjects.getService(); - this.legacyTCCL = (ClassLoader)serviceObjects.getServiceReference().getProperty(Const.EQUINOX_LEGACY_TCCL_PROP); - Long serviceIdProp = (Long)serviceObjects.getServiceReference().getProperty(Constants.SERVICE_ID); + this.legacyTCCL = (ClassLoader) serviceObjects.getServiceReference() + .getProperty(Const.EQUINOX_LEGACY_TCCL_PROP); + Long serviceIdProp = (Long) serviceObjects.getServiceReference().getProperty(Constants.SERVICE_ID); if (legacyTCCL != null) { // this is a legacy registration; use a negative id for the DTO serviceIdProp = -serviceIdProp; } this.serviceId = serviceIdProp; Object rankProp = serviceObjects.getServiceReference().getProperty(Constants.SERVICE_RANKING); - this.serviceRanking = !Integer.class.isInstance(rankProp) ? 0 : ((Integer)rankProp).intValue(); + this.serviceRanking = !Integer.class.isInstance(rankProp) ? 0 : ((Integer) rankProp).intValue(); } public ServiceHolder(S service, Bundle bundle, long serviceId, int serviceRanking, ClassLoader legacyTCCL) { @@ -76,8 +77,7 @@ public void release() { // this can happen if the whiteboard bundle is in the process of stopping // and the framework is in the middle of auto-unregistering any services // the bundle forgot to unregister on stop - } - finally { + } finally { released = true; } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java index 6ace6548a6d..990d0827cae 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/WrappedHttpContext.java @@ -36,9 +36,7 @@ public WrappedHttpContext(HttpContext httpContext, Bundle bundle) { } @Override - public boolean handleSecurity( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException { return httpContext.handleSecurity(request, response); } @@ -58,8 +56,7 @@ public Set getResourcePaths(String path) { return null; } - final Enumeration enumeration = bundle.findEntries( - path, null, false); + final Enumeration enumeration = bundle.findEntries(path, null, false); if (enumeration == null) { return null; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextErrorPageTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextErrorPageTrackerCustomizer.java index f5e4034e5c4..5bf7958fabe 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextErrorPageTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextErrorPageTrackerCustomizer.java @@ -34,18 +34,16 @@ * @author Raymond Augé */ public class ContextErrorPageTrackerCustomizer - extends RegistrationServiceTrackerCustomizer{ + extends RegistrationServiceTrackerCustomizer { - public ContextErrorPageTrackerCustomizer( - BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, - ContextController contextController) { + public ContextErrorPageTrackerCustomizer(BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, + ContextController contextController) { super(bundleContext, httpServiceRuntime, contextController); } @Override - public AtomicReference - addingService(ServiceReference serviceReference) { + public AtomicReference addingService(ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!httpServiceRuntime.matches(serviceReference)) { @@ -57,41 +55,41 @@ public ContextErrorPageTrackerCustomizer( if (!contextController.matches(serviceReference)) { // Only the default context will perform the "does anyone match" checks. - if (httpServiceRuntime.isDefaultContext(contextController) && - !httpServiceRuntime.matchesAnyContext(serviceReference)) { + if (httpServiceRuntime.isDefaultContext(contextController) + && !httpServiceRuntime.matchesAnyContext(serviceReference)) { - throw new HttpWhiteboardFailureException( - "Doesn't match any contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Doesn't match any contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } return result; - } - else if (contextController.isLegacyContext() && - (serviceReference.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP) == null) && // IS a whiteboard service - (serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT) != null) && - (((String)serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT))).contains(HTTP_SERVICE_CONTEXT_PROPERTY.concat(Const.EQUAL)) && - (serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_PATTERN) != null)) { - - // don't allow whiteboard Servlets that specifically attempt to bind to a legacy context + } else if (contextController.isLegacyContext() + && (serviceReference.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP) == null) && // IS a whiteboard + // service + (serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT) != null) + && (((String) serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT))) + .contains(HTTP_SERVICE_CONTEXT_PROPERTY.concat(Const.EQUAL)) + && (serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_PATTERN) != null)) { + + // don't allow whiteboard Servlets that specifically attempt to bind to a legacy + // context throw new HttpWhiteboardFailureException( - "Whiteboard ErrorPages with pattern cannot bind to legacy contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + "Whiteboard ErrorPages with pattern cannot bind to legacy contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } httpServiceRuntime.removeFailedErrorPageDTO(serviceReference); result.set(contextController.addErrorPageRegistration(serviceReference)); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { httpServiceRuntime.debug(hwfe.getMessage(), hwfe); recordFailed(serviceReference, hwfe.getFailureReason()); - } - catch (Throwable t) { + } catch (Throwable t) { httpServiceRuntime.error(t.getMessage(), t); recordFailed(serviceReference, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } @@ -104,7 +102,8 @@ void removeFailed(ServiceReference serviceReference) { } void recordFailed(ServiceReference servletReference, int failureReason) { - ExtendedErrorPageDTO errorPageDTO = DTOUtil.assembleErrorPageDTO(servletReference, contextController.getServiceId(), false); + ExtendedErrorPageDTO errorPageDTO = DTOUtil.assembleErrorPageDTO(servletReference, + contextController.getServiceId(), false); contextController.recordFailedErrorPageDTO(servletReference, errorPageDTO, failureReason); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextFilterTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextFilterTrackerCustomizer.java index ba0c225bbcc..7f66e5c8c95 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextFilterTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextFilterTrackerCustomizer.java @@ -29,19 +29,16 @@ /** * @author Raymond Augé */ -public class ContextFilterTrackerCustomizer - extends RegistrationServiceTrackerCustomizer { +public class ContextFilterTrackerCustomizer extends RegistrationServiceTrackerCustomizer { - public ContextFilterTrackerCustomizer( - BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, - ContextController contextController) { + public ContextFilterTrackerCustomizer(BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, + ContextController contextController) { super(bundleContext, httpServiceRuntime, contextController); } @Override - public AtomicReference addingService( - ServiceReference serviceReference) { + public AtomicReference addingService(ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!httpServiceRuntime.matches(serviceReference)) { @@ -53,11 +50,11 @@ public AtomicReference addingService( if (!contextController.matches(serviceReference)) { // Only the default context will perform the "does anyone match" checks. - if (httpServiceRuntime.isDefaultContext(contextController) && - !httpServiceRuntime.matchesAnyContext(serviceReference)) { + if (httpServiceRuntime.isDefaultContext(contextController) + && !httpServiceRuntime.matchesAnyContext(serviceReference)) { - throw new HttpWhiteboardFailureException( - "Doesn't match any contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Doesn't match any contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } return result; @@ -66,18 +63,15 @@ public AtomicReference addingService( httpServiceRuntime.removeFailedFilterDTO(serviceReference); result.set(contextController.addFilterRegistration(serviceReference)); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { httpServiceRuntime.debug(hwfe.getMessage(), hwfe); recordFailed(serviceReference, hwfe.getFailureReason()); - } - catch (Throwable t) { + } catch (Throwable t) { httpServiceRuntime.error(t.getMessage(), t); recordFailed(serviceReference, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } @@ -89,27 +83,31 @@ void removeFailed(ServiceReference serviceReference) { contextController.getHttpServiceRuntime().removeFailedFilterDTO(serviceReference); } - private void recordFailed( - ServiceReference serviceReference, int failureReason) { + private void recordFailed(ServiceReference serviceReference, int failureReason) { FailedFilterDTO failedFilterDTO = new FailedFilterDTO(); failedFilterDTO.asyncSupported = BooleanPlus.from( - serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_ASYNC_SUPPORTED), false); - failedFilterDTO.dispatcher = StringPlus.from( - serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER)).toArray(new String[0]); + serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_ASYNC_SUPPORTED), false); + failedFilterDTO.dispatcher = StringPlus + .from(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER)) + .toArray(new String[0]); failedFilterDTO.failureReason = failureReason; - failedFilterDTO.initParams = ServiceProperties.parseInitParams( - serviceReference, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_INIT_PARAM_PREFIX); - failedFilterDTO.name = (String)serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME); - failedFilterDTO.patterns = StringPlus.from( - serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN)).toArray(new String[0]); - failedFilterDTO.regexs = StringPlus.from( - serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX)).toArray(new String[0]); - failedFilterDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + failedFilterDTO.initParams = ServiceProperties.parseInitParams(serviceReference, + HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_INIT_PARAM_PREFIX); + failedFilterDTO.name = (String) serviceReference + .getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME); + failedFilterDTO.patterns = StringPlus + .from(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN)) + .toArray(new String[0]); + failedFilterDTO.regexs = StringPlus + .from(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX)) + .toArray(new String[0]); + failedFilterDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); failedFilterDTO.servletContextId = contextController.getServiceId(); - failedFilterDTO.servletNames = StringPlus.from( - serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_SERVLET)).toArray(new String[0]); + failedFilterDTO.servletNames = StringPlus + .from(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_SERVLET)) + .toArray(new String[0]); contextController.getHttpServiceRuntime().recordFailedFilterDTO(serviceReference, failedFilterDTO); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextListenerTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextListenerTrackerCustomizer.java index ad0a7ec58e7..50ed8fdba0e 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextListenerTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextListenerTrackerCustomizer.java @@ -30,18 +30,16 @@ * @author Raymond Augé */ public class ContextListenerTrackerCustomizer - extends RegistrationServiceTrackerCustomizer { + extends RegistrationServiceTrackerCustomizer { - public ContextListenerTrackerCustomizer( - BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, - ContextController contextController) { + public ContextListenerTrackerCustomizer(BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, + ContextController contextController) { super(bundleContext, httpServiceRuntime, contextController); } @Override - public AtomicReference addingService( - ServiceReference serviceReference) { + public AtomicReference addingService(ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!httpServiceRuntime.matches(serviceReference)) { @@ -53,11 +51,11 @@ public AtomicReference addingService( if (!contextController.matches(serviceReference)) { // Only the default context will perform the "does anyone match" checks. - if (httpServiceRuntime.isDefaultContext(contextController) && - !httpServiceRuntime.matchesAnyContext(serviceReference)) { + if (httpServiceRuntime.isDefaultContext(contextController) + && !httpServiceRuntime.matchesAnyContext(serviceReference)) { - throw new HttpWhiteboardFailureException( - "Doesn't match any contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Doesn't match any contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } return result; @@ -67,40 +65,36 @@ public AtomicReference addingService( Object listenerObj = serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER); - if (!(listenerObj instanceof Boolean) && - !"true".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ - !"false".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ - !"1".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ - !"0".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ - !"yes".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ - !"no".equalsIgnoreCase(String.valueOf(listenerObj)) //$NON-NLS-1$ - ) { + if (!(listenerObj instanceof Boolean) && !"true".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ + !"false".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ + !"1".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ + !"0".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ + !"yes".equalsIgnoreCase(String.valueOf(listenerObj)) && //$NON-NLS-1$ + !"no".equalsIgnoreCase(String.valueOf(listenerObj)) //$NON-NLS-1$ + ) { throw new HttpWhiteboardFailureException( - HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER + "=" + listenerObj + " is not a valid option. Ignoring!", //$NON-NLS-1$ //$NON-NLS-2$ - DTOConstants.FAILURE_REASON_VALIDATION_FAILED); + HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER + "=" + listenerObj //$NON-NLS-1$ + + " is not a valid option. Ignoring!", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - if (Boolean.FALSE.equals(listenerObj) || - "false".equalsIgnoreCase(String.valueOf(listenerObj)) || //$NON-NLS-1$ - "0".equalsIgnoreCase(String.valueOf(listenerObj)) || //$NON-NLS-1$ - "no".equalsIgnoreCase(String.valueOf(listenerObj))) { //$NON-NLS-1$ + if (Boolean.FALSE.equals(listenerObj) || "false".equalsIgnoreCase(String.valueOf(listenerObj)) || //$NON-NLS-1$ + "0".equalsIgnoreCase(String.valueOf(listenerObj)) || //$NON-NLS-1$ + "no".equalsIgnoreCase(String.valueOf(listenerObj))) { //$NON-NLS-1$ // Asks to be ignored. return result; } result.set(contextController.addListenerRegistration(serviceReference)); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { httpServiceRuntime.debug(hwfe.getMessage(), hwfe); recordFailed(serviceReference, hwfe.getFailureReason()); - } - catch (Throwable t) { + } catch (Throwable t) { httpServiceRuntime.error(t.getMessage(), t); recordFailed(serviceReference, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } @@ -112,16 +106,15 @@ void removeFailed(ServiceReference serviceReference) { contextController.getHttpServiceRuntime().removeFailedListenerDTO(serviceReference); } - private void recordFailed( - ServiceReference serviceReference, int failureReason) { + private void recordFailed(ServiceReference serviceReference, int failureReason) { FailedListenerDTO failedListenerDTO = new FailedListenerDTO(); failedListenerDTO.failureReason = failureReason; - failedListenerDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + failedListenerDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); failedListenerDTO.servletContextId = contextController.getServiceId(); - failedListenerDTO.types = StringPlus.from( - serviceReference.getProperty(Constants.OBJECTCLASS)).toArray(new String[0]); + failedListenerDTO.types = StringPlus.from(serviceReference.getProperty(Constants.OBJECTCLASS)) + .toArray(new String[0]); contextController.getHttpServiceRuntime().recordFailedListenerDTO(serviceReference, failedListenerDTO); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextResourceTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextResourceTrackerCustomizer.java index 24f98777822..dd98ab0ba9e 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextResourceTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextResourceTrackerCustomizer.java @@ -33,18 +33,16 @@ * @author Raymond Augé */ public class ContextResourceTrackerCustomizer - extends RegistrationServiceTrackerCustomizer { + extends RegistrationServiceTrackerCustomizer { - public ContextResourceTrackerCustomizer( - BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, - ContextController contextController) { + public ContextResourceTrackerCustomizer(BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, + ContextController contextController) { super(bundleContext, httpServiceRuntime, contextController); } @Override - public AtomicReference addingService( - ServiceReference serviceReference) { + public AtomicReference addingService(ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!httpServiceRuntime.matches(serviceReference)) { @@ -56,40 +54,40 @@ public AtomicReference addingService( if (!contextController.matches(serviceReference)) { // Only the default context will perform the "does anyone match" checks. - if (httpServiceRuntime.isDefaultContext(contextController) && - !httpServiceRuntime.matchesAnyContext(serviceReference)) { + if (httpServiceRuntime.isDefaultContext(contextController) + && !httpServiceRuntime.matchesAnyContext(serviceReference)) { - throw new HttpWhiteboardFailureException( - "Doesn't match any contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Doesn't match any contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } return result; - } - else if (contextController.isLegacyContext() && - (serviceReference.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP) == null) && // IS a whiteboard service - (serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT) != null) && - (((String)serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT))).contains(HTTP_SERVICE_CONTEXT_PROPERTY.concat(Const.EQUAL))) { - - // don't allow whiteboard Servlets that specifically attempt to bind to a legacy context + } else if (contextController.isLegacyContext() + && (serviceReference.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP) == null) && // IS a whiteboard + // service + (serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT) != null) + && (((String) serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT))) + .contains(HTTP_SERVICE_CONTEXT_PROPERTY.concat(Const.EQUAL))) { + + // don't allow whiteboard Servlets that specifically attempt to bind to a legacy + // context throw new HttpWhiteboardFailureException( - "Whiteboard resources cannot bind to legacy contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + "Whiteboard resources cannot bind to legacy contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } httpServiceRuntime.removeFailedResourceDTO(serviceReference); result.set(contextController.addResourceRegistration(serviceReference)); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { httpServiceRuntime.debug(hwfe.getMessage(), hwfe); recordFailed(serviceReference, hwfe.getFailureReason()); - } - catch (Throwable t) { + } catch (Throwable t) { httpServiceRuntime.error(t.getMessage(), t); recordFailed(serviceReference, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } @@ -101,16 +99,17 @@ void removeFailed(ServiceReference serviceReference) { contextController.getHttpServiceRuntime().removeFailedResourceDTO(serviceReference); } - private void recordFailed( - ServiceReference serviceReference, int failureReason) { + private void recordFailed(ServiceReference serviceReference, int failureReason) { FailedResourceDTO failedResourceDTO = new FailedResourceDTO(); failedResourceDTO.failureReason = failureReason; - failedResourceDTO.patterns = StringPlus.from( - serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN)).toArray(new String[0]); - failedResourceDTO.prefix = String.valueOf(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX)); - failedResourceDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + failedResourceDTO.patterns = StringPlus + .from(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN)) + .toArray(new String[0]); + failedResourceDTO.prefix = String + .valueOf(serviceReference.getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX)); + failedResourceDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); failedResourceDTO.servletContextId = contextController.getServiceId(); contextController.getHttpServiceRuntime().recordFailedResourceDTO(serviceReference, failedResourceDTO); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextServletTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextServletTrackerCustomizer.java index 3fb4bc10863..d75f1362640 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextServletTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/ContextServletTrackerCustomizer.java @@ -33,18 +33,16 @@ * @author Raymond Augé */ public class ContextServletTrackerCustomizer - extends RegistrationServiceTrackerCustomizer { + extends RegistrationServiceTrackerCustomizer { - public ContextServletTrackerCustomizer( - BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, - ContextController contextController) { + public ContextServletTrackerCustomizer(BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, + ContextController contextController) { super(bundleContext, httpServiceRuntime, contextController); } @Override - public AtomicReference addingService( - ServiceReference serviceReference) { + public AtomicReference addingService(ServiceReference serviceReference) { AtomicReference result = new AtomicReference<>(); if (!httpServiceRuntime.matches(serviceReference)) { @@ -56,41 +54,41 @@ public AtomicReference addingService( if (!contextController.matches(serviceReference)) { // Only the default context will perform the "does anyone match" checks. - if (httpServiceRuntime.isDefaultContext(contextController) && - !httpServiceRuntime.matchesAnyContext(serviceReference)) { + if (httpServiceRuntime.isDefaultContext(contextController) + && !httpServiceRuntime.matchesAnyContext(serviceReference)) { - throw new HttpWhiteboardFailureException( - "Doesn't match any contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Doesn't match any contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } return result; - } - else if (contextController.isLegacyContext() && - (serviceReference.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP) == null) && // IS a whiteboard service - (serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT) != null) && - (((String)serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT))).contains(HTTP_SERVICE_CONTEXT_PROPERTY.concat(Const.EQUAL)) && - (serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_PATTERN) != null)) { - - // don't allow whiteboard Servlets that specifically attempt to bind to a legacy context + } else if (contextController.isLegacyContext() + && (serviceReference.getProperty(Const.EQUINOX_LEGACY_TCCL_PROP) == null) && // IS a whiteboard + // service + (serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT) != null) + && (((String) serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT))) + .contains(HTTP_SERVICE_CONTEXT_PROPERTY.concat(Const.EQUAL)) + && (serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_PATTERN) != null)) { + + // don't allow whiteboard Servlets that specifically attempt to bind to a legacy + // context throw new HttpWhiteboardFailureException( - "Whiteboard Servlets with pattern cannot bind to legacy contexts. " + serviceReference, DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); //$NON-NLS-1$ + "Whiteboard Servlets with pattern cannot bind to legacy contexts. " + serviceReference, //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING); } httpServiceRuntime.removeFailedServletDTO(serviceReference); result.set(contextController.addServletRegistration(serviceReference)); - } - catch (HttpWhiteboardFailureException hwfe) { + } catch (HttpWhiteboardFailureException hwfe) { httpServiceRuntime.debug(hwfe.getMessage(), hwfe); recordFailed(serviceReference, hwfe.getFailureReason()); - } - catch (Throwable t) { + } catch (Throwable t) { httpServiceRuntime.error(t.getMessage(), t); recordFailed(serviceReference, DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java index 92a14e7c744..866b90b3333 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/customizer/RegistrationServiceTrackerCustomizer.java @@ -27,10 +27,10 @@ * @author Raymond Augé */ public abstract class RegistrationServiceTrackerCustomizer> - implements ServiceTrackerCustomizer> { + implements ServiceTrackerCustomizer> { - public RegistrationServiceTrackerCustomizer( - BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, ContextController contextController) { + public RegistrationServiceTrackerCustomizer(BundleContext bundleContext, HttpServiceRuntimeImpl httpServiceRuntime, + ContextController contextController) { this.bundleContext = bundleContext; this.httpServiceRuntime = httpServiceRuntime; @@ -38,20 +38,15 @@ public RegistrationServiceTrackerCustomizer( } @Override - public void modifiedService( - ServiceReference serviceReference, - AtomicReference filterReference) { + public void modifiedService(ServiceReference serviceReference, AtomicReference filterReference) { removedService(serviceReference, filterReference); AtomicReference added = addingService(serviceReference); filterReference.set(added.get()); } - @Override - public void removedService( - ServiceReference serviceReference, - AtomicReference filterReference) { + public void removedService(ServiceReference serviceReference, AtomicReference filterReference) { try { T registration = filterReference.get(); @@ -60,8 +55,7 @@ public void removedService( } removeFailed(serviceReference); - } - finally { + } finally { httpServiceRuntime.incrementServiceChangecount(); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java index a2a786e87eb..9586d250ebd 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/error/RegisteredServletContextHelperException.java @@ -19,8 +19,7 @@ /** * @author Raymond Augé */ -public class RegisteredServletContextHelperException - extends ServletException { +public class RegisteredServletContextHelperException extends ServletException { private static final long serialVersionUID = 7301237379456486249L; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java index 22d0b038a0d..77de27ef23e 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportFactoryImpl.java @@ -17,8 +17,7 @@ import org.apache.commons.fileupload.FileUploadException; import org.osgi.service.http.runtime.dto.ServletDTO; -public class MultipartSupportFactoryImpl - implements MultipartSupportFactory { +public class MultipartSupportFactoryImpl implements MultipartSupportFactory { public static final Class FAIL_EARLY = FileUploadException.class; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java index 60273890db7..19153a9ab46 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportImpl.java @@ -36,7 +36,7 @@ public MultipartSupportImpl(ServletDTO servletDTO, ServletContext servletContext this.servletDTO = servletDTO; // Must return non-null File. See Servlet 3.1 §4.8.1 - File baseStorage = (File)servletContext.getAttribute(ServletContext.TEMPDIR); + File baseStorage = (File) servletContext.getAttribute(ServletContext.TEMPDIR); if (servletDTO.multipartLocation.length() > 0) { File storage = new File(servletDTO.multipartLocation); @@ -72,10 +72,11 @@ public MultipartSupportImpl(ServletDTO servletDTO, ServletContext servletContext } private void checkPermission(File baseStorage, ServletContext servletContext) { - BundleContext bundleContext = (BundleContext)servletContext.getAttribute("osgi-bundlecontext"); //$NON-NLS-1$ + BundleContext bundleContext = (BundleContext) servletContext.getAttribute("osgi-bundlecontext"); //$NON-NLS-1$ Bundle bundle = bundleContext.getBundle(); AccessControlContext accessControlContext = bundle.adapt(AccessControlContext.class); - if (accessControlContext == null) return; + if (accessControlContext == null) + return; accessControlContext.checkPermission(new FilePermission(baseStorage.getAbsolutePath(), "read,write")); //$NON-NLS-1$ } @@ -97,12 +98,11 @@ public List parseRequest(HttpServletRequest request) throws IOException, S try { for (Object item : upload.parseRequest(request)) { - DiskFileItem diskFileItem = (DiskFileItem)item; + DiskFileItem diskFileItem = (DiskFileItem) item; parts.add(new MultipartSupportPart(diskFileItem)); } - } - catch (FileUploadException fnfe) { + } catch (FileUploadException fnfe) { throw new IOException(fnfe); } @@ -112,5 +112,4 @@ public List parseRequest(HttpServletRequest request) throws IOException, S private final ServletDTO servletDTO; private final ServletFileUpload upload; - } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportPart.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportPart.java index f473efa20b4..63c75451635 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportPart.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/multipart/MultipartSupportPart.java @@ -55,8 +55,7 @@ public long getSize() { public void write(String fileName) throws IOException { try { item.write(new File(item.getStoreLocation(), fileName)); - } - catch (Exception e) { + } catch (Exception e) { throw new IOException(e); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/EndpointRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/EndpointRegistration.java index 19026d60565..15aeb1d8eb5 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/EndpointRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/EndpointRegistration.java @@ -29,17 +29,16 @@ /** * @author Raymond Augé */ -public abstract class EndpointRegistration - extends MatchableRegistration implements Comparable>{ +public abstract class EndpointRegistration extends MatchableRegistration + implements Comparable> { protected final ServiceHolder servletHolder; - private final ServletContextHelper servletContextHelper; //The context used during the registration of the servlet + private final ServletContextHelper servletContextHelper; // The context used during the registration of the servlet private final ContextController contextController; private final ClassLoader classLoader; - public EndpointRegistration( - ServiceHolder servletHolder, D d, ServletContextHelper servletContextHelper, - ContextController contextController) { + public EndpointRegistration(ServiceHolder servletHolder, D d, ServletContextHelper servletContextHelper, + ContextController contextController) { super(servletHolder.get(), d); this.servletHolder = servletHolder; @@ -66,8 +65,7 @@ public void destroy() { super.destroy(); getT().destroy(); - } - finally { + } finally { destroyContextAttributes(); Thread.currentThread().setContextClassLoader(original); servletHolder.release(); @@ -80,7 +78,7 @@ public boolean equals(Object obj) { return false; } - EndpointRegistration endpointRegistration = (EndpointRegistration)obj; + EndpointRegistration endpointRegistration = (EndpointRegistration) obj; return getD().equals(endpointRegistration.getD()); } @@ -90,15 +88,14 @@ public int hashCode() { return getD().hashCode(); } - //Delegate the init call to the actual servlet + // Delegate the init call to the actual servlet public void init(ServletConfig servletConfig) throws ServletException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); getT().init(servletConfig); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(original); } } @@ -120,9 +117,7 @@ public ServletContextHelper getServletContextHelper() { public abstract ServiceReference getServiceReference(); @Override - public String match( - String name, String servletPath, String pathInfo, String extension, - Match match) { + public String match(String name, String servletPath, String pathInfo, String extension, Match match) { if (match == Match.ERROR) { return null; @@ -151,7 +146,7 @@ public String match( return null; } - //Delegate the handling of the request to the actual servlet + // Delegate the handling of the request to the actual servlet public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { @@ -192,8 +187,7 @@ public String toString() { return toString; } - private static final String SIMPLE_NAME = - EndpointRegistration.class.getSimpleName(); + private static final String SIMPLE_NAME = EndpointRegistration.class.getSimpleName(); private String _toString; } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ErrorPageRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ErrorPageRegistration.java index f3b33a44391..753f5a7df28 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ErrorPageRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ErrorPageRegistration.java @@ -28,10 +28,8 @@ */ public class ErrorPageRegistration extends EndpointRegistration { - public ErrorPageRegistration( - ServiceHolder servletHolder, ExtendedErrorPageDTO errorPageDTO, - ServletContextHelper servletContextHelper, - ContextController contextController) { + public ErrorPageRegistration(ServiceHolder servletHolder, ExtendedErrorPageDTO errorPageDTO, + ServletContextHelper servletContextHelper, ContextController contextController) { super(servletHolder, errorPageDTO, servletContextHelper, contextController); } @@ -57,9 +55,7 @@ public ServiceReference getServiceReference() { } @Override - public String match( - String name, String servletPath, String pathInfo, String extension, - Match match) { + public String match(String name, String servletPath, String pathInfo, String extension, Match match) { if (match != Match.ERROR) { return null; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java index 1ace14f4de7..78b8a1bf963 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java @@ -31,9 +31,8 @@ import org.osgi.service.http.runtime.dto.FilterDTO; //This class wraps the filter object registered in the HttpService.registerFilter call, to manage the context classloader when handleRequests are being asked. -public class FilterRegistration - extends MatchableRegistration - implements Comparable { +public class FilterRegistration extends MatchableRegistration + implements Comparable { private final ServiceHolder filterHolder; private final ClassLoader classLoader; @@ -42,9 +41,8 @@ public class FilterRegistration private final boolean initDestoyWithContextController; private final Pattern[] compiledRegexs; - public FilterRegistration( - ServiceHolder filterHolder, FilterDTO filterDTO, int priority, - ContextController contextController) { + public FilterRegistration(ServiceHolder filterHolder, FilterDTO filterDTO, int priority, + ContextController contextController) { super(filterHolder.get(), filterDTO); this.filterHolder = filterHolder; @@ -57,16 +55,16 @@ public FilterRegistration( } else { classLoader = filterHolder.getBundle().adapt(BundleWiring.class).getClassLoader(); } - String legacyContextFilter = (String) filterHolder.getServiceReference().getProperty(Const.EQUINOX_LEGACY_CONTEXT_SELECT); + String legacyContextFilter = (String) filterHolder.getServiceReference() + .getProperty(Const.EQUINOX_LEGACY_CONTEXT_SELECT); if (legacyContextFilter != null) { - // This is a legacy Filter registration. + // This is a legacy Filter registration. // This filter tells us the real context controller, // backed by an HttpContext that should be used to init/destroy this Filter org.osgi.framework.Filter f = null; try { f = FrameworkUtil.createFilter(legacyContextFilter); - } - catch (InvalidSyntaxException e) { + } catch (InvalidSyntaxException e) { // nothing } initDestoyWithContextController = f == null || contextController.matches(f); @@ -81,8 +79,10 @@ public int compareTo(FilterRegistration otherFilterRegistration) { if (priorityDifference != 0) return -priorityDifference; - // Note that we use abs here because the DTO service ID may have been negated for legacy filters. - // We always compare with the positive id values and we know the positive values are unique. + // Note that we use abs here because the DTO service ID may have been negated + // for legacy filters. + // We always compare with the positive id values and we know the positive values + // are unique. long thisId = Math.abs(getD().serviceId); long otherId = Math.abs(otherFilterRegistration.getD().serviceId); return (thisId < otherId) ? -1 : ((thisId == otherId) ? 0 : 1); @@ -101,8 +101,7 @@ public void destroy() { contextController.ungetServletContextHelper(filterHolder.getBundle()); super.destroy(); getT().destroy(); - } - finally { + } finally { destroyContextAttributes(); Thread.currentThread().setContextClassLoader(original); filterHolder.release(); @@ -110,22 +109,18 @@ public void destroy() { } public boolean appliesTo(FilterChainImpl filterChainImpl) { - return (Arrays.binarySearch( - getD().dispatcher, filterChainImpl.getDispatcherType().name()) >= 0); + return (Arrays.binarySearch(getD().dispatcher, filterChainImpl.getDispatcherType().name()) >= 0); } - //Delegate the handling of the request to the actual filter - public void doFilter( - HttpServletRequest request, HttpServletResponse response, - FilterChain chain) - throws IOException, ServletException { + // Delegate the handling of the request to the actual filter + public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) + throws IOException, ServletException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); getT().doFilter(request, response, chain); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(original); } } @@ -136,7 +131,7 @@ public boolean equals(Object obj) { return false; } - FilterRegistration filterRegistration = (FilterRegistration)obj; + FilterRegistration filterRegistration = (FilterRegistration) obj; return getT().equals(filterRegistration.getT()); } @@ -146,7 +141,7 @@ public int hashCode() { return Long.valueOf(getD().serviceId).hashCode(); } - //Delegate the init call to the actual filter + // Delegate the init call to the actual filter public void init(FilterConfig filterConfig) throws ServletException { if (!initDestoyWithContextController) { return; @@ -159,8 +154,7 @@ public void init(FilterConfig filterConfig) throws ServletException { createContextAttributes(); getT().init(filterConfig); initialized = true; - } - finally { + } finally { if (!initialized) { destroyContextAttributes(); } @@ -168,8 +162,7 @@ public void init(FilterConfig filterConfig) throws ServletException { } } - public String match( - String name, String requestURI, String extension, Match match) { + public String match(String name, String requestURI, String extension, Match match) { if ((name != null) && (getD().servletNames != null)) { for (String servletName : getD().servletNames) { if (servletName.equals(name)) { @@ -198,8 +191,7 @@ public String match( } @Override - public String match( - String name, String servletPath, String pathInfo, String extension, Match match) { + public String match(String name, String servletPath, String pathInfo, String extension, Match match) { // TODO need to rework match for filters to remove this method throw new UnsupportedOperationException("Should not be calling this method on FilterRegistration"); //$NON-NLS-1$ } @@ -228,8 +220,7 @@ protected boolean isPathWildcardMatch(String pattern, String path) { return pattern.equals(path); } - protected boolean doPatternMatch(String pattern, String path, String extension) - throws IllegalArgumentException { + protected boolean doPatternMatch(String pattern, String path, String extension) throws IllegalArgumentException { if (pattern.indexOf(Const.SLASH_STAR_DOT) == 0) { pattern = pattern.substring(1); @@ -243,8 +234,7 @@ protected boolean doPatternMatch(String pattern, String path, String extension) if (pattern.isEmpty() && Const.SLASH.equals(path)) { return true; - } - else if (!pattern.isEmpty()) { + } else if (!pattern.isEmpty()) { // first try prefix path matching; taking into account wild cards if necessary if (pattern.charAt(0) == '/') { if (isPathWildcardMatch(pattern, path)) { diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java index afc99697be2..c5013793d5f 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ListenerRegistration.java @@ -36,10 +36,9 @@ public class ListenerRegistration extends Registration listenerHolder, List> classes, - ListenerDTO listenerDTO, ServletContext servletContext, - ContextController contextController) { + public ListenerRegistration(ServiceHolder listenerHolder, + List> classes, ListenerDTO listenerDTO, ServletContext servletContext, + ContextController contextController) { super(listenerHolder.get(), listenerDTO); this.listenerHolder = listenerHolder; @@ -51,9 +50,8 @@ public ListenerRegistration( createContextAttributes(); - proxy = (EventListener)Proxy.newProxyInstance( - getClass().getClassLoader(), classes.toArray(new Class[0]), - new EventListenerInvocationHandler()); + proxy = (EventListener) Proxy.newProxyInstance(getClass().getClassLoader(), classes.toArray(new Class[0]), + new EventListenerInvocationHandler()); } @Override @@ -69,12 +67,11 @@ public synchronized void destroy() { super.destroy(); - if (classes.contains(HttpSessionBindingListener.class) || - classes.contains(HttpSessionAttributeListener.class) || - classes.contains(HttpSessionListener.class)) { + if (classes.contains(HttpSessionBindingListener.class) + || classes.contains(HttpSessionAttributeListener.class) + || classes.contains(HttpSessionListener.class)) { - Map activeSessions = - contextController.getActiveSessions(); + Map activeSessions = contextController.getActiveSessions(); for (HttpSessionAdaptor adaptor : activeSessions.values()) { adaptor.invokeSessionListeners(classes, super.getT()); @@ -82,14 +79,11 @@ public synchronized void destroy() { } if (classes.contains(ServletContextListener.class)) { - ServletContextListener servletContextListener = - (ServletContextListener)super.getT(); + ServletContextListener servletContextListener = (ServletContextListener) super.getT(); - servletContextListener.contextDestroyed( - new ServletContextEvent(servletContext)); + servletContextListener.contextDestroyed(new ServletContextEvent(servletContext)); } - } - finally { + } finally { destroyContextAttributes(); Thread.currentThread().setContextClassLoader(original); listenerHolder.release(); @@ -102,7 +96,7 @@ public boolean equals(Object obj) { return false; } - ListenerRegistration listenerRegistration = (ListenerRegistration)obj; + ListenerRegistration listenerRegistration = (ListenerRegistration) obj; return listenerRegistration.getT().equals(super.getT()); } @@ -143,8 +137,7 @@ public EventListenerInvocationHandler() { } @Override - public Object invoke(Object theProxy, Method method, Object[] args) - throws Throwable { + public Object invoke(Object theProxy, Method method, Object[] args) throws Throwable { Thread thread = Thread.currentThread(); ClassLoader original = thread.getContextClassLoader(); @@ -156,8 +149,7 @@ public Object invoke(Object theProxy, Method method, Object[] args) } catch (InvocationTargetException e) { throw e.getCause(); } - } - finally { + } finally { thread.setContextClassLoader(original); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java index aef016add2e..20257225624 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java @@ -21,19 +21,15 @@ /** * @author Raymond Augé */ -public abstract class MatchableRegistration - extends Registration { +public abstract class MatchableRegistration extends Registration { public MatchableRegistration(T t, D d) { super(t, d); } - public abstract String match( - String name, String servletPath, String pathInfo, String extension, - Match match); + public abstract String match(String name, String servletPath, String pathInfo, String extension, Match match); - private boolean isPathWildcardMatch( - String pattern, String servletPath) { + private boolean isPathWildcardMatch(String pattern, String servletPath) { int cpl = pattern.length() - 2; @@ -50,15 +46,13 @@ private boolean isPathWildcardMatch( return false; } - final protected boolean doMatch( - String pattern, String servletPath, String pathInfo, - String extension, Match match) - throws IllegalArgumentException { + final protected boolean doMatch(String pattern, String servletPath, String pathInfo, String extension, Match match) + throws IllegalArgumentException { if (match == Match.EXACT) { return pattern.equals(servletPath); } if ((match == Match.CONTEXT_ROOT) && Const.BLANK.equals(pattern)) { - return Const.BLANK.equals(servletPath) && Const.SLASH.equals(pathInfo); + return Const.BLANK.equals(servletPath) && Const.SLASH.equals(pathInfo); } if ((match == Match.DEFAULT_SERVLET) && Const.SLASH.equals(pattern)) { return !servletPath.isEmpty() && pathInfo == null; @@ -73,8 +67,7 @@ final protected boolean doMatch( return true; } - if ((match == Match.REGEX) && isPathWildcardMatch( - pattern, servletPath)) { + if ((match == Match.REGEX) && isPathWildcardMatch(pattern, servletPath)) { return true; } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/PreprocessorRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/PreprocessorRegistration.java index 99f01830094..2f185d01156 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/PreprocessorRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/PreprocessorRegistration.java @@ -30,15 +30,14 @@ * @author Raymond Augé */ public class PreprocessorRegistration extends Registration - implements Comparable { + implements Comparable { private final ServiceHolder preprocessorHolder; private final ClassLoader classLoader; private final HttpServiceRuntimeImpl httpServiceRuntime; - public PreprocessorRegistration( - ServiceHolder preprocessorHolder, PreprocessorDTO preprocessorDTO, - HttpServiceRuntimeImpl httpServiceRuntime) { + public PreprocessorRegistration(ServiceHolder preprocessorHolder, PreprocessorDTO preprocessorDTO, + HttpServiceRuntimeImpl httpServiceRuntime) { super(preprocessorHolder.get(), preprocessorDTO); this.preprocessorHolder = preprocessorHolder; @@ -53,17 +52,14 @@ public int compareTo(PreprocessorRegistration o) { return thisRef.compareTo(otherRef); } - public void doFilter( - HttpServletRequest request, HttpServletResponse response, - FilterChain chain) + public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); getT().doFilter(request, response, chain); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(original); } } @@ -77,8 +73,7 @@ public void destroy() { preprocessorHolder.getBundle().getBundleContext().ungetService(preprocessorHolder.getServiceReference()); super.destroy(); getT().destroy(); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(original); preprocessorHolder.release(); } @@ -95,8 +90,7 @@ public void init(FilterConfig filterConfig) throws ServletException { Thread.currentThread().setContextClassLoader(classLoader); getT().init(filterConfig); - } - finally { + } finally { Thread.currentThread().setContextClassLoader(original); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/Registration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/Registration.java index 8e669adb6ed..7c7ebe365fd 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/Registration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/Registration.java @@ -39,8 +39,7 @@ public void addReference() { try { referenceCount.incrementAndGet(); - } - finally { + } finally { readLock.unlock(); } } @@ -56,15 +55,13 @@ public void removeReference() { try { condition.signalAll(); - } - finally { + } finally { writeLock.unlock(); readLock.lock(); } } - } - finally { + } finally { readLock.unlock(); } } @@ -80,13 +77,11 @@ public void destroy() { while (referenceCount.get() != 0) { try { condition.await(); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { interrupted = true; } } - } - finally { + } finally { writeLock.unlock(); if (interrupted) { diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java index 557e86c0376..cc6daf840c3 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java @@ -20,15 +20,14 @@ import org.osgi.framework.ServiceReference; import org.osgi.service.http.context.ServletContextHelper; import org.osgi.service.http.runtime.dto.ResourceDTO; + /** * @author Raymond Augé */ public class ResourceRegistration extends EndpointRegistration { - public ResourceRegistration( - ServiceReference serviceReference, ServiceHolder servletHolder, ResourceDTO resourceDTO, - ServletContextHelper servletContextHelper, - ContextController contextController) { + public ResourceRegistration(ServiceReference serviceReference, ServiceHolder servletHolder, + ResourceDTO resourceDTO, ServletContextHelper servletContextHelper, ContextController contextController) { super(servletHolder, resourceDTO, servletContextHelper, contextController); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java index 39d38a2f1fe..24752cd5539 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java @@ -45,28 +45,25 @@ public class ServletRegistration extends EndpointRegistration { // to fail early if optional imports are missing factory = iterator.next(); break; - } - catch (Throwable t) { + } catch (Throwable t) { // ignore ServiceConfigurationError, it means our optional imports are missing. } } } - public ServletRegistration( - ServiceHolder servletHolder, ServletDTO servletDTO, - ServletContextHelper servletContextHelper, - ContextController contextController, ServletContext servletContext) { + public ServletRegistration(ServiceHolder servletHolder, ServletDTO servletDTO, + ServletContextHelper servletContextHelper, ContextController contextController, + ServletContext servletContext) { super(servletHolder, servletDTO, servletContextHelper, contextController); if (servletDTO.multipartEnabled) { if (factory == null) { throw new IllegalStateException( - "Multipart support not enabled due to missing, optional commons-fileupload dependency!"); //$NON-NLS-1$ + "Multipart support not enabled due to missing, optional commons-fileupload dependency!"); //$NON-NLS-1$ } multipartSupport = factory.newInstance(servletDTO, servletContext); - } - else { + } else { multipartSupport = null; } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterChainImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterChainImpl.java index 6f9474e69e5..4aa70ebfd11 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterChainImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterChainImpl.java @@ -30,9 +30,8 @@ public class FilterChainImpl implements FilterChain { private final int filterCount; private int filterIndex = 0; - public FilterChainImpl( - List matchingFilterRegistrations, - EndpointRegistration registration, DispatcherType dispatcherType) { + public FilterChainImpl(List matchingFilterRegistrations, EndpointRegistration registration, + DispatcherType dispatcherType) { this.matchingFilterRegistrations = matchingFilterRegistrations; this.dispatcherType = dispatcherType; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterConfigImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterConfigImpl.java index 532f732af01..db17728d853 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterConfigImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/FilterConfigImpl.java @@ -24,16 +24,13 @@ public class FilterConfigImpl implements FilterConfig { private final String filterName; private final ServletContext servletContext; - public FilterConfigImpl( - String name, Map initparams, - ServletContext servletContext) { + public FilterConfigImpl(String name, Map initparams, ServletContext servletContext) { this.filterName = name; if (initparams != null) { this.initparams = initparams; - } - else { + } else { this.initparams = Collections.emptyMap(); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java index c8886ce974a..0cd54e02eed 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestWrapperImpl.java @@ -38,7 +38,7 @@ public class HttpServletRequestWrapperImpl extends HttpServletRequestWrapper { private List parts; private final Lock lock = new ReentrantLock(); - private static final Set dispatcherAttributes = new HashSet<>(); + private static final Set dispatcherAttributes = new HashSet<>(); static { dispatcherAttributes.add(RequestDispatcher.ERROR_EXCEPTION); @@ -61,15 +61,14 @@ public class HttpServletRequestWrapperImpl extends HttpServletRequestWrapper { private static final Object NULL_PLACEHOLDER = new Object(); - public static HttpServletRequestWrapperImpl findHttpRuntimeRequest( - HttpServletRequest request) { + public static HttpServletRequestWrapperImpl findHttpRuntimeRequest(HttpServletRequest request) { while (request instanceof HttpServletRequestWrapper) { if (request instanceof HttpServletRequestWrapperImpl) { - return (HttpServletRequestWrapperImpl)request; + return (HttpServletRequestWrapperImpl) request; } - request = (HttpServletRequest)((HttpServletRequestWrapper)request).getRequest(); + request = (HttpServletRequest) ((HttpServletRequestWrapper) request).getRequest(); } return null; @@ -82,7 +81,7 @@ public HttpServletRequestWrapperImpl(HttpServletRequest request) { @Override public String changeSessionId() { - HttpSessionAdaptor httpSessionAdaptor = (HttpSessionAdaptor)getSession(false); + HttpSessionAdaptor httpSessionAdaptor = (HttpSessionAdaptor) getSession(false); if (httpSessionAdaptor == null) { throw new IllegalStateException("No session"); //$NON-NLS-1$ @@ -118,8 +117,8 @@ public String getRemoteUser() { public String getPathInfo() { DispatchTargets currentDispatchTargets = dispatchTargets.peek(); - if ((currentDispatchTargets.getServletName() != null) || - (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { + if ((currentDispatchTargets.getServletName() != null) + || (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { return this.dispatchTargets.getLast().getPathInfo(); } return currentDispatchTargets.getPathInfo(); @@ -153,8 +152,8 @@ public String[] getParameterValues(String name) { public String getQueryString() { DispatchTargets currentDispatchTargets = dispatchTargets.peek(); - if ((currentDispatchTargets.getServletName() != null) || - (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { + if ((currentDispatchTargets.getServletName() != null) + || (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { return request.getQueryString(); } return currentDispatchTargets.getQueryString(); @@ -164,8 +163,8 @@ public String getQueryString() { public String getRequestURI() { DispatchTargets currentDispatchTargets = dispatchTargets.peek(); - if ((currentDispatchTargets.getServletName() != null) || - (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { + if ((currentDispatchTargets.getServletName() != null) + || (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { return request.getRequestURI(); } return currentDispatchTargets.getRequestURI(); @@ -178,8 +177,8 @@ public ServletContext getServletContext() { public String getServletPath() { DispatchTargets currentDispatchTargets = dispatchTargets.peek(); - if ((currentDispatchTargets.getServletName() != null) || - (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { + if ((currentDispatchTargets.getServletName() != null) + || (currentDispatchTargets.getDispatcherType() == DispatcherType.INCLUDE)) { return this.dispatchTargets.getLast().getServletPath(); } if (currentDispatchTargets.getServletPath().equals(Const.SLASH)) { @@ -196,9 +195,8 @@ public Object getAttribute(String attributeName) { DispatchTargets current = dispatchTargets.peek(); DispatcherType dispatcherType = current.getDispatcherType(); - if ((dispatcherType == DispatcherType.ASYNC) || - (dispatcherType == DispatcherType.REQUEST) || - !attributeName.startsWith("javax.servlet.")) { //$NON-NLS-1$ + if ((dispatcherType == DispatcherType.ASYNC) || (dispatcherType == DispatcherType.REQUEST) + || !attributeName.startsWith("javax.servlet.")) { //$NON-NLS-1$ return request.getAttribute(attributeName); } @@ -207,13 +205,11 @@ public Object getAttribute(String attributeName) { Map specialOverides = current.getSpecialOverides(); if (dispatcherType == DispatcherType.ERROR) { - if (dispatcherAttributes.contains(attributeName) && - !attributeName.startsWith("javax.servlet.error.")) { //$NON-NLS-1$ + if (dispatcherAttributes.contains(attributeName) && !attributeName.startsWith("javax.servlet.error.")) { //$NON-NLS-1$ return null; } - } - else if (dispatcherType == DispatcherType.INCLUDE) { + } else if (dispatcherType == DispatcherType.INCLUDE) { if (hasServletName && attributeName.startsWith("javax.servlet.include")) { //$NON-NLS-1$ return null; } @@ -223,8 +219,7 @@ else if (dispatcherType == DispatcherType.INCLUDE) { if (NULL_PLACEHOLDER.equals(specialOveride)) { return null; - } - else if (specialOveride != null) { + } else if (specialOveride != null) { return specialOveride; } @@ -237,25 +232,20 @@ else if (specialOveride != null) { if (attributeName.equals(RequestDispatcher.INCLUDE_CONTEXT_PATH)) { return current.getContextController().getFullContextPath(); - } - else if (attributeName.equals(RequestDispatcher.INCLUDE_PATH_INFO)) { + } else if (attributeName.equals(RequestDispatcher.INCLUDE_PATH_INFO)) { return current.getPathInfo(); - } - else if (attributeName.equals(RequestDispatcher.INCLUDE_QUERY_STRING)) { + } else if (attributeName.equals(RequestDispatcher.INCLUDE_QUERY_STRING)) { return current.getQueryString(); - } - else if (attributeName.equals(RequestDispatcher.INCLUDE_REQUEST_URI)) { + } else if (attributeName.equals(RequestDispatcher.INCLUDE_REQUEST_URI)) { return current.getRequestURI(); - } - else if (attributeName.equals(RequestDispatcher.INCLUDE_SERVLET_PATH)) { + } else if (attributeName.equals(RequestDispatcher.INCLUDE_SERVLET_PATH)) { return current.getServletPath(); } if (dispatcherAttributes.contains(attributeName)) { return null; } - } - else if (dispatcherType == DispatcherType.FORWARD) { + } else if (dispatcherType == DispatcherType.FORWARD) { if (hasServletName && attributeName.startsWith("javax.servlet.forward")) { //$NON-NLS-1$ return null; } @@ -265,8 +255,7 @@ else if (dispatcherType == DispatcherType.FORWARD) { if (NULL_PLACEHOLDER.equals(specialOveride)) { return null; - } - else if (specialOveride != null) { + } else if (specialOveride != null) { return specialOveride; } } @@ -275,17 +264,13 @@ else if (specialOveride != null) { if (attributeName.equals(RequestDispatcher.FORWARD_CONTEXT_PATH)) { return original.getContextController().getFullContextPath(); - } - else if (attributeName.equals(RequestDispatcher.FORWARD_PATH_INFO)) { + } else if (attributeName.equals(RequestDispatcher.FORWARD_PATH_INFO)) { return original.getPathInfo(); - } - else if (attributeName.equals(RequestDispatcher.FORWARD_QUERY_STRING)) { + } else if (attributeName.equals(RequestDispatcher.FORWARD_QUERY_STRING)) { return original.getQueryString(); - } - else if (attributeName.equals(RequestDispatcher.FORWARD_REQUEST_URI)) { + } else if (attributeName.equals(RequestDispatcher.FORWARD_REQUEST_URI)) { return original.getRequestURI(); - } - else if (attributeName.equals(RequestDispatcher.FORWARD_SERVLET_PATH)) { + } else if (attributeName.equals(RequestDispatcher.FORWARD_SERVLET_PATH)) { return original.getServletPath(); } @@ -300,8 +285,7 @@ else if (attributeName.equals(RequestDispatcher.FORWARD_SERVLET_PATH)) { public RequestDispatcher getRequestDispatcher(String path) { DispatchTargets currentDispatchTarget = dispatchTargets.peek(); - ContextController contextController = - currentDispatchTarget.getContextController(); + ContextController contextController = currentDispatchTarget.getContextController(); // support relative paths if (!path.startsWith(Const.SLASH)) { @@ -344,8 +328,8 @@ public HttpSession getSession(boolean create) { if (session != null) { DispatchTargets currentDispatchTarget = dispatchTargets.peek(); - return currentDispatchTarget.getContextController().getSessionAdaptor( - session, currentDispatchTarget.getServletRegistration().getT().getServletConfig().getServletContext()); + return currentDispatchTarget.getContextController().getSessionAdaptor(session, + currentDispatchTarget.getServletRegistration().getT().getServletConfig().getServletContext()); } return null; @@ -375,20 +359,17 @@ public void removeAttribute(String name) { EventListeners eventListeners = currentDispatchTarget.getContextController().getEventListeners(); - List listeners = eventListeners.get( - ServletRequestAttributeListener.class); + List listeners = eventListeners.get(ServletRequestAttributeListener.class); if (listeners.isEmpty()) { return; } - ServletRequestAttributeEvent servletRequestAttributeEvent = - new ServletRequestAttributeEvent( + ServletRequestAttributeEvent servletRequestAttributeEvent = new ServletRequestAttributeEvent( currentDispatchTarget.getServletRegistration().getServletContext(), this, name, null); for (ServletRequestAttributeListener servletRequestAttributeListener : listeners) { - servletRequestAttributeListener.attributeRemoved( - servletRequestAttributeEvent); + servletRequestAttributeListener.attributeRemoved(servletRequestAttributeEvent); } } @@ -400,8 +381,7 @@ public void setAttribute(String name, Object value) { if (value == null) { current.getSpecialOverides().put(name, NULL_PLACEHOLDER); - } - else { + } else { current.getSpecialOverides().put(name, value); } } @@ -412,25 +392,20 @@ public void setAttribute(String name, Object value) { EventListeners eventListeners = currentDispatchTarget.getContextController().getEventListeners(); - List listeners = eventListeners.get( - ServletRequestAttributeListener.class); + List listeners = eventListeners.get(ServletRequestAttributeListener.class); if (listeners.isEmpty()) { return; } - ServletRequestAttributeEvent servletRequestAttributeEvent = - new ServletRequestAttributeEvent( + ServletRequestAttributeEvent servletRequestAttributeEvent = new ServletRequestAttributeEvent( currentDispatchTarget.getServletRegistration().getServletContext(), this, name, value); for (ServletRequestAttributeListener servletRequestAttributeListener : listeners) { if (added) { - servletRequestAttributeListener.attributeAdded( - servletRequestAttributeEvent); - } - else { - servletRequestAttributeListener.attributeReplaced( - servletRequestAttributeEvent); + servletRequestAttributeListener.attributeAdded(servletRequestAttributeEvent); + } else { + servletRequestAttributeListener.attributeReplaced(servletRequestAttributeEvent); } } } @@ -445,7 +420,7 @@ public Part getPart(String name) throws IOException, ServletException { } } } - + return null; } @@ -458,7 +433,7 @@ public AsyncContext startAsync() throws IllegalStateException { EndpointRegistration endpointRegistration = dispatchTargets.peek().getServletRegistration(); if (endpointRegistration instanceof ServletRegistration) { - ServletRegistration servletRegistration = (ServletRegistration)endpointRegistration; + ServletRegistration servletRegistration = (ServletRegistration) endpointRegistration; if (servletRegistration.getD().asyncSupported) { return request.startAsync(); @@ -483,8 +458,7 @@ private List getParts0() throws IOException, ServletException { } return parts = servletRegistration.parseRequest(this); - } - finally { + } finally { lock.unlock(); } } @@ -493,7 +467,7 @@ private org.eclipse.equinox.http.servlet.internal.registration.ServletRegistrati EndpointRegistration servletRegistration = dispatchTargets.peek().getServletRegistration(); if (servletRegistration instanceof org.eclipse.equinox.http.servlet.internal.registration.ServletRegistration) { - return (org.eclipse.equinox.http.servlet.internal.registration.ServletRegistration)servletRegistration; + return (org.eclipse.equinox.http.servlet.internal.registration.ServletRegistration) servletRegistration; } return null; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java index 99e1e45bdf2..8b25ec83225 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletResponseWrapperImpl.java @@ -77,7 +77,7 @@ public PrintWriter getWriter() throws IOException { @Override public void flushBuffer() throws IOException { if (status != -1) { - HttpServletResponse wrappedResponse = (HttpServletResponse)this.getResponse(); + HttpServletResponse wrappedResponse = (HttpServletResponse) this.getResponse(); wrappedResponse.sendError(status, getMessage()); } super.flushBuffer(); @@ -91,15 +91,14 @@ public void setCompleted(boolean completed) { this.completed = completed; } - public static HttpServletResponseWrapperImpl findHttpRuntimeResponse( - HttpServletResponse response) { + public static HttpServletResponseWrapperImpl findHttpRuntimeResponse(HttpServletResponse response) { while (response instanceof HttpServletResponseWrapper) { if (response instanceof HttpServletResponseWrapperImpl) { - return (HttpServletResponseWrapperImpl)response; + return (HttpServletResponseWrapperImpl) response; } - response = (HttpServletResponse)((HttpServletResponseWrapper)response).getResponse(); + response = (HttpServletResponse) ((HttpServletResponseWrapper) response).getResponse(); } return null; @@ -125,7 +124,8 @@ public void close() throws IOException { @Override public void flush() throws IOException { if (getInternalStatus() != -1) { - HttpServletResponse wrappedResponse = (HttpServletResponse) HttpServletResponseWrapperImpl.this.getResponse(); + HttpServletResponse wrappedResponse = (HttpServletResponse) HttpServletResponseWrapperImpl.this + .getResponse(); wrappedResponse.sendError(getInternalStatus(), getMessage()); } originalOutputStream.flush(); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionAdaptor.java index 3c864ca6e2f..27c16e327b2 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionAdaptor.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionAdaptor.java @@ -31,13 +31,12 @@ public class HttpSessionAdaptor implements HttpSession, Serializable { private transient final String attributePrefix; private String string; - static public HttpSessionAdaptor createHttpSessionAdaptor( - HttpSession session, ServletContext servletContext, ContextController controller) { + static public HttpSessionAdaptor createHttpSessionAdaptor(HttpSession session, ServletContext servletContext, + ContextController controller) { return new HttpSessionAdaptor(session, servletContext, controller); } - private HttpSessionAdaptor( - HttpSession session, ServletContext servletContext, ContextController controller) { + private HttpSessionAdaptor(HttpSession session, ServletContext servletContext, ContextController controller) { this.session = session; this.servletContext = servletContext; @@ -68,7 +67,7 @@ public Enumeration getAttributeNames() { private Collection getAttributeNames0() { Collection result = new ArrayList<>(); Enumeration containerSessionAttributes = session.getAttributeNames(); - while(containerSessionAttributes.hasMoreElements()) { + while (containerSessionAttributes.hasMoreElements()) { String attribute = containerSessionAttributes.nextElement(); if (attribute.startsWith(attributePrefix)) { result.add(attribute.substring(attributePrefix.length())); @@ -77,12 +76,12 @@ private Collection getAttributeNames0() { return result; } - /**@deprecated*/ + /** @deprecated */ public Object getValue(String arg0) { return getAttribute(arg0); } - /**@deprecated*/ + /** @deprecated */ public String[] getValueNames() { Collection result = getAttributeNames0(); return result.toArray(new String[0]); @@ -94,8 +93,7 @@ public void invalidate() { for (HttpSessionListener listener : controller.getEventListeners().get(HttpSessionListener.class)) { try { listener.sessionDestroyed(httpSessionEvent); - } - catch (IllegalStateException ise) { + } catch (IllegalStateException ise) { // outer session is already invalidated } } @@ -104,21 +102,20 @@ public void invalidate() { for (String attribute : getAttributeNames0()) { removeAttribute(attribute); } - } - catch (IllegalStateException ise) { + } catch (IllegalStateException ise) { // outer session is already invalidated } controller.removeActiveSession(session); } - public void invokeSessionListeners (List> classes, EventListener listener) { + public void invokeSessionListeners(List> classes, EventListener listener) { if (classes == null) { return; } for (Class clazz : classes) { - if (clazz.equals(HttpSessionListener.class)){ + if (clazz.equals(HttpSessionListener.class)) { HttpSessionEvent sessionEvent = new HttpSessionEvent(this); HttpSessionListener httpSessionListener = (HttpSessionListener) listener; httpSessionListener.sessionDestroyed(sessionEvent); @@ -144,7 +141,7 @@ public void invokeSessionListeners (List> classes } } - /**@deprecated*/ + /** @deprecated */ public void putValue(String arg0, Object arg1) { setAttribute(arg0, arg1); } @@ -160,23 +157,21 @@ public void removeAttribute(String arg0) { return; } - List listeners = - controller.getEventListeners().get( - HttpSessionAttributeListener.class); + List listeners = controller.getEventListeners() + .get(HttpSessionAttributeListener.class); if (listeners.isEmpty()) { return; } - HttpSessionBindingEvent httpSessionBindingEvent = - new HttpSessionBindingEvent(this, newName); + HttpSessionBindingEvent httpSessionBindingEvent = new HttpSessionBindingEvent(this, newName); for (HttpSessionAttributeListener listener : listeners) { listener.attributeRemoved(httpSessionBindingEvent); } } - /**@deprecated*/ + /** @deprecated */ public void removeValue(String arg0) { removeAttribute(arg0); } @@ -194,19 +189,16 @@ public void setAttribute(String name, Object value) { session.setAttribute(newName, value); - List listeners = - controller.getEventListeners().get( - HttpSessionAttributeListener.class); + List listeners = controller.getEventListeners() + .get(HttpSessionAttributeListener.class); if (!listeners.isEmpty()) { - HttpSessionBindingEvent httpSessionBindingEvent = - new HttpSessionBindingEvent(this, newName, value); + HttpSessionBindingEvent httpSessionBindingEvent = new HttpSessionBindingEvent(this, newName, value); for (HttpSessionAttributeListener listener : listeners) { if (added) { listener.attributeAdded(httpSessionBindingEvent); - } - else { + } else { listener.attributeReplaced(httpSessionBindingEvent); } } @@ -238,9 +230,10 @@ public int getMaxInactiveInterval() { return session.getMaxInactiveInterval(); } - /**@deprecated*/ + /** @deprecated */ public javax.servlet.http.HttpSessionContext getSessionContext() { - // Not sure this can be done per context helper and I think null is returned anyway + // Not sure this can be done per context helper and I think null is returned + // anyway return session.getSessionContext(); } @@ -262,7 +255,6 @@ public String toString() { return value; } - private static final String SIMPLE_NAME = - HttpSessionAdaptor.class.getSimpleName(); + private static final String SIMPLE_NAME = HttpSessionAdaptor.class.getSimpleName(); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java index bbeaf26ee03..3bd9407dbde 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpSessionTracker.java @@ -34,8 +34,7 @@ public HttpSessionTracker(HttpServiceRuntimeImpl httpServiceRuntime) { @Override public void invalidate(String sessionId, boolean invalidateParent) { - Set httpSessionAdaptors = - httpSessionAdaptorsMap.remove(sessionId); + Set httpSessionAdaptors = httpSessionAdaptorsMap.remove(sessionId); if (httpSessionAdaptors == null) { return; @@ -52,27 +51,21 @@ public void invalidate(String sessionId, boolean invalidateParent) { if (invalidateParent && parentSession != null) { try { parentSession.invalidate(); - } - catch (IllegalStateException ise) { - httpServiceRuntime.debug( - "Session was already invalidated: " + parentSession.getId(), ise); //$NON-NLS-1$ + } catch (IllegalStateException ise) { + httpServiceRuntime.debug("Session was already invalidated: " + parentSession.getId(), ise); //$NON-NLS-1$ } } } - public void addHttpSessionAdaptor( - String sessionId, HttpSessionAdaptor httpSessionAdaptor) { + public void addHttpSessionAdaptor(String sessionId, HttpSessionAdaptor httpSessionAdaptor) { - Set httpSessionAdaptors = - httpSessionAdaptorsMap.get(sessionId); + Set httpSessionAdaptors = httpSessionAdaptorsMap.get(sessionId); if (httpSessionAdaptors == null) { - httpSessionAdaptors = Collections.newSetFromMap( - new ConcurrentHashMap()); + httpSessionAdaptors = Collections.newSetFromMap(new ConcurrentHashMap()); - Set previousHttpSessionAdaptors = - httpSessionAdaptorsMap.putIfAbsent( - sessionId, httpSessionAdaptors); + Set previousHttpSessionAdaptors = httpSessionAdaptorsMap.putIfAbsent(sessionId, + httpSessionAdaptors); if (previousHttpSessionAdaptors != null) { httpSessionAdaptors = previousHttpSessionAdaptors; @@ -86,16 +79,14 @@ public void clear() { // At this point there should be no left over sessions. If // there are we'll log it because there's some kind of leak. if (!httpSessionAdaptorsMap.isEmpty()) { - httpServiceRuntime.debug( - "There are HttpSessionAdaptors left over. There might be a context or session leak!"); //$NON-NLS-1$ + httpServiceRuntime + .debug("There are HttpSessionAdaptors left over. There might be a context or session leak!"); //$NON-NLS-1$ } } - public boolean removeHttpSessionAdaptor( - String sessionId, HttpSessionAdaptor httpSessionAdaptor) { + public boolean removeHttpSessionAdaptor(String sessionId, HttpSessionAdaptor httpSessionAdaptor) { - Set httpSessionAdaptors = - httpSessionAdaptorsMap.get(sessionId); + Set httpSessionAdaptors = httpSessionAdaptorsMap.get(sessionId); if (httpSessionAdaptors == null) { return false; @@ -103,17 +94,14 @@ public boolean removeHttpSessionAdaptor( try { return httpSessionAdaptors.remove(httpSessionAdaptor); - } - finally { + } finally { if (httpSessionAdaptors.isEmpty()) { httpSessionAdaptorsMap.remove(sessionId, httpSessionAdaptors); } } } - private final ConcurrentMap> - httpSessionAdaptorsMap = - new ConcurrentHashMap<>(); + private final ConcurrentMap> httpSessionAdaptorsMap = new ConcurrentHashMap<>(); private final HttpServiceRuntimeImpl httpServiceRuntime; } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/PreprocessorChainImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/PreprocessorChainImpl.java index 47f416fc3c3..2a2405b417b 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/PreprocessorChainImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/PreprocessorChainImpl.java @@ -30,9 +30,8 @@ public class PreprocessorChainImpl implements FilterChain { private final int filterCount; private int filterIndex = 0; - public PreprocessorChainImpl( - List preprocessors, - String alias, DispatcherType dispatcherType, ProxyServlet proxyServlet) { + public PreprocessorChainImpl(List preprocessors, String alias, + DispatcherType dispatcherType, ProxyServlet proxyServlet) { this.preprocessors = preprocessors; this.alias = alias; @@ -45,14 +44,12 @@ public void doFilter(ServletRequest request, ServletResponse response) throws IO if (filterIndex < filterCount) { PreprocessorRegistration registration = preprocessors.get(filterIndex++); - registration.doFilter( - (HttpServletRequest) request, (HttpServletResponse) response, this); + registration.doFilter((HttpServletRequest) request, (HttpServletResponse) response, this); return; } - proxyServlet.dispatch( - (HttpServletRequest) request, (HttpServletResponse) response, alias, dispatcherType); + proxyServlet.dispatch((HttpServletRequest) request, (HttpServletResponse) response, alias, dispatcherType); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java index df672ad5d50..d2a30f8f0f3 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java @@ -32,10 +32,11 @@ import org.osgi.service.http.whiteboard.Preprocessor; /** - * The ProxyServlet is the private side of a Servlet that when registered (and init() called) in a servlet container - * will in-turn register and provide an OSGi Http Service implementation. - * This class is not meant for extending or even using directly and is purely meant for registering - * in a servlet container. + * The ProxyServlet is the private side of a Servlet that when registered (and + * init() called) in a servlet container will in-turn register and provide an + * OSGi Http Service implementation. This class is not meant for extending or + * even using directly and is purely meant for registering in a servlet + * container. */ public class ProxyServlet extends HttpServlet { @@ -54,8 +55,7 @@ public void destroy() { super.destroy(); } - public void setHttpServiceRuntimeImpl( - HttpServiceRuntimeImpl httpServiceRuntimeImpl) { + public void setHttpServiceRuntimeImpl(HttpServiceRuntimeImpl httpServiceRuntimeImpl) { this.httpServiceRuntimeImpl = httpServiceRuntimeImpl; } @@ -73,15 +73,15 @@ public void sessionIdChanged(String oldSessionId) { */ private String getNotDecodedAlias(HttpServletRequest request) { String pathInfo = HttpServletRequestWrapperImpl.getDispatchPathInfo(request); - if(pathInfo == null) { + if (pathInfo == null) { return null; } String requestUri = HttpServletRequestWrapperImpl.getDispatchRequestURI(request); String contextPath = request.getContextPath(); String servletPath = request.getServletPath(); if (request.getDispatcherType() == DispatcherType.INCLUDE) { - contextPath = (String)request.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH); - servletPath = (String)request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); + contextPath = (String) request.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH); + servletPath = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); } return requestUri.substring(contextPath.length() + servletPath.length()); } @@ -89,9 +89,8 @@ private String getNotDecodedAlias(HttpServletRequest request) { /** * @see HttpServlet#service(ServletRequest, ServletResponse) */ - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { checkRuntime(); @@ -104,17 +103,15 @@ protected void service( preprocess(request, response, alias, request.getDispatcherType()); } - public void preprocess( - HttpServletRequest request, - HttpServletResponse response, String alias, DispatcherType dispatcherType) - throws ServletException, IOException { + public void preprocess(HttpServletRequest request, HttpServletResponse response, String alias, + DispatcherType dispatcherType) throws ServletException, IOException { - Map, PreprocessorRegistration> registrations = httpServiceRuntimeImpl.getPreprocessorRegistrations(); + Map, PreprocessorRegistration> registrations = httpServiceRuntimeImpl + .getPreprocessorRegistrations(); if (registrations.isEmpty()) { dispatch(request, response, alias, dispatcherType); - } - else { + } else { List preprocessors = new CopyOnWriteArrayList<>(); for (Entry, PreprocessorRegistration> entry : registrations.entrySet()) { @@ -127,8 +124,7 @@ public void preprocess( FilterChain chain = new PreprocessorChainImpl(preprocessors, alias, dispatcherType, this); chain.doFilter(request, response); - } - finally { + } finally { for (PreprocessorRegistration registration : preprocessors) { registration.removeReference(); } @@ -136,10 +132,8 @@ public void preprocess( } } - public void dispatch( - HttpServletRequest request, - HttpServletResponse response, String alias, DispatcherType dispatcherType) - throws ServletException, IOException { + public void dispatch(HttpServletRequest request, HttpServletResponse response, String alias, + DispatcherType dispatcherType) throws ServletException, IOException { DispatchTargets dispatchTargets = httpServiceRuntimeImpl.getDispatchTargets(alias, null); @@ -149,14 +143,12 @@ public void dispatch( return; } - response.sendError( - HttpServletResponse.SC_NOT_FOUND, "ProxyServlet: " + alias); //$NON-NLS-1$ + response.sendError(HttpServletResponse.SC_NOT_FOUND, "ProxyServlet: " + alias); //$NON-NLS-1$ } private void checkRuntime() { if (httpServiceRuntimeImpl == null) { - throw new IllegalStateException( - "Proxy servlet not properly initialized. httpServiceRuntimeImpl is null"); //$NON-NLS-1$ + throw new IllegalStateException("Proxy servlet not properly initialized. httpServiceRuntimeImpl is null"); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java index 301befb0d86..093f59ba1ee 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java @@ -30,27 +30,22 @@ public class RequestDispatcherAdaptor implements RequestDispatcher { private final String path; private String string; - public RequestDispatcherAdaptor( - DispatchTargets dispatchTargets, String path) { + public RequestDispatcherAdaptor(DispatchTargets dispatchTargets, String path) { this.dispatchTargets = dispatchTargets; this.path = path; } - public void forward(ServletRequest request, ServletResponse response) - throws IOException, ServletException { + public void forward(ServletRequest request, ServletResponse response) throws IOException, ServletException { - dispatchTargets.doDispatch( - (HttpServletRequest)request, (HttpServletResponse)response, - path, DispatcherType.FORWARD); + dispatchTargets.doDispatch((HttpServletRequest) request, (HttpServletResponse) response, path, + DispatcherType.FORWARD); } - public void include(ServletRequest request, ServletResponse response) - throws IOException, ServletException { + public void include(ServletRequest request, ServletResponse response) throws IOException, ServletException { - dispatchTargets.doDispatch( - (HttpServletRequest)request, (HttpServletResponse)response, - path, DispatcherType.INCLUDE); + dispatchTargets.doDispatch((HttpServletRequest) request, (HttpServletResponse) response, path, + DispatcherType.INCLUDE); } @Override diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResourceServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResourceServlet.java index 17c29f09f3a..196801fe77b 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResourceServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResourceServlet.java @@ -68,7 +68,8 @@ public void service(HttpServletRequest req, final HttpServletResponse resp) thro } } - private void writeResource(final HttpServletRequest req, final HttpServletResponse resp, final String resourcePath, final URL resourceURL) throws IOException { + private void writeResource(final HttpServletRequest req, final HttpServletResponse resp, final String resourcePath, + final URL resourceURL) throws IOException { try { AccessController.doPrivileged((PrivilegedExceptionAction) () -> { URLConnection connection = resourceURL.openConnection(); @@ -80,7 +81,8 @@ private void writeResource(final HttpServletRequest req, final HttpServletRespon etag = "W/\"" + contentLength + "-" + lastModified + "\""; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ // Check for cache revalidation. - // We should prefer ETag validation as the guarantees are stronger and all HTTP 1.1 clients should be using it + // We should prefer ETag validation as the guarantees are stronger and all HTTP + // 1.1 clients should be using it String ifNoneMatch = req.getHeader(IF_NONE_MATCH); if (ifNoneMatch != null && etag != null && ifNoneMatch.indexOf(etag) != -1) { resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); @@ -127,9 +129,9 @@ private void writeResource(final HttpServletRequest req, final HttpServletRespon if (etag != null) resp.setHeader(ETAG, etag); - if (range == null && - (servletContextHelper instanceof RangeAwareServletContextHelper) && - ((RangeAwareServletContextHelper)servletContextHelper).rangeableContentType(contentType, req.getHeader("User-Agent"))) { //$NON-NLS-1$ + if (range == null && (servletContextHelper instanceof RangeAwareServletContextHelper) + && ((RangeAwareServletContextHelper) servletContextHelper).rangeableContentType(contentType, + req.getHeader("User-Agent"))) { //$NON-NLS-1$ range = new Range(); range.firstBytePos = 0; @@ -141,7 +143,8 @@ private void writeResource(final HttpServletRequest req, final HttpServletRespon resp.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); resp.setHeader(ACCEPT_RANGES, RANGE_UNIT_BYTES); resp.setContentLength(range.contentLength()); - resp.setHeader(CONTENT_RANGE, RANGE_UNIT_BYTES + " " + range.firstBytePos + "-" + range.lastBytePos + "/" + range.completeLength); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + resp.setHeader(CONTENT_RANGE, RANGE_UNIT_BYTES + " " + range.firstBytePos + "-" + range.lastBytePos //$NON-NLS-1$ //$NON-NLS-2$ + + "/" + range.completeLength); //$NON-NLS-1$ } if (contentLength != 0) { @@ -153,7 +156,8 @@ private void writeResource(final HttpServletRequest req, final HttpServletRespon int writtenContentLength = writeResourceToOutputStream(is, os, range); if (contentLength == -1 || contentLength != writtenContentLength) resp.setContentLength(writtenContentLength); - } catch (IllegalStateException e) { // can occur if the response output is already open as a Writer + } catch (IllegalStateException e) { // can occur if the response output is already open as a + // Writer Writer writer = resp.getWriter(); writeResourceToWriter(is, writer, range); // Since ContentLength is a measure of the number of bytes contained in the body @@ -196,8 +200,10 @@ int writeResourceToOutputStream(InputStream is, OutputStream os, Range range) th byte[] buffer = new byte[8192]; int bytesRead = is.read(buffer); int writtenContentLength = 0; - while (bytesRead != -1 && (range == null || range.lastBytePos == Range.NOT_SET || writtenContentLength < range.lastBytePos)) { - if (range != null && range.lastBytePos != Range.NOT_SET && (bytesRead + writtenContentLength) > range.lastBytePos) { + while (bytesRead != -1 + && (range == null || range.lastBytePos == Range.NOT_SET || writtenContentLength < range.lastBytePos)) { + if (range != null && range.lastBytePos != Range.NOT_SET + && (bytesRead + writtenContentLength) > range.lastBytePos) { bytesRead = range.contentLength() - writtenContentLength; } os.write(buffer, 0, bytesRead); @@ -220,8 +226,10 @@ void writeResourceToWriter(InputStream is, Writer writer, Range range) throws IO char[] buffer = new char[8192]; int charsRead = reader.read(buffer); int writtenContentLength = 0; - while (charsRead != -1 && (range == null || range.lastBytePos == Range.NOT_SET || writtenContentLength < range.lastBytePos)) { - if (range != null && range.lastBytePos != Range.NOT_SET && (charsRead + writtenContentLength) > range.lastBytePos) { + while (charsRead != -1 && (range == null || range.lastBytePos == Range.NOT_SET + || writtenContentLength < range.lastBytePos)) { + if (range != null && range.lastBytePos != Range.NOT_SET + && (charsRead + writtenContentLength) > range.lastBytePos) { charsRead = range.contentLength() - writtenContentLength; } writer.write(buffer, 0, charsRead); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java index f5bd5c78390..c565fe685b7 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java @@ -31,9 +31,8 @@ */ public class ResponseStateHandler { - public ResponseStateHandler( - HttpServletRequest request, HttpServletResponse response, - DispatchTargets dispatchTargets) { + public ResponseStateHandler(HttpServletRequest request, HttpServletResponse response, + DispatchTargets dispatchTargets) { this.request = request; this.response = response; @@ -65,38 +64,31 @@ public void processRequest() throws IOException, ServletException { try { if (filters.isEmpty()) { endpoint.service(request, response); - } - else { + } else { Collections.sort(filters); - FilterChain chain = new FilterChainImpl( - filters, endpoint, dispatchTargets.getDispatcherType()); + FilterChain chain = new FilterChainImpl(filters, endpoint, dispatchTargets.getDispatcherType()); chain.doFilter(request, response); } - } - finally { + } finally { endpoint.getServletContextHelper().finishSecurity(request, response); } } - } - catch (Exception e) { - if (!(e instanceof IOException) && - !(e instanceof RuntimeException) && - !(e instanceof ServletException)) { + } catch (Exception e) { + if (!(e instanceof IOException) && !(e instanceof RuntimeException) && !(e instanceof ServletException)) { e = new ServletException(e); } setException(e); - if (dispatchTargets.getDispatcherType() != DispatcherType.ERROR && - dispatchTargets.getDispatcherType() != DispatcherType.REQUEST) { + if (dispatchTargets.getDispatcherType() != DispatcherType.ERROR + && dispatchTargets.getDispatcherType() != DispatcherType.REQUEST) { throwException(e); } - } - finally { + } finally { endpoint.removeReference(); for (FilterRegistration filterRegistration : filters) { @@ -109,8 +101,8 @@ public void processRequest() throws IOException, ServletException { PrintWriter writer = response.getWriter(); - Integer status = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - String message = (String)request.getAttribute(RequestDispatcher.ERROR_MESSAGE); + Integer status = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + String message = (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE); if (message == null) { message = exception.getMessage(); @@ -143,24 +135,21 @@ public void processRequest() throws IOException, ServletException { if (dispatchTargets.getDispatcherType() == DispatcherType.FORWARD) { response.flushBuffer(); - HttpServletResponseWrapperImpl responseWrapper = HttpServletResponseWrapperImpl.findHttpRuntimeResponse(response); + HttpServletResponseWrapperImpl responseWrapper = HttpServletResponseWrapperImpl + .findHttpRuntimeResponse(response); if (responseWrapper != null) { responseWrapper.setCompleted(true); - } - else { + } else { try (PrintWriter writer = response.getWriter()) { // just force a close - } - catch (IllegalStateException ise1) { + } catch (IllegalStateException ise1) { try (ServletOutputStream outputStream = response.getOutputStream()) { // just force a close - } - catch (IllegalStateException | IOException ise2) { + } catch (IllegalStateException | IOException ise2) { // ignore } - } - catch (IOException ioe) { + } catch (IOException ioe) { // ignore } } @@ -187,8 +176,7 @@ private List getServletRequestListener() { private void handleErrors() throws IOException, ServletException { if (exception != null) { handleException(); - } - else { + } else { handleResponseCode(); } } @@ -198,13 +186,14 @@ private void handleException() throws IOException, ServletException { throw new IllegalStateException("Response isn't a wrapper"); //$NON-NLS-1$ } - HttpServletResponseWrapperImpl responseWrapper = HttpServletResponseWrapperImpl.findHttpRuntimeResponse(response); + HttpServletResponseWrapperImpl responseWrapper = HttpServletResponseWrapperImpl + .findHttpRuntimeResponse(response); if (responseWrapper == null) { throw new IllegalStateException("Can't locate response impl"); //$NON-NLS-1$ } - HttpServletResponse wrappedResponse = (HttpServletResponse)responseWrapper.getResponse(); + HttpServletResponse wrappedResponse = (HttpServletResponse) responseWrapper.getResponse(); if (wrappedResponse.isCommitted()) { throwException(exception); @@ -218,8 +207,8 @@ private void handleException() throws IOException, ServletException { DispatchTargets errorDispatchTargets; do { - errorDispatchTargets = contextController.getDispatchTargets( - className, null, null, null, null, null, Match.ERROR, null); + errorDispatchTargets = contextController.getDispatchTargets(className, null, null, null, null, null, + Match.ERROR, null); if (errorDispatchTargets != null) { break; @@ -227,14 +216,14 @@ private void handleException() throws IOException, ServletException { clazz = clazz.getSuperclass(); className = clazz.getName(); - } - while (Exception.class.isAssignableFrom(clazz)); + } while (Exception.class.isAssignableFrom(clazz)); if (errorDispatchTargets == null) { throwException(exception); } - HttpServletRequestWrapperImpl httpRuntimeRequest = HttpServletRequestWrapperImpl.findHttpRuntimeRequest(request); + HttpServletRequestWrapperImpl httpRuntimeRequest = HttpServletRequestWrapperImpl + .findHttpRuntimeRequest(request); try { errorDispatchTargets.setDispatcherType(DispatcherType.ERROR); @@ -270,17 +259,15 @@ public DispatcherType getDispatcherType() { }; - HttpServletResponseWrapper wrapperResponse = - new HttpServletResponseWrapperImpl(wrappedResponse); + HttpServletResponseWrapper wrapperResponse = new HttpServletResponseWrapperImpl(wrappedResponse); - ResponseStateHandler responseStateHandler = new ResponseStateHandler( - wrapperRequest, wrapperResponse, errorDispatchTargets); + ResponseStateHandler responseStateHandler = new ResponseStateHandler(wrapperRequest, wrapperResponse, + errorDispatchTargets); responseStateHandler.processRequest(); wrappedResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - finally { + } finally { httpRuntimeRequest.pop(); } } @@ -290,7 +277,8 @@ private void handleResponseCode() throws IOException, ServletException { throw new IllegalStateException("Response isn't a wrapper"); //$NON-NLS-1$ } - final HttpServletResponseWrapperImpl responseWrapper = HttpServletResponseWrapperImpl.findHttpRuntimeResponse(response); + final HttpServletResponseWrapperImpl responseWrapper = HttpServletResponseWrapperImpl + .findHttpRuntimeResponse(response); if (responseWrapper == null) { throw new IllegalStateException("Can't locate response impl"); //$NON-NLS-1$ @@ -302,7 +290,7 @@ private void handleResponseCode() throws IOException, ServletException { return; } - HttpServletResponse wrappedResponse = (HttpServletResponse)responseWrapper.getResponse(); + HttpServletResponse wrappedResponse = (HttpServletResponse) responseWrapper.getResponse(); if (wrappedResponse.isCommitted()) { // There's nothing more we can do here. @@ -311,8 +299,8 @@ private void handleResponseCode() throws IOException, ServletException { ContextController contextController = dispatchTargets.getContextController(); - DispatchTargets errorDispatchTargets = contextController.getDispatchTargets( - String.valueOf(status), null, null, null, null, null, Match.ERROR, null); + DispatchTargets errorDispatchTargets = contextController.getDispatchTargets(String.valueOf(status), null, null, + null, null, null, Match.ERROR, null); if (errorDispatchTargets == null) { wrappedResponse.sendError(status, responseWrapper.getMessage()); @@ -320,7 +308,8 @@ private void handleResponseCode() throws IOException, ServletException { return; } - HttpServletRequestWrapperImpl httpRuntimeRequest = HttpServletRequestWrapperImpl.findHttpRuntimeRequest(request); + HttpServletRequestWrapperImpl httpRuntimeRequest = HttpServletRequestWrapperImpl + .findHttpRuntimeRequest(request); try { errorDispatchTargets.setDispatcherType(DispatcherType.ERROR); @@ -352,32 +341,27 @@ public DispatcherType getDispatcherType() { }; - HttpServletResponseWrapper wrapperResponse = - new HttpServletResponseWrapperImpl(wrappedResponse); + HttpServletResponseWrapper wrapperResponse = new HttpServletResponseWrapperImpl(wrappedResponse); - ResponseStateHandler responseStateHandler = new ResponseStateHandler( - wrapperRequest, wrapperResponse, errorDispatchTargets); + ResponseStateHandler responseStateHandler = new ResponseStateHandler(wrapperRequest, wrapperResponse, + errorDispatchTargets); wrappedResponse.setStatus(status); responseStateHandler.processRequest(); - } - finally { + } finally { httpRuntimeRequest.pop(); } } - private void throwException(Exception e) - throws IOException, ServletException { + private void throwException(Exception e) throws IOException, ServletException { if (e instanceof RuntimeException) { - throw (RuntimeException)e; - } - else if (e instanceof IOException) { - throw (IOException)e; - } - else if (e instanceof ServletException) { - throw (ServletException)e; + throw (RuntimeException) e; + } else if (e instanceof IOException) { + throw (IOException) e; + } else if (e instanceof ServletException) { + throw (ServletException) e; } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletConfigImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletConfigImpl.java index 6eac9ab1195..c3847d082c0 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletConfigImpl.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletConfigImpl.java @@ -25,16 +25,13 @@ public class ServletConfigImpl implements ServletConfig { private final ServletContext servletContext; private final String servletName; - public ServletConfigImpl( - String servletName, Map initparams, - ServletContext servletContext) { + public ServletConfigImpl(String servletName, Map initparams, ServletContext servletContext) { this.servletName = servletName; if (initparams != null) { this.initparams = initparams; - } - else { + } else { this.initparams = Collections.emptyMap(); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java index 7fdde3bcc55..4d129b11d6a 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java @@ -40,43 +40,37 @@ public class ServletContextAdaptor { private static Map createContextToHandlerMethods() { Map methods = new HashMap<>(); - Method[] handlerMethods = - ServletContextAdaptor.class.getDeclaredMethods(); + Method[] handlerMethods = ServletContextAdaptor.class.getDeclaredMethods(); for (Method handlerMethod : handlerMethods) { String name = handlerMethod.getName(); Class[] parameterTypes = handlerMethod.getParameterTypes(); try { - Method method = ServletContext.class.getMethod( - name, parameterTypes); + Method method = ServletContext.class.getMethod(name, parameterTypes); methods.put(method, handlerMethod); - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { // do nothing } } try { - Method equalsMethod = Object.class.getMethod("equals", Object.class); //$NON-NLS-1$ + Method equalsMethod = Object.class.getMethod("equals", Object.class); //$NON-NLS-1$ Method equalsHandlerMethod = ServletContextAdaptor.class.getMethod("equals", Object.class); //$NON-NLS-1$ methods.put(equalsMethod, equalsHandlerMethod); - Method hashCodeMethod = Object.class.getMethod("hashCode", (Class[])null); //$NON-NLS-1$ - Method hashCodeHandlerMethod = ServletContextAdaptor.class.getMethod("hashCode", (Class[])null); //$NON-NLS-1$ + Method hashCodeMethod = Object.class.getMethod("hashCode", (Class[]) null); //$NON-NLS-1$ + Method hashCodeHandlerMethod = ServletContextAdaptor.class.getMethod("hashCode", (Class[]) null); //$NON-NLS-1$ methods.put(hashCodeMethod, hashCodeHandlerMethod); - } - catch (NoSuchMethodException e) { - // do nothing + } catch (NoSuchMethodException e) { + // do nothing } return methods; } - public ServletContextAdaptor( - ContextController contextController, Bundle bundle, - ServletContextHelper servletContextHelper, - EventListeners eventListeners, AccessControlContext acc) { + public ServletContextAdaptor(ContextController contextController, Bundle bundle, + ServletContextHelper servletContextHelper, EventListeners eventListeners, AccessControlContext acc) { this.contextController = contextController; this.proxyContext = contextController.getProxyContext(); @@ -94,19 +88,18 @@ public ServletContextAdaptor( public ServletContext createServletContext() { Class clazz = getClass(); ClassLoader curClassLoader = clazz.getClassLoader(); - Class[] interfaces = new Class[] {ServletContext.class}; + Class[] interfaces = new Class[] { ServletContext.class }; - return (ServletContext)Proxy.newProxyInstance( - curClassLoader, interfaces, new AdaptorInvocationHandler()); + return (ServletContext) Proxy.newProxyInstance(curClassLoader, interfaces, new AdaptorInvocationHandler()); } @Override - public boolean equals (Object obj) { + public boolean equals(Object obj) { if (!(obj instanceof ServletContext)) { return false; } - if (!(Proxy.isProxyClass(obj.getClass()))) { + if (!(Proxy.isProxyClass(obj.getClass()))) { return false; } @@ -116,7 +109,7 @@ public boolean equals (Object obj) { return false; } - AdaptorInvocationHandler adaptorInvocationHandler = (AdaptorInvocationHandler)invocationHandler; + AdaptorInvocationHandler adaptorInvocationHandler = (AdaptorInvocationHandler) invocationHandler; return contextController.equals(adaptorInvocationHandler.getContextController()); } @@ -149,8 +142,7 @@ public String getInitParameter(String name) { } public Enumeration getInitParameterNames() { - return Collections.enumeration( - contextController.getInitParams().keySet()); + return Collections.enumeration(contextController.getInitParams().keySet()); } public String getMimeType(final String name) { @@ -158,10 +150,8 @@ public String getMimeType(final String name) { try { mimeType = AccessController.doPrivileged( - (PrivilegedExceptionAction) () -> servletContextHelper.getMimeType(name), acc - ); - } - catch (PrivilegedActionException e) { + (PrivilegedExceptionAction) () -> servletContextHelper.getMimeType(name), acc); + } catch (PrivilegedActionException e) { servletContext.log(e.getException().getMessage(), e.getException()); } @@ -169,8 +159,8 @@ public String getMimeType(final String name) { } public RequestDispatcher getNamedDispatcher(String servletName) { - DispatchTargets dispatchTargets = contextController.getDispatchTargets( - servletName, null, null, null, null, null, Match.EXACT, null); + DispatchTargets dispatchTargets = contextController.getDispatchTargets(servletName, null, null, null, null, + null, Match.EXACT, null); if (dispatchTargets == null) { return null; @@ -182,10 +172,8 @@ public RequestDispatcher getNamedDispatcher(String servletName) { public String getRealPath(final String path) { try { return AccessController.doPrivileged( - (PrivilegedExceptionAction) () -> servletContextHelper.getRealPath(path), acc - ); - } - catch (PrivilegedActionException e) { + (PrivilegedExceptionAction) () -> servletContextHelper.getRealPath(path), acc); + } catch (PrivilegedActionException e) { servletContext.log(e.getException().getMessage(), e.getException()); } @@ -213,11 +201,9 @@ public RequestDispatcher getRequestDispatcher(String path) { public URL getResource(final String name) { try { - return AccessController.doPrivileged( - (PrivilegedExceptionAction) () -> servletContextHelper.getResource(name), acc - ); - } - catch (PrivilegedActionException e) { + return AccessController + .doPrivileged((PrivilegedExceptionAction) () -> servletContextHelper.getResource(name), acc); + } catch (PrivilegedActionException e) { servletContext.log(e.getException().getMessage(), e.getException()); } @@ -230,8 +216,7 @@ public InputStream getResourceAsStream(String name) { if (url != null) { try { return url.openStream(); - } - catch (IOException ioe) { + } catch (IOException ioe) { servletContext.log(ioe.getMessage(), ioe); } } @@ -240,7 +225,7 @@ public InputStream getResourceAsStream(String name) { } /** - * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String) + * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String) */ public Set getResourcePaths(final String name) { if (name == null || !name.startsWith(Const.SLASH)) @@ -248,10 +233,8 @@ public Set getResourcePaths(final String name) { try { return AccessController.doPrivileged( - (PrivilegedExceptionAction>) () -> servletContextHelper.getResourcePaths(name), acc - ); - } - catch (PrivilegedActionException e) { + (PrivilegedExceptionAction>) () -> servletContextHelper.getResourcePaths(name), acc); + } catch (PrivilegedActionException e) { servletContext.log(e.getException().getMessage(), e.getException()); } @@ -271,49 +254,52 @@ public void removeAttribute(String attributeName) { Dictionary attributes = getContextAttributes(); Object attributeValue = attributes.remove(attributeName); - List listeners = - eventListeners.get(ServletContextAttributeListener.class); + List listeners = eventListeners.get(ServletContextAttributeListener.class); if (listeners.isEmpty()) { return; } - ServletContextAttributeEvent servletContextAttributeEvent = - new ServletContextAttributeEvent( + ServletContextAttributeEvent servletContextAttributeEvent = new ServletContextAttributeEvent( servletContextTL.get(), attributeName, attributeValue); for (ServletContextAttributeListener servletContextAttributeListener : listeners) { - servletContextAttributeListener.attributeRemoved( - servletContextAttributeEvent); + servletContextAttributeListener.attributeRemoved(servletContextAttributeEvent); } } public void addFilter(String arg1, Class arg2) { throw new UnsupportedOperationException(); } + public void addFilter(String arg1, String arg2) { throw new UnsupportedOperationException(); } + public void addFilter(String arg1, Filter arg2) { throw new UnsupportedOperationException(); } - public void addListener(Class arg1){ + public void addListener(Class arg1) { throw new UnsupportedOperationException(); } - public void addListener(String arg1){ + + public void addListener(String arg1) { throw new UnsupportedOperationException(); } - public void addListener(EventListener arg1){ + + public void addListener(EventListener arg1) { throw new UnsupportedOperationException(); } public void addServlet(String arg1, Class arg2) { throw new UnsupportedOperationException(); } + public void addServlet(String arg1, String arg2) { throw new UnsupportedOperationException(); } + public void addServlet(String arg1, Servlet arg2) { throw new UnsupportedOperationException(); } @@ -321,9 +307,11 @@ public void addServlet(String arg1, Servlet arg2) { public void createFilter(Class arg1) { throw new UnsupportedOperationException(); } + public void createServlet(Class arg1) { throw new UnsupportedOperationException(); } + public void createListener(Class arg1) { throw new UnsupportedOperationException(); } @@ -343,25 +331,20 @@ public void setAttribute(String attributeName, Object attributeValue) { boolean added = (attributes.get(attributeName) == null); attributes.put(attributeName, attributeValue); - List listeners = - eventListeners.get(ServletContextAttributeListener.class); + List listeners = eventListeners.get(ServletContextAttributeListener.class); if (listeners.isEmpty()) { return; } - ServletContextAttributeEvent servletContextAttributeEvent = - new ServletContextAttributeEvent( + ServletContextAttributeEvent servletContextAttributeEvent = new ServletContextAttributeEvent( servletContextTL.get(), attributeName, attributeValue); for (ServletContextAttributeListener servletContextAttributeListener : listeners) { if (added) { - servletContextAttributeListener.attributeAdded( - servletContextAttributeEvent); - } - else { - servletContextAttributeListener.attributeReplaced( - servletContextAttributeEvent); + servletContextAttributeListener.attributeAdded(servletContextAttributeEvent); + } else { + servletContextAttributeListener.attributeReplaced(servletContextAttributeEvent); } } } @@ -380,12 +363,11 @@ public String toString() { } Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - boolean useThreadLocal = - "removeAttribute".equals(method.getName()) || //$NON-NLS-1$ - "setAttribute".equals(method.getName()); //$NON-NLS-1$ + boolean useThreadLocal = "removeAttribute".equals(method.getName()) || //$NON-NLS-1$ + "setAttribute".equals(method.getName()); //$NON-NLS-1$ if (useThreadLocal) { - servletContextTL.set((ServletContext)proxy); + servletContextTL.set((ServletContext) proxy); } try { @@ -398,8 +380,7 @@ Object invoke(Object proxy, Method method, Object[] args) throws Throwable { } catch (InvocationTargetException e) { throw e.getCause(); } - } - finally { + } finally { if (useThreadLocal) { servletContextTL.remove(); } @@ -411,23 +392,22 @@ private Dictionary getContextAttributes() { } private class AdaptorInvocationHandler implements InvocationHandler { - public AdaptorInvocationHandler() {} + public AdaptorInvocationHandler() { + } public ContextController getContextController() { return contextController; } @Override - public Object invoke(Object proxy, Method method, Object[] args) - throws Throwable { + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return ServletContextAdaptor.this.invoke(proxy, method, args); } } - private final static String SIMPLE_NAME = - ServletContextAdaptor.class.getSimpleName(); + private final static String SIMPLE_NAME = ServletContextAdaptor.class.getSimpleName(); private final static ThreadLocal servletContextTL = new ThreadLocal<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java index 1eb228062a1..c136cf877e8 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/BooleanPlus.java @@ -14,7 +14,6 @@ package org.eclipse.equinox.http.servlet.internal.util; - /** * @author Raymond Augé */ @@ -22,13 +21,11 @@ public class BooleanPlus { public static boolean from(Object object, boolean defaultValue) { if (object instanceof Boolean) { - return ((Boolean)object).booleanValue(); - } - else if (object instanceof String) { - if (Boolean.TRUE.toString().equalsIgnoreCase((String)object)) { + return ((Boolean) object).booleanValue(); + } else if (object instanceof String) { + if (Boolean.TRUE.toString().equalsIgnoreCase((String) object)) { return true; - } - else if (Boolean.FALSE.toString().equalsIgnoreCase((String)object)) { + } else if (Boolean.FALSE.toString().equalsIgnoreCase((String) object)) { return false; } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/DTOUtil.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/DTOUtil.java index 3c4bec30baf..63bbaff4398 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/DTOUtil.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/DTOUtil.java @@ -31,7 +31,8 @@ */ public class DTOUtil { - public static ExtendedErrorPageDTO assembleErrorPageDTO(ServiceReference serviceReference, long contextId, boolean validated) { + public static ExtendedErrorPageDTO assembleErrorPageDTO(ServiceReference serviceReference, long contextId, + boolean validated) { Object errorPageObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_ERROR_PAGE); if (errorPageObj == null) { @@ -44,24 +45,24 @@ public static ExtendedErrorPageDTO assembleErrorPageDTO(ServiceReference serv Object asyncSupportedObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED); if (asyncSupportedObj == null) { // ignored + } else if (Boolean.class.isInstance(asyncSupportedObj)) { + errorPageDTO.asyncSupported = ((Boolean) asyncSupportedObj).booleanValue(); + } else if (String.class.isInstance(asyncSupportedObj)) { + errorPageDTO.asyncSupported = Boolean.valueOf((String) asyncSupportedObj); } - else if (Boolean.class.isInstance(asyncSupportedObj)) { - errorPageDTO.asyncSupported = ((Boolean)asyncSupportedObj).booleanValue(); - } - else if (String.class.isInstance(asyncSupportedObj)) { - errorPageDTO.asyncSupported = Boolean.valueOf((String)asyncSupportedObj); - } - // There is no validation for this scenario, truthiness of any other input is false + // There is no validation for this scenario, truthiness of any other input is + // false List errorPages = StringPlus.from(errorPageObj); if (errorPages.isEmpty()) { - throw new HttpWhiteboardFailureException("'errorPage' expects String, String[] or Collection", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("'errorPage' expects String, String[] or Collection", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } List exceptions = new ArrayList<>(); Set errorCodeSet = new LinkedHashSet<>(); - for(String errorPage : errorPages) { + for (String errorPage : errorPages) { try { if ("4xx".equals(errorPage)) { //$NON-NLS-1$ errorPageDTO.errorCodeType = ErrorCodeType.RANGE_4XX; @@ -80,60 +81,58 @@ else if (String.class.isInstance(asyncSupportedObj)) { } else { exceptions.add(errorPage); } - } - catch (NumberFormatException nfe) { + } catch (NumberFormatException nfe) { exceptions.add(errorPage); } } errorPageDTO.errorCodes = new long[errorCodeSet.size()]; int i = 0; - for(Long code : errorCodeSet) { + for (Long code : errorCodeSet) { errorPageDTO.errorCodes[i] = code; i++; } errorPageDTO.exceptions = exceptions.toArray(new String[0]); - errorPageDTO.initParams = ServiceProperties.parseInitParams( - serviceReference, HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX); + errorPageDTO.initParams = ServiceProperties.parseInitParams(serviceReference, + HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX); Object servletNameObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_NAME); if (servletNameObj == null) { // ignore - } - else if (String.class.isInstance(servletNameObj)) { - errorPageDTO.name = (String)servletNameObj; - } - else if (validated) { - throw new HttpWhiteboardFailureException("'name' expects String", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + } else if (String.class.isInstance(servletNameObj)) { + errorPageDTO.name = (String) servletNameObj; + } else if (validated) { + throw new HttpWhiteboardFailureException("'name' expects String", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - errorPageDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + errorPageDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); errorPageDTO.servletContextId = contextId; return errorPageDTO; } @SuppressWarnings("deprecation") - public static org.eclipse.equinox.http.servlet.dto.ExtendedServletDTO assembleServletDTO(ServiceReference serviceReference, long contextId, boolean validated) { + public static org.eclipse.equinox.http.servlet.dto.ExtendedServletDTO assembleServletDTO( + ServiceReference serviceReference, long contextId, boolean validated) { org.eclipse.equinox.http.servlet.dto.ExtendedServletDTO servletDTO = new org.eclipse.equinox.http.servlet.dto.ExtendedServletDTO(); servletDTO.asyncSupported = false; Object asyncSupportedObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED); if (asyncSupportedObj == null) { // ignored + } else if (Boolean.class.isInstance(asyncSupportedObj)) { + servletDTO.asyncSupported = ((Boolean) asyncSupportedObj).booleanValue(); + } else if (String.class.isInstance(asyncSupportedObj)) { + servletDTO.asyncSupported = Boolean.valueOf((String) asyncSupportedObj); } - else if (Boolean.class.isInstance(asyncSupportedObj)) { - servletDTO.asyncSupported = ((Boolean)asyncSupportedObj).booleanValue(); - } - else if (String.class.isInstance(asyncSupportedObj)) { - servletDTO.asyncSupported = Boolean.valueOf((String)asyncSupportedObj); - } - // There is no validation for this scenario, truthiness of any other input is false + // There is no validation for this scenario, truthiness of any other input is + // false - servletDTO.initParams = ServiceProperties.parseInitParams( - serviceReference, HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX); + servletDTO.initParams = ServiceProperties.parseInitParams(serviceReference, + HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX); servletDTO.multipartEnabled = false; Object multipartEnabledObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED); @@ -142,14 +141,13 @@ else if (String.class.isInstance(asyncSupportedObj)) { } if (multipartEnabledObj == null) { // ignore + } else if (Boolean.class.isInstance(multipartEnabledObj)) { + servletDTO.multipartEnabled = ((Boolean) multipartEnabledObj).booleanValue(); + } else if (String.class.isInstance(multipartEnabledObj)) { + servletDTO.multipartEnabled = Boolean.valueOf((String) multipartEnabledObj); } - else if (Boolean.class.isInstance(multipartEnabledObj)) { - servletDTO.multipartEnabled = ((Boolean)multipartEnabledObj).booleanValue(); - } - else if (String.class.isInstance(multipartEnabledObj)) { - servletDTO.multipartEnabled = Boolean.valueOf((String)multipartEnabledObj); - } - // There is no validation for this scenario, truthiness of any other input is false + // There is no validation for this scenario, truthiness of any other input is + // false servletDTO.multipartFileSizeThreshold = 0; servletDTO.multipartLocation = Const.BLANK; @@ -157,18 +155,19 @@ else if (String.class.isInstance(multipartEnabledObj)) { servletDTO.multipartMaxRequestSize = -1L; if (servletDTO.multipartEnabled) { - Object multipartFileSizeThresholdObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_FILESIZETHRESHOLD); + Object multipartFileSizeThresholdObj = serviceReference + .getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_FILESIZETHRESHOLD); if (multipartFileSizeThresholdObj == null) { - multipartFileSizeThresholdObj = serviceReference.getProperty(Const.EQUINOX_HTTP_MULTIPART_FILESIZETHRESHOLD); + multipartFileSizeThresholdObj = serviceReference + .getProperty(Const.EQUINOX_HTTP_MULTIPART_FILESIZETHRESHOLD); } if (multipartFileSizeThresholdObj == null) { // ignore - } - else if (Integer.class.isInstance(multipartFileSizeThresholdObj)) { - servletDTO.multipartFileSizeThreshold = ((Integer)multipartFileSizeThresholdObj).intValue(); - } - else if (validated) { - throw new HttpWhiteboardFailureException("'multipartFileSizeThreshold' expects int or Integer", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + } else if (Integer.class.isInstance(multipartFileSizeThresholdObj)) { + servletDTO.multipartFileSizeThreshold = ((Integer) multipartFileSizeThresholdObj).intValue(); + } else if (validated) { + throw new HttpWhiteboardFailureException("'multipartFileSizeThreshold' expects int or Integer", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } Object multipartLocationObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_LOCATION); @@ -177,59 +176,56 @@ else if (validated) { } if (multipartLocationObj == null) { // ignore - } - else if (String.class.isInstance(multipartLocationObj)) { - servletDTO.multipartLocation = (String)multipartLocationObj; - } - else if (validated) { - throw new HttpWhiteboardFailureException("'multipartLocation' expects String", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + } else if (String.class.isInstance(multipartLocationObj)) { + servletDTO.multipartLocation = (String) multipartLocationObj; + } else if (validated) { + throw new HttpWhiteboardFailureException("'multipartLocation' expects String", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - Object multipartMaxFileSizeObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE); + Object multipartMaxFileSizeObj = serviceReference + .getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE); if (multipartMaxFileSizeObj == null) { multipartMaxFileSizeObj = serviceReference.getProperty(Const.EQUINOX_HTTP_MULTIPART_MAXFILESIZE); } if (multipartMaxFileSizeObj == null) { // ignore - } - else if (Long.class.isInstance(multipartMaxFileSizeObj)) { - servletDTO.multipartMaxFileSize = ((Long)multipartMaxFileSizeObj).longValue(); - } - else if (validated) { - throw new HttpWhiteboardFailureException("'multipartMaxFileSize' expects [L|l]ong", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + } else if (Long.class.isInstance(multipartMaxFileSizeObj)) { + servletDTO.multipartMaxFileSize = ((Long) multipartMaxFileSizeObj).longValue(); + } else if (validated) { + throw new HttpWhiteboardFailureException("'multipartMaxFileSize' expects [L|l]ong", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } - Object multipartMaxRequestSizeObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXREQUESTSIZE); + Object multipartMaxRequestSizeObj = serviceReference + .getProperty(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXREQUESTSIZE); if (multipartMaxRequestSizeObj == null) { multipartMaxRequestSizeObj = serviceReference.getProperty(Const.EQUINOX_HTTP_MULTIPART_MAXREQUESTSIZE); } if (multipartMaxRequestSizeObj == null) { // ignore - } - else if (Long.class.isInstance(multipartMaxRequestSizeObj)) { - servletDTO.multipartMaxRequestSize = ((Long)multipartMaxRequestSizeObj).longValue(); - } - else if (validated) { - throw new HttpWhiteboardFailureException("'multipartMaxRequestSize' expects [L|l]ong", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + } else if (Long.class.isInstance(multipartMaxRequestSizeObj)) { + servletDTO.multipartMaxRequestSize = ((Long) multipartMaxRequestSizeObj).longValue(); + } else if (validated) { + throw new HttpWhiteboardFailureException("'multipartMaxRequestSize' expects [L|l]ong", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } } Object servletNameObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_NAME); if (servletNameObj == null) { // ignore - } - else if (String.class.isInstance(servletNameObj)) { - servletDTO.name = (String)servletNameObj; - } - else if (validated) { - throw new HttpWhiteboardFailureException("'name' expects String", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + } else if (String.class.isInstance(servletNameObj)) { + servletDTO.name = (String) servletNameObj; + } else if (validated) { + throw new HttpWhiteboardFailureException("'name' expects String", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } Object patternObj = serviceReference.getProperty(HTTP_WHITEBOARD_SERVLET_PATTERN); if (patternObj == null) { servletDTO.patterns = new String[0]; - } - else { + } else { servletDTO.patterns = sort(StringPlus.from(patternObj).toArray(new String[0])); if (validated && (servletDTO.patterns.length > 0)) { @@ -239,7 +235,7 @@ else if (validated) { } } - servletDTO.serviceId = (Long)serviceReference.getProperty(Constants.SERVICE_ID); + servletDTO.serviceId = (Long) serviceReference.getProperty(Constants.SERVICE_ID); servletDTO.servletContextId = contextId; return servletDTO; @@ -430,7 +426,6 @@ private static long[] copy(long[] array) { return Arrays.copyOf(array, array.length); } - private static String[] copy(String[] array) { if (array == null) { return new String[0]; @@ -486,11 +481,7 @@ public static Map copyGenericMap(Map value) { } public static Object mapValue(Object v) { - if ((v == null) - || v instanceof Number - || v instanceof Boolean - || v instanceof Character - || v instanceof String + if ((v == null) || v instanceof Number || v instanceof Boolean || v instanceof Character || v instanceof String || v instanceof DTO) { return v; } @@ -532,7 +523,8 @@ public static Object mapValue(Object v) { private static void checkPattern(String pattern) { if (pattern == null) { - throw new HttpWhiteboardFailureException("Pattern cannot be null", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ + throw new HttpWhiteboardFailureException("Pattern cannot be null", //$NON-NLS-1$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } if (pattern.indexOf("*.") == 0) { //$NON-NLS-1$ @@ -547,23 +539,18 @@ private static void checkPattern(String pattern) { return; } - if (!pattern.startsWith(Const.SLASH) || - (pattern.endsWith(Const.SLASH) && !pattern.equals(Const.SLASH)) || - pattern.contains("**")) { //$NON-NLS-1$ + if (!pattern.startsWith(Const.SLASH) || (pattern.endsWith(Const.SLASH) && !pattern.equals(Const.SLASH)) + || pattern.contains("**")) { //$NON-NLS-1$ - throw new HttpWhiteboardFailureException( - "Invalid pattern '" + pattern + "'", DTOConstants.FAILURE_REASON_VALIDATION_FAILED); //$NON-NLS-1$ //$NON-NLS-2$ + throw new HttpWhiteboardFailureException("Invalid pattern '" + pattern + "'", //$NON-NLS-1$ //$NON-NLS-2$ + DTOConstants.FAILURE_REASON_VALIDATION_FAILED); } } private static Class mapComponentType(Class componentType) { - if (componentType.isPrimitive() - || componentType.isArray() - || Object.class.equals(componentType) - || Number.class.isAssignableFrom(componentType) - || Boolean.class.isAssignableFrom(componentType) - || Character.class.isAssignableFrom(componentType) - || String.class.isAssignableFrom(componentType) + if (componentType.isPrimitive() || componentType.isArray() || Object.class.equals(componentType) + || Number.class.isAssignableFrom(componentType) || Boolean.class.isAssignableFrom(componentType) + || Character.class.isAssignableFrom(componentType) || String.class.isAssignableFrom(componentType) || DTO.class.isAssignableFrom(componentType)) { return componentType; } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java index 5283c6b4697..203f10af3fd 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/EventListeners.java @@ -35,11 +35,10 @@ public List get(Class clazz) { return Collections.emptyList(); } - return new ListenerList<>(list) ; + return new ListenerList<>(list); } - public void put( - Class clazz, ListenerRegistration listenerRegistration) { + public void put(Class clazz, ListenerRegistration listenerRegistration) { if (clazz == null) { throw new NullPointerException("clazz can't be null"); //$NON-NLS-1$ @@ -48,8 +47,7 @@ public void put( List list = map.get(clazz); if (list == null) { - final List newList = - new CopyOnWriteArrayList<>(); + final List newList = new CopyOnWriteArrayList<>(); list = map.putIfAbsent(clazz, newList); @@ -61,17 +59,14 @@ public void put( list.add(listenerRegistration); } - public void put( - List> classes, - ListenerRegistration listenerRegistration) { + public void put(List> classes, ListenerRegistration listenerRegistration) { for (Class clazz : classes) { put(clazz, listenerRegistration); } } - public void remove( - Class clazz, ListenerRegistration listenerRegistration) { + public void remove(Class clazz, ListenerRegistration listenerRegistration) { if (clazz == null) { throw new NullPointerException("clazz can't be null"); //$NON-NLS-1$ @@ -86,17 +81,14 @@ public void remove( list.remove(listenerRegistration); } - public void remove( - List> classes, - ListenerRegistration listenerRegistration) { + public void remove(List> classes, ListenerRegistration listenerRegistration) { for (Class clazz : classes) { remove(clazz, listenerRegistration); } } - private ConcurrentMap, List> map = - new ConcurrentHashMap<>(); + private ConcurrentMap, List> map = new ConcurrentHashMap<>(); class ListenerList extends AbstractList { @@ -107,7 +99,7 @@ class ListenerList extends AbstractList { @Override @SuppressWarnings("unchecked") public R get(int index) { - return (R)list.get(index).getT(); + return (R) list.get(index).getT(); } @Override diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpStatus.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpStatus.java index ca66396405e..c277b873c94 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpStatus.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpStatus.java @@ -43,7 +43,7 @@ public enum HttpStatus { RESET_CONTENT(205, "Reset Content", "RFC7231"), //$NON-NLS-1$ //$NON-NLS-2$ PARTIAL_CONTENT(206, "Partial Content", "RFC7233"), //$NON-NLS-1$ //$NON-NLS-2$ - /** )*/ + /** ) */ MULTI_STATUS(207, "Partial Update OK", "RFC4918"), //$NON-NLS-1$ //$NON-NLS-2$ ALREADY_REPORTED(208, "Already Reported", "RFC5842"), //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java index 16541967601..c0b90bc69f2 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/HttpTuple.java @@ -21,12 +21,9 @@ public class HttpTuple { - public HttpTuple( - ProxyServlet proxyServlet, - HttpServiceFactory httpServiceFactory, - ServiceRegistration hsfRegistration, - HttpServiceRuntimeImpl httpServiceRuntime, - ServiceRegistration hsrRegistration) { + public HttpTuple(ProxyServlet proxyServlet, HttpServiceFactory httpServiceFactory, + ServiceRegistration hsfRegistration, HttpServiceRuntimeImpl httpServiceRuntime, + ServiceRegistration hsrRegistration) { this.proxyServlet = proxyServlet; this.httpServiceFactory = httpServiceFactory; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Params.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Params.java index 751dacfdd33..d0104777c79 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Params.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Params.java @@ -18,7 +18,7 @@ public class Params { public static String[] append(String[] params, String value) { if (params.length == 0) { - return new String[] {value}; + return new String[] { value }; } String[] tmp = new String[params.length + 1]; System.arraycopy(params, 0, tmp, 0, params.length); @@ -28,7 +28,7 @@ public static String[] append(String[] params, String value) { public static String[] append(String[] params, String... values) { if (values == null) { - values = new String[] {null}; + values = new String[] { null }; } String[] tmp = values; int length = 0; @@ -38,8 +38,7 @@ public static String[] append(String[] params, String... values) { System.arraycopy(params, 0, tmp, 0, params.length); } for (int i = 0; i < values.length; i++) { - tmp[length + i] = - (values[i] == null) ? Const.BLANK : values[i]; + tmp[length + i] = (values[i] == null) ? Const.BLANK : values[i]; } return tmp; } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java index 50a27390e10..841f5a4ebd0 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java @@ -26,8 +26,7 @@ public Path(String path) { if (semi != -1) { if (index > semi) { path = path.substring(0, semi) + path.substring(index, path.length()); - } - else if (index == -1) { + } else if (index == -1) { path = path.substring(0, semi); } } @@ -35,8 +34,7 @@ else if (index == -1) { if (index == -1) { _requestURI = path; _queryString = null; - } - else { + } else { _requestURI = path.substring(0, index); _queryString = path.substring(index + 1); } @@ -45,8 +43,7 @@ else if (index == -1) { if ((index == -1) || (index < _requestURI.lastIndexOf('/'))) { _extension = null; - } - else { + } else { _extension = _requestURI.substring(index + 1); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java index 20d10dafb41..28fef98fedf 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java @@ -20,30 +20,30 @@ import org.osgi.framework.ServiceReference; public class ServiceProperties { - static public boolean parseBoolean( - ServiceReference serviceReference, String property) { + static public boolean parseBoolean(ServiceReference serviceReference, String property) { Object value = serviceReference.getProperty(property); if (Boolean.class.isInstance(value)) { - return ((Boolean)value).booleanValue(); + return ((Boolean) value).booleanValue(); } if (String.class.isInstance(value)) { - return Boolean.valueOf((String)value); + return Boolean.valueOf((String) value); } return false; } - static public Map parseInitParams( - ServiceReference serviceReference, String prefix, ServletContext parentContext) { + static public Map parseInitParams(ServiceReference serviceReference, String prefix, + ServletContext parentContext) { Map initParams = new HashMap<>(); if (parentContext != null) { // use the parent context init params; // but allow them to be overriden below by service properties - for (Enumeration initParamNames = parentContext.getInitParameterNames(); initParamNames.hasMoreElements();) { + for (Enumeration initParamNames = parentContext.getInitParameterNames(); initParamNames + .hasMoreElements();) { String key = initParamNames.nextElement(); initParams.put(key, parentContext.getInitParameter(key)); } @@ -52,8 +52,7 @@ static public Map parseInitParams( if (key.startsWith(prefix)) { Object value = serviceReference.getProperty(key); if (value instanceof String) { - initParams.put( - key.substring(prefix.length()), (String)value); + initParams.put(key.substring(prefix.length()), (String) value); } } } @@ -61,8 +60,7 @@ static public Map parseInitParams( return Collections.unmodifiableMap(initParams); } - static public Map parseInitParams( - ServiceReference serviceReference, String prefix) { + static public Map parseInitParams(ServiceReference serviceReference, String prefix) { return parseInitParams(serviceReference, prefix, null); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java index 2cbbdb9aa34..22149b1f43a 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java @@ -28,8 +28,7 @@ public ServiceReferenceMap(ServiceReference serviceReference) { entries = new HashSet<>(propertyKeys.length); for (String key : propertyKeys) { - Map.Entry entry = new ReferenceEntry( - key, serviceReference.getProperty(key)); + Map.Entry entry = new ReferenceEntry(key, serviceReference.getProperty(key)); entries.add(entry); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java index 403cd775cfc..465b16617f5 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/StringPlus.java @@ -24,18 +24,15 @@ public class StringPlus { @SuppressWarnings("unchecked") public static List from(Object object) { if (String.class.isInstance(object)) { - return Collections.singletonList((String)object); - } - else if (String[].class.isInstance(object)) { - return Arrays.asList((String[])object); - } - else if (Collection.class.isInstance(object)) { - Collection collection = (Collection)object; + return Collections.singletonList((String) object); + } else if (String[].class.isInstance(object)) { + return Arrays.asList((String[]) object); + } else if (Collection.class.isInstance(object)) { + Collection collection = (Collection) object; - if (!collection.isEmpty() && - String.class.isInstance(collection.iterator().next())) { + if (!collection.isEmpty() && String.class.isInstance(collection.iterator().next())) { - return new ArrayList<>((Collection)object); + return new ArrayList<>((Collection) object); } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java index 73fe4385bb3..a93ecc3ea7b 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMDictionaryMap.java @@ -19,7 +19,7 @@ /** * @author Raymond Augé */ -public class UMDictionaryMap implements Map { +public class UMDictionaryMap implements Map { public UMDictionaryMap(Dictionary dictionary) { Map map = new HashMap<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java index 24c5d05c0f4..fcbe8b10677 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/UMMapDictionary.java @@ -19,13 +19,12 @@ /** * @author Raymond Augé */ -public class UMMapDictionary extends Dictionary { +public class UMMapDictionary extends Dictionary { public UMMapDictionary(Map map) { if (map == null) { _map = Collections.emptyMap(); - } - else { + } else { _map = Collections.unmodifiableMap(map); } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/session/HttpSessionInvalidator.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/session/HttpSessionInvalidator.java index 149dde1db27..299bff19d18 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/session/HttpSessionInvalidator.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/session/HttpSessionInvalidator.java @@ -16,27 +16,29 @@ package org.eclipse.equinox.http.servlet.session; /** - * The Http Whiteboard runtime registers a service of this type to - * allow an external actor to invalidate a session. This requirement is typical of - * the bridge deployment scenario where the host may need to control session invalidation. + * The Http Whiteboard runtime registers a service of this type to allow an + * external actor to invalidate a session. This requirement is typical of the + * bridge deployment scenario where the host may need to control session + * invalidation. *

* Note: This class is part of an interim SPI that is still under * development and expected to change significantly before reaching stability. * It is being made available at this stage to solicit feedback from pioneering - * adopters on the understanding that any code that uses this SPI will almost certainly - * be broken (repeatedly) as the SPI evolves. + * adopters on the understanding that any code that uses this SPI will almost + * certainly be broken (repeatedly) as the SPI evolves. *

+ * * @since 1.5 */ public interface HttpSessionInvalidator { /** - * Invalidate a session. If no session matching the id is found, nothing happens. - * Optionally attempt to invalidate the parent (container) session. + * Invalidate a session. If no session matching the id is found, nothing + * happens. Optionally attempt to invalidate the parent (container) session. * * @param sessionId the session id to invalidate - * @param invalidateParent if true, attempt to invalidate the parent - * (container) session + * @param invalidateParent if true, attempt to invalidate the parent (container) + * session */ public void invalidate(String sessionId, boolean invalidateParent);