private ActionHandlerValidatorInstance createInstance( ActionHandlerValidatorClass<? extends Action<?>, ? extends Result> actionHandlerValidatorClass) { ActionHandlerValidatorInstance actionHandlerValidatorInstance = null; ActionValidator actionValidator = findActionValidator(actionHandlerValidatorClass.getActionValidatorClass()); if (actionValidator == null) { actionValidator = injector.getInstance(actionHandlerValidatorClass.getActionValidatorClass()); actionHandlerValidatorInstance = new ActionHandlerValidatorInstance( actionValidator, injector.getInstance(actionHandlerValidatorClass.getActionHandlerClass())); validators.put(actionValidator.getClass(), actionValidator); } else { actionHandlerValidatorInstance = new ActionHandlerValidatorInstance( actionValidator, injector.getInstance(actionHandlerValidatorClass.getActionHandlerClass())); } if (actionHandlerValidatorInstance.getActionHandler() == null || actionHandlerValidatorInstance.getActionValidator() == null) { return null; } return actionHandlerValidatorInstance; } }
protected <A extends Action<R>, R extends Result> void bindHandler(Class<A> actionClass, Class<? extends ActionHandler<A, R>> handlerClass) { SpringUtils.registerBean(applicationContext, new ActionHandlerValidatorMapImpl<A, R>(actionClass, new ActionHandlerValidatorClass<A, R>(handlerClass, DefaultActionValidator.class))); }
private ActionHandlerValidatorInstance createInstance(ActionHandlerValidatorClass<? extends Action<?>, ? extends Result> actionHandlerValidatorClass) { ActionHandlerValidatorInstance actionHandlerValidatorInstance = null; ActionValidator actionValidator = findActionValidator(actionHandlerValidatorClass.getActionValidatorClass()); ActionHandler<?, ?> actionHandler = SpringUtils.getInstance(applicationContext, actionHandlerValidatorClass.getActionHandlerClass()); if (actionValidator == null) { actionValidator = SpringUtils.getInstance(applicationContext, actionHandlerValidatorClass.getActionValidatorClass()); actionHandlerValidatorInstance = new ActionHandlerValidatorInstance(actionValidator, actionHandler); validators.put(actionValidator.getClass(), actionValidator); } else { actionHandlerValidatorInstance = new ActionHandlerValidatorInstance(actionValidator, actionHandler); } if (actionHandlerValidatorInstance.getActionHandler() == null || actionHandlerValidatorInstance.getActionValidator() == null) { return null; } return actionHandlerValidatorInstance; }
protected <A extends Action<R>, R extends Result> void bindHandler(Class<A> actionClass, Class<? extends ActionHandler<A, R>> handlerClass, Class<? extends ActionValidator> actionValidator) { SpringUtils.registerBean(applicationContext, new ActionHandlerValidatorMapImpl<A, R>(actionClass, new ActionHandlerValidatorClass<A, R>(handlerClass, actionValidator))); }
.getActionHandlerValidatorClass().getActionValidatorClass(); Class<? extends ActionHandler<?, ?>> handlerClass = binding.getBean().getActionHandlerValidatorClass().getActionHandlerClass();
/** * @param <A> Type of {@link Action} * @param <R> Type of {@link Result} * @param actionClass Implementation of {@link Action} to link and bind * @param handlerClass Implementation of {@link ActionHandler} to link and * bind */ protected <A extends Action<R>, R extends Result> void bindHandler( Class<A> actionClass, Class<? extends ActionHandler<A, R>> handlerClass) { bind(ActionHandlerValidatorMap.class).annotatedWith( UniqueAnnotations.create()).toInstance( new ActionHandlerValidatorMapImpl<A, R>(actionClass, new ActionHandlerValidatorClass<A, R>(handlerClass, DefaultActionValidator.class))); }
/** * @param <A> Type of {@link Action} * @param <R> Type of {@link Result} * @param actionClass Implementation of {@link Action} to link and bind * @param handlerClass Implementation of {@link ActionHandler} to link and * bind * @param actionValidator Implementation of {@link ActionValidator} to link * and bind */ protected <A extends Action<R>, R extends Result> void bindHandler( Class<A> actionClass, Class<? extends ActionHandler<A, R>> handlerClass, Class<? extends ActionValidator> actionValidator) { bind(ActionHandlerValidatorMap.class).annotatedWith( UniqueAnnotations.create()).toInstance( new ActionHandlerValidatorMapImpl<A, R>( actionClass, new ActionHandlerValidatorClass<A, R>(handlerClass, actionValidator))); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof ActionHandler<?, ?>) { ActionHandler<?, ?> actionHandler = (ActionHandler<?, ?>) bean; RegisterActionHandler registerHandler = bean.getClass().getAnnotation(RegisterActionHandler.class); if (registerHandler != null) { ActionHandlerValidatorClass actionHandlerValidatorClass = new ActionHandlerValidatorClass( actionHandler.getClass(),registerHandler.validator()); SpringUtils.registerBean(applicationContext, new ActionHandlerValidatorMapImpl( actionHandler.getActionType(), actionHandlerValidatorClass)); if (actionHandlerValidatorRegistry instanceof LazyActionHandlerValidatorRegistry) { ((LazyActionHandlerValidatorRegistry) actionHandlerValidatorRegistry) .addActionHandlerValidatorClass(actionHandler.getActionType(), actionHandlerValidatorClass); } } } return bean; }