diff --git a/hapi-fhir-base-example-embedded-ws/.classpath b/hapi-fhir-base-example-embedded-ws/.classpath
new file mode 100644
index 00000000000..9cbcd519d58
--- /dev/null
+++ b/hapi-fhir-base-example-embedded-ws/.classpath
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hapi-fhir-base-example-embedded-ws/.project b/hapi-fhir-base-example-embedded-ws/.project
index dfe12454643..350f75695ef 100644
--- a/hapi-fhir-base-example-embedded-ws/.project
+++ b/hapi-fhir-base-example-embedded-ws/.project
@@ -1,10 +1,20 @@
hapi-fhir-base-example-embedded-ws
-
+ NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
org.eclipse.m2e.core.maven2Builder
@@ -12,6 +22,10 @@
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.m2e.core.maven2Nature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.wst.common.project.facet.core.nature
diff --git a/hapi-fhir-base-example-embedded-ws/pom.xml b/hapi-fhir-base-example-embedded-ws/pom.xml
index 189c558de0e..a9c68c05d86 100644
--- a/hapi-fhir-base-example-embedded-ws/pom.xml
+++ b/hapi-fhir-base-example-embedded-ws/pom.xml
@@ -26,25 +26,30 @@
com.google.inject
guice
- 3.0
+ 4.1.0
com.google.inject.extensions
guice-servlet
- 3.0
+ 4.1.0
com.sun.jersey.contribs
jersey-guice
- 1.18.1
+ 1.19.1
+
+
+ org.ebaysf.web
+ cors-filter
ca.uhn.hapi.fhir
hapi-fhir-structures-dstu2
- 1.2
+ 2.1-SNAPSHOT
+
-
+
@@ -56,5 +61,5 @@
-
+
\ No newline at end of file
diff --git a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ContextListener.java b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ContextListener.java
index 02019b886cb..20cb9c43c7a 100644
--- a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ContextListener.java
+++ b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ContextListener.java
@@ -1,18 +1,14 @@
package embedded;
-import java.util.Map;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
+import javax.inject.Singleton;
+
+import org.ebaysf.web.cors.CORSFilter;
+
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
-import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
-import com.sun.jersey.api.core.ResourceConfig;
import com.sun.jersey.guice.JerseyServletModule;
-import filters.CharsetResponseFilter;
-import filters.CorsResponseFilter;
-
public class ContextListener extends GuiceServletContextListener {
@Override
@@ -22,15 +18,9 @@ public class ContextListener extends GuiceServletContextListener {
@Override
protected void configureServlets() {
- final Map params = ImmutableMap
- . builder()
- .put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
- Joiner.on(";").join(
- CharsetResponseFilter.class.getName(),
- CorsResponseFilter.class.getName(),
- GZIPContentEncodingFilter.class
- .getName())).build();
- serve("/model/*").with(FhirRestfulServlet.class, params);
+ bind(CORSFilter.class).in(Singleton.class);
+ filter("/*").through(CORSFilter.class);
+ serve("/model/*").with(FhirRestfulServlet.class);
}
});
}
diff --git a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/FhirRestfulServlet.java b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/FhirRestfulServlet.java
index a7e082015b9..e197c62edda 100644
--- a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/FhirRestfulServlet.java
+++ b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/FhirRestfulServlet.java
@@ -6,8 +6,6 @@ import java.util.List;
import javax.inject.Singleton;
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
-import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
@@ -29,29 +27,10 @@ public class FhirRestfulServlet extends RestfulServer {
*/
@Override
public void initialize() {
- /*
- * Two resource providers are defined. Each one handles a specific type
- * of resource.
- */
final List providers = new ArrayList();
providers.add(new SomeResourceProvider());
setResourceProviders(providers);
- /*
- * Use a narrative generator. This is a completely optional step, but
- * can be useful as it causes HAPI to generate narratives for resources
- * which don't otherwise have one.
- */
- final INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator();
- getFhirContext().setNarrativeGenerator(narrativeGen);
-
- /*
- * Tells HAPI to use content types which are not technically FHIR
- * compliant when a browser is detected as the requesting client. This
- * prevents browsers from trying to download resource responses instead
- * of displaying them inline which can be handy for troubleshooting.
- */
- setUseBrowserFriendlyContentTypes(true);
registerInterceptor(new ResponseHighlighterInterceptor());
diff --git a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java
index fb8dde91365..5cf844aad02 100644
--- a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java
+++ b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java
@@ -1,4 +1,5 @@
package embedded;
+
import java.util.EnumSet;
import javax.servlet.DispatcherType;
@@ -16,10 +17,12 @@ public class ServerStartup {
final Server server = new Server(9090);
final ServletContextHandler sch = new ServletContextHandler(server, "/");
sch.addEventListener(new ContextListener());
- sch.addFilter(GuiceFilter.class, "/*",
- EnumSet.of(DispatcherType.REQUEST));
+ sch.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
sch.addServlet(DefaultServlet.class, "/");
- server.start();
+ server.start();
+
+ // Service is now accessible through
+ // http://localhost:9090/model/Practitioner
}
}
diff --git a/hapi-fhir-standalone-overlay-example/.classpath b/hapi-fhir-standalone-overlay-example/.classpath
new file mode 100644
index 00000000000..9cbcd519d58
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/.classpath
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hapi-fhir-standalone-overlay-example/.project b/hapi-fhir-standalone-overlay-example/.project
new file mode 100644
index 00000000000..b1b0d3d01a3
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/.project
@@ -0,0 +1,31 @@
+
+
+ hapi-fhir-standalone-overlay-example
+ NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.wst.common.project.facet.core.nature
+
+
diff --git a/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.core.resources.prefs b/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..99f26c0203a
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.m2e.core.prefs b/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000000..f897a7f1cb2
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/hapi-fhir-standalone-overlay-example/pom.xml b/hapi-fhir-standalone-overlay-example/pom.xml
new file mode 100644
index 00000000000..05efe37315f
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/pom.xml
@@ -0,0 +1,79 @@
+
+ 4.0.0
+
+ ca.uhn.hapi.fhir
+ hapi-fhir
+ 2.1-SNAPSHOT
+
+ hapi-fhir-standalone-overlay-example
+
+
+
+ maven-compiler-plugin
+
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-testpage-overlay
+
+
+ fhirtester
+ true
+
+
+
+
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-testpage-overlay
+ 2.1-SNAPSHOT
+ war
+ provided
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-testpage-overlay
+ 2.1-SNAPSHOT
+ classes
+ provided
+
+
+ org.eclipse.jetty
+ jetty-servlet
+
+
+ org.eclipse.jetty
+ jetty-webapp
+
+
+ com.google.inject
+ guice
+ 4.1.0
+
+
+ com.google.inject.extensions
+ guice-servlet
+ 4.1.0
+
+
+ com.sun.jersey.contribs
+ jersey-guice
+ 1.19.1
+
+
+ org.ebaysf.web
+ cors-filter
+
+
+
+
diff --git a/hapi-fhir-standalone-overlay-example/src/main/java/embedded/example/ContextListener.java b/hapi-fhir-standalone-overlay-example/src/main/java/embedded/example/ContextListener.java
new file mode 100644
index 00000000000..ce89689f297
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/src/main/java/embedded/example/ContextListener.java
@@ -0,0 +1,51 @@
+package embedded.example;
+
+import javax.inject.Singleton;
+import javax.servlet.ServletContextEvent;
+
+import org.ebaysf.web.cors.CORSFilter;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.servlet.GuiceServletContextListener;
+import com.sun.jersey.guice.JerseyServletModule;
+
+public class ContextListener extends GuiceServletContextListener {
+
+ static String username;
+ static String password;
+ static String serverAddress;
+
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ super.contextInitialized(servletContextEvent);
+
+ username = servletContextEvent.getServletContext().getInitParameter("username") != null
+ ? servletContextEvent.getServletContext().getInitParameter("username")
+ : null;
+ password = servletContextEvent.getServletContext().getInitParameter("password") != null
+ ? servletContextEvent.getServletContext().getInitParameter("password")
+ : null;
+ serverAddress = servletContextEvent.getServletContext().getInitParameter("serverAddress") != null
+ ? servletContextEvent.getServletContext().getInitParameter("serverAddress")
+ : null;
+ }
+
+ @Override
+ protected Injector getInjector() {
+ return Guice.createInjector(new JerseyServletModule() {
+
+ @Override
+ protected void configureServlets() {
+
+ AnnotationConfigWebApplicationContext webApp = new AnnotationConfigWebApplicationContext();
+ webApp.setConfigLocation(FhirTesterConfig.class.getName());
+ serve("/*").with(new DispatcherServlet(webApp));
+ bind(CORSFilter.class).in(Singleton.class);
+ filter("/*").through(CORSFilter.class);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/hapi-fhir-standalone-overlay-example/src/main/java/embedded/example/FhirTesterConfig.java b/hapi-fhir-standalone-overlay-example/src/main/java/embedded/example/FhirTesterConfig.java
new file mode 100644
index 00000000000..91a3e9f6b25
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/src/main/java/embedded/example/FhirTesterConfig.java
@@ -0,0 +1,73 @@
+package embedded.example;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+import com.google.common.base.Strings;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.FhirVersionEnum;
+import ca.uhn.fhir.rest.client.IGenericClient;
+import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
+import ca.uhn.fhir.to.FhirTesterMvcConfig;
+import ca.uhn.fhir.to.TesterConfig;
+import ca.uhn.fhir.util.ITestingUiClientFactory;
+
+//@formatter:off
+/**
+ * This spring config file configures the web testing module. It serves two
+ * purposes: 1. It imports FhirTesterMvcConfig, which is the spring config for
+ * the tester itself 2. It tells the tester which server(s) to talk to, via the
+ * testerConfig() method below
+ */
+@Configuration
+@Import(FhirTesterMvcConfig.class)
+public class FhirTesterConfig {
+
+ /**
+ * This bean tells the testing webpage which servers it should configure
+ * itself to communicate with. In this example we configure it to talk to
+ * the local server, as well as one public server. If you are creating a
+ * project to deploy somewhere else, you might choose to only put your own
+ * server's address here.
+ *
+ * Note the use of the ${serverBase} variable below. This will be replaced
+ * with the base URL as reported by the server itself. Often for a simple
+ * Tomcat (or other container) installation, this will end up being
+ * something like "http://localhost:8080/hapi-fhir-jpaserver-example". If
+ * you are deploying your server to a place with a fully qualified domain
+ * name, you might want to use that instead of using the variable.
+ */
+ @Bean
+ public TesterConfig testerConfig() {
+ final TesterConfig retVal = new TesterConfig();
+ retVal.addServer().withId("Test-Server").withFhirVersion(FhirVersionEnum.DSTU2)
+ .withBaseUrl(ContextListener.serverAddress).withName("FHIR Server Test Front End");
+
+ if (!Strings.isNullOrEmpty(ContextListener.username)) {
+ ITestingUiClientFactory clientFactory = new ITestingUiClientFactory() {
+
+ @Override
+ public IGenericClient newClient(FhirContext theFhirContext, HttpServletRequest theRequest,
+ String theServerBaseUrl) {
+ // Create a client
+ IGenericClient client = theFhirContext.newRestfulGenericClient(theServerBaseUrl);
+
+ // Register an interceptor which adds credentials
+ client.registerInterceptor(
+ new BasicAuthInterceptor(ContextListener.username, ContextListener.password));
+
+ return client;
+ }
+
+ };
+ retVal.setClientFactory(clientFactory);
+ }
+ return retVal;
+ }
+
+}
+// @formatter:on
\ No newline at end of file
diff --git a/hapi-fhir-standalone-overlay-example/src/main/webapp/WEB-INF/web.xml b/hapi-fhir-standalone-overlay-example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..8c985e61d0c
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,22 @@
+
+
+
+ Guice Filter
+ com.google.inject.servlet.GuiceFilter
+
+
+ Guice Filter
+ /*
+
+
+ embedded.example.ContextListener
+
+
+
+
+ serverAddress
+ http://fhirtest.uhn.ca/baseDstu2
+
+
\ No newline at end of file
diff --git a/hapi-fhir-standalone-overlay-example/src/test/java/test/WarTester.java b/hapi-fhir-standalone-overlay-example/src/test/java/test/WarTester.java
new file mode 100644
index 00000000000..fffbc626c75
--- /dev/null
+++ b/hapi-fhir-standalone-overlay-example/src/test/java/test/WarTester.java
@@ -0,0 +1,14 @@
+package test;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+public class WarTester {
+
+ public static void main(String[] args) throws Exception {
+ final Server server = new Server(8080);
+ server.setHandler(new WebAppContext("target/fhirtester.war", "/"));
+ server.start();
+ }
+
+}