Hashtable defs)
{
if (! name.endsWith(".class"))
return super.createFileResource(directory, req, name, defs);
ResourceReference rr = null;
FramedResource template = null;
// Check that at least one class is defined for all the extensions:
String exts[] = getFileExtensions(name) ;
if ( exts == null )
return null ;
for (int i = exts.length-1 ; i >= 0 ; i--) {
rr = getTemplateFor(exts[i]) ;
if ( rr != null )
break ;
}
if ( rr == null ) {
// Look for a default template:
if ((rr = loadExtension(defname)) == null)
return null ;
return super.createFileResource(directory, req, name, defs);
} else {
//this could become a servlet
Hashtable tempdefs = null;
String s_dir = "directory".intern();
String s_ide = "identifier".intern();
String s_ser = "servlet-class".intern();
String s_con = "context".intern();
String s_url = "url".intern();
if (defs != null) {
tempdefs = (Hashtable) defs.clone();
} else {
tempdefs = new Hashtable(5) ;
}
if ( tempdefs.get(s_dir) == null )
tempdefs.put(s_dir, directory) ;
if ( tempdefs.get(s_con) == null )
tempdefs.put(s_con, getContext());
try {
template = (FramedResource) rr.lock();
if (template instanceof ServletWrapper) {
if (tempdefs.get(s_ser) == null)
tempdefs.put(s_ser, name);
String id = getIndexedFileName(name);
tempdefs.put(s_ide, id) ;
String url = (String) tempdefs.get(s_url);
if ((url != null) && (url.endsWith(".class"))) {
int idx = url.lastIndexOf(".class");
tempdefs.put(s_url, url.substring(0, idx));
}
} else {
if ( tempdefs.get(s_ide) == null )
tempdefs.put(s_ide, name);
}
if (exts != null) {
// Merge with values defined by the extension:
for (int i = exts.length ; --i >= 0 ; )
mergeDefaultAttributes(template, exts[i], tempdefs) ;
}
// Create, initialize and return the new resource
try {
FramedResource cloned =
(FramedResource) template.getClone(tempdefs);
if (cloned instanceof ServletWrapper) {
ServletWrapper wrapper = (ServletWrapper) cloned;
// check the servlet class
if (! wrapper.isWrappingAServlet())