Java Code Examples for javax.servlet.ServletContextEvent
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project rave, under directory /rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/inject/.
Source file: GuiceBindingSpringContextLoaderListenerTest.java

@Test public void initialize_test(){ Injector injector=Guice.createInjector(createNiceMock(Module.class)); MockServletContext mockServletContext=new MockServletContext(); mockServletContext.addInitParameter("contextConfigLocation","classpath:rave-shindig-test-applicationContext.xml, classpath:rave-shindig-test-dataContext.xml"); mockServletContext.setAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE,injector); GuiceBindingSpringContextLoaderListener listener=new GuiceBindingSpringContextLoaderListener(); ServletContextEvent event=createNiceMock(ServletContextEvent.class); expect(event.getServletContext()).andReturn(mockServletContext).anyTimes(); replay(event); listener.contextInitialized(event); assertThat((Injector)mockServletContext.getAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE),is(not(sameInstance(injector)))); }
Example 2
From project repose, under directory /project-set/core/core-lib/src/test/java/com/rackspace/papi/servlet/boot/service/config/.
Source file: PowerApiConfigurationManagerTest.java

@Test public void shouldInitializeCorrectly(){ mockAll(); final ConfigurationServiceContext configurationManager=new ConfigurationServiceContext(new PowerApiConfigurationManager("n/a"),null,null); final ServletContextEvent event=new ServletContextEvent(context); configurationManager.contextInitialized(event); verify(context,times(1)).getInitParameter(eq(InitParameter.POWER_API_CONFIG_DIR.getParameterName())); verify(context,times(2)).getAttribute(eq(ServletContextHelper.SERVLET_CONTEXT_ATTRIBUTE_NAME)); verify(mockedConfigurationUpdateThread,times(1)).start(); assertNotNull(configurationManager); }
Example 3
From project tiles, under directory /tiles-servlet/src/test/java/org/apache/tiles/web/startup/.
Source file: AbstractTilesListenerTest.java

/** * Test method for {@link AbstractTilesListener#contextInitialized(ServletContextEvent)}. */ @Test public void testContextInitialized(){ AbstractTilesListener listener=createMockBuilder(AbstractTilesListener.class).createMock(); ServletContextEvent event=createMock(ServletContextEvent.class); ServletContext servletContext=createMock(ServletContext.class); TilesInitializer initializer=createMock(TilesInitializer.class); expect(event.getServletContext()).andReturn(servletContext); expect(listener.createTilesInitializer()).andReturn(initializer); initializer.initialize(isA(ServletApplicationContext.class)); initializer.destroy(); replay(listener,event,servletContext,initializer); listener.contextInitialized(event); listener.contextDestroyed(event); verify(listener,event,servletContext,initializer); }
Example 4
From project undertow, under directory /servlet/src/main/java/io/undertow/servlet/core/.
Source file: ApplicationListeners.java

public void contextInitialized(){ final ServletContextEvent event=new ServletContextEvent(servletContext); for ( ManagedListener listener : servletContextListeners) { this.<ServletContextListener>get(listener).contextInitialized(event); } }
Example 5
From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/test/java/alpha/portal/webapp/listener/.
Source file: StartupListenerTest.java

@Override protected void setUp() throws Exception { super.setUp(); this.sc=new MockServletContext(""); this.sc.addInitParameter(Constants.CSS_THEME,"simplicity"); this.sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,"classpath:/applicationContext-dao.xml, " + "classpath:/applicationContext-service.xml, " + "classpath:/applicationContext-resources.xml"); this.springListener=new ContextLoaderListener(); this.springListener.contextInitialized(new ServletContextEvent(this.sc)); this.listener=new StartupListener(); }
Example 6
From project autopatch, under directory /src/test/java/com/tacitknowledge/util/migration/jdbc/.
Source file: WebAppServletContextFactoryTest.java

/** * Tests that the new mechanism for configuring a launcher from a servlet context works. * @throws NamingException a problem with the test */ public void testConfiguredContext() throws NamingException { JdbcMigrationLauncherFactory launcherFactory=new JdbcMigrationLauncherFactory(); MockServletContext sc=new MockServletContext(); String dbType="mysql"; String sysName="testSystem"; sc.setInitParameter("migration.systemname",sysName); sc.setInitParameter("migration.readonly","true"); sc.setInitParameter("migration.databasetype",dbType); sc.setInitParameter("migration.patchpath","patches"); sc.setInitParameter("migration.datasource","jdbc/testsource"); MockDataSource ds=new MockDataSource(); InitialContext context=new InitialContext(); context.bind("java:comp/env/jdbc/testsource",ds); ServletContextEvent sce=new ServletContextEvent(sc); JdbcMigrationLauncher launcher=null; try { launcher=launcherFactory.createMigrationLauncher(sce); } catch ( MigrationException e) { e.printStackTrace(); fail("There should not have been an exception"); } JdbcMigrationContext jdbcContext=(JdbcMigrationContext)launcher.getContexts().keySet().iterator().next(); assertEquals(dbType,jdbcContext.getDatabaseType().getDatabaseType()); assertEquals(sysName,jdbcContext.getSystemName()); assertEquals(true,launcher.isReadOnly()); }
Example 7
From project hdiv, under directory /hdiv-core/src/test/java/org/hdiv/.
Source file: AbstractHDIVTestCase.java

protected final void setUp() throws Exception { String[] files={"/org/hdiv/config/hdiv-core-applicationContext.xml","/org/hdiv/config/hdiv-config.xml","/org/hdiv/config/hdiv-validations.xml","/org/hdiv/config/applicationContext-test.xml"}; if (this.applicationContext == null) { this.applicationContext=new ClassPathXmlApplicationContext(files); } HttpServletRequest request=(MockHttpServletRequest)this.applicationContext.getBean("mockRequest"); HttpSession httpSession=request.getSession(); ServletContext servletContext=httpSession.getServletContext(); HDIVUtil.setHttpServletRequest(request); StaticWebApplicationContext webApplicationContext=new StaticWebApplicationContext(); webApplicationContext.setServletContext(servletContext); webApplicationContext.setParent(this.applicationContext); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,webApplicationContext); this.config=(HDIVConfig)this.applicationContext.getBean("config"); InitListener initListener=new InitListener(); ServletContextEvent servletContextEvent=new ServletContextEvent(servletContext); initListener.contextInitialized(servletContextEvent); HttpSessionEvent httpSessionEvent=new HttpSessionEvent(httpSession); initListener.sessionCreated(httpSessionEvent); ServletRequestEvent requestEvent=new ServletRequestEvent(servletContext,request); initListener.requestInitialized(requestEvent); if (log.isDebugEnabled()) { log.debug("Hdiv test context initialized"); } onSetUp(); }
Example 8
From project jsf-test, under directory /stage/src/main/java/org/jboss/test/faces/staging/.
Source file: StagingServer.java

@Override public void init(){ log.info("Init staging server"); readDefaultMimeTypes(); JspFactory.setDefaultFactory(new StaggingJspFactory(this.context)); context.addInitParameters(initParameters); ClassLoader loader=Thread.currentThread().getContextClassLoader(); if (null == loader) { loader=this.getClass().getClassLoader(); } this.contextProxy=(ServletContext)Proxy.newProxyInstance(loader,new Class[]{ServletContext.class},getInvocationHandler(context)); final ServletContextEvent event=new ServletContextEvent(context); if (fireEvent(CONTEXT_LISTENER_CLASS,new EventInvoker<ServletContextListener>(){ public void invoke( ServletContextListener listener){ listener.contextInitialized(event); } } ) > 0) { throw new TestException("Server not started due to listener error "); } try { for ( RequestChain servlet : servlets) { servlet.init(context); } defaultServlet.init(context); } catch ( ServletException e) { throw new TestException("Servlet initialisation error ",e); } try { NamingManager.setInitialContextFactoryBuilder(new StagingInitialContextFactoryBuilder()); } catch ( NamingException e) { log.warning("Error set initial context factory builder."); } catch ( IllegalStateException e) { log.warning("Initial context factory builder already set."); } this.initialised=true; }
Example 9
From project nuxeo-webengine, under directory /nuxeo-webengine-jaxrs/src/main/java/org/nuxeo/ecm/webengine/jaxrs/servlet/config/.
Source file: ListenerSetDescriptor.java

public synchronized void init(ServletConfig config) throws Exception { if (event == null && !listenerDescriptors.isEmpty()) { event=new ServletContextEvent(config.getServletContext()); listeners=new ServletContextListener[listenerDescriptors.size()]; for (int i=0; i < listeners.length; i++) { ListenerDescriptor ld=listenerDescriptors.get(i); listeners[i]=ld.getListener(); listeners[i].contextInitialized(event); } } }
Example 10
From project openwebbeans, under directory /webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/.
Source file: CdiTestOpenWebBeansContainer.java

public void bootContainer() throws Exception { servletContext=new MockServletContext(); session=new MockHttpSession(); lifecycle=WebBeansContext.getInstance().getService(ContainerLifecycle.class); lifecycle.startApplication(new ServletContextEvent(servletContext)); }
Example 11
From project RSB, under directory /src/test/java/eu/openanalytics/rsb/config/.
Source file: BootstrapConfigurationServletContextListenerTestCase.java

@Before public void prepareTest(){ bcscl=new BootstrapConfigurationServletContextListener(); mockServletContext=new MockServletContext(){ @Override public String getRealPath( final String path){ return FileUtils.getTempDirectoryPath(); } } ; servletContextEvent=new ServletContextEvent(mockServletContext); }
Example 12
From project solder, under directory /testsuite/src/test/java/org/jboss/solder/servlet/test/weld/beanManager/.
Source file: ServletContextAttributeProviderTest.java

@Test public void should_register_and_locate_bean_manager(){ String MOCK_SERVLET_CONTEXT="Mock Servlet Context"; ServletContext ctx=mock(ServletContext.class); when(ctx.getServerInfo()).thenReturn(MOCK_SERVLET_CONTEXT); listener.contextInitialized(new ServletContextEvent(ctx)); verify(ctx).setAttribute(BeanManager.class.getName(),manager); assertEquals(MOCK_SERVLET_CONTEXT,serverInfoProvider.get()); when(ctx.getAttribute(BeanManager.class.getName())).thenReturn(manager); BeanManagerLocator locator=new BeanManagerLocator(); assertTrue(locator.isBeanManagerAvailable()); assertEquals(manager,locator.getBeanManager()); }
Example 13
From project Stripes-SpringTesting, under directory /src/test/java/base/.
Source file: StripesWithoutMockTestFixture.java

private static void initServlet(){ CTX.addInitParameter("contextConfigLocation",SPRING_APPLICATION_CONTEXT_XML); ContextLoaderListener springContextListener=new ContextLoaderListener(); springContextListener.contextInitialized(new ServletContextEvent(CTX)); CTX.setServlet(DispatcherServlet.class,"StripesDispatcher",null); }
Example 14
From project myfaces-extcdi, under directory /jee5-support-modules/openwebbeans-support/src/main/java/org/apache/myfaces/extensions/cdi/openwebbeans/startup/.
Source file: WebBeansAwareConfigurationListener.java

/** * {@inheritDoc} */ public void broadcastStartup(){ if (!isActivated()) { return; } if (isInitialized()) { return; } logger.info("Controlled MyFaces ExtCDI bootstrapping."); FacesContext facesContext=FacesContext.getCurrentInstance(); if (facesContext != null && facesContext.getExternalContext() != null) { ServletContext servletContext=(ServletContext)facesContext.getExternalContext().getContext(); contextInitialized(new ServletContextEvent(servletContext)); } markAsInitialized(); }
Example 15
From project accesointeligente, under directory /src/org/accesointeligente/server/.
Source file: ApplicationProperties.java

@Override public void contextInitialized(ServletContextEvent event){ try { properties=new Properties(); properties.load(new FileInputStream(event.getServletContext().getRealPath("/WEB-INF/accesointeligente.properties"))); logger.info("Context initialized"); } catch ( Throwable ex) { logger.error("Failed to initialize context",ex); } }
Example 16
From project Activiti-KickStart, under directory /activiti-kickstart-ui/src/main/java/org/activiti/kickstart/engine/.
Source file: ProcessEnginesServletContextListener.java

public void contextInitialized(ServletContextEvent servletContextEvent){ ProcessEngines.init(); ProcessEngine processEngine=ProcessEngines.getDefaultProcessEngine(); if (processEngine == null) { LOGGER.warning("Could not construct a process engine for KickStart. " + "Please verify if your activiti.cfg.xml configuration is correct."); if ("true".equals(System.getProperty("KickStartDebugInMem"))) { System.out.println(); System.out.println(); LOGGER.info("KickStartDebugInMem system property found. Switching to in memory Activiti configuration"); System.out.println(); System.out.println(); processEngine=StandaloneInMemProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().buildProcessEngine(); ProcessEngines.registerProcessEngine(processEngine); } } }
Example 17
From project AdServing, under directory /modules/server/adserver/src/main/java/net/mad/ads/server/utils/listener/.
Source file: StartupPlugIn.java

public void contextDestroyed(ServletContextEvent event){ try { RuntimeContext.getAdDB().close(); RuntimeContext.getIpDB().close(); RuntimeContext.getTrackService().close(); RuntimeContext.cacheManager.stop(); timer.cancel(); } catch ( Exception e) { logger.error("",e); } }
Example 18
From project agraph-java-client, under directory /src/test/web/.
Source file: AGExampleServletContextListener.java

@Override public void contextDestroyed(ServletContextEvent event){ Closer c=new Closer(); try { Context initCtx=c.closeLater(new InitialContext()); Context envCtx=(Context)c.closeLater(initCtx.lookup("java:comp/env")); AGConnPool pool=(AGConnPool)envCtx.lookup("connection-pool/agraph"); pool.close(); } catch ( Exception e) { e.printStackTrace(); } finally { c.close(); } }
Example 19
From project Arecibo, under directory /alertmanager/src/main/java/com/ning/arecibo/alertmanager/context/.
Source file: AlertManagerStartupContextListener.java

@Override public void contextInitialized(final ServletContextEvent event){ final ServerModuleBuilder builder=new ServerModuleBuilder().setAreciboProfile(System.getProperty("action.arecibo.profile","ning.jmx:name=MonitoringProfile")).addModule(new LifecycleModule()).addModule(new AlertManagerModule()).enableLog4J().addResource("com.ning.arecibo.alertmanager.resources").addResource("com.ning.arecibo.util.jaxrs"); guiceModule=builder.build(); super.contextInitialized(event); final Injector injector=(Injector)event.getServletContext().getAttribute(Injector.class.getName()); serviceLocator=injector.getInstance(ServiceLocator.class); serviceLocator.startReadOnly(); final CoreConfig jettyConfig=injector.getInstance(CoreConfig.class); final AreciboAlertManagerConfig alertManagerConfig=injector.getInstance(AreciboAlertManagerConfig.class); final Map<String,String> map=new HashMap<String,String>(); map.put("host",jettyConfig.getServerHost()); map.put("port",String.valueOf(jettyConfig.getServerPort())); final ServiceDescriptor self=new ServiceDescriptor(alertManagerConfig.getServiceName(),map); serviceLocator.advertiseLocalService(self); lifecycle=injector.getInstance(Lifecycle.class); lifecycle.fire(LifecycleEvent.START); }
Example 20
From project azkaban, under directory /azkaban/src/java/azkaban/web/.
Source file: AzkabanServletContextListener.java

/** * Load the app */ public void contextInitialized(ServletContextEvent event){ String homeDir=System.getenv(AZKABAN_HOME_VAR_NAME); if (homeDir == null) throw new IllegalStateException("The environment variable " + AZKABAN_HOME_VAR_NAME + " has not been set."); if (!new File(homeDir).isDirectory() || !new File(homeDir).canRead()) throw new IllegalStateException(homeDir + " is not a readable directory."); try { File logDir=new File(homeDir,"logs"); File jobDir=new File(homeDir,"jobs"); File tempDir=new File(homeDir,"temp"); this.app=new AzkabanApplication(Collections.singletonList(jobDir),logDir,tempDir,false); } catch ( IOException e) { throw new IllegalArgumentException(e); } event.getServletContext().setAttribute(AZKABAN_SERVLET_CONTEXT_KEY,this.app); }
Example 21
From project b3log-latke, under directory /latke/src/main/java/org/b3log/latke/servlet/.
Source file: AbstractServletListener.java

/** * Initializes context, {@linkplain #webRoot web root}, locale and runtime environment. * @param servletContextEvent servlet context event */ @Override public void contextInitialized(final ServletContextEvent servletContextEvent){ Latkes.initRuntimeEnv(); LOGGER.info("Initializing the context...."); Latkes.setLocale(Locale.SIMPLIFIED_CHINESE); LOGGER.log(Level.INFO,"Default locale[{0}]",Latkes.getLocale()); final ServletContext servletContext=servletContextEvent.getServletContext(); webRoot=servletContext.getRealPath("") + File.separator; LOGGER.log(Level.INFO,"Server[webRoot={0}, contextPath={1}]",new Object[]{webRoot,servletContextEvent.getServletContext().getContextPath()}); CronService.start(); }
Example 22
From project b3log-solo, under directory /core/src/main/java/org/b3log/solo/.
Source file: SoloServletListener.java

@Override public void contextInitialized(final ServletContextEvent servletContextEvent){ Stopwatchs.start("Context Initialized"); super.contextInitialized(servletContextEvent); Skins.setDirectoryForTemplateLoading("ease"); final PreferenceRepository preferenceRepository=PreferenceRepositoryImpl.getInstance(); final Transaction transaction=preferenceRepository.beginTransaction(); transaction.clearQueryCache(false); try { loadPreference(); if (transaction.isActive()) { transaction.commit(); } } catch ( final Exception e) { if (transaction.isActive()) { transaction.rollback(); } } PluginManager.getInstance().load(); registerEventProcessor(); LOGGER.info("Initialized the context"); Stopwatchs.end(); LOGGER.log(Level.FINE,"Stopwatch: {0}{1}",new Object[]{Strings.LINE_SEPARATOR,Stopwatchs.getTimingStat()}); }
Example 23
From project candlepin, under directory /src/main/java/org/candlepin/guice/.
Source file: CandlepinContextListener.java

@Override public void contextInitialized(final ServletContextEvent event){ super.contextInitialized(event); final ServletContext context=event.getServletContext(); final Registry registry=(Registry)context.getAttribute(Registry.class.getName()); final ResteasyProviderFactory providerFactory=(ResteasyProviderFactory)context.getAttribute(ResteasyProviderFactory.class.getName()); injector=Guice.createInjector(getModules()); processInjector(registry,providerFactory,injector); hornetqListener=injector.getInstance(HornetqContextListener.class); hornetqListener.contextInitialized(injector); pinsetterListener=injector.getInstance(PinsetterContextListener.class); pinsetterListener.contextInitialized(); }
Example 24
From project capedwarf-blue, under directory /appidentity/src/main/java/org/jboss/capedwarf/appidentity/.
Source file: GAEListener.java

public void contextInitialized(ServletContextEvent sce){ this.servletContext=sce.getServletContext(); try { appEngineWebXml=readAppEngineWebXml(); capedwarfConfiguration=readCapedwarfConfig(); } catch ( Exception e) { throw new IllegalArgumentException("Unable to read configuration files",e); } final String appId=appEngineWebXml.getApplication(); InfinispanUtils.initApplicationData(appId); servletContext.setAttribute("org.jboss.capedwarf.appId",appId); }
Example 25
From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/web/init/.
Source file: SafeContextLoaderListener.java

public void contextInitialized(final ServletContextEvent sce){ try { this.delegate.contextInitialized(sce); } catch ( Throwable t) { final String message="SafeContextLoaderListener: \n" + "The Spring ContextLoaderListener we wrap threw on contextInitialized.\n" + "But for our having caught this error, the web application context would not have initialized."; log.error(message,t); System.err.println(message); t.printStackTrace(); ServletContext context=sce.getServletContext(); context.log(message,t); context.setAttribute(CAUGHT_THROWABLE_KEY,t); } }
Example 26
From project caseconductor-platform, under directory /utest-portal-webapp/src/main/java/com/utest/portal/log/.
Source file: LogContextListener.java

public void contextInitialized(final ServletContextEvent contextEvent){ try { RepositorySelector.init(contextEvent.getServletContext()); } catch ( final Exception ex) { System.err.println(ex); } }
Example 27
From project Coffee-Framework, under directory /coffeeframework-core/src/main/java/coffee/servlet/.
Source file: CoffeeUnitializer.java

@Override public void contextDestroyed(ServletContextEvent sce){ ServletContext servletContext=sce.getServletContext(); servletContext.log("[Coffee] Removing Coffee Caches..."); CoffeeApplicationContext applicationContext=Cafeteria.getOrCreateApplicationContext(servletContext); applicationContext.clearCache(); CoffeeBinder.clearCache(); CoffeeLifeCycle.clearCache(); Cafeteria.destroyApplicationContext(applicationContext); System.gc(); servletContext.log("[Coffee] Released memory will be available next time Garbage Collection back to the scene."); }
Example 28
From project collector, under directory /src/main/java/com/ning/metrics/collector/endpoint/setup/.
Source file: SetupJULBridge.java

@Override public void contextInitialized(final ServletContextEvent event){ final Logger rootLogger=LogManager.getLogManager().getLogger(""); final Handler[] handlers=rootLogger.getHandlers(); if (!ArrayUtils.isEmpty(handlers)) { for ( final Handler handler : handlers) { rootLogger.removeHandler(handler); } } SLF4JBridgeHandler.install(); log.info("Assimilated java.util Logging"); }
Example 29
From project commons-j, under directory /src/main/java/nerds/antelax/commons/net/pubsub/.
Source file: PubSubServerContextListener.java

@Override public synchronized void contextInitialized(final ServletContextEvent ctx){ final ServletContext sc=ctx.getServletContext(); final Collection<InetSocketAddress> cluster=sc != null ? NetUtil.hostPortPairsFromString(sc.getInitParameter(CLUSTER_INIT_PARAM),PubSubServer.DEFAULT_ADDRESS.getPort()) : EMPTY; REMOTE_SERVERS.set(Collections2.filter(cluster,Predicates.not(NetUtil.machineLocalSocketAddress()))); if (Iterables.any(cluster,NetUtil.machineLocalSocketAddress())) { server=new PubSubServer(cluster); ctx.getServletContext().log("Starting PubSub server, this machine is part of the cluster definition[" + cluster + "]"); server.start(); } else { server=null; ctx.getServletContext().log("No PubSub server started, remotes available for final clients are " + remoteServers()); } }
Example 30
From project commons-logging, under directory /src/java/org/apache/commons/logging/impl/.
Source file: ServletContextCleaner.java

/** * Invoked when a webapp is undeployed, this tells the LogFactory class to release any logging information related to the current contextClassloader. */ public void contextDestroyed(ServletContextEvent sce){ ClassLoader tccl=Thread.currentThread().getContextClassLoader(); Object[] params=new Object[1]; params[0]=tccl; ClassLoader loader=tccl; while (loader != null) { try { Class logFactoryClass=loader.loadClass("org.apache.commons.logging.LogFactory"); Method releaseMethod=logFactoryClass.getMethod("release",RELEASE_SIGNATURE); releaseMethod.invoke(null,params); loader=logFactoryClass.getClassLoader().getParent(); } catch ( ClassNotFoundException ex) { loader=null; } catch ( NoSuchMethodException ex) { System.err.println("LogFactory instance found which does not support release method!"); loader=null; } catch ( IllegalAccessException ex) { System.err.println("LogFactory instance found which is not accessable!"); loader=null; } catch ( InvocationTargetException ex) { System.err.println("LogFactory instance release method failed!"); loader=null; } } LogFactory.release(tccl); }
Example 31
From project components, under directory /bpm/src/main/java/org/switchyard/component/bpm/task/service/.
Source file: TaskServerServletContextListener.java

/** * {@inheritDoc} */ @Override public void contextDestroyed(ServletContextEvent sce){ try { _server.stop(); } finally { _server=null; } }
Example 32
From project conf4j, under directory /conf4j-webapp/src/main/java/org/conf4j/webapp/listener/.
Source file: Conf4jContextListener.java

@Override public void contextInitialized(ServletContextEvent sce){ System.out.println("**********************************************************************************************************************************"); System.err.println("*"); System.out.println("* Conf4jContextListener#contextInitialized [starting ...]"); System.err.println("*"); System.out.println("**********************************************************************************************************************************"); try { CONF.setValue(scope,EScope.webapp.name()); CONF.initFolders(); if (CONF.getBooleanValue(full_config_dump)) CONF.dumpConf(System.out,false); else if (CONF.getBooleanValue(config_dump)) CONF.dumpConf(System.out,true); } catch ( RuntimeException e) { System.err.println("**********************************************************************************************************************************"); System.err.println("*"); System.err.println("* Conf4jContextListener#contextInitialized [failed]"); System.err.println("*"); System.err.print("* "); System.err.println(e.getMessage()); System.err.println("*"); System.err.println("**********************************************************************************************************************************"); throw e; } System.out.println("**********************************************************************************************************************************"); System.err.println("*"); System.out.println("* Conf4jContextListener#contextInitialized [succeed]"); System.err.println("*"); System.out.println("**********************************************************************************************************************************"); }
Example 33
From project core_1, under directory /deploy/webapp/src/main/java/org/switchyard/deployment/.
Source file: WebApplicationDeployer.java

@Override public void contextInitialized(ServletContextEvent sce){ ServletContext servletContext=sce.getServletContext(); InputStream switchYardConfig=servletContext.getResourceAsStream("WEB-INF/classes/" + AbstractDeployment.SWITCHYARD_XML); if (switchYardConfig != null) { try { _switchyard=new SwitchYard(switchYardConfig); _switchyard.start(); } catch ( IOException e) { _logger.debug("Error deploying SwitchYard within Web Application '" + servletContext.getServletContextName() + "'. SwitchYard not deployed.",e); } } else { _logger.debug("No SwitchYard configuration found at '" + AbstractDeployment.SWITCHYARD_XML + "' in Web Application '"+ servletContext.getServletContextName()+ "'. SwitchYard not deployed."); } }
Example 34
From project crash, under directory /shell/core/src/main/java/org/crsh/plugin/.
Source file: WebPluginLifeCycle.java

public void contextInitialized(ServletContextEvent sce){ ServletContext sc=sce.getServletContext(); String contextPath=sc.getContextPath(); setConfig(System.getProperties()); synchronized (lock) { if (!contextMap.containsKey(contextPath)) { FS cmdFS=new FS().mount(new ServletContextDriver(sc),"/WEB-INF/crash/commands/"); FS confFS=new FS().mount(new ServletContextDriver(sc),"/WEB-INF/crash/"); ClassLoader webAppLoader=Thread.currentThread().getContextClassLoader(); PluginContext context=new PluginContext(new ServiceLoaderDiscovery(webAppLoader),new ServletContextMap(sc),cmdFS,confFS,webAppLoader); contextMap.put(contextPath,context); registered=true; start(context); } } }
Example 35
From project ehour, under directory /eHour-wicketweb/src/main/java/net/rrm/ehour/ui/listener/.
Source file: EnvInitListener.java

@Override public void contextInitialized(ServletContextEvent sce){ String home=getEhourHomePath(sce); if (StringUtils.isBlank(home)) { throw new IllegalArgumentException("EHOUR_HOME environment variable or context parameter not defined - exiting"); } EhourHomeUtil.setEhourHome(home); configureLog4j(); LOG.info("EHOUR_HOME set to " + home); }
Example 36
From project entando-core-engine, under directory /src/main/java/com/agiletec/aps/servlet/.
Source file: StartupListener.java

/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent event){ ServletContext svCtx=event.getServletContext(); String msg=this.getClass().getName() + ": INIT " + svCtx.getServletContextName(); System.out.println(msg); super.contextInitialized(event); msg=this.getClass().getName() + ": INIT DONE " + svCtx.getServletContextName(); System.out.println(msg); }
Example 37
From project exo-training, under directory /gxt-showcase/src/main/java/com/sencha/gxt/examples/resources/server/.
Source file: MusicDataLoader.java

public static void initMusic(ServletContextEvent event){ EntityManager em=EMF.get().createEntityManager(); EntityTransaction tx=em.getTransaction(); tx.begin(); em.persist(makeFolder()); tx.commit(); }
Example 38
From project faces_1, under directory /impl/src/main/java/org/jboss/seam/faces/beanManager/.
Source file: BeanManagerServletContextListener.java

public void contextInitialized(ServletContextEvent sce){ if (beanManager == null) { beanManager=(BeanManager)sce.getServletContext().getAttribute(BeanManager.class.getName()); } if (beanManager == null) { beanManager=(BeanManager)sce.getServletContext().getAttribute("org.jboss.weld.environment.servlet.javax.enterprise.inject.spi.BeanManager"); } if (beanManager == null) { BeanManagerLocator locator=new BeanManagerLocator(); if (locator.isBeanManagerAvailable()) { beanManager=locator.getBeanManager(); } } sce.getServletContext().setAttribute(BEANMANAGER_SERVLETCONTEXT_KEY,beanManager); }
Example 39
From project gatein-wci_1, under directory /wci/src/main/java/org/gatein/wci/api/.
Source file: GateInServletListener.java

public void contextInitialized(ServletContextEvent event){ ServletContext servletContext=event.getServletContext(); String contextPath=servletContext.getContextPath(); ClassLoader classLoader=Thread.currentThread().getContextClassLoader(); GenericWebAppContext webAppContext=new GenericWebAppContext(servletContext,contextPath,classLoader); GateInServletRegistrations.register(webAppContext,"/PortletWrapper"); }
Example 40
From project GCM-Demo, under directory /gcm/samples/gcm-demo-appengine/src/com/google/android/gcm/demo/server/.
Source file: ApiKeyInitializer.java

@Override public void contextInitialized(ServletContextEvent event){ DatastoreService datastore=DatastoreServiceFactory.getDatastoreService(); Key key=KeyFactory.createKey(ENTITY_KIND,ENTITY_KEY); Entity entity; try { entity=datastore.get(key); } catch ( EntityNotFoundException e) { entity=new Entity(key); entity.setProperty(ACCESS_KEY_FIELD,"replace_this_text_by_your_Simple_API_Access_key"); datastore.put(entity); logger.severe("Created fake key. Please go to App Engine admin " + "console, change its value to your API Key (the entity " + "type is '" + ENTITY_KIND + "' and its field to be changed is '"+ ACCESS_KEY_FIELD+ "'), then restart the server!"); } String accessKey=(String)entity.getProperty(ACCESS_KEY_FIELD); event.getServletContext().setAttribute(ATTRIBUTE_ACCESS_KEY,accessKey); }
Example 41
/** * Configure Gitblit from the web.xml, if no configuration has already been specified. * @see ServletContextListener.contextInitialize(ServletContextEvent) */ @Override public void contextInitialized(ServletContextEvent contextEvent){ servletContext=contextEvent.getServletContext(); if (settings == null) { ServletContext context=contextEvent.getServletContext(); WebXmlSettings webxmlSettings=new WebXmlSettings(context); String webProps=context.getRealPath("/WEB-INF/web.properties"); if (!StringUtils.isEmpty(webProps)) { File overrideFile=new File(webProps); if (overrideFile.exists()) { webxmlSettings.applyOverrides(overrideFile); } } File overrideFile=getFileOrFolder("gitblit.properties"); if (!overrideFile.getPath().equals("gitblit.properties")) { webxmlSettings.applyOverrides(overrideFile); } configureContext(webxmlSettings,true); File localScripts=getFileOrFolder(Keys.groovy.scriptsFolder,"groovy"); if (!localScripts.exists()) { File includedScripts=new File(context.getRealPath("/WEB-INF/groovy")); if (!includedScripts.equals(localScripts)) { try { com.gitblit.utils.FileUtils.copy(localScripts,includedScripts.listFiles()); } catch ( IOException e) { logger.error(MessageFormat.format("Failed to copy included Groovy scripts from {0} to {1}",includedScripts,localScripts)); } } } } settingsModel=loadSettingModels(); serverStatus.servletContainer=servletContext.getServerInfo(); }
Example 42
From project guice-jit-providers, under directory /extensions/servlet/src/com/google/inject/servlet/.
Source file: GuiceServletContextListener.java

public void contextInitialized(ServletContextEvent servletContextEvent){ final ServletContext servletContext=servletContextEvent.getServletContext(); GuiceFilter.servletContext=new WeakReference<ServletContext>(servletContext); Injector injector=getInjector(); injector.getInstance(InternalServletModule.BackwardsCompatibleServletContextProvider.class).set(servletContext); servletContext.setAttribute(INJECTOR_NAME,injector); }
Example 43
From project gxa, under directory /atlas-web/src/main/java/uk/ac/ebi/gxa/web/listener/.
Source file: AtlasApplicationListener.java

public void contextDestroyed(ServletContextEvent sce){ SLF4JBridgeHandler.uninstall(); log.info("Shutting down atlas..."); long start=System.currentTimeMillis(); NetcdfDataset.shutdown(); long end=System.currentTimeMillis(); double time=((double)end - start) / 1000; log.info("Atlas shutdown complete in " + time + " s."); }
Example 44
From project harmony, under directory /harmony.common.serviceinterface/src/main/java/org/opennaas/extensions/idb/serviceinterface/topology/registrator/.
Source file: AbstractTopologyRegistrator.java

public synchronized void contextDestroyed(final ServletContextEvent arg0){ if (this.active) { this.shutdown(); this.active=false; if (this.superDomainDistributor != null) { this.superDomainDistributor.stop(); this.superDomainDistributor=null; } for ( final Distributor dist : this.peerDomainDistributors.values()) { dist.stop(); } this.peerDomainDistributors=new HashMap<String,Distributor>(); this.peerDomains=new HashMap<String,DomainInformationType>(); } this.servletContext=null; }
Example 45
From project hoop, under directory /hoop-server/src/main/java/com/cloudera/lib/servlet/.
Source file: ServerWebApp.java

/** * Initializes the <code>ServletContextListener</code> which initializes the Server. * @param event servelt context event. */ public void contextInitialized(ServletContextEvent event){ try { init(); } catch ( ServerException ex) { event.getServletContext().log("ERROR: " + ex.getMessage()); throw new RuntimeException(ex); } }
Example 46
From project huiswerk, under directory /print/zxing-1.6/zxingorg/src/com/google/zxing/web/.
Source file: DecodeEmailListener.java

public void contextInitialized(ServletContextEvent event){ ServletContext context=event.getServletContext(); String emailAddress=context.getInitParameter("emailAddress"); String emailPassword=context.getInitParameter("emailPassword"); if (emailAddress == null || emailPassword == null) { throw new IllegalArgumentException("emailAddress or emailPassword not specified"); } Authenticator emailAuthenticator=new EmailAuthenticator(emailAddress,emailPassword); emailTimer=new Timer("Email decoder timer",true); emailTimer.schedule(new DecodeEmailTask(emailAddress,emailAuthenticator),0L,EMAIL_CHECK_INTERVAL); }
Example 47
From project iosched_3, under directory /gcm-server/src/com/google/android/apps/iosched/gcm/server/.
Source file: ApiKeyInitializer.java

@Override public void contextInitialized(ServletContextEvent event){ DatastoreService datastore=DatastoreServiceFactory.getDatastoreService(); Key key=KeyFactory.createKey(ENTITY_KIND,ENTITY_KEY); Entity entity; try { entity=datastore.get(key); } catch ( EntityNotFoundException e) { entity=new Entity(key); entity.setProperty(ACCESS_KEY_FIELD,FAKE_API_KEY); datastore.put(entity); logger.severe("Created fake key. Please go to App Engine admin " + "console, change its value to your API Key (the entity " + "type is '" + ENTITY_KIND + "' and its field to be changed is '"+ ACCESS_KEY_FIELD+ "'), then restart the server!"); } String accessKey=(String)entity.getProperty(ACCESS_KEY_FIELD); event.getServletContext().setAttribute(ATTRIBUTE_ACCESS_KEY,accessKey); }
Example 48
From project ipdburt, under directory /iddb-web/src/main/java/iddb/quartz/web/.
Source file: QuartzContextListener.java

@Override public void contextInitialized(ServletContextEvent sce){ log.debug("Init Quartz Engine"); try { scheduler=StdSchedulerFactory.getDefaultScheduler(); log.debug("Loading jobs"); JobManager manager=new JobManager(); for ( Entry<JobDetail,Trigger> job : manager.getJobs().entrySet()) { scheduler.scheduleJob(job.getKey(),job.getValue()); } log.debug("Starting scheduller"); scheduler.start(); } catch ( SchedulerException e) { log.error(e.getMessage()); } }
Example 49
From project Ivory, under directory /prism/src/main/java/org/apache/ivory/listener/.
Source file: ContextStartupListener.java

@Override public void contextInitialized(ServletContextEvent sce){ showStartupInfo(); LOG.info("Initializing startup properties ..."); StartupProperties.get(); LOG.info("Initializing runtime properties ..."); RuntimeProperties.get(); try { startupServices.initialize(); ConfigurationStore.get(); } catch ( IvoryException e) { throw new RuntimeException(e); } }
Example 50
From project james-hupa, under directory /server/src/main/java/org/apache/hupa/server/guice/.
Source file: GuiceServletConfig.java

@Override public void contextInitialized(ServletContextEvent servletContextEvent){ servletContextRealPath=servletContextEvent.getServletContext().getRealPath("/"); try { Class<?> mockConstants=Class.forName("org.apache.hupa.server.mock.MockConstants"); demoProperties=(Properties)mockConstants.getField("mockProperties").get(null); demoHostName=demoProperties.getProperty("IMAPServerAddress"); } catch ( Exception noDemoAvailable) { } super.contextInitialized(servletContextEvent); }
Example 51
From project jAPS2, under directory /src/com/agiletec/aps/servlet/.
Source file: StartupListener.java

/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent event){ ServletContext svCtx=event.getServletContext(); String msg=this.getClass().getName() + ": INIT " + svCtx.getServletContextName(); System.out.println(msg); super.contextInitialized(event); msg=this.getClass().getName() + ": INIT DONE " + svCtx.getServletContextName(); System.out.println(msg); }
Example 52
From project JCL, under directory /JCL2/core/src/main/java/org/xeustechnologies/jcl/web/.
Source file: JclContextLoaderListener.java

/** * The context is initialised from xml on web application's deploy-time * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent sce){ String jclConfig=sce.getServletContext().getInitParameter(JCL_CONTEXT); contextLoader=new XmlContextLoader(jclConfig); contextLoader.addPathResolver(new WebAppPathResolver(sce.getServletContext())); contextLoader.loadContext(); }
Example 53
From project jclouds-chef, under directory /demos/gae/src/main/java/org/jclouds/chef/demo/config/.
Source file: GuiceServletConfig.java

@Override public void contextInitialized(ServletContextEvent servletContextEvent){ try { logger.debug("starting initialization"); properties=InitParamsToProperties.INSTANCE.apply(servletContextEvent.getServletContext()); node=getContextAttribute(servletContextEvent,CHEF_NODE); clientConnection=getContextAttribute(servletContextEvent,CHEF_SERVICE_CLIENT); super.contextInitialized(servletContextEvent); logger.debug("initialized"); } catch ( RuntimeException e) { logger.error(e,"error initializing"); throw e; } }
Example 54
From project jdonframework, under directory /src/com/jdon/container/startup/.
Source file: ServletContainerListener.java

public void contextInitialized(ServletContextEvent event){ ServletContext scontext=event.getServletContext(); ServletContextWrapper context=new ServletContextWrapper(scontext); css.initialized(context); Debug.logVerbose("[JdonFramework]contextInitialized",module); String app_configFile=context.getInitParameter(AppConfigureCollection.CONFIG_NAME); if (UtilValidate.isEmpty(app_configFile)) { Debug.logWarning("[JdonFramework] not locate a configuration in web.xml :",module); css.prepare("",context); } else { String[] configs=StringUtil.split(app_configFile,","); for (int i=0; i < configs.length; i++) { Debug.logVerbose("[JdonFramework] locate a configuration in web.xml :" + configs[i],module); css.prepare(configs[i],context); } } Debug.logVerbose("[JdonFramework]ServletContainerListener is preparing...",module); logger.info("Jdon Framework is ready .."); }
Example 55
From project karaf, under directory /demos/web/src/main/java/org/apache/karaf/web/.
Source file: WebAppListener.java

public void contextInitialized(ServletContextEvent sce){ try { System.err.println("contextInitialized"); String root=new File(sce.getServletContext().getRealPath("/") + "/WEB-INF/karaf").getAbsolutePath(); System.err.println("Root: " + root); System.setProperty("karaf.home",root); System.setProperty("karaf.base",root); System.setProperty("karaf.data",root + "/data"); System.setProperty("karaf.history",root + "/data/history.txt"); System.setProperty("karaf.instances",root + "/instances"); System.setProperty("karaf.startLocalConsole","false"); System.setProperty("karaf.startRemoteShell","true"); System.setProperty("karaf.lock","false"); main=new Main(new String[0]); main.launch(); } catch ( Exception e) { main=null; e.printStackTrace(); } }
Example 56
From project kernel_1, under directory /exo.kernel.container/src/main/java/org/exoplatform/container/web/.
Source file: PortalContainerConfigOwner.java

public void contextInitialized(ServletContextEvent event){ ServletContext ctx=event.getServletContext(); try { EnvSpecific.initThreadEnv(ctx); PortalContainer.addInitTask(ctx,new PortalContainer.RegisterTask()); } finally { EnvSpecific.cleanupThreadEnv(ctx); } }
Example 57
From project lilith, under directory /logback/shutdown-context-listener/src/main/java/de/huxhorn/lilith/logback/servlet/.
Source file: LogbackShutdownServletContextListener.java

public void contextInitialized(ServletContextEvent sce){ ServletContext c=sce.getServletContext(); if (c != null) { String debugString=c.getInitParameter(LOGBACK_SHUTDOWN_DEBUG); if (debugString != null) { debug=Boolean.parseBoolean(debugString); } } }
Example 58
From project logback, under directory /logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/.
Source file: ContextDetachingSCL.java

public void contextDestroyed(ServletContextEvent servletContextEvent){ String loggerContextName=null; try { Context ctx=JNDIUtil.getInitialContext(); loggerContextName=(String)JNDIUtil.lookup(ctx,JNDI_CONTEXT_NAME); } catch ( NamingException ne) { } if (loggerContextName != null) { System.out.println("About to detach context named " + loggerContextName); ContextSelector selector=ContextSelectorStaticBinder.getSingleton().getContextSelector(); LoggerContext context=selector.detachLoggerContext(loggerContextName); if (context != null) { Logger logger=context.getLogger(Logger.ROOT_LOGGER_NAME); logger.warn("Stopping logger context " + loggerContextName); context.stop(); } else { System.out.println("No context named " + loggerContextName + " was found."); } } }
Example 59
From project logback-audit, under directory /audit-server/src/main/java/ch/qos/logback/audit/server/.
Source file: ServletContextListener.java

public void contextInitialized(ServletContextEvent sce){ logger.debug("ContextListener.contextInitialized called"); ServletContext servletContext=sce.getServletContext(); String portStr=servletContext.getInitParameter(AuditServerConstants.PORT_INIT_PARAM); if (portStr == null || "".equals(portStr)) { logger.error("The PORT argument was not set in web.xml. Aborting"); return; } int port=Integer.parseInt(portStr); AuditEventShaper auditEventShaper; String rdbmsDialect=servletContext.getInitParameter(AuditServerConstants.RDBMS_DIALECT_INIT_PARAM); if (AuditServerConstants.SQLSERVER_2005_DIALECT_VALUE.equalsIgnoreCase(rdbmsDialect)) { logger.info("Will shape events accord to SQL Server 2005 requirements"); auditEventShaper=new SQLServerAEShaper(); } else { auditEventShaper=new NullAEShaper(); } applicationName=servletContext.getServletContextName(); logger.debug("applicationName={}",applicationName); Configuration cfg=Persistor.createConfiguration(); ResourceUtil.setApplicationName(applicationName); Properties props=ResourceUtil.getProps(applicationName + "/hibernate.properties"); cfg.setProperties(props); Persistor.setConfiguration(cfg,lock); auditServer=new AuditServer(port,new AuditEventPersistor(auditEventShaper)); auditServer.start(); servletContext.setAttribute(AuditServerConstants.AUDIT_SERVER_REFERENCE,auditServer); }
Example 60
From project lor-jamwiki, under directory /jamwiki-web/src/main/java/org/jamwiki/servlets/.
Source file: JAMWikiListener.java

/** * Initialize the database connection pool and disk cache. * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent arg0){ if (!WikiUtil.isFirstUse()) { WikiDatabase.initialize(); WikiCache.initialize(); } }
Example 61
From project lyo.core, under directory /OSLC4JRegistry/src/org/eclipse/lyo/oslc4j/core/servlet/.
Source file: ServletListener.java

@Override public void contextDestroyed(final ServletContextEvent servletContextEvent){ if (serviceProviderIdentifier != null) { try { ServiceProviderCatalogSingleton.deregisterServiceProvider(serviceProviderIdentifier); } catch ( final Exception exception) { logger.log(Level.SEVERE,"Unable to deregister with service provider catalog",exception); } finally { serviceProviderIdentifier=null; } } }
Example 62
From project lyo.rio, under directory /org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/store/.
Source file: ShutdownListener.java

public void contextDestroyed(ServletContextEvent arg0){ System.out.println("Shutting down RDF Store"); try { RioStore.shutdown(); } catch ( RioServerException e) { e.printStackTrace(); } }
Example 63
From project lyo.server, under directory /org.eclipse.lyo.samples.sharepoint/src/org/eclipse/lyo/samples/sharepoint/store/.
Source file: ShutdownListener.java

public void contextDestroyed(ServletContextEvent arg0){ System.out.println("Shutting down RDF Store"); try { ShareStore.shutdown(); } catch ( ShareServerException e) { e.printStackTrace(); } }
Example 64
From project mapmaker, under directory /src/main/java/org/jason/mapmaker/server/servlet/.
Source file: PrepareScanningContextListener.java

public void contextInitialized(ServletContextEvent servletContextEvent){ ServletContext servletContext=servletContextEvent.getServletContext(); String param=servletContext.getInitParameter(PRELOAD_CLASSES_PARAMETER); String[] preloadClasses=param.split("[\\s,;]+"); for ( String className : preloadClasses) { try { Class<?> c=Class.forName(className); } catch ( ClassNotFoundException e) { } } ClassLoader cl=Thread.currentThread().getContextClassLoader(); if (cl instanceof URLClassLoader) { Thread.currentThread().setContextClassLoader(new ClassLoaderWrapper((URLClassLoader)cl,ClassLoader.getSystemClassLoader())); } }
Example 65
From project meteo, under directory /core/src/main/java/com/ning/metrics/meteo/server/.
Source file: SetupJULBridge.java

@Override public void contextInitialized(final ServletContextEvent event){ final Logger rootLogger=LogManager.getLogManager().getLogger(""); final Handler[] handlers=rootLogger.getHandlers(); if (!ArrayUtils.isEmpty(handlers)) { for ( final Handler handler : handlers) { rootLogger.removeHandler(handler); } } SLF4JBridgeHandler.install(); log.info("Assimilated java.util Logging"); }
Example 66
From project ning-service-skeleton, under directory /core/src/main/java/com/ning/jetty/core/listeners/.
Source file: SetupJULBridge.java

@Override public void contextInitialized(final ServletContextEvent event){ final Logger rootLogger=LogManager.getLogManager().getLogger(""); final Handler[] handlers=rootLogger.getHandlers(); if (!ArrayUtils.isEmpty(handlers)) { for ( final Handler handler : handlers) { rootLogger.removeHandler(handler); } } SLF4JBridgeHandler.install(); }
Example 67
From project nsi-minlog, under directory /shared/src/main/java/com/trifork/stamdata/util/.
Source file: Log4jInitServletListener.java

@Override public void contextInitialized(ServletContextEvent sce){ String configDir=System.getProperty(JBOSS_SERVER_CONFIG_URL_PROPERTY); String file=sce.getServletContext().getInitParameter(LOG4J_CONFIG_FILE_PARAM); if (file != null) { String fullConfigFilePath=""; if (file.startsWith("/")) { fullConfigFilePath=file; } else { if (configDir != null) { configDir=configDir.substring(configDir.indexOf(":") + 1); fullConfigFilePath=configDir + file; } else { System.err.println("ERROR: System property '" + JBOSS_SERVER_CONFIG_URL_PROPERTY + "' must be defined in order for log4j to be configured using a relative path for servlet param '"+ LOG4J_CONFIG_FILE_PARAM+ "'"); return; } } try { Log4jRepositorySelector.init(sce.getServletContext(),fullConfigFilePath); } catch ( ServletException e) { throw new RuntimeException(e); } } else { System.err.println("ERROR: Servlet init parameter '" + LOG4J_CONFIG_FILE_PARAM + "' must be defined in web.xml in order for log4j to be configured for this web app"); } }
Example 68
From project nuxeo-chemistry, under directory /nuxeo-opencmis-bindings/src/main/java/org/nuxeo/ecm/core/opencmis/bindings/.
Source file: NuxeoCmisContextListener.java

@Override public void contextDestroyed(ServletContextEvent sce){ CmisServiceFactory factory=(CmisServiceFactory)sce.getServletContext().getAttribute(CmisRepositoryContextListener.SERVICES_FACTORY); if (factory != null) { factory.destroy(); } }
Example 69
From project nuxeo-opensocial, under directory /nuxeo-opensocial-server/src/main/java/org/nuxeo/opensocial/servlet/.
Source file: ContextListenerDelayer.java

@Override public void contextInitialized(ServletContextEvent sce){ delayedEvent=sce; if (hasBeenActivated) { delayed.contextInitialized(sce); } }
Example 70
From project openclaws, under directory /cat/WEB-INF/src/edu/rit/its/claws/cat/.
Source file: CatContextListener.java

/** * Event handelr for when the CAT servlet context is initialized. * @param e the context event */ public void contextInitialized(ServletContextEvent e){ try { con=e.getServletContext(); String keyFileName=con.getInitParameter("KeyStoreFile"); String keyFilePass=con.getInitParameter("KeyStorePassword"); File f=new File(keyFileName); InputStream ksin=new FileInputStream(f); CatSecureSocketFactory.init(ksin,keyFilePass); Protocol p=new Protocol("https",(ProtocolSocketFactory)(new CatSecureProtocolSocketFactory()),443); Protocol.registerProtocol("https",p); Client.init(con.getInitParameter("LdapServer"),con.getInitParameter("LdapPrincipalFormat")); try { Context initContext=new InitialContext(); String base="java:comp/env/subscriptionFinders/"; NamingEnumeration ne=initContext.list(base); while (ne.hasMore()) { NameClassPair ncp=(NameClassPair)ne.next(); SubscriptionFinder sf=(SubscriptionFinder)initContext.lookup(base + ncp.getName()); log.debug("Loaded " + sf.getClass().getName() + " "+ ncp.getName()); } } catch ( NameNotFoundException x) { log.info("Error loading SubscriptionFinders",x); } catch ( Exception x) { log.error("Error loading SubscriptionFinders",x); throw x; } if (con.getInitParameter("FilterReloadInterval") != null) { XSLTranslator.setReloadInterval(Long.parseLong(con.getInitParameter("FilterReloadInterval")) * 1000); } } catch ( Exception e1) { log.fatal("Error initializing CAT",e1); throw new Error(e1); } }
Example 71
From project OpenMEAP, under directory /server-side/openmeap-shared-serverside/src/com/openmeap/web/servlet/.
Source file: Log4JConfiguratorListener.java

@Override public void contextInitialized(ServletContextEvent arg0){ BasicConfigurator.configure(); ServletContext servletContext=arg0.getServletContext(); String xmlLoc=servletContext.getInitParameter("openmeap-log4j-xml"); if (xmlLoc == null) { return; } try { Resource res=new ClassPathResource(xmlLoc); DOMConfigurator.configure(XmlUtils.getDocument(res.getInputStream()).getDocumentElement()); } catch ( Exception ioe) { servletContext.log("The configuration failed.",ioe); } }
Example 72
From project org.ops4j.pax.web, under directory /pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/.
Source file: HttpServiceContext.java

@Override protected void doStart() throws Exception { if (servletContainerInitializers != null) { for ( final Entry<ServletContainerInitializer,Set<Class<?>>> entry : servletContainerInitializers.entrySet()) { ServletContextListener listener=new ServletContextListener(){ ServletContainerInitializer sci=entry.getKey(); Set<Class<?>> clazzes=entry.getValue(); @Override public void contextInitialized( ServletContextEvent sce){ try { sci.onStartup(clazzes,_scontext); } catch ( ServletException ignore) { LOG.error("Startup issue with ServletContainerInitializer",ignore); } } @Override public void contextDestroyed( ServletContextEvent sce){ } } ; this.addEventListener(listener); } } this.setVirtualHosts(virtualHosts.toArray(EMPTY_STRING_ARRAY)); this.setConnectorNames(connectors.toArray(EMPTY_STRING_ARRAY)); if (jettyWebXmlURL != null) { DOMJettyWebXmlParser jettyWebXmlParser=new DOMJettyWebXmlParser(); jettyWebXmlParser.parse(this,jettyWebXmlURL.openStream()); } super.doStart(); if (m_attributes != null) { for ( Map.Entry<String,?> attribute : m_attributes.entrySet()) { _scontext.setAttribute(attribute.getKey(),attribute.getValue()); } } LOG.debug("Started servlet context for http context [" + m_httpContext + "]"); }
Example 73
From project platform_2, under directory /src/eu/cassandra/server/threads/.
Source file: ExecutorContextListener.java

public void contextInitialized(ServletContextEvent arg0){ ServletContext context=arg0.getServletContext(); int nr_executors=2; ThreadFactory daemonFactory=new DaemonThreadFactory(); try { nr_executors=Integer.parseInt(context.getInitParameter("nr-executors")); } catch ( NumberFormatException ignore) { } if (nr_executors <= 1) { executor=Executors.newSingleThreadExecutor(daemonFactory); } else { executor=Executors.newFixedThreadPool(nr_executors,daemonFactory); } context.setAttribute("MY_EXECUTOR",executor); }
Example 74
From project pluto, under directory /pluto-portal-driver/src/main/java/org/apache/pluto/driver/.
Source file: PortalStartupListener.java

/** * Receives the startup notification and subsequently starts up the portal driver. The following are done in this order: <ol> <li>Retrieve the ResourceConfig File</li> <li>Parse the ResourceConfig File into ResourceConfig Objects</li> <li>Create a Portal Context</li> <li>Create the ContainerServices implementation</li> <li>Create the Portlet Container</li> <li>Initialize the Container</li> <li>Bind the configuration to the ServletContext</li> <li>Bind the container to the ServletContext</li> <ol> * @param event the servlet context event. */ public void contextInitialized(ServletContextEvent event){ LOG.info("Starting up Pluto Portal Driver. . ."); final ServletContext servletContext=event.getServletContext(); PortalStartupListener.servletContext=servletContext; super.contextInitialized(event); WebApplicationContext springContext=null; try { springContext=(WebApplicationContext)servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } catch ( RuntimeException ex) { String msg="Problem getting Spring context: " + ex.getMessage(); LOG.error(msg,ex); throw ex; } LOG.debug(" [1a] Loading DriverConfiguration. . . "); DriverConfiguration driverConfiguration=(DriverConfiguration)springContext.getBean("DriverConfiguration"); LOG.debug(" [1b] Registering DriverConfiguration. . ."); servletContext.setAttribute(DRIVER_CONFIG_KEY,driverConfiguration); LOG.debug(" [2a] Loading Optional AdminConfiguration. . ."); AdminConfiguration adminConfiguration=(AdminConfiguration)springContext.getBean("AdminConfiguration"); if (adminConfiguration != null) { LOG.debug(" [2b] Registering Optional AdminConfiguration"); servletContext.setAttribute(ADMIN_CONFIG_KEY,adminConfiguration); } else { LOG.info("Optional AdminConfiguration not found. Ignoring."); } LOG.info("Initializing Portlet Container. . ."); LOG.debug(" [1] Creating portlet container..."); PortletContainer container=(PortletContainer)springContext.getBean("PortletContainer"); servletContext.setAttribute(CONTAINER_KEY,container); LOG.info("Pluto portlet container started."); LOG.info("********** Pluto Portal Driver Started **********\n\n"); }
Example 75
From project qi4j-libraries, under directory /servlet/src/main/java/org/qi4j/library/servlet/lifecycle/.
Source file: AbstractQi4jServletBootstrap.java

public final void contextInitialized(ServletContextEvent sce){ try { ServletContext context=sce.getServletContext(); LOGGER.trace("Assembling Application"); qi4j=new Energy4Java(); applicationModel=qi4j.newApplicationModel(this); LOGGER.trace("Instanciating and activating Application"); application=applicationModel.newInstance(qi4j.api()); api=qi4j.api(); beforeApplicationActivation(application); application.activate(); afterApplicationActivation(application); LOGGER.trace("Storing Application in ServletContext"); context.setAttribute(Qi4jServletSupport.APP_IN_CTX,application); } catch ( Exception ex) { if (application != null) { try { application.passivate(); } catch ( Exception ex1) { LOGGER.warn("Application not null and could not passivate it.",ex1); } } throw new InvalidApplicationException("Unexpected error during ServletContext initialization, see previous log for errors.",ex); } }
Example 76
From project Red5, under directory /src/org/red5/logging/.
Source file: ContextLoggingListener.java

public void contextDestroyed(ServletContextEvent event){ System.out.println("Context destroying..."); String contextName=pathToName(event); ContextSelector selector=Red5LoggerFactory.getContextSelector(); LoggerContext context=selector.detachLoggerContext(contextName); if (context != null) { Logger logger=context.getLogger(Logger.ROOT_LOGGER_NAME); logger.debug("Shutting down context {}",contextName); context.reset(); } else { System.err.printf("No context named %s was found",contextName); } }
Example 77
From project red5-mavenized, under directory /red5_base/src/main/java/org/red5/logging/.
Source file: ContextLoggingListener.java

public void contextDestroyed(ServletContextEvent event){ System.out.println("Context destroying..."); String contextName=pathToName(event); ContextSelector selector=StaticLoggerBinder.getSingleton().getContextSelector(); LoggerContext context=selector.detachLoggerContext(contextName); if (context != null) { Logger logger=context.getLogger(LoggerContext.ROOT_NAME); logger.debug("Shutting down context {}",contextName); context.reset(); } else { System.err.printf("No context named %s was found",contextName); } }
Example 78
From project red5-server, under directory /src/org/red5/logging/.
Source file: ContextLoggingListener.java

public void contextDestroyed(ServletContextEvent event){ System.out.println("Context destroying..."); String contextName=pathToName(event); ContextSelector selector=Red5LoggerFactory.getContextSelector(); LoggerContext context=selector.detachLoggerContext(contextName); if (context != null) { Logger logger=context.getLogger(Logger.ROOT_LOGGER_NAME); logger.debug("Shutting down context {}",contextName); context.reset(); } else { System.err.printf("No context named %s was found",contextName); } }
Example 79
From project rj-servi, under directory /de.walware.rj.servi.webapp/src/de/walware/rj/servi/webapp/.
Source file: EAppEnvDummy.java

public void contextDestroyed(final ServletContextEvent sce){ try { for ( final IDisposable listener : this.stopListeners) { listener.dispose(); } } finally { this.stopListeners.clear(); this.context=null; } }
Example 80
From project scooter, under directory /source/src/com/scooterframework/admin/.
Source file: WebApplicationStartListener.java

/** * <p>Initializes context. Specifically it starts up the application through <tt>ApplicationConfig.configInstanceForWeb(rootPath, contextName).startApplication()</tt>.</p> <p>The <tt>rootPath</tt> is derived from the real path of the servlet context. </p> * @param ce ServletContextEvent */ public void contextInitialized(ServletContextEvent ce){ ServletContext servletContext=ce.getServletContext(); String contextName=""; String realPath=null; try { File rp=new File(servletContext.getRealPath("")); realPath=rp.getCanonicalPath(); contextName=getContextName(realPath); String appName=System.getProperty("app.name"); String jettyHome=System.getProperty("jetty.home"); if (jettyHome == null || (jettyHome != null && contextName.equals(appName))) { ApplicationConfig ac=ApplicationConfig.configInstanceForWeb(realPath,contextName); ac.startApplication(); } } catch ( Exception ex) { ex.printStackTrace(); String errorMessage="Failed to detect root path and " + "context name from \"" + realPath + "\": "+ ex.getMessage(); System.err.println(errorMessage); System.out.println("Stop initializtion process. Exit now ..."); } }
Example 81
From project sensei, under directory /sensei-core/src/main/java/com/senseidb/servlet/.
Source file: SenseiConfigServletContextListener.java

@Override public void contextInitialized(ServletContextEvent ctxEvt){ ServletContext ctx=ctxEvt.getServletContext(); String confFileName=ctx.getInitParameter(SENSEI_CONF_FILE_PARAM); File confFile=null; if (confFileName == null) { String confDirName=ctx.getInitParameter(SENSEI_CONF_DIR_PARAM); if (confDirName != null) { confFile=new File(confDirName,"sensei.properties"); } } else { confFile=new File(confFileName); } if (confFile != null) { try { PropertiesConfiguration conf=new PropertiesConfiguration(); conf.setDelimiterParsingDisabled(true); conf.load(confFile); ctx.setAttribute(SENSEI_CONF_OBJ,conf); } catch ( ConfigurationException e) { logger.error(e.getMessage(),e); } } else { logger.warn("configuration is not set."); } }
Example 82
From project showcase, under directory /src/main/java/org/richfaces/demo/push/.
Source file: AbstractCapabilityInitializer.java

public void contextInitialized(ServletContextEvent sce){ try { initializeCapability(); correctlyInitialized=true; } catch ( Exception e) { throw new IllegalStateException(e); } }
Example 83
From project sisu-goodies, under directory /servlet/src/main/java/org/sonatype/sisu/goodies/servlet/sisu/.
Source file: SisuServletContextListener.java

@Override public void contextInitialized(final ServletContextEvent event){ checkNotNull(event); servletContext=event.getServletContext(); injector=(Injector)event.getServletContext().getAttribute(INJECTOR_KEY); super.contextInitialized(event); }
Example 84
From project sisu-guice, under directory /extensions/servlet/src/com/google/inject/servlet/.
Source file: GuiceServletContextListener.java

public void contextInitialized(ServletContextEvent servletContextEvent){ final ServletContext servletContext=servletContextEvent.getServletContext(); GuiceFilter.servletContext=new WeakReference<ServletContext>(servletContext); Injector injector=getInjector(); injector.getInstance(InternalServletModule.BackwardsCompatibleServletContextProvider.class).set(servletContext); servletContext.setAttribute(INJECTOR_NAME,injector); }
Example 85
From project smart-cms, under directory /webservice-modules/webservice/src/main/java/com/smartitengineering/cms/ws/.
Source file: InitializerContextListener.java

@Override public void contextInitialized(ServletContextEvent sce){ Initializer.init(); Configuration config=HBaseConfigurationFactory.getConfigurationInstance(); try { new HBaseTableGenerator(ConfigurationJsonParser.getConfigurations(getClass().getClassLoader().getResourceAsStream("com/smartitengineering/cms/spi/impl/schema.json")),config,false).generateTables(); } catch ( MasterNotRunningException ex) { logger.error("Master could not be found!",ex); } catch ( Exception ex) { logger.error("Could not create table!",ex); } }
Example 86
From project SOAj, under directory /soaj-core/src/main/java/info/soaj/core/lr/.
Source file: SjcBasicListener.java

/** * @see ServletContextListener#contextInitialized(ServletContextEvent) */ @Override public void contextInitialized(final ServletContextEvent contextEvent){ if (null != contextEvent) { SjcGeneralStoreUtil.setConfigurationFileName(SjcConstant.SOAJ_PLUGIN_CONFIG_XML); } final ActivatePluginsIC pluginActivationIC=new ActivatePluginsIC(); pluginActivationIC.process(); return; }
Example 87
From project sparqled, under directory /recommendation-servlet/src/main/java/org/sindice/analytics/servlet/.
Source file: AssistedSparqlEditorListener.java

@Override public void contextInitialized(ServletContextEvent sce){ super.contextInitialized(sce); final ServletContext context=sce.getServletContext(); logger.info("initializing ASE context"); XMLConfiguration config=(XMLConfiguration)sce.getServletContext().getAttribute("config"); context.setAttribute(RECOMMENDER_WRAPPER + RANKING_CONFIGURATION,createRankingConfigFile()); final String datasetLabelDef=getParameterWithLogging(config,RECOMMENDER_WRAPPER + "." + DATASET_LABEL_DEF,DataGraphSummaryVocab.DATASET_LABEL_DEF.toString()); context.setAttribute(RECOMMENDER_WRAPPER + DATASET_LABEL_DEF,datasetLabelDef); final String domainUriPrefix=getParameterWithLogging(config,RECOMMENDER_WRAPPER + "." + DOMAIN_URI_PREFIX,DataGraphSummaryVocab.DOMAIN_URI_PREFIX); context.setAttribute(RECOMMENDER_WRAPPER + DOMAIN_URI_PREFIX,domainUriPrefix); final String gsg=getParameterWithLogging(config,RECOMMENDER_WRAPPER + "." + GRAPH_SUMMARY_GRAPH,DataGraphSummaryVocab.GRAPH_SUMMARY_GRAPH); context.setAttribute(RECOMMENDER_WRAPPER + GRAPH_SUMMARY_GRAPH,gsg); final String backend=getParameterWithLogging(config,RECOMMENDER_WRAPPER + "." + BACKEND,BackendType.HTTP.toString()); context.setAttribute(RECOMMENDER_WRAPPER + BACKEND,backend); final String[] backendArgs=getParametersWithLogging(config,RECOMMENDER_WRAPPER + "." + BACKEND_ARGS,new String[]{"http://sparql.sindice.com/sparql"}); context.setAttribute(RECOMMENDER_WRAPPER + BACKEND_ARGS,backendArgs); final String pagination=getParameterWithLogging(config,RECOMMENDER_WRAPPER + "." + PAGINATION,Integer.toString(SesameBackend.LIMIT)); context.setAttribute(RECOMMENDER_WRAPPER + PAGINATION,Integer.valueOf(pagination)); final String limit=getParameterWithLogging(config,RECOMMENDER_WRAPPER + "." + LIMIT,"0"); context.setAttribute(RECOMMENDER_WRAPPER + LIMIT,Integer.valueOf(limit)); final String[] classAttributes=getParametersWithLogging(config,RECOMMENDER_WRAPPER + "." + CLASS_ATTRIBUTES,new String[]{AnalyticsClassAttributes.DEFAULT_CLASS_ATTRIBUTE}); context.setAttribute(RECOMMENDER_WRAPPER + CLASS_ATTRIBUTES,classAttributes); final String useMemcached=getParameterWithLogging(config,"USE_MEMCACHED","false"); final String memcachedHost=getParameterWithLogging(config,"MEMCACHED_HOST","localhost"); final String memcachedPort=getParameterWithLogging(config,"MEMCACHED_PORT","11211"); if (Boolean.parseBoolean(useMemcached)) { try { final List<InetSocketAddress> addresses=AddrUtil.getAddresses(memcachedHost + ":" + memcachedPort); wrapper=new MemcachedClientWrapper(new MemcachedClient(addresses)); sce.getServletContext().setAttribute(MemcachedClientWrapper.class.getName(),wrapper); } catch ( IOException e) { logger.error("Could not initialize memcached !!!",e); } } }
Example 88
From project spicy-stonehenge, under directory /QuoteDaemon/src/main/java/nl/tudelft/ewi/st/atlantis/tudelft/daemons/quotedaemon/.
Source file: AppStartUp.java

public void contextDestroyed(ServletContextEvent arg0){ try { scheduler.shutdown(); scheduler=null; } catch ( SchedulerException e) { e.printStackTrace(); } }
Example 89
From project spring-dbunit, under directory /spring-dbunit-servlet/src/main/java/com/excilys/ebi/spring/dbunit/servlet/.
Source file: DataLoaderListener.java

public void contextInitialized(ServletContextEvent sce){ context=getWebApplicationContext(sce.getServletContext()); try { configuration=configurationProcessor.getConfiguration(context); dataLoader.execute(context,configuration,Phase.SETUP); } catch ( Exception e) { LOGGER.error("Error while initializing DbUnit data",e); throw new ExceptionInInitializerError(e); } }
Example 90
From project tennera, under directory /webgettext/src/main/java/org/fedorahosted/tennera/webgettext/.
Source file: I18nServletContextListener.java

public void contextInitialized(ServletContextEvent servletContextEvent){ ServletContext servletContext=servletContextEvent.getServletContext(); JspApplicationContext jspContext=JspFactory.getDefaultFactory().getJspApplicationContext(servletContext); jspContext.addELResolver(new BundleResolver()); log.info("BundleResolver registered: " + servletContext.getContextPath()); }
Example 91
From project tesb-rt-se, under directory /sam/sam-server-war/src/main/java/org/talend/esb/sam/server/listener/.
Source file: DerbyStarterContextListener.java

public void contextDestroyed(ServletContextEvent arg0){ if (startDerby) { try { server.shutdown(); } catch ( Exception e) { e.printStackTrace(); } } }
Example 92
From project tools4j, under directory /support/support-web/src/main/java/org/deephacks/tools4j/support/web/jpa/.
Source file: ServletEntityManagerLifecycle.java

@Override public void contextInitialized(ServletContextEvent event){ ServletContext sc=event.getServletContext(); String unitName=sc.getInitParameter(PERSISTENCE_UNIT_NAME_PARAM); EntityManagerFactory factory=EntityManagerFactoryCreator.createFactory(unitName); event.getServletContext().setAttribute(PERSISTENCE_UNIT_NAME_PARAM,factory); }
Example 93
From project twitstreet, under directory /src/com/twitstreet/main/.
Source file: TSServletConfig.java

public void contextInitialized(ServletContextEvent servletContextEvent){ System.setProperty("twitter4j.loggerFactory","twitter4j.internal.logging.NullLoggerFactory"); Injector injector=getInjector(); Twitstreet twitStreet=injector.getInstance(Twitstreet.class); ServletContext servletContext=servletContextEvent.getServletContext(); twitStreet.setServletContext(servletContext); twitStreet.setInjector(injector); servletContext.setAttribute(Injector.class.getName(),injector); String fileLocation=System.getProperty("user.home") + "/.twitstreet/twitstreet.properties"; File f=new File(fileLocation); logger.debug("Checking config file at: " + fileLocation); if (f.exists()) { twitStreet.initialize(); logger.info(" Config file exist. Twitstreet initialization completed."); } else { logger.info(" Config does not exist at " + fileLocation); } }