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

项目:spring_integration_examples    文件:Application.java   
@SuppressWarnings("unchecked")
public static void main (String[] args){

    ConfigurableApplicationContext ac =
            new ClassPathXmlApplicationContext("/context.xml");
    PollableChannel feedChannel = ac.getBean("feedChannel", PollableChannel.class);

    for (int i = 0; i < 10; i++) {
        Message<SyndEntry> message = (Message<SyndEntry>) feedChannel.receive(1000);
        if (message != null){
            System.out.println("==========="+i+"===========");
            SyndEntry entry = message.getPayload();
            System.out.println(entry.getAuthor());
            System.out.println(entry.getPublishedDate());
            System.out.println(entry.getTitle());
            System.out.println(entry.getUri());
            System.out.println(entry.getLink());
            System.out.println("======================");

        }
    }
    ac.close();


}
项目:alfresco-core    文件:RuntimeExecBeansTest.java   
public void testBootstrapAndShutdown() throws Exception
{
    // now bring up the bootstrap
    ApplicationContext ctx = new ClassPathXmlApplicationContext(APP_CONTEXT_XML);

    // the folder should be gone
    assertFalse("Folder was not deleted by bootstrap", dir.exists());

    // now create the folder again
    dir.mkdir();
    assertTrue("Directory not created", dir.exists());

    // announce that the context is closing
    ctx.publishEvent(new ContextClosedEvent(ctx));

    // the folder should be gone
    assertFalse("Folder was not deleted by shutdown", dir.exists());
}
项目:WiFiProbeAnalysis    文件:HbaseInsertTest.java   
public static void main(String args[]){
    ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"classpath:applicationContext-service.xml"});
    HBaseService hbaseService = (HBaseService) ctx.getBean("HBaseService");
    GroupDataDao groupDatadao = (GroupDataDao) ctx.getBean("groupDataDao");
    GroupData groupData = new GroupData();
    try{
        groupData.setTime_id("test");
        groupData.setRecord_time("test");
        groupData.setAddr("test");
        groupData.setDataList("test");
        groupData.setProbe_id("test");
        groupData.setLat("test");
        groupData.setLon("test");
        groupData.setMmac("test");
        groupData.setWmac("test");
        groupData.setWssid("test");
        groupData.setRate("test");
        groupDatadao.save(groupData);
        System.out.println("Finish");
    }catch (Exception e){
        e.printStackTrace();
    }
}
项目:taotao-shop    文件:TestPageHelper.java   
@Test
public void testPageHelper() {
    //创建一个spring容器
    ApplicationContext applicationContext = 
            new ClassPathXmlApplicationContext("classpath:spring/applicationContext-*.xml");
    //送spring容器中获得mapper代理对象
    TbItemMapper itemMapper = applicationContext.getBean(TbItemMapper.class);
    //执行查询并分页
    TbItemExample tbItemExample = new TbItemExample();
    //分页处理
    PageHelper.startPage(1, 10);
    List<TbItem> list = itemMapper.selectByExample(tbItemExample);
    //获取商品列表
    for (TbItem tbItem : list) {
        System.out.println(tbItem.getTitle());
    }
    //取分页信息
    PageInfo<TbItem> pageInfo = new PageInfo<>(list);
    long total = pageInfo.getTotal();
    System.out.println("共有商品:" + total);


}
项目:EasyHousing    文件:OrderRentHouseTest.java   
@Test
public void delete() {
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
    OrderRentHouseDao dao = (OrderRentHouseDao) ac.getBean("orderRentHouseDao");
    OrderRentHouse c = new OrderRentHouse();
    c.setOrderId(1);
    System.out.println(dao.deleteOrderRentHouse(c));
}
项目:dubbo2    文件:AsyncConsumer.java   
public static void main(String[] args) throws Exception {
    String config = AsyncConsumer.class.getPackage().getName().replace('.', '/') + "/async-consumer.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();

    final AsyncService asyncService = (AsyncService)context.getBean("asyncService");

    Future<String> f = RpcContext.getContext().asyncCall(new Callable<String>() {
        public String call() throws Exception {
            return asyncService.sayHello("async call request");
        }
    });

    System.out.println("async call ret :" + f.get());

    RpcContext.getContext().asyncCall(new Runnable() {
        public void run() {
            asyncService.sayHello("oneway call request1");
            asyncService.sayHello("oneway call request2");
        }
    });

    System.in.read();
}
项目:dubbox-hystrix    文件:ConfigTest.java   
@Test
public void testInitReference() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider.xml");
    providerContext.start();
    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/init-reference.xml");
        ctx.start();
        try {
            DemoService demoService = (DemoService)ctx.getBean("demoService");
            assertEquals("say:world", demoService.sayName("world"));
        } finally {
            ctx.stop();
            ctx.close();
        }
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
项目:dubbox-hystrix    文件:ConfigTest.java   
@Test
public void testSystemPropertyOverrideMultiProtocol() throws Exception {
    System.setProperty("dubbo.protocol.dubbo.port", "20814");
    System.setProperty("dubbo.protocol.rmi.port", "10914");
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/override-multi-protocol.xml");
    providerContext.start();
    try {
        ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
        assertEquals(20814, dubbo.getPort().intValue());
        ProtocolConfig rmi = (ProtocolConfig) providerContext.getBean("rmi");
        assertEquals(10914, rmi.getPort().intValue());
    } finally {
        System.setProperty("dubbo.protocol.dubbo.port", "");
        System.setProperty("dubbo.protocol.rmi.port", "");
        providerContext.stop();
        providerContext.close();
    }
}
项目:cas-server-4.2.1    文件:SearchModeSearchDatabaseAuthenticationHandlerTests.java   
@Before
public void setup() throws Exception {


    final ClassPathXmlApplicationContext ctx = new
        ClassPathXmlApplicationContext("classpath:/jpaTestApplicationContext.xml");
    this.dataSource = ctx.getBean("dataSource", DataSource.class);

    this.handler = new SearchModeSearchDatabaseAuthenticationHandler();
    handler.setDataSource(this.dataSource);
    handler.setTableUsers("cassearchusers");
    handler.setFieldUser("username");
    handler.setFieldPassword("password");
    handler.afterPropertiesSet();

    final Connection c = this.dataSource.getConnection();
    final Statement s = c.createStatement();
    c.setAutoCommit(true);

    s.execute(getSqlInsertStatementToCreateUserAccount(0));
    for (int i = 0; i < 10; i++) {
        s.execute(getSqlInsertStatementToCreateUserAccount(i));
    }

    c.close();
}
项目:dubbo2    文件:ConfigTest.java   
@Test
public void testSystemPropertyOverrideMultiProtocol() throws Exception {
    System.setProperty("dubbo.protocol.dubbo.port", "20814");
    System.setProperty("dubbo.protocol.rmi.port", "10914");
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/override-multi-protocol.xml");
    providerContext.start();
    try {
        ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
        assertEquals(20814, dubbo.getPort().intValue());
        ProtocolConfig rmi = (ProtocolConfig) providerContext.getBean("rmi");
        assertEquals(10914, rmi.getPort().intValue());
    } finally {
        System.setProperty("dubbo.protocol.dubbo.port", "");
        System.setProperty("dubbo.protocol.rmi.port", "");
        providerContext.stop();
        providerContext.close();
    }
}
项目:dubbox-hystrix    文件:ConfigTest.java   
@Test
public void testXmlOverrideProperties() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/xml-override-properties.xml");
    providerContext.start();
    try {
        ApplicationConfig application = (ApplicationConfig) providerContext.getBean("application");
        assertEquals("demo-provider", application.getName());
        assertEquals("world", application.getOwner());

        RegistryConfig registry = (RegistryConfig) providerContext.getBean("registry");
        assertEquals("N/A", registry.getAddress());

        ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
        assertEquals(20813, dubbo.getPort().intValue());

    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
项目:Learning-Spring-5.0    文件:TestClasspathApplicationContext.java   
public static void main(String[] args) {
    // TODO Auto-generated method stub

    try {
        // case1:
        ApplicationContext context = new ClassPathXmlApplicationContext(
                "beans_classpath.xml");
        // case2

        ApplicationContext context1 = new ClassPathXmlApplicationContext(
                new String[] { "beans_classpath.xml","beans_classpath1.xml" });
        System.out.println("container created successfully");
    } catch (BeansException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
项目:azeroth    文件:TaskServerNode2.java   
public static void main(String[] args) throws InterruptedException {

        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "test-schduler.xml");

        InstanceFactory.setInstanceProvider(new SpringInstanceProvider(context));

        logger.info("TASK started....");
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

            @Override
            public void run() {
                logger.info("TASK Stoped....");
                context.close();
            }
        }));

        Scanner scan = new Scanner(System.in);
        String cmd = scan.next();
        if ("q".equals(cmd)) {
            scan.close();
            context.close();
        }

    }
项目:jsf-core    文件:StartWorkerServer.java   
public static void main(String[] args){
        ClassPathXmlApplicationContext cac = new ClassPathXmlApplicationContext("classpath*:worker2.xml","classpath*:spring/spring-worker-db.xml");
        cac.start();
        /*GenericApplicationContext gac = new GenericApplicationContext();
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(gac);
        xmlReader.loadBeanDefinitions(new ClassPathResource("worker2.xml"));
        xmlReader.loadBeanDefinitions(new ClassPathResource("spring/spring-worker-db.xml"));
//        PropertiesBeanDefinitionReader propReader = new PropertiesBeanDefinitionReader(gac);
//        propReader.loadBeanDefinitions(new ClassPathResource("db.properties"));
        gac.refresh();*/
        logger.info("Worker Server服务启动完成");
        // 启动本地服务,然后hold住本地服务
        synchronized (StartWorkerServer.class) {
            while (true) {
                try {
                    StartWorkerServer.class.wait();
                } catch (InterruptedException e) {
                }
            }
        }
    }
项目:JRediClients    文件:SpringNamespaceWikiTest.java   
@Test
public void testRedisClient() throws Exception {
    RedisRunner.RedisProcess run = new RedisRunner()
            .requirepass("do_not_use_if_it_is_not_set")
            .nosave()
            .randomDir()
            .run();
    try {
        ClassPathXmlApplicationContext context
                = new ClassPathXmlApplicationContext("classpath:org/redisson/spring/support/namespace_wiki_redis_client.xml");
        RedisClient redisClient = context.getBean(RedisClient.class);
        RedisConnection connection = redisClient.connect();
        Map<String, String> info = connection.sync(RedisCommands.INFO_ALL);
        assertThat(info, notNullValue());
        assertThat(info, not(info.isEmpty()));
        ((ConfigurableApplicationContext) context).close();
    } finally {
        run.stop();
    }
}
项目:EasyHousing    文件:TestBuildingDealDao.java   
@Test
public void Test2(){
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");//��ʼ������
    BuildingDealDao buildingDealDao = (BuildingDealDao) ac.getBean("buildingDealDao");
    BuildingDeal u = new BuildingDeal();
    u.setAgentId(2);
    u.setBuildingDealPerPrice(100);
    u.setBuildingDealTime(new Date());
    u.setBuildingDealTotalPrice(100);
    u.setBuildingId(1);
    u.setBuildingLayout("����һ��");
    u.setUserId(1);
    u.setBuildingDealId(1);
    buildingDealDao.updateBuildingDeal(u);
    System.out.println("-------");
}
项目:EasyHousing    文件:TestBuildingLayoutDao.java   
@Test
public void Test2(){
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");//��ʼ������
    BuildingLayoutDao buildingLayoutDao = (BuildingLayoutDao) ac.getBean("buildingLayoutDao");
    BuildingLayout u = new BuildingLayout();

    u.setBuildingId(2);
    u.setBuildingLayout("һ��һ��");
    u.setBuildingLayoutPerPrice(2);
    u.setBuildingLayoutPicUrl("2112512");
    u.setBuildingLayoutReferencePrice(2);
    u.setBuildingLayoutSoldOut(2);

    buildingLayoutDao.updateBuildingLayout(u);

    System.out.println("-------");
}
项目:Spring_Scope_LookupMethod    文件:LookUpMethod.java   
public static void main(String[] args) {
//configuring the application  context
    ApplicationContext ctx=new ClassPathXmlApplicationContext("com/pratik/cfg/config.xml");
    //get the bean
    person p1=(person)ctx.getBean("per");

    //get the bean second time 
    person p2=(person)ctx.getBean("per");

    System.out.println("\n\t1.Person-->"+p1.hashCode()+"\t1.Employee-->"+p1.getemp().hashCode());
    System.out.println("\n\t2.Person-->"+p2.hashCode()+"\t2.Employee-->"+p2.getemp().hashCode());

    if(p1.hashCode()==p2.hashCode()) {
        System.out.println("\t\tPerson is In Singleton");
        System.out.println("\t\tEmployee is In Prototype");
    }else
        System.out.println("\t\tExit");

}
项目:dubbo2    文件:RedisConsumer.java   
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    String config = RedisConsumer.class.getPackage().getName().replace('.', '/') + "/redis-consumer.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();
    Map<String, Object> cache = (Map<String, Object>) context.getBean("cache");
    cache.remove("hello");
    Object value = cache.get("hello");
    System.out.println(value);
    if (value != null) {
        throw new IllegalStateException(value + " != null");
    }
    cache.put("hello", "world");
    value = cache.get("hello");
    System.out.println(value);
    if (! "world".equals(value)) {
        throw new IllegalStateException(value + " != world");
    }
}
项目:EasyHousing    文件:TestBuildingLayoutDao.java   
@Test
public void Test4(){
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");//��ʼ������
    BuildingLayoutDao buildingLayoutDao = (BuildingLayoutDao) ac.getBean("buildingLayoutDao");
    BuildingLayout u = new BuildingLayout();

    u.setBuildingId(2);
    u.setBuildingLayout("һ��һ��");
    u.setBuildingLayoutPerPrice(1);
    u.setBuildingLayoutPicUrl("2112512");
    u.setBuildingLayoutReferencePrice(1);
    u.setBuildingLayoutSoldOut(1);

    buildingLayoutDao.deleteBuildingLayout(u);

    System.out.println(u.getBuildingLayoutPerPrice());
}
项目:dubbocloud    文件:ConfigTest.java   
@Test
public void testDelayOnInitialized() throws Exception {
    SimpleRegistryService registryService = new SimpleRegistryService();
    Exporter<RegistryService> exporter = SimpleRegistryExporter.export(4548, registryService);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/delay-on-initialized.xml");
    //ctx.start();
    try {
        List<URL> urls = registryService.getRegistered().get("com.alibaba.dubbo.config.spring.api.DemoService");
        assertNotNull(urls);
        assertEquals(1, urls.size());
        assertEquals("dubbo://" + NetUtils.getLocalHost() + ":20883/com.alibaba.dubbo.config.spring.api.DemoService", urls.get(0).toIdentityString());
    } finally {
        ctx.stop();
        ctx.close();
        exporter.unexport();
    }
}
项目:JavaStudy    文件:ApplicationMain.java   
static void findTest(){
    ApplicationContext atc=new ClassPathXmlApplicationContext("/springContext.xml");
    UserService userService1=(UserService)atc.getBean("userService");
    atc.getBean("");
    PrinterUtils.printILog(userService1);
    User user =userService1.findUserById("1");
    PrinterUtils.printELog(user);
}
项目:Spring_Scopes_Singleton_Prototype    文件:prototype_scope.java   
public static void main(String[] args) {

    ApplicationContext ctx=new ClassPathXmlApplicationContext("com/pratik/cfg/config.xml");
    person p1=(person)ctx.getBean("per");
    System.out.println("\n\t1.Person-->"+p1.hashCode());
    person p2=(person)ctx.getBean("per");
    System.out.println("\n\t1.Person-->"+p2.hashCode());
    if(p1.hashCode()==p2.hashCode())
        System.out.println("\t\tIn Singleton");
    else
        System.out.println("\t\tIn Prototype");

}
项目:airsonic    文件:TestCaseUtils.java   
public static ApplicationContext loadSpringApplicationContext(String baseResources) {
  String applicationContextService = baseResources + "applicationContext-service.xml";
  String applicationContextCache = baseResources + "applicationContext-cache.xml";

  String[] configLocations = new String[]{
          TestCaseUtils.class.getClass().getResource(applicationContextCache).toString(),
          TestCaseUtils.class.getClass().getResource(applicationContextService).toString()
  };
  return new ClassPathXmlApplicationContext(configLocations);
}
项目:dubbox-hystrix    文件:SpringContainer.java   
public void start() {
    String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
    if (configPath == null || configPath.length() == 0) {
        configPath = DEFAULT_SPRING_CONFIG;
    }
    context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));
    context.start();
}
项目:BecomeJavaHero    文件:App.java   
public static void main( String[] args ) {
    ApplicationContext context =
            new ClassPathXmlApplicationContext("META-INF/spring-configuration.xml");

    ReportGenerator generator1 = (ReportGenerator) context.getBean("reportGenerator1");
    generator1.format();

    ReportGenerator generator2 = (ReportGenerator) context.getBean("reportGenerator2");
    generator2.format();
}
项目:spring_mvc_demo    文件:App.java   
public static void main( String[] args )
{
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    ProductBoImpl productBo = (ProductBoImpl) context.getBean("productBo");

    Product product = productBo.getProductById(3);

    System.out.println("product name : "+product.getName());
}
项目:Learning-Spring-5.0    文件:Test_DisposableBean.java   
public static void main(String[] args) {
    // TODO Auto-generated method stub
    ApplicationContext context=new ClassPathXmlApplicationContext("beans_lifecycle.xml");

    Demo_DisposableBean obj=(Demo_DisposableBean)context.getBean("obj_Disposable");
       System.out.println(obj);
       ((AbstractApplicationContext)context).registerShutdownHook();
}
项目:financehelper    文件:TransactionTest.java   
public static void main(String[] args) {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext*.xml");
    final ContentService contentService = applicationContext.getBean(ContentService.class);
    Content content = new Content();
    content.setContent("哈哈哈");
    content.setAddtime(new Date());
    content.setUserId(1);
    content.setLikeNum(0);
    contentService.add(content);
}
项目:dubbox-hystrix    文件:ConfigTest.java   
@Test
public void testMultiProtocol() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol.xml");
    ctx.start();
    try {
        DemoService demoService = refer("dubbo://127.0.0.1:20881");
        String hello = demoService.sayName("hello");
        assertEquals("say:hello", hello);
    } finally {
        ctx.stop();
        ctx.close();
    }
}
项目:ZHFS-WEB    文件:UserControllerTest.java   
@SuppressWarnings("resource")
@BeforeClass
public static void Before(){

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-context.xml");
    userController = applicationContext.getBean(UserController.class);
}
项目:EasyHousing    文件:OrderRentHouseTest.java   
@Test
public void select() {
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
    OrderRentHouseDao dao = (OrderRentHouseDao) ac.getBean("orderRentHouseDao");
    OrderRentHouse c = new OrderRentHouse();
    c.setOrderId(2);
    System.out.println(dao.selectOrderRentHouse(c).getOrderTime());
}
项目:mirage-integration    文件:SpringConnectionProviderTest.java   
/**
 * Tests SQL execution (commit).
 */
public void testSpringSpringConnectionProvider2() throws Exception {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(APPLICATION_CONTEXT);

    SpringTestDao springTestDao = (SpringTestDao) applicationContext.getBean("springTestDao");

    Book book = new Book();
    book.name = "Mirage in Action";
    book.author = "Naoki Takezoe";
    book.price = 20;
    springTestDao.insert(book, false);

    assertEquals(1, springTestDao.getCount());
}
项目:springboot-shiro-cas-mybatis    文件:JpaLockingStrategyTests.java   
@Before
public void setup() {
    final ClassPathXmlApplicationContext ctx = new
        ClassPathXmlApplicationContext("classpath:/jpaSpringContext.xml");
    this.factory = ctx.getBean("ticketEntityManagerFactory", EntityManagerFactory.class);
    this.txManager = ctx.getBean("ticketTransactionManager", PlatformTransactionManager.class);
    this.dataSource = ctx.getBean("dataSourceTicket", DataSource.class);
}
项目:tinyshop8    文件:IniGoodsDataTest.java   
@Test
public void ini() throws Exception
{
    ApplicationContext applicationContext = new
              ClassPathXmlApplicationContext("applicationContext.xml");
    IniGoodsData i = (IniGoodsData) applicationContext
              .getBean("iniGoodsData");
    i.ini();
}
项目:EatDubbo    文件:ConfigTest.java   
@Test
public void test_noMethodInterface_methodsKeyHasValue() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-no-methods-interface.xml");
    ctx.start();
    try {
        ServiceBean bean = (ServiceBean) ctx.getBean("service");
        List<URL> urls = bean.getExportedUrls();
        assertEquals(1, urls.size());
        URL url = urls.get(0);
        assertEquals("sayName,getBox", url.getParameter("methods"));
    } finally {
        ctx.stop();
        ctx.close();
    }
}
项目:cas4.0.x-server-wechat    文件:MemCacheTicketRegistryTests.java   
@Before
public void setUp() {
    // Memcached is a required external test fixture.
    // Abort tests if there is no memcached server available on localhost:11211.
    final boolean environmentOk = isMemcachedListening();
    if (!environmentOk) {
        logger.warn("Aborting test since no memcached server is available on localhost.");
    }
    Assume.assumeTrue(environmentOk);

    context = new ClassPathXmlApplicationContext("/ticketRegistry-test.xml");
    registry = context.getBean(registryBean, MemCacheTicketRegistry.class);
}
项目:EasyHousing    文件:OrderBuildingTest.java   
@Test
public void insert() {
    ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
    OrderBuildingDao dao = (OrderBuildingDao) ac.getBean("orderBuildingDao");
    OrderBuilding c = new OrderBuilding();
    c.setAgentId(1);
    c.setBuildingId(1);
    c.setOrderStatus("���");
    c.setOrderTime(new Date());
    c.setUserId(1);
    c.setUserPhoneNumber("18059xxxxxx");
    dao.insertOrderBuilding(c);
}
项目:dubbocloud    文件:ConfigTest.java   
@Test
public void testMultiProtocolDefault() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol-default.xml");
    ctx.start();
    try {
        DemoService demoService = refer("rmi://127.0.0.1:10991");
        String hello = demoService.sayName("hello");
        assertEquals("say:hello", hello);
    } finally {
        ctx.stop();
        ctx.close();
    }
}
项目:minsx-java-example    文件:BookService.java   
@SuppressWarnings("resource")
public BookService() {
    // 容器
    ApplicationContext ctx = new ClassPathXmlApplicationContext("/com/demo/ioca/IOCBeans.xml");
    // 从容器中获得id为bookdao的bean
    bookDAO = (IBookDAO) ctx.getBean("bookdao");
}