本文整理匯總了Java中org.aopalliance.intercept.MethodInvocation.getThis方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInvocation.getThis方法的具體用法?Java MethodInvocation.getThis怎麽用?Java MethodInvocation.getThis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.aopalliance.intercept.MethodInvocation
的用法示例。
在下文中一共展示了MethodInvocation.getThis方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getService
import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
/**
* Retrieve the service instance from which a method was invoked.
*
* @param invocation Invoked method
* @return Service of invoked method
*/
Service getService(MethodInvocation invocation) {
if (!(invocation.getThis() instanceof Service)) {
throw new IllegalArgumentException("Invocation target is not a service implementation: " + invocation.getThis());
}
return (Service) invocation.getThis();
}
示例2: invoke
import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
// Work out the target class: may be {@code null}.
// The TransactionAttributeSource should be passed the target class
// as well as the method, which may be from an interface.
Class<?> targetClass = (invocation.getThis() != null ? AopUtils.getTargetClass(invocation.getThis()) : null);
// Adapt to TransactionAspectSupport's invokeWithinTransaction...
return invokeWithinTransaction(invocation.getMethod(), targetClass, new InvocationCallback() {
@Override
public Object proceedWithInvocation() throws Throwable {
return invocation.proceed();
}
});
}
示例3: 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();
}
}
示例4: 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);
}
示例5: 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;
}
示例6: 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();
}
示例7: getLoggerForInvocation
import org.aopalliance.intercept.MethodInvocation; //導入方法依賴的package包/類
/**
* Return the appropriate {@code Log} instance to use for the given
* {@code MethodInvocation}. If the {@code useDynamicLogger} flag
* is set, the {@code Log} instance will be for the target class of the
* {@code MethodInvocation}, otherwise the {@code Log} will be the
* default static logger.
* @param invocation the {@code MethodInvocation} being traced
* @return the {@code Log} instance to use
* @see #setUseDynamicLogger
*/
protected Log getLoggerForInvocation(MethodInvocation invocation) {
if (this.defaultLogger != null) {
return this.defaultLogger;
}
else {
Object target = invocation.getThis();
return LogFactory.getLog(getClassForLogging(target));
}
}