Examples of WireException


Examples of org.jbpm.wire.WireException

  public Object construct(WireContext wireContext) {
    try {
      return new URL(text);
    } catch (Exception e) {
      throw new WireException("couldn't create URL for text "+text, e);
    }
  }
View Full Code Here

Examples of org.jbpm.wire.WireException

  public Class<?> getType(WireDefinition wireDefinition) {
    if (className!=null) {
      try {
        return ReflectUtil.loadClass(wireDefinition.getClassLoader(), className);
      } catch (JbpmReflectException e) {
        throw new WireException("couldn't create hibernate configuration '"+className+"': "+e.getMessage(), e.getCause());
      }
    }
    return Configuration.class;
  }
View Full Code Here

Examples of org.jbpm.wire.WireException

      return wireContext.get(contextClass);

    } else if (environmentClass!=null) {
      Environment environment = wireContext.getEnvironment();
      if (environment==null) {
        throw new WireException("no environment to search an object of type "+environmentClass.getName());
      }
      log.finest("looking up "+environmentClass.getName()+" by type in environment");
      return environment.get(environmentClass);
    }
    return null;
View Full Code Here

Examples of org.jbpm.wire.WireException

      } else {
        sessionFactory = wireContext.get(SessionFactory.class);
      }
    }
    if (sessionFactory==null) {
      throw new WireException("couldn't find hibernate-session-factory "+(factoryName!=null ? "'"+factoryName+"'" : "by type ")+"to open a hibernate-session");
    }

    // open the hibernate-session
    Session session = null;
    if (connectionName!=null) {
View Full Code Here

Examples of org.jbpm.wire.WireException

        standardTransaction = (StandardTransaction) wireContext.get(standardTransactionName);
      } else {
        standardTransaction = wireContext.get(StandardTransaction.class);
      }
      if (standardTransaction==null) {
        throw new WireException("couldn't find standard-transaction "+(standardTransactionName!=null ? "'"+standardTransactionName+"'" : "by type ")+"to enlist the hibernate transaction");
      }

      // enlist the hibernate transaction to the global transaction
      HibernateTransactionResource resource = new HibernateTransactionResource(hibernateTransaction, session);
      standardTransaction.enlistResource(resource);
View Full Code Here

Examples of org.jbpm.wire.WireException

  public Object construct(WireContext wireContext) {
    StandardTransaction standardTransaction = new StandardTransaction();
    Environment environment = wireContext.getEnvironment();
    if (environment==null) {
      throw new WireException("standard transaction requires environment");
    }
    standardTransaction.setEnvironment(environment);
    wireContext.addListener(standardTransaction);
    return standardTransaction;
  }
View Full Code Here

Examples of org.jbpm.wire.WireException

          object = Collections.synchronizedCollection((Collection) object);
        }
      }

    } catch (JbpmReflectException e) {
      throw new WireException("couldn't create '"+(name!=null ? name : className)+"': "+e.getMessage(), e.getCause());
    } catch (Exception e) {
      throw new WireException("couldn't create '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
    }
    return object;
  }
View Full Code Here

Examples of org.jbpm.wire.WireException

        }
      }
    } catch (WireException e) {
      throw e;
    } catch (Exception e) {
      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
    }
  }
View Full Code Here

Examples of org.jbpm.wire.WireException

    if (className!=null) {
      try {
        ClassLoader classLoader = wireContext.getClassLoader();
        clazz = ReflectUtil.loadClass(classLoader, className);
      } catch (Exception e) {
        throw new WireException("couldn't create object"+(name!=null ? " '"+name+"'" : "")+": "+e.getMessage(), e);
      }

      if (methodName==null) {
        // plain instantiation
        try {
          Object[] args = getArgs(wireContext, argDescriptors);
          Constructor<?> constructor = ReflectUtil.findConstructor(clazz, argDescriptors, args);
          if (constructor==null) {
            throw new WireException("couldn't find constructor "+clazz.getName()+" with args "+ArrayUtil.toString(args));
          }
          object = constructor.newInstance(args);
        } catch (WireException e) {
          throw e;
        } catch (Exception e) {
          throw new WireException("couldn't create object '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
        }
      }

    } else if (factoryObjectName!=null) {
      // referenced factory object
      object = wireContext.get(factoryObjectName, false);
      if (object==null) {
        throw new WireException("can't invoke method '"+methodName+"' on null, resulted from fetching object '"+factoryObjectName+"' from this wiring environment");
      }

    } else if (factoryDescriptor!=null) {
      // factory object descriptor
      object = wireContext.create(factoryDescriptor, false);
      if (object==null) {
        throw new WireException("created factory object is null, can't invoke method '"+methodName+"' on it");
      }
    }

    if (methodName!=null) {
      // method invocation on object or static method invocation in case object is null
      if (object!=null) {
        clazz = object.getClass();
      }
      try {
        Object[] args = ObjectDescriptor.getArgs(wireContext, argDescriptors);
        Method method = ReflectUtil.findMethod(clazz, methodName, argDescriptors, args);
        if (method==null) {
          // throw exception but first, generate decent message
          throw new WireException("method "+ReflectUtil.getSignature(methodName, argDescriptors, args)+" is not available on "+
              (object!=null ? "object "+object+" ("+clazz.getName()+")" : "class "+clazz.getName()));
        }
        if (object == null && (!Modifier.isStatic(method.getModifiers()))) {
          // A non static method is invoked on a null object
          throw new WireException("method "+ clazz.getName() + "." + ReflectUtil.getSignature(methodName, argDescriptors, args)+" is not static. It cannot be called on a null object.");
        }
        object = ReflectUtil.invoke(method, object, args);

      } catch (WireException e) {
        throw e;
      } catch (Exception e) {
        throw new WireException("couldn't invoke factory method "+methodName+": "+e.getMessage(), e);
      }
    }

    return object;
  }
View Full Code Here

Examples of org.jbpm.wire.WireException

        for(Operation operation: operations) {
          operation.apply(object, wireContext);
        }
      }
    } catch (Exception e) {
      throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
    }
  }
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.