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