Package org.pentaho.platform.api.engine

Examples of org.pentaho.platform.api.engine.IComponent


        if ( RuntimeContext.debug ) {
          debug( Messages.getInstance().getString(
              "RuntimeContext.DEBUG_VALIDATING_COMPONENT", actionDef.getComponentName() ) ); //$NON-NLS-1$
        }

        IComponent component = null;
        try {
          component = resolveComponent( actionDef, instanceId, processId, session );
          component.setLoggingLevel( loggingLevel );

          // allow the ActionDefinition to cache the component
          actionDef.setComponent( component );
          paramManager.setCurrentParameters( actionDef );
          /*
           * We need to catch checked and unchecked exceptions here so we can create an ActionSequeceException with
           * contextual information, including the root cause. Allowing unchecked exceptions to pass through would
           * prevent valuable feedback in the log or response.
           */
        } catch ( Throwable ex ) {
          ActionDefinition actionDefinition = new ActionDefinition( (Element) actionDef.getNode(), null );
          throw new ActionValidationException( Messages.getInstance().getErrorString(
              "RuntimeContext.ERROR_0009_COULD_NOT_CREATE_COMPONENT", actionDef.getComponentName().trim() ), ex, //$NON-NLS-1$
              session.getName(), instanceId, getActionSequence().getSequenceName(), actionDefinition.getDescription(),
              actionDefinition.getComponentName() );
        }

        int validateResult = IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK;
        try {
          validateResult = component.validate();
          /*
           * We need to catch checked and unchecked exceptions here so we can create an ActionSequeceException with
           * contextual information, including the root cause. Allowing unchecked exceptions to pass through would
           * prevent valuable feedback in the log or response.
           */
        } catch ( Throwable t ) {
          throw new ActionValidationException( Messages.getInstance().getErrorString(
              "RuntimeContext.ERROR_0035_ACTION_VALIDATION_FAILED" ), t, //$NON-NLS-1$
              session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition() );
        }

        if ( validateResult != IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK ) {
          throw new ActionValidationException( Messages.getInstance().getErrorString(
              "RuntimeContext.ERROR_0035_ACTION_VALIDATION_FAILED" ), //$NON-NLS-1$
              session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition() );
        }

        paramManager.addOutputParameters( actionDef );
        setCurrentComponent( "" ); //$NON-NLS-1$
        setCurrentActionDef( null );
View Full Code Here


    Element componentDefinition = (Element) actionDefinition.getComponentSection();
    setCurrentComponent( componentClassName );
    setCurrentActionDef( actionDefinition );

    IComponent component = null;
    Class componentClass = null;
    Object componentTmp = null;

    // Explicitly using the short name instead of the fully layed out class name
    if ( ( pluginManager != null ) && ( pluginManager.isBeanRegistered( componentAlias ) ) ) {
      if ( RuntimeContext.debug ) {
        this.debug( "Component alias " + componentAlias + " will be resolved by the plugin manager." ); //$NON-NLS-1$ //$NON-NLS-2$
      }
      componentTmp = pluginManager.getBean( componentAlias );
      if ( RuntimeContext.debug ) {
        this.debug( "Component found in a plugin, class is: " + componentTmp.getClass().getName() ); //$NON-NLS-1$
      }
    }

    if ( RuntimeContext.debug ) {
      this.debug( "Component alias " + componentAlias + " will be resolved by the platform" ); //$NON-NLS-1$ //$NON-NLS-2$
    }
    // Ok - the plugin didn't load - try the old route
    if ( componentTmp == null ) {
      componentClass = Class.forName( componentClassName );
      componentTmp = componentClass.newInstance();
    }
    if ( componentTmp instanceof IComponent ) {
      component = (IComponent) componentTmp;
    } else if ( componentTmp instanceof IAction ) {
      component = new ActionDelegate( componentTmp );
    } else {
      // Try this out...
      PojoComponent pc = new PojoComponent();
      pc.setPojo( componentTmp );
      component = pc;
    }

    component.setInstanceId( currentInstanceId );
    component.setActionName( getActionName() );
    component.setProcessId( currentProcessId );

    // This next conditional is used to allow components to use the new action sequence dom commons project. The
    // ActionFactory should return an object that wraps the action definition element to be processed by the component.
    // The component can then use the wrappers API to access the action definition rather than make explicit references
    // to the dom nodes.
    if ( component instanceof IParameterResolver ) {
      component.setActionDefinition( ActionFactory.getActionDefinition( (Element) actionDefinition.getNode(),
          new ActionSequenceParameterMgr( this, currentSession, (IParameterResolver) component ) ) );
    } else {
      component.setActionDefinition( ActionFactory.getActionDefinition( (Element) actionDefinition.getNode(),
          new ActionSequenceParameterMgr( this, currentSession ) ) );
    }

    // create a map of the top level component definition nodes and their text
    Map<String, String> componentDefinitionMap = new HashMap<String, String>();
    List elements = componentDefinition.elements();
    Element element;
    String name;
    String value;
    String customXsl = null;
    for ( int idx = 0; idx < elements.size(); idx++ ) {
      element = (Element) elements.get( idx );
      name = element.getName();
      value = element.getText();
      // see if we have a target window for the output
      if ( "target".equals( name ) ) { //$NON-NLS-1$
        setParameterTarget( value );
      } else if ( "xsl".equals( name ) ) { //$NON-NLS-1$
        customXsl = value; // setParameterXsl(value);
      }

      componentDefinitionMap.put( element.getName(), element.getText() );
    }

    if ( customXsl != null ) {
      setParameterXsl( customXsl );
    }

    component.setComponentDefinitionMap( componentDefinitionMap );
    component.setComponentDefinition( componentDefinition );
    component.setRuntimeContext( this );
    component.setSession( currentSession );
    component.setLoggingLevel( getLoggingLevel() );
    component.setMessages( getMessages() );
    return component;
  }
View Full Code Here

    }
    List auditPre = actionDefinition.getPreExecuteAuditList();
    audit( auditPre );

    // initialize the component
    IComponent component = actionDefinition.getComponent();

    if ( RuntimeContext.debug ) {
      debug( Messages.getInstance().getString(
          "RuntimeContext.DEBUG_SETTING_LOGGING", Logger.getLogLevelName( loggingLevel ) ) ); //$NON-NLS-1$
    }
    component.setLoggingLevel( loggingLevel );
    if ( RuntimeContext.debug ) {
      debug( Messages.getInstance().getString( "RuntimeContext.DEBUG_INITIALIZING_COMPONENT" ) ); //$NON-NLS-1$
    }
    boolean initResult = false;
    try {
      initResult = component.init();
      /*
       * We need to catch checked and unchecked exceptions here so we can create an ActionSequeceException with
       * contextual information, including the root cause. Allowing unchecked exceptions to pass through would
       * prevent valuable feedback in the log or response.
       */
    } catch ( Throwable t ) {
      throw new ActionInitializationException( Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED" ), t, //$NON-NLS-1$
          session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition() );
    }

    if ( !initResult ) {
      status = IRuntimeContext.RUNTIME_STATUS_INITIALIZE_FAIL;
      audit( MessageTypes.COMPONENT_EXECUTE_FAILED, MessageTypes.VALIDATION, Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED" ), 0 ); //$NON-NLS-1$
      if ( doneListener != null ) {
        doneListener.actionComplete( this );
      }
      throw new ActionInitializationException( Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED" ), //$NON-NLS-1$
          session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition() );
    }

    try {
      executeComponent( actionDefinition );
    } catch ( ActionExecutionException ex ) {
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.IComponent

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.