当前位置: 首页>>代码示例>>Java>>正文


Java MethodInvocation.getArguments方法代码示例

本文整理汇总了Java中org.aopalliance.intercept.MethodInvocation.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java MethodInvocation.getArguments方法的具体用法?Java MethodInvocation.getArguments怎么用?Java MethodInvocation.getArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.aopalliance.intercept.MethodInvocation的用法示例。


在下文中一共展示了MethodInvocation.getArguments方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateMethodParameters

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
private void validateMethodParameters(MethodInvocation invocation) throws InvalidArgumentException {
  boolean isInvalid = false;
  InvalidArgumentException ex = new InvalidArgumentException();

  for (int i = 0; i < invocation.getMethod().getParameterCount(); i++) {
    Parameter parameter = invocation.getMethod().getParameters()[i];
    // Only validate arguments which implement ValidatingRequest.
    if (ValidatingRequest.class.isAssignableFrom(parameter.getType())) {
      ValidatingRequest request = (ValidatingRequest) invocation.getArguments()[i];
      if (request == null) {
        // Don't allow null request objects.
        ex.addValidationError(InvalidArgumentException.ErrorMessage.NULL, parameter.getName(), "NULL");
        isInvalid = true;
      } else {
        isInvalid |= validateRequest(request, ex);
      }
    }
  }

  if (isInvalid) {
    // If violations exist abort invoked service call.
    throw ex;
  }
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:25,代码来源:ValidationAspect.java

示例2: invoke

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable
{
    Class<?>[] parameterTypes = mi.getMethod().getParameterTypes();
    Object[] arguments = mi.getArguments();
    for (int i = 0; i < parameterTypes.length; i++)
    {
        if (arguments[i] instanceof ContentStreamImpl)
        {
        	ContentStreamImpl contentStream = (ContentStreamImpl) arguments[i];
            if (contentStream != null)
            {
                // ALF-18006
                if (contentStream.getMimeType() == null)
                {
                	InputStream stream = contentStream.getStream();
                    String mimeType = mimetypeService.guessMimetype(contentStream.getFileName(), stream);
                    contentStream.setMimeType(mimeType);
                }
            }
        }
    }
    return mi.proceed();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:AlfrescoCmisStreamInterceptor.java

示例3: 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

示例4: dump

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
/**
 * 记录请求信息
 * 
 * @param methodInvocation
 * @param take
 */
private void dump(MethodInvocation methodInvocation, Object result, long take) {
    // 取得日志打印对象
    Logger log = getLogger(methodInvocation.getMethod().getDeclaringClass());
    Object[] args = methodInvocation.getArguments();
    StringBuffer buffer = getArgsString(args);

    if (log.isInfoEnabled()) {
        String className = ClassUtils.getShortClassName(methodInvocation.getMethod().getDeclaringClass());
        String methodName = methodInvocation.getMethod().getName();
        String resultStr = getResultString(result);

        String now = new SimpleDateFormat(DATA_FORMAT).format(new Date());
        log.info(MessageFormat.format(MESSAGE, new Object[] { className, methodName, now, take, buffer.toString(),
                resultStr }));
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:LogInterceptor.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: proceed

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
/**
 * Allow the given method invocation to proceed, auditing values before invocation and
 * after returning or throwing.
 * 
 * @param mi                the invocation
 * @return                  Returns the method return (if a value is not thrown)
 * @throws Throwable        rethrows any exception generated by the invocation
 * 
 * @since 3.2
 */
private Object proceed(MethodInvocation mi) throws Throwable
{
    // Are we in a nested audit?
    Boolean wasInAudit = inAudit.get();
    try
    {
        // If we are already in a nested audit call, there is nothing to do
        if (Boolean.TRUE.equals(wasInAudit))
        {
            return mi.proceed();
        }

        Auditable auditableDef = mi.getMethod().getAnnotation(Auditable.class);
        if (auditableDef == null)
        {
            // No annotation, so just continue as normal
            return mi.proceed();
        }
        
        // First get the argument map, if present
        Object[] args = mi.getArguments();
        Map<String, Serializable> namedArguments = getInvocationArguments(auditableDef, args);
        // Get the service name
        String serviceName = beanIdentifier.getBeanName(mi);
        if (serviceName == null)
        {
            // Not a public service
            return mi.proceed();
        }
        String methodName = mi.getMethod().getName();
        
        return proceedWithAudit(mi, auditableDef, serviceName, methodName, namedArguments);
    }
    finally
    {
        inAudit.set(wasInAudit);                       
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:49,代码来源:AuditMethodInterceptor.java

示例7: invoke

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable 
{
    while (true)
    {
        try
        {
            MethodInvocation clone = ((ReflectiveMethodInvocation)mi).invocableClone();
            return clone.proceed();
        }
        catch (AuthenticationException ae)
        {
            // Sleep for an interval and try again.
            try
            {
                Thread.sleep(fRetryInterval);
            }
            catch (InterruptedException ie)
            {
                // Do nothing.
            }
            try
            {
                // Reauthenticate.
                fAuthService.authenticate(fUser, fPassword.toCharArray());
                String ticket = fAuthService.getCurrentTicket();
                fTicketHolder.setTicket(ticket);
                // Modify the ticket argument.
                mi.getArguments()[0] = ticket;
            }
            catch (Exception e)
            {
                // Do nothing.
            }
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:ReauthenticatingAdvice.java

示例8: 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

示例9: getArgument

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T getArgument(MethodInvocation invocation, int index)
{
    Object[] args = invocation.getArguments();
    return index > args.length ? null : (T)args[index];        
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:7,代码来源:ACLEntryVoter.java

示例10: invoke

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
@Override
public Object invoke(MethodInvocation invocation) throws Throwable // NOSONAR
{
	Class<?> targetClass = (invocation.getThis() != null ? invocation.getThis().getClass() : null);

	final SecurityAttribute secAttr = attributeSource.getAttribute(invocation.getMethod(), targetClass);
	if( CurrentUser.getUserState().isSystem() )
	{
		return invocation.proceed();
	}
	if( secAttr.isSystemOnly() )
	{
		throw new AccessDeniedException("You must be the system administrator"); //$NON-NLS-1$
	}
	Object domainObj = null;
	Set<String> onCallPrivs = secAttr.getOnCallPrivileges();
	if( !Check.isEmpty(onCallPrivs) && secAttr.getOnCallmode() != null )
	{
		switch( secAttr.getOnCallmode() )
		{
			case DOMAIN:
				domainObj = invocation.getArguments()[secAttr.getDomainArg()]; // NOSONAR
				// Let it fall through
			case TOPLEVEL:
				if( tleAclManager.filterNonGrantedPrivileges(domainObj, onCallPrivs).isEmpty() )
				{
					throwAccessDenied(onCallPrivs);
				}
				break;
			case ANY:
				if( tleAclManager.filterNonGrantedPrivileges(onCallPrivs).isEmpty() )
				{
					throwAccessDenied(onCallPrivs);
				}
				break;
		}
	}
	if( secAttr.isFilterMatching() )
	{
		return filterResult(invocation, secAttr);
	}
	return invocation.proceed();
}
 
开发者ID:equella,项目名称:Equella,代码行数:44,代码来源:MethodSecurityInteceptor.java

示例11: RemoteInvocation

import org.aopalliance.intercept.MethodInvocation; //导入方法依赖的package包/类
/**
 * Create a new RemoteInvocation for the given AOP method invocation.
 * @param methodInvocation the AOP invocation to convert
 */
public RemoteInvocation(MethodInvocation methodInvocation) {
	this.methodName = methodInvocation.getMethod().getName();
	this.parameterTypes = methodInvocation.getMethod().getParameterTypes();
	this.arguments = methodInvocation.getArguments();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:RemoteInvocation.java


注:本文中的org.aopalliance.intercept.MethodInvocation.getArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。