List of usage examples for org.apache.commons.lang3.mutable MutableObject setValue
@Override public void setValue(final T value)
From source file:org.statefulj.framework.core.actions.MethodInvocationAction.java
@SuppressWarnings("unchecked") public void execute(Object stateful, String event, Object... parms) throws RetryException { try {//from w w w .ja v a 2 s . c o m // Parse out incoming parms to pass into the method // List<Object> parmList = new ArrayList<Object>(Arrays.asList(parms)); // Remove the first Object in the parm list - it's our Return Value // MutableObject<Object> returnValue = (MutableObject<Object>) parmList.remove(0); // If there is a retry parameter object, pop it off // popOffRetryParms(parmList); // Now build the list of parameters to pass into the method // List<Object> invokeParmList = buildInvokeParameters(stateful, event, parmList); if (invokeParmList.size() < this.parameters.length) { throw new RuntimeException("Incoming parameter list is incorrect, expected " + this.parameters.length + " parameters, but have " + invokeParmList.size()); } // Call the method on the Controller // Object retVal = invoke(stateful, event, invokeParmList); // If the return value is a String prefixed with "event:", then it's an event // so forward the event to the FSM. Else, return the value as-is // if (retVal instanceof String) { Pair<String, String> pair = this.parseResponse((String) retVal); if ("event".equals(pair.getLeft())) { this.fsm.onEvent(stateful, pair.getRight(), parms); } else { returnValue.setValue(retVal); } } else { returnValue.setValue(retVal); } } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } if (e.getCause() instanceof RetryException) { throw (RetryException) e.getCause(); } } catch (TooBusyException e) { throw new RuntimeException(e); } }