if ((value == null) || (value.equals("")))
return parent;
- ArrayList repositoryLocations = new ArrayList();
- ArrayList repositoryTypes = new ArrayList();
+ ArrayList<String> repositoryLocations = new ArrayList<String>();
+ ArrayList<Integer> repositoryTypes = new ArrayList<Integer>();
int i;
StringTokenizer tokenizer = new StringTokenizer(value, ",");
}
}
- String[] locations = (String[]) repositoryLocations.toArray(new String[0]);
- Integer[] types = (Integer[]) repositoryTypes.toArray(new Integer[0]);
+ String[] locations = repositoryLocations.toArray(new String[0]);
+ Integer[] types = repositoryTypes.toArray(new Integer[0]);
ClassLoader classLoader = ClassLoaderFactory.createClassLoader
(locations, types, parent);
// Load our startup class and call its process() method
if (log.isDebugEnabled())
log.debug("Loading startup class");
- Class startupClass =
+ Class<?> startupClass =
catalinaLoader.loadClass
("org.apache.catalina.startup.Catalina");
Object startupInstance = startupClass.newInstance();
if (log.isDebugEnabled())
log.debug("Setting startup class properties");
String methodName = "setParentClassLoader";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = Class.forName("java.lang.ClassLoader");
Object paramValues[] = new Object[1];
paramValues[0] = sharedLoader;
// Call the load() method
String methodName = "load";
Object param[];
- Class paramTypes[];
+ Class<?> paramTypes[];
if (arguments==null || arguments.length==0) {
paramTypes = null;
param = null;
throws Exception {
Object param[];
- Class paramTypes[];
+ Class<?> paramTypes[];
if (arguments==null || arguments.length==0) {
paramTypes = null;
param = null;
public void setAwait(boolean await)
throws Exception {
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = Boolean.TYPE;
Object paramValues[] = new Object[1];
paramValues[0] = new Boolean(await);
public boolean getAwait()
throws Exception
{
- Class paramTypes[] = new Class[0];
+ Class<?> paramTypes[] = new Class[0];
Object paramValues[] = new Object[0];
Method method =
catalinaDaemon.getClass().getMethod("getAwait", paramTypes);
}
// Register the properties as system properties
- Enumeration enumeration = properties.propertyNames();
+ Enumeration<?> enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
String name = (String) enumeration.nextElement();
String value = properties.getProperty(name);
log.debug("Creating new class loader");
// Construct the "class path" for this class loader
- ArrayList list = new ArrayList();
+ ArrayList<URL> list = new ArrayList<URL>();
// Add unpacked directories
if (unpacked != null) {
}
// Construct the class loader itself
- URL[] array = (URL[]) list.toArray(new URL[list.size()]);
+ URL[] array = list.toArray(new URL[list.size()]);
StandardClassLoader classLoader = null;
if (parent == null)
classLoader = new StandardClassLoader(array);
log.debug("Creating new class loader");
// Construct the "class path" for this class loader
- ArrayList list = new ArrayList();
+ ArrayList<URL> list = new ArrayList<URL>();
if (locations != null && types != null && locations.length == types.length) {
for (int i = 0; i < locations.length; i++) {
}
// Construct the class loader itself
- URL[] array = (URL[]) list.toArray(new URL[list.size()]);
+ URL[] array = list.toArray(new URL[list.size()]);
if (log.isDebugEnabled())
for (int i = 0; i < array.length; i++) {
log.debug(" location " + i + " is " + array[i]);
throws ClassNotFoundException, InstantiationException,
NoSuchMethodException,IllegalAccessException,
InvocationTargetException {
- Class clazz = Class.forName(className,true,cl);
- Constructor cons = clazz.getConstructor(new Class[] {String.class});
+ Class<?> clazz = Class.forName(className,true,cl);
+ Constructor<?> cons = clazz.getConstructor(new Class[] {String.class});
return (RuleSetBase)cons.newInstance(prefix);
}
/**
* Custom mappings of login methods to authenticators
*/
- protected Map customAuthenticators;
+ protected Map<String,Authenticator> customAuthenticators;
/**
* @param customAuthenticators Custom mappings of login methods to
* authenticators
*/
- public void setCustomAuthenticators(Map customAuthenticators) {
+ public void setCustomAuthenticators(
+ Map<String,Authenticator> customAuthenticators) {
this.customAuthenticators = customAuthenticators;
}
// Process the event that has occurred
if (event.getType().equals(Lifecycle.START_EVENT)) {
start();
- } else if (event.getType().equals(StandardContext.BEFORE_START_EVENT)) {
+ } else if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) {
beforeStart();
- } else if (event.getType().equals(StandardContext.AFTER_START_EVENT)) {
+ } else if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
// Restore docBase for management tools
if (originalDocBase != null) {
String docBase = context.getDocBase();
// Instantiate and install an Authenticator of the requested class
try {
- Class authenticatorClass = Class.forName(authenticatorName);
+ Class<?> authenticatorClass = Class.forName(authenticatorName);
authenticator = (Valve) authenticatorClass.newInstance();
} catch (Throwable t) {
log.error(sm.getString(
* @version $Revision$ $Date$
*/
-public class Embedded extends StandardService implements Lifecycle {
+public class Embedded extends StandardService {
private static Log log = LogFactory.getLog(Embedded.class);
// ----------------------------------------------------------- Constructors
/**
* Custom mappings of login methods to authenticators
*/
- protected HashMap authenticators;
+ protected HashMap<String,Authenticator> authenticators;
/**
/**
* The default realm to be used by all containers associated with
- * this compoennt.
+ * this component.
*/
protected Realm realm = null;
while (true) {
int n = -1;
for (int i = 0; i < connectors.length; i++) {
- if (connectors[i].getContainer() == (Container) engine) {
+ if (connectors[i].getContainer() == engine) {
n = i;
break;
}
if (authenticators == null) {
synchronized (this) {
if (authenticators == null) {
- authenticators = new HashMap();
+ authenticators = new HashMap<String,Authenticator>();
}
}
}
InputStream input = null;
try {
jarFile = juc.getJarFile();
- Enumeration jarEntries = jarFile.entries();
+ Enumeration<JarEntry> jarEntries = jarFile.entries();
while (jarEntries.hasMoreElements()) {
- JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
+ JarEntry jarEntry = jarEntries.nextElement();
String name = jarEntry.getName();
int last = name.lastIndexOf('/');
if (last >= 0) {
/**
* The set of home directories for all defined users, keyed by username.
*/
- private Hashtable homes = new Hashtable();
+ private Hashtable<String,String> homes = new Hashtable<String,String>();
/**
*/
public String getHome(String user) {
- return ((String) homes.get(user));
+ return homes.get(user);
}
/**
* Return an enumeration of the usernames defined on this server.
*/
- public Enumeration getUsers() {
+ public Enumeration<String> getUsers() {
return (homes.keys());
if (value != null)
className = value;
}
- Class clazz = Class.forName(className);
+ Class<?> clazz = Class.forName(className);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
/**
* The set of home directories for all defined users, keyed by username.
*/
- private Hashtable homes = new Hashtable();
+ private Hashtable<String,String> homes = new Hashtable<String,String>();
/**
*/
public String getHome(String user) {
- return ((String) homes.get(user));
+ return homes.get(user);
}
/**
* Return an enumeration of the usernames defined on this server.
*/
- public Enumeration getUsers() {
+ public Enumeration<String> getUsers() {
return (homes.keys());
Iterator<String> paths = resourcePaths.iterator();
while (paths.hasNext()) {
- String path = (String) paths.next();
+ String path = paths.next();
URL url = context.getServletContext().getResource(path);
if (url == null) {
log.debug( "Null url "+ path );
resourcePath));
}
inputSource = new InputSource(stream);
- if (inputSource == null) {
- throw new IllegalArgumentException
- (sm.getString("contextConfig.tldResourcePath",
- resourcePath));
- }
tldScanStream(inputSource);
} catch (Exception e) {
throw new ServletException
// Construct the class loader we will be using
ClassLoader classLoader = null;
try {
- ArrayList packed = new ArrayList();
- ArrayList unpacked = new ArrayList();
+ ArrayList<File> packed = new ArrayList<File>();
+ ArrayList<File> unpacked = new ArrayList<File>();
unpacked.add(new File(catalinaHome, "classes"));
packed.add(new File(catalinaHome, "lib"));
if (common) {
}
classLoader =
ClassLoaderFactory.createClassLoader
- ((File[]) unpacked.toArray(new File[0]),
- (File[]) packed.toArray(new File[0]),
+ (unpacked.toArray(new File[0]),
+ packed.toArray(new File[0]),
null);
} catch (Throwable t) {
log.error("Class loader creation threw exception", t);
Thread.currentThread().setContextClassLoader(classLoader);
// Load our application class
- Class clazz = null;
+ Class<?> clazz = null;
String className = args[index++];
try {
if (log.isDebugEnabled())
if (log.isDebugEnabled())
log.debug("Identifying main() method");
String methodName = "main";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = params.getClass();
method = clazz.getMethod(methodName, paramTypes);
} catch (Throwable t) {
// Load the user database object for this host
UserDatabase database = null;
try {
- Class clazz = Class.forName(userClass);
+ Class<?> clazz = Class.forName(userClass);
database = (UserDatabase) clazz.newInstance();
database.setUserConfig(this);
} catch (Exception e) {
}
// Deploy the web application (if any) for each defined user
- Enumeration users = database.getUsers();
+ Enumeration<String> users = database.getUsers();
while (users.hasMoreElements()) {
- String user = (String) users.nextElement();
+ String user = users.nextElement();
String home = database.getHome(user);
deploy(user, home);
}
// Deploy the web application for this user
try {
- Class clazz = Class.forName(contextClass);
+ Class<?> clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
/**
* Return an enumeration of the usernames defined on this server.
*/
- public Enumeration getUsers();
+ public Enumeration<String> getUsers();
}
ClassLoader classLoader = context.getLoader().getClassLoader();
StandardWrapper wrapper = null;
- Class classClass = null;
+ Class<?> classClass = null;
Container[] children = context.findChildren();
for (int i = 0; i < children.length; i++) {
* the deployment descriptor
*/
if (classClass.isAnnotationPresent(RunAs.class)) {
- RunAs annotation = (RunAs)
- classClass.getAnnotation(RunAs.class);
+ RunAs annotation = classClass.getAnnotation(RunAs.class);
wrapper.setRunAs(annotation.value());
}
}
protected static void loadClassAnnotation(Context context, String fileString) {
ClassLoader classLoader = context.getLoader().getClassLoader();
- Class classClass = null;
+ Class<?> classClass = null;
try {
classClass = classLoader.loadClass(fileString);
// Initialize the annotations
if (classClass.isAnnotationPresent(Resource.class)) {
- Resource annotation = (Resource)
- classClass.getAnnotation(Resource.class);
+ Resource annotation = classClass.getAnnotation(Resource.class);
addResource(context, annotation);
}
/* Process Resources annotation.
* Ref JSR 250
*/
if (classClass.isAnnotationPresent(Resources.class)) {
- Resources annotation = (Resources)
- classClass.getAnnotation(Resources.class);
+ Resources annotation = classClass.getAnnotation(Resources.class);
for (int i = 0; annotation.value() != null && i < annotation.value().length; i++) {
addResource(context, annotation.value()[i]);
}
* the deployment descriptor
*/
if (classClass.isAnnotationPresent(DeclareRoles.class)) {
- DeclareRoles annotation = (DeclareRoles)
+ DeclareRoles annotation =
classClass.getAnnotation(DeclareRoles.class);
for (int i = 0; annotation.value() != null && i < annotation.value().length; i++) {
context.addSecurityRole(annotation.value()[i]);
public void begin(String namespace, String name, Attributes attributes)
throws Exception {
- Context context = (Context) digester.peek(digester.getCount() - 1);
Object top = digester.peek();
- Class paramClasses[] = new Class[1];
+ Class<?> paramClasses[] = new Class[1];
paramClasses[0] = "String".getClass();
String paramValues[] = new String[1];
paramValues[0] = digester.getPublicId();
public void end(String namespace, String name) {
if (bodyTextStack != null && !bodyTextStack.empty()) {
// what we do now is push one parameter onto the top set of parameters
- Object parameters[] = (Object[]) digester.peekParams();
- ArrayList params = (ArrayList) parameters[paramIndex];
+ ArrayList<String> parameters[] =
+ (ArrayList<String>[]) digester.peekParams();
+ ArrayList<String> params = parameters[paramIndex];
if (params == null) {
- params = new ArrayList();
+ params = new ArrayList<String>();
parameters[paramIndex] = params;
}
params.add(bodyTextStack.pop());
if (paramCount > 0) {
parameters = (Object[]) digester.popParams();
} else {
- super.end();
+ super.end(namespace, name);
}
- ArrayList multiParams = (ArrayList) parameters[multiParamIndex];
+ ArrayList<?> multiParams = (ArrayList<?>) parameters[multiParamIndex];
// Construct the parameter values array we will need
// We only do the conversion if the param value is a String and