/** * Convenience method when no arguments are required * * @param methodName the name of the method to invoke * @return the result of the call */ public Object invokeMethod(String methodName) { return getProxyBuilder().invokeMethod(methodName, null); }
public Object invokeMethod(Object object, String methodName, Object arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt builder resolution try { if (builder.getMetaClass().respondsTo(builder, methodName).isEmpty()) { // dispatch to factories if it is not a literal method return builder.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(builder, methodName, arguments); } } catch (MissingMethodException mme2) { // chain secondary exception Throwable root = mme; while (root.getCause() != null) { root = root.getCause(); } root.initCause(mme2); // throw original throw mme; } } }
public Object invokeMethod(Object object, String methodName, Object[] arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt builder resolution try { if (builder.getMetaClass().respondsTo(builder, methodName).isEmpty()) { // dispatch to factories if it is not a literal method return builder.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(builder, methodName, arguments); } } catch (MissingMethodException mme2) { // chain secondary exception Throwable root = mme; while (root.getCause() != null) { root = root.getCause(); } root.initCause(mme2); // throw original throw mme; } } } }
/** * Switches the builder's proxyBuilder during the execution of a closure.<br> * This is useful to temporary change the building context to another builder * without the need for a contrived setup. It will also take care of restoring * the previous proxyBuilder when the execution finishes, even if an exception * was thrown from inside the closure. Additionally it will use the closure's * result as the value for the node identified by 'name'. * * @param builder the temporary builder to switch to as proxyBuilder. * @param name the node to build on the 'parent' builder. * @param closure the closure to be executed under the temporary builder. * @return a node that responds to value of name with the closure's result as its * value. * @throws RuntimeException - any exception the closure might have thrown during * execution. */ public Object withBuilder(FactoryBuilderSupport builder, String name, Closure closure) { if (name == null) { return null; } Object result = getProxyBuilder().withBuilder(builder, closure); return getProxyBuilder().invokeMethod(name, new Object[]{result}); }
/** * Switches the builder's proxyBuilder during the execution of a closure.<br> * This is useful to temporary change the building context to another builder * without the need for a contrived setup. It will also take care of restoring * the previous proxyBuilder when the execution finishes, even if an exception * was thrown from inside the closure. Additionally it will use the closure's * result as the value for the node identified by 'name' and assign any attributes * that might have been set. * * @param attributes additional properties for the node on the parent builder. * @param builder the temporary builder to switch to as proxyBuilder. * @param name the node to build on the 'parent' builder. * @param closure the closure to be executed under the temporary builder. * @return a node that responds to value of name with the closure's result as its * value. * @throws RuntimeException - any exception the closure might have thrown during * execution. */ public Object withBuilder(Map attributes, FactoryBuilderSupport builder, String name, Closure closure) { if (name == null) { return null; } Object result = getProxyBuilder().withBuilder(builder, closure); return getProxyBuilder().invokeMethod(name, new Object[]{attributes, result}); }
/** * Convenience method when no arguments are required * * @return the result of the call * @param methodName the name of the method to invoke */ public Object invokeMethod( String methodName ) { return proxyBuilder.invokeMethod( methodName, null ); }
/** * Convenience method when no arguments are required * * @param methodName the name of the method to invoke * @return the result of the call */ public Object invokeMethod(String methodName) { return getProxyBuilder().invokeMethod(methodName, null); }
/** * Convenience method when no arguments are required * * @param methodName the name of the method to invoke * @return the result of the call */ public Object invokeMethod(String methodName) { return getProxyBuilder().invokeMethod(methodName, null); }
/** * Convenience method when no arguments are required * * @param methodName the name of the method to invoke * @return the result of the call */ public Object invokeMethod(String methodName) { return getProxyBuilder().invokeMethod(methodName, null); }
public Object invokeMethod(Object object, String methodName, Object arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt builder resolution try { if (builder.getMetaClass().respondsTo(builder, methodName).isEmpty()) { // dispatch to factories if it is not a literal method return builder.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(builder, methodName, arguments); } } catch (MissingMethodException mme2) { // chain secondary exception Throwable root = mme; while (root.getCause() != null) { root = root.getCause(); } root.initCause(mme2); // throw original throw mme; } } }
public Object invokeMethod(Object object, String methodName, Object arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt factory resolution try { if (factory.getMetaClass().respondsTo(factory, methodName).isEmpty()) { // dispatch to factories if it is not a literal method return factory.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(factory, methodName, arguments); } } catch (MissingMethodException mme2) { // chain secondary exception Throwable root = mme; while (root.getCause() != null) { root = root.getCause(); } root.initCause(mme2); // throw original throw mme; } } }
public Object invokeMethod(Object object, String methodName, Object[] arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt factory resolution try { if (factory.getMetaClass().respondsTo(factory, methodName).isEmpty()) { // dispatch to factories if it is not a literal method return factory.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(factory, methodName, arguments); } } catch (MissingMethodException mme2) { // chain secondary exception Throwable root = mme; while (root.getCause() != null) { root = root.getCause(); } root.initCause(mme2); // throw original throw mme; } } } }
public Object invokeMethod(Object object, String methodName, Object[] arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt factory resolution try { if (factory.getMetaClass().respondsTo(factory, methodName).isEmpty()) { // dispatch to factories if it is not a literal method return factory.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(factory, methodName, arguments); } } catch (MissingMethodException mme2) { // chain secondary exception Throwable root = mme; while (root.getCause() != null) { root = root.getCause(); } root.initCause(mme2); // throw original throw mme; } } } }
public void make(@Nonnull FactoryBuilderSupport builder) { requireNonNull(builder, "Cannot make binding with a null builder!"); requireNonNull(source, "Unspecified value for: source"); requireNonNull(target, "Unspecified value for: target"); Map<String, Object> attributes = new LinkedHashMap<>(); if (isBlank(sourceProperty)) sourceProperty = targetProperty; if (isBlank(sourceProperty)) { throw new IllegalArgumentException("Unspecified values for: sourceProperty, targetProperty"); } if (isBlank(targetProperty)) targetProperty = sourceProperty; attributes.put("source", source); attributes.put("target", target); attributes.put("sourceProperty", sourceProperty); attributes.put("targetProperty", targetProperty); attributes.put("mutual", mutual); if (converter != null) { attributes.put("converter", makeClosure(builder, converter)); } if (validator != null) { attributes.put("validator", makeClosure(builder, validator)); } builder.invokeMethod("bind", attributes); }
public Object invokeMethod(Object object, String methodName, Object[] arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt factory resolution try { if (factory.getMetaClass().respondsTo(factory, methodName).isEmpty()) { // dispatch to fectories if it is not a literal method return factory.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(factory, methodName, arguments); } } catch (MissingMethodException mme2) { // throw original // should we chain in mme2 somehow? throw mme; } } } }
public Object invokeMethod(Object object, String methodName, Object arguments) { try { return delegate.invokeMethod(object, methodName, arguments); } catch (MissingMethodException mme) { // attempt factory resolution try { if (factory.getMetaClass().respondsTo(factory, methodName).isEmpty()) { // dispatch to fectories if it is not a literal method return factory.invokeMethod(methodName, arguments); } else { return InvokerHelper.invokeMethod(factory, methodName, arguments); } } catch (MissingMethodException mme2) { // throw original // should we chain in mme2 somehow? throw mme; } } }
/** * Switches the builder's proxyBuilder during the execution of a closure.<br> * This is useful to temporary change the building context to another builder * without the need for a contrived setup. It will also take care of restoring * the previous proxyBuilder when the execution finishes, even if an exception * was thrown from inside the closure. Additionally it will use the closure's * result as the value for the node identified by 'name'. * * @param builder the temporary builder to switch to as proxyBuilder. * @param name the node to build on the 'parent' builder. * @param closure the closure to be executed under the temporary builder. * @return a node that responds to value of name with the closure's result as its * value. * @throws RuntimeException - any exception the closure might have thrown during * execution. */ public Object withBuilder(FactoryBuilderSupport builder, String name, Closure closure) { if (name == null) { return null; } Object result = getProxyBuilder().withBuilder(builder, closure); return getProxyBuilder().invokeMethod(name, new Object[]{result}); }
/** * Switches the builder's proxyBuilder during the execution of a closure.<br> * This is useful to temporary change the building context to another builder * without the need for a contrived setup. It will also take care of restoring * the previous proxyBuilder when the execution finishes, even if an exception * was thrown from inside the closure. Additionally it will use the closure's * result as the value for the node identified by 'name'. * * @param builder the temporary builder to switch to as proxyBuilder. * @param name the node to build on the 'parent' builder. * @param closure the closure to be executed under the temporary builder. * @return a node that responds to value of name with the closure's result as its * value. * @throws RuntimeException - any exception the closure might have thrown during * execution. */ public Object withBuilder(FactoryBuilderSupport builder, String name, Closure closure) { if (name == null) { return null; } Object result = getProxyBuilder().withBuilder(builder, closure); return getProxyBuilder().invokeMethod(name, new Object[]{result}); }
/** * Switches the builder's proxyBuilder during the execution of a closure.<br> * This is useful to temporary change the building context to another builder * without the need for a contrived setup. It will also take care of restoring * the previous proxyBuilder when the execution finishes, even if an exception * was thrown from inside the closure. Additionally it will use the closure's * result as the value for the node identified by 'name' and assign any attributes * that might have been set. * * @param attributes additional properties for the node on the parent builder. * @param builder the temporary builder to switch to as proxyBuilder. * @param name the node to build on the 'parent' builder. * @param closure the closure to be executed under the temporary builder. * @return a node that responds to value of name with the closure's result as its * value. * @throws RuntimeException - any exception the closure might have thrown during * execution. */ public Object withBuilder(Map attributes, FactoryBuilderSupport builder, String name, Closure closure) { if (name == null) { return null; } Object result = getProxyBuilder().withBuilder(builder, closure); return getProxyBuilder().invokeMethod(name, new Object[]{attributes, result}); }
/** * Switches the builder's proxyBuilder during the execution of a closure.<br> * This is useful to temporary change the building context to another builder * without the need for a contrived setup. It will also take care of restoring * the previous proxyBuilder when the execution finishes, even if an exception * was thrown from inside the closure. Additionally it will use the closure's * result as the value for the node identified by 'name'. * * @param builder the temporary builder to switch to as proxyBuilder. * @param name the node to build on the 'parent' builder. * @param closure the closure to be executed under the temporary builder. * @return a node that responds to value of name with the closure's result as its * value. * @throws RuntimeException - any exception the closure might have thrown during * execution. */ public Object withBuilder(FactoryBuilderSupport builder, String name, Closure closure) { if (name == null) { return null; } Object result = getProxyBuilder().withBuilder(builder, closure); return getProxyBuilder().invokeMethod(name, new Object[]{result}); }