Enhanced android documentation
This commit is contained in:
parent
f80bf98dcd
commit
4c2841436f
|
@ -40,6 +40,11 @@
|
||||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||||
<version>2.1-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
<artifactId>hapi-fhir-client-okhttp</artifactId>
|
||||||
|
<version>2.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-jaxrsserver-base</artifactId>
|
<artifactId>hapi-fhir-jaxrsserver-base</artifactId>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package example;
|
package example;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.okhttp.client.OkHttpRestfulClientFactory;
|
||||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||||
import ca.uhn.fhir.rest.client.IRestfulClientFactory;
|
import ca.uhn.fhir.rest.client.IRestfulClientFactory;
|
||||||
import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor;
|
import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor;
|
||||||
|
@ -34,6 +35,19 @@ public class ClientExamples {
|
||||||
// END SNIPPET: proxy
|
// END SNIPPET: proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void createOkHttp() {
|
||||||
|
// START SNIPPET: okhttp
|
||||||
|
FhirContext ctx = FhirContext.forDstu3();
|
||||||
|
|
||||||
|
// Use OkHttp
|
||||||
|
ctx.setRestfulClientFactory(new OkHttpRestfulClientFactory(ctx));
|
||||||
|
|
||||||
|
// Create the client
|
||||||
|
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
|
||||||
|
// END SNIPPET: okhttp
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void createTimeouts() {
|
public void createTimeouts() {
|
||||||
// START SNIPPET: timeouts
|
// START SNIPPET: timeouts
|
||||||
|
|
|
@ -60,6 +60,11 @@
|
||||||
<artifactId>hapi-fhir-client-okhttp</artifactId>
|
<artifactId>hapi-fhir-client-okhttp</artifactId>
|
||||||
<version>2.1-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.woodstox</groupId>
|
<groupId>org.codehaus.woodstox</groupId>
|
||||||
|
|
3
pom.xml
3
pom.xml
|
@ -269,9 +269,6 @@
|
||||||
<!-- configure timestamp in MANIFEST.MF for maven-war-provider -->
|
<!-- configure timestamp in MANIFEST.MF for maven-war-provider -->
|
||||||
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
|
||||||
|
|
||||||
<!-- This property is used in some of the site documentation where the version is shown, so that we can deploy the site even if the project is on a snapshot version. -->
|
|
||||||
<hapi_stable_version>1.4</hapi_stable_version>
|
|
||||||
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
<!-- For site-deploy -->
|
<!-- For site-deploy -->
|
||||||
|
|
|
@ -69,6 +69,21 @@
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section name="Examples">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following is intended to be a selection of publicly available open source
|
||||||
|
Android applications which use HAPI FHIR and might be useful as a reference.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you know of others, please let us know!
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://github.com/SynappzMA/FHIR-Android">https://github.com/SynappzMA/FHIR-Android</a> (Nice FHIR DSTU2 search app)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
While this process is not particularly significant on reasonably
|
While this process is not particularly significant on reasonably
|
||||||
performant machines (current benchmarks show that this takes
|
performant machines (one benchmark showed that this takes
|
||||||
roughly 6 seconds on one developer workstation), on some devices
|
roughly 0.6 seconds to scan all types on one developer workstation), on some devices
|
||||||
(e.g. Android phones where every millisecond counts)
|
(e.g. Android phones where every millisecond counts)
|
||||||
it may be desirable to defer this scan.
|
it may be desirable to defer this scan.
|
||||||
</p>
|
</p>
|
||||||
|
@ -74,11 +74,16 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section name="Configuring the HTTP Client">
|
<section name="Configuring the HTTP Client">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
RESTful clients (both Generic and Annotation-Driven) use
|
RESTful clients (both Generic and Annotation-Driven) use
|
||||||
<a href="http://hc.apache.org/httpcomponents-client-ga/">Apache HTTP Client</a>
|
<a href="http://hc.apache.org/httpcomponents-client-ga/">Apache HTTP Client</a>
|
||||||
as a provider. The Apache HTTP Client is very powerful and extremely
|
as a provider by default (except on Android, where
|
||||||
|
<a href="http://square.github.io/okhttp/">OkHttp</a>
|
||||||
|
is the default).
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The Apache HTTP Client is very powerful and extremely
|
||||||
flexible,
|
flexible,
|
||||||
but can be confusing at first to configure, because of the low-level
|
but can be confusing at first to configure, because of the low-level
|
||||||
approach that
|
approach that
|
||||||
|
@ -135,6 +140,49 @@
|
||||||
|
|
||||||
</subsection>
|
</subsection>
|
||||||
|
|
||||||
|
<subsection name="Using OkHttp instead of Apache HttpClient">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
As of HAPI FHIR 2.0, an alternate client implementation
|
||||||
|
is available. This client replaces the low-level
|
||||||
|
Apache HttpClient implementation with the
|
||||||
|
Square
|
||||||
|
<a href="http://square.github.io/okhttp/">OkHttp</a>
|
||||||
|
library.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Changing HTTP implementations should be mostly
|
||||||
|
transparent (it has no effect on the actual FHIR
|
||||||
|
semantics which are transmitted over the wire) but
|
||||||
|
might be useful if you have an application that
|
||||||
|
uses OkHttp in other parts of the application and
|
||||||
|
has specific configuration for that library.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Note that as of HAPI FHIR 2.1, OkHttp is the default
|
||||||
|
provider on Android, and will be used without any
|
||||||
|
configuration being required. This is done because
|
||||||
|
HttpClient is deprecated on Android and has caused
|
||||||
|
problems in the past.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To use OkHttp, first add the library as a dependency to your project POM:
|
||||||
|
</p>
|
||||||
|
<source><![CDATA[<dependency>
|
||||||
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
<artifactId>hapi-fhir-client-okhttp</artifactId>
|
||||||
|
<version>${hapi_stable_version}</version>
|
||||||
|
</dependency>]]></source>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Then, set the client factory to use OkHttp.
|
||||||
|
</p>
|
||||||
|
<macro name="snippet">
|
||||||
|
<param name="id" value="okhttp"/>
|
||||||
|
<param name="file"
|
||||||
|
value="examples/src/main/java/example/ClientExamples.java"/>
|
||||||
|
</macro>
|
||||||
|
</subsection>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</body>
|
</body>
|
|
@ -123,12 +123,12 @@
|
||||||
<source><![CDATA[<dependency>
|
<source><![CDATA[<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-base</artifactId>
|
<artifactId>hapi-fhir-base</artifactId>
|
||||||
<version>${hapi_stable_version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||||
<version>${hapi_stable_version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>]]></source>
|
</dependency>]]></source>
|
||||||
</subsection>
|
</subsection>
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
<source><![CDATA[<dependency>
|
<source><![CDATA[<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||||
<version>${hapi_stable_version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>]]></source>
|
</dependency>]]></source>
|
||||||
|
|
||||||
</subsection>
|
</subsection>
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
<source><![CDATA[<dependency>
|
<source><![CDATA[<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||||
<version>${hapi_stable_version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>]]></source>
|
</dependency>]]></source>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
<source><![CDATA[<dependency>
|
<source><![CDATA[<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||||
<version>${hapi_stable_version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>]]></source>
|
</dependency>]]></source>
|
||||||
|
|
||||||
</subsection>
|
</subsection>
|
||||||
|
@ -193,19 +193,19 @@
|
||||||
<p>
|
<p>
|
||||||
DSTU1:
|
DSTU1:
|
||||||
</p>
|
</p>
|
||||||
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${hapi_stable_version}'
|
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${project.version}'
|
||||||
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu:${hapi_stable_version}']]></source>
|
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu:${project.version}']]></source>
|
||||||
<p>
|
<p>
|
||||||
DSTU2 (HAPI):
|
DSTU2 (HAPI):
|
||||||
</p>
|
</p>
|
||||||
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${hapi_stable_version}'
|
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${project.version}'
|
||||||
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:${hapi_stable_version}']]></source>
|
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:${project.version}']]></source>
|
||||||
<p>
|
<p>
|
||||||
DSTU2 (RI):
|
DSTU2 (RI):
|
||||||
</p>
|
</p>
|
||||||
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${hapi_stable_version}'
|
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${project.version}'
|
||||||
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2:${hapi_stable_version}'
|
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2:${project.version}'
|
||||||
compile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:${hapi_stable_version}']]></source>
|
compile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:${project.version}']]></source>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section name="Using Snapshot Builds">
|
<section name="Using Snapshot Builds">
|
||||||
|
|
Loading…
Reference in New Issue