From f5b53b56785cef73a84e7f59c0a000bff7ba10f0 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 21 Dec 2012 11:42:43 +0800 Subject: [PATCH] IDEMPIERE-455 Discover and fix FindBugs problems / Eclipse warning. --- .../.settings/org.eclipse.jdt.core.prefs | 8 --- .../http/servlet/ExtendedHttpService.java | 2 +- .../http/servlet/internal/Activator.java | 16 +++--- .../servlet/internal/FilterChainImpl.java | 4 +- .../servlet/internal/FilterConfigImpl.java | 8 +-- .../servlet/internal/FilterRegistration.java | 5 +- .../servlet/internal/HttpServiceFactory.java | 7 +-- .../servlet/internal/HttpServiceImpl.java | 17 ++++--- .../servlet/internal/HttpSessionAdaptor.java | 2 +- .../http/servlet/internal/ProxyContext.java | 12 ++--- .../http/servlet/internal/ProxyServlet.java | 24 ++++----- .../servlet/internal/ResourceServlet.java | 2 +- .../servlet/internal/ServletConfigImpl.java | 8 +-- .../internal/ServletContextAdaptor.java | 51 ++++++++++--------- .../.settings/org.eclipse.jdt.core.prefs | 8 --- .../.settings/org.eclipse.jdt.core.prefs | 8 --- 16 files changed, 81 insertions(+), 101 deletions(-) delete mode 100644 org.adempiere.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs delete mode 100644 org.adempiere.eclipse.equinox.http.servletbridge/.settings/org.eclipse.jdt.core.prefs delete mode 100644 org.adempiere.eclipse.equinox.servletbridge/.settings/org.eclipse.jdt.core.prefs diff --git a/org.adempiere.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs b/org.adempiere.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c5b7b23b56..0000000000 --- a/org.adempiere.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Jun 01 10:21:31 MYT 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1 -org.eclipse.jdt.core.compiler.compliance=1.3 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java index d270f7e163..f8df39c460 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/ExtendedHttpService.java @@ -24,7 +24,7 @@ public interface ExtendedHttpService extends HttpService { * @throws java.lang.IllegalArgumentException if any of the arguments are * 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 diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java index 66cf277e9c..db2d4931ea 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java @@ -25,7 +25,7 @@ public class Activator implements BundleActivator { private static final String[] HTTP_SERVICES_CLASSES = new String[] {HttpService.class.getName(), ExtendedHttpService.class.getName()}; private static BundleContext context; - private static Map serviceRegistrations = new HashMap(); + private static Map> serviceRegistrations = new HashMap>(); public void start(BundleContext bundleContext) throws Exception { startHttpServiceProxy(bundleContext); @@ -39,7 +39,7 @@ public class Activator implements BundleActivator { context = bundleContext; Object[] proxyServlets = serviceRegistrations.keySet().toArray(); for (int i = 0; i < proxyServlets.length; ++i) { - ServiceRegistration registration = registerHttpService((ProxyServlet) proxyServlets[i]); + ServiceRegistration registration = registerHttpService((ProxyServlet) proxyServlets[i]); serviceRegistrations.put(proxyServlets[i], registration); } } @@ -47,25 +47,25 @@ public class Activator implements BundleActivator { private static synchronized void stopHttpServiceProxy(BundleContext bundleContext) { Object[] proxyServlets = serviceRegistrations.keySet().toArray(); for (int i = 0; i < proxyServlets.length; ++i) { - ServiceRegistration registration = (ServiceRegistration) serviceRegistrations.put(proxyServlets[i], null); + ServiceRegistration registration = serviceRegistrations.put(proxyServlets[i], null); registration.unregister(); } context = null; } static synchronized void addProxyServlet(ProxyServlet proxyServlet) { - ServiceRegistration registration = null; + ServiceRegistration registration = null; if (context != null) registration = registerHttpService(proxyServlet); serviceRegistrations.put(proxyServlet, registration); } - private static ServiceRegistration registerHttpService(ProxyServlet proxyServlet) { + private static ServiceRegistration registerHttpService(ProxyServlet proxyServlet) { HttpServiceFactory factory = new HttpServiceFactory(proxyServlet); - Dictionary serviceProperties = new Hashtable(2); + Dictionary serviceProperties = new Hashtable(2); ServletConfig config = proxyServlet.getServletConfig(); - Enumeration initparameterNames = config.getInitParameterNames(); + Enumeration initparameterNames = config.getInitParameterNames(); while (initparameterNames.hasMoreElements()) { String name = (String) initparameterNames.nextElement(); serviceProperties.put(name, config.getInitParameter(name)); @@ -81,7 +81,7 @@ public class Activator implements BundleActivator { } static synchronized void removeProxyServlet(ProxyServlet proxyServlet) { - ServiceRegistration registration = (ServiceRegistration) serviceRegistrations.remove(proxyServlet); + ServiceRegistration registration = serviceRegistrations.remove(proxyServlet); if (registration != null) registration.unregister(); } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterChainImpl.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterChainImpl.java index 49b50629f7..ae94c5f1f3 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterChainImpl.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterChainImpl.java @@ -8,12 +8,12 @@ import javax.servlet.http.HttpServletResponse; public class FilterChainImpl implements FilterChain { - private List matchingFilterRegistrations; + private List matchingFilterRegistrations; private ServletRegistration registration; private int filterIndex = 0; private int filterCount; - public FilterChainImpl(List matchingFilterRegistrations, ServletRegistration registration) { + public FilterChainImpl(List matchingFilterRegistrations, ServletRegistration registration) { this.matchingFilterRegistrations = matchingFilterRegistrations; this.registration = registration; this.filterCount = matchingFilterRegistrations.size(); diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterConfigImpl.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterConfigImpl.java index 388b780996..82440e47b9 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterConfigImpl.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterConfigImpl.java @@ -15,13 +15,13 @@ import javax.servlet.*; public class FilterConfigImpl implements FilterConfig { - private static final Dictionary EMPTY_PARAMS = new Hashtable(0); + private static final Dictionary EMPTY_PARAMS = new Hashtable(0); private static final String FILTER_NAME = "filter-name"; //$NON-NLS-1$ private Filter filter; - private Dictionary initparams; + private Dictionary initparams; private ServletContext servletContext; - public FilterConfigImpl(Filter filter, Dictionary initparams, ServletContext servletContext) { + public FilterConfigImpl(Filter filter, Dictionary initparams, ServletContext servletContext) { this.filter = filter; this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS; this.servletContext = servletContext; @@ -46,7 +46,7 @@ public class FilterConfigImpl implements FilterConfig { return (String) initparams.get(name); } - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { return initparams.keys(); } } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterRegistration.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterRegistration.java index 0faa00dd2b..348c9e0668 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterRegistration.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/FilterRegistration.java @@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse; import org.osgi.service.http.HttpContext; //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 Registration implements Comparable { +public class FilterRegistration extends Registration implements Comparable { private static long nextSequenceNumber = 1L; @@ -101,8 +101,7 @@ public class FilterRegistration extends Registration implements Comparable { return dispatchPathInfo.endsWith(suffix) && dispatchPathInfo.length() > prefix.length() + suffix.length(); } - public int compareTo(Object other) { - FilterRegistration otherFilterRegistration = (FilterRegistration) other; + public int compareTo(FilterRegistration otherFilterRegistration) { int priorityDifference = priority - otherFilterRegistration.priority; if (priorityDifference != 0) return -priorityDifference; diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java index 3e147a4e14..4c6ed3b034 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java @@ -13,9 +13,10 @@ package org.eclipse.equinox.http.servlet.internal; import org.osgi.framework.*; +import org.osgi.service.http.HttpService; // Factory to create http services. This is because the service needs to be customized for each bundle in order to implement the default resource lookups. -public class HttpServiceFactory implements ServiceFactory { +public class HttpServiceFactory implements ServiceFactory { private ProxyServlet proxy; @@ -23,11 +24,11 @@ public class HttpServiceFactory implements ServiceFactory { this.proxy = proxy; } - public Object getService(Bundle bundle, ServiceRegistration registration) { + public HttpService getService(Bundle bundle, ServiceRegistration registration) { return new HttpServiceImpl(bundle, proxy); } - public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { + public void ungetService(Bundle bundle, ServiceRegistration registration, HttpService service) { ((HttpServiceImpl) service).shutdown(); } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java index 8589e2986b..a1b21c4e96 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java @@ -24,8 +24,8 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService { private ProxyServlet proxy; //The proxy that does the dispatching of the incoming requests - private Set aliases = new HashSet(); //Aliases registered against this particular instance of the service - private Set filters = new HashSet(); //Filters registered against this particular instance of the service + private Set aliases = new HashSet(); //Aliases registered against this particular instance of the service + private Set filters = new HashSet(); //Filters registered against this particular instance of the service private boolean shutdown = false; // We prevent use of this instance if HttpServiceFactory.ungetService has called unregisterAliases. @@ -36,14 +36,14 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService { //Clean up method synchronized void shutdown() { - for (Iterator it = aliases.iterator(); it.hasNext();) { - String alias = (String) it.next(); + for (Iterator it = aliases.iterator(); it.hasNext();) { + String alias = it.next(); proxy.unregister(alias, false); } aliases.clear(); - for (Iterator it = filters.iterator(); it.hasNext();) { - Filter filter = (Filter) it.next(); + for (Iterator it = filters.iterator(); it.hasNext();) { + Filter filter = it.next(); proxy.unregisterFilter(filter, false); } filters.clear(); @@ -58,6 +58,8 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService { /** * @see HttpService#registerServlet(String, Servlet, Dictionary, HttpContext) */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override public synchronized void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) throws ServletException, NamespaceException { checkShutdown(); if (context == null) { @@ -99,7 +101,8 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService { return new DefaultHttpContext(bundle); } - public void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext context) throws ServletException { + @Override + public void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext context) throws ServletException { checkShutdown(); if (context == null) { context = createDefaultHttpContext(); diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java index 1784a25810..bdf59905d4 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java @@ -35,7 +35,7 @@ public class HttpSessionAdaptor implements HttpSession { return session.getAttribute(arg0); } - public Enumeration getAttributeNames() { + public Enumeration getAttributeNames() { return session.getAttributeNames(); } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java index cfa906fc41..5fd5b6b4c4 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java @@ -31,7 +31,7 @@ public class ProxyContext { private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$ private String servletPath; - private HashMap attributesMap = new HashMap(); + private HashMap attributesMap = new HashMap(); File proxyContextTempDir; public ProxyContext(ServletContext servletContext) { @@ -62,7 +62,7 @@ public class ProxyContext { } synchronized void createContextAttributes(HttpContext httpContext) { - ContextAttributes attributes = (ContextAttributes) attributesMap.get(httpContext); + ContextAttributes attributes = attributesMap.get(httpContext); if (attributes == null) { attributes = new ContextAttributes(httpContext); attributesMap.put(httpContext, attributes); @@ -71,7 +71,7 @@ public class ProxyContext { } synchronized void destroyContextAttributes(HttpContext httpContext) { - ContextAttributes attributes = (ContextAttributes) attributesMap.get(httpContext); + ContextAttributes attributes = attributesMap.get(httpContext); attributes.removeReference(); if (attributes.referenceCount() == 0) { attributesMap.remove(httpContext); @@ -79,8 +79,8 @@ public class ProxyContext { } } - synchronized Dictionary getContextAttributes(HttpContext httpContext) { - return (Dictionary) attributesMap.get(httpContext); + synchronized Dictionary getContextAttributes(HttpContext httpContext) { + return attributesMap.get(httpContext); } /** @@ -102,7 +102,7 @@ public class ProxyContext { return directory.delete(); } - public class ContextAttributes extends Hashtable { + public class ContextAttributes extends Hashtable { private static final long serialVersionUID = 1916670423277243587L; private int referenceCount; diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java index f9d1854f9c..308581195a 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java @@ -30,10 +30,10 @@ import org.osgi.service.http.NamespaceException; public class ProxyServlet extends HttpServlet implements Filter { private static final long serialVersionUID = 4117456123807468871L; - private Map servletRegistrations = new HashMap(); //alias --> servlet registration - private Set registeredServlets = new HashSet(); //All the servlets objects that have been registered + private Map servletRegistrations = new HashMap(); //alias --> servlet registration + private Set registeredServlets = new HashSet(); //All the servlets objects that have been registered - private Map filterRegistrations = new HashMap(); //filter --> filter registration; + private Map filterRegistrations = new HashMap(); //filter --> filter registration; private ProxyContext proxyContext; public void init(ServletConfig config) throws ServletException { @@ -106,7 +106,7 @@ public class ProxyServlet extends HttpServlet implements Filter { private boolean processAlias(HttpServletRequest req, HttpServletResponse resp, String alias, String extensionAlias, FilterChain filterChain) throws ServletException, IOException { ServletRegistration registration = null; - List matchingFilterRegistrations = Collections.EMPTY_LIST; + List matchingFilterRegistrations = Collections.emptyList(); String dispatchPathInfo = HttpServletRequestAdaptor.getDispatchPathInfo(req, filterChain); synchronized (this) { if (extensionAlias == null) @@ -123,9 +123,9 @@ public class ProxyServlet extends HttpServlet implements Filter { if (registration != null) { registration.addReference(); if (!filterRegistrations.isEmpty()) { - matchingFilterRegistrations = new ArrayList(); - for (Iterator it = filterRegistrations.values().iterator(); it.hasNext();) { - FilterRegistration filterRegistration = (FilterRegistration) it.next(); + matchingFilterRegistrations = new ArrayList(); + for (Iterator it = filterRegistrations.values().iterator(); it.hasNext();) { + FilterRegistration filterRegistration = it.next(); if (filterRegistration.matches(dispatchPathInfo)) { matchingFilterRegistrations.add(filterRegistration); filterRegistration.addReference(); @@ -146,7 +146,7 @@ public class ProxyServlet extends HttpServlet implements Filter { } } finally { registration.removeReference(); - for (Iterator it = matchingFilterRegistrations.iterator(); it.hasNext();) { + for (Iterator it = matchingFilterRegistrations.iterator(); it.hasNext();) { FilterRegistration filterRegistration = (FilterRegistration) it.next(); filterRegistration.removeReference(); } @@ -171,7 +171,7 @@ public class ProxyServlet extends HttpServlet implements Filter { } //Effective registration of the servlet as defined HttpService#registerServlet() - synchronized void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException { + synchronized void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException { checkAlias(alias); if (servletRegistrations.containsKey(alias)) throw new NamespaceException("The alias '" + alias + "' is already in use."); //$NON-NLS-1$//$NON-NLS-2$ @@ -238,7 +238,7 @@ public class ProxyServlet extends HttpServlet implements Filter { } } - public synchronized void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext httpContext) throws ServletException { + public synchronized void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext httpContext) throws ServletException { checkAlias(alias); if (filter == null) throw new IllegalArgumentException("Filter cannot be null"); //$NON-NLS-1$ @@ -263,7 +263,7 @@ public class ProxyServlet extends HttpServlet implements Filter { filterRegistrations.put(filter, registration); } - private int findFilterPriority(Dictionary initparams) { + private int findFilterPriority(Dictionary initparams) { if (initparams == null) return 0; String filterPriority = (String) initparams.get("filter-priority"); //$NON-NLS-1$ @@ -303,7 +303,7 @@ public class ProxyServlet extends HttpServlet implements Filter { return filterConfig.getInitParameter(arg0); } - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { return filterConfig.getInitParameterNames(); } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceServlet.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceServlet.java index 62f4ed11b8..bfcb3a8d99 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceServlet.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceServlet.java @@ -59,7 +59,7 @@ public class ResourceServlet extends HttpServlet { private void writeResource(final HttpServletRequest req, final HttpServletResponse resp, final String resourcePath, final URL resourceURL) throws IOException { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { + AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { URLConnection connection = resourceURL.openConnection(); diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java index 51951e1476..1738c944db 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java @@ -16,13 +16,13 @@ import javax.servlet.*; public class ServletConfigImpl implements ServletConfig { - private static final Dictionary EMPTY_PARAMS = new Hashtable(0); + private static final Dictionary EMPTY_PARAMS = new Hashtable(0); private static final String SERVLET_NAME = "servlet-name"; //$NON-NLS-1$ private Servlet servlet; - private Dictionary initparams; + private Dictionary initparams; private ServletContext servletContext; - public ServletConfigImpl(Servlet servlet, Dictionary initparams, ServletContext servletContext) { + public ServletConfigImpl(Servlet servlet, Dictionary initparams, ServletContext servletContext) { this.servlet = servlet; this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS; this.servletContext = servletContext; @@ -47,7 +47,7 @@ public class ServletConfigImpl implements ServletConfig { return (String) initparams.get(name); } - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { return initparams.keys(); } } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java index 9d325b109f..b0e7040691 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java @@ -47,14 +47,15 @@ public class ServletContextAdaptor implements ServletContext { * implementation uses reflection to check for and then call the associated HttpContext.getResourcePaths(...) * method opportunistically. Null is returned if the method is not present or fails. */ - public Set getResourcePaths(String name) { + @SuppressWarnings("unchecked") + public Set getResourcePaths(String name) { if (name == null || !name.startsWith("/")) //$NON-NLS-1$ return null; try { Method getResourcePathsMethod = httpContext.getClass().getMethod("getResourcePaths", new Class[] {String.class}); //$NON-NLS-1$ if (!getResourcePathsMethod.isAccessible()) getResourcePathsMethod.setAccessible(true); - return (Set) getResourcePathsMethod.invoke(httpContext, new Object[] {name}); + return (Set) getResourcePathsMethod.invoke(httpContext, new Object[] {name}); } catch (Exception e) { // ignore } @@ -62,22 +63,22 @@ public class ServletContextAdaptor implements ServletContext { } public Object getAttribute(String attributeName) { - Dictionary attributes = proxyContext.getContextAttributes(httpContext); + Dictionary attributes = proxyContext.getContextAttributes(httpContext); return attributes.get(attributeName); } - public Enumeration getAttributeNames() { - Dictionary attributes = proxyContext.getContextAttributes(httpContext); + public Enumeration getAttributeNames() { + Dictionary attributes = proxyContext.getContextAttributes(httpContext); return attributes.keys(); } public void setAttribute(String attributeName, Object attributeValue) { - Dictionary attributes = proxyContext.getContextAttributes(httpContext); + Dictionary attributes = proxyContext.getContextAttributes(httpContext); attributes.put(attributeName, attributeValue); } public void removeAttribute(String attributeName) { - Dictionary attributes = proxyContext.getContextAttributes(httpContext); + Dictionary attributes = proxyContext.getContextAttributes(httpContext); attributes.remove(attributeName); } @@ -88,7 +89,7 @@ public class ServletContextAdaptor implements ServletContext { public URL getResource(final String name) { try { - return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() { + return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { return httpContext.getResource(name); } @@ -119,7 +120,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.getInitParameter(arg0); } - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { return servletContext.getInitParameterNames(); } @@ -157,12 +158,12 @@ public class ServletContextAdaptor implements ServletContext { } /**@deprecated*/ - public Enumeration getServletNames() { + public Enumeration getServletNames() { return servletContext.getServletNames(); } /**@deprecated*/ - public Enumeration getServlets() { + public Enumeration getServlets() { return servletContext.getServlets(); } @@ -182,8 +183,8 @@ public class ServletContextAdaptor implements ServletContext { // Added in Servlet 2.5 public String getContextPath() { try { - Method getContextPathMethod = servletContext.getClass().getMethod("getContextPath", null); //$NON-NLS-1$ - return (String) getContextPathMethod.invoke(servletContext, null) + proxyContext.getServletPath(); + Method getContextPathMethod = servletContext.getClass().getMethod("getContextPath", (Class[])null); //$NON-NLS-1$ + return (String) getContextPathMethod.invoke(servletContext, (Object[])null) + proxyContext.getServletPath(); } catch (Exception e) { // ignore } @@ -198,7 +199,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.addFilter(arg0, arg1); } - public Dynamic addFilter(String arg0, Class arg1) { + public Dynamic addFilter(String arg0, Class arg1) { return servletContext.addFilter(arg0, arg1); } @@ -210,7 +211,7 @@ public class ServletContextAdaptor implements ServletContext { servletContext.addListener(arg0); } - public void addListener(Class arg0) { + public void addListener(Class arg0) { servletContext.addListener(arg0); } @@ -225,23 +226,23 @@ public class ServletContextAdaptor implements ServletContext { } public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0, - Class arg1) { + Class arg1) { return servletContext.addServlet(arg0, arg1); } - public Filter createFilter(Class arg0) throws ServletException { + public T createFilter(Class arg0) throws ServletException { return servletContext.createFilter(arg0); } - public EventListener createListener(Class arg0) throws ServletException { + public T createListener(Class arg0) throws ServletException { return servletContext.createListener(arg0); } - public Servlet createServlet(Class arg0) throws ServletException { + public T createServlet(Class arg0) throws ServletException { return servletContext.createServlet(arg0); } - public void declareRoles(String[] arg0) { + public void declareRoles(String... arg0) { servletContext.declareRoles(arg0); } @@ -249,7 +250,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.getClassLoader(); } - public Set getDefaultSessionTrackingModes() { + public Set getDefaultSessionTrackingModes() { return servletContext.getDefaultSessionTrackingModes(); } @@ -261,7 +262,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.getEffectiveMinorVersion(); } - public Set getEffectiveSessionTrackingModes() { + public Set getEffectiveSessionTrackingModes() { return servletContext.getEffectiveSessionTrackingModes(); } @@ -269,7 +270,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.getFilterRegistration(arg0); } - public Map getFilterRegistrations() { + public Map getFilterRegistrations() { return servletContext.getFilterRegistrations(); } @@ -281,7 +282,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.getServletRegistration(arg0); } - public Map getServletRegistrations() { + public Map getServletRegistrations() { return servletContext.getServletRegistrations(); } @@ -293,7 +294,7 @@ public class ServletContextAdaptor implements ServletContext { return servletContext.setInitParameter(arg0, arg1); } - public void setSessionTrackingModes(Set arg0) { + public void setSessionTrackingModes(Set arg0) { servletContext.setSessionTrackingModes(arg0); } } diff --git a/org.adempiere.eclipse.equinox.http.servletbridge/.settings/org.eclipse.jdt.core.prefs b/org.adempiere.eclipse.equinox.http.servletbridge/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c5b7b23b56..0000000000 --- a/org.adempiere.eclipse.equinox.http.servletbridge/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Jun 01 10:21:31 MYT 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1 -org.eclipse.jdt.core.compiler.compliance=1.3 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/org.adempiere.eclipse.equinox.servletbridge/.settings/org.eclipse.jdt.core.prefs b/org.adempiere.eclipse.equinox.servletbridge/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c5b7b23b56..0000000000 --- a/org.adempiere.eclipse.equinox.servletbridge/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Jun 01 10:21:31 MYT 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1 -org.eclipse.jdt.core.compiler.compliance=1.3 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.3