Enhanced android documentation

This commit is contained in:
James Agnew 2016-10-14 17:34:55 -04:00
parent f80bf98dcd
commit 4c2841436f
7 changed files with 103 additions and 19 deletions

View File

@ -40,6 +40,11 @@
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-client-okhttp</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jaxrsserver-base</artifactId>

View File

@ -1,6 +1,7 @@
package example;
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.IRestfulClientFactory;
import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor;
@ -34,6 +35,19 @@ public class ClientExamples {
// 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")
public void createTimeouts() {
// START SNIPPET: timeouts

View File

@ -60,6 +60,11 @@
<artifactId>hapi-fhir-client-okhttp</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>

View File

@ -269,9 +269,6 @@
<!-- 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>
<!-- 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>
<!-- For site-deploy -->

View File

@ -69,6 +69,21 @@
</p>
</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>
</document>

View File

@ -51,8 +51,8 @@
</p>
<p>
While this process is not particularly significant on reasonably
performant machines (current benchmarks show that this takes
roughly 6 seconds on one developer workstation), on some devices
performant machines (one benchmark showed that this takes
roughly 0.6 seconds to scan all types on one developer workstation), on some devices
(e.g. Android phones where every millisecond counts)
it may be desirable to defer this scan.
</p>
@ -78,7 +78,12 @@
<p>
RESTful clients (both Generic and Annotation-Driven) use
<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,
but can be confusing at first to configure, because of the low-level
approach that
@ -135,6 +140,49 @@
</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>
</body>

View File

@ -123,12 +123,12 @@
<source><![CDATA[<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${hapi_stable_version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${hapi_stable_version}</version>
<version>${project.version}</version>
</dependency>]]></source>
</subsection>
@ -151,7 +151,7 @@
<source><![CDATA[<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${hapi_stable_version}</version>
<version>${project.version}</version>
</dependency>]]></source>
</subsection>
@ -166,7 +166,7 @@
<source><![CDATA[<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>${hapi_stable_version}</version>
<version>${project.version}</version>
</dependency>]]></source>
<p>
@ -177,7 +177,7 @@
<source><![CDATA[<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${hapi_stable_version}</version>
<version>${project.version}</version>
</dependency>]]></source>
</subsection>
@ -193,19 +193,19 @@
<p>
DSTU1:
</p>
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${hapi_stable_version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu:${hapi_stable_version}']]></source>
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${project.version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu:${project.version}']]></source>
<p>
DSTU2 (HAPI):
</p>
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${hapi_stable_version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:${hapi_stable_version}']]></source>
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${project.version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:${project.version}']]></source>
<p>
DSTU2 (RI):
</p>
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${hapi_stable_version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2:${hapi_stable_version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:${hapi_stable_version}']]></source>
<source><![CDATA[compile 'ca.uhn.hapi.fhir:hapi-fhir-base:${project.version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2:${project.version}'
compile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:${project.version}']]></source>
</section>
<section name="Using Snapshot Builds">