Java 类org.springframework.context.support.GenericGroovyApplicationContext 实例源码

项目:sponge    文件:StandaloneEngineListener.java   
/**
 * Creates a Spring context.
 */
protected void createSpringContext() {
    List<Resource> resources = resolveSpringConfigurationResources();
    if (resources.isEmpty()) {
        return;
    }

    logger.debug("Loading Spring configuration from {}", resources);

    context = new GenericGroovyApplicationContext();
    StandalonePlugin standalonePlugin = getStandalonePlugin();
    context.getBeanFactory().registerSingleton(
            standalonePlugin != null ? standalonePlugin.getEngineBeanName() : StandalonePlugin.DEFAULT_ENGINE_BEAN_NAME, engine);
    resources.forEach(resource -> context.load(resource));
    context.refresh();

    context.start();

    setupSpringPlugin();
    setupCamelPlugin();
}
项目:spring4-understanding    文件:GroovyControlGroupTests.java   
@Test
@SuppressWarnings("resource")
public void verifyScriptUsingGenericGroovyApplicationContext() {
    ApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy");

    String foo = ctx.getBean("foo", String.class);
    assertEquals("Foo", foo);

    String bar = ctx.getBean("bar", String.class);
    assertEquals("Bar", bar);

    Pet pet = ctx.getBean(Pet.class);
    assertNotNull("pet", pet);
    assertEquals("Dogbert", pet.getName());

    Employee employee = ctx.getBean(Employee.class);
    assertNotNull("employee", employee);
    assertEquals("Dilbert", employee.getName());
    assertEquals("???", employee.getCompany());
}
项目:spring4-understanding    文件:GroovyApplicationContextTests.java   
@Test
public void testLoadingConfigFile() {
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext(
            "org/springframework/context/groovy/applicationContext.groovy");

    Object framework = ctx.getBean("framework");
    assertNotNull("could not find framework bean", framework);
    assertEquals("Grails", framework);
}
项目:spring4-understanding    文件:GroovyApplicationContextTests.java   
@Test
public void testLoadingMultipleConfigFiles() {
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext(
            "org/springframework/context/groovy/applicationContext2.groovy",
            "org/springframework/context/groovy/applicationContext.groovy");

    Object framework = ctx.getBean("framework");
    assertNotNull("could not find framework bean", framework);
    assertEquals("Grails", framework);

    Object company = ctx.getBean("company");
    assertNotNull("could not find company bean", company);
    assertEquals("SpringSource", company);
}
项目:spring4-understanding    文件:GroovyApplicationContextTests.java   
@Test
public void testLoadingMultipleConfigFilesWithRelativeClass() {
    GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
    ctx.load(GroovyApplicationContextTests.class, "applicationContext2.groovy", "applicationContext.groovy");
    ctx.refresh();

    Object framework = ctx.getBean("framework");
    assertNotNull("could not find framework bean", framework);
    assertEquals("Grails", framework);

    Object company = ctx.getBean("company");
    assertNotNull("could not find company bean", company);
    assertEquals("SpringSource", company);
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup() {
    context = new GenericGroovyApplicationContext(
            "META-INF/spring/mydocuments.groovy");
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup() {
    context = new GenericGroovyApplicationContext(
            "META-INF/spring/mydocuments.groovy");
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup() {
    context = new GenericGroovyApplicationContext(
            "META-INF/spring/mydocuments.groovy");
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
    engine = context.getBean(SearchEngine.class);
    webType = context.getBean("webType",Type.class);
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
}
项目:spring4-understanding    文件:GroovyApplicationContextTests.java   
@Test(expected = BeanDefinitionParsingException.class)
public void testConfigFileParsingError() {
    new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext-error.groovy");
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup() {
    context = new GenericGroovyApplicationContext(
            "META-INF/spring/mydocuments.groovy");
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup() {
    context = new GenericGroovyApplicationContext(
            "META-INF/spring/mydocuments.groovy");
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup() {
    context = new GenericGroovyApplicationContext(
            "META-INF/spring/mydocuments.groovy");
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
    engine = context.getBean(SearchEngine.class);
    webType = context.getBean("webType",Type.class);
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Before
public void setup(){
    context = new GenericGroovyApplicationContext("META-INF/spring/mydocuments.groovy");
}