/** * Retrieves the named object. * * @param name the name of the object to look up * @return the object bound to name */ @Override protected Object doLookup(String name) { Object result = null; File file = file(name); if (file == null) return null; if (file.isDirectory()) { FileDirContext tempContext = new FileDirContext(env); tempContext.setDocBase(file.getPath()); tempContext.setAllowLinking(getAllowLinking()); result = tempContext; } else { result = new FileResource(file); } return result; }
/** * {@inheritDoc} */ @Override public void allocate() { super.allocate(); virtualMappings = new Hashtable<String, File>(); tagfileMappings = new Hashtable<String, File>(); // looks into any META-INF dir found in classpath entries for tld files. StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";"); while (tkn.hasMoreTokens()) { File file = new File(tkn.nextToken(), "META-INF"); if (!file.exists() || !file.isDirectory()) { continue; } scanForTlds(file); } }
/** * 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 name 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 name) throws NamingException { File file = file(name); if (file == null) return null; return list(file); }
Context ctx = tomcat.addWebapp(...); FileDirContext fdc = new FileDirContext(); fdc.setDocBase(new File("/path/to/my/classes").getAbsolutePath()); ctx.getResources().createSubcontext("/WEB-INF/classes").bind("myclasses", fdc);
/** * Retrieves the named object. * * @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(String name) throws NamingException { Object result = null; File file = file(name); if (file == null) throw new NamingException (sm.getString("resources.notFound", name)); if (file.isDirectory()) { FileDirContext tempContext = new FileDirContext(env); tempContext.setDocBase(file.getPath()); tempContext.setAllowLinking(getAllowLinking()); tempContext.setCaseSensitive(isCaseSensitive()); result = tempContext; } else { result = new FileResource(file); } return result; }
FileDirContext fileDirContext = new FileDirContext(); fileDirContext.setDocBase(new File(url.toURI()).getAbsolutePath()); try { fileDirContext.lookup("META-INF/resources/");
@Override protected List<NamingEntry> doListBindings( String name ) throws NamingException { if ( "/WEB-INF/classes".equals( name ) ) { if ( !new File( buildOutputDirectory ).exists() ) { return Collections.emptyList(); } FileDirContext fileDirContext = new FileDirContext(); fileDirContext.setDocBase( buildOutputDirectory ); NamingEntry namingEntry = new NamingEntry( "/WEB-INF/classes", fileDirContext, -1 ); return Collections.singletonList( namingEntry ); } return super.doListBindings( name ); } }
context = new WARDirContext(); } else if (aliasLoc.isDirectory()) { context = new FileDirContext(); } else { throw new IllegalArgumentException(
filesystemBased = true; FileDirContext fileDirContext = (FileDirContext)resources; fileDirContext.setCaseSensitive(isCaseSensitive()); fileDirContext.setAllowLinking(isAllowLinking());
/** * 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); }
protected File file(String arg0) { return super.file(arg0); } }
@Override protected ArrayList<NamingEntry> list(File file) { ArrayList<NamingEntry> entries = super.list(file); // adds virtual tlds for WEB-INF listing if ("WEB-INF".equals(file.getName())) { entries.addAll(getVirtualNamingEntries()); } return entries; }
@Override public Attributes getAttributes(String name) throws NamingException { // handle "virtual" tlds if (name.startsWith("/WEB-INF/") && name.endsWith(".tld")) { String tldName = name.substring(name.lastIndexOf("/") + 1); if (virtualMappings.containsKey(tldName)) { return new FileResourceAttributes(virtualMappings.get(tldName)); } } else if (name.startsWith("/META-INF/tags") && name.endsWith(".tag") || name.endsWith(".tagx")) { // already loaded tag file if (tagfileMappings.containsKey(name)) { return new FileResourceAttributes(tagfileMappings.get(name)); } // unknown tagfile, search for it in virtualClasspath StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";"); while (tkn.hasMoreTokens()) { File file = new File(tkn.nextToken(), name); if (file.exists()) { tagfileMappings.put(name, file); return new FileResourceAttributes(file); } } } return super.getAttributes(name); }
@Override public void setDocBase(String arg0) { super.setDocBase(arg0); }
((FileDirContext) resources).setAllowLinking(isAllowLinking());
/** * Retrieves the named object. * * @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(String name) throws NamingException { Object result = null; File file = file(name); if (file == null) throw new NamingException (MESSAGES.resourceNotFound(name)); if (file.isDirectory()) { FileDirContext tempContext = new FileDirContext(env); tempContext.setDocBase(file.getPath()); tempContext.setAllowLinking(getAllowLinking()); tempContext.setCaseSensitive(isCaseSensitive()); result = tempContext; } else { result = new FileResource(file); } return result; }
FileDirContext fileDirContext = new FileDirContext(); fileDirContext.setDocBase(new File(url.toURI()).getAbsolutePath()); try { fileDirContext.lookup("META-INF/resources/");
docBase = file.getCanonicalPath(); if (context instanceof SipContext) { FileDirContext fileDirContext =new FileDirContext(); fileDirContext.setDocBase(docBase); ((CatalinaSipContext) context).setResources(fileDirContext ); FileDirContext fileDirContext =new FileDirContext(); fileDirContext.setDocBase(docBase); ((CatalinaSipContext) context).setResources(fileDirContext );
context = new WARDirContext(); } else if (aliasLoc.isDirectory()) { context = new FileDirContext(); } else { throw MESSAGES.aliasNotFolder(kv[1]);