public Object createAction() { return actionDef.getComponent(); }
protected void throwTooManyRegistrationComponentException() { final LdiExceptionMessageBuilder br = new LdiExceptionMessageBuilder(); br.addNotice("Too many registration components."); br.addItem("Component Key"); br.addElement(key); br.addItem("Registered Components"); for (ComponentDef def : getComponentDefs()) { final String componentName = def.getComponentName(); final String componentType = def.getComponentClass().getName(); Object componentInstance = null; try { componentInstance = def.getComponent(); } catch (RuntimeException ignored) { // nested too many...no way but just in case } final String definedDiXml = def.getContainer().getPath(); br.addElement("componentName: " + componentName); br.addElement(" componentType: " + componentType); if (componentInstance != null) { // just in case br.addElement(" componentInstance: " + componentInstance); br.addElement(" classLoader: " + componentInstance.getClass().getClassLoader()); } br.addElement(" definedDiXml: " + definedDiXml); } final String msg = br.buildExceptionMessage(); throw new TooManyRegistrationComponentException(msg, key, componentDefs); }
public Object createAction() { return actionDef.getComponent(); }
protected Object[] toComponentArray(Object componentKey, ComponentDef[] componentDefs) { int length = componentDefs.length; Object[] components = (componentKey instanceof Class) ? (Object[]) Array.newInstance((Class<?>) componentKey, length) : new Object[length]; for (int i = 0; i < length; ++i) { components[i] = componentDefs[i].getComponent(); } return components; }
public Object getValue(Class<?> conversionType) { if (expression != null) { return expression.evaluate(Collections.emptyMap(), container, conversionType); } if (childComponentDef != null) { return childComponentDef.getComponent(); } return value; }
public static LaContainerPreparer getPreparer(ComponentDef componentDef) { final LaContainer container = componentDef.getContainer(); final ComponentDef[] componentDefs = container.findLocalComponentDefs(LaContainerPreparer.class); if (componentDefs.length == 0) { return null; } return (LaContainerPreparer) componentDefs[0].getComponent(); }
public Object invoke(final MethodInvocation invocation) throws Throwable { final MethodInterceptor[] interceptors = new MethodInterceptor[interceptorDefs.length]; for (int i = 0; i < interceptors.length; ++i) { interceptors[i] = (MethodInterceptor) interceptorDefs[i].getComponent(); } final MethodInvocation nestInvocation = new NestedMethodInvocation((LaMethodInvocation) invocation, interceptors); return nestInvocation.proceed(); } }
@SuppressWarnings("unchecked") public <COMPONENT> COMPONENT getComponent(Object componentKey) { assertParameterIsNotNull(componentKey, "componentKey"); final ComponentDef cd = LaContainerBehavior.acquireFromGetComponent(this, componentKey); if (cd == null) { // maybe unneeded, exception when not found but keep just in case by jflute return null; } return (COMPONENT) cd.getComponent(); }
protected OptionalThing<LoginManager> handleLoginManagerTooMany(Class<?> userBeanType, TooManyRegistrationComponentException cause) { // not use findAllComponents() because cannot get components by login manager if hot deploy // and cannot use same user bean between plural login managers final List<ComponentDef> componentDefList = cause.getComponentDefList(); return OptionalThing.migratedFrom(componentDefList.stream().map(def -> { final Object component = def.getComponent(); if (component == null) { String msg = "Not found the login manager, getComponent() returned null:"; msg = msg + " componentDef=" + def + " userBeanType=" + userBeanType; throw new IllegalStateException(msg, cause); } if (!(component instanceof LoginManager)) { String msg = "Cannot cast the component to login manager:"; msg = msg + " componentType=" + component.getClass() + " component=" + component + " userBeanType=" + userBeanType; throw new IllegalStateException(msg, cause); } return (LoginManager) component; }).filter(manager -> { return userBeanType.equals(manager.getSaveKeyUserBeanType()); }).findFirst(), () -> { String msg = "Not found the login manager for the bean type: " + userBeanType.getName(); throw new IllegalStateException(msg, cause); }); }
protected OptionalThing<LoginManager> handleLoginManagerTooMany(Class<?> userBeanType, TooManyRegistrationComponentException cause) { // not use findAllComponents() because cannot get components by login manager if hot deploy // and cannot use same user bean between plural login managers final List<ComponentDef> componentDefList = cause.getComponentDefList(); return OptionalThing.migratedFrom(componentDefList.stream().map(def -> { final Object component = def.getComponent(); if (component == null) { String msg = "Not found the login manager, getComponent() returned null:"; msg = msg + " componentDef=" + def + " userBeanType=" + userBeanType; throw new IllegalStateException(msg, cause); } if (!(component instanceof LoginManager)) { String msg = "Cannot cast the component to login manager:"; msg = msg + " componentType=" + component.getClass() + " component=" + component + " userBeanType=" + userBeanType; throw new IllegalStateException(msg, cause); } return (LoginManager) component; }).filter(manager -> { return userBeanType.equals(manager.getSaveKeyUserBeanType()); }).findFirst(), () -> { String msg = "Not found the login manager for the bean type: " + userBeanType.getName(); throw new IllegalStateException(msg, cause); }); }