FileDocCategorySizeDatePackage
AutoRegisterServlet.javaAPI DocApache Axis 1.46060Sat Apr 22 18:57:28 BST 2006org.apache.axis.transport.http

AutoRegisterServlet

public class AutoRegisterServlet extends AxisServletBase
Servlet that autoregisters
author
Steve Loughran xdoclet tags are not active yet; keep web.xml in sync
web.servlet
name="AutoRegisterServlet" display-name="Axis Autoregister Servlet" load-on-startup="30"

Fields Summary
private static Log
log
Constructors Summary
Methods Summary
protected voidapplyAndSaveSettings()
actually update the engine and save the settings

throws
AxisFault
throws
ConfigurationException

        AxisEngine engine = getEngine();
        engine.refreshGlobalOptions();
        engine.saveConfiguration();
    
protected voidautoRegister()
register classes, log exceptions

        String[] resources=getResourcesToRegister();
        if(resources==null || resources.length==0) {
            return;
        }
        for(int i=0;i<resources.length;i++) {
            final String resource = resources[i];
            registerAndLogResource(resource);
        }
        registerAnythingElse();
        try {
            applyAndSaveSettings();
        } catch (Exception e) {
            log.error(Messages.getMessage("autoRegServletApplyAndSaveSettings00"), e);
        }
    
private org.apache.axis.deployment.wsdd.WSDDDeploymentgetDeployment()
get deployment

return
throws
AxisFault

        WSDDDeployment deployment;
        AxisEngine engine = getEngine();
        EngineConfiguration config = engine.getConfig();
        if (config instanceof WSDDEngineConfiguration) {
            deployment = ((WSDDEngineConfiguration) config).getDeployment();
        } else {
            deployment=null;
        }
        return deployment;
    
public java.lang.String[]getResourcesToRegister()
subclass this to return an array of resource names.

return
array of resource names of wsdd files, or null

        return null;
    
public voidinit()
init by registering


            
         
        log.debug(Messages.getMessage("autoRegServletInit00"));
        autoRegister();
    
protected voidlogSuccess(java.lang.String item)
handler for logging success, defaults to handing off to logging at debug level

param
item what were we loading?

        log.debug(Messages.getMessage("autoRegServletLoaded01",item));
    
public voidregisterAndLogResource(java.lang.String resource)
register a single resource; log trouble and success.

param
resource

        try {
            registerResource(resource);
            logSuccess(resource);
        } catch (Exception e) {
            log.error(Messages.getMessage("autoRegServletLoadFailed01",resource),e);
        }
    
protected voidregisterAnythingElse()
override point for subclasses to add other registration stuff

    
public voidregisterFile(java.io.File file)
register a file

param
file
throws
IOException
throws
SAXException
throws
ParserConfigurationException

        InputStream in=new BufferedInputStream(new FileInputStream(file));
        registerStream(in);
    
public voidregisterResource(java.lang.String resourcename)
register a resource

param
resourcename
throws
SAXException
throws
ParserConfigurationException
throws
IOException

        InputStream in=getServletContext().getResourceAsStream(resourcename);
        if(in==null) {
            throw new FileNotFoundException(resourcename);
        }
        registerStream(in);
    
public voidregisterStream(java.io.InputStream instream)
register an open stream, which we close afterwards

param
instream
throws
SAXException
throws
ParserConfigurationException
throws
IOException

        try {
            Document doc=XMLUtils.newDocument(instream);
            WSDDDocument wsddDoc = new WSDDDocument(doc);
            WSDDDeployment deployment;
            deployment = getDeployment();
            if(deployment!=null) {
                wsddDoc.deploy(deployment);
            }
        } finally {
            instream.close();
        }