Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added link to http://kool.io the new home of the code

  • Loading branch information...
commit 9d0f3d8a53b9119045c6dff47fd136780cd69308 1 parent dc4533b
@jstrachan jstrachan authored
Showing with 1 addition and 30,308 deletions.
  1. +1 −11 ReadMe.md
  2. +0 −108 apidoc/pom.xml
  3. +0 −50 javafx/koolapp-javafx-sample/ReadMe.md
  4. +0 −109 javafx/koolapp-javafx-sample/pom.xml
  5. +0 −25 javafx/koolapp-javafx-sample/sample.html
  6. +0 −8,981 javafx/koolapp-javafx-sample/src/main/js/jquery.js
  7. +0 −28 javafx/koolapp-javafx-sample/src/main/kotlin/test/koolapp/myapp/MyApp.kt
  8. +0 −21 javafx/koolapp-javafx-sample/src/main/resources/sample.html
  9. +0 −56 javafx/koolapp-javafx/pom.xml
  10. +0 −12 javafx/koolapp-javafx/src/main/kotlin/org/koolapp/javafx/Main.kt
  11. +0 −198 javafx/koolapp-javafx/src/main/kotlin/org/koolapp/javafx/WebApplication.kt
  12. +0 −22 javafx/pom.xml
  13. +0 −37 koolapp-camel/ReadMe.md
  14. +0 −53 koolapp-camel/pom.xml
  15. +0 −115 koolapp-camel/src/main/kotlin/org/koolapp/camel/CamelContexts.kt
  16. +0 −57 koolapp-camel/src/main/kotlin/org/koolapp/camel/Endpoints.kt
  17. +0 −192 koolapp-camel/src/main/kotlin/org/koolapp/camel/Exchanges.kt
  18. +0 −29 koolapp-camel/src/main/kotlin/org/koolapp/camel/Messages.kt
  19. +0 −459 koolapp-camel/src/main/kotlin/org/koolapp/camel/RoutesDefinitions.kt
  20. +0 −82 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/EndpointStream.kt
  21. +0 −25 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/FunctionExpression.kt
  22. +0 −22 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/FunctionProcessor.kt
  23. +0 −21 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/PredicateFunction.kt
  24. +0 −15 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/ThenDefinition.kt
  25. +0 −49 koolapp-camel/src/test/kotlin/test/koolapp/camel/ChoiceTest.kt
  26. +0 −78 koolapp-camel/src/test/kotlin/test/koolapp/camel/EndpointConsumeTest.kt
  27. +0 −45 koolapp-camel/src/test/kotlin/test/koolapp/camel/EndpointProduceTest.kt
  28. +0 −33 koolapp-camel/src/test/kotlin/test/koolapp/camel/FilterTest.kt
  29. +0 −34 koolapp-camel/src/test/kotlin/test/koolapp/camel/FilterThenTest.kt
  30. +0 −29 koolapp-camel/src/test/kotlin/test/koolapp/camel/ProcessTest.kt
  31. +0 −37 koolapp-camel/src/test/kotlin/test/koolapp/camel/RecipientListTest.kt
  32. +0 −34 koolapp-camel/src/test/kotlin/test/koolapp/camel/RouteBuilderTest.kt
  33. +0 −34 koolapp-camel/src/test/kotlin/test/koolapp/camel/TransformAndSetHeaderTest.kt
  34. +0 −29 koolapp-camel/src/test/kotlin/test/koolapp/camel/TransformTest.kt
  35. +0 −64 koolapp-html-modelgen/pom.xml
  36. +0 −187 koolapp-html-modelgen/src/main/kotlin/org/koolapp/tools/htmlgen/GenerateHtmlModel.kt
  37. +0 −1,291 koolapp-html-modelgen/src/main/resources/global-attributes.html
  38. +0 −3,413 koolapp-html-modelgen/src/main/resources/html5-spec.html
  39. +0 −8 koolapp-html-modelgen/src/test/kotlin/test/koolapp/htmlgen/Dummy.kt
  40. +0 −45 koolapp-html/pom.xml
  41. +0 −112 koolapp-html/src/main/kotlin/org/koolapp/html/Functions.kt
  42. +0 −8 koolapp-html/src/test/kotlin/test/koolapp/html/Dummy.kt
  43. +0 −64 koolapp-js-library/pom.xml
  44. +0 −72 koolapp-math/pom.xml
  45. +0 −156 koolapp-math/src/main/kotlin/org/koolapp/math/Functions.kt
  46. +0 −27 koolapp-math/src/test/kotlin/test/koolapp/math/CalculationsOnBeansTest.kt
  47. +0 −34 koolapp-math/src/test/kotlin/test/koolapp/math/CalculationsTest.kt
  48. +0 −42 koolapp-math/src/test/kotlin/test/koolapp/math/GroupByTest.kt
  49. +0 −90 koolapp-math/src/test/kotlin/test/koolapp/math/MarketDataMonitorTest.kt
  50. +0 −26 koolapp-math/src/test/kotlin/test/koolapp/math/WindowTest.kt
  51. +0 −54 koolapp-stream/ReadMe.md
  52. +0 −105 koolapp-stream/pom.xml
  53. +0 −9 koolapp-stream/src/main/kotlin/org/koolapp/stream/Collections.kt
  54. +0 −23 koolapp-stream/src/main/kotlin/org/koolapp/stream/Cursor.kt
  55. +0 −35 koolapp-stream/src/main/kotlin/org/koolapp/stream/Handler.kt
  56. +0 −14 koolapp-stream/src/main/kotlin/org/koolapp/stream/NonBlockingCursor.kt
  57. +0 −40 koolapp-stream/src/main/kotlin/org/koolapp/stream/NonBlockingHandler.kt
  58. +0 −40 koolapp-stream/src/main/kotlin/org/koolapp/stream/ScheduledExecutorServices.kt
  59. +0 −37 koolapp-stream/src/main/kotlin/org/koolapp/stream/SimpleStream.kt
  60. +0 −195 koolapp-stream/src/main/kotlin/org/koolapp/stream/Stream.kt
  61. +0 −59 koolapp-stream/src/main/kotlin/org/koolapp/stream/Timers.kt
  62. +0 −30 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/AbstractCursor.kt
  63. +0 −44 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/Collections.kt
  64. +0 −43 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/Cursors.kt
  65. +0 −40 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/DelegateStream.kt
  66. +0 −50 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/FutureStreams.kt
  67. +0 −93 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/Handlers.kt
  68. +0 −182 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/JoinStreams.kt
  69. +0 −33 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/MapStream.kt
  70. +0 −115 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/NonBlockingHandlers.kt
  71. +0 −33 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/Streams.kt
  72. +0 −15 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/SynchronousExecutor.kt
  73. +0 −44 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/TakeWhileStream.kt
  74. +0 −50 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/TimeWindowStream.kt
  75. +0 −36 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/TimerStream.kt
  76. +0 −47 koolapp-stream/src/main/kotlin/org/koolapp/stream/support/WindowStream.kt
  77. +0 −22 koolapp-stream/src/test/kotlin/test/koolapp/stream/CollectionTest.kt
  78. +0 −29 koolapp-stream/src/test/kotlin/test/koolapp/stream/DistinctTest.kt
  79. +0 −9 koolapp-stream/src/test/kotlin/test/koolapp/stream/Extensions.kt
  80. +0 −54 koolapp-stream/src/test/kotlin/test/koolapp/stream/JoinWindowsTest.kt
  81. +0 −27 koolapp-stream/src/test/kotlin/test/koolapp/stream/ScheduledExecutorServiceTest.kt
  82. +0 −34 koolapp-stream/src/test/kotlin/test/koolapp/stream/SimpleStreamTest.kt
  83. +0 −44 koolapp-stream/src/test/kotlin/test/koolapp/stream/TakeTest.kt
  84. +0 −348 koolapp-stream/src/test/kotlin/test/koolapp/stream/TcpEchoTest.kt
  85. +0 −33 koolapp-stream/src/test/kotlin/test/koolapp/stream/TimeWindowTest.kt
  86. +0 −25 koolapp-stream/src/test/kotlin/test/koolapp/stream/TimerTest.kt
  87. +0 −27 koolapp-stream/src/test/kotlin/test/koolapp/stream/WindowTest.kt
  88. +0 −29 koolapp-stream/src/test/kotlin/test/koolapp/stream/swing/SwingDemo.kt
  89. +0 −19 koolapp-template/ReadMe.md
  90. +0 −45 koolapp-template/pom.xml
  91. +0 −12 koolapp-template/src/main/kotlin/org/koolapp/template/FilterContext.kt
  92. +0 −25 koolapp-template/src/main/kotlin/org/koolapp/template/Filters.kt
  93. +0 −101 koolapp-template/src/main/kotlin/org/koolapp/template/Inputs.kt
  94. +0 −46 koolapp-template/src/main/kotlin/org/koolapp/template/Outputs.kt
  95. +0 −8 koolapp-template/src/main/kotlin/org/koolapp/template/RequestContext.kt
  96. +0 −21 koolapp-template/src/main/kotlin/org/koolapp/template/Template.kt
  97. +0 −12 koolapp-template/src/main/kotlin/org/koolapp/template/TextFilter.kt
  98. +0 −2,724 koolapp-template/src/main/kotlin/org/koolapp/template/html/GeneratedElements.kt
  99. +0 −69 koolapp-template/src/main/kotlin/org/koolapp/template/html/HtmlTemplates.kt
  100. +0 −16 koolapp-template/src/main/kotlin/org/koolapp/template/html/NodesJVM.kt
  101. +0 −30 koolapp-template/src/main/kotlin/org/koolapp/template/markdown/MarkdownFilter.kt
  102. +0 −1  koolapp-template/src/main/resources/META-INF/services/org.koolapp.template.TextFilter
  103. +0 −32 koolapp-template/src/test/kotlin/test/koolapp/template/html/HtmlTemplateTest.kt
  104. +0 −26 koolapp-template/src/test/kotlin/test/koolapp/template/html/HtmlTextTemplateTest.kt
  105. +0 −15 koolapp-template/src/test/kotlin/test/koolapp/template/markdown/MarkdownTest.kt
  106. +0 −39 koolapp-ui/pom.xml
  107. +0 −11 koolapp-ui/src/main/kotlin/org/koolapp/ui/DomBinder.kt
  108. +0 −11 koolapp-ui/src/test/kotlin/test/koolapp/BinderTest.kt
  109. +0 −46 koolapp-web/pom.xml
  110. +0 −59 koolapp-web/src/main/kotlin/org/koolapp/web/ContextListener.kt
  111. +0 −14 koolapp-web/src/main/kotlin/org/koolapp/web/Contexts.kt
  112. +0 −12 koolapp-web/src/main/kotlin/org/koolapp/web/HttpRequestContext.kt
  113. +0 −75 koolapp-web/src/main/kotlin/org/koolapp/web/LayoutServletFilter.kt
  114. +0 −35 koolapp-web/src/main/kotlin/org/koolapp/web/TextFilterServlet.kt
  115. +0 −69 koolapp-web/src/main/kotlin/org/koolapp/web/support/Wrappers.kt
  116. +0 −11 koolapp-web/src/test/kotlin/test/koolapp/BinderTest.kt
  117. +0 −142 pom.xml
  118. +0 −8 website/module.kt
  119. +0 −134 website/pom.xml
  120. +0 −339 website/src/main/apidocs/jquery-ui.css
  121. +0 −41 website/src/main/apidocs/js/apidoc.js
  122. +0 −38 website/src/main/apidocs/js/jquery-ui.js
  123. +0 −4 website/src/main/apidocs/js/jquery.js
  124. +0 −96 website/src/main/apidocs/kotlin.css
  125. BIN  website/src/main/apidocs/resources/bkg_blkheader.png
  126. BIN  website/src/main/apidocs/resources/bkg_gradient.gif
  127. BIN  website/src/main/apidocs/resources/bkgheader.png
  128. BIN  website/src/main/apidocs/resources/inherit.gif
  129. BIN  website/src/main/apidocs/resources/underline.gif
  130. +0 −127 website/src/main/apidocs/stylesheet.css
  131. +0 −96 website/src/main/kotlin/org/koolapp/website/DefaultLayoutTemplate.kt
  132. +0 −14 website/src/main/kotlin/org/koolapp/website/MyContextListener.kt
  133. +0 −21 website/src/main/kotlin/org/koolapp/website/MyLayoutFilter.kt
  134. +0 −84 website/src/main/kotlin/org/koolapp/website/SiteGenerator.kt
  135. +0 −7 website/src/main/webapp/WEB-INF/web.xml
  136. +0 −1  website/src/main/webapp/camel.md
  137. +0 −581 website/src/main/webapp/css/bootstrap-responsive.css
  138. +0 −4 website/src/main/webapp/css/bootstrap-responsive.min.css
  139. +0 −3,496 website/src/main/webapp/css/bootstrap.css
  140. +0 −632 website/src/main/webapp/css/bootstrap.min.css
  141. BIN  website/src/main/webapp/img/glyphicons-halflings-white.png
  142. BIN  website/src/main/webapp/img/glyphicons-halflings.png
  143. +0 −28 website/src/main/webapp/index.html
  144. +0 −1,720 website/src/main/webapp/js/bootstrap.js
  145. +0 −1  website/src/main/webapp/js/bootstrap.min.js
  146. +0 −1  website/src/main/webapp/streams.md
  147. +0 −1  website/src/main/webapp/templates.md
  148. +0 −59 website/src/test/kotlin/org/koolapp/kotlin/website/GenerateSiteTest.kt
  149. +0 −133 website/src/test/kotlin/org/koolapp/kotlin/website/Main.kt
View
12 ReadMe.md
@@ -1,12 +1,2 @@
-## Welcome to KoolApp!
+## This repo has moved to [http://kool.io](http://kool.io) and at [github/koolio/kool](https://github.com/koolio/kool)
-**KoolApp** is a framework for developing applications built in [Kotlin](http://jetbrains.github.com/kotlin/) so that it can be used on the client
-side in a browser via JavaScript or on the server side in some JVM process, Servlet or JAXRS system.
-
-The main components of KoolApp today are
-
-* [Kool Camel](http://koolapp.org/camel.html) provides a [kotlin](http://jetbrains.github.com/kotlin/) based DSL for [Apache Camel](http://camel.apache.org/) together with integration with [Kool Streams](http://koolapp.org/streams.html) to provide a typesafe Camel Integration and Event Processing DSL.
-* [Kool Streams](http://koolapp.org/streams.html) for working with event streams and Complex Event Processing
-* [Kool Templates](http://koolapp.org/templates.html) for creating HTML5 templates for use on the client or server side
-
-If you've not tried Kotlin yet, try the [Getting Started Guide](http://confluence.jetbrains.net/display/Kotlin/Getting+Started) to install the IDE plugin.
View
108 apidoc/pom.xml
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <modelVersion>4.0.0</modelVersion>
- <properties>
- <jetty.version>8.1.2.v20120308</jetty.version>
- </properties>
-
- <parent>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-project</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>apidoc</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-stdlib</artifactId>
- <version>${kotlin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math</artifactId>
- <version>${common-math-version}</version>
- </dependency>
- <dependency>
- <groupId>org.pegdown</groupId>
- <artifactId>pegdown</artifactId>
- <version>${pegdown.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <version>${camel.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kdoc-maven-plugin</artifactId>
- <version>${kotlin.version}</version>
- <configuration>
- <sources>
- <source>${basedir}/../koolapp-camel/src/main/kotlin</source>
- <source>${basedir}/../koolapp-math/src/main/kotlin</source>
- <source>${basedir}/../koolapp-stream/src/main/kotlin</source>
- <source>${basedir}/../koolapp-template/src/main/kotlin</source>
-<!--
- <source>${basedir}/../koolapp-ui/src/main/kotlin</source>
--->
- </sources>
- <title>KoolApp API</title>
- <ignorePackages>
- <ignorePackage>com</ignorePackage>
- <ignorePackage>sun</ignorePackage>
- <ignorePackage>java</ignorePackage>
- <ignorePackage>jet</ignorePackage>
- <ignorePackage>org.p</ignorePackage>
- <ignorePackage>org.w</ignorePackage>
- <ignorePackage>org.slf4j</ignorePackage>
- <ignorePackage>org.xml</ignorePackage>
- <ignorePackage>org.apache</ignorePackage>
- <ignorePackage>org.koolapp.camel.support</ignorePackage>
- <ignorePackage>org.koolapp.stream.beans</ignorePackage>
- <ignorePackage>org.koolapp.stream.support</ignorePackage>
- <ignorePackage>org.koolapp.template.markdown</ignorePackage>
- </ignorePackages>
- <sourceRootHref>https://github.com/koolapp/koolapp/tree/master</sourceRootHref>
- <projectRootDir>${project.basedir}/..</projectRootDir>
- <packageDescriptionFiles>
- <org.koolapp.stream>${project.basedir}/../koolapp-stream/ReadMe.md</org.koolapp.stream>
- <org.koolapp.template.html>${project.basedir}/../koolapp-template/ReadMe.md</org.koolapp.template.html>
- </packageDescriptionFiles>
- <packageSummaryText>
- <org.koolapp.camel>[Kool Camel DSL](http://koolapp.org/camel.html), extensions and integration with [Kool Streams](http://koolapp.org/streams.html)</org.koolapp.camel>
- <org.koolapp.math>Extension functions using [Apache Commons Math](http://commons.apache.org/math/) to easily perform calculations and statistics on collections</org.koolapp.math>
- <org.koolapp.stream>[Kool Streams](http://koolapp.org/streams.html) for working with events and asynchronous collections</org.koolapp.stream> ah lemme check :)
-
- <org.koolapp.template>Text processing helper classes</org.koolapp.template>
- <org.koolapp.template.html>[Kool Templates](http://koolapp.org/templates.html) a HTML5 [template engine](http://koolapp.org/versions/snapshot/apidocs/org/koolapp/template/html/org/w3c/dom/Node-extensions.html)</org.koolapp.template.html>
- </packageSummaryText>
- <packagePrefixToUrls>
- <kotlin>http://jetbrains.github.com/kotlin/versions/snapshot/apidocs/</kotlin>
- <org.apache.camel>http://camel.apache.org/maven/current/camel-core/apidocs/</org.apache.camel>
- <org.apache.commons.math>http://commons.apache.org/math/api-2.2/</org.apache.commons.math>
- </packagePrefixToUrls>
- </configuration>
-
- <executions>
- <execution>
- <id>apidoc</id>
- <phase>install</phase>
- <goals>
- <goal>apidoc</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
View
50 javafx/koolapp-javafx-sample/ReadMe.md
@@ -1,50 +0,0 @@
-## Kool JavaFX
-
-**NOTE** this module requires [Java 7 update 4](http://www.oracle.com/technetwork/java/javase/overview/index.html) or later which ships with JavaFX. If you install Java 7 and use a Mac you might want to run this first...
-
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
- export PATH=$JAVA_HOME/bin:$PATH
-
-You can check you have JavaFX in your JDK install via
-
- ls -l $JAVA_HOME/lib/javafx-mx.jar
-
-which should find the javafx jar.
-
-### Running the sample
-
-To run the sample try...
-
- mvn -Pui
-
-Assuming you've Java 7 enabled and JAVA_HOME points to the JRE/JDK for Java 7 or later.
-
-### Demo code walkthrough
-
-The demo should create a really simple Java application that boots up a browser, loads a local file then dynamically updates the DOM using [Kool Templates](http://koolapp.org/templates.html).
-
-Here's a breakdown of the source code used to implement this:
-
-* [test.koolapp.myapp.MyApp.kt](https://github.com/koolapp/koolapp/blob/master/koolapp-javafx/src/test/kotlin/test/koolapp/myapp/MyApp.kt) the actual application which interacts with the DOM using the standard [kotlin.browser](http://jetbrains.github.com/kotlin/versions/snapshot/apidocs/kotlin/browser/package-summary.html) package.
-* [org.koolapp.javafx.WebApplication](https://github.com/koolapp/koolapp/tree/master/koolapp-javafx/src/main/kotlin/org/koolapp/javafx/WebApplication.kt) : standard KoolApp browser Application
-* [org.koolapp.javafx.namespace](https://github.com/koolapp/koolapp/tree/master/koolapp-javafx/src/main/kotlin/org/koolapp/javafx/Main.kt) : Java main() function launcher for the JavaFX web app
-
-The application code - the [myapp() function](https://github.com/koolapp/koolapp/blob/master/koolapp-javafx/src/test/kotlin/test/koolapp/myapp/MyApp.kt) should be usable when compiled to JavaScript directly. The code in the org.koolapp.javafx package is only required if you want to run the application on a JVM with JavaFX.
-
-### How a KoolApp JavaFX application works
-
-When using your web application in the KoolApp JavaFX browser, you need to bind your Kotlin application code to the web page. This is done by adding a [text/kotlin script tag](https://github.com/koolapp/koolapp/blob/master/koolapp-javafx/src/test/resources/sample.html#L6) or using the WebApplication.ready() function to pass a block when the document is ready.
-
-For example if you add this to a HTML file:
-
- <script type="text/kotlin">
- test.koolapp.myapp.namespace.myApp()
- </script>
-
-when opening in the HTML in the KoolApp JavaFX browser (running the org.koolapp.javafx.namespace class as a Java main() function)
-
- java org.koolapp.javafx.namespace file://foo.html
-
-The browser will startup, load the HTML and then when it sees the text/kotlin script it will invoke your function; once the document has loaded (and the kotlin.browser.document property is updated).
-
-The same Kotlin code should then work if the code is compiled to JavaScript. The only change is required is that the script tag with text/kotlin needs to be replaced with the actual JavaScript file; this could be done dynamically on the server or as part of your build process.
View
109 javafx/koolapp-javafx-sample/pom.xml
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.koolapp</groupId>
- <artifactId>javafx</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>koolapp-javafx-sample</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-javafx</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-template</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit-version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <defaultGoal>install</defaultGoal>
-
- <plugins>
- <plugin>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-maven-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-js-library</artifactId>
- <version>${kotlin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-js-library</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>compile</id>
- <phase>compile</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- <execution>
- <id>js</id>
- <goals>
- <goal>js</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <!-- runs the JavaFX UI -->
- <profile>
- <id>ui</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.7</version>
- <executions>
- <execution>
- <id>run</id>
- <phase>test</phase>
- <configuration>
- <target>
- <java fork="true" classpathref="maven.test.classpath"
- classname="org.koolapp.javafx.namespace">
- <arg value="file://src/main/resources/sample.html"/>
- </java>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
View
25 javafx/koolapp-javafx-sample/sample.html
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Sample</title>
-
- <!-- this is the bootstrap mechanism to initialise our Kotlin application -->
- <script type="text/javascript" src="src/main/js/jquery.js"></script>
- <script type="text/javascript" src="target/js/kotlin-lib.js"></script>
- <script type="text/javascript" src="target/js/koolapp-javafx-sample.js"></script>
-</head>
-<body>
-<h1>Sample</h1>
-
-<p>This example HTML was loaded from a local file!</p>
-
-<div id="view"/>
-
-<p>Should have generated stuff above...</p>
-
-<script type="text/javascript">
- $(document).ready(test.koolapp.myapp.myApp)
-</script>
-
-</body>
-</html>
View
8,981 javafx/koolapp-javafx-sample/src/main/js/jquery.js
0 additions, 8,981 deletions not shown
View
28 javafx/koolapp-javafx-sample/src/main/kotlin/test/koolapp/myapp/MyApp.kt
@@ -1,28 +0,0 @@
-package test.koolapp.myapp
-
-import org.koolapp.template.html.*
-import org.w3c.dom.Document
-import org.w3c.dom.Node
-import kotlin.browser.*
-import kotlin.dom.*
-
-/**
- * Entry point to my application which can be called
- * from a JS browser when its ready, or from JavaFX
- */
-fun myApp() {
- val newNode = sampleTemplate(document)
- println("About to insert DOM node $newNode into document $document")
-
- val container = document.getElementById("view")
- if (container != null) {
- container.appendChild(newNode)
- println("Added new node!!!")
- } else println("Cannot find container!")
-}
-
-fun sampleTemplate(document: Document): Node {
- return document.div {
- h2("Kool Template Generated Content!") {}
- }
-}
View
21 javafx/koolapp-javafx-sample/src/main/resources/sample.html
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Sample</title>
-
- <!-- this is the bootstrap mechanism to initialise our Kotlin application -->
- <script type="text/kotlin">
- test.koolapp.myapp.namespace.myApp()
- </script>
-</head>
-<body>
-<h1>Sample</h1>
-
-<p>This example HTML was loaded from a local file!</p>
-
-<div id="view"/>
-
-<p>Should have generated stuff above...</p>
-
-</body>
-</html>
View
56 javafx/koolapp-javafx/pom.xml
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.koolapp</groupId>
- <artifactId>javafx</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>koolapp-javafx</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-stdlib</artifactId>
- <version>${kotlin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-template</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>javafx</groupId>
- <artifactId>jfxrt</artifactId>
- <version>2.1</version>
- <scope>system</scope>
- <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
- </dependency>
-
-
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit-version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <defaultGoal>install</defaultGoal>
-
- <plugins>
- <plugin>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
View
12 javafx/koolapp-javafx/src/main/kotlin/org/koolapp/javafx/Main.kt
@@ -1,12 +0,0 @@
-package org.koolapp.javafx
-
-import javafx.application.Application
-
-/**
- * A command line application which starts the JavaFX browser and boots up
- * the application defined by the first URL parameter.
- */
-fun main(args: Array<String>): Unit {
- println("Starting KoolApp browser: http://koolapp.org/ - pleasae keep kool!")
- Application.launch(javaClass<WebApplication>(), args.makeString(" "))
-}
View
198 javafx/koolapp-javafx/src/main/kotlin/org/koolapp/javafx/WebApplication.kt
@@ -1,198 +0,0 @@
-package org.koolapp.javafx
-
-import java.io.File
-import javafx.application.Application
-import javafx.beans.value.ChangeListener
-import javafx.beans.value.ObservableValue
-import javafx.concurrent.Worker.State
-import javafx.event.ActionEvent
-import javafx.event.EventHandler
-import javafx.geometry.HPos
-import javafx.geometry.VPos
-import javafx.scene.Scene
-import javafx.scene.control.Button
-import javafx.scene.control.TextField
-import javafx.scene.layout.ColumnConstraints
-import javafx.scene.layout.GridPane
-import javafx.scene.layout.Priority
-import javafx.scene.web.WebEngine
-import javafx.scene.web.WebView
-import javafx.stage.Stage
-import kotlin.browser.*
-import kotlin.dom.*
-import org.w3c.dom.Document
-
-/**
-* An [[Application]] which uses a [[WebView]] and [[WebEngine]]
-*/
-public open class WebApplication(): Application() {
- private var _engine: WebEngine? = null
-
- var engine: WebEngine
- get() = _engine!!
- set(value) {
- _engine = value
- }
-
- var prefWidth = 800.0
- var prefHeight = 600.0
-
- /**
- * Registers a function block to be invoked when the browser is ready and the page has been loaded
- */
- public fun ready(fireOnce: Boolean = false, block: (Document) -> Any?): Unit {
- val changeListener = object : ChangeListener<State?> {
- public override fun changed(observable: ObservableValue<out State?>?, oldValue: State?, newValue: State?) {
- if (newValue != null && newValue == State.SUCCEEDED) {
- val doc = engine.getDocument()
- if (doc != null) {
- block(doc)
- }
- if (fireOnce) {
- engine.getLoadWorker()?.stateProperty()?.removeListener(this)
- }
- }
- }
- }
- engine.getLoadWorker()?.stateProperty()?.addListener(changeListener)
- }
-
- override public fun start(primaryStage: Stage?) {
- val view = WebView()
- engine = view.getEngine()!!
-
- view.setMinSize(100.0, 100.0)
- view.setPrefSize(prefWidth, prefHeight)
- view.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
-
- ready {
- // lets register the global DOM instance
- document = it
- loadKotlinScripts(it)
- }
- val initialLocation = loadInitial()
-
- val locationField = TextField(initialLocation)
- locationField.setMaxHeight(Double.MAX_VALUE)
- val goButton = Button("Go")
- goButton.setDefaultButton(true)
- val goAction = object : EventHandler<ActionEvent?> {
- public override fun handle(event: ActionEvent?) {
- val location = locationField.getText() ?: ""
- if (location.notEmpty()) {
- val fullUrl = if (location.startsWith("http://") || location.contains("://")) location else
- "http://" + location
- load(fullUrl)
- }
- }
- }
- goButton.setOnAction(goAction)
- locationField.setOnAction(goAction)
- val changeListener = object : ChangeListener<String?> {
- public override fun changed(observable: ObservableValue<out String?>?, oldValue: String?, newValue: String?) {
- locationField.setText(newValue)
- }
- }
- engine.locationProperty()?.addListener(changeListener)
- val grid = GridPane()
- grid.setVgap(5.0)
- grid.setHgap(5.0)
- grid.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
- //grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
-
- GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES)
- GridPane.setConstraints(goButton, 1, 0)
- GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS)
-
- val buttonWidth = 40.0
- var gridConstraints = grid.getColumnConstraints()!!
- gridConstraints.add(ColumnConstraints(100.0, prefWidth - (buttonWidth + (2 * grid.getHgap())), Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true))
- gridConstraints.add(ColumnConstraints(buttonWidth, buttonWidth, Double.MAX_VALUE, Priority.SOMETIMES, HPos.CENTER, true))
-
- grid.getChildren()?.addAll(locationField, goButton, view)
-
-
- val scene = Scene(grid)
- val stage = primaryStage!!
- stage.setMaxHeight(Double.MAX_VALUE)
- stage.setMaxWidth(Double.MAX_VALUE)
- stage.setHeight(prefHeight + buttonWidth + (2 * grid.getVgap()))
- stage.setWidth(prefWidth)
- stage.setScene(scene)
- stage.show()
- }
-
- /**
- * Strategy method to load the initial URL and returning the URL
- * so it can be populated into the address bar
- */
- protected open fun loadInitial(): String {
- val parameters = getParameters()!!
- val unnamed = parameters.getUnnamed()!!
- val raw = parameters.getRaw()!!
- val url = if (unnamed.notEmpty()) {
- unnamed.first()!!
- } else if (raw.notEmpty()) {
- raw.first()!!
- } else {
- "http://koolapp.org/"
- }
- return load(url)
- }
-
- /**
- * Loads the given URL
- */
- fun load(val url: String): String {
- val filePrefix = "file://"
- if (url.startsWith(filePrefix)) {
- val fileName = url.trimLeading(filePrefix)
- println("Loading file: " + fileName)
- val content = File(fileName).readText()
- engine.loadContent(content)
- } else {
- println("Loading URL: " + url)
- engine.load(url)
- }
- return url
- }
-
- /**
- * Attempts to find any &lt;script&gt; tags for the type *text/kotlin* and invokes the methods
- */
- protected fun loadKotlinScripts(document: Document): Unit {
- val scriptTags = document["script"]
- for (scriptTag in scriptTags) {
- val t = scriptTag.attribute("type")
- if (t == "text/kotlin") {
- val text = scriptTag.text.trim()
- val lines = text.split("\n")
- for (line in lines) {
- val initCall = line.trim().trimTrailing("()")
- if (initCall.notEmpty()) {
- val idx = initCall.lastIndexOf('.')
- if (idx <= 0) {
- println("Warning cannot invoke initCall which is not on a class $initCall")
- } else {
- try {
- val className = initCall.substring(0, idx)
- val methodName = initCall.substring(idx + 1)
- val klass = loadClass<Any>(className)
- val method = klass.getMethod(methodName)!!
- method.invoke(null)
- } catch (e: Exception) {
- println("Failed to invoke startup method: " + initCall + ". Reason: " + e)
- e.printStackTrace()
- }
- }
- }
- }
- }
- }
- }
-
- protected fun <T> loadClass(className: String): Class<T> {
- return Class.forName(className) as Class<T>
- }
-}
-
View
22 javafx/pom.xml
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-project</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>javafx</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>koolapp-javafx</module>
- <module>koolapp-javafx-sample</module>
- </modules>
-
-</project>
View
37 koolapp-camel/ReadMe.md
@@ -1,37 +0,0 @@
-## Kool Camel
-
-**Kool Camel** provides a [kotlin](http://jetbrains.github.com/kotlin/) based DSL for [Apache Camel](http://camel.apache.org/) which is a powerful extension to the Java DSL with Kool Expressions together with adding integration with [Kool Streams](http://koolapp.org/streams.html) to provide a typesafe Camel Integration and Event Processing DSL.
-
-### Kool Expressions
-
-The power of the Kool Camel DSL comes from the use of Kool Expressions. These are anonymous function blocks
-used wherever you can use Camel Expression in the Java DSL. The function blocks take an implicit Camel [Exchange](http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html) object which lets you immediately refer to any of the existing [exchange methods](http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html) together with the [extension methods on Exchange](http://koolapp.org/versions/snapshot/apidocs/org/koolapp/camel/org/apache/camel/Exchange-extensions.html) without requiring extra noise like a '_' expression in Scala, an 'it' variable in Groovy or a named parameter declaration and variable in Java 8 lambdas which keeps the DSL nice and DRY.
-
-For example you can refer to the **input** property to get the inbound [Message](http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Message.html) or **out** for the outbound message and refer to headers or properties using the [subscript operators](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/TransformAndSetHeaderTest.kt#L14)
-
-
-### Kool Camel DSL examples
-
-Here are various example patterns using the Kool Camel DSL to show you how DRY it is while still being very easy to read (even if you've never used kotlin before) and how Kool Expressions are integrated into the entire Java DSL:
-
-* [message filter](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/FilterThenTest.kt#L12)
-* [content based router](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/ChoiceTest.kt#L15)
-* [message translator](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/TransformTest.kt#L12)
-* [message translator and setting headers in the same block](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/TransformAndSetHeaderTest.kt#L12)
-* [recipient list](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/RecipientListTest.kt#L9)
-* [process block](https://github.com/koolapp/koolapp/blob/master/koolapp-camel/src/test/kotlin/test/koolapp/camel/ProcessTest.kt#L12)
-
-### Camel and Kool Streams
-
-Kool Camel allows you to turn any Camel [Endpoint](http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html) into a <a href="http://koolapp.org/versions/snapshot/apidocs/org/koolapp/stream/Stream.html">Stream&lt;T&gt;</a> using a number of [helper methods on the Camel Endpoint](http://koolapp.org/versions/snapshot/apidocs/org/koolapp/camel/org/apache/camel/Endpoint-extensions.html) class. Once you have a typesafe Stream\<T\> you can then compose event processing steps (filtering, transforming, grouping, buffering, windowing, merging, correlating etc) with [Kool Streams](http://koolapp.org/streams.html) to perform powerful complex event processing.
-
-On the flip side, you can easily send events on a [Kool Stream](http://koolapp.org/streams.html) to any Camel [Endpoint](http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html) using the <a href="http://koolapp.org/versions/snapshot/apidocs/org/koolapp/camel/org/koolapp/stream/Stream-extensions.html#to(org.apache.camel.Endpoint)">to(Endpoint)</a> extension method.
-
-This allows us to easily compose any [Kool Streams](http://koolapp.org/streams.html) and Camel Endpoints and Routes together to combine powerful integration and complex event processing capabilities into a single simple type safe DSL that works directly on your domain model and generates fast statically typed java bytecode without the need for reflection or dynamic invocation.
-
-While the Kool Camel and Stream DSLs are Kotlin based; they obviously can easily work with any JVM code for domain models, functions and services; so its easy to reuse Kool Camel routes and Streams from Java, Scala, Groovy, JavaScript, JRuby in addition to the Kotlin language.
-
-### IDE support
-
-If you've not tried Kotlin yet, try the [Getting Started Guide](http://confluence.jetbrains.net/display/Kotlin/Getting+Started) to install the IDE plugin.
-
View
53 koolapp-camel/pom.xml
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-project</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>koolapp-camel</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.koolapp</groupId>
- <artifactId>koolapp-stream</artifactId>
- <version>${project.version}</version>
- </dependency>
-<!--
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-stdlib</artifactId>
- <version>${kotlin.version}</version>
- </dependency>
--->
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <version>${camel.version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit-version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
View
115 koolapp-camel/src/main/kotlin/org/koolapp/camel/CamelContexts.kt
@@ -1,115 +0,0 @@
-package org.koolapp.camel
-
-import org.koolapp.stream.*
-import org.koolapp.stream.support.*
-import org.koolapp.camel.support.*
-import org.apache.camel.CamelContext
-import org.apache.camel.Endpoint
-import org.apache.camel.util.CamelContextHelper
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.Exchange
-import org.apache.camel.Message
-import org.apache.camel.model.ModelCamelContext
-import org.apache.camel.model.RouteDefinition
-import org.apache.camel.model.RoutesDefinition
-import org.apache.camel.component.mock.MockEndpoint
-import org.apache.camel.ProducerTemplate
-import org.apache.camel.ConsumerTemplate
-
-/**
- * Helper method to create a new [[ModelCamelContext]]
- */
-inline fun <T> camel(useBlock: ModelCamelContext.() -> T): T {
- val context = createCamelContext()
- return context.use(useBlock)
-}
-
-/**
- * Helper method to create a new [[ModelCamelContext]]
- */
-inline fun createCamelContext(): ModelCamelContext {
- return DefaultCamelContext()
-}
-
-/**
- * Looks up the given endpoint in the [[CamelContext]] throwing an exception if its not available
- */
-inline fun CamelContext.endpoint(uri: String): Endpoint = CamelContextHelper.getMandatoryEndpoint(this, uri)!!
-
-// TODO if http://youtrack.jetbrains.com/issue/KT-1751 is resolved we can omit the
-// verbose klass parameter
-
-/**
- * Looks up the given endpoint of type T in the [[CamelContext]] throwing an exception if its not available
- */
-inline fun <T: Endpoint> CamelContext.endpoint(uri: String, klass: Class<T>): T = CamelContextHelper.getMandatoryEndpoint(this, uri, klass)!!
-
-/**
- * Looks up the given [[MockEndpoint]] in the [[CamelContext]] throwing an exception if its not available
- */
-inline fun CamelContext.mockEndpoint(uri: String): MockEndpoint = CamelContextHelper.getMandatoryEndpoint(this, uri, javaClass<MockEndpoint>())!!
-
-/**
- * Creates a [[ProducerTemplate]] on this context
- */
-inline fun CamelContext.producerTemplate(): ProducerTemplate = createProducerTemplate()!!
-
-/**
- * Creates a [[ProducerTemplate]] on this context
- */
-inline fun CamelContext.consumerTemplate(): ConsumerTemplate = createConsumerTemplate()!!
-
-/**
- * Starts the given [[CamelContext]], processes the block and then stops it at the end
- */
-inline fun <T> ModelCamelContext.use(block: ModelCamelContext.() -> T): T {
- var closed = false
- try {
- this.start()
- return this.block()
- } catch (e: Exception) {
- closed = true
- try {
- this.stop()
- } catch (closeException: Exception) {
- // eat the closeException as we are already throwing the original cause
- // and we don't want to mask the real exception
-
- // TODO on Java 7 we should call
- // e.addSuppressed(closeException)
- // to work like try-with-resources
- // http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html#suppressed-exceptions
- }
- throw e
- } finally {
- if (!closed) {
- this.stop()
- }
- }
-}
-
-
-/**
- * A builder to add some route builders to the [[ModelCamelContext]]
- */
-inline fun CamelContext.routes(init: RoutesDefinition.() -> Any): RoutesDefinition {
- val definition = RoutesDefinition()
- definition.init()
- addRouteDefinitions(definition.getRoutes())
- return definition
-}
-
-/**
- * A builder to add some route builders to the [[ModelCamelContext]]
- */
-/*
-//inline fun ModelCamelContext.routes(init: RoutesDefinition.() -> Any): RoutesDefinition {
-inline fun CamelContext.route(init: CamelBuilder.() -> Any): RouteDefinition {
- val definition = RoutesDefinition()
- val route = definition.route()!!
- val builder = CamelBuilder(route)
- builder.init()
- addRouteDefinitions(definition.getRoutes())
- return route
-}
-*/
View
57 koolapp-camel/src/main/kotlin/org/koolapp/camel/Endpoints.kt
@@ -1,57 +0,0 @@
-package org.koolapp.camel
-
-import org.koolapp.stream.*
-import org.koolapp.stream.support.*
-import org.koolapp.camel.support.*
-import org.apache.camel.CamelContext
-import org.apache.camel.Endpoint
-import org.apache.camel.util.CamelContextHelper
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.Exchange
-import org.apache.camel.Message
-
-/**
- * Creates a stream of [[Message]] objects by consuming from the given [[Endpoint]] URI
- */
-inline fun Endpoint.toStream(): Stream<Message> {
- return toStream{ it.getIn()!! }
-}
-
-/**
- * Creates a stream of events by consuming messages from the given [[Endpoint]] URI and applying the given function on each Exchange
- */
-inline fun <T> Endpoint.toStream(fn: (Exchange) -> T): Stream<T> {
- return EndpointStream(this, fn)
-}
-
-/**
- * Creates a stream of [[Exchange]] objects by consuming from the given [[Endpoint]] URI
- */
-inline fun Endpoint.toExchangeStream(): Stream<Exchange> {
- return toStream{ it }
-}
-
-/**
- * Creates a stream of events by consuming messages from the given [[Endpoint]] of the given type
- */
-// TODO is there a way to avoid explicit passing in of the class?
-inline fun <T> Endpoint.toStreamOf(klass: Class<T>): Stream<T> {
- return if (klass.isAssignableFrom(javaClass<Exchange>())) {
- EndpointStream(this) {
- it as T
- }
- } else {
- EndpointStream(this) {
- it.getIn<T>(klass) as T
- }
- }
-}
-
-/**
- * Sends events on a [[Stream]] to an endpoint
- */
-inline fun <T> Stream<T>.sendTo(endpoint: Endpoint): Cursor {
- val producer = endpoint.createProducer()!!
- val handler = ProducerHandler<T>(producer)
- return open(handler)
-}
View
192 koolapp-camel/src/main/kotlin/org/koolapp/camel/Exchanges.kt
@@ -1,192 +0,0 @@
-package org.koolapp.camel
-
-import org.apache.camel.Exchange
-import org.apache.camel.Message
-import org.apache.camel.util.ExchangeHelper
-import org.apache.camel.CamelContext
-
-/**
-* Returns the in message body
-*/
-inline fun Exchange.body(): Any? {
- val message = this.getIn()
- return message?.getBody()
-}
-
-// TODO if http://youtrack.jetbrains.com/issue/KT-1751 is resolved we can omit the
-// verbose klass parameter
-
-/**
- * Returns the in message body of the given type
- */
-inline fun <T> Exchange.body(klass: Class<T>): T? {
- val message = this.getIn()
- return message?.getBody<T>(klass)
-}
-
-// TODO in is a reserved word in kotlinso we can't use it as the property
-var Exchange.input: Message
- get() = getIn()!!
- set(value) {
- setIn(value)
- }
-
-var Exchange.out: Message
- get() = getOut()!!
- set(value) {
- setOut(value)
- }
-
-/**
- * Returns the result message which is either the input or out message based on the exchange pattern
- */
-val Exchange.result: Message
- get() = ExchangeHelper.getResultMessage(this)!!
-
-/**
- * Returns the request IN [[Message]]
- */
-val Exchange.request: Message
- get() = getIn()!!
-
-/**
- * Returns the response OUT [[Message]]
- */
-val Exchange.response: Message
- get() = getOut()!!
-
-/**
- * Returns true if the given exchange pattern (if defined) can support OUT messages
- */
-val Exchange.outCapable: Boolean
- get() = ExchangeHelper.isOutCapable(this)
-
-/**
- * Returns true if the unit of work is exhausted
- */
-val Exchange.unitOfWorkExhausted: Boolean
- get() = ExchangeHelper.isUnitOfWorkExhausted(this)
-
-/**
- * Returns true if the message has been redelivered
- */
-val Exchange.redelivered: Boolean
- get() = ExchangeHelper.isRedelivered(this)
-
-
-/**
- * Returns true if the redelivery has been exhausted
- */
-val Exchange.redeliveryExhausted: Boolean
- get() = ExchangeHelper.isRedeliveryExhausted(this)
-
-/**
- * Returns true if the exchange has been interrupted
- */
-val Exchange.interrupted: Boolean
- get() = ExchangeHelper.isInterrupted(this)
-
-
-/**
- * Returns true if the exchange has a fault message
- */
-val Exchange.hasFaultMessage: Boolean
- get() = ExchangeHelper.hasFaultMessage(this)
-
-/**
- * Returns true if the exception has been handled by an error handler
- */
-val Exchange.hasExceptionBeenHandledByErrorHandler: Boolean
- get() = ExchangeHelper.hasExceptionBeenHandledByErrorHandler(this)
-
-/**
- * Returns true if the failure has been handled
- */
-var Exchange.failureHanded: Boolean
- get() = ExchangeHelper.isFailureHandled(this)
- set(value) {
- setProperty(Exchange.FAILURE_HANDLED, value)
- if (value) {
- // clear exception since its failure handled
- setException(null)
- }
- }
-
-/**
- * Returns the [[CamelContext]]
- */
-val Exchange.context: CamelContext
- get() = this.getContext()!!
-
-/**
- * Returns the MIME content type on the input message or null if one is not defined
- */
-val Exchange.contentType: String?
- get() = ExchangeHelper.getContentType(this)
-
-/**
- * Returns the MIME content encoding on the input message or null if one is not defined
- */
-val Exchange.contentEncoding: String?
- get() = ExchangeHelper.getContentEncoding(this)
-
-/**
- * Returns the input message body as a String using the empty string if its null
- */
-inline fun Exchange.bodyString(nullValue: String = ""): String = body<String>(javaClass<String>()) ?: nullValue
-
-/**
- * Provides array style access to properties on the exchange
- */
-inline fun Exchange.get(propertyName: String): Any? = getProperty(propertyName)
-
-/**
- * Provides array style access to properties on the exchange
- */
-inline fun Exchange.set(propertyName: String, value: Any?): Unit = setProperty(propertyName, value)
-
-/**
- * Creates a copy of this exchange, optionally preserving the exchange id
- */
-inline fun <T> Exchange.copy(preserveExchangeId: Boolean = false): Exchange = ExchangeHelper.createCopy(this, preserveExchangeId)!!
-
-/**
- * Copies the results from the given *source* to this exchange
- */
-inline fun <T> Exchange.copyResultsFrom(source: Exchange): Unit {
- ExchangeHelper.copyResults(this, source)
-}
-
-/**
- * Copies the results from the given *source* to this exchange, preserving the pattern
- */
-inline fun <T> Exchange.copyResultsPreservePatternFrom(source: Exchange): Unit {
- ExchangeHelper.copyResultsPreservePattern(this, source)
-}
-
-/**
- * Converts the given value to the given type using the current type conversion registry for the camel context
- * returning null if the conversion could not be completed
- */
-inline fun <T> Exchange.convertToType(value: Any, klass: Class<T>): T? = ExchangeHelper.convertToType(this, klass, value)
-
-/**
- * Converts the given value to the given type using the current type conversion registry for the camel context
- * throwing an exception if it could not be converted
- */
-inline fun <T> Exchange.requireConvertToType(value: Any, klass: Class<T>): T = ExchangeHelper.convertToMandatoryType(this, klass, value)!!
-
-/**
- * Creates a new instance of the given type from the injector
- */
-inline fun <T> Exchange.newInstance(klass: Class<T>): T = ExchangeHelper.newInstance(this, klass)!!
-
-/**
- * Performs a lookup in the registry of the bean name
- */
-inline fun <T> Exchange.lookupBean(name: String, klass: Class<T>): T? = ExchangeHelper.lookupBean(this, name, klass)
-
-/**
- * Performs a lookup in the registry of the bean name
- */
-inline fun Exchange.lookupBean(name: String): Any? = ExchangeHelper.lookupBean(this, name)
View
29 koolapp-camel/src/main/kotlin/org/koolapp/camel/Messages.kt
@@ -1,29 +0,0 @@
-package org.koolapp.camel
-
-import org.apache.camel.Exchange
-import org.apache.camel.Message
-import java.util.Map
-
-var Message.body: Any?
- get() = getBody()
- set(value) {
- setBody(value)
- }
-
-var Message.headers: Map<String?, Any?>
- get() = getHeaders().orEmpty()
- set(value) {
- setHeaders(value)
- }
-
-
-/**
- * Provides array style access to headers on the message
- */
-inline fun Message.get(headerName: String): Any? = getHeader(headerName)
-
-/**
- * Provides array style access to headers on the message
- */
-inline fun Message.set(headerName: String, value: Any?): Unit = setHeader(headerName, value)
-
View
459 koolapp-camel/src/main/kotlin/org/koolapp/camel/RoutesDefinitions.kt
@@ -1,459 +0,0 @@
-package org.koolapp.camel
-
-import java.util.List
-import org.apache.camel.Endpoint
-import org.apache.camel.Exchange
-import org.apache.camel.model.*
-import org.apache.camel.spi.IdempotentRepository
-import org.koolapp.camel.support.*
-import org.apache.camel.processor.aggregate.AggregationStrategy
-import java.util.Comparator
-
-/**
-* A builder API to help create a new [[RouteDefinition]] on a [[CamelContext]]
-* using Camel's Java DSL
-*/
-inline fun RoutesDefinition.route(init: RouteDefinition.() -> Any): RouteDefinition {
- val definition = this.route()!!
- definition.init()
- return definition
-}
-
-/**
- * A builder API to help create a new [[RouteDefinition]] on a [[CamelContext]]
- * using Camel's Java DSL
- */
-inline fun RoutesDefinition.from(uri: String, init: RouteDefinition.() -> Any): RouteDefinition {
- val definition = this.route()!!
- definition.from(uri)
- definition.init()
- return definition
-}
-
-
-/**
- * Sends the message to the given URI
- */
-inline fun <T: ProcessorDefinition<T>> T.sendTo(uri: String): T {
- return this.to(uri)!!
-}
-
-/**
- * Sends the message to the given endpoint
- */
-inline fun <T: ProcessorDefinition<T>> T.sendTo(endpoint: Endpoint): T {
- return this.to(endpoint)!!
-}
-
-// TODO the sendTo methods on FilterDefinition should not really be required
-// they are workarounds from compiler glitches
-
-/**
- * Sends the message to the given URI
- */
-inline fun FilterDefinition.sendTo(uri: String): FilterDefinition {
- to(uri)
- return this
-}
-
-/**
- * Sends the message to the given endpoint
- */
-inline fun FilterDefinition.sendTo(endpoint: Endpoint): FilterDefinition {
- to(endpoint)
- return this
-}
-/**
- * Performs a filter using the function block as the predicate
- */
-inline fun <T: ProcessorDefinition<T>> T.filter(predicate: Exchange.() -> Boolean, block: FilterDefinition.() -> Any): T {
- val predicateInstance = PredicateFunction(predicate)
- val filterBlock: FilterDefinition = filter(predicateInstance)!!
- filterBlock.block()
- return this
-}
-
-/**
- * Performs a filter using the function block as the predicate, then calling *then* on the result object will
- * pass the action block.
- */
-inline fun <T: ProcessorDefinition<T>> T.filter(predicate: Exchange.() -> Boolean): ThenDefinition<T> {
- val predicateInstance = PredicateFunction(predicate)
- val filterBlock = filter(predicateInstance)!!
- return ThenDefinition<T>(filterBlock)
-}
-
-/**
- * Performs a content based router
- */
-inline fun <T: ProcessorDefinition<T>> T.choice(block: ChoiceDefinition.() -> Any?): T {
- val choiceBlock = choice()!!
- choiceBlock.block()
- return this
-}
-
-/**
- * Evaluates the nested body if this predicate matches
- */
-inline fun ChoiceDefinition.filter(predicate: Exchange.() -> Boolean): ThenDefinition<ChoiceDefinition> {
- val predicateInstance = PredicateFunction(predicate)
- this.`when`(predicateInstance)
-
- // lets get the last when output
- val outputs: List<Any> = this.getOutputs()!! as List<Any>
- val whenDefinition = outputs.last
- if (whenDefinition is WhenDefinition) {
- return ThenDefinition<ChoiceDefinition>(whenDefinition)
- } else {
- throw IllegalStateException("Could not find WhenDefinition in ChoiceDefinition, found " + whenDefinition)
- }
-}
-
-/**
- * Adds an otherwise section
- */
-inline fun ChoiceDefinition.otherwise(block: ChoiceDefinition.() -> Any?): ChoiceDefinition {
- this.otherwise()
- this.block()
- end()
-
- // TODO should we be returning the parent node?
- return this
-}
-
-
-/**
- * Processes the exchange using a function block
- */
-inline fun <T: ProcessorDefinition<T>> T.process(block: Exchange.() -> Unit): T {
- val processor = FunctionProcessor(block)
- this.process(processor)
- return this
-}
-
-
-/**
- * Transforms the message, setting the output body to the result of the function block
- */
-inline fun <T: ProcessorDefinition<T>> T.transform(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.transform(expression)
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/idempotent-consumer.html">Idempotent consumer EIP:</a>
- * Creates an {@link org.apache.camel.processor.idempotent.IdempotentConsumer IdempotentConsumer}
- * to avoid duplicate messages
- */
-inline fun <T: ProcessorDefinition<T>> T.idempotentConsumer(block: Exchange.() -> Any?): IdempotentConsumerDefinition {
- val expression = FunctionExpression(block)
- return this.idempotentConsumer(expression)!!
-}
-
-
-/**
- * <a href="http://camel.apache.org/idempotent-consumer.html">Idempotent consumer EIP:</a>
- * Creates an {@link org.apache.camel.processor.idempotent.IdempotentConsumer IdempotentConsumer}
- * to avoid duplicate messages
- *
- * @param messageIdExpression expression to test of duplicate messages
- * @param idempotentRepository the repository to use for duplicate check
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.idempotentConsumer(idempotentRepository: IdempotentRepository<*>, block: Exchange.() -> Any?): IdempotentConsumerDefinition {
- val expression = FunctionExpression(block)
- return this.idempotentConsumer(expression, idempotentRepository)!!
-}
-
-
-/**
- * Creates a validation expression which only if it is <tt>true</tt> then the
- * exchange is forwarded to the destination.
- * Otherwise a {@link org.apache.camel.processor.validation.PredicateValidationException} is thrown.
- *
- * @param expression the expression
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.idempotentConsumer(block: Exchange.() -> Any?): ValidateDefinition {
- val expression = FunctionExpression(block)
- return this.validate(expression)!!
-}
-
-/**
- * <a href="http://camel.apache.org/recipient-list.html">Recipient List EIP:</a>
- * Creates a dynamic recipient list allowing you to route messages to a number of dynamically specified recipients
- *
- * @param recipients expression to decide the destinations
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.recipientList(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.recipientList(expression)!!
- // TODO should we return RecipientListDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/recipient-list.html">Recipient List EIP:</a>
- * Creates a dynamic recipient list allowing you to route messages to a number of dynamically specified recipients
- *
- * @param recipients expression to decide the destinations
- * @param delimiter a custom delimiter to use
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.recipientList(delimiter: String, block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.recipientList(expression, delimiter)!!
- // TODO should we return RecipientListDefinition
- return this
-}
-
-
-/**
- * <a href="http://camel.apache.org/routing-slip.html">Routing Slip EIP:</a>
- * Creates a routing slip allowing you to route a message consecutively through a series of processing
- * steps where the sequence of steps is not known at design time and can vary for each message.
- * <p/>
- * The route slip will be evaluated <i>once</i>, use {@link #dynamicRouter()} if you need even more dynamic routing.
- *
- * @param expression to decide the destinations
- * @param uriDelimiter is the delimiter that will be used to split up
- * the list of URIs in the routing slip.
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.routingSlip(uriDelimiter: String, block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.routingSlip(expression, uriDelimiter)!!
- // TODO should we return RoutingSlipDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/routing-slip.html">Routing Slip EIP:</a>
- * Creates a routing slip allowing you to route a message consecutively through a series of processing
- * steps where the sequence of steps is not known at design time and can vary for each message.
- * <p/>
- * The list of URIs will be split based on the default delimiter {@link RoutingSlipDefinition#DEFAULT_DELIMITER}
- * <p/>
- * The route slip will be evaluated <i>once</i>, use {@link #dynamicRouter()} if you need even more dynamic routing.
- *
- * @param expression to decide the destinations
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.routingSlip(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.routingSlip(expression)!!
- // TODO should we return RoutingSlipDefinition
- return this
-}
-
-
-/**
- * <a href="http://camel.apache.org/dynamic-router.html">Dynamic Router EIP:</a>
- * Creates a dynamic router allowing you to route a message consecutively through a series of processing
- * steps where the sequence of steps is not known at design time and can vary for each message.
- * <p/>
- * <br/><b>Important:</b> The expression will be invoked repeatedly until it returns <tt>null</tt>, so be sure it does that,
- * otherwise it will be invoked endlessly.
- *
- * @param expression to decide the destinations, which will be invoked repeatedly
- * until it evaluates <tt>null</tt> to indicate no more destinations.
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.dynamicRouter(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.dynamicRouter(expression)!!
- // TODO should we return DynamicRouterDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/splitter.html">Splitter EIP:</a>
- * Creates a splitter allowing you split a message into a number of pieces and process them individually.
- * <p>
- * This splitter responds with the original input message. You can use a custom {@link AggregationStrategy} to
- * control what to respond from the splitter.
- *
- * @param block the expression on which to split the message
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.split(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.split(expression)!!
- // TODO should we return SplitDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/splitter.html">Splitter EIP:</a>
- * Creates a splitter allowing you split a message into a number of pieces and process them individually.
- * <p>
- * The splitter responds with the answer produced by the given {@link AggregationStrategy}.
- *
- * @param expression the expression on which to split
- * @param aggregationStrategy the strategy used to aggregate responses for every part
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.split(aggregationStrategy: AggregationStrategy, block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.split(expression, aggregationStrategy)!!
- // TODO should we return SplitDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/resequencer.html">Resequencer EIP:</a>
- * Creates a resequencer allowing you to reorganize messages based on some comparator.
- *
- * @param expression the expression on which to compare messages in order
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.resequence(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.resequence(expression)!!
- // TODO should we return ResequenceDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/aggregator.html">Aggregator EIP:</a>
- * Creates an aggregator allowing you to combine a number of messages together into a single message.
- *
- * @param correlationExpression the expression used to calculate the
- * correlation key. For a JMS message this could be the
- * expression <code>header("JMSDestination")</code> or
- * <code>header("JMSCorrelationID")</code>
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.aggregate(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.aggregate(expression)!!
- // TODO should we return AggregateDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/aggregator.html">Aggregator EIP:</a>
- * Creates an aggregator allowing you to combine a number of messages together into a single message.
- *
- * @param correlationExpression the expression used to calculate the
- * correlation key. For a JMS message this could be the
- * expression <code>header("JMSDestination")</code> or
- * <code>header("JMSCorrelationID")</code>
- * @param aggregationStrategy the strategy used for the aggregation
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.aggregate(aggregationStrategy: AggregationStrategy, block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.aggregate(expression, aggregationStrategy)!!
- // TODO should we return AggregateDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/delayer.html">Delayer EIP:</a>
- * Creates a delayer allowing you to delay the delivery of messages to some destination.
- *
- * @param delay an expression to calculate the delay time in millis
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.delay(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.delay(expression)!!
- // TODO should we return DelayDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/throttler.html">Throttler EIP:</a>
- * Creates a throttler allowing you to ensure that a specific endpoint does not get overloaded,
- * or that we don't exceed an agreed SLA with some external service.
- * <p/>
- * Will default use a time period of 1 second, so setting the maximumRequestCount to eg 10
- * will default ensure at most 10 messages per second.
- *
- * @param maximumRequestCount an expression to calculate the maximum request count
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.throttle(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.throttle(expression)!!
- // TODO should we return ThrottleDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/loop.html">Loop EIP:</a>
- * Creates a loop allowing to process the a message a number of times and possibly process them
- * in a different way. Useful mostly for testing.
- *
- * @param expression the loop expression
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.loop(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.loop(expression)!!
- // TODO should we return LoopDefinition
- return this
-}
-
-/**
- * <a href="http://camel.apache.org/message-translator.html">Message Translator EIP:</a>
- * Adds a processor which sets the body on the IN message
- *
- * @param expression the expression used to set the body
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.setBody(block: Exchange.() -> Any?): T = transform(block)
-
-/**
- * Adds a processor which sets the body on the FAULT message
- *
- * @param expression the expression used to set the body
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.setFaultBody(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.setFaultBody(expression)!!
- return this
-}
-
-/**
- * Adds a processor which sets the header on the IN message
- *
- * @param name the header name
- * @param expression the expression used to set the header
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.setHeader(name: String, block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.setHeader(name, expression)!!
- return this
-}
-
-
-/**
- * Sorts the expression using a default sorting based on toString representation.
- *
- * @param expression the expression, must be convertable to {@link List}
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.sort(block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.sort(expression)!!
- return this
-}
-
-/**
- * Sorts the expression using the given comparator
- *
- * @param expression the expression, must be convertable to {@link List}
- * @param comparator the comparator to use for sorting
- * @return the builder
- */
-inline fun <T: ProcessorDefinition<T>> T.sort(comparator: Comparator<*>, block: Exchange.() -> Any?): T {
- val expression = FunctionExpression(block)
- this.sort(expression, comparator)!!
- return this
-}
View
82 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/EndpointStream.kt
@@ -1,82 +0,0 @@
-package org.koolapp.camel.support
-
-import org.apache.camel.Consumer
-import org.apache.camel.Endpoint
-import org.apache.camel.Exchange
-import org.apache.camel.Processor as ExchangeProcessor
-import org.koolapp.stream.Cursor
-import org.koolapp.stream.Handler
-import org.koolapp.stream.Stream
-import org.koolapp.stream.support.*
-import org.apache.camel.Producer
-
-/**
- * A [[Stream]] which consumes messages on a Camel [[Endpoint]]
- */
-public class EndpointStream<T>(val endpoint: Endpoint,val fn: (Exchange) -> T): Stream<T>() {
- public fun toString(): String = "EndpointStream($endpoint)"
-
- public override fun open(handler: Handler<T>): Cursor {
- val processor = HandlerProcessor(handler, fn)
- val consumer = endpoint.createConsumer(processor)!!
- val cursor = ConsumerCursor(consumer, handler)
- handler.onOpen(cursor)
- consumer.start()
- return cursor
- }
-}
-
-public class HandlerProcessor<T>(val handler: Handler<T>, val fn: (Exchange) -> T): ExchangeProcessor {
- public override fun toString() = "HandlerProcessor($handler)"
-
- public override fun process(exchange: Exchange?): Unit {
- if (exchange != null) {
- val message = (fn)(exchange)
- if (message != null) {
- handler.onNext(message)
- }
-
- }
- }
-}
-
-/**
- * Represents a [[Cursor]] on a Camel [[Consumer]]
- *
- * The consumer is registered after this object is constructed
- * so that we can pass the cursor into the [[Handler]]'s Open before
- * the consumer is created to avoid it arriving after a Next
- */
-public class ConsumerCursor(val consumer: Consumer, val handler: Handler<*>): AbstractCursor() {
- public override fun toString() = "ConsumerCursor($consumer, $handler)"
-
- public override fun doClose() {
- consumer.stop()
- handler.onComplete()
- }
-}
-
-/**
- * A [[Handler]] implementation which sends messages to a Camel [[Producer]]
- */
-public class ProducerHandler<T>(val producer: Producer) : AbstractHandler<T>() {
- public override fun toString() = "EndpointProducerHandler($producer)"
-
- public override fun onOpen(cursor: Cursor) {
- super.onOpen(cursor)
- producer.start()
- }
-
- public override fun onNext(next: T) {
- val exchange = producer.createExchange()!!
- val message = exchange.getIn()!!
- message.setBody(next)
- producer.process(exchange)
- }
-
- // TODO compiler bug this should be protected!!!
- public override fun doClose() {
- super.doClose()
- producer.stop()
- }
-}
View
25 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/FunctionExpression.kt
@@ -1,25 +0,0 @@
-package org.koolapp.camel.support
-
-import org.apache.camel.model.ExpressionNode
-import org.apache.camel.model.ProcessorDefinition
-import org.apache.camel.Exchange
-import org.apache.camel.Processor
-import org.apache.camel.Expression
-import org.apache.camel.util.ExchangeHelper
-
-/**
- * Implements [[Expression]] using a function block
- */
-public class FunctionExpression(val block: Exchange.() -> Any?) : Expression {
-
- public override fun toString(): String? {
- return "FunctionExpression($block)"
- }
-
- public override fun <T> evaluate(exchange: Exchange?, klass: Class<T>?): T? {
- if (exchange != null) {
- val result = exchange.block()
- return ExchangeHelper.convertToMandatoryType(exchange, klass, result)
- } else return null
- }
-}
View
22 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/FunctionProcessor.kt
@@ -1,22 +0,0 @@
-package org.koolapp.camel.support
-
-import org.apache.camel.model.ExpressionNode
-import org.apache.camel.model.ProcessorDefinition
-import org.apache.camel.Exchange
-import org.apache.camel.Processor
-
-/**
- * Implements [[Processor]] using a function block
- */
-public class FunctionProcessor(val block: Exchange.() -> Unit) : Processor {
-
- public override fun toString(): String? {
- return "FunctionProcessor($block)"
- }
-
- public override fun process(exchange: Exchange?) {
- if (exchange != null) {
- exchange.block()
- }
- }
-}
View
21 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/PredicateFunction.kt
@@ -1,21 +0,0 @@
-package org.koolapp.camel.support
-
-import org.apache.camel.Predicate
-import org.apache.camel.Exchange
-
-/**
- * An implementation of [[Predicate]] which takes a function
- */
-public class PredicateFunction(val fn: Exchange.() -> Boolean): Predicate {
-//public class PredicateFunction(val fn: (Exchange) -> Boolean): Predicate {
- public override fun matches(exchange: Exchange?): Boolean {
- return if (exchange != null) {
- exchange.fn()
- //fn(exchange)
- } else false
- }
-
- public override fun toString(): String {
- return "PredicateFunction($fn)"
- }
-}
View
15 koolapp-camel/src/main/kotlin/org/koolapp/camel/support/ThenDefinition.kt
@@ -1,15 +0,0 @@
-package org.koolapp.camel.support
-
-import org.apache.camel.model.ExpressionNode
-import org.apache.camel.model.ProcessorDefinition
-
-/**
- * Supports the *then* syntax in the DSL to chain predicates and action blocks
- */
-public class ThenDefinition<T: ProcessorDefinition<T>>(val expressionBlock: ExpressionNode) {
-
- public fun then(block: ExpressionNode.() -> Any): T {
- expressionBlock.block()
- return expressionBlock.getParent()!! as T
- }
-}
View
49 koolapp-camel/src/test/kotlin/test/koolapp/camel/ChoiceTest.kt
@@ -1,49 +0,0 @@
-package test.koolapp.camel
-
-import org.koolapp.camel.*
-
-import org.junit.Test as test
-import org.apache.camel.component.mock.MockEndpoint
-
-class ChoiceTest {
- test fun createRoute() {
- camel {
- val bigEndpoint = mockEndpoint("mock:big")
- val smallEndpoint = mockEndpoint("mock:small")
- val otherwiseEndpoint = mockEndpoint("mock:otherwise")
-
- routes {
- from("seda:foo") {
- choice {
- filter { bodyString().contains("big") } then {
- sendTo(bigEndpoint)
- }
- filter { bodyString().contains("small") } then {
- sendTo(smallEndpoint)
- }
- otherwise {
- sendTo(otherwiseEndpoint)
- }
- }
- }
- }
- bigEndpoint.expectedBodiesReceived("big1")
- smallEndpoint.expectedBodiesReceived("small1", "small2")
- otherwiseEndpoint.expectedBodiesReceived("dummy1", "dummy2")
-
- val producer = producerTemplate()
- for (body in arrayList("dummy1", "small1", "big1", "small2", "dummy2")) {
- producer.sendBody("seda:foo", body)
- }
-
- for (result in arrayList(bigEndpoint, smallEndpoint, otherwiseEndpoint)) {
- result.assertIsSatisfied()
- println("$result has messages:")
- for (exchange in result.getReceivedExchanges()) {
- println(" ${exchange?.input}")
- }
- println()
- }
- }
- }
-}
View
78 koolapp-camel/src/test/kotlin/test/koolapp/camel/EndpointConsumeTest.kt
@@ -1,78 +0,0 @@
-package test.koolapp.camel
-
-import org.koolapp.stream.*
-import org.koolapp.camel.*
-
-import org.apache.camel.*
-import org.apache.camel.CamelContext
-import org.apache.camel.Consumer
-import org.apache.camel.Endpoint
-import org.apache.camel.Processor as ExchangeProcessor
-import org.apache.camel.spi.*
-import org.apache.camel.impl.*
-import org.apache.camel.util.CamelContextHelper
-
-import org.koolapp.stream.Stream
-import org.koolapp.stream.support.*
-import org.koolapp.stream.Handler
-import org.koolapp.stream.Cursor
-import javax.annotation.processing.Processor
-import org.apache.camel.Exchange
-
-import org.junit.Test as test
-import kotlin.test.*
-
-class EndpointConsumeTest {
-
- test fun endpointExchangeStream() {
- val context = createCamelContext()
- context.use {
- val stream = context.endpoint("timer://foo?fixedRate=true&period=1000").toExchangeStream()
- val cursor = stream.take(4).open{ println("Stream Exchange handler got $it of type ${it.javaClass} with properties ${it.getProperties()}") }
-
- Thread.sleep(6000)
- assertTrue(cursor.isClosed())
- }
- }
-
- test fun endpointStream() {
- val context = createCamelContext()
- context.use {
- val stream = context.endpoint("timer://foo?fixedRate=true&period=1000").toStream()
- val cursor = stream.take(4).open{ println("Stream Message handler got $it of type ${it.javaClass} with headers ${it.getHeaders()}") }
-
- Thread.sleep(6000)
- assertTrue(cursor.isClosed())
- }
- }
-
- test fun endpointStreamMapToHeader() {
- val context = createCamelContext()
- context.use {
- val stream = context.endpoint("timer://foo?fixedRate=true&period=1000").toStream()
- val cursor = stream.map{ it.getHeader<String>("firedTime", javaClass<String>()) }.take(4).open{
- println("Stream String handler got $it of type ${it.javaClass}")
- }
-
- Thread.sleep(6000)
- assertTrue(cursor.isClosed())
- }
- }
-
- test fun endpointHeaderStreamByFunction() {
- val context = createCamelContext()
- context.use {
- val stream = context.endpoint("timer://foo?fixedRate=true&period=1000").toStream {
- it.getIn()?.getHeader<String>("firedTime", javaClass<String>())
- }
- val cursor = stream.take(4).open{
- println("Stream String handler got $it of type ${it.javaClass}")
- }
-
- Thread.sleep(6000)
- assertTrue(cursor.isClosed())
- }
- }
-
-
-}
View
45 koolapp-camel/src/test/kotlin/test/koolapp/camel/EndpointProduceTest.kt
@@ -1,45 +0,0 @@
-package test.koolapp.camel
-
-import org.koolapp.stream.*
-import org.koolapp.camel.*
-
-import org.apache.camel.*
-import org.apache.camel.CamelContext
-import org.apache.camel.Consumer
-import org.apache.camel.Endpoint
-import org.apache.camel.Processor as ExchangeProcessor
-import org.apache.camel.spi.*
-import org.apache.camel.impl.*
-import org.apache.camel.util.CamelContextHelper
-
-import org.koolapp.stream.Stream
-import org.koolapp.stream.support.*
-import org.koolapp.stream.Handler
-import org.koolapp.stream.Cursor
-import javax.annotation.processing.Processor
-import org.apache.camel.Exchange
-
-import org.junit.Test as test
-import kotlin.test.*
-
-class EndpointProduceTest {
-
- test fun endpointExchangeStream() {
- val context = createCamelContext()
- context.use {
-
- val inStream = context.endpoint("timer://foo?fixedRate=true&period=1000").toExchangeStream()
-
- val resultsEndpoint = context.endpoint("seda:resultsEndpoint")
- inStream.sendTo(resultsEndpoint)
-
- val outStream = resultsEndpoint.toStream()
- val cursor = outStream.take(4).open{ println("handler consuming from $resultsEndpoint got $it of type ${it.javaClass}") }
-
- Thread.sleep(6000)
- assertTrue(cursor.isClosed())
- }
- }
-
-
-}
View
33 koolapp-camel/src/test/kotlin/test/koolapp/camel/FilterTest.kt
@@ -1,33 +0,0 @@
-package test.koolapp.camel
-
-import org.koolapp.camel.*
-
-import org.junit.Test as test
-import org.apache.camel.component.mock.MockEndpoint
-
-class FilterTest {
- test fun createRoute() {
- camel {
- val result = mockEndpoint("mock:result")
- routes {
- from("seda:foo") {
- filter({ bodyString().contains("big") }, {
- sendTo(result)
- })
- }
- }
- result.expectedBodiesReceived("big1")
-
- val producer = producerTemplate()
- for (body in arrayList("small1", "big1", "small2")) {
- producer.sendBody("seda:foo", body)
- }
-
- result.assertIsSatisfied()
-
- for (exchange in result.getReceivedExchanges()) {
- println("Found message ${exchange?.input}")
- }
- }
- }
-}
View
34 koolapp-camel/src/test/kotlin/test/koolapp/camel/FilterThenTest.kt
@@ -1,34 +0,0 @@
-package test.koolapp.camel
-
-import org.koolapp.camel.*
-
-import org.junit.Test as test
-import org.apache.camel.component.mock.MockEndpoint
-
-class FilterThenTest {
- test fun createRoute() {
- camel {
- val result = mockEndpoint("mock:result")
- routes {
- from("seda:foo") {
- filter { bodyString().contains("big") } then {
- sendTo(result)
- }
- }
- }
-
- result.expectedBodiesReceived("big1")
-
- val producer = producerTemplate()
- for (body in arrayList("small1", "big1", "small2")) {
- producer.sendBody("seda:foo", body)
- }
-
- result.assertIsSatisfied()
-
- for (exchange in result.getReceivedExchanges()) {
- println("Found message ${exchange?.input}")
- }
- }
- }
-}
View
29 koolapp-camel/src/test/kotlin/test/koolapp/camel/ProcessTest.kt
@@ -1,29 +0,0 @@
-package test.koolapp.camel
-
-import org.koolapp.camel.*
-
-import org.junit.Test as test
-import org.apache.camel.component.mock.MockEndpoint
-
-class ProcessTest {
- test fun createRoute() {
- camel {
- val result = mockEndpoint("mock:result")
- routes {
- from("seda:foo") {
- process { out.body = "Hello ${bodyString()}" }.sendTo(result)
- }
- }
- result.expectedBodiesReceived("Hello world!")
-
- val producer = producerTemplate()
- producer.sendBody("seda:foo", "world!")
-
- result.assertIsSatisfied()
-
- for (exchange in result.getReceivedExchanges()) {
- println("Found message ${exchange?.input}")
- }
- }
- }
-}
View
37 koolapp-camel/src/test/kotlin/test/koolapp/camel/RecipientListTest.kt
@@ -1,37 +0,0 @@
-package test.koolapp.camel
-
-import org.junit.Test as test
-import org.koolapp.camel.*
-
-class RecipientListTest<