當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodInvocation.getMethod方法代碼示例

本文整理匯總了Java中org.aopalliance.intercept.MethodInvocation.getMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInvocation.getMethod方法的具體用法?Java MethodInvocation.getMethod怎麽用?Java MethodInvocation.getMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.aopalliance.intercept.MethodInvocation的用法示例。


在下文中一共展示了MethodInvocation.getMethod方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getName

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
private String getName(MethodInvocation mi) throws BeansException
{
    if (methodToBeanMap.get() == null)
    {
        methodToBeanMap.set(new HashMap<Method, String>());
    }
    Method method = mi.getMethod();
    String name = methodToBeanMap.get().get(method);
    if (name == null)
    {
        name = getBeanNameImpl(mi);
        methodToBeanMap.get().put(method, name);
    }
    else
    {
        if (s_logger.isDebugEnabled())
        {
            s_logger.debug("Cached look up for " + name + "." + method.getName());
        }
    }
    return name;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:BeanIdentifierImpl.java

示例2: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    //
    Method m = invocation.getMethod();

    if (m.isAnnotationPresent(Conditioned.class)) {
        Object[] arg = invocation.getArguments();
        if (arg.length > 0 && arg[arg.length - 1] instanceof List && !((List) arg[arg.length - 1]).isEmpty() && ((List) arg[arg.length - 1]).get(0) instanceof GherkinStepCondition) {
            List<GherkinStepCondition> conditions = (List) arg[arg.length - 1];
            displayMessageAtTheBeginningOfMethod(m.getName(), conditions);
            if (!checkConditions(conditions)) {
                Context.getCurrentScenario().write(Messages.getMessage(SKIPPED_DUE_TO_CONDITIONS));
                return Void.TYPE;
            }
        }
    }

    logger.debug("NORAUI ConditionedInterceptor invoke method {}", invocation.getMethod());
    return invocation.proceed();
}
 
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:24,代碼來源:ConditionedInterceptor.java

示例3: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
	Method method = invocation.getMethod();

	Invoker aopAllianceInvoker = new Invoker() {
		@Override
		public Object invoke() {
			try {
				return invocation.proceed();
			} catch (Throwable ex) {
				throw new ThrowableWrapper(ex);
			}
		}
	};

	try {
		return execute(aopAllianceInvoker, invocation.getThis(), method, invocation.getArguments());
	} catch (ThrowableWrapper th) {
		throw th.original;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:CacheInterceptor.java

示例4: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
/**
 * 後續加上緩存,一定要加
 *
 * @param inv
 * @return dummy
 * @throws Throwable
 */
@Override
public Object invoke(MethodInvocation inv) throws Throwable {
    if (ReflectionUtils.isObjectMethod(inv.getMethod())) {
        if ("toString".equals(inv.getMethod().getName())) {
            return clazz.getName();
        }
        return ReflectionUtils.invokeMethod(inv.getMethod(), inv.getThis(), inv.getArguments());
    }
    WxApiMethodInfo wxApiMethodInfo = methodCache.get(inv.getMethod());
    if (wxApiMethodInfo == null) {
        wxApiMethodInfo = new WxApiMethodInfo(inv.getMethod(), wxApiTypeInfo);
        methodCache.put(inv.getMethod(), wxApiMethodInfo);
    }
    return wxApiExecutor.execute(wxApiMethodInfo, inv.getArguments());
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:23,代碼來源:WxInvokerProxyFactoryBean.java

示例5: getRequestHeader

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
/**
 * Retrieve the RequestHeader set in the invoked method.
 *
 * @param invocation Invoked method
 * @return RequestHeader
 */
RequestHeader getRequestHeader(MethodInvocation invocation) {
  Method method = invocation.getMethod();
  if (!isServiceMethod(method)) {
    throw new IllegalArgumentException("Invoked method is not a service method: " + method.getName());
  }

  if (invocation.getArguments()[0] == null) {
    throw new IllegalStateException("RequestHeader is not set in method: " + method.getName());
  }

  return (RequestHeader) invocation.getArguments()[0];
}
 
開發者ID:mnemonic-no,項目名稱:act-platform,代碼行數:19,代碼來源:AbstractAspect.java

示例6: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

    Class targetClass = methodInvocation.getThis().getClass();
    Method method = methodInvocation.getMethod();

    targetClass = ClassKits.getUsefulClass(targetClass);

    Interceptor[] finalInters = manger.buildServiceMethodInterceptor(InterceptorManager.NULL_INTERS, targetClass, method);
    JFinalBeforeInvocation invocation = new JFinalBeforeInvocation(methodInvocation, finalInters);
    invocation.invoke();
    return invocation.getReturnValue();
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:14,代碼來源:JFinalBeforeInterceptor.java

示例7: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

    Class targetClass = methodInvocation.getThis().getClass();
    Method method = methodInvocation.getMethod();

    Object result = methodInvocation.proceed();

    CachePut cachePut = method.getAnnotation(CachePut.class);
    if (cachePut == null) {
        return result;
    }

    String unlessString = cachePut.unless();
    if (StringUtils.isNotBlank(unlessString)) {
        unlessString = String.format("#(%s)", unlessString);
        String unlessBoolString = Kits.engineRender(unlessString, method, methodInvocation.getArguments());
        if ("true".equals(unlessBoolString)) {
            return result;
        }
    }


    String cacheName = cachePut.name();
    JbootAssert.assertTrue(StringUtils.isNotBlank(cacheName),
            String.format("CachePut.name()  must not empty in method [%s]!!!", targetClass.getName() + "#" + method.getName()));

    String cacheKey = Kits.buildCacheKey(cachePut.key(), targetClass, method, methodInvocation.getArguments());

    if (cachePut.liveSeconds() > 0) {
        Jboot.me().getCache().put(cacheName, cacheKey, result, cachePut.liveSeconds());
    } else {
        Jboot.me().getCache().put(cacheName, cacheKey, result);
    }
    return result;
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:37,代碼來源:JbootCachePutInterceptor.java

示例8: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

    Class targetClass = methodInvocation.getThis().getClass();
    Method method = methodInvocation.getMethod();

    CacheEvict cacheEvict = method.getAnnotation(CacheEvict.class);
    if (cacheEvict == null) {
        return methodInvocation.proceed();
    }

    String unlessString = cacheEvict.unless();
    if (StringUtils.isNotBlank(unlessString)) {
        unlessString = String.format("#(%s)", unlessString);
        String unlessBoolString = Kits.engineRender(unlessString, method, methodInvocation.getArguments());
        if ("true".equals(unlessBoolString)) {
            return methodInvocation.proceed();
        }
    }


    String cacheName = cacheEvict.name();
    JbootAssert.assertTrue(StringUtils.isNotBlank(cacheName),
            String.format("CacheEvict.name()  must not empty in method [%s]!!!", targetClass.getName() + "#" + method.getName()));

    String cacheKey = Kits.buildCacheKey(cacheEvict.key(), targetClass, method, methodInvocation.getArguments());

    Jboot.me().getCache().remove(cacheName, cacheKey);
    return methodInvocation.proceed();
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:31,代碼來源:JbootCacheEvictInterceptor.java

示例9: invokeAttribute

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
private Object invokeAttribute(PropertyDescriptor pd, MethodInvocation invocation)
		throws JMException, IOException {

	String attributeName = JmxUtils.getAttributeName(pd, this.useStrictCasing);
	MBeanAttributeInfo inf = this.allowedAttributes.get(attributeName);
	// If no attribute is returned, we know that it is not defined in the
	// management interface.
	if (inf == null) {
		throw new InvalidInvocationException(
				"Attribute '" + pd.getName() + "' is not exposed on the management interface");
	}
	if (invocation.getMethod().equals(pd.getReadMethod())) {
		if (inf.isReadable()) {
			return this.serverToUse.getAttribute(this.objectName, attributeName);
		}
		else {
			throw new InvalidInvocationException("Attribute '" + attributeName + "' is not readable");
		}
	}
	else if (invocation.getMethod().equals(pd.getWriteMethod())) {
		if (inf.isWritable()) {
			this.serverToUse.setAttribute(this.objectName, new Attribute(attributeName, invocation.getArguments()[0]));
			return null;
		}
		else {
			throw new InvalidInvocationException("Attribute '" + attributeName + "' is not writable");
		}
	}
	else {
		throw new IllegalStateException(
				"Method [" + invocation.getMethod() + "] is neither a bean property getter nor a setter");
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:MBeanClientInterceptor.java

示例10: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
	Method method = invocation.getMethod();
	if (logger.isDebugEnabled()) {
		logger.debug("Incoming " + this.exporterNameClause + "remote call: " +
				ClassUtils.getQualifiedMethodName(method));
	}
	try {
		Object retVal = invocation.proceed();
		if (logger.isDebugEnabled()) {
			logger.debug("Finished processing of " + this.exporterNameClause + "remote call: " +
					ClassUtils.getQualifiedMethodName(method));
		}
		return retVal;
	}
	catch (Throwable ex) {
		if (ex instanceof RuntimeException || ex instanceof Error) {
			if (logger.isWarnEnabled()) {
				logger.warn("Processing of " + this.exporterNameClause + "remote call resulted in fatal exception: " +
						ClassUtils.getQualifiedMethodName(method), ex);
			}
		}
		else {
			if (logger.isInfoEnabled()) {
				logger.info("Processing of " + this.exporterNameClause + "remote call resulted in exception: " +
						ClassUtils.getQualifiedMethodName(method), ex);
			}
		}
		throw ex;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:RemoteInvocationTraceInterceptor.java

示例11: createInvocationTraceName

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
/**
 * Create a {@code String} name for the given {@code MethodInvocation}
 * that can be used for trace/logging purposes. This name is made up of the
 * configured prefix, followed by the fully-qualified name of the method being
 * invoked, followed by the configured suffix.
 * @see #setPrefix
 * @see #setSuffix
 */
protected String createInvocationTraceName(MethodInvocation invocation) {
	StringBuilder sb = new StringBuilder(getPrefix());
	Method method = invocation.getMethod();
	Class<?> clazz = method.getDeclaringClass();
	if (this.logTargetClassInvocation && clazz.isInstance(invocation.getThis())) {
		clazz = invocation.getThis().getClass();
	}
	sb.append(clazz.getName());
	sb.append('.').append(method.getName());
	sb.append(getSuffix());
	return sb.toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:AbstractMonitoringInterceptor.java

示例12: invokeHandlerMethod

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
	Object[] handlerArgs;
	if (method.getParameterTypes().length == 1) {
		handlerArgs = new Object[] { ex };
	}
	else {
		handlerArgs = new Object[] {mi.getMethod(), mi.getArguments(), mi.getThis(), ex};
	}
	try {
		method.invoke(this.throwsAdvice, handlerArgs);
	}
	catch (InvocationTargetException targetEx) {
		throw targetEx.getTargetException();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:ThrowsAdviceInterceptor.java

示例13: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
public Object invoke(final MethodInvocation invocation) throws Throwable {
    Method method = invocation.getMethod();
    Object obj = invocation.getThis();
    CacheInvokeConfig cac = null;
    if (obj != null) {
        String key = CachePointcut.getKey(method, obj.getClass());
        cac  = cacheConfigMap.get(key);
    }

    /*
    if(logger.isTraceEnabled()){
        logger.trace("JetCacheInterceptor invoke. foundJetCacheConfig={}, method={}.{}(), targetClass={}",
                cac != null,
                method.getDeclaringClass().getName(),
                method.getName(),
                invocation.getThis() == null ? null : invocation.getThis().getClass().getName());
    }
    */

    if (cac == null) {
        return invocation.proceed();
    }

    if (globalCacheConfig == null) {
        globalCacheConfig = applicationContext.getBean(GlobalCacheConfig.class);
    }
    CacheInvokeContext context = globalCacheConfig.getCacheContext().createCacheInvokeContext();
    context.setInvoker(invocation::proceed);
    context.setMethod(method);
    context.setArgs(invocation.getArguments());
    context.setCacheInvokeConfig(cac);
    context.setHiddenPackages(globalCacheConfig.getHiddenPackages());
    return CacheHandler.invoke(context);
}
 
開發者ID:alibaba,項目名稱:jetcache,代碼行數:35,代碼來源:JetCacheInterceptor.java

示例14: invoke

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
public Object invoke(MethodInvocation invocation) throws Throwable {
	Method method=invocation.getMethod();
	Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
	this.doInterceptors(true, targetClass, method, invocation.getArguments(), null);
	Object retVal = invocation.proceed();
	this.doInterceptors(false, targetClass, method, invocation.getArguments(), retVal);
	return retVal;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:9,代碼來源:GlobalMethodInterceptor.java

示例15: invokeInternal

import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
private Object invokeInternal(MethodInvocation invocation) throws Throwable
{
    // Get the txn start time
    long txnStartTime = AlfrescoTransactionSupport.getTransactionStartTime();
    if (txnStartTime < 0)
    {
        // There is no transaction
        return invocation.proceed();
    }
    
    // Check if the required time has passed
    long now = System.currentTimeMillis();
    long txnElapsedTime = (now - txnStartTime);
    if (txnElapsedTime < elapsedTimeBeforeActivationMillis)
    {
        // It's not been long enough
        return invocation.proceed();
    }

    // We need to start timing the method calls
    Method calledMethod = invocation.getMethod();
    long beforeNs = System.nanoTime();
    Object ret = invocation.proceed();
    long deltaNs = System.nanoTime() - beforeNs;
    
    // Get the method stats
    @SuppressWarnings("unchecked")
    Map<Method, MethodStatistics> methodStatsByMethod =
        (Map<Method, MethodStatistics>) AlfrescoTransactionSupport.getResource(resourceKey);
    if (methodStatsByMethod == null)
    {
        methodStatsByMethod = new HashMap<Method, MethodStatistics>(11);
        AlfrescoTransactionSupport.bindResource(resourceKey, methodStatsByMethod);
    }
    
    // Update method stats
    MethodStatistics calledMethodStats = methodStatsByMethod.get(calledMethod);
    if (calledMethodStats == null)
    {
        calledMethodStats = new MethodStatistics();
        methodStatsByMethod.put(calledMethod, calledMethodStats);
    }
    calledMethodStats.accumulateNs(deltaNs);
    
    // Check if we need to call the resource managers to clean up 
    if ((now - lastCallMillis) >= resourceManagerCallFrequencyMillis)
    {
        for (MethodResourceManager resourceManager : methodResourceManagers)
        {
            resourceManager.manageResources(methodStatsByMethod, txnElapsedTime, calledMethod);
        }
        lastCallMillis = now;
    }
    
    // Done
    return ret;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:58,代碼來源:SingleEntryTransactionResourceInterceptor.java


注:本文中的org.aopalliance.intercept.MethodInvocation.getMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。