Example usage for org.springframework.beans.factory.xml XmlBeanFactory XmlBeanFactory

List of usage examples for org.springframework.beans.factory.xml XmlBeanFactory XmlBeanFactory

Introduction

In this page you can find the example usage for org.springframework.beans.factory.xml XmlBeanFactory XmlBeanFactory.

Prototype

public XmlBeanFactory(Resource resource) throws BeansException 

Source Link

Document

Create a new XmlBeanFactory with the given resource, which must be parsable using DOM.

Usage

From source file:gaderian.test.utilities.TestSpringLookupFactory.java

public void testSpringIntegration() throws Exception {
    // Spring setup

    ClassPathResource springBeansResource = new ClassPathResource("SpringBeans.xml",
            TestSpringLookupFactory.class);

    BeanFactory beanFactory = new XmlBeanFactory(springBeansResource);

    Registry r = buildFrameworkRegistry("SpringIntegration.xml", false);

    SpringBeanFactoryHolder h = (SpringBeanFactoryHolder) r
            .getService("gaderian.utilities.DefaultSpringBeanFactoryHolder", SpringBeanFactoryHolder.class);

    h.setBeanFactory(beanFactory);/*w ww  .  j  av  a  2  s  . c  o m*/

    SimpleService a = (SimpleService) r.getService("gaderian.test.utilities.Adder", SimpleService.class);

    assertEquals(17, a.add(9, 8));
}

From source file:com.eventattend.portal.Factory.UserFactory.java

public static UserController userTimeZone() throws Exception {
    ClassPathResource resource = new ClassPathResource("BusinessObjectFactory.xml");
    BeanFactory factory = new XmlBeanFactory(resource);
    return (UserController) factory.getBean("userTimeZone");
}

From source file:org.intalio.deploy.deployment.impl.DeployServiceDeployTest.java

public DeploymentServiceImpl loadDeploymentService(String xmlConfigFile) throws Exception {
    ClassPathResource config = new ClassPathResource(xmlConfigFile);
    XmlBeanFactory factory = new XmlBeanFactory(config);
    DeploymentServiceImpl deployService = (DeploymentServiceImpl) factory.getBean("deploymentService");
    return deployService;
}

From source file:TopicsTest.java

@Test
public void testJDBCUpdateDateDerComment() {

    ListableBeanFactory bf;/* www .j  a  va2s .  co m*/
    bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
    ITopics m = (ITopics) bf.getBean("topicsDao");
    System.out.print("Je suis ici");
    m.UpdateDateLastComment(36);

    //System.out.print(to.getTopic_desc() + "" + to.getCat_id());
}

From source file:me.springframework.adapter.ClassicSpringAdapter.java

/**
 * Constructs a {@link ClassicSpringAdapter} from the XML application context file to which this
 * <code>resource</code> is pointing.
 * /*from ww w. j  a  v  a 2  s .c o m*/
 * @param resource The {@link Resource} pointing to the XML application context file holding the
 *            bean configuration.
 */
public ClassicSpringAdapter(Resource resource) {
    this.factory = new XmlBeanFactory(resource);
}

From source file:wsconfig.PaysRepository.java

/**
 * Renvoye la liste des pays en fonction de leurs dangerosit
 * @param danger True pour les pays dangereux, false sinon
 * @return La liste de pays correspondant
 */// ww  w  .  j  av a  2s .  c  o m
public List findAllPaysDanger(boolean danger) {

    ListableBeanFactory bf;
    bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
    IPaysMetier instance = (IPaysMetier) bf.getBean("paysMetier");

    List<Pays> result = instance.findAllPaysDanger(danger);
    for (Pays pays : result) {
        System.out.println("libelle : " + pays.getLibelleFr());
    }
    return result;
}

From source file:me.springframework.di.spring.ParentBeanTest.java

@Test
public void validateParentBeansConfigWorksInSpring() {
    ClassPathResource res = new ClassPathResource("/parent.xml");
    XmlBeanFactory beanFactory = new XmlBeanFactory(res);

    Person typePerson = (Person) beanFactory.getBean("type-bob");
    assertEquals(Teacher.class, typePerson.getClass());
    Person propPerson = (Person) beanFactory.getBean("prop-bob");
    assertEquals("Bob", propPerson.getName());
    assertEquals(-1, propPerson.getAge());
    try {/*from w w  w  .  j a v  a2 s. co  m*/
        beanFactory.getBean("type-teacher-base");
        fail("Did not expect getBean to succeed on with name of abstract bean");
    } catch (Exception ex) {
        // Expected
    }
}

From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.TestListWrapper.java

protected void setUp() throws Exception {
    loadJdbcProps();/*from   w  w  w  .jav a 2 s. c o  m*/

    ClassPathResource resource = new ClassPathResource("viewService.xml");
    XmlBeanFactory factory = new XmlBeanFactory(resource);

    PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
    cfg.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_OVERRIDE");
    cfg.setProperties(jdbcProps);
    cfg.postProcessBeanFactory(factory);

    repo = (RepositoryService) factory.getBean("repoService");
}

From source file:me.springframework.di.spring.FactoryBeanTest.java

@Test
public void validateFactoryBeanConfigWorksInSpring() {
    ClassPathResource xml = new ClassPathResource("/factorybean.xml");
    XmlBeanFactory beanFactory = new XmlBeanFactory(xml);
    TestBean bean = (TestBean) beanFactory.getBean("test");
    assertTrue(bean.registry instanceof Registry);
}

From source file:TopicsTest.java

@Test
public void testJDBCUpdateUsernameDerComment() {

    ListableBeanFactory bf;/*w w  w  .  java2  s.  c  om*/
    bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
    ITopics m = (ITopics) bf.getBean("topicsDao");
    System.out.print("Je suis ici");
    m.UpdateUsernameLastComment(36, "anthony");

    //System.out.print(to.getTopic_desc() + "" + to.getCat_id());
}