/** * Gets a component by name. If a component is configured as a singleton, this * method would always return the same instance for specified name, otherwise a * new component instance is always created. * * @param name * the component name * @return the component * @throws UnifyException * if container is not started. If component with name is unknown. * If component instantiation error occurs. */ public UnifyComponent getComponent(String name) throws UnifyException { return getComponent(name, null, null); }
valueToInject = getComponent(configValues[0]);
(RequestContextManager) getComponent(ApplicationComponents.APPLICATION_REQUESTCONTEXTMANAGER); uplCompiler = (UplCompiler) getComponent(ApplicationComponents.APPLICATION_UPLCOMPILER); clusterService = (ClusterService) getComponent(ApplicationComponents.APPLICATION_CLUSTERSERVICE); userSessionManager = (UserSessionManager) getComponent(ApplicationComponents.APPLICATION_USERSESSIONMANAGER); bootComponentName = ApplicationComponents.APPLICATION_DEFAULTBOOTSERVICE; applicationBootService = (BootService) getComponent(bootComponentName); applicationBootService.startup(); TaskManager taskManager = (TaskManager) getComponent(ApplicationComponents.APPLICATION_TASKMANAGER); for (Map.Entry<String, Map<String, Periodic>> entry1 : componentPeriodMethodMap.entrySet()) { logInfo("Intializing component [{0}] with periodic methods...", entry1.getKey()); getComponent(entry1.getKey()); for (Map.Entry<String, Periodic> entry2 : entry1.getValue().entrySet()) { Periodic pa = entry2.getValue();
/** * Gets a component by name using alternate settings. Applies to non-singletons * only.. * * @param name * the component name * @param altSettings * the alternate settings * @return the component * @throws UnifyException * if container is not started. If component with name is unknown. * If component is a singleton. If component instantiation error * occurs. */ public UnifyComponent getComponent(String name, UnifyComponentSettings altSettings) throws UnifyException { return getComponent(name, altSettings, null); }
private RequestContextManager getRequestContextManager() throws UnifyException { if (requestContextManager == null) { requestContextManager = (RequestContextManager) applicationContext.getContainer() .getComponent(ApplicationComponents.APPLICATION_REQUESTCONTEXTMANAGER); } return requestContextManager; } }
/** * Gets component by name. * * @param name * the component name * @return the component with name * @throws UnifyException * If component is unknown. If an error occurs */ public UnifyComponent getComponent(String name) throws UnifyException { return applicationContext.getContainer().getComponent(name); }
public ListManager getListManager() throws UnifyException { if (listManager == null) { listManager = (ListManager) applicationContext.getContainer() .getComponent(ApplicationComponents.APPLICATION_LISTMANAGER); } return listManager; }
@SuppressWarnings("unchecked") private <T> Map<String, T> getComponents(Class<T> type, String[] names) throws UnifyException { Map<String, T> map = new LinkedHashMap<String, T>(); for (String name : names) { UnifyComponent component = getComponent(name); if (!type.isAssignableFrom(component.getClass())) { throw new UnifyException(UnifyCoreErrorConstants.FIELD_INJECTION_INCOMPATIBLE, type, component.getClass()); } map.put(name, (T) component); } return map; }
@SuppressWarnings("unchecked") private void initializeInterfaces() throws UnifyException { // Initialize command interface if flagged if (DataUtils.convert(boolean.class, unifySettings.get(UnifyCorePropertyConstants.APPLICATION_COMMAND_INTERFACE), null)) { interfaces.add((UnifyContainerInterface) getComponent("unify-commandinterface")); } // Initialize other interfaces List<String> interfacesList = DataUtils.convert(ArrayList.class, String.class, unifySettings.get(UnifyCorePropertyConstants.APPLICATION_INTERFACES), null); if (interfacesList != null) { for (String interfaceName : interfacesList) { interfaces.add((UnifyContainerInterface) getComponent(interfaceName)); } } }
/** * Gets a component by name using alternate settings. Applies to non-singletons * only.. * * @param name * the component name * @param altSettings * the alternate settings * @return the component * @throws UnifyException * if container is not started. If component with name is unknown. * If component is a singleton. If component instantiation error * occurs. */ public UnifyComponent getComponent(String name, UnifyComponentSettings altSettings) throws UnifyException { return applicationContext.getContainer().getComponent(name, altSettings); }
/** * Gets a UPL component using supplied attributes key. * * @param locale * the component locale * @param attributesKey * the UPL element attributes key * @return the UPL component * @throws UnifyException * if container is not started. If component with name is unknown. * If component instantiation error occurs. */ public UplComponent getUplComponent(Locale locale, String attributesKey) throws UnifyException { try { UplElementAttributes uplElementAttributes = uplCompiler.getUplElementAttributes(locale, attributesKey); UplComponent uplComponent = (UplComponent) getComponent(uplElementAttributes.getComponentName(), null, uplElementAttributes); return uplComponent; } finally { initializationTrailThreadLocal.remove(); } }
/** * Gets a UPL component with specified descriptor. * * @param locale * the locale * @param descriptor * the UPL descriptor * @param cached * the cached flag. * @return If the cached flag is set, the container returns a cached instance * with the same descriptor and locale if found. Otherwise, a new * instance is returned. * @throws UnifyException * if an error occurs */ public UplComponent getUplComponent(Locale locale, String descriptor, boolean cached) throws UnifyException { if (cached) { return cachedLocaleUplComponentMap.get(locale, descriptor); } try { UplElementAttributes uplElementAttributes = uplCompiler.compileDescriptor(locale, descriptor); UplComponent uplComponent = (UplComponent) getComponent(uplElementAttributes.getComponentName(), null, uplElementAttributes); return uplComponent; } finally { initializationTrailThreadLocal.remove(); } }
if (broadcastInfo != null) { List<String> params = clusterCommand.getParams(); broadcastInfo.getMethod().invoke(getComponent(broadcastInfo.getComponentName()), new Object[] { params.toArray(new String[params.size()]) });
unifyContainer.startup(uce, ucc); requestContextManager = (RequestContextManager) unifyContainer .getComponent(ApplicationComponents.APPLICATION_REQUESTCONTEXTMANAGER); applicationController = (ApplicationController) unifyContainer .getComponent(WebApplicationComponents.APPLICATION_HTTPCONTROLLER); userSessionManager = (UserSessionManager) unifyContainer .getComponent(ApplicationComponents.APPLICATION_USERSESSIONMANAGER); } catch (Exception e) { if (unifyContainer != null && unifyContainer.isStarted()) {
@SuppressWarnings("unchecked") private UnifyComponentConfig generateInstallBusinessServiceProxyObjects(UnifyComponentConfig businessLogicConfig, Map<String, List<UnifyPluginInfo>> pluginMap) throws UnifyException { ProxyBusinessServiceGenerator bspg = (ProxyBusinessServiceGenerator) this .getComponent(ApplicationComponents.APPLICATION_PROXYBUSINESSSERVICEGENERATOR); Class<? extends BusinessService> proxyClazz = bspg.generateCompileLoadProxyBusinessServiceClass(businessLogicConfig.getName(), (Class<? extends BusinessService>) businessLogicConfig.getType(), pluginMap); UnifyComponentConfig internalComponentConfig = new UnifyComponentConfig(businessLogicConfig.getSettings(), businessLogicConfig.getName(), businessLogicConfig.getDescription(), proxyClazz, businessLogicConfig.isSingleton()); return internalComponentConfig; }