⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delegationimpl.java

📁 一个java工作流引擎
💻 JAVA
字号:
package org.jbpm.model.definition.impl;

import org.apache.commons.logging.*;
import org.jbpm.*;
import org.jbpm.delegation.*;
import org.jbpm.model.definition.*;

public class DelegationImpl implements Delegation {

  private Long id = null;
  private DefinitionImpl definition = null;
  private String className = null;
  private String configuration = null;
  
  public DelegationImpl() {}

  public DelegationImpl(DefinitionImpl definition) {
    this.definition = definition;
  }

  public DelegationImpl(DefinitionImpl definition, String className ) {
    this.definition = definition;
    this.className = className;
  }

  public Long getId() { return id; }
  public void setId(Long id) { this.id = id; }

  public Definition getDefinition() { return definition; }
  public void setDefinition(DefinitionImpl definition) { this.definition = definition; }

  public String getClassName() { return className; }
  public void setClassName(String className) { this.className = className; }

  public String getConfiguration() { return configuration; }
  public void setConfiguration(String configuration) { this.configuration = configuration; }

  public String toString() {
    return "delegation[" + id + "|" + className + "]";  
  }

	public Object instantiate() {
    Object object = null;

    try {

			Class clazz = null;
      
      if ( definition != null ) {
        clazz = definition.loadClass( className );
      } else {
        clazz = DelegationImpl.class.getClassLoader().loadClass( className );
      }
      
			object = clazz.newInstance();
			
			if ( object instanceof Configurable ) {
			  Configurable configurable = (Configurable) object;
			  configurable.configure( configuration );
			}

		} catch (Throwable t) {
      throw new DefinitionException( "unable to instantiate delegation class '" + className + "'", t );
    }
    
		return object;
	}

  public void handleException(Throwable t) throws DelegationException {
    log.error( "exception came out of delegation '" + className + "' of definition '" + definition.getId() + "'", t );
    if ( t instanceof RuntimeException ) {
      log.error( "If you're reading this then you're probably the naugthy programmer that threw a RuntimeException out of a delegation implementation.  Tss tss tss...." ); 
    }
    throw new DelegationException( "runtime exception while executing delegation", t );
  }

	public void toXml(org.dom4j.Element element) {
    element.addAttribute( "class", className );
    if ( ( configuration != null )
         && ( ! "".equals( configuration.trim() ) ) ) {
      element.addCDATA( configuration );
    }
	}

  private static Log log = LogFactory.getLog(DelegationImpl.class);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -