當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationContext類代碼示例

本文整理匯總了Java中org.springframework.context.ApplicationContext的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationContext類的具體用法?Java ApplicationContext怎麽用?Java ApplicationContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApplicationContext類屬於org.springframework.context包,在下文中一共展示了ApplicationContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setApplicationContext

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Override
public final void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;

    try {
        logger.info("Initializing {} root application context", contextInitializerName);
        initializeRootApplicationContext();
        logger.info("Initialized {} root application context successfully", contextInitializerName);

        logger.info("Initializing {} servlet application context", contextInitializerName);
        initializeServletApplicationContext();
        logger.info("Initialized {} servlet application context successfully", contextInitializerName);
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:17,代碼來源:AbstractServletContextInitializer.java

示例2: jettyServer

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Bean
public Server jettyServer(ApplicationContext context) throws Exception {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    Servlet servlet = new JettyHttpHandlerAdapter(handler);

    Server server = new Server();
    ServletContextHandler contextHandler = new ServletContextHandler(server, "");
    contextHandler.addServlet(new ServletHolder(servlet), "/");
    contextHandler.start();

    ServerConnector connector = new ServerConnector(server);
    connector.setHost("localhost");
    connector.setPort(port);
    server.addConnector(connector);

    return server;
}
 
開發者ID:hantsy,項目名稱:spring-reactive-sample,代碼行數:18,代碼來源:Application.java

示例3: Test4

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Test
public void Test4(){
	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("111��һ��");
	u.setUserId(1);
	u.setBuildingDealId(1);
	buildingDealDao.deleteBuildingDeal(u);
	System.out.println(u.getBuildingLayout());
}
 
開發者ID:632team,項目名稱:EasyHousing,代碼行數:17,代碼來源:TestBuildingDealDao.java

示例4: mockApplicationContext

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Before
public void mockApplicationContext() {
	final ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
	SpringUtils.setSharedApplicationContext(applicationContext);
	mockLdapResource = Mockito.mock(UserOrgResource.class);
	final UserFullLdapTask mockTask = new UserFullLdapTask();
	mockTask.resource = mockLdapResource;
	mockTask.securityHelper = securityHelper;
	final UserAtomicLdapTask mockTaskUpdate = new UserAtomicLdapTask();
	mockTaskUpdate.resource = mockLdapResource;
	mockTaskUpdate.securityHelper = securityHelper;
	Mockito.when(applicationContext.getBean(SessionSettings.class)).thenReturn(new SessionSettings());
	Mockito.when(applicationContext.getBean((Class<?>) ArgumentMatchers.any(Class.class))).thenAnswer((Answer<Object>) invocation -> {
		final Class<?> requiredType = (Class<Object>) invocation.getArguments()[0];
		if (requiredType == UserFullLdapTask.class) {
			return mockTask;
		}
		if (requiredType == UserAtomicLdapTask.class) {
			return mockTaskUpdate;
		}
		return UserBatchLdapResourceTest.super.applicationContext.getBean(requiredType);
	});

	mockTaskUpdate.jaxrsFactory = ServerProviderFactory.createInstance(null);
}
 
開發者ID:ligoj,項目名稱:plugin-id,代碼行數:27,代碼來源:UserBatchLdapResourceTest.java

示例5: after

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Override protected void after()
{
    // Set up required services
    ApplicationContext ctxt = getApplicationContext();
    final RetryingTransactionHelper transactionHelper = (RetryingTransactionHelper) ctxt.getBean("retryingTransactionHelper");
    
    transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override public Void execute() throws Throwable
        {
            for (Map.Entry<String, NodeRef> entry : usersPersons.entrySet())
            {
                deletePerson(entry.getKey());
            }
            
            return null;
        }
    });
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:20,代碼來源:AlfrescoPeople.java

示例6: main

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
public static void main(String[] args) {

		ApplicationContext ctx =  SpringApplication.run(LearnspringdiApplication.class, args);

		//Always the bean name will be equivalent to the class name (but starts with lowercase)
		FirstController controller = (FirstController) ctx.getBean("firstController");
		System.out.println(controller.sayHello());
		System.out.println(ctx.getBean(PropertyInjectController.class).sayHello());
		System.out.println(ctx.getBean(SetterInjectController.class).sayHello());
		System.out.println(ctx.getBean(ConstructorInjectController.class).sayHello());

		TestDataSource testDataSource = (TestDataSource) ctx.getBean(TestDataSource.class);
		System.out.println("Reading value from external Property File :"+ testDataSource.getDbUrl());

        TestEnvProp testEnvProp = (TestEnvProp) ctx.getBean(TestEnvProp.class);
        System.out.println("Accessed System value through Spring Environmet Variable "+testEnvProp.getSystemUserName());
        System.out.println("Accessed System value directly via Spring @Value Annotation :"+testEnvProp.JAVA_VERSION);

        TestJmsBroker testJmsBroker = (TestJmsBroker) ctx.getBean(TestJmsBroker.class);
        System.out.println("Accessed multiple property file values using @PropertySources :"+testJmsBroker.getJmsUrl());
	}
 
開發者ID:murugan425,項目名稱:learn-spring-5,代碼行數:22,代碼來源:LearnspringdiApplication.java

示例7: setApplicationContext

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	try {
		repository = repositoryBuilder.getRepository();
		SimpleCredentials cred = new SimpleCredentials("admin", "admin".toCharArray());
		cred.setAttribute("AutoRefresh", true);
		session = repository.login(cred, null);
		versionManager = session.getWorkspace().getVersionManager();
		lockManager=session.getWorkspace().getLockManager();
		Collection<RepositoryInteceptor> repositoryInteceptors=applicationContext.getBeansOfType(RepositoryInteceptor.class).values();
		if(repositoryInteceptors.size()==0){
			repositoryInteceptor=new DefaultRepositoryInteceptor();
		}else{
			repositoryInteceptor=repositoryInteceptors.iterator().next();
		}
	} catch (Exception ex) {
		throw new RuleException(ex);
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:20,代碼來源:BaseRepositoryService.java

示例8: release

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Override
public void release() {
	if (this.applicationContext != null) {
		ApplicationContext savedCtx;

		// We don't actually guarantee thread-safety, but it's not a lot of extra work.
		synchronized (this) {
			savedCtx = this.applicationContext;
			this.applicationContext = null;
		}

		if (savedCtx != null && savedCtx instanceof ConfigurableApplicationContext) {
			((ConfigurableApplicationContext) savedCtx).close();
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:ContextBeanFactoryReference.java

示例9: Test2

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@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("-------");
}
 
開發者ID:632team,項目名稱:EasyHousing,代碼行數:18,代碼來源:TestBuildingLayoutDao.java

示例10: refresh

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Override
public void refresh(ApplicationContext applicationContext)
{
	unResolvePostProcessList = new ArrayList<>();

	Map<String, UnResolvePostProcess> unResolvePostProcessMap = applicationContext.getBeansOfType(UnResolvePostProcess.class);

	if (!CollectionUtils.isEmpty(unResolvePostProcessMap)) {
		unResolvePostProcessList.addAll(unResolvePostProcessMap.values());
	}
	unResolvePostProcessMap = null;

	unResolveFieldPostProcessList = new ArrayList<>();

	Map<String, UnResolveFieldPostProcess> unResolveFieldPostProcessMap = applicationContext.getBeansOfType(UnResolveFieldPostProcess.class);

	if (!CollectionUtils.isEmpty(unResolveFieldPostProcessMap)) {
		unResolveFieldPostProcessList.addAll(unResolveFieldPostProcessMap.values());
	}
	unResolveFieldPostProcessMap = null;

}
 
開發者ID:yanghao0518,項目名稱:cstruct-parser,代碼行數:23,代碼來源:AbstractResolve.java

示例11: main

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);  // (1)

    Tomcat tomcatServer = context.getBean(Tomcat.class);
    tomcatServer.start();

    System.out.println("Press ENTER to exit.");
    System.in.read();
}
 
開發者ID:hantsy,項目名稱:spring-reactive-sample,代碼行數:10,代碼來源:Application.java

示例12: select

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Test
public void select() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
	RentHousePicDao dao = (RentHousePicDao) ac.getBean("rentHousePicDao");
	RentHousePic c = new RentHousePic();
	c.setRentHousePicId(2);
	System.out.println(dao.selectRentHousePic(c).getPicUrl());
}
 
開發者ID:632team,項目名稱:EasyHousing,代碼行數:9,代碼來源:RentHousePicTest.java

示例13: test

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Test
public void test(){
    ApplicationContext atc=new AnnotationConfigApplicationContext(SystemXml.class);
    SystemXmlMap map=(SystemXmlMap)atc.getBean("systemXmlMap");
    PrinterUtils.printILog(map.toString());

    Environment environment=(Environment)atc.getBean("environment");
    PrinterUtils.printILog(environment.getProperty("username"));
}
 
開發者ID:tomoncle,項目名稱:JavaStudy,代碼行數:10,代碼來源:App.java

示例14: nettyContext

import org.springframework.context.ApplicationContext; //導入依賴的package包/類
@Bean(name="serverBrowse")
public NettyContext nettyContext(ApplicationContext context) {
	HttpHandler handler = DispatcherHandler.toHttpHandler(context);
	ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
	HttpServer httpServer = HttpServer.create(host, port);
	return httpServer.newHandler(adapter).block();
}
 
開發者ID:guilhebl,項目名稱:item-shop-reactive-backend,代碼行數:8,代碼來源:Server.java

示例15: 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


注:本文中的org.springframework.context.ApplicationContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。