|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.clients.web.extensions.ServletLoader
public class ServletLoader
Loads servlet definitions from an XML file. The file format is a
simplified version of the format allowed for web.xml
files in Tomcat. We have kept only the <servlet> tag
and it's subtags.
Field Summary | |
---|---|
private static String |
namespace
The name of the servlets namespace. |
private static String |
schemaFileURL
The URL pointing to the servlets.xsd schema. |
private List<ServletWrapper> |
servlets
|
private Document |
validatedDom
|
Constructor Summary | |
---|---|
ServletLoader()
Create a new XML loader instance. |
Method Summary | |
---|---|
List<ServletWrapper> |
getServlets()
Get a list with all loaded servlet definitions. |
boolean |
hasValidFile()
Checks if an XML file has passed validation in the validateXmlFile(InputStream, String) method. |
protected Document |
loadDocument(InputStream xmlFile,
String filename)
Load and validate the XML file. |
void |
loadLastValidatedFile(ClassLoader classLoader,
boolean clear)
Continue loading servlet definitions from the last validated XML file. |
protected Class<? extends Servlet> |
loadServletClass(String className,
ClassLoader classLoader)
Load the servlet class. |
protected int |
loadServlets(Document dom,
ClassLoader classLoader)
Load the servlet definitions from an XML document. |
void |
loadXmlFile(InputStream xmlFile,
String filename,
ClassLoader classLoader,
boolean clear)
Load a servlet definition XML file. |
void |
validateXmlFile(InputStream xmlFile,
String filename)
Validate an XML file against the servlet definition schema. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String schemaFileURL
private static final String namespace
private Document validatedDom
private List<ServletWrapper> servlets
Constructor Detail |
---|
public ServletLoader()
Method Detail |
---|
public void loadXmlFile(InputStream xmlFile, String filename, ClassLoader classLoader, boolean clear) throws JDOMException, IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException
validateXmlFile(InputStream, String)
and loadLastValidatedFile(ClassLoader, boolean)
.
xmlFile
- An input stream to read the XML data fromfilename
- The original filename the stream is coming from, or null
if not known. This value is only used when generating error messagesclassLoader
- The classloader to use when loading classes that are
named in the XML file, or null to use the default classloader (=the same
class loader that loaded the BASE core classes)clear
- TRUE to clear all already loaded servlets before loading
the servlets in this file
JDOMException
- If validation of the XML file fails
IOException
- If there is an error reading the XML file
ClassNotFoundException
- If a servlet class named in the XML file can't
be found
NoSuchMethodException
- If a servlet class doesn't implement a
public, no-argument constructor
IllegalAccessException
- If a servlet class constructor isn't
publicvalidateXmlFile(InputStream, String)
,
loadLastValidatedFile(ClassLoader, boolean)
public void validateXmlFile(InputStream xmlFile, String filename) throws IOException, JDOMException
loadLastValidatedFile(ClassLoader, boolean)
.
xmlFile
- An input stream to read the XML data fromfilename
- The original filename the stream is coming from, or null
if not known. This value is only used when generating error messages
JDOMException
- If validation of the XML file fails
IOException
- If there is an error reading the XML filepublic void loadLastValidatedFile(ClassLoader classLoader, boolean clear) throws ClassNotFoundException, IllegalAccessException, NoSuchMethodException
validateXmlFile(InputStream, String)
has been successfully called
first.
classLoader
- The classloader to use when loading classes that are
named in the XML file, or null to use the default classloader (=the same
class loader that loaded the BASE core classes)clear
- TRUE to clear all already loaded servlets before loading
the servlets in this file
ClassNotFoundException
- If a servlet class named in the XML file can't
be found
NoSuchMethodException
- If a servlet class doesn't implement a
public, no-argument constructor
IllegalAccessException
- If a servlet class constructor isn't
publicpublic boolean hasValidFile()
validateXmlFile(InputStream, String)
method. If so,
the loadLastValidatedFile(ClassLoader, boolean)
can be called
to continue loading the servlet definitions.
Note that once the file has been loaded this flag is reset to FALSE.
public List<ServletWrapper> getServlets()
protected Document loadDocument(InputStream xmlFile, String filename) throws IOException, JDOMException
IOException
JDOMException
protected int loadServlets(Document dom, ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
protected Class<? extends Servlet> loadServletClass(String className, ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException
Servlet
interface and have a public, no-argument contstructor
className
- The name of the servlet classclassLoader
- The classloader to use, or null to use
the BASE core classloader
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |