當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。