Examples of OutputModule


Examples of org.apache.cocoon.components.modules.output.OutputModule

            if (conn.getAutoCommit()==false)
                conn.commit();

            // obtain output mode module and rollback output
            ServiceSelector outputSelector = null;
            OutputModule output = null;
            try {
                outputSelector = (ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
                if (outputMode != null && outputSelector != null && outputSelector.isSelectable(outputMode)){
                    output = (OutputModule) outputSelector.select(outputMode);
                }
                output.commit(null, objectModel);
            } catch (Exception e) {
                if (getLogger().isWarnEnabled()) {
                    getLogger().warn("Could not select output mode "
                                     + outputMode + ":" + e.getMessage());
                }
            } finally {
                if (outputSelector != null) {
                    if (output != null)
                        outputSelector.release(output);
                    this.manager.release(outputSelector);
                }
            }

        } catch (Exception e) {
            failed = true;
            if ( conn != null ) {
                try {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug( "Rolling back transaction. Caused by " + e.getMessage() );
                        e.printStackTrace();
                    }
                    conn.rollback();
                    results = null;

                    // obtain output mode module and commit output
                    ServiceSelector outputSelector = null;
                    OutputModule output = null;
                    try {
                        outputSelector = (ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
                        if (outputMode != null && outputSelector != null && outputSelector.isSelectable(outputMode)){
                            output = (OutputModule) outputSelector.select(outputMode);
                        }
                        output.rollback( null, objectModel, e);
                    } catch (Exception e2) {
                        if (getLogger().isWarnEnabled()) {
                            getLogger().warn("Could not select output mode "
                                       + outputMode + ":" + e2.getMessage());
                        }
View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

    String source,
    Parameters parameters)
    throws Exception {

    // general setup
    OutputModule output = null;
    ServiceSelector outputSelector = null;

    // I don't like this. Have a better idea to return two values.   
    Object[] obj = this.readParameters(parameters);
    String outputName = (String) obj[0];
    boolean storeEmpty = ((Boolean) obj[1]).booleanValue();

    Configuration outputConf = null;
    if (outputName == null) {
      outputName = this.outputName;
      outputConf = this.outputConf;
    }

    Map actionMap = new HashMap();

    try {
      outputSelector =
        (ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
      if (outputName != null
        && outputSelector != null
        && outputSelector.isSelectable(outputName)) {

        output = (OutputModule) outputSelector.select(outputName);

        String[] names = parameters.getNames();

        // parameters
        for (int i = 0; i < names.length; i++) {
          String sessionParamName = names[i];
          String value = parameters.getParameter(sessionParamName);
          if (storeEmpty || (value != null && !value.equals(""))) {
            if (getLogger().isDebugEnabled()) {
              getLogger().debug(
                "Propagating value "
                  + value
                  + " to output module"
                  + sessionParamName);
            }
            output.setAttribute(
              outputConf,
              objectModel,
              sessionParamName,
              value);
            actionMap.put(sessionParamName, value);
          }
        }

        // defaults, that are not overridden
        for (Iterator i = defaults.iterator(); i.hasNext();) {
          Entry entry = (Entry) i.next();
          if (!actionMap.containsKey(entry.key)) {
            if (getLogger().isDebugEnabled()) {
              getLogger().debug(
                "Propagating default value "
                  + entry.value
                  + " to session attribute "
                  + entry.key);
            }
            output.setAttribute(
              outputConf,
              objectModel,
              entry.key,
              entry.value);
            actionMap.put(entry.key, entry.value);
          }
        }

        output.commit(outputConf, objectModel);
      }
    } catch (Exception e) {
      if (output != null) {
        output.rollback(outputConf, objectModel, e);
      }
      throw e;
    } finally {
      if (outputSelector != null) {
        if (output != null)
View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

     * @param doc a <code>Document</code> value
     */
    public void handleExtractedDocument(Document doc) {
       
        ServiceSelector outputSelector = null;
        OutputModule output = null;

        try {
            if (getLogger().isDebugEnabled())
                getLogger().debug("wrote ['"+this.instanceName+"'] to "+output+" using "+outputConf);
            outputSelector = (ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
            if (outputSelector.isSelectable(this.outputModuleName)) {
                output = (OutputModule) outputSelector.select(this.outputModuleName);
            }
            output.setAttribute(outputConf, this.objectModel, this.instanceName, new DocumentWrapper(doc));
            output.commit(outputConf, this.objectModel);
            if (getLogger().isDebugEnabled())
                getLogger().debug("wrote ['"+this.instanceName+"'] to "+output+" using "+outputConf);

        } catch (Exception e) {
            if (getLogger().isWarnEnabled())
View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

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

        try {
            if (getLogger().isDebugEnabled()) getLogger().debug("start...");
            // obtain input and output components
            inputSelector=(ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
            if (inputName != null && inputSelector != null && inputSelector.hasComponent(inputName)){
                input = (InputModule) inputSelector.select(inputName);
            }
            outputSelector=(ComponentSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
            if (outputName != null && outputSelector != null && outputSelector.hasComponent(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+"]");
                        // ------------------------------------------------------------------------
                    }
                }
                output.commit(this.outputConf,objectModel);
                if (getLogger().isDebugEnabled()) getLogger().debug("done commit");
                // done
            }

View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

    String source,
    Parameters parameters)
    throws Exception {

    // general setup
    OutputModule output = null;
    ServiceSelector outputSelector = null;

    // I don't like this. Have a better idea to return two values.   
    Object[] obj = this.readParameters(parameters);
    String outputName = (String) obj[0];
    boolean storeEmpty = ((Boolean) obj[1]).booleanValue();

    Configuration outputConf = null;
    if (outputName == null) {
      outputName = this.outputName;
      outputConf = this.outputConf;
    }

    Map actionMap = new HashMap();

    try {
      outputSelector =
        (ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
      if (outputName != null
        && outputSelector != null
        && outputSelector.isSelectable(outputName)) {

        output = (OutputModule) outputSelector.select(outputName);

        String[] names = parameters.getNames();

        // parameters
        for (int i = 0; i < names.length; i++) {
          String sessionParamName = names[i];
          String value = parameters.getParameter(sessionParamName);
          if (storeEmpty || (value != null && !value.equals(""))) {
            if (getLogger().isDebugEnabled()) {
              getLogger().debug(
                "Propagating value "
                  + value
                  + " to output module"
                  + sessionParamName);
            }
            output.setAttribute(
              outputConf,
              objectModel,
              sessionParamName,
              value);
            actionMap.put(sessionParamName, value);
          }
        }

        // defaults, that are not overridden
        for (Iterator i = defaults.iterator(); i.hasNext();) {
          Entry entry = (Entry) i.next();
          if (!actionMap.containsKey(entry.key)) {
            if (getLogger().isDebugEnabled()) {
              getLogger().debug(
                "Propagating default value "
                  + entry.value
                  + " to session attribute "
                  + entry.key);
            }
            output.setAttribute(
              outputConf,
              objectModel,
              entry.key,
              entry.value);
            actionMap.put(entry.key, entry.value);
          }
        }

        output.commit(outputConf, objectModel);
      }
    } catch (Exception e) {
      if (output != null) {
        output.rollback(outputConf, objectModel, e);
      }
      throw e;
    } finally {
      if (outputSelector != null) {
        if (output != null)
View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

    private void setOutputAttribute( String outputModuleName,
                                     String attributeName, Object value )
        throws SAXException{
        ServiceSelector selector = null;
        OutputModule outputModule = null;
        try {
            selector = (ServiceSelector) this.manager.lookup( OutputModule.ROLE + "Selector" );
            outputModule = (OutputModule) selector.select( outputModuleName );
            outputModule.setAttribute( null, this.objectModel, attributeName, value );
            outputModule.commit( null, this.objectModel );

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

Examples of org.apache.cocoon.components.modules.output.OutputModule

     * to take care of what to do with the values.
     */
    protected void setRequestAttribute(Request request, String key, Object value) {

        ComponentSelector outputSelector = null;
        OutputModule output = null;
        String outputMode = null;
        try {
            outputSelector=(ComponentSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
            outputMode = (String) request.getAttribute(ATTRIBUTE_KEY);
            if (outputMode != null && outputSelector != null && outputSelector.hasComponent(outputMode)){
                output = (OutputModule) outputSelector.select(outputMode);
            }
            output.setAttribute( null, request, key, value );
        } catch (Exception e) {
                if (getLogger().isWarnEnabled())
                    getLogger()
                        .warn( "Could not select output mode "
                               + (String) outputMode
View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

            if (conn.getAutoCommit()==false)
                conn.commit();

            // obtain output mode module and rollback output
            ComponentSelector outputSelector = null;
            OutputModule output = null;
            try {
                outputSelector=(ComponentSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
                if (outputMode != null && outputSelector != null && outputSelector.hasComponent(outputMode)){
                    output = (OutputModule) outputSelector.select(outputMode);
                }
                output.commit( null, request );
            } catch (Exception e) {
                if (getLogger().isWarnEnabled())
                    getLogger()
                        .warn( "Could not select output mode "
                               + (String) outputMode
                               + ":" + e.getMessage() );
            } finally {
                if (outputSelector != null) {
                    if (output != null)
                        outputSelector.release(output);
                    this.manager.release(outputSelector);
                }
            }

        } catch (Exception e) {
            if ( conn != null ) {
                try {
                    if (getLogger().isDebugEnabled())
                        getLogger().debug( "Rolling back transaction. Caused by " + e.getMessage() );
                    conn.rollback();
                    results = null;

                    // obtain output mode module and commit output
                    ComponentSelector outputSelector = null;
                    OutputModule output = null;
                    try {
                        outputSelector=(ComponentSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
                        if (outputMode != null && outputSelector != null && outputSelector.hasComponent(outputMode)){
                            output = (OutputModule) outputSelector.select(outputMode);
                        }
                        output.rollback( null, request, e);
                    } catch (Exception e2) {
                        if (getLogger().isWarnEnabled())
                            getLogger()
                                .warn( "Could not select output mode "
                                       + (String) outputMode
View Full Code Here

Examples of org.apache.cocoon.components.modules.output.OutputModule

    private void setOutputAttribute( String outputModuleName,
                                     String attributeName, Object value )
        throws SAXException{
        ServiceSelector selector = null;
        OutputModule outputModule = null;
        try {
            selector = (ServiceSelector) this.manager.lookup( OutputModule.ROLE + "Selector" );
            outputModule = (OutputModule) selector.select( outputModuleName );
            outputModule.setAttribute( null, this.objectModel, attributeName, value );
            outputModule.commit( null, this.objectModel );

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

Examples of org.apache.cocoon.components.modules.output.OutputModule

        // 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 outputSelector = (ComponentSelector)sitemapManager
            .lookup(OutputModule.ROLE + "Selector");
        OutputModule output = (OutputModule) outputSelector.select(type);
        try {
            output.setAttribute(null, this.environment.getObjectModel(), attribute,
                                jsobjectToObject(value));
        }
        finally {
            outputSelector.release(output);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.