* Empty collection to serve as the basis for empty enumerations.
* <strong>DO NOT ADD ANY ELEMENTS TO THIS COLLECTION!</strong>
*/
- private static final ArrayList empty = new ArrayList();
+ private static final ArrayList<Object> empty = new ArrayList<Object>();
/**
/**
* The merged context initialization parameters for this Context.
*/
- private Map parameters = null;
+ private Map<String,String> parameters = null;
/**
*/
public Enumeration getAttributeNames() {
- return new Enumerator(attributes.keySet(), true);
+ return new Enumerator<String>(attributes.keySet(), true);
}
public String getInitParameter(final String name) {
mergeParameters();
- return ((String) parameters.get(name));
+ return parameters.get(name);
}
public Enumeration getInitParameterNames() {
mergeParameters();
- return (new Enumerator(parameters.keySet()));
+ return (new Enumerator<String>(parameters.keySet()));
}
jarFile = new File(context.getWorkPath(), path);
}
if (jarFile.exists()) {
- return jarFile.toURL();
+ return jarFile.toURI().toURL();
} else {
return null;
}
* @param resources Directory context to search
* @param path Collection path
*/
- private Set getResourcePathsInternal(DirContext resources, String path) {
+ private Set<String> getResourcePathsInternal(DirContext resources,
+ String path) {
- ResourceSet set = new ResourceSet();
+ ResourceSet<String> set = new ResourceSet<String>();
try {
listCollectionPaths(set, resources, path);
} catch (NamingException e) {
* @deprecated As of Java Servlet API 2.1, with no direct replacement.
*/
public Enumeration getServletNames() {
- return (new Enumerator(empty));
+ return (new Enumerator<Object>(empty));
}
* @deprecated As of Java Servlet API 2.1, with no direct replacement.
*/
public Enumeration getServlets() {
- return (new Enumerator(empty));
+ return (new Enumerator<Object>(empty));
}
return this.context;
}
- protected Map getReadonlyAttributes() {
+ protected Map<String,String> getReadonlyAttributes() {
return this.readOnlyAttributes;
}
/**
protected void clearAttributes() {
// Create list of attributes to be removed
- ArrayList list = new ArrayList();
- Iterator iter = attributes.keySet().iterator();
+ ArrayList<String> list = new ArrayList<String>();
+ Iterator<String> iter = attributes.keySet().iterator();
while (iter.hasNext()) {
list.add(iter.next());
}
// Remove application originated attributes
// (read only attributes will be left in place)
- Iterator keys = list.iterator();
+ Iterator<String> keys = list.iterator();
while (keys.hasNext()) {
- String key = (String) keys.next();
+ String key = keys.next();
removeAttribute(key);
}
if (parameters != null)
return;
- Map results = new ConcurrentHashMap();
+ Map<String,String> results = new ConcurrentHashMap<String,String>();
String names[] = context.findParameters();
for (int i = 0; i < names.length; i++)
results.put(names[i], context.findParameter(names[i]));
* List resource paths (recursively), and store all of them in the given
* Set.
*/
- private static void listCollectionPaths
- (Set set, DirContext resources, String path)
- throws NamingException {
+ private static void listCollectionPaths(Set<String> set,
+ DirContext resources, String path) throws NamingException {
- Enumeration childPaths = resources.listBindings(path);
+ Enumeration<Binding> childPaths = resources.listBindings(path);
while (childPaths.hasMoreElements()) {
- Binding binding = (Binding) childPaths.nextElement();
+ Binding binding = childPaths.nextElement();
String name = binding.getName();
StringBuffer childPath = new StringBuffer(path);
if (!"/".equals(path) && !path.endsWith("/"))
/**
* Cache Class object used for reflection.
*/
- private HashMap classCache;
+ private HashMap<String,Class<?>[]> classCache;
/**
* Cache method object.
*/
- private HashMap objectCache;
+ private HashMap<String,Method> objectCache;
// ----------------------------------------------------------- Constructors
super();
this.context = context;
- classCache = new HashMap();
- objectCache = new HashMap();
+ classCache = new HashMap<String,Class<?>[]>();
+ objectCache = new HashMap<String,Method>();
initClassCache();
}
private void initClassCache(){
- Class[] clazz = new Class[]{String.class};
+ Class<?>[] clazz = new Class[]{String.class};
classCache.put("getContext", clazz);
classCache.put("getMimeType", clazz);
classCache.put("getResourcePaths", clazz);
/**
* Use reflection to invoke the requested method. Cache the method object
* to speed up the process
- * @param appContext The AppliationContext object on which the method
- * will be invoked
- * @param methodName The method to call.
- * @param params The arguments passed to the called method.
- */
- private Object doPrivileged(ApplicationContext appContext,
- final String methodName,
- final Object[] params) {
- try{
- return invokeMethod(appContext, methodName, params );
- } catch (Throwable t){
- throw new RuntimeException(t.getMessage());
- }
-
- }
-
-
- /**
- * Use reflection to invoke the requested method. Cache the method object
- * to speed up the process
* will be invoked
* @param methodName The method to call.
* @param params The arguments passed to the called method.
throws Throwable{
try{
- Method method = (Method)objectCache.get(methodName);
+ Method method = objectCache.get(methodName);
if (method == null){
method = appContext.getClass()
- .getMethod(methodName, (Class[])classCache.get(methodName));
+ .getMethod(methodName, classCache.get(methodName));
objectCache.put(methodName, method);
}
return executeMethod(method,appContext,params);
} catch (Exception ex){
- handleException(ex, methodName);
+ handleException(ex);
return null;
} finally {
params = null;
* @param params The arguments passed to the called method.
*/
private Object doPrivileged(final String methodName,
- final Class[] clazz,
+ final Class<?>[] clazz,
Object[] params){
try{
- Method method = context.getClass()
- .getMethod(methodName, (Class[])clazz);
+ Method method = context.getClass().getMethod(methodName, clazz);
return executeMethod(method,context,params);
} catch (Exception ex){
try{
- handleException(ex, methodName);
+ handleException(ex);
}catch (Throwable t){
throw new RuntimeException(t.getMessage());
}
InvocationTargetException {
if (SecurityUtil.isPackageProtectionEnabled()){
- return AccessController.doPrivileged(new PrivilegedExceptionAction(){
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>(){
public Object run() throws IllegalAccessException, InvocationTargetException{
return method.invoke(context, params);
}
* Throw the real exception.
* @param ex The current exception
*/
- private void handleException(Exception ex, String methodName)
+ private void handleException(Exception ex)
throws Throwable {
Throwable realException;
implements RequestDispatcher {
- protected class PrivilegedForward implements PrivilegedExceptionAction {
+ protected class PrivilegedForward
+ implements PrivilegedExceptionAction<Void> {
private ServletRequest request;
private ServletResponse response;
this.response = response;
}
- public Object run() throws java.lang.Exception {
+ public Void run() throws java.lang.Exception {
doForward(request,response);
return null;
}
}
- protected class PrivilegedInclude implements PrivilegedExceptionAction {
+ protected class PrivilegedInclude implements
+ PrivilegedExceptionAction<Void> {
private ServletRequest request;
private ServletResponse response;
this.response = response;
}
- public Object run() throws ServletException, IOException {
+ public Void run() throws ServletException, IOException {
doInclude(request,response);
return null;
}
ServletOutputStream stream = response.getOutputStream();
stream.close();
} catch (IllegalStateException f) {
- ;
+ // Ignore
} catch (IOException f) {
- ;
+ // Ignore
}
} catch (IOException e) {
- ;
+ // Ignore
}
}
final class ApplicationFilterChain implements FilterChain, CometFilterChain {
// Used to enforce requirements of SRV.8.2 / SRV.14.2.5.1
- private final static ThreadLocal lastServicedRequest;
- private final static ThreadLocal lastServicedResponse;
+ private final static ThreadLocal<ServletRequest> lastServicedRequest;
+ private final static ThreadLocal<ServletResponse> lastServicedResponse;
static {
if (Globals.STRICT_SERVLET_COMPLIANCE) {
- lastServicedRequest = new ThreadLocal();
- lastServicedResponse = new ThreadLocal();
+ lastServicedRequest = new ThreadLocal<ServletRequest>();
+ lastServicedResponse = new ThreadLocal<ServletResponse>();
} else {
lastServicedRequest = null;
lastServicedResponse = null;
* Static class array used when the SecurityManager is turned on and
* <code>doFilter</code> is invoked.
*/
- private static Class[] classType = new Class[]{ServletRequest.class,
- ServletResponse.class,
- FilterChain.class};
+ private static Class<?>[] classType = new Class[]{ServletRequest.class,
+ ServletResponse.class,
+ FilterChain.class};
/**
* Static class array used when the SecurityManager is turned on and
* <code>service</code> is invoked.
*/
- private static Class[] classTypeUsedInService = new Class[]{
+ private static Class<?>[] classTypeUsedInService = new Class[]{
ServletRequest.class,
ServletResponse.class};
* Static class array used when the SecurityManager is turned on and
* <code>doFilterEvent</code> is invoked.
*/
- private static Class[] cometClassType =
+ private static Class<?>[] cometClassType =
new Class[]{ CometEvent.class, CometFilterChain.class};
/**
* Static class array used when the SecurityManager is turned on and
* <code>event</code> is invoked.
*/
- private static Class[] classTypeUsedInEvent =
+ private static Class<?>[] classTypeUsedInEvent =
new Class[] { CometEvent.class };
// ---------------------------------------------------- FilterChain Methods
final ServletResponse res = response;
try {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
- public Object run()
+ new java.security.PrivilegedExceptionAction<Void>() {
+ public Void run()
throws ServletException, IOException {
internalDoFilter(req,res);
return null;
principal);
args = null;
} else {
- servlet.service((HttpServletRequest) request,
- (HttpServletResponse) response);
+ servlet.service(request, response);
}
} else {
servlet.service(request, response);
final CometEvent ev = event;
try {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
- public Object run()
+ new java.security.PrivilegedExceptionAction<Void>() {
+ public Void run()
throws ServletException, IOException {
internalDoFilterEvent(ev);
return null;
* @return The last request to be serviced.
*/
public static ServletRequest getLastServicedRequest() {
- return (ServletRequest) lastServicedRequest.get();
+ return lastServicedRequest.get();
}
* @return The last response to be serviced.
*/
public static ServletResponse getLastServicedResponse() {
- return (ServletResponse) lastServicedResponse.get();
+ return lastServicedResponse.get();
}
*/
public String getInitParameter(String name) {
- Map map = filterDef.getParameterMap();
+ Map<String,String> map = filterDef.getParameterMap();
if (map == null)
return (null);
else
- return ((String) map.get(name));
+ return map.get(name);
}
*/
public Enumeration getInitParameterNames() {
- Map map = filterDef.getParameterMap();
+ Map<String,String> map = filterDef.getParameterMap();
if (map == null)
- return (new Enumerator(new ArrayList()));
+ return (new Enumerator<String>(new ArrayList<String>()));
else
- return (new Enumerator(map.keySet()));
+ return (new Enumerator<String>(map.keySet()));
}
} else {
// Allocate a new filter instance
- Filter filter = getFilter();
+ getFilter();
}
import javax.servlet.Servlet;
import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.CometFilter;
import org.apache.catalina.Globals;
public static final String DISPATCHER_REQUEST_PATH_ATTR =
Globals.DISPATCHER_REQUEST_PATH_ATTR;
- private static ApplicationFilterFactory factory = null;;
+ private static ApplicationFilterFactory factory = null;
// ----------------------------------------------------------- Constructors
requestPath = attribute.toString();
}
- HttpServletRequest hreq = null;
- if (request instanceof HttpServletRequest)
- hreq = (HttpServletRequest)request;
// If there is no servlet to execute, return null
if (servlet == null)
return (null);
ApplicationFilterConfig filterConfig = (ApplicationFilterConfig)
context.findFilterConfig(filterMaps[i].getFilterName());
if (filterConfig == null) {
- ; // FIXME - log configuration problem
+ // FIXME - log configuration problem
continue;
}
boolean isCometFilter = false;
ApplicationFilterConfig filterConfig = (ApplicationFilterConfig)
context.findFilterConfig(filterMaps[i].getFilterName());
if (filterConfig == null) {
- ; // FIXME - log configuration problem
+ // FIXME - log configuration problem
continue;
}
boolean isCometFilter = false;
* The request parameters for this request. This is initialized from the
* wrapped request, but updates are allowed.
*/
- protected Map parameters = null;
+ protected Map<String, String[]> parameters = null;
/**
* Override the <code>getParameterMap()</code> method of the
* wrapped request.
*/
- public Map getParameterMap() {
+ public Map<String, String[]> getParameterMap() {
parseParameters();
return (parameters);
* Override the <code>getParameterNames()</code> method of the
* wrapped request.
*/
- public Enumeration getParameterNames() {
+ public Enumeration<String> getParameterNames() {
parseParameters();
- return (new Enumerator(parameters.keySet()));
+ return (new Enumerator<String>(parameters.keySet()));
}
parseParameters();
Object value = parameters.get(name);
if (value == null)
- return ((String[]) null);
+ return null;
else if (value instanceof String[])
return ((String[]) value);
else if (value instanceof String) {
*
* @param orig Origin Map to be copied
*/
- Map copyMap(Map orig) {
+ Map<String, String[]> copyMap(Map<String, String[]> orig) {
if (orig == null)
- return (new HashMap());
- HashMap dest = new HashMap();
- Iterator keys = orig.keySet().iterator();
+ return (new HashMap<String, String[]>());
+ HashMap<String, String[]> dest = new HashMap<String, String[]>();
+ Iterator<String> keys = orig.keySet().iterator();
while (keys.hasNext()) {
- String key = (String) keys.next();
+ String key = keys.next();
dest.put(key, orig.get(key));
}
return (dest);
return;
}
- parameters = new HashMap();
+ parameters = new HashMap<String, String[]>();
parameters = copyMap(getRequest().getParameterMap());
mergeParameters();
parsedParams = true;
*/
protected String[] mergeValues(Object values1, Object values2) {
- ArrayList results = new ArrayList();
+ ArrayList<Object> results = new ArrayList<Object>();
if (values1 == null)
;
results.add(values2.toString());
String values[] = new String[results.size()];
- return ((String[]) results.toArray(values));
+ return results.toArray(values);
}
if ((queryParamString == null) || (queryParamString.length() < 1))
return;
- HashMap queryParameters = new HashMap();
+ HashMap<String, String[]> queryParameters = new HashMap<String, String[]>();
String encoding = getCharacterEncoding();
if (encoding == null)
encoding = "ISO-8859-1";
RequestUtil.parseParameters
(queryParameters, queryParamString, encoding);
} catch (Exception e) {
- ;
+ // Ignore
}
- Iterator keys = parameters.keySet().iterator();
+ Iterator<String> keys = parameters.keySet().iterator();
while (keys.hasNext()) {
- String key = (String) keys.next();
+ String key = keys.next();
Object value = queryParameters.get(key);
if (value == null) {
queryParameters.put(key, parameters.get(key));
* Utility class used to expose the special attributes as being available
* as request attributes.
*/
- protected class AttributeNamesEnumerator implements Enumeration {
+ protected class AttributeNamesEnumerator implements Enumeration<String> {
protected int pos = -1;
protected int last = -1;
- protected Enumeration parentEnumeration = null;
+ protected Enumeration<String> parentEnumeration = null;
protected String next = null;
public AttributeNamesEnumerator() {
|| ((next = findNext()) != null));
}
- public Object nextElement() {
+ public String nextElement() {
if (pos != last) {
for (int i = pos + 1; i <= last; i++) {
if (getAttribute(specials[i]) != null) {
protected String findNext() {
String result = null;
while ((result == null) && (parentEnumeration.hasMoreElements())) {
- String current = (String) parentEnumeration.nextElement();
+ String current = parentEnumeration.nextElement();
if (!isSpecial(current)) {
result = current;
}
* The request attributes for this request. This is initialized from the
* wrapped request, but updates are allowed.
*/
- protected HashMap attributes = new HashMap();
+ protected HashMap<String, Object> attributes =
+ new HashMap<String, Object>();
/**
* Override the <code>getAttributeNames()</code> method of the wrapped
* request.
*/
- public Enumeration getAttributeNames() {
+ public Enumeration<String> getAttributeNames() {
synchronized (attributes) {
- return (new Enumerator(attributes.keySet()));
+ return (new Enumerator<String>(attributes.keySet()));
}
}
// Initialize the attributes for this request
synchronized (attributes) {
attributes.clear();
- Enumeration names = request.getAttributeNames();
+ Enumeration<String> names = request.getAttributeNames();
while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
+ String name = names.nextElement();
Object value = request.getAttribute(name);
attributes.put(name, value);
}
}
try {
String methodName = "initialize";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = String.class;
Object paramValues[] = new Object[1];
paramValues[0] = null;
- Class clazz = Class.forName("org.apache.tomcat.jni.Library");
+ Class<?> clazz = Class.forName("org.apache.tomcat.jni.Library");
Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
major = clazz.getField("TCN_MAJOR_VERSION").getInt(null);
+ minor + "." + patch));
}
// Log APR flags
- log.info(sm.getString("aprListener.flags", Library.APR_HAVE_IPV6, Library.APR_HAS_SENDFILE,
- Library.APR_HAS_SO_ACCEPTFILTER, Library.APR_HAS_RANDOM));
+ log.info(sm.getString("aprListener.flags",
+ Boolean.valueOf(Library.APR_HAVE_IPV6),
+ Boolean.valueOf(Library.APR_HAS_SENDFILE),
+ Boolean.valueOf(Library.APR_HAS_SO_ACCEPTFILTER),
+ Boolean.valueOf(Library.APR_HAS_RANDOM)));
return true;
}
return;
}
String methodName = "randSet";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = String.class;
Object paramValues[] = new Object[1];
paramValues[0] = SSLRandomSeed;
- Class clazz = Class.forName("org.apache.tomcat.jni.SSL");
+ Class<?> clazz = Class.forName("org.apache.tomcat.jni.SSL");
Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
}
public void setSSLEngine(String SSLEngine) {
- this.SSLEngine = SSLEngine;
+ AprLifecycleListener.SSLEngine = SSLEngine;
}
public String getSSLRandomSeed() {
}
public void setSSLRandomSeed(String SSLRandomSeed) {
- this.SSLRandomSeed = SSLRandomSeed;
+ AprLifecycleListener.SSLRandomSeed = SSLRandomSeed;
}
}
* Tomcat.
*/
protected class PrivilegedAddChild
- implements PrivilegedAction {
+ implements PrivilegedAction<Void> {
private Container child;
this.child = child;
}
- public Object run() {
+ public Void run() {
addChildInternal(child);
return null;
}
/**
* The child Containers belonging to this Container, keyed by name.
*/
- protected HashMap children = new HashMap();
+ protected HashMap<String, Container> children =
+ new HashMap<String, Container>();
/**
/**
* The container event listeners for this Container.
*/
- protected ArrayList listeners = new ArrayList();
+ protected ArrayList<ContainerListener> listeners = new ArrayList<ContainerListener>();
/**
DirContext oldResources = this.resources;
if (oldResources == resources)
return;
- Hashtable env = new Hashtable();
+ Hashtable<String, String> env = new Hashtable<String, String>();
if (getParent() != null)
env.put(ProxyDirContext.HOST, getParent().getName());
env.put(ProxyDirContext.CONTEXT, getName());
*/
public void addChild(Container child) {
if (Globals.IS_SECURITY_ENABLED) {
- PrivilegedAction dp =
+ PrivilegedAction<Void> dp =
new PrivilegedAddChild(child);
AccessController.doPrivileged(dp);
} else {
if (name == null)
return (null);
synchronized (children) { // Required by post-start changes
- return ((Container) children.get(name));
+ return children.get(name);
}
}
synchronized (children) {
Container results[] = new Container[children.size()];
- return ((Container[]) children.values().toArray(results));
+ return children.values().toArray(results);
}
}
synchronized (listeners) {
ContainerListener[] results =
new ContainerListener[listeners.size()];
- return ((ContainerListener[]) listeners.toArray(results));
+ return listeners.toArray(results);
}
}
ContainerEvent event = new ContainerEvent(this, type, data);
ContainerListener list[] = new ContainerListener[0];
synchronized (listeners) {
- list = (ContainerListener[]) listeners.toArray(list);
+ list = listeners.toArray(list);
}
for (int i = 0; i < list.length; i++)
- ((ContainerListener) list[i]).containerEvent(event);
+ list[i].containerEvent(event);
}
public ObjectName[] getChildren() {
ObjectName result[]=new ObjectName[children.size()];
- Iterator it=children.values().iterator();
+ Iterator<Container> it=children.values().iterator();
int i=0;
while( it.hasNext() ) {
Object next=it.next();
try {
thread.join();
} catch (InterruptedException e) {
- ;
+ // Ignore
}
thread = null;
try {
Thread.sleep(backgroundProcessorDelay * 1000L);
} catch (InterruptedException e) {
- ;
+ // Ignore
}
if (!threadDone) {
Container parent = (Container) getMappingObject();
protected FilterChain filterChain = null;
- private static Enumeration dummyEnum = new Enumeration(){
+ private static Enumeration<Object> dummyEnum = new Enumeration<Object>(){
public boolean hasMoreElements(){
return false;
}
}
public void finishRequest() throws IOException {}
public Object getNote(String name) { return null; }
- public Iterator getNoteNames() { return null; }
+ public Iterator<String> getNoteNames() { return null; }
public void removeNote(String name) {}
public void setContentType(String type) {}
public void setNote(String name, Object value) {}
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.ContainerListener;
import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
-import org.apache.catalina.Service;
import org.apache.catalina.deploy.ContextEjb;
import org.apache.catalina.deploy.ContextEnvironment;
import org.apache.catalina.deploy.ContextHandler;
/**
* Objectnames hashtable.
*/
- protected HashMap objectNames = new HashMap();
+ protected HashMap<String, ObjectName> objectNames =
+ new HashMap<String, ObjectName>();
/**
if (initialized)
return;
- Hashtable contextEnv = new Hashtable();
+ Hashtable<String, Object> contextEnv = new Hashtable<String, Object>();
try {
namingContext = new NamingContext(contextEnv, getName());
} catch (NamingException e) {
compCtx.bind("UserTransaction", ref);
ContextTransaction transaction = namingResources.getTransaction();
if (transaction != null) {
- Iterator params = transaction.listProperties();
+ Iterator<String> params = transaction.listProperties();
while (params.hasNext()) {
- String paramName = (String) params.next();
+ String paramName = params.next();
String paramValue = (String) transaction.getProperty(paramName);
StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
ref.add(refAddr);
if (path.length() < 1)
path = "/";
Host host = (Host) ((Context)container).getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
name = new ObjectName(domain + ":type=DataSource" +
",path=" + path +
",host=" + host.getName() +
Reference ref = new EjbRef
(ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
// Adding the additional parameters, if any
- Iterator params = ejb.listProperties();
+ Iterator<String> params = ejb.listProperties();
while (params.hasNext()) {
- String paramName = (String) params.next();
+ String paramName = params.next();
String paramValue = (String) ejb.getProperty(paramName);
StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
ref.add(refAddr);
(service.getName(), service.getType(), service.getServiceqname(),
service.getWsdlfile(), service.getJaxrpcmappingfile());
// Adding the additional port-component-ref, if any
- Iterator portcomponent = service.getServiceendpoints();
+ Iterator<String> portcomponent = service.getServiceendpoints();
while (portcomponent.hasNext()) {
- String serviceendpoint = (String) portcomponent.next();
+ String serviceendpoint = portcomponent.next();
StringRefAddr refAddr = new StringRefAddr(ServiceRef.SERVICEENDPOINTINTERFACE, serviceendpoint);
ref.add(refAddr);
- String portlink = (String) service.getPortlink(serviceendpoint);
+ String portlink = service.getPortlink(serviceendpoint);
refAddr = new StringRefAddr(ServiceRef.PORTCOMPONENTLINK, portlink);
ref.add(refAddr);
}
// Adding the additional parameters, if any
- Iterator handlers = service.getHandlers();
+ Iterator<String> handlers = service.getHandlers();
while (handlers.hasNext()) {
- String handlername = (String) handlers.next();
- ContextHandler handler = (ContextHandler) service.getHandler(handlername);
+ String handlername = handlers.next();
+ ContextHandler handler = service.getHandler(handlername);
HandlerRef handlerRef = new HandlerRef(handlername, handler.getHandlerclass());
- Iterator localParts = handler.getLocalparts();
+ Iterator<String> localParts = handler.getLocalparts();
while (localParts.hasNext()) {
- String localPart = (String) localParts.next();
- String namespaceURI = (String) handler.getNamespaceuri(localPart);
+ String localPart = localParts.next();
+ String namespaceURI = handler.getNamespaceuri(localPart);
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_LOCALPART, localPart));
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_NAMESPACE, namespaceURI));
}
- Iterator params = handler.listProperties();
+ Iterator<String> params = handler.listProperties();
while (params.hasNext()) {
- String paramName = (String) params.next();
+ String paramName = params.next();
String paramValue = (String) handler.getProperty(paramName);
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMNAME, paramName));
handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMVALUE, paramValue));
(resource.getType(), resource.getDescription(),
resource.getScope(), resource.getAuth());
// Adding the additional parameters, if any
- Iterator params = resource.listProperties();
+ Iterator<String> params = resource.listProperties();
while (params.hasNext()) {
- String paramName = (String) params.next();
+ String paramName = params.next();
String paramValue = (String) resource.getProperty(paramName);
StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
ref.add(refAddr);
// Create a reference to the resource env.
Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
// Adding the additional parameters, if any
- Iterator params = resourceEnvRef.listProperties();
+ Iterator<String> params = resourceEnvRef.listProperties();
while (params.hasNext()) {
- String paramName = (String) params.next();
+ String paramName = params.next();
String paramValue = (String) resourceEnvRef.getProperty(paramName);
StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
ref.add(refAddr);
logger.error(sm.getString("naming.unbindFailed", e));
}
- ObjectName on = (ObjectName) objectNames.get(name);
+ ObjectName on = objectNames.get(name);
if (on != null) {
Registry.getRegistry(null, null).unregisterComponent(on);
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
- ;
+ // Ignore
}
}
try {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (IllegalStateException e) {
- ;
+ // Ignore
} catch (IOException e) {
- ;
+ // Ignore
}
}
/**
- * The live deploy flag for this Host.
- */
- private boolean liveDeploy = true;
-
-
- /**
* Unpack WARs property.
*/
private boolean unpackWARs = true;
try {
((Contained) oldBasic).setContainer(null);
} catch (Throwable t) {
- ;
+ // Ignore
}
}
}
*/
public Valve[] getValves() {
- ArrayList valveList = new ArrayList();
+ ArrayList<Valve> valveList = new ArrayList<Valve>();
Valve current = first;
if (current == null) {
current = basic;
current = current.getNext();
}
- return ((Valve[]) valveList.toArray(new Valve[0]));
+ return valveList.toArray(new Valve[0]);
}
public ObjectName[] getValveObjectNames() {
- ArrayList valveList = new ArrayList();
+ ArrayList<ObjectName> valveList = new ArrayList<ObjectName>();
Valve current = first;
if (current == null) {
current = basic;
current = current.getNext();
}
- return ((ObjectName[]) valveList.toArray(new ObjectName[0]));
+ return valveList.toArray(new ObjectName[0]);
}
private static Log log = LogFactory.getLog(StandardServer.class);
- // -------------------------------------------------------------- Constants
-
-
- /**
- * ServerLifecycleListener classname.
- */
- private static String SERVER_LISTENER_CLASS_NAME =
- "org.apache.catalina.mbeans.ServerLifecycleListener";
-
-
// ------------------------------------------------------------ Constructor
try {
((Lifecycle) service).start();
} catch (LifecycleException e) {
- ;
+ // Ignore
}
}
try {
socket.close();
} catch (IOException e) {
- ;
+ // Ignore
}
// Match against our command string
try {
serverSocket.close();
} catch (IOException e) {
- ;
+ // Ignore
}
}
try {
((Lifecycle) services[j]).stop();
} catch (LifecycleException e) {
- ;
+ // Ignore
}
}
int k = 0;
try {
((Lifecycle) this.container).start();
} catch (LifecycleException e) {
- ;
+ // Ignore
}
}
synchronized (connectors) {
try {
((Lifecycle) oldContainer).stop();
} catch (LifecycleException e) {
- ;
+ // Ignore
}
}
}
}
- if (started && (connector instanceof Lifecycle)) {
+ if (started) {
try {
((Lifecycle) connector).start();
} catch (LifecycleException e) {
}
if (j < 0)
return;
- if (started && (connectors[j] instanceof Lifecycle)) {
+ if (started) {
try {
((Lifecycle) connectors[j]).stop();
} catch (LifecycleException e) {
// Start our defined Connectors second
synchronized (connectors) {
for (int i = 0; i < connectors.length; i++) {
- if (connectors[i] instanceof Lifecycle)
- ((Lifecycle) connectors[i]).start();
+ ((Lifecycle) connectors[i]).start();
}
}
// Stop our defined Connectors first
synchronized (connectors) {
for (int i = 0; i < connectors.length; i++) {
- if (connectors[i] instanceof Lifecycle)
- ((Lifecycle) connectors[i]).stop();
+ ((Lifecycle) connectors[i]).stop();
}
}
TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority());
lifecycle.fireLifecycleEvent(START_EVENT, null);
executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
- taskqueue.setParent( (ThreadPoolExecutor) executor);
+ taskqueue.setParent(executor);
lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
}
/**
* Mappings associated with the wrapper.
*/
- protected ArrayList mappings = new ArrayList();
+ protected ArrayList<String> mappings = new ArrayList<String>();
/**
* The initialization parameters for this servlet, keyed by
* parameter name.
*/
- protected HashMap parameters = new HashMap();
+ protected HashMap<String, String> parameters = new HashMap<String, String>();
/**
* used in the servlet. The corresponding value is the role name of
* the web application itself.
*/
- protected HashMap references = new HashMap();
+ protected HashMap<String, String> references = new HashMap<String, String>();
/**
/**
* Stack containing the STM instances.
*/
- protected Stack instancePool = null;
+ protected Stack<Servlet> instancePool = null;
/**
* Static class array used when the SecurityManager is turned on and
* <code>Servlet.init</code> is invoked.
*/
- protected static Class[] classType = new Class[]{ServletConfig.class};
+ protected static Class<?>[] classType = new Class[]{ServletConfig.class};
/**
* Static class array used when the SecurityManager is turned on and
* <code>Servlet.service</code> is invoked.
*/
- protected static Class[] classTypeUsedInService = new Class[]{
+ protected static Class<?>[] classTypeUsedInService = new Class[]{
ServletRequest.class,
ServletResponse.class};
try {
loadServlet();
} catch (Throwable t) {
- ;
+ // Ignore
}
return (singleThreadModel);
*/
public String[] getServletMethods() throws ServletException {
- Class servletClazz = loadServlet().getClass();
+ Class<? extends Servlet> servletClazz = loadServlet().getClass();
if (!javax.servlet.http.HttpServlet.class.isAssignableFrom(
servletClazz)) {
return DEFAULT_SERVLET_METHODS;
}
- HashSet allow = new HashSet();
+ HashSet<String> allow = new HashSet<String>();
allow.add("TRACE");
allow.add("OPTIONS");
}
String[] methodNames = new String[allow.size()];
- return (String[]) allow.toArray(methodNames);
+ return allow.toArray(methodNames);
}
try {
instancePool.wait();
} catch (InterruptedException e) {
- ;
+ // Ignore
}
}
}
if (log.isTraceEnabled())
log.trace(" Returning allocated STM instance");
countAllocated.incrementAndGet();
- return (Servlet) instancePool.pop();
+ return instancePool.pop();
}
public String findInitParameter(String name) {
synchronized (parameters) {
- return ((String) parameters.get(name));
+ return parameters.get(name);
}
}
synchronized (parameters) {
String results[] = new String[parameters.size()];
- return ((String[]) parameters.keySet().toArray(results));
+ return parameters.keySet().toArray(results);
}
}
public String[] findMappings() {
synchronized (mappings) {
- return (String[]) mappings.toArray(new String[mappings.size()]);
+ return mappings.toArray(new String[mappings.size()]);
}
}
public String findSecurityReference(String name) {
synchronized (references) {
- return ((String) references.get(name));
+ return references.get(name);
}
}
synchronized (references) {
String results[] = new String[references.size()];
- return ((String[]) references.keySet().toArray(results));
+ return references.keySet().toArray(results);
}
}
if( Globals.IS_SECURITY_ENABLED) {
- Object[] args = new Object[]{((ServletConfig)facade)};
+ Object[] args = new Object[]{(facade)};
SecurityUtil.doAsPrivilege("init",
servlet,
classType,
singleThreadModel = servlet instanceof SingleThreadModel;
if (singleThreadModel) {
if (instancePool == null)
- instancePool = new Stack();
+ instancePool = new Stack<Servlet>();
}
fireContainerEvent("load", this);
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
- ;
+ // Ignore
}
nRetries++;
}
if (singleThreadModel && (instancePool != null)) {
try {
while (!instancePool.isEmpty()) {
- Servlet s = (Servlet) instancePool.pop();
+ Servlet s = instancePool.pop();
if (Globals.IS_SECURITY_ENABLED) {
SecurityUtil.doAsPrivilege("destroy", s);
SecurityUtil.remove(instance);
* Return the set of initialization parameter names defined for this
* servlet. If none are defined, an empty Enumeration is returned.
*/
- public Enumeration getInitParameterNames() {
+ public Enumeration<String> getInitParameterNames() {
synchronized (parameters) {
- return (new Enumerator(parameters.keySet()));
+ return (new Enumerator<String>(parameters.keySet()));
}
}
*/
protected void addDefaultMapper(String mapperClass) {
- ; // No need for a default Mapper on a Wrapper
+ // No need for a default Mapper on a Wrapper
}
return (true);
}
try {
- Class clazz =
+ Class<?> clazz =
this.getClass().getClassLoader().loadClass(classname);
return (ContainerServlet.class.isAssignableFrom(clazz));
} catch (Throwable t) {
}
- protected Method[] getAllDeclaredMethods(Class c) {
+ protected Method[] getAllDeclaredMethods(Class<?> c) {
if (c.equals(javax.servlet.http.HttpServlet.class)) {
return null;
public StandardWrapperFacade(StandardWrapper config) {
super();
- this.config = (ServletConfig) config;
+ this.config = config;
}