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

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


            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


                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

                    String source, Parameters param ) throws Exception {

        // general setup
        String parameterName = param.getParameter("parameter-name",this.defaultParameterName);
        boolean useGetValues = param.getParameterAsBoolean("use-getValues",this.useGetValues);
        InputModule input = null;
        OutputModule output = null;
        ServiceSelector inputSelector = null;
        ServiceSelector outputSelector = null;

        try {
            if (getLogger().isDebugEnabled()) getLogger().debug("start...");
            // obtain input and output components
            inputSelector=(ServiceSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
            if (inputName != null && inputSelector != null && inputSelector.isSelectable(inputName)){
                input = (InputModule) inputSelector.select(inputName);
            }
            outputSelector=(ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
            if (outputName != null && outputSelector != null && outputSelector.isSelectable(outputName)){
                output = (OutputModule) outputSelector.select(outputName);
            }


            if (input != null  && output != null) {
                if (getLogger().isDebugEnabled()) getLogger().debug("got input and output modules");
                // do something

                if (parameterName == null) {
                    if (getLogger().isDebugEnabled()) getLogger().debug("reading all parameter values");
                    // for a test, read all parameters from input and write them to outout
                    // get names first, then (one) value per name
                    Iterator iter = input.getAttributeNames(this.inputConf,objectModel);
                    while (iter.hasNext()) {
                        parameterName = (String) iter.next();
                        Object value = input.getAttribute(parameterName, this.inputConf, objectModel);
                        output.setAttribute(this.outputConf, objectModel, parameterName, value);
                       
                        if (getLogger().isDebugEnabled())
                            getLogger().debug("["+parameterName+"] = ["+value+"]");
                    }
                        // ------------------------------------------------------------------------
                } else {

                    if (useGetValues) {
                        // get all existing values
                        Object[] value = input.getAttributeValues(parameterName, this.inputConf, objectModel);
                        output.setAttribute(this.outputConf, objectModel, parameterName, value);
                       
                        if (getLogger().isDebugEnabled())
                            for (int i=0; i<value.length; i++)
                                getLogger().debug("["+parameterName+"["+i+"]] = ["+value[i]+"]");
                        // ------------------------------------------------------------------------

                    } else {
                        // get just one parameter value
                        if (getLogger().isDebugEnabled())
                            getLogger().debug("reading parameter values for "+parameterName);
                       
                        Object value = input.getAttribute(parameterName, this.inputConf, objectModel);
                        output.setAttribute(this.outputConf, objectModel, parameterName, value);
                       
                        if (getLogger().isDebugEnabled()) getLogger().debug("["+parameterName+"] = ["+value+"]");
                        // ------------------------------------------------------------------------
                    }
View Full Code Here

            }
        } else {
            // input was not thread safe
            // so acquire it again
            ComponentSelector iputSelector = null;
            InputModule iput = null;
            try {
                // obtain input module
                iputSelector=(ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (iputSelector != null && iputSelector.hasComponent(inputName)) {
                    iput = (InputModule) iputSelector.select(inputName);
                }
                if (iput != null) {
                    result = iput.getAttribute(paramName, this.inputConf, objectModel);
                }
            } catch (Exception e) {
                if (getLogger().isWarnEnabled())
                    getLogger().warn("A problem occurred acquiring Parameter '" + paramName
                                     + "' from '" + inputName + "': " + e.getMessage());
View Full Code Here

            }
        } else {
            // input was not thread safe
            // so acquire it again
            ComponentSelector iputSelector = null;
            InputModule iput = null;
            try {
                // obtain input module
                iputSelector=(ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (iputSelector != null && iputSelector.hasComponent(inputName)) {
                    iput = (InputModule) iputSelector.select(inputName);
                }
                if (iput != null) {
                    result = iput.getAttribute(paramName, this.inputConf, objectModel);
                }
            } catch (Exception e) {
                if (getLogger().isWarnEnabled())
                    getLogger().warn("A problem occurred acquiring Parameter '" + paramName
                                     + "' from '" + inputName + "': " + e.getMessage());
View Full Code Here

            if (getLogger().isWarnEnabled())
                getLogger().warn("No input module given. FAILING");
            return null;
        }

        InputModule input = null;
        ComponentSelector inputSelector = null;
        Object result = null;

        // one could test whether the input module is ThreadSafe and
        // keep a reference for that instance. Then one would need
        // to implement Disposable in order to release it at EOL
        // That would probably speed up things a lot. Especially, since
        // matchers are invoked very often.
        // Perhaps a CachingWildcardMatcher ?

        try {
            // obtain input module
            inputSelector=(ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
            if (inputSelector != null && inputSelector.hasComponent(inputName)) {
                input = (InputModule) inputSelector.select(inputName);
            }
            if (input != null) {
                result = input.getAttribute(paramName, this.inputConf, objectModel);
            }
        } catch (Exception e) {
            if (getLogger().isWarnEnabled())
                getLogger().warn("A problem occurred acquiring Parameter '" + paramName
                                 + "' from '" + inputName + "': " + e.getMessage());
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

            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

                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

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.