/**
* Catalina context names on which writing is not allowed.
*/
- private static Hashtable readOnlyContexts = new Hashtable();
+ private static Hashtable<Object,Object> readOnlyContexts =
+ new Hashtable<Object,Object>();
/**
* Security tokens repository.
*/
- private static Hashtable securityTokens = new Hashtable();
+ private static Hashtable<Object,Object> securityTokens =
+ new Hashtable<Object,Object>();
// --------------------------------------------------------- Public Methods
/**
* Bindings name - naming context. Keyed by name.
*/
- private static Hashtable contextNameBindings = new Hashtable();
+ private static Hashtable<Object,Context> contextNameBindings =
+ new Hashtable<Object,Context>();
/**
* Bindings thread - naming context. Keyed by thread id.
*/
- private static Hashtable threadBindings = new Hashtable();
+ private static Hashtable<Thread,Context> threadBindings =
+ new Hashtable<Thread,Context>();
/**
* Bindings thread - name. Keyed by thread id.
*/
- private static Hashtable threadNameBindings = new Hashtable();
+ private static Hashtable<Thread,Object> threadNameBindings =
+ new Hashtable<Thread,Object>();
/**
* Bindings class loader - naming context. Keyed by CL id.
*/
- private static Hashtable clBindings = new Hashtable();
+ private static Hashtable<ClassLoader,Context> clBindings =
+ new Hashtable<ClassLoader,Context>();
/**
* Bindings class loader - name. Keyed by CL id.
*/
- private static Hashtable clNameBindings = new Hashtable();
+ private static Hashtable<ClassLoader,Object> clNameBindings =
+ new Hashtable<ClassLoader,Object>();
/**
* @param name Name of the context
*/
static Context getContext(Object name) {
- return (Context) contextNameBindings.get(name);
+ return contextNameBindings.get(name);
}
public static void bindThread(Object name, Object token)
throws NamingException {
if (ContextAccessController.checkSecurityToken(name, token)) {
- Context context = (Context) contextNameBindings.get(name);
+ Context context = contextNameBindings.get(name);
if (context == null)
throw new NamingException
(sm.getString("contextBindings.unknownContext", name));
*/
public static Context getThread()
throws NamingException {
- Context context =
- (Context) threadBindings.get(Thread.currentThread());
+ Context context = threadBindings.get(Thread.currentThread());
if (context == null)
throw new NamingException
(sm.getString("contextBindings.noContextBoundToThread"));
ClassLoader classLoader)
throws NamingException {
if (ContextAccessController.checkSecurityToken(name, token)) {
- Context context = (Context) contextNameBindings.get(name);
+ Context context = contextNameBindings.get(name);
if (context == null)
throw new NamingException
(sm.getString("contextBindings.unknownContext", name));
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Context context = null;
do {
- context = (Context) clBindings.get(cl);
+ context = clBindings.get(cl);
if (context != null) {
return context;
}
sb.append(getFactoryClassLocation());
sb.append(",factoryClassName=");
sb.append(getFactoryClassName());
- Enumeration refAddrs = getAll();
+ Enumeration<RefAddr> refAddrs = getAll();
while (refAddrs.hasMoreElements()) {
- RefAddr refAddr = (RefAddr) refAddrs.nextElement();
+ RefAddr refAddr = refAddrs.nextElement();
sb.append(",{type=");
sb.append(refAddr.getType());
sb.append(",content=");
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Enumeration;
+
+import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.LinkRef;
import javax.naming.CompositeName;
+import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.Referenceable;
import javax.naming.Reference;
/**
* Builds a naming context using the given environment.
*/
- public NamingContext(Hashtable env, String name)
+ public NamingContext(Hashtable<String,Object> env, String name)
throws NamingException {
- this.bindings = new HashMap();
- this.env = new Hashtable();
+ this.bindings = new HashMap<String,NamingEntry>();
+ this.env = new Hashtable<String,Object>();
// FIXME ? Could be put in the environment ?
this.name = name;
// Populating the environment hashtable
if (env != null ) {
- Enumeration envEntries = env.keys();
+ Enumeration<String> envEntries = env.keys();
while (envEntries.hasMoreElements()) {
- String entryName = (String) envEntries.nextElement();
+ String entryName = envEntries.nextElement();
addToEnvironment(entryName, env.get(entryName));
}
}
/**
* Builds a naming context using the given environment.
*/
- public NamingContext(Hashtable env, String name, HashMap bindings)
+ public NamingContext(Hashtable<String,Object> env, String name,
+ HashMap<String,NamingEntry> bindings)
throws NamingException {
this(env, name);
this.bindings = bindings;
/**
* Environment.
*/
- protected Hashtable env;
+ protected Hashtable<String,Object> env;
/**
/**
* Bindings in this Context.
*/
- protected HashMap bindings;
+ protected HashMap<String,NamingEntry> bindings;
/**
throw new NamingException
(sm.getString("namingContext.invalidName"));
- NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
+ NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(Name name)
+ public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
// Removing empty parts
while ((!name.isEmpty()) && (name.get(0).length() == 0))
return new NamingContextEnumeration(bindings.values().iterator());
}
- NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
+ NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name)
+ public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
return list(new CompositeName(name));
}
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(Name name)
+ public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
// Removing empty parts
while ((!name.isEmpty()) && (name.get(0).length() == 0))
return new NamingContextBindingsEnumeration(bindings.values().iterator(), this);
}
- NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
+ NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name)
+ public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
return listBindings(new CompositeName(name));
}
throw new NamingException
(sm.getString("namingContext.invalidName"));
- NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
+ NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
* @return the environment of this context; never null
* @exception NamingException if a naming exception is encountered
*/
- public Hashtable getEnvironment()
+ public Hashtable<?,?> getEnvironment()
throws NamingException {
return env;
}
return new NamingContext(env, this.name, bindings);
}
- NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
+ NamingEntry entry = bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
throw new NamingException
(sm.getString("namingContext.invalidName"));
- NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
+ NamingEntry entry = bindings.get(name.get(0));
if (name.size() > 1) {
if (entry == null) {
*/
public class NamingContextBindingsEnumeration
- implements NamingEnumeration {
+ implements NamingEnumeration<Binding> {
// ----------------------------------------------------------- Constructors
- public NamingContextBindingsEnumeration(Iterator entries, Context ctx) {
+ public NamingContextBindingsEnumeration(Iterator<NamingEntry> entries,
+ Context ctx) {
iterator = entries;
this.ctx = ctx;
}
/**
* Underlying enumeration.
*/
- protected Iterator iterator;
+ protected Iterator<NamingEntry> iterator;
/**
/**
* Retrieves the next element in the enumeration.
*/
- public Object next()
+ public Binding next()
throws NamingException {
return nextElementInternal();
}
}
- public Object nextElement() {
+ public Binding nextElement() {
try {
return nextElementInternal();
} catch (NamingException e) {
}
}
- private Object nextElementInternal() throws NamingException {
- NamingEntry entry = (NamingEntry) iterator.next();
+ private Binding nextElementInternal() throws NamingException {
+ NamingEntry entry = iterator.next();
// If the entry is a reference, resolve it
if (entry.type == NamingEntry.REFERENCE
*/
public class NamingContextEnumeration
- implements NamingEnumeration {
+ implements NamingEnumeration<NameClassPair> {
// ----------------------------------------------------------- Constructors
- public NamingContextEnumeration(Iterator entries) {
+ public NamingContextEnumeration(Iterator<NamingEntry> entries) {
iterator = entries;
}
/**
* Underlying enumeration.
*/
- protected Iterator iterator;
+ protected Iterator<NamingEntry> iterator;
// --------------------------------------------------------- Public Methods
/**
* Retrieves the next element in the enumeration.
*/
- public Object next()
+ public NameClassPair next()
throws NamingException {
return nextElement();
}
}
- public Object nextElement() {
- NamingEntry entry = (NamingEntry) iterator.next();
+ public NameClassPair nextElement() {
+ NamingEntry entry = iterator.next();
return new NameClassPair(entry.name, entry.value.getClass().getName());
}
sb.append(getFactoryClassLocation());
sb.append(",factoryClassName=");
sb.append(getFactoryClassName());
- Enumeration refAddrs = getAll();
+ Enumeration<RefAddr> refAddrs = getAll();
while (refAddrs.hasMoreElements()) {
- RefAddr refAddr = (RefAddr) refAddrs.nextElement();
+ RefAddr refAddr = refAddrs.nextElement();
sb.append(",{type=");
sb.append(refAddr.getType());
sb.append(",content=");
package org.apache.naming;
import java.util.Hashtable;
+
+import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
+import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
/**
* Builds a Catalina selector context using the given environment.
*/
- public SelectorContext(Hashtable env) {
+ public SelectorContext(Hashtable<String,Object> env) {
this.env = env;
}
/**
* Builds a Catalina selector context using the given environment.
*/
- public SelectorContext(Hashtable env, boolean initialContext) {
+ public SelectorContext(Hashtable<String,Object> env,
+ boolean initialContext) {
this(env);
this.initialContext = initialContext;
}
/**
* Environment.
*/
- protected Hashtable env;
+ protected Hashtable<String,Object> env;
/**
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(Name name)
+ public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
return getBoundContext().list(parseName(name));
}
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name)
+ public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
return getBoundContext().list(parseName(name));
}
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(Name name)
+ public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
return getBoundContext().listBindings(parseName(name));
}
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name)
+ public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
return getBoundContext().listBindings(parseName(name));
}
* @return the environment of this context; never null
* @exception NamingException if a naming exception is encountered
*/
- public Hashtable getEnvironment()
+ public Hashtable<?,?> getEnvironment()
throws NamingException {
return getBoundContext().getEnvironment();
}
sb.append(getFactoryClassLocation());
sb.append(",factoryClassName=");
sb.append(getFactoryClassName());
- Enumeration refAddrs = getAll();
+ Enumeration<RefAddr> refAddrs = getAll();
while (refAddrs.hasMoreElements()) {
- RefAddr refAddr = (RefAddr) refAddrs.nextElement();
+ RefAddr refAddr = refAddrs.nextElement();
sb.append(",{type=");
sb.append(refAddr.getType());
sb.append(",content=");
Object nonNullArgs[] = args;
for (int i=0; i<args.length; i++) {
if (args[i] == null) {
- if (nonNullArgs==args) nonNullArgs=(Object[])args.clone();
+ if (nonNullArgs==args) nonNullArgs = args.clone();
nonNullArgs[i] = "null";
}
}
// STATIC SUPPORT METHODS
// --------------------------------------------------------------
- private static Hashtable managers = new Hashtable();
+ private static Hashtable<String,StringManager> managers =
+ new Hashtable<String,StringManager>();
/**
* Get the StringManager for a particular package. If a manager for
*/
public synchronized static StringManager getManager(String packageName) {
- StringManager mgr = (StringManager)managers.get(packageName);
+ StringManager mgr = managers.get(packageName);
if (mgr == null) {
mgr = new StringManager(packageName);
managers.put(packageName, mgr);
* @param obj The reference object describing the Bean
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws NamingException {
if (obj instanceof ResourceRef) {
Reference ref = (Reference) obj;
String beanClassName = ref.getClassName();
- Class beanClass = null;
+ Class<?> beanClass = null;
ClassLoader tcl =
Thread.currentThread().getContextClassLoader();
if (tcl != null) {
Object bean = beanClass.newInstance();
- Enumeration e = ref.getAll();
+ Enumeration<RefAddr> e = ref.getAll();
while (e.hasMoreElements()) {
- RefAddr ra = (RefAddr) e.nextElement();
+ RefAddr ra = e.nextElement();
String propName = ra.getType();
if (propName.equals(Constants.FACTORY) ||
if (pda[i].getName().equals(propName)) {
- Class propType = pda[i].getPropertyType();
+ Class<?> propType = pda[i].getPropertyType();
if (propType.equals(String.class)) {
valueArray[0] = value;
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws Exception {
if (obj instanceof EjbRef) {
// Loading factory
ClassLoader tcl =
Thread.currentThread().getContextClassLoader();
- Class factoryClass = null;
+ Class<?> factoryClass = null;
if (tcl != null) {
try {
factoryClass = tcl.loadClass(factoryClassName);
* @exception Exception if an error occurs during object creation
*/
public Object getObjectInstance(Object refObj, Name name, Context context,
- Hashtable env) throws Exception
+ Hashtable<?,?> env) throws Exception
{
// Return null if we cannot create an object of the requested type
// exceptions.
//
// Bugzilla 31288, 33077: add support for authentication.
- return AccessController.doPrivileged( new PrivilegedAction() {
- public Object run() {
+ return AccessController.doPrivileged(new PrivilegedAction<Session>() {
+ public Session run() {
// Create the JavaMail properties we will use
Properties props = new Properties();
String password = null;
- Enumeration attrs = ref.getAll();
+ Enumeration<RefAddr> attrs = ref.getAll();
while (attrs.hasMoreElements()) {
- RefAddr attr = (RefAddr) attrs.nextElement();
+ RefAddr attr = attrs.nextElement();
if ("factory".equals(attr.getType())) {
continue;
}
continue;
}
- props.put(attr.getType(), (String) attr.getContent());
+ props.put(attr.getType(), attr.getContent());
}
Authenticator auth = null;
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws Exception {
Object beanObj = null;
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws Exception {
if (obj instanceof ResourceEnvRef) {
// Loading factory
ClassLoader tcl =
Thread.currentThread().getContextClassLoader();
- Class factoryClass = null;
+ Class<?> factoryClass = null;
if (tcl != null) {
try {
factoryClass = tcl.loadClass(factoryClassName);
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws Exception {
if (obj instanceof ResourceRef) {
// Loading factory
ClassLoader tcl =
Thread.currentThread().getContextClassLoader();
- Class factoryClass = null;
+ Class<?> factoryClass = null;
if (tcl != null) {
try {
factoryClass = tcl.loadClass(factoryClassName);
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws NamingException {
if (!(obj instanceof ResourceLinkRef))
"javax.mail.internet.MimePartDataSource";
public Object getObjectInstance(Object RefObj, Name Nm, Context Ctx,
- Hashtable Env) throws Exception
+ Hashtable<?,?> Env) throws Exception
{
final Reference Ref = (Reference)RefObj;
// so that javamail can read its default properties without
// throwing Security Exceptions
if (Ref.getClassName().equals(DataSourceClassName)) {
- return AccessController.doPrivileged( new PrivilegedAction()
+ return AccessController.doPrivileged(
+ new PrivilegedAction<MimePartDataSource>()
{
- public Object run() {
+ public MimePartDataSource run() {
// set up the smtp session that will send the message
Properties props = new Properties();
// enumeration of all refaddr
- Enumeration list = Ref.getAll();
+ Enumeration<RefAddr> list = Ref.getAll();
// current refaddr to be set
RefAddr refaddr;
// set transport to smtp
props.put("mail.transport.protocol", "smtp");
while (list.hasMoreElements()) {
- refaddr = (RefAddr)list.nextElement();
+ refaddr = list.nextElement();
// set property
- props.put(refaddr.getType(), (String)refaddr.getContent());
+ props.put(refaddr.getType(), refaddr.getContent());
}
MimeMessage message = new MimeMessage(
Session.getInstance(props));
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws Exception {
if (obj instanceof TransactionRef) {
// Loading factory
ClassLoader tcl =
Thread.currentThread().getContextClassLoader();
- Class factoryClass = null;
+ Class<?> factoryClass = null;
if (tcl != null) {
try {
factoryClass = tcl.loadClass(factoryClassName);
* Crete a new Context's instance.
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
- Hashtable environment)
+ Hashtable<?,?> environment)
throws NamingException {
if ((ContextBindings.isThreadBound()) ||
(ContextBindings.isClassLoaderBound())) {
- return new SelectorContext(environment);
+ return new SelectorContext((Hashtable<String,Object>)environment);
} else {
return null;
}
/**
* Get a new (writable) initial context.
*/
- public Context getInitialContext(Hashtable environment)
+ public Context getInitialContext(Hashtable<?,?> environment)
throws NamingException {
if (ContextBindings.isThreadBound() ||
(ContextBindings.isClassLoaderBound())) {
// Redirect the request to the bound initial context
- return new SelectorContext(environment, true);
+ return new SelectorContext(
+ (Hashtable<String,Object>)environment, true);
} else {
// If the thread is not bound, return a shared writable context
if (initialContext == null)
- initialContext = new NamingContext(environment, MAIN);
+ initialContext = new NamingContext(
+ (Hashtable<String,Object>)environment, MAIN);
return initialContext;
}
}
import java.util.Hashtable;
+import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
+import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import org.apache.naming.NameParserImpl;
import org.apache.naming.StringManager;
* Builds a base directory context.
*/
public BaseDirContext() {
- this.env = new Hashtable();
+ this.env = new Hashtable<String,Object>();
}
/**
* Builds a base directory context using the given environment.
*/
- public BaseDirContext(Hashtable env) {
+ public BaseDirContext(Hashtable<String,Object> env) {
this.env = env;
}
/**
* Environment.
*/
- protected Hashtable env;
+ protected Hashtable<String,Object> env;
/**
* Allocate resources for this directory context.
*/
public void allocate() {
- ; // No action taken by the default implementation
+ // No action taken by the default implementation
}
* Release any resources allocated for this directory context.
*/
public void release() {
- ; // No action taken by the default implementation
+ // No action taken by the default implementation
}
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(Name name)
+ public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
return list(name.toString());
}
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public abstract NamingEnumeration list(String name)
+ public abstract NamingEnumeration<NameClassPair> list(String name)
throws NamingException;
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(Name name)
+ public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
return listBindings(name.toString());
}
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public abstract NamingEnumeration listBindings(String name)
+ public abstract NamingEnumeration<Binding> listBindings(String name)
throws NamingException;
* @return the environment of this context; never null
* @exception NamingException if a naming exception is encountered
*/
- public Hashtable getEnvironment()
+ public Hashtable<String,Object> getEnvironment()
throws NamingException {
return env;
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, Attributes matchingAttributes,
- String[] attributesToReturn)
+ public NamingEnumeration<SearchResult> search(Name name,
+ Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
return search(name.toString(), matchingAttributes, attributesToReturn);
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public abstract NamingEnumeration search
+ public abstract NamingEnumeration<SearchResult> search
(String name, Attributes matchingAttributes,
String[] attributesToReturn)
throws NamingException;
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, Attributes matchingAttributes)
- throws NamingException {
+ public NamingEnumeration<SearchResult> search(Name name,
+ Attributes matchingAttributes) throws NamingException {
return search(name.toString(), matchingAttributes);
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public abstract NamingEnumeration search
+ public abstract NamingEnumeration<SearchResult> search
(String name, Attributes matchingAttributes)
throws NamingException;
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search
+ public NamingEnumeration<SearchResult> search
(Name name, String filter, SearchControls cons)
throws NamingException {
return search(name.toString(), filter, cons);
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public abstract NamingEnumeration search(String name, String filter,
- SearchControls cons)
+ public abstract NamingEnumeration<SearchResult> search(String name,
+ String filter, SearchControls cons)
throws NamingException;
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, String filterExpr,
+ public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException {
return search(name.toString(), filterExpr, filterArgs, cons);
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public abstract NamingEnumeration search
+ public abstract NamingEnumeration<SearchResult> search
(String name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.naming.NamingException;
/**
* Returns an unmodifiable Map of the header fields.
*/
- public Map getHeaderFields() {
+ public Map<String,List<String>> getHeaderFields() {
if (!connected) {
// Try to connect (silently)
if (attributes == null)
return (Collections.EMPTY_MAP);
- HashMap headerFields = new HashMap(attributes.size());
- NamingEnumeration attributeEnum = attributes.getIDs();
+ HashMap<String,List<String>> headerFields =
+ new HashMap<String,List<String>>(attributes.size());
+ NamingEnumeration<String> attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
- String attributeID = (String)attributeEnum.next();
+ String attributeID = attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null) continue;
- ArrayList attributeValueList = new ArrayList(attribute.size());
- NamingEnumeration attributeValues = attribute.getAll();
+ ArrayList<String> attributeValueList =
+ new ArrayList<String>(attribute.size());
+ NamingEnumeration<?> attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
if (attributes == null)
return (null);
- NamingEnumeration attributeEnum = attributes.getIDs();
+ NamingEnumeration<String> attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
- String attributeID = (String)attributeEnum.next();
+ String attributeID = attributeEnum.next();
if (attributeID.equalsIgnoreCase(name)) {
Attribute attribute = attributes.get(attributeID);
if (attribute == null) return null;
* List children of this collection. The names given are relative to this
* URI's path. The full uri of the children is then : path + "/" + name.
*/
- public Enumeration list()
+ public Enumeration<String> list()
throws IOException {
if (!connected) {
throw new FileNotFoundException();
}
- Vector result = new Vector();
+ Vector<String> result = new Vector<String>();
if (collection != null) {
try {
- NamingEnumeration enumeration = context.list(getURL().getFile());
+ NamingEnumeration<NameClassPair> enumeration =
+ context.list(getURL().getFile());
while (enumeration.hasMoreElements()) {
- NameClassPair ncp = (NameClassPair) enumeration.nextElement();
+ NameClassPair ncp = enumeration.nextElement();
result.addElement(ncp.getName());
}
} catch (NamingException e) {
/**
* Bindings class loader - directory context. Keyed by CL id.
*/
- private static Hashtable clBindings = new Hashtable();
+ private static Hashtable<ClassLoader,DirContext> clBindings =
+ new Hashtable<ClassLoader,DirContext>();
/**
* Bindings thread - directory context. Keyed by thread id.
*/
- private static Hashtable threadBindings = new Hashtable();
+ private static Hashtable<Thread,DirContext> threadBindings =
+ new Hashtable<Thread,DirContext>();
// ----------------------------------------------------- Instance Variables
ClassLoader currentCL = currentThread.getContextClassLoader();
// Checking CL binding
- result = (DirContext) clBindings.get(currentCL);
+ result = clBindings.get(currentCL);
if (result != null)
return result;
// Checking thread biding
- result = (DirContext) threadBindings.get(currentThread);
+ result = threadBindings.get(currentThread);
// Checking parent CL binding
currentCL = currentCL.getParent();
while (currentCL != null) {
- result = (DirContext) clBindings.get(currentCL);
+ result = clBindings.get(currentCL);
if (result != null)
return result;
currentCL = currentCL.getParent();
* Get the bound context.
*/
public static DirContext get(ClassLoader cl) {
- return (DirContext) clBindings.get(cl);
+ return clBindings.get(cl);
}
* Get the bound context.
*/
public static DirContext get(Thread thread) {
- return (DirContext) threadBindings.get(thread);
+ return threadBindings.get(thread);
}
import java.util.Date;
import java.util.Hashtable;
+import javax.naming.Binding;
import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.OperationNotSupportedException;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import org.apache.naming.NamingContextBindingsEnumeration;
import org.apache.naming.NamingContextEnumeration;
/**
* Builds a file directory context using the given environment.
*/
- public FileDirContext(Hashtable env) {
+ public FileDirContext(Hashtable<String,Object> env) {
super(env);
}
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name)
+ public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
File file = file(name);
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name)
+ public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
File file = file(name);
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes,
- String[] attributesToReturn)
+ public NamingEnumeration<SearchResult> search(String name,
+ Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
return null;
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes)
- throws NamingException {
+ public NamingEnumeration<SearchResult> search(String name,
+ Attributes matchingAttributes) throws NamingException {
return null;
}
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filter,
+ public NamingEnumeration<SearchResult> search(String name, String filter,
SearchControls cons)
throws NamingException {
return null;
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filterExpr,
- Object[] filterArgs, SearchControls cons)
+ public NamingEnumeration<SearchResult> search(String name,
+ String filterExpr, Object[] filterArgs, SearchControls cons)
throws NamingException {
return null;
}
* @param file Collection
* @return Vector containg NamingEntry objects
*/
- protected ArrayList list(File file) {
+ protected ArrayList<NamingEntry> list(File file) {
- ArrayList entries = new ArrayList();
+ ArrayList<NamingEntry> entries = new ArrayList<NamingEntry>();
if (!file.isDirectory())
return entries;
String[] names = file.list();
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import org.apache.naming.StringManager;
/**
* Builds a proxy directory context using the given environment.
*/
- public ProxyDirContext(Hashtable env, DirContext dirContext) {
+ public ProxyDirContext(Hashtable<String,String> env,
+ DirContext dirContext) {
this.env = env;
this.dirContext = dirContext;
if (dirContext instanceof BaseDirContext) {
}
}
}
- hostName = (String) env.get(HOST);
- contextName = (String) env.get(CONTEXT);
+ hostName = env.get(HOST);
+ contextName = env.get(CONTEXT);
}
/**
* Environment.
*/
- protected Hashtable env;
+ protected Hashtable<String,String> env;
/**
* @return the environment of this context; never null
* @exception NamingException if a naming exception is encountered
*/
- public Hashtable getEnvironment()
+ public Hashtable<?,?> getEnvironment()
throws NamingException {
return dirContext.getEnvironment();
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, Attributes matchingAttributes,
- String[] attributesToReturn)
+ public NamingEnumeration<SearchResult> search(Name name,
+ Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
return dirContext.search(parseName(name), matchingAttributes,
attributesToReturn);
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes,
- String[] attributesToReturn)
+ public NamingEnumeration<SearchResult> search(String name,
+ Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
return dirContext.search(parseName(name), matchingAttributes,
attributesToReturn);
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, Attributes matchingAttributes)
- throws NamingException {
+ public NamingEnumeration<SearchResult> search(Name name,
+ Attributes matchingAttributes) throws NamingException {
return dirContext.search(parseName(name), matchingAttributes);
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes)
- throws NamingException {
+ public NamingEnumeration<SearchResult> search(String name,
+ Attributes matchingAttributes) throws NamingException {
return dirContext.search(parseName(name), matchingAttributes);
}
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, String filter,
+ public NamingEnumeration<SearchResult> search(Name name, String filter,
SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filter, cons);
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filter,
+ public NamingEnumeration<SearchResult> search(String name, String filter,
SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filter, cons);
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, String filterExpr,
+ public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filterExpr, filterArgs,
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filterExpr,
- Object[] filterArgs, SearchControls cons)
+ public NamingEnumeration<SearchResult> search(String name,
+ String filterExpr, Object[] filterArgs, SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filterExpr, filterArgs,
cons);
}
entry.resource.setContent(b);
} catch (IOException e) {
- ; // Ignore
+ // Ignore
} finally {
try {
if (is != null)
is.close();
} catch (IOException e) {
- ; // Ignore
+ // Ignore
}
}
}
* @version $Revision$ $Date$
*/
-public class RecyclableNamingEnumeration
- implements NamingEnumeration {
+public class RecyclableNamingEnumeration<E>
+ implements NamingEnumeration<E> {
// ----------------------------------------------------------- Constructors
- public RecyclableNamingEnumeration(Vector entries) {
+ public RecyclableNamingEnumeration(Vector<E> entries) {
this.entries = entries;
recycle();
}
/**
* Entries.
*/
- protected Vector entries;
+ protected Vector<E> entries;
/**
* Underlying enumeration.
*/
- protected Enumeration enumeration;
+ protected Enumeration<E> enumeration;
// --------------------------------------------------------- Public Methods
/**
* Retrieves the next element in the enumeration.
*/
- public Object next()
+ public E next()
throws NamingException {
return nextElement();
}
}
- public Object nextElement() {
+ public E nextElement() {
return enumeration.nextElement();
}
try {
contentLength = Long.parseLong(value.toString());
} catch (NumberFormatException e) {
- ; // Ignore
+ // Ignore
}
}
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
try {
result = formats[i].parse(creationDateValue);
} catch (ParseException e) {
- ;
+ // Ignore
}
}
if (result != null) {
}
}
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
try {
result = formats[i].parse(creationDateValue);
} catch (ParseException e) {
- ;
+ // Ignore
}
}
if (result != null) {
}
}
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
result =
formats[i].parse(lastModifiedDateValue);
} catch (ParseException e) {
- ;
+ // Ignore
}
}
if (result != null) {
}
}
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
result =
formats[i].parse(lastModifiedDateValue);
} catch (ParseException e) {
- ;
+ // Ignore
}
}
if (result != null) {
}
}
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
try {
name = attribute.get().toString();
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
try {
result = attribute.get().toString();
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
try {
result = attribute.get().toString();
} catch (NamingException e) {
- ; // No value for the attribute
+ // No value for the attribute
}
}
}
/**
* Get all attributes.
*/
- public NamingEnumeration getAll() {
+ public NamingEnumeration<? extends Attribute> getAll() {
if (attributes == null) {
- Vector attributes = new Vector();
+ Vector<BasicAttribute> attributes = new Vector<BasicAttribute>();
Date creationDate = getCreationDate();
if (creationDate != null) {
attributes.addElement(new BasicAttribute
attributes.addElement(new BasicAttribute(ETAG, etag));
attributes.addElement(new BasicAttribute(ALTERNATE_ETAG, etag));
}
- return new RecyclableNamingEnumeration(attributes);
+ return new RecyclableNamingEnumeration<BasicAttribute>(attributes);
} else {
return attributes.getAll();
}
/**
* Get all attribute IDs.
*/
- public NamingEnumeration getIDs() {
+ public NamingEnumeration<String> getIDs() {
if (attributes == null) {
- Vector attributeIDs = new Vector();
+ Vector<String> attributeIDs = new Vector<String>();
Date creationDate = getCreationDate();
if (creationDate != null) {
attributeIDs.addElement(CREATION_DATE);
attributeIDs.addElement(ETAG);
attributeIDs.addElement(ALTERNATE_ETAG);
}
- return new RecyclableNamingEnumeration(attributeIDs);
+ return new RecyclableNamingEnumeration<String>(attributeIDs);
} else {
return attributes.getIDs();
}
/**
* Not found cache.
*/
- protected HashMap notFoundCache = new HashMap();
+ protected HashMap<String,CacheEntry> notFoundCache =
+ new HashMap<String,CacheEntry>();
/**
}
if (cacheEntry == null) {
try {
- cacheEntry = (CacheEntry) notFoundCache.get(name);
+ cacheEntry = notFoundCache.get(name);
} catch (Exception e) {
// Ignore: the reliability of this lookup is not critical
}
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import javax.naming.Binding;
import javax.naming.CompositeName;
import javax.naming.Name;
+import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.OperationNotSupportedException;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import org.apache.naming.NamingContextBindingsEnumeration;
import org.apache.naming.NamingContextEnumeration;
/**
* Builds a WAR directory context using the given environment.
*/
- public WARDirContext(Hashtable env) {
+ public WARDirContext(Hashtable<String,Object> env) {
super(env);
}
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name)
+ public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
return list(new CompositeName(name));
}
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(Name name)
+ public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
if (name.isEmpty())
return new NamingContextEnumeration(list(entries).iterator());
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name)
+ public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
return listBindings(new CompositeName(name));
}
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(Name name)
+ public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
if (name.isEmpty())
return new NamingContextBindingsEnumeration(list(entries).iterator(),
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes,
- String[] attributesToReturn)
+ public NamingEnumeration<SearchResult> search(String name,
+ Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
throw new OperationNotSupportedException();
}
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes)
- throws NamingException {
+ public NamingEnumeration<SearchResult> search(String name,
+ Attributes matchingAttributes) throws NamingException {
throw new OperationNotSupportedException();
}
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filter,
+ public NamingEnumeration<SearchResult> search(String name, String filter,
SearchControls cons)
throws NamingException {
throw new OperationNotSupportedException();
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filterExpr,
+ public NamingEnumeration<SearchResult> search(String name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException {
throw new OperationNotSupportedException();
try {
- Enumeration entryList = base.entries();
+ Enumeration<? extends ZipEntry> entryList = base.entries();
entries = new Entry("/", new ZipEntry("/"));
while (entryList.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) entryList.nextElement();
+ ZipEntry entry = entryList.nextElement();
String name = normalize(entry);
int pos = name.lastIndexOf('/');
// Check that parent entries exist and, if not, create them.
/**
* List children as objects.
*/
- protected ArrayList list(Entry entry) {
+ protected ArrayList<NamingEntry> list(Entry entry) {
- ArrayList entries = new ArrayList();
+ ArrayList<NamingEntry> entries = new ArrayList<NamingEntry>();
Entry[] children = entry.getChildren();
Arrays.sort(children);
NamingEntry namingEntry = null;
/**
* Entries structure.
*/
- protected class Entry implements Comparable {
+ protected class Entry implements Comparable<Object> {
// -------------------------------------------------------- Constructor