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


    private Object getInputAttribute( String inputModuleName, String attributeName )
    throws  SourceException {
        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 SourceException("Could not find an InputModule of the type " +
                                      inputModuleName, e);
        } catch (ConfigurationException e) {
View Full Code Here

    }


    protected Token getNewModuleToken(String moduleName) throws PatternException {
        // Get the module
        InputModule module;
        try {
            module = (InputModule) this.manager.lookup(InputModule.ROLE + '/' + moduleName);
        } catch (ServiceException e) {
            throw new PatternException("Cannot get module named '" + moduleName +
                                       "' in expression '" + this.originalExpr + "'", e);
View Full Code Here

            Object result = levelResult.get(expr.getStringValue());
            return new Token(EXPR, result==null ? "" : result.toString());
        } else if (type == THREADSAFE_MODULE) {
            try {
                InputModule im = module.getModule();
                Object result = im.getAttribute(expr.getStringValue(), null, objectModel);
                return new Token(EXPR, result==null ? "" : result.toString());

            } catch(ConfigurationException confEx) {
                throw new PatternException("Cannot get variable '" + expr.getStringValue() +
                    "' in expression '" + this.originalExpr + "'", confEx);
            }

        } else if (type == STATEFUL_MODULE) {
            InputModule im = null;
            String moduleName = module.getStringValue();
            try {
                im = (InputModule) this.manager.lookup(InputModule.ROLE + '/' + moduleName);

                Object result = im.getAttribute(expr.getStringValue(), null, objectModel);
                return new Token(EXPR, result==null ? "" : result.toString());

            } catch(ServiceException e) {
                throw new PatternException("Cannot get module '" + moduleName +
                                           "' in expression '" + this.originalExpr + "'", e);
View Full Code Here

    public final void dispose() {
        if (this.manager != null) {
            for (Iterator i = tokens.iterator(); i.hasNext();) {
                Token token = (Token)i.next();
                if (token.hasType(THREADSAFE_MODULE)) {
                    InputModule im = token.getModule();
                    this.manager.release(im);
                }
            }
            this.tokens.clear();
            this.manager = null;
View Full Code Here

            }
        } else {
            // input was not thread safe
            // so acquire it again
            ServiceSelector iputSelector = null;
            InputModule iput = null;
            try {
                // obtain input module
                iputSelector=(ServiceSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (iputSelector != null && iputSelector.isSelectable(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
            ServiceSelector iputSelector = null;
            InputModule iput = null;
            try {
                // obtain input module
                iputSelector=(ServiceSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
                if (iputSelector != null && iputSelector.isSelectable(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;
        ServiceSelector 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=(ServiceSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
            if (inputSelector != null && inputSelector.isSelectable(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

                throw new PatternException("Cannot access input modules selector", ce);
            }
        }
       
        // Get the module
        InputModule module;
        try {
            module = (InputModule)this.selector.select(moduleName);
        } catch(ComponentException 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

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.