Package org.springframework.context

Examples of org.springframework.context.ApplicationContext


public class HelloWorldSpringInnerPojosExample {

    public static void main(String[] args) throws Exception {
        Logger.getLogger("org.springframework").setLevel(Level.WARNING);
        ApplicationContext context = new ClassPathXmlApplicationContext("org/drools/spring/examples/helloworld/helloworld.appctx.xml");

        RuleSet ruleSet = (RuleSet) context.getBean("innerPojosRuleSet");
        RuleBaseBuilder builder = new RuleBaseBuilder();
        builder.addRuleSet(ruleSet);
        RuleBase ruleBase = builder.build();

        HelloWorldRunner.run(ruleBase);
View Full Code Here


public class HelloWorldSpringOuterPojosExample {

    public static void main(String[] args) throws Exception {
        Logger.getLogger("org.springframework").setLevel(Level.WARNING);
        ApplicationContext context = new ClassPathXmlApplicationContext("org/drools/spring/examples/helloworld/helloworld.appctx.xml");

        RuleSet ruleSet = (RuleSet) context.getBean("outerPojosRuleSet");
        RuleBaseBuilder builder = new RuleBaseBuilder();
        builder.addRuleSet(ruleSet);
        RuleBase ruleBase = builder.build();

        HelloWorldRunner.run(ruleBase);
View Full Code Here

        return NameUtil.capitalize(dbName.toLowerCase()) + ToolConstants.DATABIND_BEAN_NAME_SUFFIX;
    }

    @Override
    public ServiceBuilder newBuilder(FrontendFactory.Style s) {
        ApplicationContext applicationContext = getApplicationContext(beanDefinitions);
        DataBinding dataBinding;
        String databindingBeanName = databindingNameToBeanName(databindingName);
        try {
            dataBinding = (DataBinding)applicationContext.getBean(databindingBeanName);
        } catch (RuntimeException e) {
            throw new ToolException("Cannot get databinding bean " + databindingBeanName
                                    + " for databinding " + databindingName);
        }

        String beanName = getBuilderBeanName(s);
        ServiceBuilder builder = null;

        try {
            builder = applicationContext.getBean(beanName, ServiceBuilder.class);
            AbstractServiceFactory serviceFactory = (AbstractServiceFactory)builder;
            serviceFactory.setDataBinding(dataBinding);
        } catch (RuntimeException e) {
            throw new ToolException("Can not get ServiceBuilder bean " + beanName
                                    + "to initialize the ServiceBuilder for style: " + s + " Reason: \n"
View Full Code Here

    public CXFServlet() {
    }

    @Override
    protected void loadBus(ServletConfig servletConfig) {
        ApplicationContext wac = WebApplicationContextUtils.
            getWebApplicationContext(servletConfig.getServletContext());
       
        if (wac instanceof AbstractApplicationContext) {
            addListener((AbstractApplicationContext)wac);
        }
       
        String configLocation = servletConfig.getInitParameter("config-location");
        if (configLocation == null) {
            try {
                InputStream is = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/cxf-servlet.xml");
                if (is != null && is.available() > 0) {
                    is.close();
                    configLocation = "/WEB-INF/cxf-servlet.xml";
                }
            } catch (Exception ex) {
                //ignore
            }
        }
        if (configLocation != null) {
            wac = createSpringContext(wac, servletConfig, configLocation);
        }
        if (wac != null) {
            String busParam = servletConfig.getInitParameter(BUS_PARAMETER);
            String busName = busParam == null ? "cxf" : busParam.trim();
           
            setBus((Bus)wac.getBean(busName, Bus.class));
        } else {
            busCreated = true;
            setBus(BusFactory.newInstance().createBus());
        }
    }
View Full Code Here

            public void onApplicationEvent(ApplicationEvent event) {
                SpringBus.this.onApplicationEvent(event);
            }
        };
        ctx.addApplicationListener(listener);
        ApplicationContext ac = applicationContext.getParent();
        while (ac != null) {
            if (ac instanceof AbstractApplicationContext) {
                ((AbstractApplicationContext)ac).addApplicationListener(listener);
            }
            ac = ac.getParent();
        }
       
        // set the classLoader extension with the application context classLoader
        setExtension(applicationContext.getClassLoader(), ClassLoader.class);
       
View Full Code Here

    public void onApplicationEvent(ApplicationEvent event) {
        if (ctx == null) {
            return;
        }
        boolean doIt = false;
        ApplicationContext ac = ctx;
        while (ac != null && !doIt) {
            if (event.getSource() == ac) {
                doIt = true;
                break;
            }
            ac = ac.getParent();
        }
        if (doIt) {
            if (event instanceof ContextRefreshedEvent) {
                if (getState() != BusState.RUNNING) {
                    initialize();
View Full Code Here

    }

    public SyncopeSession(final Request request) {
        super(request);

        final ApplicationContext applicationContext =
                WebApplicationContextUtils.getWebApplicationContext(WebApplication.get().getServletContext());

        restTemplate = applicationContext.getBean(RestTemplate.class);
        baseURL = applicationContext.getBean("baseURL", String.class);

        setupRESTClients();
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {

        final ApplicationContext ctx = ((ConfigurableApplicationContext) schedulerContext.get("applicationContext"));

        // Try to re-create job bean from underlying task (useful for managing
        // failover scenarios)
        if (!ctx.containsBean(bundle.getJobDetail().getKey().getName())) {
            Long taskId = JobInstanceLoader.getTaskIdFromJobName(bundle.getJobDetail().getKey().getName());
            if (taskId != null) {
                TaskDAO taskDAO = ctx.getBean(TaskDAO.class);
                SchedTask task = taskDAO.find(taskId);

                JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
                jobInstanceLoader.registerJob(task, task.getJobClassName(), task.getCronExpression());
            }

            Long reportId = JobInstanceLoader.getReportIdFromJobName(bundle.getJobDetail().getKey().getName());
            if (reportId != null) {
                ReportDAO reportDAO = ctx.getBean(ReportDAO.class);
                Report report = reportDAO.find(reportId);

                JobInstanceLoader jobInstanceLoader = ctx.getBean(JobInstanceLoader.class);
                jobInstanceLoader.registerJob(report);
            }
        }

        final Object job = ctx.getBean(bundle.getJobDetail().getKey().getName());
        final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(job);
        if (isEligibleForPropertyPopulation(wrapper.getWrappedInstance())) {
            final MutablePropertyValues pvs = new MutablePropertyValues();
            if (this.schedulerContext != null) {
                pvs.addPropertyValues(this.schedulerContext);
View Full Code Here

   public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
     //might make more sense to do this on a timer instead of a session listener?
     HttpSession session = httpSessionEvent.getSession();
     String sessionId = session.getId();
     //unfortunately, there doesn't currently seem to be a nice way to inject this dependency in the regular fashion
       ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
       RequestStatusManager requestStatusManager = (RequestStatusManager) ctx.getBean("requestStatusManager");
     if (requestStatusManager != null){
       requestStatusManager.removeRequestsBySessionId(sessionId);
       logger.debug("Removing Status info for session: "+ sessionId);
     } else {
       logger.error("The ingestStatusManager has a null value here");
View Full Code Here

  }

  @Test
  public void registersEntitiesOnInitialization() {

    ApplicationContext context = mock(ApplicationContext.class);

    SampleMappingContext mappingContext = new SampleMappingContext();
    mappingContext.setInitialEntitySet(Collections.singleton(Person.class));
    mappingContext.setApplicationEventPublisher(context);
View Full Code Here

TOP

Related Classes of org.springframework.context.ApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.