Examples of registerSingleton()


Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

        jettyServer.start();
        WebServiceConnection connection = null;
        try {

            StaticApplicationContext appContext = new StaticApplicationContext();
            appContext.registerSingleton("messageSender", HttpComponentsMessageSender.class);
            appContext.refresh();

            HttpComponentsMessageSender messageSender = appContext
                    .getBean("messageSender", HttpComponentsMessageSender.class);
            connection = messageSender.createConnection(new URI("http://localhost:" + port));
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

        jettyServer.start();
        WebServiceConnection connection = null;
        try {

            StaticApplicationContext appContext = new StaticApplicationContext();
            appContext.registerSingleton("messageSender", CommonsHttpMessageSender.class);
            appContext.refresh();

            CommonsHttpMessageSender messageSender = appContext
                    .getBean("messageSender", CommonsHttpMessageSender.class);
            connection = messageSender.createConnection(new URI("http://localhost:" + port));
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

        strategies.put(Strategy.class.getName(),
                StrategyImpl.class.getName() + "," + ContextAwareStrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        List<Strategy> result = helper.getDefaultStrategies(Strategy.class, applicationContext);
        Assert.assertNotNull("No result", result);
        Assert.assertEquals("Invalid amount of strategies", 2, result.size());
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

                StrategyImpl.class.getName() + "," + ContextAwareStrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        List<Strategy> result = helper.getDefaultStrategies(Strategy.class, applicationContext);
        Assert.assertNotNull("No result", result);
        Assert.assertEquals("Invalid amount of strategies", 2, result.size());
        Assert.assertTrue("Result not a Strategy implementation", result.get(0) != null);
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

        Properties strategies = new Properties();
        strategies.put(Strategy.class.getName(), StrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        Object result = helper.getDefaultStrategy(Strategy.class, applicationContext);
        Assert.assertNotNull("No result", result);
        Assert.assertTrue("Result not a Strategy implementation", result instanceof Strategy);
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

        strategies.put(Strategy.class.getName(), StrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        Object result = helper.getDefaultStrategy(Strategy.class, applicationContext);
        Assert.assertNotNull("No result", result);
        Assert.assertTrue("Result not a Strategy implementation", result instanceof Strategy);
        Assert.assertTrue("Result not a StrategyImpl implementation", result instanceof StrategyImpl);
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

        strategies.put(Strategy.class.getName(),
                StrategyImpl.class.getName() + "," + ContextAwareStrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        try {
            helper.getDefaultStrategy(Strategy.class, applicationContext);
            Assert.fail("Expected BeanInitializationException");
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

                StrategyImpl.class.getName() + "," + ContextAwareStrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        try {
            helper.getDefaultStrategy(Strategy.class, applicationContext);
            Assert.fail("Expected BeanInitializationException");
        }
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

  @Test
  public void newInstance() throws Exception {
    StaticApplicationContext oContext = new StaticApplicationContext();
    String oClassName = MyAction.class.getName();
    oContext.registerSingleton(oClassName, MyAction.class);
   
    SpringBeanFactory oFactory = new SpringBeanFactory();
    oFactory.setApplicationContext(oContext);
    Object oActual = oFactory.newInstance(MyAction.class, oClassName);
    assertNotNull(oActual);
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext.registerSingleton()

*/
public class PropertyResourceConfigurerTests extends TestCase {

  public void testPropertyOverrideConfigurer() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb1.age=99\ntb2.name=test");
    ac.registerSingleton("configurer1", PropertyOverrideConfigurer.class, pvs);
    pvs = new MutablePropertyValues();
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.