List of usage examples for org.springframework.web.context WebApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:com.telefonica.euro_iaas.paasmanager.bootstrap.PropertiesMBeanRegisterBootstrap.java
/** * Unregister the mbean./*from w ww . j a v a 2s . com*/ */ public void contextDestroyed(ServletContextEvent event) { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); PropertiesProvider propertiesUtil = new PropertiesProviderFactoryImpl() .createPropertiesProvider((EntityManagerFactory) ctx.getBean("entityManagerFactory")); try { for (String namespace : propertiesUtil.getNamespaces()) { log.info("Unregistering mbean " + namespace); MBeanUtils.unregister( event.getServletContext().getContextPath() + ":service=SystemConfiguration-" + namespace); } } catch (Exception e) { throw new PaasManagerServerRuntimeException(e); } }
From source file:net.naijatek.myalumni.util.taglib.LatestMembersTag.java
/** * Includes the body of the tag if the page attribute equals the value set * in the 'match' attribute.// w w w . j ava2 s. c o m * * @return SKIP_BODY if equalsAttribute body content does not equal the * value of the match attribute, EVAL_BODY_include if it does * @throws JspException */ @Override public final int doStartTag() throws JspException { request = (HttpServletRequest) pageContext.getRequest(); WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()); memService = (IMemberService) wac.getBean(BaseConstants.SERVICE_MEMBER_LOOKUP); return EVAL_BODY_BUFFERED; }
From source file:com.telefonica.euro_iaas.paasmanager.bootstrap.PropertiesMBeanRegisterBootstrap.java
/** * Stores every system properties in BD and show them by JMX *///w ww. j av a 2 s . c o m public void contextInitialized(ServletContextEvent event) { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); PropertiesProvider propertiesUtil = new PropertiesProviderFactoryImpl() .createPropertiesProvider((EntityManagerFactory) ctx.getBean("entityManagerFactory")); try { for (String namespace : propertiesUtil.getNamespaces()) { PropertiesProviderMBean mbean = new PropertiesProviderMBean(namespace, propertiesUtil); log.info("Registering mbean " + namespace); MBeanUtils.register(mbean, event.getServletContext().getContextPath() + ":service=SystemConfiguration-" + namespace); } } catch (Exception e) { throw new PaasManagerServerRuntimeException(e); } }
From source file:com.telefonica.euro_iaas.sdc.bootstrap.PropertiesMBeanRegisterBootstrap.java
/** * Unregister the mbean./*from w w w. j a v a2 s. c om*/ */ public void contextDestroyed(ServletContextEvent event) { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); PropertiesProvider propertiesUtil = new PropertiesProviderFactoryImpl() .createPropertiesProvider((EntityManagerFactory) ctx.getBean("entityManagerFactory")); try { for (String namespace : propertiesUtil.getNamespaces()) { log.info("Unregistering mbean " + namespace); MBeanUtils.unregister( event.getServletContext().getContextPath() + ":service=SystemConfiguration-" + namespace); } } catch (Exception e) { throw new SdcRuntimeException(e); } }
From source file:com.telefonica.euro_iaas.sdc.bootstrap.PropertiesMBeanRegisterBootstrap.java
/** * Stores every system properties in BD and show them by JMX *///from www . jav a2 s. co m public void contextInitialized(ServletContextEvent event) { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); PropertiesProvider propertiesUtil = new PropertiesProviderFactoryImpl() .createPropertiesProvider((EntityManagerFactory) ctx.getBean("entityManagerFactory")); try { for (String namespace : propertiesUtil.getNamespaces()) { PropertiesProviderMBean mbean = new PropertiesProviderMBean(namespace, propertiesUtil); log.info("Registering mbean " + namespace); MBeanUtils.register(mbean, event.getServletContext().getContextPath() + ":service=SystemConfiguration-" + namespace); } } catch (Exception e) { throw new SdcRuntimeException(e); } }
From source file:net.cit.tetrad.rrd.batch.InitializeServlet.java
/** * RRD ? ? ? ?.//from w ww . j ava 2 s. c o m * @param context */ private void rrdInitialize(WebApplicationContext context) { try { String execute = TetradRrdConfig.getTetradRrdConfig("initservlet"); DeviceInMemory deviceInMemory = (DeviceInMemory) context.getBean("deviceInMemory"); MongoInMemory mongoInMemory = (MongoInMemory) context.getBean("mongoInMemory"); DataAccessObjectForMongo daoForMongo = (DataAccessObjectForMongo) context .getBean("dataAccessObjectForMongo"); deviceInMemory.createDeviceGroup(); mongoInMemory.createMongoGroup(); if (execute.equals("Y")) { logger.info("start init servlet!"); RrdNioBackendFactory.setSyncPeriod(3600); String poolSize = TetradRrdConfig.getTetradRrdConfig("default_rrdPoolSize"); TetradRrdDbPool.setPoolCount(Integer.parseInt(poolSize)); TetradRrdInitializer tetradRrdInitializer = (TetradRrdInitializer) context .getBean("tetradRrdInitializer"); tetradRrdInitializer.input(); TotalInfoScheduling totalInfoSchedul = new TotalInfoScheduling(); totalInfoSchedul.run(); Thread checkingMongo = new Thread(new ConnectMongoHandlerThread()); checkingMongo.start(); Thread helper = new Thread(new MultieventMapHelper(daoForMongo)); helper.start(); } } catch (Exception ex) { logger.error(ex, ex); } }
From source file:org.hdiv.listener.InitWebSphereListener.java
/** * HDIV state parameter initialization./*w ww . ja v a2s. c o m*/ * @param wac web application context * @param httpSessionEvent http session event * @since HDIV 1.1 */ private void initHDIVState(WebApplicationContext wac, HttpSessionEvent httpSessionEvent) { String hdivParameterName = null; Boolean isRandomName = (Boolean) wac.getBean("randomName"); if (Boolean.TRUE.equals(isRandomName)) { hdivParameterName = HDIVUtil.createRandomToken(Integer.MAX_VALUE); } else { hdivParameterName = (String) wac.getBean("hdivParameter"); } httpSessionEvent.getSession().setAttribute(Constants.HDIV_PARAMETER, hdivParameterName); }
From source file:org.cometd.websocket.SpringFrameworkConfigurationTest.java
@Test public void testXMLSpringConfigurationWithWebSocket() throws Exception { prepareServer(0, null, false);// w ww.j a v a 2 s . co m // Add Spring listener context.addEventListener(new ContextLoaderListener()); String config = WEBSOCKET_JSR_356.equals(wsTransportType) ? "applicationContext-javax-websocket.xml" : "applicationContext-jetty-websocket.xml"; context.getInitParams().put(ContextLoader.CONFIG_LOCATION_PARAM, "classpath:/" + config); startServer(); prepareClient(); startClient(); WebApplicationContext applicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(context.getServletContext()); Assert.assertNotNull(applicationContext); BayeuxServerImpl bayeuxServer = (BayeuxServerImpl) applicationContext.getBean("bayeux"); Assert.assertNotNull(bayeuxServer); Assert.assertTrue(bayeuxServer.isStarted()); Assert.assertSame(bayeuxServer, bayeux); ServerTransport transport = bayeuxServer.getTransport("websocket"); Assert.assertNotNull(transport); final BayeuxClient client = newBayeuxClient(); client.handshake(); Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED)); // Wait for connect to establish Thread.sleep(1000); ClientTransport clientTransport = client.getTransport(); Assert.assertEquals("websocket", clientTransport.getName()); disconnectBayeuxClient(client); }
From source file:com.reignite.messaging.server.SpringWebInitializer.java
@Override protected RAMFServer getServerFromServletContext(ServletContext servletContext) { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext); String beanName = servletContext.getInitParameter("RAMFServerBeanName"); if (beanName == null || beanName.trim().length() == 0) { beanName = "ramfServer"; }//from www. j av a 2 s .c om return (RAMFServer) wac.getBean(beanName); }