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.
*
- *
Control the default selection filter used when no "osgi.http.whiteboard.context.select"
- * is specified.
- *
Provide a prefix to the context path "osgi.http.whiteboard.context.path"
- * specified by ServletContextHelper registrations.
+ *
Control the default selection filter used when no
+ * "osgi.http.whiteboard.context.select" is specified.
+ *
Provide a prefix to the context path
+ * "osgi.http.whiteboard.context.path" specified by
+ * ServletContextHelper registrations.
*
*
- * 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 extends ServletContextHelper> 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