configruleset.java

来自「这是STRUTS1.2。6的开发包。。这是我从芝APACHE网站下下来」· Java 代码 · 共 476 行 · 第 1/2 页

JAVA
476
字号
 */

final class AddDataSourcePropertyRule extends Rule {

    public AddDataSourcePropertyRule() {
        super();
    }

    public void begin(String namespace, String name, Attributes attributes) throws Exception {
        DataSourceConfig dsc = (DataSourceConfig) digester.peek();
        dsc.addProperty(attributes.getValue("property"),
                        attributes.getValue("value"));
    }

}


/**
 * Class that records the name and value of a configuration property to be
 * used in configuring a <code>PlugIn</code> instance when instantiated.
 */

final class PlugInSetPropertyRule extends Rule {

    public PlugInSetPropertyRule() {
        super();
    }

    public void begin(String namespace, String names, Attributes attributes) throws Exception {
        PlugInConfig plugInConfig = (PlugInConfig) digester.peek();
        plugInConfig.addProperty(attributes.getValue("property"),
                                 attributes.getValue("value"));
    }

}


/**
 * Class that sets the name of the class to use when creating action form bean
 * instances. The value is set on the object on the top of the stack, which
 * must be a <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class SetActionFormBeanClassRule extends Rule {

    public SetActionFormBeanClassRule() {
        super();
    }

    public void begin(String namespace, String name, Attributes attributes) throws Exception {
        String className = attributes.getValue("type");
        if (className != null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            mc.setActionFormBeanClass(className);
        }
    }

}


/**
 * An object creation factory which creates action form bean instances, taking
 * into account the default class name, which may have been specified on the
 * parent element and which is made available through the object on the top
 * of the stack, which must be a
 * <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class ActionFormBeanFactory extends AbstractObjectCreationFactory {

    public Object createObject(Attributes attributes) {

        // Identify the name of the class to instantiate
        String className = attributes.getValue("className");
        if (className == null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            className = mc.getActionFormBeanClass();
        }

        // Instantiate the new object and return it
        Object actionFormBean = null;
        try {
            actionFormBean =
                RequestUtils.applicationInstance(className);
        } catch (Exception e) {
            digester.getLogger().error(
                    "ActionFormBeanFactory.createObject: ", e);
        }

        return actionFormBean;
    }

}


/**
 * Class that sets the name of the class to use when creating action mapping
 * instances. The value is set on the object on the top of the stack, which
 * must be a <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class SetActionMappingClassRule extends Rule {

    public SetActionMappingClassRule() {
        super();
    }

    public void begin(String namespace, String name, Attributes attributes) throws Exception {
        String className = attributes.getValue("type");
        if (className != null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            mc.setActionMappingClass(className);
        }
    }

}


/**
 * An object creation factory which creates action mapping instances, taking
 * into account the default class name, which may have been specified on the
 * parent element and which is made available through the object on the top
 * of the stack, which must be a
 * <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class ActionMappingFactory extends AbstractObjectCreationFactory {

    public Object createObject(Attributes attributes) {

        // Identify the name of the class to instantiate
        String className = attributes.getValue("className");
        if (className == null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            className = mc.getActionMappingClass();
        }

        // Instantiate the new object and return it
        Object actionMapping = null;
        try {
            actionMapping =
                RequestUtils.applicationInstance(className);
        } catch (Exception e) {
            digester.getLogger().error(
                    "ActionMappingFactory.createObject: ", e);
        }

        return actionMapping;
    }

}


/**
 * Class that sets the name of the class to use when creating global forward
 * instances. The value is set on the object on the top of the stack, which
 * must be a <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class SetActionForwardClassRule extends Rule {

    public SetActionForwardClassRule() {
        super();
    }

    public void begin(String namespace, String name, Attributes attributes) throws Exception {
        String className = attributes.getValue("type");
        if (className != null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            mc.setActionForwardClass(className);
        }
    }

}


/**
 * An object creation factory which creates global forward instances, taking
 * into account the default class name, which may have been specified on the
 * parent element and which is made available through the object on the top
 * of the stack, which must be a
 * <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class GlobalForwardFactory extends AbstractObjectCreationFactory {

    public Object createObject(Attributes attributes) {

        // Identify the name of the class to instantiate
        String className = attributes.getValue("className");
        if (className == null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            className = mc.getActionForwardClass();
        }

        // Instantiate the new object and return it
        Object globalForward = null;
        try {
            globalForward =
                RequestUtils.applicationInstance(className);
        } catch (Exception e) {
            digester.getLogger().error(
                    "GlobalForwardFactory.createObject: ", e);
        }

        return globalForward;
    }

}


/**
 * An object creation factory which creates action forward instances, taking
 * into account the default class name, which may have been specified on the
 * parent element and which is made available through the object on the top
 * of the stack, which must be a
 * <code>org.apache.struts.config.ModuleConfig</code>.
 */
final class ActionForwardFactory extends AbstractObjectCreationFactory {

    public Object createObject(Attributes attributes) {

        // Identify the name of the class to instantiate
        String className = attributes.getValue("className");
        if (className == null) {
            ModuleConfig mc = (ModuleConfig) digester.peek(1);
            className = mc.getActionForwardClass();
        }

        // Instantiate the new object and return it
        Object actionForward = null;
        try {
            actionForward =
                RequestUtils.applicationInstance(className);
        } catch (Exception e) {
            digester.getLogger().error(
                    "ActionForwardFactory.createObject: ", e);
        }

        return actionForward;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?