Examples of ApplicationContext


Examples of org.springframework.context.ApplicationContext

public class HVAC {

    public static void main(String args[]) throws Exception {

        final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                "org/drools/spring/examples/jiahvac/control/hvac.appctx.xml");

        final WorkingMemory workingMemory =
                (WorkingMemory) applicationContext.getBean("workingMemory");
       
        final Simulator simulator =
                (Simulator) applicationContext.getBean("simulator");
       
        final TempuratureControl control =
                (TempuratureControl) applicationContext.getBean("tempuratureControl");

        workingMemory.assertObject(control);

        for (Floor floor : simulator.getFloors()) {
            workingMemory.assertObject(floor.getThermometer(), true);
            workingMemory.assertObject(floor.getVent(), true);
        }
        for (HeatPump pump : simulator.getHeatPumps()) {
            workingMemory.assertObject(pump, true);
        }
        System.out.println("---- begin initial fireAllRules");
        workingMemory.fireAllRules();
        System.out.println("---- end initial fireAllRules");

        // The 'executor' bean is lazy-init so we can control when the simulator starts
        // (which is now). Alternatively, we could have defined a start method to begin
        // the simulation.
        applicationContext.getBean("executor");
    }
View Full Code Here

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

Examples of org.springframework.context.ApplicationContext

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

Examples of org.springframework.context.ApplicationContext

        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

Examples of org.springframework.context.ApplicationContext

    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

Examples of org.springframework.context.ApplicationContext

            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

Examples of org.springframework.context.ApplicationContext

    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

Examples of org.springframework.context.ApplicationContext

    }

    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

Examples of org.springframework.context.ApplicationContext

     * {@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

Examples of pivot.wtk.ApplicationContext

        // needed, see http://people.apache.org/~tvolkert/tests/scrolling/
        // There seems to be no workaround, so we have to turn the optimization
        // completely off if we're not sure that we're unobscured.
        if (optimizeScrolling) {
            ApplicationContext.DisplayHost displayHost = viewport.getDisplay().getDisplayHost();
            ApplicationContext applicationContext = displayHost.getApplicationContext();

            optimizeScrolling = (applicationContext instanceof DesktopApplicationContext ||
                (displayHost.getPeer().canDetermineObscurity() && !displayHost.getPeer().isObscured()));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.