http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/112b098d/content/api-documentation/org/apache/juneau/client/class-use/SSLOpts.html ---------------------------------------------------------------------- diff --git a/content/api-documentation/org/apache/juneau/client/class-use/SSLOpts.html b/content/api-documentation/org/apache/juneau/client/class-use/SSLOpts.html new file mode 100644 index 0000000..707fd21 --- /dev/null +++ b/content/api-documentation/org/apache/juneau/client/class-use/SSLOpts.html @@ -0,0 +1,215 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<title>Uses of Class org.apache.juneau.client.SSLOpts (Juneau)</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +<script type="text/javascript" src="../../../../../script.js"></script> +</head> +<body> +<script type="text/javascript"><!-- + try { + if (location.href.indexOf('is-external=true') == -1) { + parent.document.title="Uses of Class org.apache.juneau.client.SSLOpts (Juneau)"; + } + } + catch(err) { + } +//--> +</script> +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<!-- ========= START OF TOP NAVBAR ======= --> +<div class="topNav"><a name="navbar.top"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.top.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../../overview-summary.html">Overview</a></li> +<li><a href="../package-summary.html">Package</a></li> +<li><a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">Class</a></li> +<li class="navBarCell1Rev">Use</li> +<li><a href="../package-tree.html">Tree</a></li> +<li><a href="../../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../../index-all.html">Index</a></li> +<li><a href="../../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="../../../../../index.html?org/apache/juneau/client/class-use/SSLOpts.html" target="_top">Frames</a></li> +<li><a href="SSLOpts.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_top"> +<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_top"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.top"> +<!-- --> +</a></div> +<!-- ========= END OF TOP NAVBAR ========= --> +<div class="header"> +<h2 title="Uses of Class org.apache.juneau.client.SSLOpts" class="title">Uses of Class<br>org.apache.juneau.client.SSLOpts</h2> +</div> +<div class="classUseContainer"> +<ul class="blockList"> +<li class="blockList"> +<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation"> +<caption><span>Packages that use <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Package</th> +<th class="colLast" scope="col">Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><a href="#org.apache.juneau.client">org.apache.juneau.client</a></td> +<td class="colLast"> +<div class="block">REST client API</div> +</td> +</tr> +</tbody> +</table> +</li> +<li class="blockList"> +<ul class="blockList"> +<li class="blockList"><a name="org.apache.juneau.client"> +<!-- --> +</a> +<h3>Uses of <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a> in <a href="../../../../../org/apache/juneau/client/package-summary.html">org.apache.juneau.client</a></h3> +<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation"> +<caption><span>Fields in <a href="../../../../../org/apache/juneau/client/package-summary.html">org.apache.juneau.client</a> declared as <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Modifier and Type</th> +<th class="colLast" scope="col">Field and Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><code>static <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></code></td> +<td class="colLast"><span class="typeNameLabel">SSLOpts.</span><code><span class="memberNameLink"><a href="../../../../../org/apache/juneau/client/SSLOpts.html#DEFAULT">DEFAULT</a></span></code> +<div class="block">Reusable SSL options for normal SSL (default cert validation and hostname verification).</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><code>static <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></code></td> +<td class="colLast"><span class="typeNameLabel">SSLOpts.</span><code><span class="memberNameLink"><a href="../../../../../org/apache/juneau/client/SSLOpts.html#LAX">LAX</a></span></code> +<div class="block">Reusable SSL options for lenient SSL (no cert validation or hostname verification).</div> +</td> +</tr> +</tbody> +</table> +<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> +<caption><span>Methods in <a href="../../../../../org/apache/juneau/client/package-summary.html">org.apache.juneau.client</a> that return <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Modifier and Type</th> +<th class="colLast" scope="col">Method and Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><code><a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></code></td> +<td class="colLast"><span class="typeNameLabel">SSLOpts.</span><code><span class="memberNameLink"><a href="../../../../../org/apache/juneau/client/SSLOpts.html#setCertValidate-org.apache.juneau.client.SSLOpts.CertValidate-">setCertValidate</a></span>(<a href="../../../../../org/apache/juneau/client/SSLOpts.CertValidate.html" title="enum in org.apache.juneau.client">SSLOpts.CertValidate</a> certValidate)</code> +<div class="block">Bean property setter: <property>certValidate</property>.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><code><a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></code></td> +<td class="colLast"><span class="typeNameLabel">SSLOpts.</span><code><span class="memberNameLink"><a href="../../../../../org/apache/juneau/client/SSLOpts.html#setHostVerify-org.apache.juneau.client.SSLOpts.HostVerify-">setHostVerify</a></span>(<a href="../../../../../org/apache/juneau/client/SSLOpts.HostVerify.html" title="enum in org.apache.juneau.client">SSLOpts.HostVerify</a> hostVerify)</code> +<div class="block">Bean property setter: <property>hostVerify</property>.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><code><a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></code></td> +<td class="colLast"><span class="typeNameLabel">SSLOpts.</span><code><span class="memberNameLink"><a href="../../../../../org/apache/juneau/client/SSLOpts.html#setProtocols-java.lang.String-">setProtocols</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> protocols)</code> +<div class="block">Bean property setter: <property>protocols</property>.</div> +</td> +</tr> +</tbody> +</table> +<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> +<caption><span>Methods in <a href="../../../../../org/apache/juneau/client/package-summary.html">org.apache.juneau.client</a> with parameters of type <a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Modifier and Type</th> +<th class="colLast" scope="col">Method and Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><code><a href="../../../../../org/apache/juneau/client/RestClient.html" title="class in org.apache.juneau.client">RestClient</a></code></td> +<td class="colLast"><span class="typeNameLabel">RestClient.</span><code><span class="memberNameLink"><a href="../../../../../org/apache/juneau/client/RestClient.html#enableSSL-org.apache.juneau.client.SSLOpts-">enableSSL</a></span>(<a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a> opts)</code> +<div class="block">Enable SSL support on this client.</div> +</td> +</tr> +</tbody> +</table> +</li> +</ul> +</li> +</ul> +</div> +<!-- ======= START OF BOTTOM NAVBAR ====== --> +<div class="bottomNav"><a name="navbar.bottom"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.bottom.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../../overview-summary.html">Overview</a></li> +<li><a href="../package-summary.html">Package</a></li> +<li><a href="../../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">Class</a></li> +<li class="navBarCell1Rev">Use</li> +<li><a href="../package-tree.html">Tree</a></li> +<li><a href="../../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../../index-all.html">Index</a></li> +<li><a href="../../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="../../../../../index.html?org/apache/juneau/client/class-use/SSLOpts.html" target="_top">Frames</a></li> +<li><a href="SSLOpts.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_bottom"> +<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_bottom"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.bottom"> +<!-- --> +</a></div> +<!-- ======== END OF BOTTOM NAVBAR ======= --> +</body> +</html>
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/112b098d/content/api-documentation/org/apache/juneau/client/class-use/SerializedNameValuePair.html ---------------------------------------------------------------------- diff --git a/content/api-documentation/org/apache/juneau/client/class-use/SerializedNameValuePair.html b/content/api-documentation/org/apache/juneau/client/class-use/SerializedNameValuePair.html new file mode 100644 index 0000000..40e53b0 --- /dev/null +++ b/content/api-documentation/org/apache/juneau/client/class-use/SerializedNameValuePair.html @@ -0,0 +1,123 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<title>Uses of Class org.apache.juneau.client.SerializedNameValuePair (Juneau)</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +<script type="text/javascript" src="../../../../../script.js"></script> +</head> +<body> +<script type="text/javascript"><!-- + try { + if (location.href.indexOf('is-external=true') == -1) { + parent.document.title="Uses of Class org.apache.juneau.client.SerializedNameValuePair (Juneau)"; + } + } + catch(err) { + } +//--> +</script> +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<!-- ========= START OF TOP NAVBAR ======= --> +<div class="topNav"><a name="navbar.top"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.top.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../../overview-summary.html">Overview</a></li> +<li><a href="../package-summary.html">Package</a></li> +<li><a href="../../../../../org/apache/juneau/client/SerializedNameValuePair.html" title="class in org.apache.juneau.client">Class</a></li> +<li class="navBarCell1Rev">Use</li> +<li><a href="../package-tree.html">Tree</a></li> +<li><a href="../../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../../index-all.html">Index</a></li> +<li><a href="../../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="../../../../../index.html?org/apache/juneau/client/class-use/SerializedNameValuePair.html" target="_top">Frames</a></li> +<li><a href="SerializedNameValuePair.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_top"> +<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_top"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.top"> +<!-- --> +</a></div> +<!-- ========= END OF TOP NAVBAR ========= --> +<div class="header"> +<h2 title="Uses of Class org.apache.juneau.client.SerializedNameValuePair" class="title">Uses of Class<br>org.apache.juneau.client.SerializedNameValuePair</h2> +</div> +<div class="classUseContainer">No usage of org.apache.juneau.client.SerializedNameValuePair</div> +<!-- ======= START OF BOTTOM NAVBAR ====== --> +<div class="bottomNav"><a name="navbar.bottom"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.bottom.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../../overview-summary.html">Overview</a></li> +<li><a href="../package-summary.html">Package</a></li> +<li><a href="../../../../../org/apache/juneau/client/SerializedNameValuePair.html" title="class in org.apache.juneau.client">Class</a></li> +<li class="navBarCell1Rev">Use</li> +<li><a href="../package-tree.html">Tree</a></li> +<li><a href="../../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../../index-all.html">Index</a></li> +<li><a href="../../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="../../../../../index.html?org/apache/juneau/client/class-use/SerializedNameValuePair.html" target="_top">Frames</a></li> +<li><a href="SerializedNameValuePair.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_bottom"> +<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_bottom"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.bottom"> +<!-- --> +</a></div> +<!-- ======== END OF BOTTOM NAVBAR ======= --> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/112b098d/content/api-documentation/org/apache/juneau/client/class-use/SimpleX509TrustManager.html ---------------------------------------------------------------------- diff --git a/content/api-documentation/org/apache/juneau/client/class-use/SimpleX509TrustManager.html b/content/api-documentation/org/apache/juneau/client/class-use/SimpleX509TrustManager.html new file mode 100644 index 0000000..6857b10 --- /dev/null +++ b/content/api-documentation/org/apache/juneau/client/class-use/SimpleX509TrustManager.html @@ -0,0 +1,123 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<title>Uses of Class org.apache.juneau.client.SimpleX509TrustManager (Juneau)</title> +<link rel="stylesheet" type="text/css" href="../../../../../javadoc.css" title="Style"> +<script type="text/javascript" src="../../../../../script.js"></script> +</head> +<body> +<script type="text/javascript"><!-- + try { + if (location.href.indexOf('is-external=true') == -1) { + parent.document.title="Uses of Class org.apache.juneau.client.SimpleX509TrustManager (Juneau)"; + } + } + catch(err) { + } +//--> +</script> +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<!-- ========= START OF TOP NAVBAR ======= --> +<div class="topNav"><a name="navbar.top"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.top.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../../overview-summary.html">Overview</a></li> +<li><a href="../package-summary.html">Package</a></li> +<li><a href="../../../../../org/apache/juneau/client/SimpleX509TrustManager.html" title="class in org.apache.juneau.client">Class</a></li> +<li class="navBarCell1Rev">Use</li> +<li><a href="../package-tree.html">Tree</a></li> +<li><a href="../../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../../index-all.html">Index</a></li> +<li><a href="../../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="../../../../../index.html?org/apache/juneau/client/class-use/SimpleX509TrustManager.html" target="_top">Frames</a></li> +<li><a href="SimpleX509TrustManager.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_top"> +<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_top"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.top"> +<!-- --> +</a></div> +<!-- ========= END OF TOP NAVBAR ========= --> +<div class="header"> +<h2 title="Uses of Class org.apache.juneau.client.SimpleX509TrustManager" class="title">Uses of Class<br>org.apache.juneau.client.SimpleX509TrustManager</h2> +</div> +<div class="classUseContainer">No usage of org.apache.juneau.client.SimpleX509TrustManager</div> +<!-- ======= START OF BOTTOM NAVBAR ====== --> +<div class="bottomNav"><a name="navbar.bottom"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.bottom.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../../overview-summary.html">Overview</a></li> +<li><a href="../package-summary.html">Package</a></li> +<li><a href="../../../../../org/apache/juneau/client/SimpleX509TrustManager.html" title="class in org.apache.juneau.client">Class</a></li> +<li class="navBarCell1Rev">Use</li> +<li><a href="../package-tree.html">Tree</a></li> +<li><a href="../../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../../index-all.html">Index</a></li> +<li><a href="../../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="../../../../../index.html?org/apache/juneau/client/class-use/SimpleX509TrustManager.html" target="_top">Frames</a></li> +<li><a href="SimpleX509TrustManager.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_bottom"> +<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_bottom"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.bottom"> +<!-- --> +</a></div> +<!-- ======== END OF BOTTOM NAVBAR ======= --> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/112b098d/content/api-documentation/org/apache/juneau/client/package-frame.html ---------------------------------------------------------------------- diff --git a/content/api-documentation/org/apache/juneau/client/package-frame.html b/content/api-documentation/org/apache/juneau/client/package-frame.html new file mode 100644 index 0000000..fa605f1 --- /dev/null +++ b/content/api-documentation/org/apache/juneau/client/package-frame.html @@ -0,0 +1,44 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<title>org.apache.juneau.client (Juneau)</title> +<link rel="stylesheet" type="text/css" href="../../../../javadoc.css" title="Style"> +<script type="text/javascript" src="../../../../script.js"></script> +</head> +<body> +<h1 class="bar"><a href="../../../../org/apache/juneau/client/package-summary.html" target="classFrame">org.apache.juneau.client</a></h1> +<div class="indexContainer"> +<h2 title="Interfaces">Interfaces</h2> +<ul title="Interfaces"> +<li><a href="RetryOn.html" title="interface in org.apache.juneau.client" target="classFrame"><span class="interfaceName">RetryOn</span></a></li> +</ul> +<h2 title="Classes">Classes</h2> +<ul title="Classes"> +<li><a href="AllowAllRedirects.html" title="class in org.apache.juneau.client" target="classFrame">AllowAllRedirects</a></li> +<li><a href="DateHeader.html" title="class in org.apache.juneau.client" target="classFrame">DateHeader</a></li> +<li><a href="NameValuePairs.html" title="class in org.apache.juneau.client" target="classFrame">NameValuePairs</a></li> +<li><a href="ResponsePattern.html" title="class in org.apache.juneau.client" target="classFrame">ResponsePattern</a></li> +<li><a href="RestCall.html" title="class in org.apache.juneau.client" target="classFrame">RestCall</a></li> +<li><a href="RestCallInterceptor.html" title="class in org.apache.juneau.client" target="classFrame">RestCallInterceptor</a></li> +<li><a href="RestCallLogger.html" title="class in org.apache.juneau.client" target="classFrame">RestCallLogger</a></li> +<li><a href="RestClient.html" title="class in org.apache.juneau.client" target="classFrame">RestClient</a></li> +<li><a href="RestRequestEntity.html" title="class in org.apache.juneau.client" target="classFrame">RestRequestEntity</a></li> +<li><a href="SerializedNameValuePair.html" title="class in org.apache.juneau.client" target="classFrame">SerializedNameValuePair</a></li> +<li><a href="SimpleX509TrustManager.html" title="class in org.apache.juneau.client" target="classFrame">SimpleX509TrustManager</a></li> +<li><a href="SSLOpts.html" title="class in org.apache.juneau.client" target="classFrame">SSLOpts</a></li> +</ul> +<h2 title="Enums">Enums</h2> +<ul title="Enums"> +<li><a href="HttpMethod.html" title="enum in org.apache.juneau.client" target="classFrame">HttpMethod</a></li> +<li><a href="SSLOpts.CertValidate.html" title="enum in org.apache.juneau.client" target="classFrame">SSLOpts.CertValidate</a></li> +<li><a href="SSLOpts.HostVerify.html" title="enum in org.apache.juneau.client" target="classFrame">SSLOpts.HostVerify</a></li> +</ul> +<h2 title="Exceptions">Exceptions</h2> +<ul title="Exceptions"> +<li><a href="RestCallException.html" title="class in org.apache.juneau.client" target="classFrame">RestCallException</a></li> +</ul> +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/112b098d/content/api-documentation/org/apache/juneau/client/package-summary.html ---------------------------------------------------------------------- diff --git a/content/api-documentation/org/apache/juneau/client/package-summary.html b/content/api-documentation/org/apache/juneau/client/package-summary.html new file mode 100644 index 0000000..a96f59a --- /dev/null +++ b/content/api-documentation/org/apache/juneau/client/package-summary.html @@ -0,0 +1,1100 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<title>org.apache.juneau.client (Juneau)</title> +<link rel="stylesheet" type="text/css" href="../../../../javadoc.css" title="Style"> +<script type="text/javascript" src="../../../../script.js"></script> +</head> +<body> +<script type="text/javascript"><!-- + try { + if (location.href.indexOf('is-external=true') == -1) { + parent.document.title="org.apache.juneau.client (Juneau)"; + } + } + catch(err) { + } +//--> +</script> +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<!-- ========= START OF TOP NAVBAR ======= --> +<div class="topNav"><a name="navbar.top"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.top.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../overview-summary.html">Overview</a></li> +<li class="navBarCell1Rev">Package</li> +<li>Class</li> +<li><a href="package-use.html">Use</a></li> +<li><a href="package-tree.html">Tree</a></li> +<li><a href="../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../index-all.html">Index</a></li> +<li><a href="../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li><a href="../../../../org/apache/juneau/annotation/package-summary.html">Prev Package</a></li> +<li><a href="../../../../org/apache/juneau/csv/package-summary.html">Next Package</a></li> +</ul> +<ul class="navList"> +<li><a href="../../../../index.html?org/apache/juneau/client/package-summary.html" target="_top">Frames</a></li> +<li><a href="package-summary.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_top"> +<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_top"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.top"> +<!-- --> +</a></div> +<!-- ========= END OF TOP NAVBAR ========= --> +<div class="header"> +<h1 title="Package" class="title">Package org.apache.juneau.client</h1> +<div class="docSummary"> +<div class="block">REST client API</div> +</div> +<p>See: <a href="#package.description">Description</a></p> +</div> +<div class="contentContainer"> +<ul class="blockList"> +<li class="blockList"> +<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation"> +<caption><span>Interface Summary</span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Interface</th> +<th class="colLast" scope="col">Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RetryOn.html" title="interface in org.apache.juneau.client">RetryOn</a></td> +<td class="colLast"> +<div class="block">Used to determine whether a request should be retried based on the HTTP response code.</div> +</td> +</tr> +</tbody> +</table> +</li> +<li class="blockList"> +<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation"> +<caption><span>Class Summary</span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Class</th> +<th class="colLast" scope="col">Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/AllowAllRedirects.html" title="class in org.apache.juneau.client">AllowAllRedirects</a></td> +<td class="colLast"> +<div class="block">Redirect strategy that allows for redirects on any request type, not just <code>GET</code> or <code>HEAD</code>.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/DateHeader.html" title="class in org.apache.juneau.client">DateHeader</a></td> +<td class="colLast"> +<div class="block">Convenience class for setting date headers in RFC2616 format.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/NameValuePairs.html" title="class in org.apache.juneau.client">NameValuePairs</a></td> +<td class="colLast"> +<div class="block">Convenience class for constructing instances of <code>List<NameValuePair></code> + for the <code>UrlEncodedFormEntity</code> class.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/ResponsePattern.html" title="class in org.apache.juneau.client">ResponsePattern</a></td> +<td class="colLast"> +<div class="block">Used to find regular expression matches in REST responses made through <a href="../../../../org/apache/juneau/client/RestCall.html" title="class in org.apache.juneau.client"><code>RestCall</code></a>.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RestCall.html" title="class in org.apache.juneau.client">RestCall</a></td> +<td class="colLast"> +<div class="block">Represents a connection to a remote REST resource.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RestCallInterceptor.html" title="class in org.apache.juneau.client">RestCallInterceptor</a></td> +<td class="colLast"> +<div class="block">Used to intercept http connection responses to allow modification of that response before processing + and for listening for call lifecycle events.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RestCallLogger.html" title="class in org.apache.juneau.client">RestCallLogger</a></td> +<td class="colLast"> +<div class="block">Specialized interceptor for logging calls to a log file.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RestClient.html" title="class in org.apache.juneau.client">RestClient</a></td> +<td class="colLast"> +<div class="block">Utility class for interfacing with remote REST interfaces.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RestRequestEntity.html" title="class in org.apache.juneau.client">RestRequestEntity</a></td> +<td class="colLast"> +<div class="block">HttpEntity for serializing POJOs as the body of HTTP requests.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/SerializedNameValuePair.html" title="class in org.apache.juneau.client">SerializedNameValuePair</a></td> +<td class="colLast"> +<div class="block">Subclass of <code>NameValuePair</code> for serializing POJOs as URL-encoded form post entries + using the <a href="../../../../org/apache/juneau/urlencoding/UrlEncodingSerializer.html" title="class in org.apache.juneau.urlencoding"><code>class</code></a>.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/SimpleX509TrustManager.html" title="class in org.apache.juneau.client">SimpleX509TrustManager</a></td> +<td class="colLast"> +<div class="block">A trust manager that optionally allows for self-signed certificates.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client">SSLOpts</a></td> +<td class="colLast"> +<div class="block">SSL configuration options that get passed to <a href="../../../../org/apache/juneau/client/RestClient.html#enableSSL-org.apache.juneau.client.SSLOpts-"><code>RestClient.enableSSL(SSLOpts)</code></a>.</div> +</td> +</tr> +</tbody> +</table> +</li> +<li class="blockList"> +<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation"> +<caption><span>Enum Summary</span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Enum</th> +<th class="colLast" scope="col">Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/HttpMethod.html" title="enum in org.apache.juneau.client">HttpMethod</a></td> +<td class="colLast"> +<div class="block">Enumeration of HTTP methods.</div> +</td> +</tr> +<tr class="rowColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/SSLOpts.CertValidate.html" title="enum in org.apache.juneau.client">SSLOpts.CertValidate</a></td> +<td class="colLast"> +<div class="block">Certificate validation options.</div> +</td> +</tr> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/SSLOpts.HostVerify.html" title="enum in org.apache.juneau.client">SSLOpts.HostVerify</a></td> +<td class="colLast"> +<div class="block">Certificate host verification options.</div> +</td> +</tr> +</tbody> +</table> +</li> +<li class="blockList"> +<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation"> +<caption><span>Exception Summary</span><span class="tabEnd"> </span></caption> +<tr> +<th class="colFirst" scope="col">Exception</th> +<th class="colLast" scope="col">Description</th> +</tr> +<tbody> +<tr class="altColor"> +<td class="colFirst"><a href="../../../../org/apache/juneau/client/RestCallException.html" title="class in org.apache.juneau.client">RestCallException</a></td> +<td class="colLast"> +<div class="block">Exception representing a <code>400+</code> HTTP response code against a remote resource.</div> +</td> +</tr> +</tbody> +</table> +</li> +</ul> +<a name="package.description"> +<!-- --> +</a> +<h2 title="Package org.apache.juneau.client Description">Package org.apache.juneau.client Description</h2> +<div class="block"><p>REST client API</p> + +<script> + function toggle(x) { + var div = x.nextSibling; + while (div != null && div.nodeType != 1) + div = div.nextSibling; + if (div != null) { + var d = div.style.display; + if (d == 'block' || d == '') { + div.style.display = 'none'; + x.className += " closed"; + } else { + div.style.display = 'block'; + x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); + } + } + } +</script> + +<a id='TOC'></a><h5 class='toc'>Table of Contents</h5> +<ol class='toc'> + <li><p><a class='doclink' href='#RestClient'>REST Client API</a></p> + <ol> + <li><p><a class='doclink' href='#SSL'>SSL Support</a></p> + <ol> + <li><p><a class='doclink' href='#SSLOpts'>SSLOpts Bean</a></p> + </ol> + <li><p><a class='doclink' href='#Authentication'>Authentication</a></p> + <ol> + <li><p><a class='doclink' href='#BASIC'>BASIC Authentication</a></p> + <li><p><a class='doclink' href='#FORM'>FORM-based Authentication</a></p> + <li><p><a class='doclink' href='#OIDC'>OIDC Authentication</a></p> + </ol> + <li><p><a class='doclink' href='#ResponsePatterns'>Using Response Patterns</a></p> + <li><p><a class='doclink' href='#PipingOutput'>Piping Response Output</a></p> + <li><p><a class='doclink' href='#Logging'>Logging</a></p> + <li><p><a class='doclink' href='#Interceptors'>Interceptors</a></p> + <li><p><a class='doclink' href='#Remoteable'>Remoteable Proxies</a></p> + <li><p><a class='doclink' href='#Other'>Other Useful Methods</a></p> + </ol> +</ol> + +<!-- ======================================================================================================== --> +<a id="RestClient"></a> +<h2 class='topic' onclick='toggle(this)'>1 - REST Client API</h2> +<div class='topic'> + <p> + Juneau provides an HTTP client API that makes it extremely simple to connect to remote REST interfaces and + seemlessly send and receive serialized POJOs in requests and responses. + </p> + <h6 class='notes'>Features:</h6> + <ul class='notes'> + <li>Converts POJOs directly to HTTP request message bodies using <a href="../../../../org/apache/juneau/serializer/Serializer.html" title="class in org.apache.juneau.serializer"><code>Serializer</code></a> classes. + <li>Converts HTTP response message bodies directly to POJOs using <a href="../../../../org/apache/juneau/parser/Parser.html" title="class in org.apache.juneau.parser"><code>Parser</code></a> classes. + <li>Exposes the full functionality of the Apache HttpClient API by exposing all methods defined on the + <code>HttpClientBuilder</code> class. + <li>Provides various convenience methods for setting up common SSL and authentication methods. + <li>Provides a fluent interface that allows you to make complex REST calls in a single line of code. + </ul> + <p> + The client API is designed to work as a thin layer on top of the proven Apache HttpClient API. + By leveraging the HttpClient library, details such as SSL certificate negotiation, proxies, encoding, etc... + are all handled in Apache code. + </p> + <p> + The Juneau client API prereq's Apache HttpClient 4.1.2+. + At a mimimum, the following jars are required: + </p> + <ul> + <li><code>httpclient-4.5.jar</code> + <li><code>httpcore-4.4.1.jar</code> + <li><code>httpmime-4.5.jar</code> + </ul> + <h6 class='topic'>Examples</h6> + <p class='bcode'> + <jc>// Examples below use the Juneau Address Book resource example</jc> + + <jc>// Create a reusable client with JSON support</jc> + RestClient client = <jk>new</jk> RestClient(JsonSerializer.<jk>class</jk>, JsonParser.<jk>class</jk>); + + <jc>// GET request, ignoring output</jc> + <jk>try</jk> { + <jk>int</jk> rc = client.doGet(<js>"http://localhost:9080/sample/addressBook"</js>).execute(); + <jc>// Succeeded!</jc> + } <jk>catch</jk> (RestCallException e) { + <jc>// Failed!</jc> + System.<jsf>err</jsf>.println( + String.<jsm>format</jsm>(<js>"status=%s, message=%s"</js>, e.getResponseStatus(), e.getResponseMessage()) + ); + } + + <jc>// Remaining examples ignore thrown exceptions.</jc> + + <jc>// GET request, secure, ignoring output</jc> + client.doGet(<js>"https://localhost:9443/sample/addressBook"</js>).execute(); + + <jc>// GET request, getting output as a String. No POJO parsing is performed. + // Note that when calling one of the getX() methods, you don't need to call connect() or disconnect(), since + // it's automatically called for you.</jc> + String output = client.doGet(<js>"http://localhost:9080/sample/addressBook"</js>) + .getResponseAsString(); + + <jc>// GET request, getting output as a Reader</jc> + Reader r = client.doGet(<js>"http://localhost:9080/sample/addressBook"</js>) + .getReader(); + + <jc>// GET request, getting output as an ObjectMap</jc> + <jc>// Input must be an object (e.g. "{...}")</jc> + ObjectMap m = client.doGet(<js>"http://localhost:9080/sample/addressBook/0"</js>) + .getResponse(ObjectMap.<jk>class</jk>); + + <jc>// GET request, getting output as a ObjectList</jc> + <jc>// Input must be an array (e.g. "[...]")</jc> + ObjectList l = client.doGet(<js>"http://localhost:9080/sample/addressBook"</js>) + .getResponse(ObjectList.<jk>class</jk>); + + <jc>// GET request, getting output as a parsed bean</jc> + <jc>// Input must be an object (e.g. "{...}")</jc> + <jc>// Note that you don't have to do any casting!</jc> + Person p = client.doGet(<js>"http://localhost:9080/sample/addressBook/0"</js>) + .getResponse(Person.<jk>class</jk>); + + <jc>// GET request, getting output as a parsed bean</jc> + <jc>// Input must be an array of objects (e.g. "[{...},{...}]")</jc> + Person[] pa = client.doGet(<js>"http://localhost:9080/sample/addressBook"</js>) + .getResponse(Person[].<jk>class</jk>); + + <jc>// Same as above, except as a List<Person></jc> + ClassMeta cm = BeanContext.<jsf>DEFAULT</jsf>.getCollectionClassMeta(LinkedList.<jk>class</jk>, Person.<jk>class</jk>); + List<Person> pl = client.doGet(<js>"http://localhost:9080/sample/addressBook"</js>) + .getResponse(cm); + + <jc>// GET request, getting output as a parsed string</jc> + <jc>// Input must be a string (e.g. "<string>foo</string>" or "'foo'")</jc> + String name = client.doGet(<js>"http://localhost:9080/sample/addressBook/0/name"</js>) + .getResponse(String.<jk>class</jk>); + + <jc>// GET request, getting output as a parsed number</jc> + <jc>// Input must be a number (e.g. "<number>123</number>" or "123")</jc> + <jk>int</jk> age = client.doGet(<js>"http://localhost:9080/sample/addressBook/0/age"</js>) + .getResponse(Integer.<jk>class</jk>); + + <jc>// GET request, getting output as a parsed boolean</jc> + <jc>// Input must be a boolean (e.g. "<boolean>true</boolean>" or "true")</jc> + <jk>boolean</jk> isCurrent = client.doGet(<js>"http://localhost:9080/sample/addressBook/0/addresses/0/isCurrent"</js>) + .getResponse(Boolean.<jk>class</jk>); + + <jc>// GET request, getting a filtered object</jc> + client.getParser().addTransforms(CalendarTransform.<jsf>ISO8601</jsf>.<jk>class</jk>); + Calendar birthDate = client.doGet(<js>"http://localhost:9080/sample/addressBook/0/birthDate"</js>) + .getResponse(GregorianCalendar.<jk>class</jk>); + + <jc>// PUT request on regular field</jc> + String newName = <js>"John Smith"</js>; + <jk>int</jk> rc = client.doPut(<js>"http://localhost:9080/addressBook/0/name"</js>, newName).execute(); + + <jc>// PUT request on filtered field</jc> + Calendar newBirthDate = <jk>new</jk> GregorianCalendar(1, 2, 3, 4, 5, 6); + rc = client.doPut(<js>"http://localhost:9080/sample/addressBook/0/birthDate"</js>, newBirthDate).execute(); + + <jc>// POST of a new entry to a list</jc> + Address newAddress = <jk>new</jk> Address(<js>"101 Main St"</js>, <js>"Anywhere"</js>, <js>"NY"</js>, 12121, <jk>false</jk>); + rc = client.doPost(<js>"http://localhost:9080/addressBook/0/addresses"</js>, newAddress).execute(); + </p> + + <h6 class='notes'>Notes:</h6> + <ul class='notes'> + <li><p>The <a href="../../../../org/apache/juneau/client/RestClient.html" title="class in org.apache.juneau.client"><code>RestClient</code></a> class exposes all the builder methods on the Apache HttpClient <code>HttpClientBuilder</code> class. + Use these methods to provide any customized HTTP client behavior..</p> + </ul> + + <!-- ======================================================================================================== --> + <a id="SSL"></a> + <h3 class='topic' onclick='toggle(this)'>1.1 - SSL Support</h3> + <div class='topic'> + <p> + The simplest way to enable SSL support in the client is to use the <a href="../../../../org/apache/juneau/client/RestClient.html#enableSSL-org.apache.juneau.client.SSLOpts-"><code>RestClient.enableSSL(SSLOpts)</code></a> method + and one of the predefined <a href="../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client"><code>SSLOpts</code></a> instances: + <ul> + <li><a href="../../../../org/apache/juneau/client/SSLOpts.html#DEFAULT"><code>SSLOpts.DEFAULT</code></a> - Normal certificate and hostname validation. + <li><a href="../../../../org/apache/juneau/client/SSLOpts.html#LAX"><code>SSLOpts.LAX</code></a> - Allows for self-signed certificates. + </ul> + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jc>// Create a client that ignores self-signed or otherwise invalid certificates.</jc> + RestClient restClient = <jk>new</jk> RestClient() + .enableSSL(SSLOpts.<jsf>LAX</jsf>); + + <jc>// ...or...</jc> + RestClient restClient = <jk>new</jk> RestClient() + .enableLaxSSL(); + </p> + <p> + This is functionally equivalent to the following: + </p> + <p class='bcode'> + RestClient restClient = <jk>new</jk> RestClient(); + + HostnameVerifier hv = <jk>new</jk> NoopHostnameVerifier(); + TrustManager tm = <jk>new</jk> SimpleX509TrustManager(<jk>true</jk>); + + <jk>for</jk> (String p : <jk>new</jk> String[]{<js>"SSL"</js>,<js>"TLS"</js>,<js>"SSL_TLS"</js>}) { + SSLContext ctx = SSLContext.<jsm>getInstance</jsm>(p); + ctx.init(<jk>null</jk>, <jk>new</jk> TrustManager[] { tm }, <jk>null</jk>); + SSLConnectionSocketFactory sf = <jk>new</jk> SSLConnectionSocketFactory(ctx, hv); + restClient.setSSLSocketFactory(sf); + Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory><jsm>.create</jsm>().register(<js>"https"</js>, sf).build(); + restClient.setConnectionManager(<jk>new</jk> PoolingHttpClientConnectionManager(r)); + } + </p> + <p> + More complex SSL support can be enabled through the various <code>HttpClientBuilder</code> methods defined on the class. + </p> + + <!-- ======================================================================================================== --> + <a id="SSLOpts"></a> + <h4 class='topic' onclick='toggle(this)'>1.1.1 - SSLOpts Bean</h4> + <div class='topic'> + <p> + The <a href="../../../../org/apache/juneau/client/SSLOpts.html" title="class in org.apache.juneau.client"><code>SSLOpts</code></a> class itself is a bean that can be created by the parsers. + For example, SSL options can be specified in a config file and retrieved as a bean using the <a href="../../../../org/apache/juneau/ini/ConfigFile.html" title="class in org.apache.juneau.ini"><code>ConfigFile</code></a> class. + </p> + <h6 class='figure'>Contents of <code>MyConfig.cfg</code></h6> + <p class='bcode'> + <jc>#================================================================================ + # My Connection Settings + #================================================================================</jc> + [Connection] + url = https://myremotehost:9443 + ssl = {certValidate:'LAX',hostVerify:'LAX'} + </p> + <h6 class='figure'>Code that reads an <code>SSLOpts</code> bean from the config file</h6> + <p class='bcode'> + <jc>// Read config file and set SSL options based on what's in that file.</jc> + ConfigFile cf = ConfigMgr.<jsf>DEFAULT</jsf>.get(<js>"MyConfig.cfg"</js>); + SSLOpts ssl = cf.getObject(SSLOpts.<jk>class</jk>, <js>"Connection/ssl"</js>); + RestClient rc = <jk>new</jk> RestClient().enableSSL(ssl); + </p> + </div> + </div> + + <!-- ======================================================================================================== --> + <a id="Authentication"></a> + <h3 class='topic' onclick='toggle(this)'>1.2 - Authentication</h3> + <div class='topic'> + + <!-- ======================================================================================================== --> + <a id="BASIC"></a> + <h4 class='topic' onclick='toggle(this)'>1.2.1 - BASIC Authentication</h4> + <div class='topic'> + <p> + The <a href="../../../../org/apache/juneau/client/RestClient.html#setBasicAuth-java.lang.String-int-java.lang.String-java.lang.String-"><code>RestClient.setBasicAuth(String,int,String,String)</code></a> method can be used to quickly enable + BASIC authentication support. + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jc>// Create a client that performs BASIC authentication using the specified user/pw.</jc> + RestClient restClient = <jk>new</jk> RestClient() + .setBasicAuth(<jsf>HOST</jsf>, <jsf>PORT</jsf>, <jsf>USER</jsf>, <jsf>PW</jsf>); + </p> + <p> + This is functionally equivalent to the following: + </p> + <p class='bcode'> + RestClient restClient = <jk>new</jk> RestClient(); + AuthScope scope = <jk>new</jk> AuthScope(<jsf>HOST</jsf>, <jsf>PORT</jsf>); + Credentials up = <jk>new</jk> UsernamePasswordCredentials(<jsf>USER</jsf>, <jsf>PW</jsf>); + CredentialsProvider p = <jk>new</jk> BasicCredentialsProvider(); + p.setCredentials(scope, up); + restClient.setDefaultCredentialsProvider(p); + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="FORM"></a> + <h4 class='topic' onclick='toggle(this)'>1.2.2 - FORM-based Authentication</h4> + <div class='topic'> + <p> + The <a href="../../../../org/apache/juneau/client/RestClient.html" title="class in org.apache.juneau.client"><code>RestClient</code></a> class does not itself provide FORM-based authentication since there + is no standard way of providing such support. + Typically, to perform FORM-based or other types of authentication, you'll want to create your own + subclass of <a href="../../../../org/apache/juneau/client/RestClient.html" title="class in org.apache.juneau.client"><code>RestClient</code></a> and override the <a href="../../../../org/apache/juneau/client/RestClient.html#createHttpClient--"><code>RestClient.createHttpClient()</code></a> + method to provide an authenticated client. + </p> + <p> + The following example shows how the <code>JazzRestClient</code> class provides + FORM-based authentication support. + </p> + <p class='bcode'> + <jd>/** + * Constructor. + */</jd> + <jk>public</jk> JazzRestClient(URI jazzUri, String user, String pw) <jk>throws</jk> IOException { + ... + } + + <jd>/** + * Override the createHttpClient() method to return an authenticated client. + */</jd> + <ja>@Override</ja> <jc>/* RestClient */</jc> + <jk>protected</jk> CloseableHttpClient createHttpClient() <jk>throws</jk> Exception { + CloseableHttpClient client = <jk>super</jk>.createHttpClient(); + formBasedAuthenticate(client); + visitAuthenticatedURL(client); + <jk>return</jk> client; + } + + <jc>/* + * Performs form-based authentication against the Jazz server. + */</jc> + <jk>private void</jk> formBasedAuthenticate(HttpClient client) <jk>throws</jk> IOException { + + URI uri2 = <jf>jazzUri</jf>.resolve(<js>"j_security_check"</js>); + HttpPost request = <jk>new</jk> HttpPost(uri2); + request.setConfig(RequestConfig.<jsm>custom</jsm>().setRedirectsEnabled(<jk>false</jk>).build()); + + <jc>// Charset must explicitly be set to UTF-8 to handle user/pw with non-ascii characters.</jc> + request.addHeader(<js>"Content-Type"</js>, <js>"application/x-www-form-urlencoded; charset=utf-8"</js>); + + NameValuePairs params = <jk>new</jk> NameValuePairs() + .append(<jk>new</jk> BasicNameValuePair(<js>"j_username""</js>, <jf>user</jf>)) + .append(<jk>new</jk> BasicNameValuePair(<js>"j_password"</js>, <jf>pw</jf>)); + request.setEntity(<jk>new</jk> UrlEncodedFormEntity(params)); + + HttpResponse response = client.execute(request); + <jk>try</jk> { + <jk>int</jk> rc = response.getStatusLine().getStatusCode(); + + Header authMsg = response.getFirstHeader(<js>"X-com-ibm-team-repository-web-auth-msg"</js>); + <jk>if</jk> (authMsg != <jk>null</jk>) + <jk>throw new</jk> IOException(authMsg.getValue()); + + <jc>// The form auth request should always respond with a 200 ok or 302 redirect code</jc> + <jk>if</jk> (rc == <jsf>SC_MOVED_TEMPORARILY</jsf>) { + <jk>if</jk> (response.getFirstHeader(<js>"Location"</js>).getValue().matches(<js>"^.*/auth/authfailed.*$"</js>)) + <jk>throw new</jk> IOException(<js>"Invalid credentials."</js>); + } <jk>else if</jk> (rc != <jsf>SC_OK</jsf>) { + <jk>throw new</jk> IOException(<js>"Unexpected HTTP status: "</js> + rc); + } + } <jk>finally</jk> { + EntityUtils.<jsm>consume</jsm>(response.getEntity()); + } + } + + <jc>/* + * This is needed for Tomcat because it responds with SC_BAD_REQUEST when the j_security_check URL is visited before an + * authenticated URL has been visited. This same URL must also be visited after authenticating with j_security_check + * otherwise tomcat will not consider the session authenticated + */</jc> + <jk>private int</jk> visitAuthenticatedURL(HttpClient httpClient) <jk>throws</jk> IOException { + HttpGet authenticatedURL = <jk>new</jk> HttpGet(<jf>jazzUri</jf>.resolve(<js>"authenticated/identity"</js>)); + HttpResponse response = httpClient.execute(authenticatedURL); + <jk>try</jk> { + <jk>return</jk> response.getStatusLine().getStatusCode(); + } <jk>finally</jk> { + EntityUtils.<jsm>consume</jsm>(response.getEntity()); + } + } + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="OIDC"></a> + <h4 class='topic' onclick='toggle(this)'>1.2.3 - OIDC Authentication</h4> + <div class='topic'> + <p> + The following example shows how the <code>JazzRestClient</code> class provides + OIDC authentication support. + </p> + <p class='bcode'> + <jd>/** + * Constructor. + */</jd> + <jk>public</jk> JazzRestClient(URI jazzUri, String user, String pw) <jk>throws</jk> IOException { + ... + } + + <jd>/** + * Override the createHttpClient() method to return an authenticated client. + */</jd> + <ja>@Override</ja> <jc>/* RestClient */</jc> + <jk>protected</jk> CloseableHttpClient createHttpClient() <jk>throws</jk> Exception { + CloseableHttpClient client = <jk>super</jk>.createHttpClient(); + oidcAuthenticate(client); + <jk>return</jk> client; + } + + <jk>private void</jk> oidcAuthenticate(HttpClient client) <jk>throws</jk> IOException { + + HttpGet request = <jk>new</jk> HttpGet(<jf>jazzUri</jf>); + request.setConfig(RequestConfig.<jsm>custom</jsm>().setRedirectsEnabled(<jk>false</jk>).build()); + + <jc>// Charset must explicitly be set to UTF-8 to handle user/pw with non-ascii characters.</jc> + request.addHeader(<js>"Content-Type"</js>, <js>"application/x-www-form-urlencoded; charset=utf-8"</js>); + + HttpResponse response = client.execute(request); + <jk>try</jk> { + <jk>int</jk> code = response.getStatusLine().getStatusCode(); + + <jc>// Already authenticated</jc> + <jk>if</jk> (code == <jsf>SC_OK</jsf>) + <jk>return</jk>; + + <jk>if</jk> (code != <jsf>SC_UNAUTHORIZED</jsf>) + <jk>throw new</jk> RestCallException(<js>"Unexpected response during OIDC authentication: "</js> + response.getStatusLine()); + + <jc>// x-jsa-authorization-redirect</jc> + String redirectUri = getHeader(response, <js>"X-JSA-AUTHORIZATION-REDIRECT"</js>); + + <jk>if</jk> (redirectUri == <jk>null</jk>) + <jk>throw new</jk> RestCallException(<js>"Expected a redirect URI during OIDC authentication: "</js> + response.getStatusLine()); + + <jc>// Handle Bearer Challenge</jc> + HttpGet method = <jk>new</jk> HttpGet(redirectUri + <js>"&prompt=none"</js>); + addDefaultOidcHeaders(method); + + response = client.execute(method); + + code = response.getStatusLine().getStatusCode(); + + <jk>if</jk> (code != <jsf>SC_OK</jsf>) + <jk>throw new</jk> RestCallException(<js>"Unexpected response during OIDC authentication phase 2: "</js> + response.getStatusLine()); + + String loginRequired = getHeader(response, <js>"X-JSA-LOGIN-REQUIRED"</js>); + + <jk>if</jk> (! <js>"true"</js>.equals(loginRequired)) + <jk>throw new</jk> RestCallException(<js>"X-JSA-LOGIN-REQUIRED header not found on response during OIDC authentication phase 2: "</js> + response.getStatusLine()); + + method = <jk>new</jk> HttpGet(redirectUri + <js>"&prompt=none"</js>); + + addDefaultOidcHeaders(method); + response = client.execute(method); + + code = response.getStatusLine().getStatusCode(); + + <jk>if</jk> (code != <jsf>SC_OK</jsf>) + <jk>throw new</jk> RestCallException(<js>"Unexpected response during OIDC authentication phase 3: "</js> + response.getStatusLine()); + + <jc>// Handle JAS Challenge</jc> + method = <jk>new</jk> HttpGet(redirectUri); + addDefaultOidcHeaders(method); + + response = client.execute(method); + + code = response.getStatusLine().getStatusCode(); + + <jk>if</jk> (code != <jsf>SC_OK</jsf>) + <jk>throw new</jk> RestCallException(<js>"Unexpected response during OIDC authentication phase 4: "</js> + response.getStatusLine()); + + <jf>cookie</jf> = getHeader(response, <js>"Set-Cookie"</js>); + + Header[] defaultHeaders = <jk>new</jk> Header[] { + <jk>new</jk> BasicHeader(<js>"User-Agent"</js>, <js>"Jazz Native Client"</js>), + <jk>new</jk> BasicHeader(<js>"X-com-ibm-team-configuration-versions"</js>, <js>"com.ibm.team.rtc=6.0.0,com.ibm.team.jazz.foundation=6.0"</js>), + <jk>new</jk> BasicHeader(<js>"Accept"</js>, <js>"text/json"</js>), + <jk>new</jk> BasicHeader(<js>"Authorization"</js>, <js>"Basic "</js> + StringUtils.<jsm>base64EncodeToString</jsm>(<jf>user</jf> + <js>":"</js> + <jf>pw</jf>)), + <jk>new</jk> BasicHeader(<js>"Cookie"</js>, cookie) + }; + + setDefaultHeaders(Arrays.<jsm>asList</jsm>(defaultHeaders)); + + } <jk>finally</jk> { + EntityUtils.<jsm>consume</jsm>(response.getEntity()); + } + } + + <jk>private void</jk> addDefaultOidcHeaders(HttpRequestBase method) { + method.addHeader(<js>"User-Agent"</js>, <js>"Jazz Native Client"</js>); + method.addHeader(<js>"X-com-ibm-team-configuration-versions"</js>, <js>"com.ibm.team.rtc=6.0.0,com.ibm.team.jazz.foundation=6.0"</js>); + method.addHeader(<js>"Accept"</js>, <js>"text/json"</js>); + + <jk>if</jk> (<jf>cookie</jf> != <jk>null</jk>) { + method.addHeader(<js>"Authorization"</js>, <js>"Basic "</js> + StringUtils.<jsm>base64EncodeToString</jsm>(<jf>user</jf> + <js>":"</js> + <jf>pw</jf>)); + method.addHeader(<js>"Cookie"</js>, cookie); + } + } + </p> + </div> + </div> + + <!-- ======================================================================================================== --> + <a id="ResponsePatterns"></a> + <h3 class='topic' onclick='toggle(this)'>1.3 - Using Response Patterns</h3> + <div class='topic'> + <p> + One issue with REST (and HTTP in general) is that the HTTP response code must be set as a header before the + body of the request is sent. This can be problematic when REST calls invoke long-running processes, pipes + the results through the connection, and then fails after an HTTP 200 has already been sent. + </p> + <p> + One common solution is to serialize some text at the end to indicate whether the long-running process succeeded (e.g. <js>"FAILED"</js> or <js>"SUCCEEDED"</js>). + </p> + <p> + The <a href="../../../../org/apache/juneau/client/RestClient.html" title="class in org.apache.juneau.client"><code>RestClient</code></a> class has convenience methods for scanning the response without + interfering with the other methods used for retrieving output. + </p> + <p> + The following example shows how the <a href="../../../../org/apache/juneau/client/RestCall.html#successPattern-java.lang.String-"><code>RestCall.successPattern(String)</code></a> method can be used + to look for a SUCCESS message in the output: + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jc>// Throw a RestCallException if SUCCESS is not found in the output.</jc> + restClient.doPost(<jsf>URL</jsf>) + .successPattern(<js>"SUCCESS"</js>) + .run(); + </p> + <p> + The <a href="../../../../org/apache/juneau/client/RestCall.html#failurePattern-java.lang.String-"><code>RestCall.failurePattern(String)</code></a> method does the opposite. + It throws an exception if a failure message is detected. + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jc>// Throw a RestCallException if FAILURE or ERROR is found in the output.</jc> + restClient.doPost(<jsf>URL</jsf>) + .failurePattern(<js>"FAILURE|ERROR"</js>) + .run(); + </p> + <p> + These convenience methods are specialized methods that use the <a href="../../../../org/apache/juneau/client/RestCall.html#addResponsePattern-org.apache.juneau.client.ResponsePattern-"><code>RestCall.addResponsePattern(ResponsePattern)</code></a> + method which uses regular expression matching against the response body. + This method can be used to search for arbitrary patterns in the response body. + </p> + <p> + The following example shows how to use a response pattern finder to find and capture patterns for <js>"x=number"</js> and <js>"y=string"</js> + from a response body. + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jk>final</jk> List<Number> xList = <jk>new</jk> ArrayList<Number>(); + <jk>final</jk> List<String> yList = <jk>new</jk> ArrayList<String>(); + + String responseText = restClient.doGet(<jsf>URL</jsf>) + .addResponsePattern( + <jk>new</jk> ResponsePattern(<js>"x=(\\d+)"</js>) { + <ja>@Override</ja> + <jk>public void</jk> onMatch(RestCall restCall, Matcher m) <jk>throws</jk> RestCallException { + xList.add(Integer.<jsm>parseInt</jsm>(m.group(1))); + } + <ja>@Override</ja> + <jk>public void</jk> onNoMatch(RestCall restCall) <jk>throws</jk> RestCallException { + <jk>throw new</jk> RestCallException(<js>"No X's found!"</js>); + } + } + ) + .addResponsePattern( + <jk>new</jk> ResponsePattern(<js>"y=(\\S+)"</js>) { + <ja>@Override</ja> + <jk>public void</jk> onMatch(RestCall restCall, Matcher m) <jk>throws</jk> RestCallException { + yList.add(m.group(1)); + } + <ja>@Override</ja> + <jk>public void</jk> onNoMatch(RestCall restCall) <jk>throws</jk> RestCallException { + <jk>throw new</jk> RestCallException(<js>"No Y's found!"</js>); + } + } + ) + .getResponseAsString(); + </p> + <p> + Using response patterns does not affect the functionality of any of the other methods + used to retrieve the response such as <a href="../../../../org/apache/juneau/client/RestCall.html#getResponseAsString--"><code>RestCall.getResponseAsString()</code></a> or <a href="../../../../org/apache/juneau/client/RestCall.html#getResponse-java.lang.Class-"><code>RestCall.getResponse(Class)</code></a>.<br> + HOWEVER, if you want to retrieve the entire text of the response from inside the match methods, + use <a href="../../../../org/apache/juneau/client/RestCall.html#getCapturedResponse--"><code>RestCall.getCapturedResponse()</code></a> since this method will not absorb the response for those other methods. + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="#PipingOutput"></a> + <h3 class='topic' onclick='toggle(this)'>1.4 - Piping Response Output</h3> + <div class='topic'> + <p> + The <a href="../../../../org/apache/juneau/client/RestCall.html" title="class in org.apache.juneau.client"><code>RestCall</code></a> class provides various convenience <code>pipeTo()</code> methods + to pipe output to output streams and writers. + </p> + <p> + If you want to pipe output without any intermediate buffering, you can use the <a href="../../../../org/apache/juneau/client/RestCall.html#byLines--"><code>RestCall.byLines()</code></a> method. + This will cause the output to be piped and flushed after every line. + This can be useful if you want to display the results in real-time from a long running process producing + output on a REST call. + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jc>// Pipe output from REST call to System.out in real-time.</jc> + restClient.doPost(<jsf>URL</jsf>).byLines().pipeTo(<jk>new</jk> PrintWriter(System.<jk>out</jk>)).run(); + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="Logging"></a> + <h3 class='topic' onclick='toggle(this)'>1.5 - Logging</h3> + <div class='topic'> + <p> + Use the <a href="../../../../org/apache/juneau/client/RestClient.html#logTo-java.util.logging.Level-java.util.logging.Logger-"><code>RestClient.logTo(Level,Logger)</code></a> and <a href="../../../../org/apache/juneau/client/RestCall.html#logTo-java.util.logging.Level-java.util.logging.Logger-"><code>RestCall.logTo(Level,Logger)</code></a> methods + to log HTTP calls. + These methods will cause the HTTP request and response headers and body to be logged to the specified logger. + </p> + <h6 class='topic'>Example:</h6> + <p class='bcode'> + <jc>// Log the HTTP request/response to the specified logger.</jc> + <jk>int</jk> rc = restClient.doGet(<jsf>URL</jsf>).logTo(<jsf>INFO</jsf>, getLogger()).run(); + </p> + <p> + The method call is ignored if the logger level is below the specified level. + </p> + <p> + Customized logging can be handled by subclassing the <a href="../../../../org/apache/juneau/client/RestCallLogger.html" title="class in org.apache.juneau.client"><code>RestCallLogger</code></a> class and using the + <a href="../../../../org/apache/juneau/client/RestCall.html#addInterceptor-org.apache.juneau.client.RestCallInterceptor-"><code>RestCall.addInterceptor(RestCallInterceptor)</code></a> method. + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="Interceptors"></a> + <h3 class='topic' onclick='toggle(this)'>1.6 - Interceptors</h3> + <div class='topic'> + <p> + The <a href="../../../../org/apache/juneau/client/RestClient.html#addInterceptor-org.apache.juneau.client.RestCallInterceptor-"><code>RestClient.addInterceptor(RestCallInterceptor)</code></a> and <a href="../../../../org/apache/juneau/client/RestCall.html#addInterceptor-org.apache.juneau.client.RestCallInterceptor-"><code>RestCall.addInterceptor(RestCallInterceptor)</code></a> methods + can be used to intercept responses during specific connection lifecycle events. + </p> + <p> + The <a href="../../../../org/apache/juneau/client/RestCallLogger.html" title="class in org.apache.juneau.client"><code>RestCallLogger</code></a> class is an example of an interceptor that uses the various lifecycle methods + to log HTTP requests. + </p> + <p class='bcode'> + <jd>/** + * Specialized interceptor for logging calls to a log file. + */</jd> + <jk>public class</jk> RestCallLogger <jk>extends</jk> RestCallInterceptor { + + <jk>private</jk> Level <jf>level</jf>; + <jk>private</jk> Logger <jf>log</jf>; + + <jd>/** + * Constructor. + * + * <ja>@param</ja> level The log level to log messages at. + * <ja>@param</ja> log The logger to log to. + */</jd> + <jk>protected</jk> RestCallLogger(Level level, Logger log) { + <jk>this</jk>.<jf>level</jf> = level; + <jk>this</jk>.<jf>log</jf> = log; + } + + <ja>@Override</ja> <jc>/* RestCallInterceptor */</jc> + <jk>public void</jk> onInit(RestCall restCall) { + <jk>if</jk> (<jf>log</jf>.isLoggable(<jf>level</jf>)) + restCall.captureResponse(); + } + + <ja>@Override</ja> <jc>/* RestCallInterceptor */</jc> + <jk>public void</jk> onConnect(RestCall restCall, <jk>int</jk> statusCode, HttpRequest req, HttpResponse res) { + <jc>// Do nothing.</jc> + } + + <ja>@Override</ja> <jc>/* RestCallInterceptor */</jc> + <jk>public void</jk> onRetry(RestCall restCall, <jk>int</jk> statusCode, HttpRequest req, HttpResponse res) { + <jk>if</jk> (<jf>log</jf>.isLoggable(<jf>level</jf>)) + <jf>log</jf>.log(level, MessageFormat.<jsm>format</jsm>(<js>"Call to {0} returned {1}. Will retry."</js>, req.getRequestLine().getUri(), statusCode)); + } + + <ja>@Override</ja> <jc>/* RestCallInterceptor */</jc> + <jk>public void</jk> onClose(RestCall restCall) <jk>throws</jk> RestCallException { + <jk>try</jk> { + <jk>if</jk> (<jf>log</jf>.isLoggable(<jf>level</jf>)) { + String output = restCall.getCapturedResponse(); + StringBuilder sb = <jk>new</jk> StringBuilder(); + HttpUriRequest req = restCall.getRequest(); + HttpResponse res = restCall.getResponse(); + <jk>if</jk> (req != <jk>null</jk>) { + sb.append(<js>"\n=== HTTP Call =================================================================="</js>); + + sb.append(<js>"\n=== REQUEST ===\n"</js>).append(req); + sb.append(<js>"\n---request headers---"</js>); + <jk>for</jk> (Header h : req.getAllHeaders()) + sb.append(<js>"\n"</js>).append(h); + <jk>if</jk> (req <jk>instanceof</jk> HttpEntityEnclosingRequestBase) { + sb.append(<js>"\n---request entity---"</js>); + HttpEntityEnclosingRequestBase req2 = (HttpEntityEnclosingRequestBase)req; + HttpEntity e = req2.getEntity(); + <jk>if</jk> (e == <jk>null</jk>) + sb.append(<js>"\nEntity is null"</js>); + <jk>else</jk> { + <jk>if</jk> (e.getContentType() != <jk>null</jk>) + sb.append(<js>"\n"</js>).append(e.getContentType()); + <jk>if</jk> (e.getContentEncoding() != <jk>null</jk>) + sb.append(<js>"\n"</js>).append(e.getContentEncoding()); + <jk>if</jk> (e.isRepeatable()) { + <jk>try</jk> { + sb.append(<js>"\n---request content---\n"</js>).append(EntityUtils.<jsm>toString</jsm>(e)); + } <jk>catch</jk> (Exception ex) { + <jk>throw new</jk> RuntimeException(ex); + } + } + } + } + } + <jk>if</jk> (res != <jk>null</jk>) { + sb.append(<js>"\n=== RESPONSE ===\n"</js>).append(res.getStatusLine()); + sb.append(<js>"\n---response headers---"</js>); + <jk>for</jk> (Header h : res.getAllHeaders()) + sb.append(<js>"\n"</js>).append(h); + sb.append(<js>"\n---response content---\n"</js>).append(output); + sb.append(<js>"\n=== END ========================================================================"</js>); + } + <jf>log</jf>.log(<jf>level</jf>, sb.toString()); + } + } <jk>catch</jk> (IOException e) { + <jf>log</jf>.log(Level.<jsf>SEVERE</jsf>, e.getLocalizedMessage(), e); + } + } + } + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="Remoteable"></a> + <h3 class='topic' onclick='toggle(this)'>1.7 - Remotable Proxies</h3> + <div class='topic'> + <p> + Juneau provides the capability of calling methods on POJOs on a server through client-side proxy interfaces. + It offers a number of advantages over other similar remote proxy interfaces, such as being much simpler to + use and allowing much more flexibility. + </p> + <p> + Proxy interfaces are retrieved using the <a href="../../../../org/apache/juneau/client/RestClient.html#getRemoteableProxy-java.lang.Class-"><code>RestClient.getRemoteableProxy(Class)</code></a> method. + The <a href="../../../../org/apache/juneau/client/RestClient.html#setRemoteableServletUri-java.lang.String-"><code>RestClient.setRemoteableServletUri(String)</code></a> method is used to specify the location + of the remoteable services servlet running on the server. + The remoteable servlet is a specialized subclass of <a href="../../../../org/apache/juneau/server/RestServlet.html" title="class in org.apache.juneau.server"><code>RestServlet</code></a> that provides a full-blown + REST interface for calling interfaces remotely. + </p> + <p> + In this example, we have the following interface defined that we want to call from the client side against + a POJO on the server side (i.e. a Remoteable Service)... + <p class='bcode'> + <jk>public interface</jk> IAddressBook { + Person createPerson(CreatePerson cp) <jk>throws</jk> Exception; + } + </p> + <p> + The client side code for invoking this method is shown below... + </p> + <p class='bcode'> + <jc>// Create a RestClient using JSON for serialization, and point to the server-side remoteable servlet.</jc> + RestClient client = <jk>new</jk> RestClient(JsonSerializer.<jk>class</jk>, JsonParser.<jk>class</jk>) + .setRemoteableServletUri(<js>"https://localhost:9080/juneau/sample/remoteable"</js>); + + <jc>// Create a proxy interface.</jc> + IAddressBook ab = client.getRemoteableProxy(IAddressBook.<jk>class</jk>); + + <jc>// Invoke a method on the server side and get the returned result.</jc> + Person p = ab.createPerson( + <jk>new</jk> CreatePerson(<js>"Test Person"</js>, + AddressBook.<jsm>toCalendar</jsm>(<js>"Aug 1, 1999"</js>), + <jk>new</jk> CreateAddress(<js>"Test street"</js>, <js>"Test city"</js>, <js>"Test state"</js>, 12345, <jk>true</jk>)) + ); + </p> + <p> + The requirements for a method to be callable through a remoteable service are: + <ul class='spaced-list'> + <li>The method must be public. + <li>The parameter and return types must be <a href='../../../../org/apache/juneau/package-summary.html#PojoCategories'><u>serializable and parsable</u></a>. + </ul> + </p> + <p> + One significant feature is that the remoteable services servlet is a full-blown REST interface. + Therefore, in cases where the interface classes are not available on the client side, + the same method calls can be made through pure REST calls. + This can also aid significantly in debugging since calls to the remoteable service + can be called directly from a browser with no code involved. + </p> + <p> + See <a href="../../../../org/apache/juneau/server/remoteable/package-summary.html"><code>org.apache.juneau.server.remoteable</code></a> for more information. + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="Other"></a> + <h3 class='topic' onclick='toggle(this)'>1.8 - Other Useful Methods</h3> + <div class='topic'> + <p> + The <a href="../../../../org/apache/juneau/client/RestClient.html#setRootUrl-java.lang.String-"><code>RestClient.setRootUrl(String)</code></a> method can be used to specify a root URL on + all requests so that you don't have to use absolute paths on individual calls. + </p> + <p class='bcode'> + <jc>// Create a rest client with a root URL</jc> + RestClient rc = <jk>new</jk> RestClient().setRootUrl(<js>"http://localhost:9080/foobar"</js>); + String r = rc.doGet(<js>"/baz"</js>).getResponseAsString(); <jc>// Gets "http://localhost:9080/foobar/baz"</jc> + </p> + <p> + The <a href="../../../../org/apache/juneau/client/RestClient.html#setProperty-java.lang.String-java.lang.Object-"><code>RestClient.setProperty(String,Object)</code></a> method can be used to set serializer + and parser properties. + For example, if you're parsing a response into POJOs and you want to ignore fields that aren't on the + POJOs, you can use the <a href="../../../../org/apache/juneau/BeanContext.html#BEAN_ignoreUnknownBeanProperties"><code>BeanContext.BEAN_ignoreUnknownBeanProperties</code></a> property. + </p> + <p class='bcode'> + <jc>// Create a rest client that ignores unknown fields in the response</jc> + RestClient rc = <jk>new</jk> RestClient(JsonSerializer.<jk>class</jk>, JsonParser.<jk>class</jk>) + .setProperty(<jsf>BEAN_ignoreUnknownBeanProperties</jsf>, <jk>true</jk>); + MyPojo myPojo = rc.doGet(<jsf>URL</jsf>).getResponse(MyPojo.<jk>class</jk>); + </p> + <p> + The <a href="../../../../org/apache/juneau/client/RestCall.html#setRetryable-int-long-org.apache.juneau.client.RetryOn-"><code>RestCall.setRetryable(int,long,RetryOn)</code></a> method can be used to automatically + retry requests on failures. + This can be particularly useful if you're attempting to connect to a REST resource that may be in + the process of still initializing. + </p> + <p class='bcode'> + <jc>// Create a rest call that retries every 10 seconds for up to 30 minutes as long as a connection fails + // or a 400+ is received.</jc> + restClient.doGet(<jsf>URL</jsf>) + .setRetryable(180, 10000, RetryOn.<jsf>DEFAULT</jsf>) + .run(); + </p> + </div> +</div></div> +</div> +<!-- ======= START OF BOTTOM NAVBAR ====== --> +<div class="bottomNav"><a name="navbar.bottom"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.bottom.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="../../../../overview-summary.html">Overview</a></li> +<li class="navBarCell1Rev">Package</li> +<li>Class</li> +<li><a href="package-use.html">Use</a></li> +<li><a href="package-tree.html">Tree</a></li> +<li><a href="../../../../deprecated-list.html">Deprecated</a></li> +<li><a href="../../../../index-all.html">Index</a></li> +<li><a href="../../../../help-doc.html">Help</a></li> +</ul> +</div> +<div class="subNav"> +<ul class="navList"> +<li><a href="../../../../org/apache/juneau/annotation/package-summary.html">Prev Package</a></li> +<li><a href="../../../../org/apache/juneau/csv/package-summary.html">Next Package</a></li> +</ul> +<ul class="navList"> +<li><a href="../../../../index.html?org/apache/juneau/client/package-summary.html" target="_top">Frames</a></li> +<li><a href="package-summary.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_bottom"> +<li><a href="../../../../allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_bottom"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.bottom"> +<!-- --> +</a></div> +<!-- ======== END OF BOTTOM NAVBAR ======= --> +</body> +</html>
