當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。