String war = null;
FileItem warUpload = null;
try {
- List items = upload.parseRequest(request);
+ List<FileItem> items = upload.parseRequest(request);
// Process the uploaded fields
- Iterator iter = items.iterator();
+ Iterator<FileItem> iter = items.iterator();
while (iter.hasNext()) {
- FileItem item = (FileItem) iter.next();
+ FileItem item = iter.next();
if (!item.isFormField()) {
if (item.getFieldName().equals("deployWar") &&
for (int i = 0; i < children.length; i++)
contextPaths[i] = children[i].getName();
- TreeMap sortedContextPathsMap = new TreeMap();
+ TreeMap<String,String> sortedContextPathsMap =
+ new TreeMap<String,String>();
for (int i = 0; i < contextPaths.length; i++) {
String displayPath = contextPaths[i];
String appsUndeploy = sm.getString("htmlManagerServlet.appsUndeploy");
String appsExpire = sm.getString("htmlManagerServlet.appsExpire");
- Iterator iterator = sortedContextPathsMap.entrySet().iterator();
+ Iterator<Map.Entry<String,String>> iterator =
+ sortedContextPathsMap.entrySet().iterator();
boolean isHighlighted = true;
boolean isDeployed = true;
String highlightColor = null;
highlightColor = "#FFFFFF";
}
- Map.Entry entry = (Map.Entry) iterator.next();
- String displayPath = (String) entry.getKey();
- String contextPath = (String) entry.getValue();
+ Map.Entry<String,String> entry = iterator.next();
+ String displayPath = entry.getKey();
+ String contextPath = entry.getValue();
Context context = (Context) host.findChild(contextPath);
if (displayPath.equals("")) {
displayPath = "/";
* @throws IOException
*/
protected void displaySessionsListPage(String path, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- List/*<Session>*/ activeSessions = Arrays.asList(getSessionsForPath(path));
+ List<Session> activeSessions = Arrays.asList(getSessionsForPath(path));
String sortBy = req.getParameter("sort");
String orderBy = null;
if (null != sortBy && !"".equals(sortBy.trim())) {
- Comparator comparator = getComparator(sortBy);
+ Comparator<Session> comparator = getComparator(sortBy);
if (comparator != null) {
orderBy = req.getParameter("order");
if ("DESC".equalsIgnoreCase(orderBy)) {
}
}
- protected Comparator getComparator(String sortBy) {
- Comparator comparator = null;
+ protected Comparator<Session> getComparator(String sortBy) {
+ Comparator<Session> comparator = null;
if ("CreationTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Date>() {
+ public Comparable<Date> getComparableObject(Session session) {
return new Date(session.getCreationTime());
}
};
} else if ("id".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<String>() {
+ public Comparable<String> getComparableObject(Session session) {
return session.getId();
}
};
} else if ("LastAccessedTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Date>() {
+ public Comparable<Date> getComparableObject(Session session) {
return new Date(session.getLastAccessedTime());
}
};
} else if ("MaxInactiveInterval".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Date>() {
+ public Comparable<Date> getComparableObject(Session session) {
return new Date(session.getMaxInactiveInterval());
}
};
} else if ("new".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Boolean>() {
+ public Comparable<Boolean> getComparableObject(Session session) {
return Boolean.valueOf(session.getSession().isNew());
}
};
} else if ("locale".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<String>() {
+ public Comparable<String> getComparableObject(Session session) {
return JspHelper.guessDisplayLocaleFromSession(session);
}
};
} else if ("user".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<String>() {
+ public Comparable<String> getComparableObject(Session session) {
return JspHelper.guessDisplayUserFromSession(session);
}
};
} else if ("UsedTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Date>() {
+ public Comparable<Date> getComparableObject(Session session) {
return new Date(SessionUtils.getUsedTimeForSession(session));
}
};
} else if ("InactiveTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Date>() {
+ public Comparable<Date> getComparableObject(Session session) {
return new Date(SessionUtils.getInactiveTimeForSession(session));
}
};
} else if ("TTL".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
+ comparator = new BaseSessionComparator<Date>() {
+ public Comparable<Date> getComparableObject(Session session) {
return new Date(SessionUtils.getTTLForSession(session));
}
};
public void listBeans( PrintWriter writer, String qry )
{
- Set names = null;
+ Set<ObjectName> names = null;
try {
names=mBeanServer.queryNames(new ObjectName(qry), null);
writer.println("OK - Number of results: " + names.size());
return;
}
- Iterator it=names.iterator();
+ Iterator<ObjectName> it=names.iterator();
while( it.hasNext()) {
- ObjectName oname=(ObjectName)it.next();
+ ObjectName oname=it.next();
writer.println( "Name: " + oname.toString());
try {
package org.apache.catalina.manager;
-import java.io.IOException;
-import java.io.Writer;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
public class JspHelper {
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
- private static final String DATE_FORMAT = "yyyy-MM-dd";
- private static final String TIME_FORMAT = "HH:mm:ss";
/**
* Public constructor, so that this class can be considered a JavaBean
}
- /**
- * Following copied from org.apache.taglibs.standard.tag.common.core.OutSupport v1.1.2
- *
- * Optimized to create no extra objects and write directly
- * to the JspWriter using blocks of escaped and unescaped characters
- *
- */
- private static void writeEscapedXml(char[] buffer, int length, Writer w) throws IOException {
- int start = 0;
-
- for (int i = 0; i < length; i++) {
- char c = buffer[i];
- if (c <= HIGHEST_SPECIAL) {
- char[] escaped = specialCharactersRepresentation[c];
- if (escaped != null) {
- // add unescaped portion
- if (start < i) {
- w.write(buffer,start,i-start);
- }
- // add escaped xml
- w.write(escaped);
- start = i + 1;
- }
- }
- }
- // add rest of unescaped portion
- if (start < length) {
- w.write(buffer,start,length-start);
- }
- }
-
-
/*
* Following copied from org.apache.taglibs.standard.tag.common.core.Util v1.1.2
*/
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.Manager;
*/
public void destroy() {
- ; // No actions necessary
+ // No actions necessary
}
value = getServletConfig().getInitParameter("debug");
debug = Integer.parseInt(value);
} catch (Throwable t) {
- ;
+ // Ignore
}
// Acquire global JNDI resources if available
writer.println(sm.getString("managerServlet.resourcesAll"));
}
- Class clazz = null;
+ Class<?> clazz = null;
try {
if (type != null) {
clazz = Class.forName(type);
*/
protected void printResources(PrintWriter writer, String prefix,
javax.naming.Context namingContext,
- String type, Class clazz) {
+ String type, Class<?> clazz) {
try {
- NamingEnumeration items = namingContext.listBindings("");
+ NamingEnumeration<Binding> items = namingContext.listBindings("");
while (items.hasMore()) {
- Binding item = (Binding) items.next();
+ Binding item = items.next();
if (item.getObject() instanceof javax.naming.Context) {
printResources
(writer, prefix + item.getName() + "/",
// Enumerate the available roles
writer.println(sm.getString("managerServlet.rolesList"));
- Iterator roles = database.getRoles();
+ Iterator<Role> roles = database.getRoles();
if (roles != null) {
while (roles.hasNext()) {
- Role role = (Role) roles.next();
+ Role role = roles.next();
writer.print(role.getRolename());
writer.print(':');
if (role.getDescription() != null) {
try {
ostream.close();
} catch (Throwable t) {
- ;
+ // Ignore
}
ostream = null;
}
try {
istream.close();
} catch (Throwable t) {
- ;
+ // Ignore
}
istream = null;
}
/**
- * The debugging detail level for this servlet.
- */
- private int debug = 0;
-
-
- /**
* MBean server.
*/
protected MBeanServer mBeanServer = null;
/**
* Vector of protocol handlers object names.
*/
- protected Vector protocolHandlers = new Vector();
+ protected Vector<ObjectName> protocolHandlers = new Vector<ObjectName>();
/**
* Vector of thread pools object names.
*/
- protected Vector threadPools = new Vector();
+ protected Vector<ObjectName> threadPools = new Vector<ObjectName>();
/**
* Vector of request processors object names.
*/
- protected Vector requestProcessors = new Vector();
+ protected Vector<ObjectName> requestProcessors = new Vector<ObjectName>();
/**
* Vector of global request processors object names.
*/
- protected Vector globalRequestProcessors = new Vector();
+ protected Vector<ObjectName> globalRequestProcessors = new Vector<ObjectName>();
/**
// Retrieve the MBean server
mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
- // Set our properties from the initialization parameters
- String value = null;
- try {
- value = getServletConfig().getInitParameter("debug");
- debug = Integer.parseInt(value);
- } catch (Throwable t) {
- ;
- }
-
try {
// Query protocol handlers
String onStr = "*:type=ProtocolHandler,*";
ObjectName objectName = new ObjectName(onStr);
- Set set = mBeanServer.queryMBeans(objectName, null);
- Iterator iterator = set.iterator();
+ Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null);
+ Iterator<ObjectInstance> iterator = set.iterator();
while (iterator.hasNext()) {
- ObjectInstance oi = (ObjectInstance) iterator.next();
+ ObjectInstance oi = iterator.next();
protocolHandlers.addElement(oi.getObjectName());
}
set = mBeanServer.queryMBeans(objectName, null);
iterator = set.iterator();
while (iterator.hasNext()) {
- ObjectInstance oi = (ObjectInstance) iterator.next();
+ ObjectInstance oi = iterator.next();
threadPools.addElement(oi.getObjectName());
}
set = mBeanServer.queryMBeans(objectName, null);
iterator = set.iterator();
while (iterator.hasNext()) {
- ObjectInstance oi = (ObjectInstance) iterator.next();
+ ObjectInstance oi = iterator.next();
globalRequestProcessors.addElement(oi.getObjectName());
}
set = mBeanServer.queryMBeans(objectName, null);
iterator = set.iterator();
while (iterator.hasNext()) {
- ObjectInstance oi = (ObjectInstance) iterator.next();
+ ObjectInstance oi = iterator.next();
requestProcessors.addElement(oi.getObjectName());
}
*/
public void destroy() {
- ; // No actions necessary
+ // No actions necessary
}
// Display virtual machine statistics
StatusTransformer.writeVMState(writer,mode);
- Enumeration enumeration = threadPools.elements();
+ Enumeration<ObjectName> enumeration = threadPools.elements();
while (enumeration.hasMoreElements()) {
- ObjectName objectName = (ObjectName) enumeration.nextElement();
+ ObjectName objectName = enumeration.nextElement();
String name = objectName.getKeyProperty("name");
// use StatusTransformer to output status
StatusTransformer.writeConnectorState
boolean ok = false;
try {
String methodName = "info";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = result.getClass();
Object paramValues[] = new Object[1];
paramValues[0] = result;
/**
* Write connector state.
*/
- public static void writeConnectorState(PrintWriter writer,
- ObjectName tpName, String name,
- MBeanServer mBeanServer,
- Vector globalRequestProcessors,
- Vector requestProcessors,
- int mode)
- throws Exception {
+ public static void writeConnectorState(PrintWriter writer,
+ ObjectName tpName, String name, MBeanServer mBeanServer,
+ Vector<ObjectName> globalRequestProcessors,
+ Vector<ObjectName> requestProcessors, int mode) throws Exception {
if (mode == 0) {
writer.print("<h1>");
ObjectName grpName = null;
- Enumeration enumeration = globalRequestProcessors.elements();
+ Enumeration<ObjectName> enumeration =
+ globalRequestProcessors.elements();
while (enumeration.hasMoreElements()) {
- ObjectName objectName = (ObjectName) enumeration.nextElement();
+ ObjectName objectName = enumeration.nextElement();
if (name.equals(objectName.getKeyProperty("name"))) {
grpName = objectName;
}
enumeration = requestProcessors.elements();
while (enumeration.hasMoreElements()) {
- ObjectName objectName = (ObjectName) enumeration.nextElement();
+ ObjectName objectName = enumeration.nextElement();
if (name.equals(objectName.getKeyProperty("worker"))) {
writer.print("<tr>");
writeProcessorState(writer, objectName, mBeanServer, mode);
ObjectName grpName = null;
- Enumeration enumeration = globalRequestProcessors.elements();
+ Enumeration<ObjectName> enumeration =
+ globalRequestProcessors.elements();
while (enumeration.hasMoreElements()) {
- ObjectName objectName = (ObjectName) enumeration.nextElement();
+ ObjectName objectName = enumeration.nextElement();
if (name.equals(objectName.getKeyProperty("name"))) {
grpName = objectName;
}
writer.write("<workers>");
enumeration = requestProcessors.elements();
while (enumeration.hasMoreElements()) {
- ObjectName objectName = (ObjectName) enumeration.nextElement();
+ ObjectName objectName = enumeration.nextElement();
if (name.equals(objectName.getKeyProperty("worker"))) {
writeProcessorState(writer, objectName, mBeanServer, mode);
}
if (mode == 0){
ObjectName queryHosts = new ObjectName("*:j2eeType=WebModule,*");
- Set hostsON = mBeanServer.queryNames(queryHosts, null);
+ Set<ObjectName> hostsON = mBeanServer.queryNames(queryHosts, null);
// Navigation menu
writer.print("<h1>");
writer.print("<p>");
int count = 0;
- Iterator iterator = hostsON.iterator();
+ Iterator<ObjectName> iterator = hostsON.iterator();
while (iterator.hasNext()) {
- ObjectName contextON = (ObjectName) iterator.next();
+ ObjectName contextON = iterator.next();
String webModuleName = contextON.getKeyProperty("name");
if (webModuleName.startsWith("//")) {
webModuleName = webModuleName.substring(2);
count = 0;
iterator = hostsON.iterator();
while (iterator.hasNext()) {
- ObjectName contextON = (ObjectName) iterator.next();
+ ObjectName contextON = iterator.next();
writer.print("<a class=\"A.name\" name=\""
+ (count++) + ".0\">");
writeContext(writer, contextON, mBeanServer, mode);
ObjectName queryManager = new ObjectName
(objectName.getDomain() + ":type=Manager,path=" + contextName
+ ",host=" + hostName + ",*");
- Set managersON = mBeanServer.queryNames(queryManager, null);
+ Set<ObjectName> managersON =
+ mBeanServer.queryNames(queryManager, null);
ObjectName managerON = null;
- Iterator iterator2 = managersON.iterator();
+ Iterator<ObjectName> iterator2 = managersON.iterator();
while (iterator2.hasNext()) {
- managerON = (ObjectName) iterator2.next();
+ managerON = iterator2.next();
}
ObjectName queryJspMonitor = new ObjectName
(objectName.getDomain() + ":type=JspMonitor,WebModule=" +
webModuleName + ",*");
- Set jspMonitorONs = mBeanServer.queryNames(queryJspMonitor, null);
+ Set<ObjectName> jspMonitorONs =
+ mBeanServer.queryNames(queryJspMonitor, null);
// Special case for the root context
if (contextName.equals("/")) {
String onStr = objectName.getDomain()
+ ":j2eeType=Servlet,WebModule=" + webModuleName + ",*";
ObjectName servletObjectName = new ObjectName(onStr);
- Set set = mBeanServer.queryMBeans(servletObjectName, null);
- Iterator iterator = set.iterator();
+ Set<ObjectInstance> set =
+ mBeanServer.queryMBeans(servletObjectName, null);
+ Iterator<ObjectInstance> iterator = set.iterator();
while (iterator.hasNext()) {
- ObjectInstance oi = (ObjectInstance) iterator.next();
+ ObjectInstance oi = iterator.next();
writeWrapper(writer, oi.getObjectName(), mBeanServer, mode);
}
* Write JSP monitoring information.
*/
public static void writeJspMonitor(PrintWriter writer,
- Set jspMonitorONs,
+ Set<ObjectName> jspMonitorONs,
MBeanServer mBeanServer,
int mode)
throws Exception {
int jspCount = 0;
int jspReloadCount = 0;
- Iterator iter = jspMonitorONs.iterator();
+ Iterator<ObjectName> iter = jspMonitorONs.iterator();
while (iter.hasNext()) {
- ObjectName jspMonitorON = (ObjectName) iter.next();
+ ObjectName jspMonitorON = iter.next();
Object obj = mBeanServer.getAttribute(jspMonitorON, "jspCount");
jspCount += ((Integer) obj).intValue();
obj = mBeanServer.getAttribute(jspMonitorON, "jspReloadCount");
sortedHostNamesMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String,String> entry = iterator.next();
- String hostName = (String) entry.getKey();
+ String hostName = entry.getKey();
Host host = (Host) engine.findChild(hostName);
if (host != null ) {
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.Wrapper;
*/
public void destroy() {
- ; // No actions necessary
+ // No actions necessary
}
value = getServletConfig().getInitParameter("debug");
debug = Integer.parseInt(value);
} catch (Throwable t) {
- ;
+ // Ignore
}
}
* Comparator which permits to compare on a session's content
* @author Cédrik LIME
*/
-public abstract class BaseSessionComparator implements Comparator {
+public abstract class BaseSessionComparator<T> implements Comparator<Session> {
/**
*
super();
}
- public abstract Comparable getComparableObject(Session session);
+ public abstract Comparable<T> getComparableObject(Session session);
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public final int compare(Object o1, Object o2) {
- Comparable c1 = getComparableObject((Session)o1);
- Comparable c2 = getComparableObject((Session)o2);
- return c1==null ? (c2==null ? 0 : -1) : (c2==null ? 1 : c1.compareTo(c2));
+ public final int compare(Session s1, Session s2) {
+ Comparable<T> c1 = getComparableObject(s1);
+ Comparable<T> c2 = getComparableObject(s2);
+ return c1==null ? (c2==null ? 0 : -1) : (c2==null ? 1 : c1.compareTo((T)c2));
}
}
import java.util.Comparator;
+import org.apache.catalina.Session;
+
/**
* Comparator which reverse the sort order
* @author Cédrik LIME
*/
-public class ReverseComparator implements Comparator {
- protected Comparator comparator;
+public class ReverseComparator implements Comparator<Session> {
+ protected Comparator<Session> comparator;
/**
*
*/
- public ReverseComparator(Comparator comparator) {
+ public ReverseComparator(Comparator<Session> comparator) {
super();
this.comparator = comparator;
}
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(Object o1, Object o2) {
+ public int compare(Session o1, Session o2) {
int returnValue = comparator.compare(o1, o2);
return (- returnValue);
}
// Tapestry 3.0: Engine stored in session under "org.apache.tapestry.engine:" + config.getServletName()
// TODO: Tapestry 4+
{
- final List tapestryArray = new ArrayList();
- for (Enumeration enumeration = in_session.getAttributeNames(); enumeration.hasMoreElements();) {
- String name = (String) enumeration.nextElement();
+ final List<Object> tapestryArray = new ArrayList<Object>();
+ for (Enumeration<String> enumeration = in_session.getAttributeNames(); enumeration.hasMoreElements();) {
+ String name = enumeration.nextElement();
if (name.indexOf("tapestry") > -1 && name.indexOf("engine") > -1 && null != in_session.getAttribute(name)) {//$NON-NLS-1$ //$NON-NLS-2$
tapestryArray.add(in_session.getAttribute(name));
}
Object probableEngine = tapestryArray.get(0);
if (null != probableEngine) {
try {
- Method readMethod = probableEngine.getClass().getMethod("getLocale", null);//$NON-NLS-1$
+ Method readMethod = probableEngine.getClass().getMethod("getLocale", (Class<?>[])null);//$NON-NLS-1$
if (null != readMethod) {
// Call the property getter and return the value
- Object possibleLocale = readMethod.invoke(probableEngine, null);
+ Object possibleLocale = readMethod.invoke(probableEngine, (Object[]) null);
if (null != possibleLocale && possibleLocale instanceof Locale) {
locale = (Locale) possibleLocale;
}
// Last guess: iterate over all attributes, to find a Locale
// If there is only one, consider it to be /the/ locale
{
- final List localeArray = new ArrayList();
- for (Enumeration enumeration = in_session.getAttributeNames(); enumeration.hasMoreElements();) {
- String name = (String) enumeration.nextElement();
+ final List<Object> localeArray = new ArrayList<Object>();
+ for (Enumeration<String> enumeration = in_session.getAttributeNames(); enumeration.hasMoreElements();) {
+ String name = enumeration.nextElement();
Object obj = in_session.getAttribute(name);
if (null != obj && obj instanceof Locale) {
localeArray.add(obj);
// Last guess: iterate over all attributes, to find a java.security.Principal or javax.security.auth.Subject
// If there is only one, consider it to be /the/ user
{
- final List principalArray = new ArrayList();
- for (Enumeration enumeration = httpSession.getAttributeNames(); enumeration.hasMoreElements();) {
- String name = (String) enumeration.nextElement();
+ final List<Object> principalArray = new ArrayList<Object>();
+ for (Enumeration<String> enumeration = httpSession.getAttributeNames(); enumeration.hasMoreElements();) {
+ String name = enumeration.nextElement();
Object obj = httpSession.getAttribute(name);
if (null != obj && (obj instanceof Principal || obj instanceof Subject)) {
principalArray.add(obj);
}
- // This workaround for JDK 1.3 compatibility. For JDK 1.4+, use previous (commented) instanceof.
-// try {
-// Class subjectClass = Class.forName("javax.security.auth.Subject", true, Thread.currentThread().getContextClassLoader());
-// if (subjectClass.isInstance(obj)) {
-// principalArray.add(obj);
-// }
-// } catch (ClassNotFoundException cnfe) {
-// // This is JDK 1.3: javax.security.auth.Subject does not exist; do nothing
-// }
}
if (principalArray.size() == 1) {
user = principalArray.get(0);