List of usage examples for org.springframework.aop.support AopUtils isToStringMethod
public static boolean isToStringMethod(@Nullable Method method)
From source file:org.logicblaze.lingo.jms.JmsClientInterceptor.java
public Object invoke(MethodInvocation methodInvocation) throws Throwable { if (AopUtils.isToStringMethod(methodInvocation.getMethod())) { return "JMS invoker proxy for service URL [" + getServiceUrl() + "]"; }//w w w.j a v a2 s . c o m LingoInvocation invocation = (LingoInvocation) createRemoteInvocation(methodInvocation); MethodMetadata metadata = invocation.getMetadata(); replaceRemoteReferences(invocation, metadata); try { Message requestMessage = marshaller.createRequestMessage(requestor, invocation); populateHeaders(requestMessage); if (metadata.isOneWay()) { requestor.send(destination, requestMessage); return null; } else if (!isMultipleResponse(methodInvocation, metadata)) { Message response = requestor.request(destination, requestMessage, getResponseTimeout()); RemoteInvocationResult result = marshaller.extractInvocationResult(response); return recreateRemoteInvocationResult(result); } else { ResultJoinHandler handler = createResultJoinHandler(methodInvocation, metadata); requestor.request(destination, requestMessage, handler, getMultipleResponseTimeout()); RemoteInvocationResult result = handler.waitForResult(); return recreateRemoteInvocationResult(result); } } catch (JMSException e) { log.warn("Remote access error: " + methodInvocation, e); throw new RemoteAccessException("Cannot access JMS invoker remote service at [" + getServiceUrl() + "]", e); } }
From source file:org.springframework.data.gemfire.function.execution.GemfireFunctionProxyFactoryBean.java
@Override public Object invoke(MethodInvocation invocation) throws Throwable { if (AopUtils.isToStringMethod(invocation.getMethod())) { return "Gemfire function proxy for service interface [" + this.serviceInterface + "]"; }/*from w ww. j av a2 s .c o m*/ if (logger.isDebugEnabled()) { logger.debug("invoking method " + invocation.getMethod().getName()); } return invokeFunction(invocation.getMethod(), invocation.getArguments()); }
From source file:org.springmodules.xt.model.generator.factory.FactoryGeneratorInterceptor.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (this.isConstructorArg(method)) { return this.putConstructorArg(args, method); } else if (this.isPropertySetter(method)) { return this.putProperty(args, method); } else if (this.isValueSetter(method)) { return this.putValue(args, method); } else if (this.isGetter(method)) { return this.readProperty(args, method); } else if (this.isFactoryMethod(method)) { Class returnType = method.getReturnType(); if (!returnType.isAssignableFrom(this.productClass)) { throw new ReturnTypeMismatchException("Return type mismatch. Expected assignable from: " + this.productClass + ", found: " + returnType); } else {//from ww w. j a v a 2 s . co m Object product = this.make(); // Fill properties: for (Map.Entry<String, PropertyPair> entry : this.properties.entrySet()) { String propertyName = entry.getKey(); Object propertyValue = entry.getValue().getValue(); Property.AccessType propertyAccess = entry.getValue().getAccess(); if (propertyAccess.equals(Property.AccessType.FIELD)) { Field field = this.productClass.getDeclaredField(propertyName); field.setAccessible(true); field.set(product, propertyValue); } else { String methodName = new StringBuilder("set").append(StringUtils.capitalize(propertyName)) .toString(); Method methodObj = this.productClass.getMethod(methodName, propertyValue.getClass()); methodObj.invoke(product, propertyValue); } } // Return product: return product; } } else { if (AopUtils.isEqualsMethod(method)) { return this.doEquals(proxy, args[0]); } else if (AopUtils.isHashCodeMethod(method)) { return this.doHashCode(proxy); } else if (AopUtils.isToStringMethod(method)) { return this.doToString(proxy); } else { // Fail fast: throw new UnsupportedOperationException("Unsupported method called: " + method.getName()); } } }