@SuppressWarnings("unchecked") public final <T> T getComponent(Class<T> key) { return (T) container.getComponent(key); }
public Object evaluate(Map<String, ? extends Object> context, LaContainer container, Class<?> conversionType) { Object result = container.getComponent(source); if (result == null && context != null) { result = context.get(source); } return result; } }
/** * @param componentType The component type to find. (NotNull) * @return The found component. (NotNull) * @throws ComponentNotFoundException When the component is not found by the type. * @throws TooManyRegistrationComponentException When the component key is related to plural components. * @throws CyclicReferenceComponentException When the components refers each other. */ @SuppressWarnings("unchecked") public static <T> T getComponent(Class<T> componentType) { return (T) SingletonLaContainerFactory.getContainer().getComponent(componentType); }
/** * @param componentName The component name to find. (NotNull) * @return The found component. (NotNull) * @throws ComponentNotFoundException When the component is not found by the type. * @throws TooManyRegistrationComponentException When the component key is related to plural components. * @throws CyclicReferenceComponentException When the components refers each other. */ @SuppressWarnings("unchecked") public static <T> T getComponent(String componentName) { return (T) SingletonLaContainerFactory.getContainer().getComponent(componentName); } }
protected void prepareActionComponent(String actionName) { SingletonLaContainerFactory.getContainer().getComponent(actionName); // initialize }
protected LaContainerBuilder createDefaultBuilder(final LaContainer configurationContainer) { if (configurationContainer.hasComponentDef(DEFAULT_BUILDER_NAME)) { return (LaContainerBuilder) configurationContainer.getComponent(DEFAULT_BUILDER_NAME); } if (configurationContainer.hasComponentDef(ResourceResolver.class) && defaultBuilder instanceof AbstractLaContainerBuilder) { final ResourceResolver resolver = (ResourceResolver) configurationContainer.getComponent(ResourceResolver.class); ((AbstractLaContainerBuilder) defaultBuilder).setResourceResolver(resolver); } return defaultBuilder; }
protected Object resolveSimpleComponent(String exp, Map<String, ? extends Object> contextMap, LaContainer container, Class<?> resultType) { if (!LdiSrl.containsAny(exp, ".", ",", SQ, DQ, "@", "#")) { // main except, just in case if (container.hasComponentDef(exp)) { return container.getComponent(exp); } } return null; }
protected Object getComponent(ComponentDef componentDef, Object key, Object component, String propertyName) throws BeanIllegalPropertyException { try { return componentDef.getContainer().getComponent(key); } catch (RuntimeException cause) { throwPropertyComponentGetFailureException(componentDef, key, component, propertyName, cause); return null; // unreachable } }
protected void setupBehavior(final LaContainer configurationContainer) { if (configurationContainer.hasComponentDef(LaContainerBehavior.Provider.class)) { LaContainerBehavior.setProvider( (LaContainerBehavior.Provider) configurationContainer.getComponent(LaContainerBehavior.Provider.class)); } }
protected void setupAssembler(final LaContainer configurationContainer) { if (configurationContainer.hasComponentDef(AssemblerFactory.Provider.class)) { AssemblerFactory .setProvider((AssemblerFactory.Provider) configurationContainer.getComponent(AssemblerFactory.Provider.class)); } } }
protected void setupDeployer(final LaContainer configurationContainer) { if (configurationContainer.hasComponentDef(ComponentDeployerFactory.Provider.class)) { ComponentDeployerFactory.setProvider( (ComponentDeployerFactory.Provider) configurationContainer.getComponent(ComponentDeployerFactory.Provider.class)); } }
public DataSource getSelectedDataSource() { return container.getRoot().getComponent(getDataSourceComponentName()); }
public DataSource getSelectedDataSource() { return container.getRoot().getComponent(getDataSourceComponentName()); }
public Object lookup(final String name) throws NamingException { if (LdiStringUtil.isEmpty(name)) { return new JndiContext(new Hashtable<String, Object>(env)); } return SingletonLaContainerFactory.getContainer().getComponent(JndiResourceLocator.resolveName(name)); }
protected LaContainerBuilder getBuilder(String ext) { final String componentName = ext + "Redefined"; final LaContainer configurationContainer = LaContainerFactory.getConfigurationContainer(); if (configurationContainer != null && configurationContainer.hasComponentDef(componentName)) { return (LaContainerBuilder) configurationContainer.getComponent(componentName); } return LaContainerFactory.getDefaultBuilder(); }
public LaContainer create(String path) { final LaContainer configurationContainer = LaContainerFactory.getConfigurationContainer(); final ClassLoader classLoader; if (configurationContainer != null && configurationContainer.hasComponentDef(ClassLoader.class)) { classLoader = (ClassLoader) configurationContainer.getComponent(ClassLoader.class); } else { classLoader = Thread.currentThread().getContextClassLoader(); } final LaContainer container = LdiStringUtil.isEmpty(path) ? new LaContainerImpl() : build(path, classLoader); if (container.isInitializeOnCreate()) { container.init(); } return container; }
protected Object[] getArgs(Class<?>[] argTypes) { final Object[] args = new Object[argTypes.length]; for (int i = 0; i < argTypes.length; ++i) { try { args[i] = getComponentDef().getContainer().getComponent(argTypes[i]); } catch (ComponentNotFoundException e) { logger.log("WSSR0007", new Object[] { getComponentDef().getComponentClass().getName(), e.getComponentKey() }); args[i] = null; } } return args; }
public Object invoke(final MethodInvocation invocation) throws Throwable { final LaContainer container = getComponentDef(invocation).getContainer().getRoot(); final MethodInterceptor[] interceptors = new MethodInterceptor[interceptorNames.length]; for (int i = 0; i < interceptors.length; ++i) { interceptors[i] = (MethodInterceptor) container.getComponent(interceptorNames[i]); } final MethodInvocation nestInvocation = new NestedMethodInvocation((LaMethodInvocation) invocation, interceptors); return nestInvocation.proceed(); } }
public Object invoke(MethodInvocation invocation) throws Throwable { if (targetName == null) { throw new EmptyRuntimeException("targetName"); } Method method = invocation.getMethod(); if (!LdiMethodUtil.isAbstract(method)) { return invocation.proceed(); } else { final Object target = container.getComponent(targetName); return LdiMethodUtil.invoke(method, target, invocation.getArguments()); } }
protected static void doConfigure(String configFile) { show("...Reading {}", configFile); // first configuration so no indent (see LaContainerDefaultProvider) final LaContainerBuilder builder = newConfigurationContainerBuilder(); configurationContainer = builder.build(configFile); configurationContainer.init(); final Configurator configurator; if (configurationContainer.hasComponentDef(Configurator.class)) { configurator = (Configurator) configurationContainer.getComponent(Configurator.class); } else { configurator = newDefaultConfigurator(); } configurator.configure(configurationContainer); }