IDEMPIERE-455 Discover and fix FindBugs problems / Eclipse warning.

This commit is contained in:
Heng Sin Low 2012-12-21 11:42:43 +08:00
parent 944542b2d5
commit f5b53b5678
16 changed files with 81 additions and 101 deletions

View File

@ -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

View File

@ -24,7 +24,7 @@ public interface ExtendedHttpService extends HttpService {
* @throws java.lang.IllegalArgumentException if any of the arguments are * @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<String, String> initparams, HttpContext context) throws ServletException, NamespaceException;
/** /**
* Unregisters a previous filter registration done by the * Unregisters a previous filter registration done by the

View File

@ -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 final String[] HTTP_SERVICES_CLASSES = new String[] {HttpService.class.getName(), ExtendedHttpService.class.getName()};
private static BundleContext context; private static BundleContext context;
private static Map serviceRegistrations = new HashMap(); private static Map<Object, ServiceRegistration<?>> serviceRegistrations = new HashMap<Object, ServiceRegistration<?>>();
public void start(BundleContext bundleContext) throws Exception { public void start(BundleContext bundleContext) throws Exception {
startHttpServiceProxy(bundleContext); startHttpServiceProxy(bundleContext);
@ -39,7 +39,7 @@ public class Activator implements BundleActivator {
context = bundleContext; context = bundleContext;
Object[] proxyServlets = serviceRegistrations.keySet().toArray(); Object[] proxyServlets = serviceRegistrations.keySet().toArray();
for (int i = 0; i < proxyServlets.length; ++i) { 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); serviceRegistrations.put(proxyServlets[i], registration);
} }
} }
@ -47,25 +47,25 @@ public class Activator implements BundleActivator {
private static synchronized void stopHttpServiceProxy(BundleContext bundleContext) { private static synchronized void stopHttpServiceProxy(BundleContext bundleContext) {
Object[] proxyServlets = serviceRegistrations.keySet().toArray(); Object[] proxyServlets = serviceRegistrations.keySet().toArray();
for (int i = 0; i < proxyServlets.length; ++i) { 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(); registration.unregister();
} }
context = null; context = null;
} }
static synchronized void addProxyServlet(ProxyServlet proxyServlet) { static synchronized void addProxyServlet(ProxyServlet proxyServlet) {
ServiceRegistration registration = null; ServiceRegistration<?> registration = null;
if (context != null) if (context != null)
registration = registerHttpService(proxyServlet); registration = registerHttpService(proxyServlet);
serviceRegistrations.put(proxyServlet, registration); serviceRegistrations.put(proxyServlet, registration);
} }
private static ServiceRegistration registerHttpService(ProxyServlet proxyServlet) { private static ServiceRegistration<?> registerHttpService(ProxyServlet proxyServlet) {
HttpServiceFactory factory = new HttpServiceFactory(proxyServlet); HttpServiceFactory factory = new HttpServiceFactory(proxyServlet);
Dictionary serviceProperties = new Hashtable(2); Dictionary<String, String> serviceProperties = new Hashtable<String, String>(2);
ServletConfig config = proxyServlet.getServletConfig(); ServletConfig config = proxyServlet.getServletConfig();
Enumeration initparameterNames = config.getInitParameterNames(); Enumeration<String> initparameterNames = config.getInitParameterNames();
while (initparameterNames.hasMoreElements()) { while (initparameterNames.hasMoreElements()) {
String name = (String) initparameterNames.nextElement(); String name = (String) initparameterNames.nextElement();
serviceProperties.put(name, config.getInitParameter(name)); serviceProperties.put(name, config.getInitParameter(name));
@ -81,7 +81,7 @@ public class Activator implements BundleActivator {
} }
static synchronized void removeProxyServlet(ProxyServlet proxyServlet) { static synchronized void removeProxyServlet(ProxyServlet proxyServlet) {
ServiceRegistration registration = (ServiceRegistration) serviceRegistrations.remove(proxyServlet); ServiceRegistration<?> registration = serviceRegistrations.remove(proxyServlet);
if (registration != null) if (registration != null)
registration.unregister(); registration.unregister();
} }

View File

@ -8,12 +8,12 @@ import javax.servlet.http.HttpServletResponse;
public class FilterChainImpl implements FilterChain { public class FilterChainImpl implements FilterChain {
private List matchingFilterRegistrations; private List<FilterRegistration> matchingFilterRegistrations;
private ServletRegistration registration; private ServletRegistration registration;
private int filterIndex = 0; private int filterIndex = 0;
private int filterCount; private int filterCount;
public FilterChainImpl(List matchingFilterRegistrations, ServletRegistration registration) { public FilterChainImpl(List<FilterRegistration> matchingFilterRegistrations, ServletRegistration registration) {
this.matchingFilterRegistrations = matchingFilterRegistrations; this.matchingFilterRegistrations = matchingFilterRegistrations;
this.registration = registration; this.registration = registration;
this.filterCount = matchingFilterRegistrations.size(); this.filterCount = matchingFilterRegistrations.size();

View File

@ -15,13 +15,13 @@ import javax.servlet.*;
public class FilterConfigImpl implements FilterConfig { public class FilterConfigImpl implements FilterConfig {
private static final Dictionary EMPTY_PARAMS = new Hashtable(0); private static final Dictionary<String, String> EMPTY_PARAMS = new Hashtable<String, String>(0);
private static final String FILTER_NAME = "filter-name"; //$NON-NLS-1$ private static final String FILTER_NAME = "filter-name"; //$NON-NLS-1$
private Filter filter; private Filter filter;
private Dictionary initparams; private Dictionary<String, String> initparams;
private ServletContext servletContext; private ServletContext servletContext;
public FilterConfigImpl(Filter filter, Dictionary initparams, ServletContext servletContext) { public FilterConfigImpl(Filter filter, Dictionary<String, String> initparams, ServletContext servletContext) {
this.filter = filter; this.filter = filter;
this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS; this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS;
this.servletContext = servletContext; this.servletContext = servletContext;
@ -46,7 +46,7 @@ public class FilterConfigImpl implements FilterConfig {
return (String) initparams.get(name); return (String) initparams.get(name);
} }
public Enumeration getInitParameterNames() { public Enumeration<String> getInitParameterNames() {
return initparams.keys(); return initparams.keys();
} }
} }

View File

@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse;
import org.osgi.service.http.HttpContext; 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. //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<FilterRegistration> {
private static long nextSequenceNumber = 1L; 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(); return dispatchPathInfo.endsWith(suffix) && dispatchPathInfo.length() > prefix.length() + suffix.length();
} }
public int compareTo(Object other) { public int compareTo(FilterRegistration otherFilterRegistration) {
FilterRegistration otherFilterRegistration = (FilterRegistration) other;
int priorityDifference = priority - otherFilterRegistration.priority; int priorityDifference = priority - otherFilterRegistration.priority;
if (priorityDifference != 0) if (priorityDifference != 0)
return -priorityDifference; return -priorityDifference;

View File

@ -13,9 +13,10 @@
package org.eclipse.equinox.http.servlet.internal; package org.eclipse.equinox.http.servlet.internal;
import org.osgi.framework.*; 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. // 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<HttpService> {
private ProxyServlet proxy; private ProxyServlet proxy;
@ -23,11 +24,11 @@ public class HttpServiceFactory implements ServiceFactory {
this.proxy = proxy; this.proxy = proxy;
} }
public Object getService(Bundle bundle, ServiceRegistration registration) { public HttpService getService(Bundle bundle, ServiceRegistration<HttpService> registration) {
return new HttpServiceImpl(bundle, proxy); return new HttpServiceImpl(bundle, proxy);
} }
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { public void ungetService(Bundle bundle, ServiceRegistration<HttpService> registration, HttpService service) {
((HttpServiceImpl) service).shutdown(); ((HttpServiceImpl) service).shutdown();
} }

View File

@ -24,8 +24,8 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService {
private ProxyServlet proxy; //The proxy that does the dispatching of the incoming requests 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<String> aliases = new HashSet<String>(); //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<Filter> filters = new HashSet<Filter>(); //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. 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 //Clean up method
synchronized void shutdown() { synchronized void shutdown() {
for (Iterator it = aliases.iterator(); it.hasNext();) { for (Iterator<String> it = aliases.iterator(); it.hasNext();) {
String alias = (String) it.next(); String alias = it.next();
proxy.unregister(alias, false); proxy.unregister(alias, false);
} }
aliases.clear(); aliases.clear();
for (Iterator it = filters.iterator(); it.hasNext();) { for (Iterator<Filter> it = filters.iterator(); it.hasNext();) {
Filter filter = (Filter) it.next(); Filter filter = it.next();
proxy.unregisterFilter(filter, false); proxy.unregisterFilter(filter, false);
} }
filters.clear(); filters.clear();
@ -58,6 +58,8 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService {
/** /**
* @see HttpService#registerServlet(String, Servlet, Dictionary, HttpContext) * @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 { public synchronized void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) throws ServletException, NamespaceException {
checkShutdown(); checkShutdown();
if (context == null) { if (context == null) {
@ -99,7 +101,8 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService {
return new DefaultHttpContext(bundle); 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<String, String> initparams, HttpContext context) throws ServletException {
checkShutdown(); checkShutdown();
if (context == null) { if (context == null) {
context = createDefaultHttpContext(); context = createDefaultHttpContext();

View File

@ -35,7 +35,7 @@ public class HttpSessionAdaptor implements HttpSession {
return session.getAttribute(arg0); return session.getAttribute(arg0);
} }
public Enumeration getAttributeNames() { public Enumeration<String> getAttributeNames() {
return session.getAttributeNames(); return session.getAttributeNames();
} }

View File

@ -31,7 +31,7 @@ public class ProxyContext {
private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$ private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$
private String servletPath; private String servletPath;
private HashMap attributesMap = new HashMap(); private HashMap<HttpContext, ContextAttributes> attributesMap = new HashMap<HttpContext, ContextAttributes>();
File proxyContextTempDir; File proxyContextTempDir;
public ProxyContext(ServletContext servletContext) { public ProxyContext(ServletContext servletContext) {
@ -62,7 +62,7 @@ public class ProxyContext {
} }
synchronized void createContextAttributes(HttpContext httpContext) { synchronized void createContextAttributes(HttpContext httpContext) {
ContextAttributes attributes = (ContextAttributes) attributesMap.get(httpContext); ContextAttributes attributes = attributesMap.get(httpContext);
if (attributes == null) { if (attributes == null) {
attributes = new ContextAttributes(httpContext); attributes = new ContextAttributes(httpContext);
attributesMap.put(httpContext, attributes); attributesMap.put(httpContext, attributes);
@ -71,7 +71,7 @@ public class ProxyContext {
} }
synchronized void destroyContextAttributes(HttpContext httpContext) { synchronized void destroyContextAttributes(HttpContext httpContext) {
ContextAttributes attributes = (ContextAttributes) attributesMap.get(httpContext); ContextAttributes attributes = attributesMap.get(httpContext);
attributes.removeReference(); attributes.removeReference();
if (attributes.referenceCount() == 0) { if (attributes.referenceCount() == 0) {
attributesMap.remove(httpContext); attributesMap.remove(httpContext);
@ -79,8 +79,8 @@ public class ProxyContext {
} }
} }
synchronized Dictionary getContextAttributes(HttpContext httpContext) { synchronized Dictionary<String, Object> getContextAttributes(HttpContext httpContext) {
return (Dictionary) attributesMap.get(httpContext); return attributesMap.get(httpContext);
} }
/** /**
@ -102,7 +102,7 @@ public class ProxyContext {
return directory.delete(); return directory.delete();
} }
public class ContextAttributes extends Hashtable { public class ContextAttributes extends Hashtable<String, Object> {
private static final long serialVersionUID = 1916670423277243587L; private static final long serialVersionUID = 1916670423277243587L;
private int referenceCount; private int referenceCount;

View File

@ -30,10 +30,10 @@ import org.osgi.service.http.NamespaceException;
public class ProxyServlet extends HttpServlet implements Filter { public class ProxyServlet extends HttpServlet implements Filter {
private static final long serialVersionUID = 4117456123807468871L; private static final long serialVersionUID = 4117456123807468871L;
private Map servletRegistrations = new HashMap(); //alias --> servlet registration private Map<String, ServletRegistration> servletRegistrations = new HashMap<String, ServletRegistration>(); //alias --> servlet registration
private Set registeredServlets = new HashSet(); //All the servlets objects that have been registered private Set<Servlet> registeredServlets = new HashSet<Servlet>(); //All the servlets objects that have been registered
private Map filterRegistrations = new HashMap(); //filter --> filter registration; private Map<Filter, FilterRegistration> filterRegistrations = new HashMap<Filter, FilterRegistration>(); //filter --> filter registration;
private ProxyContext proxyContext; private ProxyContext proxyContext;
public void init(ServletConfig config) throws ServletException { 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 { private boolean processAlias(HttpServletRequest req, HttpServletResponse resp, String alias, String extensionAlias, FilterChain filterChain) throws ServletException, IOException {
ServletRegistration registration = null; ServletRegistration registration = null;
List matchingFilterRegistrations = Collections.EMPTY_LIST; List<FilterRegistration> matchingFilterRegistrations = Collections.emptyList();
String dispatchPathInfo = HttpServletRequestAdaptor.getDispatchPathInfo(req, filterChain); String dispatchPathInfo = HttpServletRequestAdaptor.getDispatchPathInfo(req, filterChain);
synchronized (this) { synchronized (this) {
if (extensionAlias == null) if (extensionAlias == null)
@ -123,9 +123,9 @@ public class ProxyServlet extends HttpServlet implements Filter {
if (registration != null) { if (registration != null) {
registration.addReference(); registration.addReference();
if (!filterRegistrations.isEmpty()) { if (!filterRegistrations.isEmpty()) {
matchingFilterRegistrations = new ArrayList(); matchingFilterRegistrations = new ArrayList<FilterRegistration>();
for (Iterator it = filterRegistrations.values().iterator(); it.hasNext();) { for (Iterator<FilterRegistration> it = filterRegistrations.values().iterator(); it.hasNext();) {
FilterRegistration filterRegistration = (FilterRegistration) it.next(); FilterRegistration filterRegistration = it.next();
if (filterRegistration.matches(dispatchPathInfo)) { if (filterRegistration.matches(dispatchPathInfo)) {
matchingFilterRegistrations.add(filterRegistration); matchingFilterRegistrations.add(filterRegistration);
filterRegistration.addReference(); filterRegistration.addReference();
@ -146,7 +146,7 @@ public class ProxyServlet extends HttpServlet implements Filter {
} }
} finally { } finally {
registration.removeReference(); registration.removeReference();
for (Iterator it = matchingFilterRegistrations.iterator(); it.hasNext();) { for (Iterator<FilterRegistration> it = matchingFilterRegistrations.iterator(); it.hasNext();) {
FilterRegistration filterRegistration = (FilterRegistration) it.next(); FilterRegistration filterRegistration = (FilterRegistration) it.next();
filterRegistration.removeReference(); filterRegistration.removeReference();
} }
@ -171,7 +171,7 @@ public class ProxyServlet extends HttpServlet implements Filter {
} }
//Effective registration of the servlet as defined HttpService#registerServlet() //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<String, String> initparams, HttpContext httpContext) throws ServletException, NamespaceException {
checkAlias(alias); checkAlias(alias);
if (servletRegistrations.containsKey(alias)) if (servletRegistrations.containsKey(alias))
throw new NamespaceException("The alias '" + alias + "' is already in use."); //$NON-NLS-1$//$NON-NLS-2$ 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<String, String> initparams, HttpContext httpContext) throws ServletException {
checkAlias(alias); checkAlias(alias);
if (filter == null) if (filter == null)
throw new IllegalArgumentException("Filter cannot be null"); //$NON-NLS-1$ 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); filterRegistrations.put(filter, registration);
} }
private int findFilterPriority(Dictionary initparams) { private int findFilterPriority(Dictionary<String, String> initparams) {
if (initparams == null) if (initparams == null)
return 0; return 0;
String filterPriority = (String) initparams.get("filter-priority"); //$NON-NLS-1$ 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); return filterConfig.getInitParameter(arg0);
} }
public Enumeration getInitParameterNames() { public Enumeration<String> getInitParameterNames() {
return filterConfig.getInitParameterNames(); return filterConfig.getInitParameterNames();
} }

View File

@ -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 { private void writeResource(final HttpServletRequest req, final HttpServletResponse resp, final String resourcePath, final URL resourceURL) throws IOException {
try { try {
AccessController.doPrivileged(new PrivilegedExceptionAction() { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception { public Object run() throws Exception {
URLConnection connection = resourceURL.openConnection(); URLConnection connection = resourceURL.openConnection();

View File

@ -16,13 +16,13 @@ import javax.servlet.*;
public class ServletConfigImpl implements ServletConfig { public class ServletConfigImpl implements ServletConfig {
private static final Dictionary EMPTY_PARAMS = new Hashtable(0); private static final Dictionary<String, String> EMPTY_PARAMS = new Hashtable<String, String>(0);
private static final String SERVLET_NAME = "servlet-name"; //$NON-NLS-1$ private static final String SERVLET_NAME = "servlet-name"; //$NON-NLS-1$
private Servlet servlet; private Servlet servlet;
private Dictionary initparams; private Dictionary<String, String> initparams;
private ServletContext servletContext; private ServletContext servletContext;
public ServletConfigImpl(Servlet servlet, Dictionary initparams, ServletContext servletContext) { public ServletConfigImpl(Servlet servlet, Dictionary<String, String> initparams, ServletContext servletContext) {
this.servlet = servlet; this.servlet = servlet;
this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS; this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS;
this.servletContext = servletContext; this.servletContext = servletContext;
@ -47,7 +47,7 @@ public class ServletConfigImpl implements ServletConfig {
return (String) initparams.get(name); return (String) initparams.get(name);
} }
public Enumeration getInitParameterNames() { public Enumeration<String> getInitParameterNames() {
return initparams.keys(); return initparams.keys();
} }
} }

View File

@ -47,14 +47,15 @@ public class ServletContextAdaptor implements ServletContext {
* implementation uses reflection to check for and then call the associated HttpContext.getResourcePaths(...) * 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. * method opportunistically. Null is returned if the method is not present or fails.
*/ */
public Set getResourcePaths(String name) { @SuppressWarnings("unchecked")
public Set<String> getResourcePaths(String name) {
if (name == null || !name.startsWith("/")) //$NON-NLS-1$ if (name == null || !name.startsWith("/")) //$NON-NLS-1$
return null; return null;
try { try {
Method getResourcePathsMethod = httpContext.getClass().getMethod("getResourcePaths", new Class[] {String.class}); //$NON-NLS-1$ Method getResourcePathsMethod = httpContext.getClass().getMethod("getResourcePaths", new Class[] {String.class}); //$NON-NLS-1$
if (!getResourcePathsMethod.isAccessible()) if (!getResourcePathsMethod.isAccessible())
getResourcePathsMethod.setAccessible(true); getResourcePathsMethod.setAccessible(true);
return (Set) getResourcePathsMethod.invoke(httpContext, new Object[] {name}); return (Set<String>) getResourcePathsMethod.invoke(httpContext, new Object[] {name});
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
@ -62,22 +63,22 @@ public class ServletContextAdaptor implements ServletContext {
} }
public Object getAttribute(String attributeName) { public Object getAttribute(String attributeName) {
Dictionary attributes = proxyContext.getContextAttributes(httpContext); Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
return attributes.get(attributeName); return attributes.get(attributeName);
} }
public Enumeration getAttributeNames() { public Enumeration<String> getAttributeNames() {
Dictionary attributes = proxyContext.getContextAttributes(httpContext); Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
return attributes.keys(); return attributes.keys();
} }
public void setAttribute(String attributeName, Object attributeValue) { public void setAttribute(String attributeName, Object attributeValue) {
Dictionary attributes = proxyContext.getContextAttributes(httpContext); Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
attributes.put(attributeName, attributeValue); attributes.put(attributeName, attributeValue);
} }
public void removeAttribute(String attributeName) { public void removeAttribute(String attributeName) {
Dictionary attributes = proxyContext.getContextAttributes(httpContext); Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
attributes.remove(attributeName); attributes.remove(attributeName);
} }
@ -88,7 +89,7 @@ public class ServletContextAdaptor implements ServletContext {
public URL getResource(final String name) { public URL getResource(final String name) {
try { try {
return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() { return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception { public Object run() throws Exception {
return httpContext.getResource(name); return httpContext.getResource(name);
} }
@ -119,7 +120,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.getInitParameter(arg0); return servletContext.getInitParameter(arg0);
} }
public Enumeration getInitParameterNames() { public Enumeration<String> getInitParameterNames() {
return servletContext.getInitParameterNames(); return servletContext.getInitParameterNames();
} }
@ -157,12 +158,12 @@ public class ServletContextAdaptor implements ServletContext {
} }
/**@deprecated*/ /**@deprecated*/
public Enumeration getServletNames() { public Enumeration<String> getServletNames() {
return servletContext.getServletNames(); return servletContext.getServletNames();
} }
/**@deprecated*/ /**@deprecated*/
public Enumeration getServlets() { public Enumeration<Servlet> getServlets() {
return servletContext.getServlets(); return servletContext.getServlets();
} }
@ -182,8 +183,8 @@ public class ServletContextAdaptor implements ServletContext {
// Added in Servlet 2.5 // Added in Servlet 2.5
public String getContextPath() { public String getContextPath() {
try { try {
Method getContextPathMethod = servletContext.getClass().getMethod("getContextPath", null); //$NON-NLS-1$ Method getContextPathMethod = servletContext.getClass().getMethod("getContextPath", (Class<?>[])null); //$NON-NLS-1$
return (String) getContextPathMethod.invoke(servletContext, null) + proxyContext.getServletPath(); return (String) getContextPathMethod.invoke(servletContext, (Object[])null) + proxyContext.getServletPath();
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
@ -198,7 +199,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.addFilter(arg0, arg1); return servletContext.addFilter(arg0, arg1);
} }
public Dynamic addFilter(String arg0, Class arg1) { public Dynamic addFilter(String arg0, Class<? extends Filter> arg1) {
return servletContext.addFilter(arg0, arg1); return servletContext.addFilter(arg0, arg1);
} }
@ -210,7 +211,7 @@ public class ServletContextAdaptor implements ServletContext {
servletContext.addListener(arg0); servletContext.addListener(arg0);
} }
public void addListener(Class arg0) { public void addListener(Class<? extends EventListener> arg0) {
servletContext.addListener(arg0); servletContext.addListener(arg0);
} }
@ -225,23 +226,23 @@ public class ServletContextAdaptor implements ServletContext {
} }
public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0, public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
Class arg1) { Class<? extends Servlet> arg1) {
return servletContext.addServlet(arg0, arg1); return servletContext.addServlet(arg0, arg1);
} }
public Filter createFilter(Class arg0) throws ServletException { public <T extends Filter> T createFilter(Class<T> arg0) throws ServletException {
return servletContext.createFilter(arg0); return servletContext.createFilter(arg0);
} }
public EventListener createListener(Class arg0) throws ServletException { public <T extends EventListener> T createListener(Class<T> arg0) throws ServletException {
return servletContext.createListener(arg0); return servletContext.createListener(arg0);
} }
public Servlet createServlet(Class arg0) throws ServletException { public <T extends Servlet> T createServlet(Class<T> arg0) throws ServletException {
return servletContext.createServlet(arg0); return servletContext.createServlet(arg0);
} }
public void declareRoles(String[] arg0) { public void declareRoles(String... arg0) {
servletContext.declareRoles(arg0); servletContext.declareRoles(arg0);
} }
@ -249,7 +250,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.getClassLoader(); return servletContext.getClassLoader();
} }
public Set getDefaultSessionTrackingModes() { public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
return servletContext.getDefaultSessionTrackingModes(); return servletContext.getDefaultSessionTrackingModes();
} }
@ -261,7 +262,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.getEffectiveMinorVersion(); return servletContext.getEffectiveMinorVersion();
} }
public Set getEffectiveSessionTrackingModes() { public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
return servletContext.getEffectiveSessionTrackingModes(); return servletContext.getEffectiveSessionTrackingModes();
} }
@ -269,7 +270,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.getFilterRegistration(arg0); return servletContext.getFilterRegistration(arg0);
} }
public Map getFilterRegistrations() { public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
return servletContext.getFilterRegistrations(); return servletContext.getFilterRegistrations();
} }
@ -281,7 +282,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.getServletRegistration(arg0); return servletContext.getServletRegistration(arg0);
} }
public Map getServletRegistrations() { public Map<String, ? extends ServletRegistration> getServletRegistrations() {
return servletContext.getServletRegistrations(); return servletContext.getServletRegistrations();
} }
@ -293,7 +294,7 @@ public class ServletContextAdaptor implements ServletContext {
return servletContext.setInitParameter(arg0, arg1); return servletContext.setInitParameter(arg0, arg1);
} }
public void setSessionTrackingModes(Set arg0) { public void setSessionTrackingModes(Set<SessionTrackingMode> arg0) {
servletContext.setSessionTrackingModes(arg0); servletContext.setSessionTrackingModes(arg0);
} }
} }

View File

@ -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

View File

@ -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