当前位置: 首页>>代码示例>>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;未经允许,请勿转载。