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


Java ContextLoaderListener.getCurrentWebApplicationContext方法代码示例

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


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

示例1: initialize

import org.springframework.web.context.ContextLoaderListener; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void initialize() throws ServletException {
	super.initialize();
	TimeZone.setDefault(TimeZone.getTimeZone("UTC"));


	FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU3;
	setFhirContext(new FhirContext(fhirVersion));

	// Get the spring context from the web container (it's declared in web.xml)
	myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();

       if (serverBase != null && !serverBase.isEmpty()) {
           setServerAddressStrategy(new HardcodedServerAddressStrategy(serverBase));
       }


	setResourceProviders(Arrays.asList(
			 myAppCtx.getBean(PatientResourceProvider.class)
              	,myAppCtx.getBean(OrganisationResourceProvider.class)
               ,myAppCtx.getBean(PractitionerResourceProvider.class)
               ,myAppCtx.getBean(LocationResourceProvider.class)
              	,myAppCtx.getBean(PractitionerRoleResourceProvider.class)
     			,myAppCtx.getBean(ObservationResourceProvider.class) // Sprint 4 addition KGM
			,myAppCtx.getBean(EncounterResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(ConditionResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(ProcedureResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(AllergyIntoleranceResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(MedicationRequestResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(MedicationStatementResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(ImmunizationResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(BundleResourceProvider.class) // Bunlde upload mock

			// ,myAppCtx.getBean(EpisodeOfCareResourceProvider.class) // TO DO Remove me for live KGM
	));

       // Replace built in conformance provider (CapabilityStatement)
       setServerConformanceProvider(new CareConnectConformanceProvider( ));

       setServerName(serverName);
       setServerVersion(serverVersion);


	// This is the format for each line. A number of substitution variables may
	// be used here. See the JavaDoc for LoggingInterceptor for information on
	// what is available.

	ServerInterceptor gatewayInterceptor = new ServerInterceptor(log);
	registerInterceptor(gatewayInterceptor);
	//gatewayInterceptor.setLoggerName("ccri.FHIRGateway");
	//gatewayInterceptor.setLogger(ourLog);

	// This paging provider is not robust KGM 24/11/2017

	// Mocking of a database Paging Provider is in server

	FifoMemoryPagingProvider pp = new FifoMemoryPagingProvider(10);
	pp.setDefaultPageSize(10);
	pp.setMaximumPageSize(100);
	setPagingProvider(pp);

	setDefaultPrettyPrint(true);
	setDefaultResponseEncoding(EncodingEnum.JSON);

	FhirContext ctx = getFhirContext();
	// Remove as believe due to issues on docker ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:69,代码来源:HAPIRestfulConfig.java

示例2: initialize

import org.springframework.web.context.ContextLoaderListener; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
  @Override
  protected void initialize() throws ServletException {
      super.initialize();
      TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

      // Get the spring context from the web container (it's declared in web.xml)
      myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();

      AutowireCapableBeanFactory autowireCapableBeanFactory = myAppCtx.getAutowireCapableBeanFactory();
      autowireCapableBeanFactory.autowireBean(this);

      ourLog.info("REST Servlet initialised with config: " + toString());

/* 
       * We want to support FHIR DSTU2 format. This means that the server
 * will use the DSTU2 bundle format and other DSTU2 encoding changes.
 *
 * If you want to use DSTU1 instead, change the following line, and change the 2 occurrences of dstu2 in web.xml to dstu1
 */

      if (serverBase != null && !serverBase.isEmpty()) {
          setServerAddressStrategy(new HardcodedServerAddressStrategy(serverBase));
      }

      FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU3;
      setFhirContext(new FhirContext(fhirVersion));

/*
 * The BaseJavaConfigDstu2.java class is a spring configuration
 * file which is automatically generated as a part of hapi-fhir-jpaserver-base and
 * contains bean definitions for a resource provider for each resource type
 */
      setResourceProviders(Arrays.asList(
              myAppCtx.getBean(PatientProvider.class),
              myAppCtx.getBean(OrganizationProvider.class),
              myAppCtx.getBean(PractitionerProvider.class),
              myAppCtx.getBean(LocationProvider.class),
              myAppCtx.getBean(ValueSetProvider.class),
              myAppCtx.getBean(StructureDefinitionProvider.class),
              myAppCtx.getBean(CodeSystemProvider.class),
              myAppCtx.getBean(ObservationProvider.class),
              myAppCtx.getBean(PractitionerRoleProvider.class)
              ,myAppCtx.getBean(EncounterProvider.class)
              ,myAppCtx.getBean(EpisodeOfCareProvider.class)
              ,myAppCtx.getBean(AllergyIntoleranceProvider.class)
              ,myAppCtx.getBean(ConditionProvider.class)
              ,myAppCtx.getBean(ProcedureProvider.class)
              ,myAppCtx.getBean(ImmunizationProvider.class)
              ,myAppCtx.getBean(MedicationRequestProvider.class)
              ,myAppCtx.getBean(MedicationStatementProvider.class)
              // Basic implementation of reporting resources
              ,myAppCtx.getBean(CompositionProvider.class)
              ,myAppCtx.getBean(DocumentReferenceProvider.class)
              ,myAppCtx.getBean(DiagnosticReportProvider.class)
              ,myAppCtx.getBean(CarePlanProvider.class)

      ));

      // Replace built in conformance provider (CapabilityStatement)
      setServerConformanceProvider(new CareConnectServerConformanceProvider());

      ServerInterceptor loggingInterceptor = new ServerInterceptor(ourLog);
      registerInterceptor(loggingInterceptor);

     // KGM 24/11/2017
      // Mocked for exploration only setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class));

      // not fully tested registerProvider(myAppCtx.getBean(TerminologyUploaderProvider.class));
      setDefaultPrettyPrint(true);
      setDefaultResponseEncoding(EncodingEnum.JSON);

      ctx = getFhirContext();
      // Remove as believe due to issues on docker ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
  }
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:76,代码来源:HAPIRestfulConfig.java

示例3: initialize

import org.springframework.web.context.ContextLoaderListener; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void initialize() throws ServletException {
	super.initialize();
	TimeZone.setDefault(TimeZone.getTimeZone("UTC"));


	FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU3;
	setFhirContext(new FhirContext(fhirVersion));

	// Get the spring context from the web container (it's declared in web.xml)
	myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();

       if (serverBase != null && !serverBase.isEmpty()) {
           setServerAddressStrategy(new HardcodedServerAddressStrategy(serverBase));
       }


	setResourceProviders(Arrays.asList(
			 myAppCtx.getBean(PatientResourceProvider.class)
              	,myAppCtx.getBean(OrganisationResourceProvider.class)
               ,myAppCtx.getBean(PractitionerResourceProvider.class)
               ,myAppCtx.getBean(LocationResourceProvider.class)
              	,myAppCtx.getBean(PractitionerRoleResourceProvider.class)
     			,myAppCtx.getBean(ObservationResourceProvider.class) // Sprint 4 addition KGM
			,myAppCtx.getBean(EncounterResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(ConditionResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(ProcedureResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(AllergyIntoleranceResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(MedicationRequestResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(MedicationStatementResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(ImmunizationResourceProvider.class) // R3 addition KGM
			,myAppCtx.getBean(EpisodeOfCareResourceProvider.class) // TO DO Remove me for live KGM
	));

       // Replace built in conformance provider (CapabilityStatement)
       setServerConformanceProvider(new CareConnectConformanceProvider(oauth2authorize
			,oauth2token
			,oauth2register));

       setServerName(serverName);
       setServerVersion(serverVersion);


	// This is the format for each line. A number of substitution variables may
	// be used here. See the JavaDoc for LoggingInterceptor for information on
	// what is available.

	ServerInterceptor gatewayInterceptor = new ServerInterceptor(ourLog);
	registerInterceptor(new OAuth2Interceptor());  // Add OAuth2 Security Filter
	registerInterceptor(gatewayInterceptor);

	//gatewayInterceptor.setLoggerName("ccri.FHIRGateway");
	//gatewayInterceptor.setLogger(ourLog);

	setDefaultPrettyPrint(true);
	setDefaultResponseEncoding(EncodingEnum.JSON);

	FhirContext ctx = getFhirContext();
	// Remove as believe due to issues on docker ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:62,代码来源:HAPIRestfulConfig.java

示例4: initialize

import org.springframework.web.context.ContextLoaderListener; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void initialize() throws ServletException {
	super.initialize();

	/* 
	 * We want to support FHIR DSTU2 format. This means that the server
	 * will use the DSTU2 bundle format and other DSTU2 encoding changes.
	 *
	 * If you want to use DSTU1 instead, change the following line, and change the 2 occurrences of dstu2 in web.xml to dstu1
	 */
	FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU2;
	setFhirContext(new FhirContext(fhirVersion));

	// Get the spring context from the web container (it's declared in web.xml)
	myAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();

	/* 
	 * The hapi-fhir-server-resourceproviders-dev.xml file is a spring configuration
	 * file which is automatically generated as a part of hapi-fhir-jpaserver-base and
	 * contains bean definitions for a resource provider for each resource type
	 */
	List<IResourceProvider> beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class);
	setResourceProviders(beans);
	
	/* 
	 * The system provider implements non-resource-type methods, such as
	 * transaction, and global history.
	 */
	Object systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
	setPlainProviders(systemProvider);

	/*
	 * The conformance provider exports the supported resources, search parameters, etc for
	 * this server. The JPA version adds resource counts to the exported statement, so it
	 * is a nice addition.
	 */
	IFhirSystemDao<Bundle> systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
	JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao);
	confProvider.setImplementationDescription("Example Server");
	setServerConformanceProvider(confProvider);

	/*
	 * Enable ETag Support (this is already the default)
	 */
	setETagSupport(ETagSupportEnum.ENABLED);

	/*
	 * This tells the server to use "browser friendly" MIME types if it 
	 * detects that the request is coming from a browser, in the hopes that the 
	 * browser won't just treat the content as a binary payload and try 
	 * to download it (which is what generally happens if you load a 
	 * FHIR URL in a browser). 
	 * 
	 * This means that the server isn't technically complying with the 
	 * FHIR specification for direct browser requests, but this mode
	 * is very helpful for testing and troubleshooting since it means 
	 * you can look at FHIR URLs directly in a browser.  
	 */
	setUseBrowserFriendlyContentTypes(true);

	/*
	 * Default to XML and pretty printing
	 */
	setDefaultPrettyPrint(true);
	setDefaultResponseEncoding(EncodingEnum.JSON);

	/*
	 * This is a simple paging strategy that keeps the last 10 searches in memory
	 */
	setPagingProvider(new FifoMemoryPagingProvider(10));

	/*
	 * Load interceptors for the server from Spring (these are defined in hapi-fhir-server-config.xml
	 */
	List<IServerInterceptor> interceptorBeans = myAppCtx.getBean("myServerInterceptors", List.class);
	for (IServerInterceptor interceptor : interceptorBeans) {
		this.registerInterceptor(interceptor);
	}

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:82,代码来源:JpaServerDemo.java


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