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


Java InvocationContext.getTarget方法代码示例

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


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

示例1: accessAllowed

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object accessAllowed(InvocationContext ctx) throws Exception {
	Method businessAction = ctx.getMethod();
	Object managedBean = ctx.getTarget();
	boolean isAccessAllowed = false;

	try {

		ActionContext securityContext = new ActionContext(getUser(userModule));
		securityContext.setBusinessAction(businessAction);
		securityContext.setManagedBean(managedBean);

		isAccessAllowed = forumsACLProvider.hasAccess(securityContext);
		if (!isAccessAllowed)
			return null;
	} catch (NoSuchMethodException nsme) {
		throw new FacesException("Error calling action method of component with id " + nsme, nsme);
	} catch (Exception e) {
		throw new FacesException("Error calling action method of component with id " + e, e);
	}
	return ctx.proceed();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:23,代码来源:AuthorizationListener.java

示例2: guard

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object guard(InvocationContext context) throws Exception {
    Object target = context.getTarget();
    AtomicInteger counter = admin.getCounter(target);
    try {
        int failureCount = counter.get();
        if (failureCount >= this.maxExceptionsThreashold) {
            String methodName = context.getMethod().toString();
            this.unstableServiceEvent.fire(new SubsequentInvocationsFailure(methodName, failureCount));
            throw new UnstableExternalServiceException(methodName);
        }
        return context.proceed();
    } catch (Exception ex) {
        counter.incrementAndGet();
        throw ex;
    }
}
 
开发者ID:AdamBien,项目名称:javaee-calculator,代码行数:18,代码来源:CircuitBreaker.java

示例3: logMethodCall

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object logMethodCall(InvocationContext invocationContext) throws Exception {
    Object interceptedObject = invocationContext.getTarget();
    Method interceptedMethod = invocationContext.getMethod();

    System.out.println("Entering "
            + interceptedObject.getClass().getName() + "."
            + interceptedMethod.getName() + "()");

    Object o = invocationContext.proceed();

    System.out.println("Leaving  "
            + interceptedObject.getClass().getName() + "."
            + interceptedMethod.getName() + "()");

    return o;
}
 
开发者ID:PacktPublishing,项目名称:Java-EE-7-Development-with-NetBeans-8,代码行数:18,代码来源:LoggingInterceptor.java

示例4: dbStoreInterceptor

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object dbStoreInterceptor(InvocationContext ctx) throws Exception {
    Object result = ctx.proceed();
    Method method = ctx.getMethod();
    final Object target = ctx.getTarget();
        
    try {
        final DBStore dbStoreAnnotation = method.getAnnotation(DBStore.class);
        
        DBStoreAdapter.dBStoreAdapter(dbStoreAnnotation, target, null, method, metricFields);
    } catch(Exception e) {
        e.printStackTrace();
    }
    
    return result;
}
 
开发者ID:panossot,项目名称:jam-metrics,代码行数:17,代码来源:DBStoreInterceptor.java

示例5: dbStoreSyncInterceptor

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object dbStoreSyncInterceptor(InvocationContext ctx) throws Exception {
    Object result = ctx.proceed();
    Method method = ctx.getMethod();
    final Object target = ctx.getTarget();
        
    try {
        DBStore dbStoreAnnotation = method.getAnnotation(DBStore.class);
        
        DBStoreSyncAdapter.dBStoreSyncAdapter(dbStoreAnnotation, target, null, method, metricFields);
        
    } catch(Exception e) {
        e.printStackTrace();
    }
    
    return result;
}
 
开发者ID:panossot,项目名称:jam-metrics,代码行数:18,代码来源:DBStoreSyncInterceptor.java

示例6: metricFilterInterceptor

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object metricFilterInterceptor(InvocationContext ctx) throws Exception {
    Object result = ctx.proceed();
    Method method = ctx.getMethod();
    final Object target = ctx.getTarget();
        
    try {
        final MetricFilter metricFilterAnnotation = method.getAnnotation(MetricFilter.class);
        
        MetricFilterAdapter.metricFilterAdapter(metricFilterAnnotation, target, null, method, metricFields);

    } catch(Exception e) {
        e.printStackTrace();
    }
    
    return result;
}
 
开发者ID:panossot,项目名称:jam-metrics,代码行数:18,代码来源:MetricFilterInterceptor.java

示例7: onMessage

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object onMessage(InvocationContext invocation) throws Exception {
	Object mdb = invocation.getTarget();

	if (invocation.getMethod().getName().equals("onMessage")) {
		Message message = (Message) invocation.getParameters()[0];
		try {
			Object payload = extractPayload(message);
			invokeConsumeMethod(mdb, payload);
		} catch (Exception e) {
			System.out.println("Report error: sending message to dead letter");
			e.printStackTrace();
			deadLetterSender.sendDeadLetter(message, e.getMessage(), e);
		}
	}
	return invocation.proceed();
}
 
开发者ID:victorrentea,项目名称:training,代码行数:18,代码来源:PayloadExtractor.java

示例8: checkFailure

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object checkFailure(InvocationContext invocationContext) throws Exception {
    Class targetClass = (invocationContext.getTarget() != null ? invocationContext.getTarget().getClass() : invocationContext.getMethod().getDeclaringClass());
    ExpectedFailure expectedFailure =
            AnnotationUtils.extractAnnotationFromMethodOrClass(beanManager, invocationContext.getMethod(), targetClass, ExpectedFailure.class);
    Object returnValue = null;
    try {
        returnValue = invocationContext.proceed();
    } catch (Throwable e) {
        if (expectedFailure != null && expectedFailure.failure().equals(e.getClass())) {
            return returnValue;
        }
        else {
            Assert.fail("Expected Failure [" + (expectedFailure != null ? expectedFailure.failure() : "null") +
                        "], but was [" + e.getClass() + "] - [" + e.getMessage() + "]");
        }
    }
    Assert.fail("Expected Failure [" + (expectedFailure != null ? expectedFailure.failure() : "null") +
            "], but was [no failure recorded]");
    return returnValue;
}
 
开发者ID:lbitonti,项目名称:deltaspike-dbunit,代码行数:22,代码来源:ExpectedFailureInterceptor.java

示例9: loadConfiguration

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
/**
 * Method initialises class fields from configuration.
 */
@PostConstruct
public Object loadConfiguration(InvocationContext ic) throws Exception {

    Object target = ic.getTarget();
    Class targetClass = target.getClass();

    if (targetClassIsProxied(targetClass)) {
        targetClass = targetClass.getSuperclass();
    }

    ConfigBundle configBundleAnnotation = (ConfigBundle) targetClass.getDeclaredAnnotation(ConfigBundle.class);

    processConfigBundleBeanSetters(target, targetClass, getKeyPrefix(targetClass), new HashMap<>(),
            configBundleAnnotation.watch());

    return ic.proceed();
}
 
开发者ID:kumuluz,项目名称:kumuluzee,代码行数:21,代码来源:ConfigBundleInterceptor.java

示例10: registerCommandRoutes

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@PostConstruct
public Object registerCommandRoutes(InvocationContext ctx) throws Exception {
  Component component = (Component) ctx.getTarget();
  CommandRouter.findCommandMethods(component.getClass(), CommandRoute.class)
      .mapKey(this::persistedCommand)
      .forEach((command, method) -> {
        // Register the command
        commandRouterRegistry.put(command.getCommand(), component, method);
        // Register any aliasses
        command.getAliasses().forEach(alias -> commandRouterRegistry.putAlias(alias, command.getCommand()));
      });

  return ctx.proceed();
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:15,代码来源:CommandRouteImplementorInterceptor.java

示例11: registerCommandRoutes

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@PostConstruct
public Object registerCommandRoutes(InvocationContext ctx) throws Exception {
  Component component = (Component) ctx.getTarget();
  CommandRouter.findCommandMethods(component.getClass(), CliCommandRoute.class)
      .mapKey(CliCommandRoute::command)
      .forEach((command, method) -> cliCommandRouterRegistry.put(command, component, method));

  return ctx.proceed();
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:10,代码来源:CliCommandRouteImplementorInterceptor.java

示例12: validateMethodInvocation

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object validateMethodInvocation(InvocationContext ctx) throws Exception {

    Object resource = ctx.getTarget();
    Method method = ctx.getMethod();

    log.log(Level.FINE, "Starting validation for controller method: {0}#{1}", new Object[]{
            resource.getClass().getName(), method.getName()
    });

    Validator validator = validatorFactory.getValidator();
    ExecutableValidator executableValidator = validator.forExecutables();

    // validate controller property parameters
    processViolations(ctx,
            validator.validate(resource)
    );

    // validate controller method parameters
    processViolations(ctx,
            executableValidator.validateParameters(resource, method, ctx.getParameters())
    );

    // execute method
    Object result = ctx.proceed();

    // TODO: Does this make sense? Nobody will be able to handle these. Remove?
    processViolations(ctx,
            executableValidator.validateReturnValue(resource, method, result)
    );

    return result;

}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:35,代码来源:ValidationInterceptor.java

示例13: plotInterceptor

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object plotInterceptor(InvocationContext ctx) throws Exception {
    Object result = ctx.proceed();
    Method method = ctx.getMethod();
    final Object target = ctx.getTarget();

    try {
        final Plot plotAnnotation = method.getAnnotation(Plot.class);
        if (plotAnnotation != null) {
            int fieldNameSize = plotAnnotation.fieldData().length;
            final String group = plotAnnotation.groupName();
            final boolean threeD = plotAnnotation.threeD();

            final MetricProperties properties = DeploymentMetricProperties.getDeploymentMetricProperties().getDeploymentMetricProperty(group);
            String metricPlot = properties.getMetricPlot();
            final int refreshRate = properties.getPlotRefreshRate();

            if (metricPlot.compareTo("true")==0) {
                for (int i = 0; i < fieldNameSize; i++) {
                    JMathPlotAdapter.jMathPlotAdapter(metricPlot, group, target, method, plotAnnotation.fieldData()[i], refreshRate, i, properties, plotAnnotation, threeD);  
                }
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return result;
}
 
开发者ID:panossot,项目名称:jam-metrics,代码行数:31,代码来源:PlotInterceptor.java

示例14: isRollbackOnly

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
protected boolean isRollbackOnly(InvocationContext context) {
    Class targetClass = (context.getTarget() != null ? context.getTarget().getClass() : context.getMethod().getDeclaringClass());
    DatabaseNoRollbackTest databaseNoRollbackTest =
            AnnotationUtils.extractAnnotationFromMethodOrClass(beanManager, context.getMethod(), targetClass, DatabaseNoRollbackTest.class);
    if (databaseNoRollbackTest != null) {
        return false;
    }
    TransactionalTest transactionalTest =
        AnnotationUtils.extractAnnotationFromMethodOrClass(beanManager, context.getMethod(), targetClass, TransactionalTest.class);
    if (transactionalTest != null) {
        return transactionalTest.rollback();
    }
    // default is true
    return  true;
}
 
开发者ID:lbitonti,项目名称:deltaspike-dbunit,代码行数:16,代码来源:TransactionalTestInterceptor.java

示例15: getRequestName

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@Override
protected String getRequestName(InvocationContext context) {
	final Method method = context.getMethod();
	final Object target = context.getTarget();
	return target.getClass().getSimpleName() + '.' + method.getName();
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:7,代码来源:MonitoringTargetInterceptor.java


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