Package org.apache.cocoon.components.modules.input

Examples of org.apache.cocoon.components.modules.input.InputModule


    private Object getInputAttribute( String inputModuleName, String attributeName )
        throws SAXException {
        Object obj;
        ServiceSelector selector = null;
        InputModule inputModule = null;
        try {
            selector = (ServiceSelector) this.manager.lookup( InputModule.ROLE + "Selector" );
            inputModule = (InputModule) selector.select( inputModuleName );
            obj = inputModule.getAttribute( attributeName, null, this.objectModel );

        } catch ( ServiceException e ) {
            throw new SAXException( "Could not find an InputModule of the type " +
                                    inputModuleName , e );
        } catch ( ConfigurationException e ) {
View Full Code Here


        // since no new components can be declared on sitemap we could
        // very well use the 'other' one here. Anyway, since it's there...
        ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
        ComponentSelector inputSelector = (ComponentSelector)sitemapManager
            .lookup(InputModule.ROLE + "Selector");
        InputModule input = (InputModule) inputSelector.select(type);
        Object result = null;
        try {
            result = input.getAttribute(attribute, null,
                                        this.environment.getObjectModel());
        } finally {
            inputSelector.release(input);
        }
        return result;
View Full Code Here

                throw new PatternException("Cannot access input modules selector", ce);
            }
        }
       
        // Get the module
        InputModule module;
        try {
            module = (InputModule)this.selector.select(moduleName);
        } catch(ServiceException ce) {
            throw new PatternException("Cannot get InputModule named '" + moduleName +
                "' in expression '" + this.expression + "'", ce);
View Full Code Here

                    result.append(items.get(++i));
                break;

                case THREADSAFE_MODULE :
                {
                    InputModule module = (InputModule)items.get(++i);
                    String variable = (String)items.get(++i);
                   
                    try {                   
                        Object value = module.getAttribute(variable, null, ContextHelper.getObjectModel(this.context));
                       
                        if (value != null) {
                            result.append(value);
                        }

                    } catch(ConfigurationException confEx) {
                        throw new PatternException("Cannot get variable '" + variable +
                            "' in expression '" + this.expression + "'", confEx);
                    }
                }
                break;
               
                case STATEFUL_MODULE :
                {
                    InputModule module = null;
                    String moduleName = (String)items.get(++i);
                    String variableName = (String)items.get(++i);
                    try {
                        module = (InputModule)this.selector.select(moduleName);
                       
                        Object value = module.getAttribute(variableName, null, ContextHelper.getObjectModel(this.context));
                       
                        if (value != null) {
                            result.append(value);
                        }
                       
View Full Code Here

            Object[] values;
            String cname = getOutputName( tableConf, column.columnConf );

            // obtain input module and read values
            ServiceSelector inputSelector = null;
            InputModule input = null;
            try {
                inputSelector = (ServiceSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (column.mode != null && inputSelector != null && inputSelector.isSelectable(column.mode)){
                    input = (InputModule) inputSelector.select(column.mode);
                }

                if (column.isSet) {
                    if (getLogger().isDebugEnabled())
                        getLogger().debug( "Trying to set column " + cname +" from "+column.mode+" using getAttributeValues method");
                    values = input.getAttributeValues( cname, column.modeConf, objectModel );
                } else {
                    if (getLogger().isDebugEnabled())
                        getLogger().debug( "Trying to set column " + cname +" from "+column.mode+" using getAttribute method");
                    values = new Object[1];
                    values[0] = input.getAttribute( cname, column.modeConf, objectModel );
                }

                if ( values != null ) {
                    for ( int i = 0; i < values.length; i++ ) {
                        if (getLogger().isDebugEnabled())
View Full Code Here

    private InputModule getInputModule(String name)
    throws CascadingRuntimeException {
        if ( this.inputModules == null ) {
            throw new RuntimeException("ModuleHelper is not setup correctly.");
        }
        InputModule module = (InputModule) this.inputModules.get(name);
        if ( module == null ) {
            try {
                if ( this.componentManager != null ) {
                    if (this.componentInputSelector.hasComponent(name)) {
                        module = (InputModule) this.componentInputSelector.select(name);
View Full Code Here

     * exception can be obtained with <code>getCause</code>.
     */
    private Object get(int op, String name, String attr, Map objectModel, Configuration conf) throws CascadingRuntimeException {

        Object value = null;
        final InputModule input = this.getInputModule(name);

        try {

            switch (op) {
            case OP_GET:   
                value = input.getAttribute(attr, conf, objectModel);
                break;
            case OP_VALUES:
                value = input.getAttributeValues(attr, conf, objectModel);
                break;
            case OP_NAMES:
                value = input.getAttributeNames(conf, objectModel);
                break;
            }

        } catch (Exception e) {
            throw new CascadingRuntimeException("Error accessing attribute '"+attr+"' from input module '"+name+"'. "+e.getMessage(), e);
View Full Code Here

     * Obtain values from the used InputModule.
     */
    private Object[] getValues(String name) {
        Object[] values = null;
        ServiceSelector iputSelector = null;
        InputModule iput = null;
        try {
            if (this.input != null) {
                // input module is thread safe
                // thus we still have a reference to it
                values = input.getAttributeValues(name, this.inputConf, objectModel);
                if (getLogger().isDebugEnabled())
                    getLogger().debug("cached module " + this.input
                                      + " attribute " + name
                                      + " returns " + values);
            } else {
                // input was not thread safe
                // so acquire it again
                iputSelector = (ServiceSelector)this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (this.inputName != null
                    && iputSelector != null
                    && iputSelector.isSelectable(this.inputName)) {

                    iput = (InputModule) iputSelector.select(this.inputName);
                }
                if (iput != null) {
                    values = iput.getAttributeValues(name, this.inputConf, objectModel);
                }
                if (getLogger().isDebugEnabled())
                    getLogger().debug(
                        "fresh module " + iput + " attribute " + name + " returns " + values);
            }
View Full Code Here

     * Obtain values from the used InputModule.
     */
    private Object[] getValues(String name) {
        Object[] values = null;
        ComponentSelector iputSelector = null;
        InputModule iput = null;
        try {
            if (this.input != null) {
                // input module is thread safe
                // thus we still have a reference to it
                values = input.getAttributeValues(name, this.inputConf, objectModel);
                if (getLogger().isDebugEnabled())
                    getLogger().debug(
                        "cached module "
                            + this.input
                            + " attribute "
                            + name
                            + " returns "
                            + values);
            } else {
                // input was not thread safe
                // so acquire it again
                iputSelector = (ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (this.inputName != null
                    && iputSelector != null
                    && iputSelector.hasComponent(this.inputName)) {

                    iput = (InputModule) iputSelector.select(this.inputName);
                }
                if (iput != null) {
                    values = iput.getAttributeValues(name, this.inputConf, objectModel);
                }
                if (getLogger().isDebugEnabled())
                    getLogger().debug(
                        "fresh module " + iput + " attribute " + name + " returns " + values);
            }
View Full Code Here

     * Obtain values from the used InputModule.
     */
    private Object[] getValues(String name) {
        Object[] values = null;
        ServiceSelector iputSelector = null;
        InputModule iput = null;
        try {
            if (this.input != null) {
                // input module is thread safe
                // thus we still have a reference to it
                values = input.getAttributeValues(name, this.inputConf, objectModel);
                if (getLogger().isDebugEnabled())
                    getLogger().debug("cached module " + this.input
                                      + " attribute " + name
                                      + " returns " + values);
            } else {
                // input was not thread safe
                // so acquire it again
                iputSelector = (ServiceSelector)this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (this.inputName != null
                    && iputSelector != null
                    && iputSelector.isSelectable(this.inputName)) {

                    iput = (InputModule) iputSelector.select(this.inputName);
                }
                if (iput != null) {
                    values = iput.getAttributeValues(name, this.inputConf, objectModel);
                }
                if (getLogger().isDebugEnabled())
                    getLogger().debug(
                        "fresh module " + iput + " attribute " + name + " returns " + values);
            }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.modules.input.InputModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.