/** * Retrieves selected attributes associated with a named object. * See the class description regarding attribute models, attribute type * names, and operational attributes. * * @return the requested attributes; never null * @param name the name of the object from which to retrieve attributes * @param attrIds the identifiers of the attributes to retrieve. null * indicates that all attributes should be retrieved; an empty array * indicates that none should be retrieved * @exception NamingException if a naming exception is encountered */ @Override protected Attributes doGetAttributes(String name, String[] attrIds) throws NamingException { return getAttributes(getEscapedJndiName(name), attrIds); }
/** * Enumerates the names bound in the named context, along with the * objects bound to them. The contents of any subcontexts are not * included. * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param strName the name of the context to list * @return an enumeration of the bindings in this context. * Each element of the enumeration is of type Binding. * @exception NamingException if a naming exception is encountered */ @Override protected List<NamingEntry> doListBindings(String strName) throws NamingException { Name name = getEscapedJndiName(strName); if (name.isEmpty()) return list(entries); Entry entry = treeLookup(name); if (entry == null) return null; return list(entry); }
/** * Retrieves the named object, following links except for the terminal * atomic component of the name. If the object bound to name is not a * link, returns the object itself. * * @param name the name of the object to look up * @return the object bound to name, not following the terminal link * (if any). * @exception NamingException if a naming exception is encountered */ public Object lookupLink(String name) throws NamingException { // Note : Links are not supported return lookup(name); }
/** * Enumerates the names bound in the named context, along with the class * names of objects bound to them. The contents of any subcontexts are * not included. * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param name the name of the context to list * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<NameClassPair> list(String name) throws NamingException { return list(getEscapedJndiName(name)); }
/** * Retrieves the named object. * * @param strName the name of the object to look up * @return the object bound to name */ @Override protected Object doLookup(String strName) { Name name; try { name = getEscapedJndiName(strName); } catch (InvalidNameException e) { log.info(sm.getString("resources.invalidName", strName), e); return null; } if (name.isEmpty()) return this; Entry entry = treeLookup(name); if (entry == null) return null; ZipEntry zipEntry = entry.getEntry(); if (zipEntry.isDirectory()) return new WARDirContext(base, entry); else return new WARResource(entry.getEntry()); }
context = new WARDirContext(); } else if (aliasLoc.isDirectory()) { context = new FileDirContext();
String name = normalize(entry); int pos = name.lastIndexOf('/'); int lastPos = 0; while ((currentPos = name.indexOf('/', lastPos)) != -1) { Name parentName = getEscapedJndiName(name.substring(0, lastPos)); Name childName = getEscapedJndiName(name.substring(0, currentPos)); String entryName = name.substring(lastPos, currentPos); Entry parent = treeLookup(parentName); Entry child = treeLookup(childName); if (child == null) { Name compositeName = getEscapedJndiName(name.substring(0, pos)); Entry parent = treeLookup(compositeName); Entry child = new Entry(entryName, entry); if (parent != null)
/** * Enumerates the names bound in the named context, along with the class * names of objects bound to them. The contents of any subcontexts are * not included. * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param name the name of the context to list * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ public NamingEnumeration list(Name name) throws NamingException { if (name.isEmpty()) return new NamingContextEnumeration(list(entries).iterator()); Entry entry = treeLookup(name); if (entry == null) throw new NamingException (MESSAGES.resourceNotFound(name.toString())); return new NamingContextEnumeration(list(entry).iterator()); }
/** * Add a resources JAR. The contents of /META-INF/resources/ will be used if * a requested resource can not be found in the main context. */ public void addResourcesJar(URL url) { try { JarURLConnection conn = (JarURLConnection) url.openConnection(); JarFile jarFile = conn.getJarFile(); ZipEntry entry = jarFile.getEntry("/"); WARDirContext warDirContext = new WARDirContext(jarFile, new WARDirContext.Entry("/", entry)); warDirContext.loadEntries(); altDirContexts.add(warDirContext); } catch (IOException ioe) { log.warn(sm.getString("resources.addResourcesJarFail", url), ioe); } }
/** * Retrieves the named object. If name is empty, returns a new instance * of this context (which represents the same naming context as this * context, but its environment may be modified independently and it may * be accessed concurrently). * * @param name the name of the object to look up * @return the object bound to name * @exception NamingException if a naming exception is encountered */ public Object lookup(Name name) throws NamingException { if (name.isEmpty()) return this; Entry entry = treeLookup(name); if (entry == null) throw new NamingException (MESSAGES.resourceNotFound(name.toString())); ZipEntry zipEntry = entry.getEntry(); if (zipEntry.isDirectory()) return new WARDirContext(base, entry); else return new WARResource(entry.getEntry()); }
String name = normalize(entry); int pos = name.lastIndexOf('/'); Entry parent = treeLookup(parentName); Entry child = treeLookup(childName); if (child == null) { Entry parent = treeLookup(compositeName); Entry child = new Entry(entryName, entry); if (parent != null)
entry = entries; else entry = treeLookup(name); if (entry == null) throw new NamingException
/** * Retrieves selected attributes associated with a named object. * See the class description regarding attribute models, attribute type * names, and operational attributes. * * @return the requested attributes; never null * @param name the name of the object from which to retrieve attributes * @param attrIds the identifiers of the attributes to retrieve. null * indicates that all attributes should be retrieved; an empty array * indicates that none should be retrieved * @exception NamingException if a naming exception is encountered */ public Attributes getAttributes(String name, String[] attrIds) throws NamingException { return getAttributes(new CompositeName(name), attrIds); }
/** * Enumerates the names bound in the named context, along with the class * names of objects bound to them. The contents of any subcontexts are * not included. * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param name the name of the context to list * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ public NamingEnumeration list(String name) throws NamingException { return list(new CompositeName(name)); }
/** * Retrieves the named object. * * @param strName the name of the object to look up * @return the object bound to name */ @Override protected Object doLookup(String strName) { Name name; try { name = getEscapedJndiName(strName); } catch (InvalidNameException e) { log.info(sm.getString("resources.invalidName", strName), e); return null; } if (name.isEmpty()) return this; Entry entry = treeLookup(name); if (entry == null) return null; ZipEntry zipEntry = entry.getEntry(); if (zipEntry.isDirectory()) return new WARDirContext(base, entry); else return new WARResource(entry.getEntry()); }
context = new WARDirContext(); } else if (aliasLoc.isDirectory()) { context = new FileDirContext();
String name = normalize(entry); int pos = name.lastIndexOf('/'); int lastPos = 0; while ((currentPos = name.indexOf('/', lastPos)) != -1) { Name parentName = getEscapedJndiName(name.substring(0, lastPos)); Name childName = getEscapedJndiName(name.substring(0, currentPos)); String entryName = name.substring(lastPos, currentPos); Entry parent = treeLookup(parentName); Entry child = treeLookup(childName); if (child == null) { Name compositeName = getEscapedJndiName(name.substring(0, pos)); Entry parent = treeLookup(compositeName); Entry child = new Entry(entryName, entry); if (parent != null)
/** * Enumerates the names bound in the named context, along with the class * names of objects bound to them. The contents of any subcontexts are * not included. * <p> * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. * * @param name the name of the context to list * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ public NamingEnumeration list(Name name) throws NamingException { if (name.isEmpty()) return new NamingContextEnumeration(list(entries).iterator()); Entry entry = treeLookup(name); if (entry == null) throw new NamingException (sm.getString("resources.notFound", name)); return new NamingContextEnumeration(list(entry).iterator()); }
/** * Add a resources JAR. The contents of /META-INF/resources/ will be used if * a requested resource can not be found in the main context. */ public void addResourcesJar(URL url) { try { JarURLConnection conn = (JarURLConnection) url.openConnection(); JarFile jarFile = conn.getJarFile(); ZipEntry entry = jarFile.getEntry("/"); WARDirContext warDirContext = new WARDirContext(jarFile, new WARDirContext.Entry("/", entry)); warDirContext.loadEntries(); altDirContexts.add(warDirContext); } catch (IOException ioe) { log.warn(sm.getString("resources.addResourcesJarFail", url), ioe); } }