Package org.jbpm.wire.descriptor

Source Code of org.jbpm.wire.descriptor.ClassDescriptor

package org.jbpm.wire.descriptor;

import org.jbpm.util.JbpmReflectException;
import org.jbpm.util.ReflectUtil;
import org.jbpm.wire.WireContext;
import org.jbpm.wire.WireException;

/** loads the class with the specified class name using the WireContext class loader.
*
* @see WireContext#getClassLoader()
*
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
*/
public class ClassDescriptor extends AbstractDescriptor {

  private static final long serialVersionUID = 1L;

  String text;

  /** loads the class from the class loader of the specified WireContext.
   * @throws WireException if the class could not be loaded.
   */
  public Object construct(WireContext wireContext) {
    ClassLoader classLoader = wireContext.getClassLoader();
    try {
      return ReflectUtil.loadClass(classLoader, text);
    } catch (JbpmReflectException e) {
      Throwable cause = e.getCause();
      throw new WireException("couldn't load class '"+text+"': "+cause.getMessage(), cause);
    }
  }

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

  public void setClass(Class<?> clazz) {
    if (clazz==null) {
      text = null;
    } else {
      this.text = clazz.getName();
    }
  }
}
TOP

Related Classes of org.jbpm.wire.descriptor.ClassDescriptor

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.