List of usage examples for javax.servlet ServletContext getAttribute
public Object getAttribute(String name);
null
if there is no attribute by that name. From source file:com.aurel.track.ApplicationStarter.java
/** * Get the progress text shown during system initialization in the browser * * @return// ww w .j a v a 2 s . c o m */ public String getProgressText() { ServletContext scx = ApplicationBean.getInstance().getServletContext(); if (scx != null) { return (String) scx.getAttribute(PROGRESS_TEXT); } return ""; }
From source file:com.aurel.track.ApplicationStarter.java
public int getPercentComplete() { ServletContext scx = ApplicationBean.getInstance().getServletContext(); if (scx != null) { Integer pc = (Integer) scx.getAttribute(PERCENT_COMPLETE); if (pc != null) { return pc; }/*from www. jav a2 s. c om*/ } return 0; }
From source file:jp.or.openid.eiwg.scim.operation.Operation.java
/** * /*from www . j av a2 s .c om*/ * * @param context * @param request * @param attributes * @param requestJson */ public boolean deleteUserInfo(ServletContext context, HttpServletRequest request, String targetId) { // ? setError(0, null, null); // id? LinkedHashMap<String, Object> targetInfo = null; @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> users = (ArrayList<LinkedHashMap<String, Object>>) context .getAttribute("Users"); Iterator<LinkedHashMap<String, Object>> usersIt = null; if (users != null && !users.isEmpty()) { usersIt = users.iterator(); while (usersIt.hasNext()) { LinkedHashMap<String, Object> userInfo = usersIt.next(); Object id = SCIMUtil.getAttribute(userInfo, "id"); if (id != null && id instanceof String) { if (targetId.equals(id.toString())) { targetInfo = userInfo; break; } } } } if (targetInfo == null) { // ??? setError(HttpServletResponse.SC_NOT_FOUND, null, MessageConstants.ERROR_NOT_FOUND); return false; } // (??) usersIt.remove(); context.setAttribute("Users", users); return true; }
From source file:com.concursive.connect.config.ApplicationPrefs.java
private void configureScheduler(ServletContext context) { Scheduler scheduler = (Scheduler) context.getAttribute(Constants.SCHEDULER); if (scheduler != null) { // Initialize try {/*ww w . j a v a 2s . co m*/ scheduler.getContext().setAllowsTransientData(true); scheduler.getContext().put("ServletContext", context); // Give the scheduler its own connection pool... this can speed up the web-tier // when background processing is occurring ConnectionPool commonCP = (ConnectionPool) context.getAttribute(Constants.CONNECTION_POOL); if (commonCP != null) { if (!this.has(CONNECTION_POOL_MAX_SCHEDULER_CONNECTIONS)) { scheduler.getContext().put(Constants.CONNECTION_POOL, context.getAttribute(Constants.CONNECTION_POOL)); } else { ConnectionPool schedulerCP = new ConnectionPool(); schedulerCP.setDebug(commonCP.getDebug()); schedulerCP.setTestConnections(commonCP.getTestConnections()); schedulerCP.setAllowShrinking(commonCP.getAllowShrinking()); schedulerCP.setMaxConnections(this.get(CONNECTION_POOL_MAX_SCHEDULER_CONNECTIONS)); schedulerCP.setMaxIdleTime(commonCP.getMaxIdleTime()); schedulerCP.setMaxDeadTime(commonCP.getMaxDeadTime()); scheduler.getContext().put("ConnectionPool", schedulerCP); } } ConnectionElement ce = new ConnectionElement(); ce.setDriver(this.get(CONNECTION_DRIVER)); ce.setUrl(this.get(CONNECTION_URL)); ce.setUsername(this.get(CONNECTION_USER)); ce.setPassword(this.get(CONNECTION_PASSWORD)); scheduler.getContext().put("ConnectionElement", ce); scheduler.getContext().put("ApplicationPrefs", this); scheduler.start(); scheduler.getContext().put(ScheduledJobs.CONTEXT_SCHEDULER_GROUP, ScheduledJobs.UNIQUE_GROUP); ScheduledJobs.addJobs(scheduler, context); } catch (Exception e) { e.printStackTrace(System.out); LOG.error("Scheduler Error: " + e.getMessage(), e); } } }
From source file:com.concursive.connect.config.ApplicationPrefs.java
private void configureWebdavManager(ServletContext context) { LOG.info("configureWebdavManager"); WebdavManager webdavManager = (WebdavManager) context.getAttribute(Constants.WEBDAV_MANAGER); if (webdavManager != null) { webdavManager.setFileLibraryPath(this.get(FILE_LIBRARY_PATH)); }/*w w w. j a v a 2 s . c o m*/ }
From source file:com.concursive.connect.config.ApplicationPrefs.java
/** * Utility for upgrading the application * * @param context/*from w w w . j a va 2 s . c o m*/ */ private void performUpgrade(ServletContext context) { Connection db = null; ConnectionPool commonCP = (ConnectionPool) context.getAttribute(Constants.CONNECTION_POOL); try { LOG.info("Upgrading the database..."); // Share the preferences with the upgrade scripts context.setAttribute(Constants.APPLICATION_PREFS, this); // Determine the database connection to use ConnectionElement ce = new ConnectionElement(); ce.setDriver(this.get(CONNECTION_DRIVER)); ce.setUrl(this.get(CONNECTION_URL)); ce.setUsername(this.get(CONNECTION_USER)); ce.setPassword(this.get(CONNECTION_PASSWORD)); // Retrieve a database connection db = commonCP.getConnection(ce, true); // Perform the upgrade UpgradeUtils.performUpgrade(db, context); // Persist the new version info save(); } catch (Exception e) { LOG.error("performUpgrade", e); e.printStackTrace(System.out); } finally { commonCP.free(db); } }
From source file:jp.terasoluna.fw.web.struts.plugins.ResetterPlugInTest.java
/** * testInitResetter01()/*from w ww. ja v a2 s . c om*/ * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:null<br> * * <br> * l?F(?) RESETTER:T?[ubgReLXg"RESETTER"L?[ResetterCX^Xi[?B<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * this.resetternull?A??ftHgresetterT?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter01() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", null); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResetter(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterImpl", ((ResetterImpl) ctx.getAttribute("RESETTER")).getClass().getName()); }
From source file:jp.terasoluna.fw.web.struts.plugins.ResetterPlugInTest.java
/** * testInitResetter02()//ww w . j av a2 s . c o m * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:""<br> * * <br> * l?F(?) RESETTER:T?[ubgReLXg"RESETTER"L?[ResetterCX^Xi[?B<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * this.resetter?A??ftHgresetterT?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter02() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", ""); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResetter(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterImpl", ((ResetterImpl) ctx.getAttribute("RESETTER")).getClass().getName()); }
From source file:jp.terasoluna.fw.web.struts.plugins.ResetterPlugInTest.java
/** * testInitResources05()/*w w w . java2s .co m*/ * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml"<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:T?[ubgReLXg"RESETTER_RESOURCES"L?[ResetterResourcesCX^Xi[?B<br> * (?) digesterRules:?|<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * RESETTER_RESOURCESL?[?A??T?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources05() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResources(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterResources", ((ResetterResources) ctx.getAttribute("RESETTER_RESOURCES")).getClass().getName()); }