Permalink
Browse files

2nd commit

  • Loading branch information...
1 parent 2f96eb8 commit 5a5d91ca46f94d19740e7f0b5a7fd60068c5355f @helun committed Apr 13, 2011
Showing with 15,127 additions and 0 deletions.
  1. +8 −0 doc/src/docbkx/customization.xsl
  2. +10 −0 doc/src/docbkx/docbook.css
  3. +35 −0 doc/src/docbkx/index.html
  4. +201 −0 license.txt
  5. +115 −0 org.ektorp.spring/src/main/java/org/ektorp/spring/HttpClientFactoryBean.java
  6. +97 −0 org.ektorp.spring/src/main/java/org/ektorp/spring/InitialDataLoader.java
  7. +58 −0 org.ektorp.spring/src/main/java/org/ektorp/spring/RetryAdvice.java
  8. +19 −0 org.ektorp.spring/src/main/java/org/ektorp/spring/Retryable.java
  9. +40 −0 org.ektorp.spring/src/test/java/org/ektorp/spring/RetryAdviceTest.java
  10. +101 −0 org.ektorp/src/main/java/org/ektorp/Attachment.java
  11. +42 −0 org.ektorp/src/main/java/org/ektorp/AttachmentInputStream.java
  12. +80 −0 org.ektorp/src/main/java/org/ektorp/BulkDeleteDocument.java
  13. +60 −0 org.ektorp/src/main/java/org/ektorp/ComplexKey.java
  14. +344 −0 org.ektorp/src/main/java/org/ektorp/CouchDbConnector.java
  15. +39 −0 org.ektorp/src/main/java/org/ektorp/CouchDbInstance.java
  16. +22 −0 org.ektorp/src/main/java/org/ektorp/DbAccessException.java
  17. +129 −0 org.ektorp/src/main/java/org/ektorp/DbInfo.java
  18. +85 −0 org.ektorp/src/main/java/org/ektorp/DbPath.java
  19. +117 −0 org.ektorp/src/main/java/org/ektorp/DesignDocInfo.java
  20. +17 −0 org.ektorp/src/main/java/org/ektorp/DocumentExistsException.java
  21. +44 −0 org.ektorp/src/main/java/org/ektorp/DocumentNotFoundException.java
  22. +82 −0 org.ektorp/src/main/java/org/ektorp/DocumentOperationResult.java
  23. +15 −0 org.ektorp/src/main/java/org/ektorp/InvalidDocumentException.java
  24. +159 −0 org.ektorp/src/main/java/org/ektorp/ReplicationCommand.java
  25. +169 −0 org.ektorp/src/main/java/org/ektorp/ReplicationStatus.java
  26. +62 −0 org.ektorp/src/main/java/org/ektorp/Revision.java
  27. +29 −0 org.ektorp/src/main/java/org/ektorp/UpdateConflictException.java
  28. +755 −0 org.ektorp/src/main/java/org/ektorp/ViewQuery.java
  29. +145 −0 org.ektorp/src/main/java/org/ektorp/ViewResult.java
  30. +25 −0 org.ektorp/src/main/java/org/ektorp/ViewResultException.java
  31. +120 −0 org.ektorp/src/main/java/org/ektorp/changes/ChangesCommand.java
  32. +42 −0 org.ektorp/src/main/java/org/ektorp/changes/ChangesFeed.java
  33. +40 −0 org.ektorp/src/main/java/org/ektorp/changes/DocumentChange.java
  34. +24 −0 org.ektorp/src/main/java/org/ektorp/dataload/DataLoader.java
  35. +68 −0 org.ektorp/src/main/java/org/ektorp/dataload/DefaultDataLoader.java
  36. +31 −0 org.ektorp/src/main/java/org/ektorp/docref/CascadeType.java
  37. +68 −0 org.ektorp/src/main/java/org/ektorp/docref/DocumentReferences.java
  38. +21 −0 org.ektorp/src/main/java/org/ektorp/docref/FetchType.java
  39. +422 −0 org.ektorp/src/main/java/org/ektorp/http/AndroidSSLSocketFactory.java
  40. +25 −0 org.ektorp/src/main/java/org/ektorp/http/HttpClient.java
  41. +15 −0 org.ektorp/src/main/java/org/ektorp/http/HttpResponse.java
  42. +49 −0 org.ektorp/src/main/java/org/ektorp/http/HttpStatus.java
  43. +42 −0 org.ektorp/src/main/java/org/ektorp/http/IdleConnectionMonitor.java
  44. +43 −0 org.ektorp/src/main/java/org/ektorp/http/PreemptiveAuthRequestInterceptor.java
  45. +17 −0 org.ektorp/src/main/java/org/ektorp/http/ResponseCallback.java
  46. +110 −0 org.ektorp/src/main/java/org/ektorp/http/RestTemplate.java
  47. +359 −0 org.ektorp/src/main/java/org/ektorp/http/StdHttpClient.java
  48. +151 −0 org.ektorp/src/main/java/org/ektorp/http/StdHttpResponse.java
  49. +69 −0 org.ektorp/src/main/java/org/ektorp/http/StdResponseHandler.java
  50. +96 −0 org.ektorp/src/main/java/org/ektorp/http/URI.java
  51. +50 −0 org.ektorp/src/main/java/org/ektorp/impl/BulkDocumentWriter.java
  52. +33 −0 org.ektorp/src/main/java/org/ektorp/impl/BulkOperation.java
  53. +70 −0 org.ektorp/src/main/java/org/ektorp/impl/BulkOperationResponseHandler.java
  54. +54 −0 org.ektorp/src/main/java/org/ektorp/impl/DocIdResponseHandler.java
  55. +206 −0 org.ektorp/src/main/java/org/ektorp/impl/EmbeddedDocViewResponseHandler.java
  56. +12 −0 org.ektorp/src/main/java/org/ektorp/impl/JsonSerializer.java
  57. +28 −0 org.ektorp/src/main/java/org/ektorp/impl/NameConventions.java
  58. +23 −0 org.ektorp/src/main/java/org/ektorp/impl/ObjectMapperFactory.java
  59. +25 −0 org.ektorp/src/main/java/org/ektorp/impl/RevisionResponseHandler.java
  60. +494 −0 org.ektorp/src/main/java/org/ektorp/impl/StdCouchDbConnector.java
  61. +93 −0 org.ektorp/src/main/java/org/ektorp/impl/StdCouchDbInstance.java
  62. +70 −0 org.ektorp/src/main/java/org/ektorp/impl/StdObjectMapperFactory.java
  63. +93 −0 org.ektorp/src/main/java/org/ektorp/impl/StreamingJsonSerializer.java
  64. +30 −0 org.ektorp/src/main/java/org/ektorp/impl/ThreadLocalBulkBufferHolder.java
  65. +130 −0 org.ektorp/src/main/java/org/ektorp/impl/changes/ContinuousChangesFeed.java
  66. +64 −0 org.ektorp/src/main/java/org/ektorp/impl/changes/StdDocumentChange.java
  67. +97 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/BackReferencedBeanDeserializer.java
  68. +118 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/BackReferencedBeanSerializer.java
  69. +52 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/ConstructibleAnnotatedCollection.java
  70. +140 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/DocumentReferenceDeserializerFactory.java
  71. +105 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/DocumentReferenceSerializerFactory.java
  72. +136 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/DocumentReferenceSerializerProvider.java
  73. +37 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/LazyLoadingViewBasedCollection.java
  74. +246 −0 org.ektorp/src/main/java/org/ektorp/impl/docref/ViewBasedCollection.java
  75. +108 −0 org.ektorp/src/main/java/org/ektorp/support/CouchDbDocument.java
  76. +283 −0 org.ektorp/src/main/java/org/ektorp/support/CouchDbRepositorySupport.java
  77. +290 −0 org.ektorp/src/main/java/org/ektorp/support/DesignDocument.java
  78. +17 −0 org.ektorp/src/main/java/org/ektorp/support/DesignDocumentFactory.java
  79. +33 −0 org.ektorp/src/main/java/org/ektorp/support/Entity.java
  80. +35 −0 org.ektorp/src/main/java/org/ektorp/support/Filter.java
  81. +11 −0 org.ektorp/src/main/java/org/ektorp/support/Filters.java
  82. +18 −0 org.ektorp/src/main/java/org/ektorp/support/GenerateView.java
  83. +58 −0 org.ektorp/src/main/java/org/ektorp/support/GenericRepository.java
  84. +34 −0 org.ektorp/src/main/java/org/ektorp/support/ListFunction.java
  85. +10 −0 org.ektorp/src/main/java/org/ektorp/support/Lists.java
  86. +49 −0 org.ektorp/src/main/java/org/ektorp/support/OpenCouchDbDocument.java
  87. +34 −0 org.ektorp/src/main/java/org/ektorp/support/ShowFunction.java
  88. +10 −0 org.ektorp/src/main/java/org/ektorp/support/Shows.java
  89. +366 −0 org.ektorp/src/main/java/org/ektorp/support/SimpleViewGenerator.java
  90. +144 −0 org.ektorp/src/main/java/org/ektorp/support/StdDesignDocumentFactory.java
  91. +27 −0 org.ektorp/src/main/java/org/ektorp/support/TypeDiscriminator.java
  92. +48 −0 org.ektorp/src/main/java/org/ektorp/support/View.java
  93. +18 −0 org.ektorp/src/main/java/org/ektorp/support/ViewGenerationException.java
  94. +16 −0 org.ektorp/src/main/java/org/ektorp/support/Views.java
  95. +70 −0 org.ektorp/src/main/java/org/ektorp/util/Assert.java
  96. +112 −0 org.ektorp/src/main/java/org/ektorp/util/ClassHierarchyMap.java
  97. +21 −0 org.ektorp/src/main/java/org/ektorp/util/DocumentAccessor.java
  98. +495 −0 org.ektorp/src/main/java/org/ektorp/util/Documents.java
  99. +26 −0 org.ektorp/src/main/java/org/ektorp/util/Exceptions.java
  100. +123 −0 org.ektorp/src/main/java/org/ektorp/util/JSONComparator.java
  101. +18 −0 org.ektorp/src/main/java/org/ektorp/util/JSONEncoding.java
  102. +18 −0 org.ektorp/src/main/java/org/ektorp/util/Joiner.java
  103. +7 −0 org.ektorp/src/main/java/org/ektorp/util/Predicate.java
  104. +109 −0 org.ektorp/src/main/java/org/ektorp/util/ReflectionUtils.java
  105. +18 −0 org.ektorp/src/test/java/org/ektorp/BulkDeleteDocumentTest.java
  106. +31 −0 org.ektorp/src/test/java/org/ektorp/ComplexKeyTest.java
  107. +29 −0 org.ektorp/src/test/java/org/ektorp/DesignDocInfoTest.java
  108. +19 −0 org.ektorp/src/test/java/org/ektorp/DocumentNotFoundExceptionTest.java
  109. +32 −0 org.ektorp/src/test/java/org/ektorp/DocumentOperationResponseTest.java
  110. +52 −0 org.ektorp/src/test/java/org/ektorp/ReplicationCommandTest.java
  111. +33 −0 org.ektorp/src/test/java/org/ektorp/ReplicationStatusTest.java
  112. +264 −0 org.ektorp/src/test/java/org/ektorp/ViewQueryTest.java
  113. +89 −0 org.ektorp/src/test/java/org/ektorp/ViewResultTest.java
  114. +28 −0 org.ektorp/src/test/java/org/ektorp/changes/ChangesCommandTest.java
  115. +74 −0 org.ektorp/src/test/java/org/ektorp/http/BulkTest.java
  116. +304 −0 org.ektorp/src/test/java/org/ektorp/http/RestTemplateTest.java
  117. +40 −0 org.ektorp/src/test/java/org/ektorp/http/URITest.java
  118. +86 −0 org.ektorp/src/test/java/org/ektorp/impl/BulkDocumentWriterTest.java
  119. +54 −0 org.ektorp/src/test/java/org/ektorp/impl/BulkOperationResponseHandlerTest.java
  120. +90 −0 org.ektorp/src/test/java/org/ektorp/impl/EmbeddedDocViewResponseHandlerTest.java
  121. +52 −0 org.ektorp/src/test/java/org/ektorp/impl/HttpResponseStub.java
  122. +79 −0 org.ektorp/src/test/java/org/ektorp/impl/ResponseOnFileStub.java
  123. +574 −0 org.ektorp/src/test/java/org/ektorp/impl/StdCouchDbConnectorTest.java
  124. +61 −0 org.ektorp/src/test/java/org/ektorp/impl/StdCouchDbInstanceTest.java
  125. +49 −0 org.ektorp/src/test/java/org/ektorp/impl/StreamingJsonSerializerTest.java
  126. +72 −0 org.ektorp/src/test/java/org/ektorp/impl/ThreadLocalBulkBufferHolderTest.java
  127. +188 −0 org.ektorp/src/test/java/org/ektorp/impl/changes/ContinuousChangesFeedTest.java
  128. +51 −0 org.ektorp/src/test/java/org/ektorp/impl/changes/StdDocumentChangeTest.java
  129. +28 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/BasicSofa.java
  130. +115 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/DocumentReferenceDeserializerTest.java
  131. +262 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/DocumentReferenceTest.java
  132. +178 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/DocumentReferencesCouchDbTest.java
  133. +66 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/InputStreamAsJsonMatcher.java
  134. +28 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/JSONMatcher.java
  135. +21 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/LazyLounge.java
  136. +36 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/NoCascadeLounge.java
  137. +12 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/People.java
  138. +84 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/Person.java
  139. +36 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/SetLounge.java
  140. +118 −0 org.ektorp/src/test/java/org/ektorp/impl/docref/ViewBasedCollectionTest.java
  141. +41 −0 org.ektorp/src/test/java/org/ektorp/support/CouchDbDocumentTest.java
  142. +227 −0 org.ektorp/src/test/java/org/ektorp/support/CouchDbRepositorySupportTest.java
  143. +60 −0 org.ektorp/src/test/java/org/ektorp/support/DesignDocumentFactoryTest.java
  144. +129 −0 org.ektorp/src/test/java/org/ektorp/support/DesignDocumentTest.java
  145. +51 −0 org.ektorp/src/test/java/org/ektorp/support/OpenCouchDbDocumentTest.java
  146. +427 −0 org.ektorp/src/test/java/org/ektorp/support/SimpleViewGeneratorTest.java
  147. +66 −0 org.ektorp/src/test/java/org/ektorp/util/ClassHierarchyMapTest.java
  148. +339 −0 org.ektorp/src/test/java/org/ektorp/util/DocumentsTest.java
  149. +37 −0 org.ektorp/src/test/java/org/ektorp/util/JSONComparatorTest.java
  150. +30 −0 org.ektorp/src/test/java/org/ektorp/util/JoinerTest.java
  151. +52 −0 org.ektorp/src/test/java/org/ektorp/util/ReflectionUtilsTest.java
  152. +24 −0 org.ektorp/src/test/java/org/ektorp/util/RegexMatcher.java
  153. +1 −0 org.ektorp/src/test/resources/org/ektorp/basic_replication_command.json
  154. +13 −0 org.ektorp/src/test/resources/org/ektorp/design_doc_info.json
  155. +5 −0 org.ektorp/src/test/resources/org/ektorp/document_operation_response.json
  156. +9 −0 org.ektorp/src/test/resources/org/ektorp/full_replication_command.json
  157. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/all_docs_result.json
  158. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/array_and_object_view_result.json
  159. +5 −0 org.ektorp/src/test/resources/org/ektorp/impl/bulk_response.json
  160. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/changes/change_message.json
  161. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/changes/change_message_w_deleted_doc.json
  162. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/changes/change_message_w_included_doc.json
  163. +5 −0 org.ektorp/src/test/resources/org/ektorp/impl/charset.json
  164. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/complex_key_view_result.json
  165. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/create.json
  166. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/create_attachment_rsp.json
  167. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/create_from_json_node.json
  168. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/create_with_no_id.json
  169. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/dates.json
  170. +11 −0 org.ektorp/src/test/resources/org/ektorp/impl/db_info.json
  171. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/docref/expected_lounge_persons_update.json
  172. +5 −0 org.ektorp/src/test/resources/org/ektorp/impl/docref/lounge.json
  173. +5 −0 org.ektorp/src/test/resources/org/ektorp/impl/docref/lounge_person_kalle.json
  174. +5 −0 org.ektorp/src/test/resources/org/ektorp/impl/docref/lounge_person_nisse.json
  175. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/docref/setlounge_persons_nisse_kalle.json
  176. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/empty_reduced_view_result.json
  177. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/erroneous_cloudant_view_result.json
  178. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/int_view_result.json
  179. +5 −0 org.ektorp/src/test/resources/org/ektorp/impl/reduce_view_result.json
  180. +10 −0 org.ektorp/src/test/resources/org/ektorp/impl/revisions.json
  181. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/set_dbname.json
  182. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/update.json
  183. +1 −0 org.ektorp/src/test/resources/org/ektorp/impl/update_conflict.json
  184. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/view_result.json
  185. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/view_result_with_embedded_docs.json
  186. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/view_result_with_error.json
  187. +4 −0 org.ektorp/src/test/resources/org/ektorp/impl/view_result_with_included_docs.json
  188. +3 −0 org.ektorp/src/test/resources/org/ektorp/impl/view_result_with_single_row.json
  189. +1 −0 org.ektorp/src/test/resources/org/ektorp/replication_response.json
  190. +16 −0 org.ektorp/src/test/resources/org/ektorp/support/complicated_view.json
  191. +17 −0 org.ektorp/src/test/resources/org/ektorp/support/design_doc.json
  192. +9 −0 org.ektorp/src/test/resources/org/ektorp/support/open_doc.json
  193. +1 −0 org.ektorp/src/test/resources/org/ektorp/util/doc_a.json
  194. +1 −0 org.ektorp/src/test/resources/org/ektorp/util/doc_b.json
  195. +1 −0 org.ektorp/src/test/resources/org/ektorp/util/doc_c.json
  196. +180 −0 pom.xml
@@ -0,0 +1,8 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xslthl="http://xslthl.sf.net" exclude-result-prefixes="xslthl"
+ version="1.0">
+
+ <xsl:import href="urn:docbkx:stylesheet" />
+ <xsl:import href="urn:docbkx:stylesheet/highlight.xsl" />
+
+</xsl:stylesheet>
View
@@ -0,0 +1,10 @@
+@IMPORT url("http://yui.yahooapis.com/combo?3.0.0/build/cssfonts/fonts-min.css&3.0.0/build/cssreset/reset-min.css&3.0.0/build/cssbase/base-min.css");
+html, body {background: #fefefe;}
+.book { margin: 0 10%; font-size:123.1%; font-family: 'Lucida Grande', Calibri, Arial, Verdana, sans-serif;}
+.author, .pubdate { color: #aaa;}
+.programlisting { background: #eee; border: 1px solid #ccc; padding: 1em; font-size: 93%;}
+h2 { border-bottom: 1px solid #ccc; }
+.hl-keyword {color: #82075a; }
+.hl-string i {color: #2a00ff !important; font-weight: normal; font-style: normal;}
+.emphasis { font-family: monospace;}
+.emphasis em { font-style: normal; }
View
@@ -0,0 +1,35 @@
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>Ektorp Java API for CouchDB</title>
+ <link rel="stylesheet" href="docbook.css" type="text/css">
+<body>
+ <div class="book">
+ <h1 style="font-size: 300%;">Welcome to Ektorp!</h1>
+ <p>Ektorp is a Java persistence API that uses CouchDB as storage engine.</p>
+ <p>The goal of Ektorp is to combine JPA-like functionality with the simplicity and flexibility that CouchDB provides.</p>
+ <h2>Useful links</h2>
+ <ul>
+ <li><a href="reference_documentation.html">Reference Documentation</a></li>
+ <li><a href="tutorial.html">Tutorial</a></li>
+ <li><a href="/javadoc/ektorp/1.0.2/">Javadoc for org.ektorp</a></li>
+ <li><a href="/javadoc/ektorp.spring/1.0.2/">Javadoc for org.ektorp.spring</a></li>
+ <li><a href="http://groups.google.com/group/ektorp-discuss">Mailing List</a></li>
+ <li><a href="http://twitter.com/#!/org_ektorp">Follow Ektorp on Twitter</a></li>
+ </ul>
+ <p>Also see the ektorp site at Google Code for the <a href="http://code.google.com/p/ektorp/downloads/list">downloads</a> and <a href="http://code.google.com/p/ektorp/issues/list">issue tracking.</a></p>
+ <h2>Contact</h2>
+ <p>Ektorp is brought to you by Henrik Lundgren and friends.</p>
+ <p>Send a mail to carl.henrik.lundgren [at] gmail.com if you have questions regarding Ektorp</p>
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try{
+ var pageTracker = _gat._getTracker("UA-504305-5");
+ pageTracker._trackPageview();
+ } catch(err) {}
+ </script>
+</body>
+</html>
View
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
@@ -0,0 +1,115 @@
+package org.ektorp.spring;
+
+import org.apache.http.conn.ssl.*;
+import org.ektorp.http.*;
+import org.ektorp.support.*;
+import org.slf4j.*;
+import org.springframework.beans.factory.*;
+import org.springframework.beans.factory.annotation.*;
+/**
+ * FactoryBean that produces a HttpClient.
+ * Configuration parameters are set through @Value annotations.
+ *
+ * The application context must define properties along the line of:
+ * <code>
+ * <util:properties id="couchdbProperties" location="classpath:/couchdb.properties"/>
+ * </code>
+ * @author henrik lundgren
+ *
+ */
+public class HttpClientFactoryBean implements FactoryBean<HttpClient> {
+
+ private final static Logger LOG = LoggerFactory.getLogger(HttpClientFactoryBean.class);
+
+ public @Value("#{couchdbProperties['host']?:'localhost'}") String host;
+ public @Value("#{couchdbProperties['port']?:5984}") int port;
+ public @Value("#{couchdbProperties['maxConnections']?:20}") int maxConnections;
+ public @Value("#{couchdbProperties['connectionTimeout']?:1000}") int connectionTimeout;
+ public @Value("#{couchdbProperties['socketTimeout']?:10000}") int socketTimeout;
+ public @Value("#{couchdbProperties['autoUpdateViewOnChange']?:false}") boolean autoUpdateViewOnChange;
+ public @Value("#{couchdbProperties['username']}") String username;
+ public @Value("#{couchdbProperties['password']}") String password;
+ public @Value("#{couchdbProperties['testConnectionAtStartup']?:false}") boolean testConnectionAtStartup;
+ public @Value("#{couchdbProperties['cleanupIdleConnections']?:true}") boolean cleanupIdleConnections;
+ public @Value("#{couchdbProperties['enableSSL']?:false}") boolean enableSSL;
+ public @Value("#{couchdbProperties['relaxedSSLSettings']?:false}") boolean relaxedSSLSettings;
+
+ private SSLSocketFactory sslSocketFactory;
+
+ public HttpClient getObject() throws Exception {
+ LOG.debug("host: {}", host);
+ LOG.debug("port: {}", port);
+ LOG.debug("maxConnections: {}", maxConnections);
+ LOG.debug("connectionTimeout: {}", connectionTimeout);
+ LOG.debug("socketTimeout: {}", socketTimeout);
+ LOG.debug("autoUpdateViewOnChange: {}", autoUpdateViewOnChange);
+ LOG.debug("testConnectionAtStartup: {}", testConnectionAtStartup);
+ LOG.debug("cleanupIdleConnections: {}", cleanupIdleConnections);
+ LOG.debug("enableSSL: {}", enableSSL);
+ LOG.debug("relaxedSSLSettings: {}", relaxedSSLSettings);
+
+ HttpClient client = new StdHttpClient.Builder()
+ .host(host)
+ .port(port)
+ .maxConnections(maxConnections)
+ .connectionTimeout(connectionTimeout)
+ .socketTimeout(socketTimeout)
+ .username(username)
+ .password(password)
+ .cleanupIdleConnections(cleanupIdleConnections)
+ .enableSSL(enableSSL)
+ .relaxedSSLSettings(relaxedSSLSettings)
+ .sslSocketFactory(sslSocketFactory)
+ .build();
+
+ if (testConnectionAtStartup) {
+ testConnect(client);
+ }
+
+ configureAutoUpdateViewOnChange();
+ return client;
+ }
+
+ private void configureAutoUpdateViewOnChange() {
+ if (autoUpdateViewOnChange && !Boolean.getBoolean(CouchDbRepositorySupport.AUTO_UPDATE_VIEW_ON_CHANGE)) {
+ System.setProperty(CouchDbRepositorySupport.AUTO_UPDATE_VIEW_ON_CHANGE, Boolean.TRUE.toString());
+ }
+ }
+
+ private void testConnect(HttpClient client) {
+ try {
+ client.head("/");
+ } catch (Exception e) {
+ throw new BeanCreationException(String.format("Cannot connect to CouchDb@%s:%s", host, port), e);
+ }
+ }
+
+ public Class<? extends HttpClient> getObjectType() {
+ return HttpClient.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void setAutoUpdateViewOnChange(boolean b) {
+ this.autoUpdateViewOnChange = b;
+ }
+
+ public void setUsername(String user) {
+ this.username = user;
+ }
+
+ public void setPassword(String s) {
+ this.password = s;
+ }
+
+ public void setTestConnectionAtStartup(boolean b) {
+ this.testConnectionAtStartup = b;
+ }
+
+ public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) {
+ this.sslSocketFactory = sslSocketFactory;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 5a5d91c

Please sign in to comment.