本文整理汇总了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;
}
}
示例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();
}
示例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();
}
示例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 }));
}
}
示例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];
}
示例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);
}
}
示例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.
}
}
}
}
示例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();
}
}
示例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];
}
示例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();
}
示例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();
}