List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext
@Nullable public static WebApplicationContext getWebApplicationContext(ServletContext sc)
From source file:com.artivisi.belajar.restful.ui.controller.HomepageController.java
@RequestMapping("/homepage/appinfo") @ResponseBody// www.j a va2 s . c o m public Map<String, String> appInfo(HttpServletRequest request) { ApplicationContext ctx = WebApplicationContextUtils .getWebApplicationContext(request.getSession().getServletContext()); Map<String, String> hasil = new HashMap<String, String>(); hasil.put("profileDefault", StringUtils.arrayToCommaDelimitedString(ctx.getEnvironment().getDefaultProfiles())); hasil.put("profileActive", StringUtils.arrayToCommaDelimitedString(ctx.getEnvironment().getActiveProfiles())); hasil.put("namaAplikasi", messageSource.getMessage("app.name", null, "undefined", null)); hasil.put("versiAplikasi", messageSource.getMessage("app.version", null, "x.x.x", null)); return hasil; }
From source file:net.sourceforge.stripes.integration.spring.SpringHelper.java
/** * Injects Spring managed beans using a Web Application Context derived from * the ServletContext./* w ww .j av a2 s . c o m*/ * * @param bean the object to have beans injected into * @param ctx the ServletContext to use to find the Spring ApplicationContext */ public static void injectBeans(Object bean, ServletContext ctx) { ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(ctx); if (ac == null) { final String name = ctx.getServletContextName(); throw new IllegalStateException( "No Spring application context was found in servlet context \"" + name + "\""); } injectBeans(bean, ac); }
From source file:org.openmeetings.servlet.outputhandler.LangExport.java
public Fieldmanagment getFieldmanagment() { try {/*from w w w .jav a 2s . c om*/ if (ScopeApplicationAdapter.initComplete) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); return context.getBean("fieldmanagment", Fieldmanagment.class); } } catch (Exception err) { log.error("[getFieldmanagment]", err); } return null; }
From source file:net.naijatek.myalumni.util.taglib.TwitterTag.java
/** * Includes the body of the tag if the page attribute equals the value set * in the 'match' attribute./* w w w . ja va 2 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(); //session = request.getSession(); //container = (MyAlumniUserContainer)session.getAttribute(BaseConstants.USER_CONTAINER); WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()); configService = (ISystemConfigService) wac.getBean(BaseConstants.SERVICE_SYSTEM_CONFIG); return EVAL_BODY_BUFFERED; }
From source file:org.openmeetings.servlet.outputhandler.ScreenRequestHandler.java
public Fieldmanagment getFieldmanagment() { try {/*from www .j a va 2s.com*/ if (ScopeApplicationAdapter.initComplete) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); return context.getBean(Fieldmanagment.class); } } catch (Exception err) { log.error("[getFieldmanagment]", err); } return null; }
From source file:org.ws13.vaadin.osgi.dm.app.SpringApplicationServlet.java
/** * Get the application class from the bean configured in Spring's context. * //from w w w.ja v a2 s . c o m * @see AbstractApplicationServlet#getApplicationClass() */ @Override protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); if (wac == null) { throw new ClassNotFoundException("Cannot get an handle on Spring's context. Is Spring running? " + "Check there's an org.springframework.web.context.ContextLoaderListener configured."); } String[] beanDefinitionNames = wac.getBeanDefinitionNames(); for (String string : beanDefinitionNames) { System.out.println("SpringApplicationServlet.getApplicationClass() " + string); } Application bean = wac.getBean(name, Application.class); if (bean == null) { throw new ClassNotFoundException("No application bean found under name " + name); } return bean.getClass(); }
From source file:co.edu.udea.prestamoDispositivos.server.PrestamoRemoteServiceImpl.java
/** * es la implementacion del metodo usado para listar los prestamos pendientes *///from ww w. ja v a 2s .c o m @Override public List<PrestamosListado> verPrestamosPendientes() throws MyException { List<PrestamosListado> prestamosListado = new ArrayList<PrestamosListado>(); List<Prestamo> prestamos = null; ServletContext sc = getServletContext(); ApplicationContext webApp = WebApplicationContextUtils.getWebApplicationContext(sc); HttpServletRequest req = this.getThreadLocalRequest(); HttpSession ses = req.getSession(); try { PrestamoBL prestamoBL = (PrestamoBL) webApp.getBean("prestamoBL"); prestamos = prestamoBL.verPrestamosPendientes(); for (Prestamo prestamo : prestamos) { PrestamosListado prestamoL = new PrestamosListado(); prestamoL.setCodigo_prestamo(prestamo.getCodigo_prestamo()); prestamoL.setEstado_prestamo(prestamo.getEstado_prestamo()); prestamoL.setFecha_final(prestamo.getFecha_final()); prestamoL.setFecha_inicial(prestamo.getFecha_inicial()); prestamoL.setId_dispositivo(prestamo.getId_dispositivo().getId_dispositivo().toString()); prestamoL.setDescripcion_dispositivo(prestamo.getId_dispositivo().getDescripcion().toString()); prestamoL.setUsuario(prestamo.getUsuario().getUsuario()); prestamosListado.add(prestamoL); } } catch (PrestamoDispositivoException e) { throw new MyException(e.getMessage()); } return prestamosListado; }
From source file:net.naijatek.myalumni.util.quartz.BirthdayWishJob.java
/** * <p>// ww w.ja v a2 s . c o m * Called by the <code>{@link org.quartz.Scheduler}</code> when a * <code>{@link org.quartz.Trigger}</code> fires that is associated with * the <code>Job</code>. * </p> * * @throws JobExecutionException * if there is an exception while executing the job. */ public void execute(JobExecutionContext context) throws JobExecutionException { try { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); IMemberService memService = (IMemberService) wac.getBean(BaseConstants.SERVICE_MEMBER_LOOKUP); ISystemConfigService sysConfigService = (ISystemConfigService) wac .getBean(BaseConstants.SERVICE_SYSTEM_CONFIG); SystemConfigVO sysConfigVO = sysConfigService.getSystemConfig(); // This job simply prints out its job name and the // date and time that it is running //String jobName = context.getJobDetail().getFullName(); //logger.info("===> BirthdayWishJob says: " + jobName + " executing at " + new Date()); Calendar now = new GregorianCalendar(); int today = now.get(java.util.Calendar.DATE); // get the list of birthday people List<MemberVO> members = new ArrayList<MemberVO>(); members = memService.getTodayBirthdayMembers( StringUtil.convertToAlphaMonth(now.get(Calendar.MONTH) + 1), String.valueOf(today)); System.out.println("Getting memebrs..."); for (MemberVO memberVO : members) { if (memberVO.getEmail() != null && memberVO.getEmail().length() > 0) { //SendMailUtil.sendBirthdayWish(memberVO, sysConfigVO); System.out.println("Sent birthday wishes to " + memberVO.getFullName()); } } } catch (Exception e) { logger.fatal("Schedular failed. " + e.getMessage()); e.printStackTrace(); } }
From source file:org.ambraproject.cas.filter.GetGuidReturnEmailFilter.java
/** * Set the Database Service (which will be used to query the user's Email Address) by way of * the Web Application Context, which is managed by the supporting framework. * * @param filterConfig Standard Filter configuration values, most notably the Servlet Context * @throws ServletException Thrown if there is a problem getting or setting the Database Service *//*from ww w.j a v a 2 s .c o m*/ public void init(final FilterConfig filterConfig) throws ServletException { try { databaseService = (DatabaseService) WebApplicationContextUtils .getWebApplicationContext(filterConfig.getServletContext()).getBean("databaseService"); } catch (final Exception e) { log.error("Failed to initialize GetGuidReturnEmailFilter.", e); throw new ServletException(e); } }
From source file:net.naijatek.myalumni.util.taglib.DisplayClassNewsTag.java
/** * Includes the body of the tag if the page attribute equals the value set * in the 'match' attribute./*from w ww . j a v a 2 s. co 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(); session = request.getSession(); container = (MyAlumniUserContainer) session.getAttribute(BaseConstants.USER_CONTAINER); WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()); classNewsService = (IClassNewsService) wac.getBean(BaseConstants.SERVICE_CLASSNEWS_LOOKUP); return EVAL_BODY_BUFFERED; }