/** * Lookup and launch the timer. * * @param config servlet configuration * @throws ServletException shouldn't occur * * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig) */ public void init(ServletConfig config) throws ServletException { super.init(config); String jndiName = config.getInitParameter(JNDI_NAME); if ((jndiName == null) || "".equals(jndiName)) { LOG.error("Please specify a '" + JNDI_NAME + "' parameter to lookup the timer manager."); return; } try { TimerFactory.instance().setManager((TimerManager) (new InitialContext()).lookup(jndiName)); // launch timer indirectly Configuration datupConfig = (Configuration) ContextSingletonBeanFactoryLocator.getInstance( "classpath*:beanRefContext.xml").useBeanFactory("businessBeanFactory").getFactory().getBean( "datupConfiguration"); LOG.debug(datupConfig); } catch (Throwable t) { LOG.error("Unable to lookup the Timer Manager: " + jndiName, t); } }
/** * Setter for application context * * @param context * App context */ public void setApplicationContext(ApplicationContext context) { this.applicationContext = context; String deploymentType = System.getProperty("red5.deployment.type"); logger.debug("Deployment type: " + deploymentType); if (deploymentType == null) { // standalone core context String config = System.getProperty("red5.conf_file"); if (config == null) { config = "red5.xml"; } coreContext = ContextSingletonBeanFactoryLocator.getInstance(config).useBeanFactory("red5.core").getFactory(); } else { logger.info("Setting parent bean factory as core"); coreContext = applicationContext.getParentBeanFactory(); } }
/** * Setter for application context * * @param context App context */ public void setApplicationContext(ApplicationContext context) { this.applicationContext = context; String deploymentType = System.getProperty("red5.deployment.type"); logger.debug("Deployment type: " + deploymentType); if (deploymentType == null) { // standalone core context String config = System.getProperty("red5.conf_file"); if (config == null) { config = "red5.xml"; } coreContext = ContextSingletonBeanFactoryLocator.getInstance(config).useBeanFactory("red5.core") .getFactory(); } else { logger.info("Setting parent bean factory as core"); coreContext = applicationContext.getParentBeanFactory(); } }
public ComponentLoaderImpl () throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { checkInit(); BeanFactoryLocator factoryLocator = ContextSingletonBeanFactoryLocator .getInstance(String.format("classpath:%s", CoreGlobalProperty.BEAN_REF_CONTEXT_CONF)); BeanFactoryReference ref = factoryLocator.useBeanFactory("parentContext"); ioc = ref.getFactory(); }
/** * Template method with default implementation (which may be overridden by a * subclass), to load or obtain an ApplicationContext instance which will be * used as the parent context of the root WebApplicationContext. If the * return value from the method is null, no parent context is set. * <p>The main reason to load a parent context here is to allow multiple root * web application contexts to all be children of a shared EAR context, or * alternately to also share the same parent context that is visible to * EJBs. For pure web applications, there is usually no need to worry about * having a parent context to the root web application context. * <p>The default implementation uses * {@link org.springframework.context.access.ContextSingletonBeanFactoryLocator}, * configured via {@link #LOCATOR_FACTORY_SELECTOR_PARAM} and * {@link #LOCATOR_FACTORY_KEY_PARAM}, to load a parent context * which will be shared by all other users of ContextsingletonBeanFactoryLocator * which also use the same configuration parameters. * @param servletContext current servlet context * @return the parent application context, or {@code null} if none * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator */ protected ApplicationContext loadParentContext(ServletContext servletContext) { ApplicationContext parentContext = null; String locatorFactorySelector = servletContext.getInitParameter(LOCATOR_FACTORY_SELECTOR_PARAM); String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM); if (parentContextKey != null) { // locatorFactorySelector may be null, indicating the default "classpath*:beanRefContext.xml" BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(locatorFactorySelector); Log logger = LogFactory.getLog(ContextLoader.class); if (logger.isDebugEnabled()) { logger.debug("Getting parent context definition: using parent context key of '" + parentContextKey + "' with BeanFactoryLocator"); } this.parentContextRef = locator.useBeanFactory(parentContextKey); parentContext = (ApplicationContext) this.parentContextRef.getFactory(); } return parentContext; }
public void setSessionContext(SessionContext ctx) { super.setSessionContext(ctx); setBeanFactoryLocator(ContextSingletonBeanFactoryLocator.getInstance("classpath*:beanRefContext.xml")); setBeanFactoryLocatorKey("applicationContext-main"); }
public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) { super.setMessageDrivenContext(messageDrivenContext); setBeanFactoryLocator(ContextSingletonBeanFactoryLocator.getInstance("classpath*:beanRefContext.xml")); setBeanFactoryLocatorKey("applicationContext-main"); }
/** * Delegate GET requests to {@link #doService(ServletRequest, ServletResponse)}. * * @param request HttpServletRequest * @param response HttpServletResponse * @throws ServletException if error * @throws IOException if error * * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /* @todo (mspears:Mar 29, 2010) testing purposes only, should be disabled in production */ response.setContentType("text/html"); PrintWriter out = response.getWriter(); if (request.getParameter("lock") != null) { // DifUpdater.RUNCOUNTER = 1; // out.println("Order checks are locked out."); } else if (request.getParameter("unlock") != null) { // DifUpdater.RUNCOUNTER = 0; // out.println("Order checks are available."); } else { String runCommand = request.getParameter("run"); if (runCommand == null) { out.println("<p>Manually <a href='timer?run'><b>execute</b></a> the FDB-DIF update process.</p>"); out.println("<p>*This trigger is provided for testing purposes only.</p>"); } else { try { DifUpdateCapability capability = (DifUpdateCapability) ContextSingletonBeanFactoryLocator.getInstance( "classpath*:beanRefContext.xml").useBeanFactory("businessBeanFactory").getFactory().getBean( "difUpdateCapability"); if (capability.execute()) { out.println("<font color='blue'><h2>Updater ran successfully.</h2></font>"); out.println("See log for more information."); } else { out .println("<font color='orange'><h2>Updater ran successfully but no updates were processed. Should there have been?</h2></font>"); out.println("See log for more information."); } } catch (Throwable t) { out.println("<font color='red'><h2>Updater run failed!</h2></font>"); out.println("See log for more information."); out.println("<pre>"); t.printStackTrace(out); out.println("</pre>"); } } } out.flush(); out.close(); }
/** * Template method with default implementation (which may be overridden by a * subclass), to load or obtain an ApplicationContext instance which will be * used as the parent context of the root WebApplicationContext. If the * return value from the method is null, no parent context is set. * <p>The main reason to load a parent context here is to allow multiple root * web application contexts to all be children of a shared EAR context, or * alternately to also share the same parent context that is visible to * EJBs. For pure web applications, there is usually no need to worry about * having a parent context to the root web application context. * <p>The default implementation uses * {@link org.springframework.context.access.ContextSingletonBeanFactoryLocator}, * configured via {@link #LOCATOR_FACTORY_SELECTOR_PARAM} and * {@link #LOCATOR_FACTORY_KEY_PARAM}, to load a parent context * which will be shared by all other users of ContextsingletonBeanFactoryLocator * which also use the same configuration parameters. * @param servletContext current servlet context * @return the parent application context, or <code>null</code> if none * @throws BeansException if the context couldn't be initialized * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator */ protected ApplicationContext loadParentContext(ServletContext servletContext) throws BeansException { ApplicationContext parentContext = null; String locatorFactorySelector = servletContext.getInitParameter(LOCATOR_FACTORY_SELECTOR_PARAM); String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM); if (parentContextKey != null) { // locatorFactorySelector may be null, indicating the default "classpath*:beanRefContext.xml" BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(locatorFactorySelector); if (logger.isDebugEnabled()) { logger.debug("Getting parent context definition: using parent context key of '" + parentContextKey + "' with BeanFactoryLocator"); } this.parentContextRef = locator.useBeanFactory(parentContextKey); parentContext = (ApplicationContext) this.parentContextRef.getFactory(); } return parentContext; }
/** * Determine the BeanFactoryLocator to obtain the BeanFactoryReference from. * <p>The default implementation exposes Spring's default * {@link ContextSingletonBeanFactoryLocator}. * @param target the target bean to autowire * @return the BeanFactoryLocator to use (never {@code null}) * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator#getInstance() */ protected BeanFactoryLocator getBeanFactoryLocator(Object target) { return ContextSingletonBeanFactoryLocator.getInstance(); }
/** * Start Spring ApplicationContext * * @param messageDrivenContext Set the MBD context * * @see org.springframework.ejb.support.AbstractMessageDrivenBean#setMessageDrivenContext(javax.ejb.MessageDrivenContext) */ public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) { super.setMessageDrivenContext(messageDrivenContext); setBeanFactoryLocator(ContextSingletonBeanFactoryLocator.getInstance()); setBeanFactoryLocatorKey("businessBeanFactory"); }