当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationContext.getBean方法代码示例

本文整理汇总了Java中org.springframework.context.ApplicationContext.getBean方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationContext.getBean方法的具体用法?Java ApplicationContext.getBean怎么用?Java ApplicationContext.getBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.context.ApplicationContext的用法示例。


在下文中一共展示了ApplicationContext.getBean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception
{
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    mimetypeService = serviceRegistry.getMimetypeService();
    transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig");
    registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry");
    transactionService = serviceRegistry.getTransactionService();
    repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
    nodeService = serviceRegistry.getNodeService();
    contentService = serviceRegistry.getContentService();
    
    assertNotNull("MimetypeMap not present", this.mimetypeService);
    assertNotNull("ServiceRegistry not present", serviceRegistry);
    assertNotNull("TransformerDebug not present", transformerDebug);
    assertNotNull("TransformerConfig not present", transformerConfig);
    assertNotNull("transactionService not present", transactionService);
    assertNotNull("repositoryHelper not present", repositoryHelper);
    assertNotNull("nodeService not present", nodeService);
    assertNotNull("contentService not present", contentService);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:DifferrentMimeTypeTest.java

示例2: findServices

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private static void findServices()
{
    ApplicationContext ctx = testContext.getApplicationContext();
    
    copyService = ctx.getBean("CopyService", CopyService.class);
    nodeService = ctx.getBean("NodeService", NodeService.class);
    directQuickShareService = ctx.getBean("quickShareService", QuickShareService.class);
    quickShareService = ctx.getBean("QuickShareService", QuickShareService.class);
    repository = ctx.getBean("repositoryHelper", Repository.class);
    attributeService = ctx.getBean("AttributeService", AttributeService.class);
    permissionService = ctx.getBean("PermissionService", PermissionService.class);
    nodeArchiveService = ctx.getBean("nodeArchiveService", NodeArchiveService.class);
    scheduledPersistedActionService = ctx.getBean("scheduledPersistedActionService", ScheduledPersistedActionService.class);
    quickShareLinkExpiryActionPersister = ctx.getBean("quickShareLinkExpiryActionPersister", QuickShareLinkExpiryActionPersister.class);
    transactionHelper = ctx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    globalProperties = ctx.getBean("global-properties", Properties.class);
    siteService = (SiteService) ctx.getBean("SiteService");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:QuickShareServiceIntegrationTest.java

示例3: delete

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@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));
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:9,代码来源:OrderRentHouseTest.java

示例4: getCtxAndSetBeans

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private void getCtxAndSetBeans()
{
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    this.customModelService = ctx.getBean("customModelService", CustomModelService.class);
    this.transactionHelper = ctx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:CustomModelRepoRestartTest.java

示例5: deletePerson

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * This method deletes the specified user's person and authentication details if they are
 * present in the system.
 * This method does not handle transactions.
 * 
 * @param userName the username of the user to be deleted.
 */
protected void deletePerson(final String userName)
{
    // Get the spring context
    final ApplicationContext ctxt = getApplicationContext();
    
    // Extract required service beans
    final TestUserComponent testUserComponent = (TestUserComponent) ctxt.getBean("testUserComponent");
    
    testUserComponent.deleteTestUser(userName);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:AbstractPersonRule.java

示例6: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext*.xml");
    final IndustryProcessor industryProcessor = applicationContext.getBean(IndustryProcessor.class);
    industryProcessor.crawl();
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:6,代码来源:IndustryProcessor.java

示例7: helloTest

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Test
public void helloTest() {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    RpcProxy proxy = (RpcProxy) context.getBean("buddha-rpc-proxy");
    IHelloService service = proxy.newProxy(IHelloService.class);
    for (int i = 0; i < 100; i++) {
        String result = service.hello("chenyang");
        System.out.println(result);
    }

}
 
开发者ID:tinylcy,项目名称:buddha,代码行数:12,代码来源:HelloServiceTest.java

示例8: SimpleDocumentDbRepository

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public SimpleDocumentDbRepository(DocumentDbEntityInformation<T, ID> metadata,
                                  ApplicationContext applicationContext) {
    this.documentDbOperations = applicationContext.getBean(DocumentDbOperations.class);
    this.entityInformation = metadata;
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:6,代码来源:SimpleDocumentDbRepository.java

示例9: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) {
	// TODO Auto-generated method stub
	ApplicationContext context=new ClassPathXmlApplicationContext("connection_new.xml");
	BookDAO bookDAO=(BookDAO) context.getBean("bookDAO_jdbcTemplate");
	//add book
	int rows=bookDAO.addBook(new Book("Java EE 7 Developer Handbook", 97815678L,"PacktPub publication",332,"explore the Java EE7 programming","Peter pilgrim"));
    if(rows>0)
    {
    	System.out.println("book inserted successfully");
    }
    else
    	System.out.println("SORRY!cannot add book");

    //update the book
	rows=bookDAO.updateBook(97815678L,432);
    if(rows>0)
    {
    	System.out.println("book updated successfully");
    }
    else
    	System.out.println("SORRY!cannot update book");

    //delete the book
    boolean deleted=bookDAO.deleteBook(97815678L);
    if(deleted)
    {
    	System.out.println("book deleted successfully");
    }
    else
    	System.out.println("SORRY!cannot delete book");

}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:33,代码来源:MainBookDAO_operations.java

示例10: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args){
	ApplicationContext ctx = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext.xml");  
	StorageBean p = (StorageBean)ctx.getBean("diskStorage");  
	ConfigurationContext.propMap.putIfAbsent("storage", p.getName());		
	ServerStarter container = new ServerStarter();
	try {
		container.start();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:polarcoral,项目名称:pandora,代码行数:13,代码来源:PandoraServerBootstrap.java

示例11: testSpringSpringConnectionProvider1

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Tests dialect configuration.
 */
public void testSpringSpringConnectionProvider1() throws Exception {
	ApplicationContext applicationContext = new ClassPathXmlApplicationContext(APPLICATION_CONTEXT);

	SqlManager sqlManager = (SqlManager) applicationContext.getBean("sqlManager");

	Field field = SqlManagerImpl.class.getDeclaredField("dialect");
	field.setAccessible(true);
	Dialect dialect = (Dialect) field.get(sqlManager);

	assertTrue(dialect instanceof HyperSQLDialect);
}
 
开发者ID:mirage-sql,项目名称:mirage-integration,代码行数:15,代码来源:SpringConnectionProviderTest.java

示例12: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext
       ("META-INF/spring/app-context.xml");

    MessageRenderer mr = ctx.getBean("renderer", MessageRenderer.class);
    mr.render();
}
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:8,代码来源:DependencyPull.java

示例13: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	XxlJobDynamicScheduler.xxlJobLogDao = applicationContext.getBean(IXxlJobLogDao.class);
	XxlJobDynamicScheduler.xxlJobInfoDao = applicationContext.getBean(IXxlJobInfoDao.class);
       XxlJobDynamicScheduler.xxlJobRegistryDao = applicationContext.getBean(IXxlJobRegistryDao.class);
       XxlJobDynamicScheduler.xxlJobGroupDao = applicationContext.getBean(IXxlJobGroupDao.class);
}
 
开发者ID:kevinKaiF,项目名称:xxl-job,代码行数:8,代码来源:XxlJobDynamicScheduler.java

示例14: Test1

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@Test
public void Test1(){
	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);
	buildingDealDao.insertBuildingDeal(u);
	System.out.println("-------");
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:16,代码来源:TestBuildingDealDao.java

示例15: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) {
	//read and print the employee i.e parent object
	ApplicationContext ctx=new ClassPathXmlApplicationContext(
			"com/app/cfg/Springconfig_Autowiring_MultipleMatch.xml");
	Employee e=(Employee)ctx.getBean("emp");
		System.out.println(e);
}
 
开发者ID:pratikdimble,项目名称:Spring_Autowiring_Annotation_OneMatch_MultipleMatch_Qualifier,代码行数:8,代码来源:ClientApp_Autowiring_MultipleMatch.java


注:本文中的org.springframework.context.ApplicationContext.getBean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。