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


Java InvocationContext.getParameters方法代码示例

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


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

示例1: aroundInvoke

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object aroundInvoke(InvocationContext ic) throws Exception {
	String methodName = ic.getMethod().getName();
	logger.info("Executing " + ic.getTarget().getClass().getSimpleName() + "." + methodName + " method");
	Object[] parameters = (Object[]) ic.getParameters();
	logger.info("parameters are: " + parameters.length);
	if (parameters.length == 1) {
		Item item = (Item) parameters[0];
		logger.info("item: " + item.getName());
	}
	Map<String, Object> contextData = ic.getContextData();
	if (!contextData.isEmpty())
		getItemHistory().add(contextData.get("test_trace") + "");
	return ic.proceed();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:16,代码来源:IncludedInterceptor.java

示例2: aroundInvoke

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object aroundInvoke(InvocationContext ic) throws Exception {
	String methodName = ic.getMethod().getName();
	logger.info("Executing " + ic.getTarget().getClass().getSimpleName() + "." + methodName + " method");
	Object[] parameters = (Object[]) ic.getParameters();
	logger.info("parameters are: " + parameters.length);
	if (parameters.length == 1) {
		Item item = (Item) parameters[0];
		logger.info("item: " + item.getName());
	}
	Map<String, Object> contextData = ic.getContextData();
	if (contextData.isEmpty())
		contextData.put("test_trace", "test_trace");
	return ic.proceed();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:16,代码来源:ExcludedInterceptor.java

示例3: log

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

    Object result = ctx.proceed();

    Object[] parameters = ctx.getParameters();
    boolean isRoleAllowed = contextManager.isCallerInRole(UserGroupMapping.REGULAR_USER_ROLE_ID);

    if (isRoleAllowed && parameters != null && parameters.length > 0 && parameters[0] instanceof String) {
        // Not reliable condition, should be reviewed
        String fullName = (String) parameters[0];
        try {
            documentManager.logDocument(fullName, DOWNLOAD_EVENT);
        } catch (Exception ex) {
            LOGGER.log(Level.SEVERE, null, ex);
        }
    }

    return result;
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:21,代码来源:DocumentLoggerInterceptor.java

示例4: interceptLogging

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object interceptLogging(InvocationContext ctx) throws Exception {
	StringBuilder params = new StringBuilder();
	for(Object param: ctx.getParameters()) {
		params.append(param.toString()).append(",");
	}
	String signature = ctx.getClass() + "." + ctx.getMethod() + "(" + params.substring(0, params.length() -1) + ")";
	Date now1 = new Date(System.currentTimeMillis());
	SimpleDateFormat sdf = new SimpleDateFormat("hh.mm.ss dd.MM.yyyy");
	LOG.info(sdf.format(now1) +" - " + signature);
	Object o = null; 
	try{
		o = ctx.getMethod().invoke(ctx.getTarget(), ctx.getParameters());
	} catch(Exception e) {
		LOG.error(signature, e);
		throw new BusinessException(signature, e);
	} finally {
		Date now2 = new Date(System.currentTimeMillis());
		LOG.info(sdf.format(now2) +" - " + signature);
	}
	return o;
}
 
开发者ID:Angular2Guy,项目名称:Angular2AndJavaEE,代码行数:23,代码来源:LoggingInterceptor.java

示例5: logMyCall

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
	public Object logMyCall(InvocationContext context) throws Exception {
		
		// you can get the called method 
		Method method = context.getMethod();
		
		// and the class of that method, of course
		Class<?> clazz = method.getDeclaringClass();
		
		// you can get the parameters
		Object[] params = context.getParameters();
		//you can set (!) the parameters....
//		context.setParameters(...);
		
		// you can get the target class (the instance of clazz on which the method was called)
//		context.getTarget();

		
		// do what you need 
		System.out.println("called " + method.getName() + " on class " + clazz+ " params="+listParams(params));
		
		// invoke the method or let the next interceptor do its work
		return context.proceed();
	}
 
开发者ID:notsojug,项目名称:jug-material,代码行数:25,代码来源:LoggedInterceptor.java

示例6: aroundInvoke

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object aroundInvoke(InvocationContext invocationContext) throws Throwable {
    Valid valid = invokeAnnotation(invocationContext, Valid.class);
    if (!valid.ignore()) {
        Class<?>[] parameterTypes = invocationContext.getMethod().getParameterTypes();
        Object[] parameters = invocationContext.getParameters();
        // TODO This is necessary?
        //if (parameterTypes.length != parameters.length) {
        //    throw new IllegalStateException();
        //}
        if (parameterTypes.length > 0) {
            List<String> messages = validate(valid, parameterTypes, parameters);
            if (!messages.isEmpty()) {
                throw new IllegalArgumentException(messages.stream().collect(joining("\n", "\n", "\n")));
            }
        }
    }
    return invocationContext.proceed();
}
 
开发者ID:namioka,项目名称:eclipselink-example,代码行数:20,代码来源:ValidationInterceptor.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: intercept

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object intercept(InvocationContext ctx) throws Exception {
    final Object[] params = ctx.getParameters();
    Session session = null;
    for (Object param : params) {
        if (param instanceof Session) {
            session = (Session) param;
            break;
        }
    }

    if (session != null) {
        final Principal principal = (Principal) session.getUserProperties().get(SESSION_PRINCIPAL);
        final Subject subject = (Subject) session.getUserProperties().get(SESSION_SUBJECT);
        final Object credential = session.getUserProperties().get(SESSION_CREDENTIAL);

        if (principal != null && subject != null) {
            SecurityActions.setSubjectInfo(principal, subject, credential);
        }

    }

    return ctx.proceed();
}
 
开发者ID:panga,项目名称:jboss-security-extended,代码行数:25,代码来源:WebsocketSecurityInterceptor.java

示例9: intercept

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object intercept(InvocationContext ctx) throws Exception {
    final Method method = ctx.getMethod();
    if ("onMessage".equals(method.getName())
            && method.getParameterCount() == 1
            && method.getParameterTypes()[0] == Message.class) {
        final ObjectMessage message = (ObjectMessage) ctx.getParameters()[0];
        final SecureObjectMessage secureMessage = (SecureObjectMessage) message.getObject();

        final Principal principal = secureMessage.getPrincipal();
        final Subject subject = secureMessage.getSubject();
        final Object credential = secureMessage.getCredential();

        if (principal != null && subject != null) {
            SecurityActions.setSubjectInfo(principal, subject, credential);
        }

        final ObjectMessage proxiedMessage = (ObjectMessage) Proxy.newProxyInstance(
                ObjectMessage.class.getClassLoader(),
                new Class[]{ObjectMessage.class},
                new ObjectMessageProxy(message));
        ctx.setParameters(new Object[]{proxiedMessage});
    }

    return ctx.proceed();
}
 
开发者ID:panga,项目名称:jboss-security-extended,代码行数:27,代码来源:JmsSecurityInterceptor.java

示例10: filterMethodParameters

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
void filterMethodParameters(InvocationContext ctx, String username) {
    Object[] parameters = ctx.getParameters();
    if (parameters == null || parameters.length < 1) return;
    
    Method method = ctx.getMethod();
    boolean filtered = filterParameters(username, method, parameters);

    if (filtered) return;
    
    for (Class<?> iclass : method.getDeclaringClass().getInterfaces()) {
        try {
            Method imethod = iclass.getDeclaredMethod(method.getName(), method.getParameterTypes());
            filtered = filterParameters(username, imethod, parameters);
            if (filtered) return;
        } catch (NoSuchMethodException e) { }
    }
}
 
开发者ID:3venthorizon,项目名称:guardian,代码行数:18,代码来源:GuardInterceptor.java

示例11: open

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object open(InvocationContext ctx) throws Exception {
    Object[] parameters = ctx.getParameters();
    if (parameters == null || parameters.length < 1) return ctx.proceed();
    Annotation[][] annotations = ctx.getMethod().getParameterAnnotations();
    
    for (int index = 0; index < parameters.length; index++) {
        if (parameters[index] == null) continue;
        
        for (Annotation annotation : annotations[index]) {
            if (!(annotation instanceof Token)) continue;
            
            String token = parameters[index].toString();
            Session registered = registry.getSession(token);
            
            if (registered == null) return ctx.proceed();
            
            session.merge(registered);
            registry.register(session); //swap out the session pointer
            
            return ctx.proceed();
        }
    }

    return ctx.proceed();
}
 
开发者ID:3venthorizon,项目名称:guardian,代码行数:27,代码来源:GateKeeper.java

示例12: logInvocation

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object logInvocation(final InvocationContext ic) throws Exception {
    StringBuilder sb = new StringBuilder("(");
    for (Object obj : ic.getParameters()) {
        sb.append(obj.toString());
        sb.append(", ");
    }
    if (sb.length() > 1) {
        sb.deleteCharAt(sb.length() - 1);
        sb.deleteCharAt(sb.length() - 1);
    }
    sb.append(")");
    String message = ">>> " + ic.getTarget().getClass().getSuperclass().getSimpleName() +
            "." + ic.getMethod().getName() + sb.toString();
    log.info(message);

    return ic.proceed();
}
 
开发者ID:thma,项目名称:fmek,代码行数:19,代码来源:LogInterceptor.java

示例13: aroundTimeout

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundTimeout
public Object aroundTimeout(InvocationContext ic) throws Exception {
	logger.info("Executing " + ic.getTimer());
	Object[] parameters = (Object[]) ic.getParameters();
	logger.info("parameters are: " + parameters.length);
	return ic.proceed();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:8,代码来源:ExcludingInterceptor.java

示例14: aroundInvoke

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
@AroundInvoke
public Object aroundInvoke(InvocationContext ic) throws Exception {
	String methodName = ic.getMethod().getName();
	logger.info("Executing " + ic.getTarget().getClass().getSimpleName() + "." + methodName + " method");
	Object[] parameters = (Object[]) ic.getParameters();
	logger.info("parameters are: " + parameters.length);
	if (parameters.length == 1) {
		Item item = (Item) parameters[0];
		logger.info("item: " + item.getName());
	}
	return ic.proceed();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:13,代码来源:LoggingInterceptor.java

示例15: ensureLdapDisabledForServiceProvider

import javax.interceptor.InvocationContext; //导入方法依赖的package包/类
/**
 * Ensures that LDAP support is disabled if OSCM acts as a SAML SP.
 */
@AroundInvoke
public Object ensureLdapDisabledForServiceProvider(InvocationContext context)
        throws Exception {
    Object result = null;
    Object organizationProperties = null;

    Object[] parameters = context.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        if (parameters[i] instanceof LdapProperties
                || parameters[i] instanceof Properties) {
            organizationProperties = parameters[i];
        }
    }

    if (configService.isServiceProvider() && organizationProperties != null) {
        UnsupportedOperationException e = new UnsupportedOperationException(
                "It is forbidden to perform this operation if a OSCM acts as a SAML service provider.");

        Log4jLogger logger = LoggerFactory.getLogger(context.getTarget()
                .getClass());
        logger.logError(Log4jLogger.SYSTEM_LOG, e,
                LogMessageIdentifier.ERROR_OPERATION_FORBIDDEN_FOR_SAML_SP);
        throw e;
    }

    result = context.proceed();
    return result;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:32,代码来源:LdapInterceptor.java


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