Ejemplo n.º 1
0
  public Object getValue(Object instance) {
    try {
      if (getter != null) {
        return getter.invoke(instance, new Object[] {});
      }

      return field.get(instance);
    } catch (Exception e) {
      // todo is it good?
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 2
0
  public void setValue(Object instance, Object newValue) {
    try {
      if (setter != null) {
        setter.invoke(instance, new Object[] {newValue});
        return;
      }

      field.set(instance, newValue);
    } catch (Exception e) {
      // todo impl is is good?
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 3
0
 private Object getBeanPropInternal(Object object, int index) throws PropertyAccessException {
   try {
     Object value = fastMethod.invoke(object, null);
     if (Array.getLength(value) <= index) {
       return null;
     }
     return Array.get(value, index);
   } catch (ClassCastException e) {
     throw new PropertyAccessException("Mismatched getter instance to event bean type");
   } catch (InvocationTargetException e) {
     throw new PropertyAccessException(e);
   }
 }
  public List<EventBean> poll(Object[] lookupValues) {
    List<EventBean> rowResult = null;
    try {
      Object invocationResult = method.invoke(null, lookupValues);
      if (invocationResult != null) {
        if (isArray) {
          int length = Array.getLength(invocationResult);
          if (length > 0) {
            rowResult = new ArrayList<EventBean>();
            for (int i = 0; i < length; i++) {
              Object value = Array.get(invocationResult, i);
              if (value == null) {
                log.warn(
                    "Expected non-null return result from method '"
                        + method.getName()
                        + "', but received null value");
                continue;
              }

              EventBean theEvent;
              if (useMapType) {
                if (!(value instanceof Map)) {
                  log.warn(
                      "Expected Map-type return result from method '"
                          + method.getName()
                          + "', but received type '"
                          + value.getClass()
                          + "'");
                  continue;
                }
                Map mapValues = (Map) value;
                theEvent = eventAdapterService.adapterForTypedMap(mapValues, eventType);
              } else {
                theEvent = eventAdapterService.adapterForBean(value);
              }

              rowResult.add(theEvent);
            }
          }
        } else {
          rowResult = new LinkedList<EventBean>();

          EventBean theEvent;
          if (useMapType) {
            if (!(invocationResult instanceof Map)) {
              log.warn(
                  "Expected Map-type return result from method '"
                      + method.getName()
                      + "', but received type '"
                      + invocationResult.getClass()
                      + "'");
            } else {
              Map mapValues = (Map) invocationResult;
              theEvent = eventAdapterService.adapterForTypedMap(mapValues, eventType);
              rowResult.add(theEvent);
            }
          } else {
            theEvent = eventAdapterService.adapterForBean(invocationResult);
            rowResult.add(theEvent);
          }
        }
      }
    } catch (InvocationTargetException ex) {
      throw new EPException(
          "Method '"
              + method.getName()
              + "' of class '"
              + method.getJavaMethod().getDeclaringClass().getName()
              + "' reported an exception: "
              + ex.getTargetException(),
          ex.getTargetException());
    }

    return rowResult;
  }
 protected void handleSignalInternal(EPDataFlowSignal signal) throws InvocationTargetException {
   fastMethod.invoke(target, new Object[] {signal});
 }