本文整理汇总了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);
}
示例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");
}
示例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));
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
}
示例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;
}
示例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");
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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("-------");
}
示例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