Startup event listener for a
that configures the properties
of that Context, and the associated defined servlets.
| Method from org.apache.catalina.startup.TldConfig Detail: |
public void addApplicationListener(String s) {
//if(log.isDebugEnabled())
log.debug( "Add tld listener " + s);
listeners.add(s);
}
|
public void execute() throws Exception {
long t1=System.currentTimeMillis();
File tldCache=null;
if (context instanceof StandardContext) {
File workDir= (File)
((StandardContext)context).getServletContext().getAttribute(Globals.WORK_DIR_ATTR);
//tldCache=new File( workDir, "tldCache.ser");
}
// Option to not rescan
if( ! rescan ) {
// find the cache
if( tldCache!= null && tldCache.exists()) {
// just read it...
processCache(tldCache);
return;
}
}
/*
* Acquire the list of TLD resource paths, possibly embedded in JAR
* files, to be processed
*/
Set resourcePaths = tldScanResourcePaths();
Map jarPaths = getJarPaths();
// Check to see if we can use cached listeners
if (tldCache != null && tldCache.exists()) {
long lastModified = getLastModified(resourcePaths, jarPaths);
if (lastModified < tldCache.lastModified()) {
processCache(tldCache);
return;
}
}
// Scan each accumulated resource path for TLDs to be processed
Iterator paths = resourcePaths.iterator();
while (paths.hasNext()) {
String path = (String) paths.next();
if (path.endsWith(".jar")) {
tldScanJar(path);
} else {
tldScanTld(path);
}
}
if (jarPaths != null) {
paths = jarPaths.values().iterator();
while (paths.hasNext()) {
tldScanJar((File) paths.next());
}
}
String list[] = getTldListeners();
if( tldCache!= null ) {
log.debug( "Saving tld cache: " + tldCache + " " + list.length);
try {
FileOutputStream out=new FileOutputStream(tldCache);
ObjectOutputStream oos=new ObjectOutputStream( out );
oos.writeObject( list );
oos.close();
} catch( IOException ex ) {
ex.printStackTrace();
}
}
if( log.isDebugEnabled() )
log.debug( "Adding tld listeners:" + list.length);
for( int i=0; list!=null && i< list.length; i++ ) {
context.addApplicationListener(list[i]);
}
long t2=System.currentTimeMillis();
if( context instanceof StandardContext ) {
((StandardContext)context).setTldScanTime(t2-t1);
}
}
Scan for and configure all tag library descriptors found in this
web application. |
public Context getContext() {
return context;
}
|
public String[] getTldListeners() {
String result[]=new String[listeners.size()];
listeners.toArray(result);
return result;
}
|
public boolean getTldNamespaceAware() {
return tldNamespaceAware;
}
Get the server.xml attribute's xmlNamespaceAware. |
public boolean getTldValidation() {
return tldValidation;
}
Get the server.xml attribute's xmlValidation. |
public boolean isRescan() {
return rescan;
}
|
public void setContext(Context context) {
this.context = context;
}
|
public static void setNoTldJars(String jarNames) {
// --------------------------------------------------------- Public Methods
if (jarNames != null) {
noTldJars.clear();
StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
while (tokenizer.hasMoreElements()) {
noTldJars.add(tokenizer.nextToken());
}
}
}
Sets the list of JARs that are known not to contain any TLDs. |
public void setRescan(boolean rescan) {
this.rescan = rescan;
}
|
public void setTldNamespaceAware(boolean tldNamespaceAware) {
TldConfig.tldNamespaceAware = tldNamespaceAware;
}
Set the namespace aware feature of the XML parser used when
parsing xml instances. |
public void setTldValidation(boolean tldValidation) {
TldConfig.tldValidation = tldValidation;
}
Set the validation feature of the XML parser used when
parsing xml instances. |