Examples of AnnotationConfigApplicationContext


Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

     * @return the created instance of {@link AnnotationConfigApplicationContext}
     */
    private ApplicationContext createAnnotatedApplicationContext(Class<?>[] classes, String[] packages) {

        if (classes.length > 0) {
            AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(classes);

            if (packages.length > 0) {
                applicationContext.scan(packages);
                applicationContext.refresh();
            }

            return applicationContext;

        } else {

            return new AnnotationConfigApplicationContext(packages);
        }
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

     * @return the created instance of {@link org.springframework.context.annotation.AnnotationConfigApplicationContext}
     */
    private ApplicationContext createAnnotatedApplicationContext(Class<?>[] classes, String[] packages) {

        if (classes.length > 0) {
            AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(classes);

            if (packages.length > 0) {
                applicationContext.scan(packages);
                applicationContext.refresh();
            }

            return applicationContext;

        } else {

            return new AnnotationConfigApplicationContext(packages);
        }
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

     * @return the created instance of {@link AnnotationConfigApplicationContext}
     */
    private ApplicationContext createAnnotatedApplicationContext(Class<?>[] classes, String[] packages) {

        if (classes.length > 0) {
            AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(classes);

            if (packages.length > 0) {
                applicationContext.scan(packages);
                applicationContext.refresh();
            }

            return applicationContext;

        } else {

            return new AnnotationConfigApplicationContext(packages);
        }
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class IoCContainerExample {
 
  public static void main(String[] args) {
   
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("com.jverstry");
    ctx.refresh();   
   
    MyServices mcs = ctx.getBean(MyServices.class);
    System.out.println("Data: " + mcs.getMyService().getData());
   
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

  protected ConfigurableApplicationContext getApplicationContext(String configLocation) {

    ConfigurableApplicationContext context;
    if (ClassUtils.isPresent(configLocation, getClass().getClassLoader())) {
      Class<?> clazz = ClassUtils.resolveClassName(configLocation, getClass().getClassLoader());
      context = new AnnotationConfigApplicationContext(clazz);
    } else {
      context = new ClassPathXmlApplicationContext(configLocation);
    }

    context.getAutowireCapableBeanFactory().autowireBeanProperties(this,
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

  }

  @SuppressWarnings("unchecked")
  @Before
  public void setup() {
    ctx = new AnnotationConfigApplicationContext(ContainerClusterStateMachineConfiguration.class, TestConfig.class);
    stateMachineFactory = ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, EnumStateMachineFactory.class);
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class ListenerTests extends AbstractStateMachineTests {

  @Test
  public void testStateEvents() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
    assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
    @SuppressWarnings("unchecked")
    EnumStateMachine<TestStates,TestEvents> machine =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);

    TestStateMachineListener listener = new TestStateMachineListener();
    machine.addStateListener(listener);

    assertThat(machine, notNullValue());
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("foo", "jee1").build());
    assertThat(listener.states.size(), is(1));
    assertThat(listener.states.get(0).from.getId(), is(TestStates.S1));
    assertThat(listener.states.get(0).to.getId(), is(TestStates.S2));
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E2).setHeader("foo", "jee2").build());
    assertThat(listener.states.size(), is(2));
    assertThat(listener.states.get(1).from.getId(), is(TestStates.S2));
    assertThat(listener.states.get(1).to.getId(), is(TestStates.S3));
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E4).setHeader("foo", "jee2").build());
    assertThat(listener.states.size(), is(2));

    ctx.close();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class ConfigurationTests extends AbstractStateMachineTests {

  @SuppressWarnings({ "unchecked" })
  @Test
  public void testStates() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config1.class);
    assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
    EnumStateMachine<TestStates,TestEvents> machine =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
    assertThat(machine, notNullValue());
    TestAction testAction = ctx.getBean("testAction", TestAction.class);
    assertThat(testAction, notNullValue());
    ctx.close();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class StateMachineFactoryTests extends AbstractStateMachineTests {

  @SuppressWarnings({ "unchecked" })
  @Test
  public void testMachineFromFactory() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);

    EnumStateMachineFactory<TestStates, TestEvents> stateMachineFactory =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, EnumStateMachineFactory.class);

    StateMachine<State<TestStates, TestEvents>, TestEvents> machine = stateMachineFactory.getStateMachine();
    assertThat(machine.getState().getId(), is(TestStates.S1));
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).build());
    assertThat(machine.getState().getId(), is(TestStates.S2));
    ctx.close();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class TransitionTests extends AbstractStateMachineTests {

  @SuppressWarnings({ "unchecked" })
  @Test
  public void testTriggerlessTransition() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config1.class);
    assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
    EnumStateMachine<TestStates,TestEvents> machine =
        ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
    assertThat(machine.getState().getId(), is(TestStates.S1));
    machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).build());
    assertThat(machine.getState().getId(), is(TestStates.S3));
    ctx.close();
  }
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.