├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── chat.api ├── .classpath ├── .project ├── bnd.bnd └── src │ └── chat │ └── api │ └── ChatMessage.java ├── chat.vertx.bootstrap ├── .classpath ├── .gitignore ├── .project ├── bnd.bnd ├── lib │ ├── handlebars-1.3.0.jar │ ├── jade4j-0.4.0.jar │ ├── vertx-auth-common-3.2.0.jar │ ├── vertx-rx-java-3.2.0.jar │ └── vertx-web-3.2.0.jar ├── src │ ├── .gitignore │ └── chat │ │ └── vertx │ │ └── bootstrap │ │ └── VertxActivator.java └── test │ └── .gitignore ├── chat.vertx.http ├── .classpath ├── .project ├── bnd.bnd └── src │ └── chat │ └── vertx │ └── http │ └── HttpServer.java ├── chat.vertx.messaging.storage.itest ├── .classpath ├── .gitignore ├── .project ├── bnd.bnd ├── src │ ├── .gitignore │ └── chat │ │ └── vertx │ │ └── messaging │ │ └── storage │ │ └── test │ │ └── MessageStoreTest.java └── test │ └── .gitignore ├── chat.vertx.messaging.storage ├── .classpath ├── .project ├── bnd.bnd ├── mongo.bnd ├── rest.bnd └── src │ └── chat │ └── vertx │ └── messaging │ ├── rest │ └── MessageHistoryResource.java │ └── storage │ ├── MessageStore.java │ ├── mongo │ └── MongoMessageStorage.java │ └── packageinfo ├── chat.vertx.mongo ├── .classpath ├── .project ├── bnd.bnd ├── lib │ └── vertx-mongo-client-3.2.0.jar └── src │ └── chat │ └── vertx │ └── mongo │ ├── MongoService.java │ ├── connection │ └── VertxMongoService.java │ └── packageinfo ├── chat.vertx.sockjs ├── .classpath ├── .project ├── bnd.bnd └── src │ └── chat │ └── vertx │ └── sockjs │ └── SockJs.java ├── cnf ├── .classpath ├── .gitignore ├── .project ├── build.bnd ├── ext │ ├── junit.bnd │ ├── pluginpaths.bnd │ └── repositories.bnd ├── localrepo │ ├── com.googlecode.concurrentlinkedhashmap.lru │ │ └── com.googlecode.concurrentlinkedhashmap.lru-1.3.1.jar │ ├── index.xml │ ├── index.xml.sha │ ├── io.netty.buffer │ │ └── io.netty.buffer-4.0.28.jar │ ├── io.netty.codec-http │ │ └── io.netty.codec-http-4.0.28.jar │ ├── io.netty.codec │ │ └── io.netty.codec-4.0.28.jar │ ├── io.netty.common │ │ └── io.netty.common-4.0.28.jar │ ├── io.netty.handler │ │ └── io.netty.handler-4.0.28.jar │ ├── io.netty.transport │ │ └── io.netty.transport-4.0.28.jar │ ├── io.vertx.core │ │ ├── io.vertx.core-3.0.0.jar │ │ └── io.vertx.core-3.2.0.jar │ ├── org.mongodb.driver-async │ │ └── org.mongodb.driver-async-3.2.0.jar │ └── org.mongodb.mongo-java-driver │ │ └── org.mongodb.mongo-java-driver-3.2.0.jar ├── plugins │ ├── biz.aQute.repository │ │ └── biz.aQute.repository.jar │ ├── org.apache.felix.dependencymanager.annotation-3.2.0.jar │ └── org.apache.felix.dependencymanager.annotation.jar ├── releaserepo │ ├── index.xml │ └── index.xml.sha └── src │ └── .gitignore ├── gradle.properties ├── run ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── bnd.bnd ├── chat.bndrun ├── conf │ ├── org.ops4j.pax.logging.cfg │ └── vertx.mongo.cfg ├── src │ └── .gitignore ├── test │ └── .gitignore └── webroot │ ├── app │ ├── app.js │ ├── app.js.map │ ├── app.ts │ ├── boot.js │ ├── boot.js.map │ ├── boot.ts │ └── chat │ │ ├── ChatComponents.js │ │ ├── ChatComponents.js.map │ │ ├── ChatComponents.ts │ │ ├── ChatService.js │ │ ├── ChatService.js.map │ │ ├── ChatService.ts │ │ ├── Model.js │ │ ├── Model.js.map │ │ └── Model.ts │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ └── typings │ ├── VertxEventBus.d.ts │ └── moment │ └── moment-node.d.ts └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle/ 2 | /reports/ 3 | /generated/ 4 | chat.api/bin 5 | chat.api/.settings 6 | chat.api/generated 7 | chat.vertx.bootstrap/.settings 8 | chat.vertx.http/generated 9 | chat.vertx.http/.settings 10 | chat.vertx.http/bin 11 | chat.vertx.messaging.storage/.settings 12 | chat.vertx.messaging.storage/bin 13 | chat.vertx.messaging.storage/generated 14 | chat.vertx.mongo/.settings 15 | chat.vertx.mongo/bin 16 | chat.vertx.mongo/generated 17 | chat.vertx.sockjs/generated 18 | chat.vertx.sockjs/bin 19 | chat.vertx.sockjs/.settings 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # osgi-vertx-demo 2 | 3 | This is the example repo that comes together with a [blog post](http://paulbakker.io/osgi/vertx-osgi/) describing how to run Vertx Web with OSGi. Please refer to the blog post for all the details of how this project is set up. 4 | 5 | The following is a list of bundles (modules) which make the application. The workspace is created in Bndtools, a plugin for Eclipse to make OSGi development easy. Out-of-the-box we also get a Gradle build for each Bndtools workspace, which we use on build servers. During development, we don’t need to run Gradle however. 6 | 7 | * chat.api : API only project, containing the ChatMessage class. 8 | * chat.vertx.bootstrap : Wraps Vertx Web and vertx RX and makes the Vertx and Router instance available as OSGi services. 9 | * chat.vertx.http : Setup static file routing and starts HTTP server. 10 | * chat.vertx.messaging.storage.mongo : Stores chat messages in Mongo 11 | * chat.vertx.messaging.storage.rest : Makes the stored chat messages available in a RESTful web service 12 | * chat.vertx.messaging.storage.itest : OSGi integration test for the Mongo service. 13 | * chat.vertx.mongo : Sets up a MongoClient based on Configuration Admin configuration and publishes it as an OSGi service. 14 | * chat.vertx.sockjs : Sets up the SockJS event bus bridge. 15 | * run : Contains the configuration files, static web resources and bndrun configuration to start the application. Check the chat.bndrun file for the full list of bundles to run the application. The application can also be started from this file directly. 16 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Master Gradle build script 3 | * 4 | * Depends on bndWorkspace and bndURI properties set by settings.gradle. 5 | */ 6 | 7 | import aQute.bnd.build.Workspace 8 | import aQute.bnd.osgi.Constants 9 | import org.osgi.service.indexer.* 10 | import org.osgi.service.indexer.impl.* 11 | 12 | /* Add bnd gradle plugin as a script dependency */ 13 | buildscript { 14 | dependencies { 15 | classpath bndPlugin 16 | } 17 | } 18 | 19 | /* Initialize the bnd workspace */ 20 | Workspace.setDriver(Constants.BNDDRIVER_GRADLE) 21 | Workspace.addGestalt(Constants.GESTALT_BATCH, null) 22 | ext.bndWorkspace = new Workspace(rootDir, bnd_cnf) 23 | if (bndWorkspace == null) { 24 | throw new GradleException("Unable to load workspace ${rootDir}/${bnd_cnf}") 25 | } 26 | logging.captureStandardOutput LogLevel.INFO 27 | ext.cnf = rootProject.project(bnd_cnf) 28 | 29 | /* Configure the subprojects */ 30 | subprojects { 31 | def bndProject = bndWorkspace.getProject(name) 32 | if (bndProject != null) { 33 | plugins.apply 'biz.aQute.bnd' 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /chat.api/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chat.api/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.api 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.api/bnd.bnd: -------------------------------------------------------------------------------- 1 | -baseline: * 2 | 3 | Bundle-Version: 1.0.0.${tstamp} 4 | Export-Package: chat.api -------------------------------------------------------------------------------- /chat.api/src/chat/api/ChatMessage.java: -------------------------------------------------------------------------------- 1 | package chat.api; 2 | 3 | public class ChatMessage { 4 | private long timestamp; 5 | private String user; 6 | private String text; 7 | 8 | public ChatMessage() { 9 | } 10 | 11 | public ChatMessage(long timestamp, String user, String text) { 12 | this.timestamp = timestamp; 13 | this.user = user; 14 | this.text = text; 15 | } 16 | 17 | public String getUser() { 18 | return user; 19 | } 20 | 21 | public void setUser(String user) { 22 | this.user = user; 23 | } 24 | 25 | public String getText() { 26 | return text; 27 | } 28 | 29 | public void setText(String text) { 30 | this.text = text; 31 | } 32 | 33 | public long getTimestamp() { 34 | return timestamp; 35 | } 36 | 37 | public void setTimestamp(long timestamp) { 38 | this.timestamp = timestamp; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /chat.vertx.bootstrap/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /chat.vertx.bootstrap/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /bin_test/ 3 | /generated/ 4 | -------------------------------------------------------------------------------- /chat.vertx.bootstrap/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.vertx.bootstrap 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.vertx.bootstrap/bnd.bnd: -------------------------------------------------------------------------------- 1 | Bundle-Version: 0.0.0.${tstamp} 2 | -buildpath: \ 3 | ../cnf/plugins/org.apache.felix.dependencymanager.annotation.jar;version=file,\ 4 | org.apache.felix.dependencymanager;version='[4,5)',\ 5 | osgi.core,\ 6 | lib/vertx-web-3.2.0.jar;version=file,\ 7 | lib/vertx-rx-java-3.2.0.jar;version=file,\ 8 | io.reactivex.rxjava,\ 9 | io.vertx.core;version=3.2 10 | 11 | Include-Resource: @lib/vertx-web-3.2.0.jar,\ 12 | @lib/handlebars-1.3.0.jar,\ 13 | @lib/jade4j-0.4.0.jar,\ 14 | @lib/vertx-auth-common-3.2.0.jar,\ 15 | @lib/vertx-rx-java-3.2.0.jar 16 | 17 | Import-Package: \ 18 | org.apache.commons.jexl2.*;resolution:=optional,\ 19 | org.mozilla.*;resolution:=optional,\ 20 | org.pegdown.*;resolution:=optional,\ 21 | org.codehaus.groovy.*;resolution:=optional,\ 22 | org.antlr.*;resolution:=optional,\ 23 | io.vertx.lang.*;resolution:=optional,\ 24 | groovy.lang.*;resolution:=optional,\ 25 | io.vertx.groovy.*;resolution:=optional,\ 26 | io.vertx.codegen.*;resolution:=optional,\ 27 | io.vertx.ext.auth.oauth2;resolution:=optional,\ 28 | com.jcraft.jzlib;resolution:=optional,\ 29 | com.google.protobuf;resolution:=optional,\ 30 | * 31 | Export-Package: \ 32 | io.vertx.rxjava.ext.*,\ 33 | io.vertx.ext.*,\ 34 | io.vertx.rxjava.*,\ 35 | io.vertx.rx.java 36 | Private-Package: chat.vertx.bootstrap 37 | Bundle-Activator: chat.vertx.bootstrap.VertxActivator 38 | -------------------------------------------------------------------------------- /chat.vertx.bootstrap/lib/handlebars-1.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/lib/handlebars-1.3.0.jar -------------------------------------------------------------------------------- /chat.vertx.bootstrap/lib/jade4j-0.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/lib/jade4j-0.4.0.jar -------------------------------------------------------------------------------- /chat.vertx.bootstrap/lib/vertx-auth-common-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/lib/vertx-auth-common-3.2.0.jar -------------------------------------------------------------------------------- /chat.vertx.bootstrap/lib/vertx-rx-java-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/lib/vertx-rx-java-3.2.0.jar -------------------------------------------------------------------------------- /chat.vertx.bootstrap/lib/vertx-web-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/lib/vertx-web-3.2.0.jar -------------------------------------------------------------------------------- /chat.vertx.bootstrap/src/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/src/.gitignore -------------------------------------------------------------------------------- /chat.vertx.bootstrap/src/chat/vertx/bootstrap/VertxActivator.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.bootstrap; 2 | 3 | import org.apache.felix.dm.DependencyActivatorBase; 4 | import org.apache.felix.dm.DependencyManager; 5 | import org.osgi.framework.BundleContext; 6 | 7 | import io.vertx.rxjava.core.Vertx; 8 | import io.vertx.rxjava.core.eventbus.EventBus; 9 | import io.vertx.rxjava.ext.web.Router; 10 | 11 | public class VertxActivator extends DependencyActivatorBase{ 12 | 13 | private volatile Vertx vertx; 14 | 15 | @Override 16 | public void init(BundleContext arg0, DependencyManager dm) throws Exception { 17 | vertx = Vertx.vertx(); 18 | 19 | dm.add(createComponent().setInterface(Vertx.class.getName(), null).setImplementation(vertx)); 20 | dm.add(createComponent().setInterface(EventBus.class.getName(), null).setImplementation(vertx.eventBus())); 21 | 22 | Router router = Router.router(vertx); 23 | dm.add(createComponent().setInterface(Router.class.getName(), null).setImplementation(router)); 24 | } 25 | 26 | @Override 27 | public void destroy(BundleContext context, DependencyManager manager) throws Exception { 28 | vertx.close(); 29 | vertx = null; 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /chat.vertx.bootstrap/test/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.bootstrap/test/.gitignore -------------------------------------------------------------------------------- /chat.vertx.http/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chat.vertx.http/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.vertx.http 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.vertx.http/bnd.bnd: -------------------------------------------------------------------------------- 1 | -buildpath: \ 2 | ../cnf/plugins/org.apache.felix.dependencymanager.annotation.jar;version=file,\ 3 | chat.vertx.bootstrap;version=latest,\ 4 | io.vertx.core;version=3.2 5 | Private-Package: chat.vertx.http -------------------------------------------------------------------------------- /chat.vertx.http/src/chat/vertx/http/HttpServer.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.http; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.apache.felix.dm.annotation.api.Component; 7 | import org.apache.felix.dm.annotation.api.ServiceDependency; 8 | import org.apache.felix.dm.annotation.api.Start; 9 | import org.apache.felix.dm.annotation.api.Stop; 10 | 11 | import io.vertx.core.http.HttpMethod; 12 | import io.vertx.rxjava.core.Vertx; 13 | import io.vertx.rxjava.ext.web.Route; 14 | import io.vertx.rxjava.ext.web.Router; 15 | import io.vertx.rxjava.ext.web.handler.CorsHandler; 16 | import io.vertx.rxjava.ext.web.handler.StaticHandler; 17 | 18 | @Component 19 | public class HttpServer { 20 | 21 | @ServiceDependency 22 | private volatile Vertx vertx; 23 | 24 | @ServiceDependency 25 | private volatile Router router; 26 | 27 | private final Set routes = new HashSet<>(); 28 | 29 | private volatile io.vertx.rxjava.core.http.HttpServer server; 30 | 31 | @Start 32 | public void start() { 33 | router.route().handler(CorsHandler.create("*") 34 | .allowedMethod(HttpMethod.GET) 35 | .allowedMethod(HttpMethod.POST) 36 | .allowedMethod(HttpMethod.DELETE) 37 | .allowedMethod(HttpMethod.PUT) 38 | .allowedMethod(HttpMethod.OPTIONS) 39 | .allowedHeader("X-PINGARUNER") 40 | .allowedHeader("Content-Type")); 41 | Route route = router.route("/static/*"); 42 | route.handler(StaticHandler.create()); 43 | routes.add(route); 44 | 45 | server = vertx.createHttpServer(); 46 | server.requestHandler(router::accept).listen(8080); 47 | } 48 | 49 | @Stop 50 | public void stop() { 51 | routes.forEach(r -> r.remove()); 52 | server.close(); 53 | server = null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /bin_test/ 3 | /generated/ 4 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.vertx.messaging.storage.itest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/bnd.bnd: -------------------------------------------------------------------------------- 1 | Bundle-Version: 1.0.0 2 | -buildpath: \ 3 | org.amdatu.testing.configurator;version='[3.1,4)',\ 4 | osgi.core;version=5.0,\ 5 | org.apache.felix.dependencymanager;version='[4,5)',\ 6 | org.apache.servicemix.bundles.junit,\ 7 | osgi.cmpn,\ 8 | chat.vertx.messaging.storage.mongo;version=latest,\ 9 | org.mongodb.mongo-java-driver,\ 10 | io.reactivex.rxjava,\ 11 | chat.api;version=latest,\ 12 | chat.vertx.bootstrap;version=latest,\ 13 | io.vertx.core;version=3.2 14 | 15 | -runbundles: \ 16 | org.apache.felix.configadmin,\ 17 | org.apache.felix.dependencymanager;version='[4,5)',\ 18 | org.apache.felix.dependencymanager.runtime;version='[4,5)',\ 19 | org.apache.felix.metatype,\ 20 | org.apache.felix.eventadmin,\ 21 | org.apache.felix.log,\ 22 | org.apache.servicemix.bundles.junit,\ 23 | org.amdatu.testing.configurator;version='[3.1,4)',\ 24 | chat.vertx.messaging.storage.mongo,\ 25 | chat.api;version=latest,\ 26 | chat.vertx.bootstrap;version=latest,\ 27 | org.mongodb.driver-async,\ 28 | com.fasterxml.jackson.core.jackson-annotations,\ 29 | com.fasterxml.jackson.core.jackson-core,\ 30 | com.fasterxml.jackson.core.jackson-databind,\ 31 | chat.vertx.mongo;version=latest,\ 32 | org.mongodb.mongo-java-driver;version='[3,4)',\ 33 | com.googlecode.concurrentlinkedhashmap.lru,\ 34 | io.netty.buffer,\ 35 | io.netty.codec,\ 36 | io.netty.codec-http,\ 37 | io.netty.common,\ 38 | io.netty.handler,\ 39 | io.netty.transport,\ 40 | org.apache.felix.http.servlet-api,\ 41 | org.apache.commons.collections,\ 42 | org.ops4j.pax.logging.pax-logging-api,\ 43 | org.ops4j.pax.logging.pax-logging-service,\ 44 | org.apache.commons.io,\ 45 | org.apache.commons.lang3,\ 46 | io.reactivex.rxjava,\ 47 | io.vertx.core;version=3.2.0 48 | 49 | -runfw: org.apache.felix.framework;version='[4.2.1,4.2.1]' 50 | -runee: JavaSE-1.8 51 | Test-Cases: chat.vertx.messaging.storage.test.MessageStoreTest 52 | Private-Package: chat.vertx.messaging.storage.test 53 | -runsystempackages: sun.misc -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/src/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.messaging.storage.itest/src/.gitignore -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/src/chat/vertx/messaging/storage/test/MessageStoreTest.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.messaging.storage.test; 2 | 3 | import static org.amdatu.testing.configurator.TestConfigurator.cleanUp; 4 | import static org.amdatu.testing.configurator.TestConfigurator.configure; 5 | import static org.amdatu.testing.configurator.TestConfigurator.createConfiguration; 6 | import static org.amdatu.testing.configurator.TestConfigurator.createServiceDependency; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | import org.junit.After; 13 | import org.junit.Before; 14 | import org.junit.Test; 15 | 16 | import chat.api.ChatMessage; 17 | import chat.vertx.messaging.storage.MessageStore; 18 | import rx.Observable; 19 | import rx.observers.TestSubscriber; 20 | import io.vertx.rxjava.core.*; 21 | import io.vertx.core.json.*; 22 | 23 | public class MessageStoreTest { 24 | 25 | private volatile MessageStore serviceToTest; 26 | private volatile Vertx vertx; 27 | 28 | @Before 29 | public void setup() { 30 | configure(this) 31 | .add(createServiceDependency().setService(Vertx.class).setRequired(true)) 32 | .add(createConfiguration("vertx.mongo").set("url", "mongodb://localhost:27017").set("db", "vertxchat")) 33 | .add(createServiceDependency().setService(MessageStore.class).setRequired(true)).apply(); 34 | 35 | serviceToTest.clear().toBlocking().subscribe(); 36 | } 37 | 38 | @Test 39 | public void test() throws InterruptedException { 40 | 41 | ChatMessage msg1 = new ChatMessage(1, "User 1", "Hello"); 42 | ChatMessage msg2 = new ChatMessage(2, "User 2", "Hello to you too!"); 43 | ChatMessage msg3 = new ChatMessage(3, "User 1", "Chatting is fun"); 44 | List msgList = Arrays.asList(msg1, msg2, msg3); 45 | Observable.from(msgList) 46 | .map(m -> Json.encode(m)) 47 | .subscribe(m -> vertx.eventBus().publish("chat", m)); 48 | TimeUnit.SECONDS.sleep(1); 49 | 50 | TestSubscriber testSubscriber = new TestSubscriber<>(); 51 | serviceToTest.listMessages().flatMap(m -> Observable.from(m)).subscribe(testSubscriber); 52 | 53 | testSubscriber.awaitTerminalEvent(); 54 | testSubscriber.assertNoErrors(); 55 | testSubscriber.assertCompleted(); 56 | testSubscriber.assertValueCount(3); 57 | } 58 | 59 | @After 60 | public void after() { 61 | cleanUp(this); 62 | } 63 | } -------------------------------------------------------------------------------- /chat.vertx.messaging.storage.itest/test/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.messaging.storage.itest/test/.gitignore -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.vertx.messaging.storage 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/bnd.bnd: -------------------------------------------------------------------------------- 1 | -buildpath: \ 2 | ../cnf/plugins/org.apache.felix.dependencymanager.annotation.jar;version=file,\ 3 | io.reactivex.rxjava,\ 4 | chat.vertx.bootstrap;version=latest,\ 5 | io.vertx.core;version=3.2,\ 6 | chat.api;version=latest,\ 7 | chat.vertx.mongo;version=latest 8 | -sub: *.bnd -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/mongo.bnd: -------------------------------------------------------------------------------- 1 | Private-Package: chat.vertx.messaging.storage.mongo 2 | Export-Package: chat.vertx.messaging.storage -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/rest.bnd: -------------------------------------------------------------------------------- 1 | Private-Package: chat.vertx.messaging.rest -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/src/chat/vertx/messaging/rest/MessageHistoryResource.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.messaging.rest; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.apache.felix.dm.annotation.api.Component; 7 | import org.apache.felix.dm.annotation.api.ServiceDependency; 8 | import org.apache.felix.dm.annotation.api.Start; 9 | import org.apache.felix.dm.annotation.api.Stop; 10 | 11 | import chat.vertx.messaging.storage.MessageStore; 12 | import io.vertx.core.json.Json; 13 | import io.vertx.rxjava.ext.web.Route; 14 | import io.vertx.rxjava.ext.web.Router; 15 | 16 | @Component 17 | public class MessageHistoryResource { 18 | 19 | @ServiceDependency 20 | private volatile Router router; 21 | 22 | private final Set routes = new HashSet<>(); 23 | 24 | @ServiceDependency 25 | private volatile MessageStore messageStore; 26 | 27 | @Start 28 | public void start() { 29 | Route route = router.get("/messages"); 30 | routes.add(route); 31 | 32 | route.handler(routingContext -> { 33 | messageStore.listMessagesAsJson().subscribe( 34 | messages -> routingContext.response().putHeader("content-type", "application/json; charset=utf-8").setChunked(true).write(Json.encodePrettily(messages)), 35 | e -> { 36 | routingContext.fail(500); 37 | e.printStackTrace(); 38 | }, 39 | () -> routingContext.response().end()); 40 | }); 41 | 42 | } 43 | 44 | @Stop 45 | public void stop() { 46 | routes.forEach(r -> r.remove()); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/src/chat/vertx/messaging/storage/MessageStore.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.messaging.storage; 2 | 3 | import java.util.List; 4 | 5 | import chat.api.ChatMessage; 6 | import io.vertx.core.json.JsonObject; 7 | import rx.Observable; 8 | 9 | public interface MessageStore { 10 | 11 | Observable> listMessagesAsJson(); 12 | Observable> listMessages(); 13 | Observable clear(); 14 | } 15 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/src/chat/vertx/messaging/storage/mongo/MongoMessageStorage.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.messaging.storage.mongo; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.felix.dm.annotation.api.Component; 6 | import org.apache.felix.dm.annotation.api.ServiceDependency; 7 | import org.apache.felix.dm.annotation.api.Start; 8 | 9 | import chat.api.ChatMessage; 10 | import chat.vertx.messaging.storage.MessageStore; 11 | import chat.vertx.mongo.MongoService; 12 | import io.vertx.core.json.JsonObject; 13 | import io.vertx.rxjava.core.Vertx; 14 | import rx.Observable; 15 | 16 | @Component 17 | public class MongoMessageStorage implements MessageStore { 18 | @ServiceDependency 19 | private volatile Vertx vertx; 20 | 21 | @ServiceDependency 22 | private volatile MongoService mongoService; 23 | 24 | 25 | @Start 26 | public void start() { 27 | vertx.eventBus().consumer("chat").toObservable() 28 | .map(m -> (String)m.body()) 29 | .map(m -> new JsonObject(m)) 30 | .flatMap(m -> mongoService.getClient().saveObservable("messages", m)).subscribe(); 31 | } 32 | 33 | 34 | @Override 35 | public Observable> listMessagesAsJson() { 36 | return mongoService.getClient().findObservable("messages", new JsonObject()); 37 | } 38 | 39 | 40 | @Override 41 | public Observable> listMessages() { 42 | return listMessagesAsJson() 43 | .flatMap(m -> Observable.from(m)) 44 | .map(m -> new ChatMessage(m.getLong("timestamp"), m.getString("user"), m.getString("text"))) 45 | .toList(); 46 | 47 | } 48 | 49 | @Override 50 | public Observable clear() { 51 | return mongoService.getClient().removeObservable("messages", new JsonObject()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /chat.vertx.messaging.storage/src/chat/vertx/messaging/storage/packageinfo: -------------------------------------------------------------------------------- 1 | version 1.0.0 2 | -------------------------------------------------------------------------------- /chat.vertx.mongo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chat.vertx.mongo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.vertx.mongo 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.vertx.mongo/bnd.bnd: -------------------------------------------------------------------------------- 1 | Include-Resource: \ 2 | @lib/vertx-mongo-client-3.2.0.jar 3 | 4 | -buildpath: \ 5 | ../cnf/plugins/org.apache.felix.dependencymanager.annotation.jar;version=file,\ 6 | lib/vertx-mongo-client-3.2.0.jar;version=file,\ 7 | chat.vertx.bootstrap;version=latest,\ 8 | io.vertx.core;version=3.2 9 | Private-Package: chat.vertx.mongo.connection 10 | Export-Package: \ 11 | chat.vertx.mongo,\ 12 | io.vertx.ext.mongo,\ 13 | io.vertx.rxjava.ext.mongo 14 | Import-Package: \ 15 | groovy.lang;resolution:=optional,\ 16 | org.codehaus.groovy.*;resolution:=optional,\ 17 | io.vertx.lang.groovy;resolution:=optional,\ 18 | io.vertx.groovy.core;resolution:=optional,\ 19 | io.vertx.codegen.annotations;resolution:=optional,\ 20 | * -------------------------------------------------------------------------------- /chat.vertx.mongo/lib/vertx-mongo-client-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/chat.vertx.mongo/lib/vertx-mongo-client-3.2.0.jar -------------------------------------------------------------------------------- /chat.vertx.mongo/src/chat/vertx/mongo/MongoService.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.mongo; 2 | 3 | import io.vertx.rxjava.ext.mongo.MongoClient; 4 | 5 | public interface MongoService { 6 | MongoClient getClient(); 7 | } 8 | -------------------------------------------------------------------------------- /chat.vertx.mongo/src/chat/vertx/mongo/connection/VertxMongoService.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.mongo.connection; 2 | 3 | import java.util.Dictionary; 4 | 5 | import org.apache.felix.dm.annotation.api.Component; 6 | import org.apache.felix.dm.annotation.api.ConfigurationDependency; 7 | import org.apache.felix.dm.annotation.api.ServiceDependency; 8 | import org.apache.felix.dm.annotation.api.Start; 9 | import org.apache.felix.dm.annotation.api.Stop; 10 | 11 | import chat.vertx.mongo.MongoService; 12 | import io.vertx.core.json.JsonObject; 13 | import io.vertx.rxjava.core.Vertx; 14 | import io.vertx.rxjava.ext.mongo.MongoClient; 15 | 16 | @Component 17 | public class VertxMongoService implements MongoService { 18 | 19 | @ServiceDependency 20 | private volatile Vertx vertx; 21 | 22 | private volatile JsonObject mongoconfig; 23 | private volatile MongoClient client; 24 | 25 | @Start 26 | public void start() { 27 | connect(); 28 | } 29 | 30 | @Stop 31 | public void stop() { 32 | client.close(); 33 | client = null; 34 | } 35 | 36 | @Override 37 | public MongoClient getClient() { 38 | return client; 39 | } 40 | 41 | @ConfigurationDependency(pid="vertx.mongo") 42 | public void updated(Dictionary properties) { 43 | if(properties != null ) { 44 | 45 | mongoconfig = new JsonObject() 46 | .put("connection_string", properties.get("url")) 47 | .put("db_name", properties.get("db")); 48 | connect(); 49 | } 50 | } 51 | 52 | private void connect() { 53 | if(vertx != null) { 54 | client = MongoClient.createShared(vertx, mongoconfig); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /chat.vertx.mongo/src/chat/vertx/mongo/packageinfo: -------------------------------------------------------------------------------- 1 | version 1.0.0 2 | -------------------------------------------------------------------------------- /chat.vertx.sockjs/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chat.vertx.sockjs/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | chat.vertx.sockjs 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /chat.vertx.sockjs/bnd.bnd: -------------------------------------------------------------------------------- 1 | -buildpath: \ 2 | ../cnf/plugins/org.apache.felix.dependencymanager.annotation.jar;version=file,\ 3 | chat.vertx.bootstrap;version=latest,\ 4 | io.vertx.core;version=3.2 5 | Private-Package: chat.vertx.sockjs -------------------------------------------------------------------------------- /chat.vertx.sockjs/src/chat/vertx/sockjs/SockJs.java: -------------------------------------------------------------------------------- 1 | package chat.vertx.sockjs; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.apache.felix.dm.annotation.api.Component; 7 | import org.apache.felix.dm.annotation.api.ServiceDependency; 8 | import org.apache.felix.dm.annotation.api.Start; 9 | import org.apache.felix.dm.annotation.api.Stop; 10 | 11 | import io.vertx.ext.web.handler.sockjs.BridgeOptions; 12 | import io.vertx.ext.web.handler.sockjs.PermittedOptions; 13 | import io.vertx.rxjava.core.Vertx; 14 | import io.vertx.rxjava.ext.web.Route; 15 | import io.vertx.rxjava.ext.web.Router; 16 | import io.vertx.rxjava.ext.web.handler.sockjs.SockJSHandler; 17 | 18 | @Component 19 | public class SockJs { 20 | @ServiceDependency 21 | private volatile Vertx vertx; 22 | 23 | @ServiceDependency 24 | private volatile Router router; 25 | 26 | private final Set routes = new HashSet<>(); 27 | 28 | @Start 29 | public void start() { 30 | SockJSHandler sockJSHandler = SockJSHandler.create(vertx); 31 | BridgeOptions options = new BridgeOptions(); 32 | PermittedOptions chatPermission = new PermittedOptions().setAddress("chat"); 33 | PermittedOptions outboundPermitted1 = new PermittedOptions().setAddress("chat"); 34 | 35 | options.addInboundPermitted(chatPermission); 36 | options.addOutboundPermitted(outboundPermitted1); 37 | sockJSHandler.bridge(options); 38 | 39 | Route route = router.route("/eventbus/*"); 40 | routes.add(route); 41 | route.handler(sockJSHandler); 42 | } 43 | 44 | @Stop 45 | public void stop() { 46 | routes.forEach(r -> r.remove()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /cnf/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /cnf/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /generated/ 3 | /cache/ 4 | -------------------------------------------------------------------------------- /cnf/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cnf 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /cnf/build.bnd: -------------------------------------------------------------------------------- 1 | ######################## 2 | ## BND BUILD SETTINGS ## 3 | ######################## 4 | 5 | 6 | ## Global defaults are loaded from the bnd library (as shown below), place your 7 | ## specific settings here. Additional settings are inherited from ext/*.bnd and 8 | ## they will be overridden by anything you specify in this file. 9 | 10 | ## General Options 11 | #project.dependson: ${p-dependson;:} 12 | #project.bootclasspath: ${p-bootclasspath;:} 13 | #project.buildpath: ${p-buildpath;:} 14 | #project.sourcepath: ${p-sourcepath;:} 15 | #project.allsourcepath: ${p-allsourcepath;:} 16 | #project.output: ${p-output} 17 | #project.testpath: ${p-testpath;:} 18 | 19 | #-verbose: false 20 | #project: ${basedir} 21 | #src: src 22 | #bin: bin 23 | #testsrc: test 24 | #testbin: bin_test 25 | #target-dir: generated 26 | #target: ${project}/${target-dir} 27 | #build: ${workspace}/cnf 28 | #p: ${basename;${project}} 29 | #project.name: ${p} 30 | #plugin-dir: ${build}/plugins 31 | 32 | ## Java Compiler Options 33 | #java: java 34 | #javac: javac 35 | javac.source: 1.8 36 | javac.target: 1.8 37 | #javac.debug: on 38 | 39 | ## Bnd Options 40 | #-sources: true 41 | #-sourcepath: ${project}/src 42 | 43 | 44 | ## Properties from ext/*.bnd can be referenced in order to extend them. For 45 | ## example, to add one additional plugin to the list defined in 46 | ## ext/repositories.bnd: 47 | # -plugin: ${ext.repositories.-plugin}, org.example.MyPlugin 48 | 49 | 50 | ## To enable baselining, uncomment the following lines: 51 | # -baseline: * 52 | 53 | 54 | ## If you use git, you might want to uncomment the following lines: 55 | # Git-Descriptor: ${system-allow-fail;git describe --dirty --always} 56 | # Git-SHA: ${system-allow-fail;git rev-list -1 HEAD} 57 | # -diffignore: Git-Descriptor,Git-SHA 58 | -plugin: \ 59 | ${ext.repositories.-plugin},\ 60 | org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;path:=${plugin-dir}/org.apache.felix.dependencymanager.annotation.jar;build-import-export-service=false;add-require-capability=true=true 61 | -------------------------------------------------------------------------------- /cnf/ext/junit.bnd: -------------------------------------------------------------------------------- 1 | junit:\ 2 | junit;version=latest,\ 3 | hamcrest-core;version=latest 4 | -------------------------------------------------------------------------------- /cnf/ext/pluginpaths.bnd: -------------------------------------------------------------------------------- 1 | -pluginpath:\ 2 | ${plugin-dir}/biz.aQute.repository/biz.aQute.repository.jar 3 | -------------------------------------------------------------------------------- /cnf/ext/repositories.bnd: -------------------------------------------------------------------------------- 1 | -plugin:\ 2 | aQute.bnd.deployer.repository.LocalIndexedRepo; name=Release; local=${workspace}/cnf/releaserepo;pretty=true,\ 3 | aQute.bnd.deployer.repository.LocalIndexedRepo; name=Local; local=${workspace}/cnf/localrepo;pretty=true,\ 4 | aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Dependencies; locations=http://repository.amdatu.org/dependencies/index.xml.gz,\ 5 | aQute.bnd.deployer.repository.FixedIndexedRepo; name=Amdatu Release; locations=http://repository.amdatu.org/release/index.xml.gz,\ 6 | aQute.lib.deployer.FileRepo; name=Build; location=${workspace}/cnf/buildrepo;latest=false 7 | 8 | -releaserepo: Release 9 | -------------------------------------------------------------------------------- /cnf/localrepo/com.googlecode.concurrentlinkedhashmap.lru/com.googlecode.concurrentlinkedhashmap.lru-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/com.googlecode.concurrentlinkedhashmap.lru/com.googlecode.concurrentlinkedhashmap.lru-1.3.1.jar -------------------------------------------------------------------------------- /cnf/localrepo/index.xml.sha: -------------------------------------------------------------------------------- 1 | ac31d4634aa3eb9b43d054f542e4bef28ba12947b36c4ee031693d9cc83881e7 -------------------------------------------------------------------------------- /cnf/localrepo/io.netty.buffer/io.netty.buffer-4.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.netty.buffer/io.netty.buffer-4.0.28.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.netty.codec-http/io.netty.codec-http-4.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.netty.codec-http/io.netty.codec-http-4.0.28.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.netty.codec/io.netty.codec-4.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.netty.codec/io.netty.codec-4.0.28.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.netty.common/io.netty.common-4.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.netty.common/io.netty.common-4.0.28.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.netty.handler/io.netty.handler-4.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.netty.handler/io.netty.handler-4.0.28.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.netty.transport/io.netty.transport-4.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.netty.transport/io.netty.transport-4.0.28.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.vertx.core/io.vertx.core-3.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.vertx.core/io.vertx.core-3.0.0.jar -------------------------------------------------------------------------------- /cnf/localrepo/io.vertx.core/io.vertx.core-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/io.vertx.core/io.vertx.core-3.2.0.jar -------------------------------------------------------------------------------- /cnf/localrepo/org.mongodb.driver-async/org.mongodb.driver-async-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/org.mongodb.driver-async/org.mongodb.driver-async-3.2.0.jar -------------------------------------------------------------------------------- /cnf/localrepo/org.mongodb.mongo-java-driver/org.mongodb.mongo-java-driver-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/localrepo/org.mongodb.mongo-java-driver/org.mongodb.mongo-java-driver-3.2.0.jar -------------------------------------------------------------------------------- /cnf/plugins/biz.aQute.repository/biz.aQute.repository.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/plugins/biz.aQute.repository/biz.aQute.repository.jar -------------------------------------------------------------------------------- /cnf/plugins/org.apache.felix.dependencymanager.annotation-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/plugins/org.apache.felix.dependencymanager.annotation-3.2.0.jar -------------------------------------------------------------------------------- /cnf/plugins/org.apache.felix.dependencymanager.annotation.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/plugins/org.apache.felix.dependencymanager.annotation.jar -------------------------------------------------------------------------------- /cnf/releaserepo/index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /cnf/releaserepo/index.xml.sha: -------------------------------------------------------------------------------- 1 | 262a924c4164db96f2409bfbe8d20793eb0c91a51c3dcd7c2160cde2bac8a492 -------------------------------------------------------------------------------- /cnf/src/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/cnf/src/.gitignore -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # cnf project name 2 | bnd_cnf=cnf 3 | 4 | # bnd_plugin is the dependency declaration for the bnd gradle plugin 5 | bnd_plugin=biz.aQute.bnd:biz.aQute.bnd.gradle:3.1.0 6 | 7 | # bnd_build can be set to the name of a "master" project whose dependencies will seed the set of projects to build. 8 | bnd_build= 9 | 10 | # Default gradle task to build 11 | bnd_defaultTask=build 12 | 13 | # This should be false. It only needs to be true in rare cases. 14 | bnd_preCompileRefresh=false 15 | -------------------------------------------------------------------------------- /run/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /run/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /bin_test/ 3 | /generated/ 4 | -------------------------------------------------------------------------------- /run/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | run 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | bndtools.core.bndbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | bndtools.core.bndnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /run/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /run/bnd.bnd: -------------------------------------------------------------------------------- 1 | Bundle-Version: 0.0.0.${tstamp} -------------------------------------------------------------------------------- /run/chat.bndrun: -------------------------------------------------------------------------------- 1 | -runfw: org.apache.felix.framework;version='[5.2.0,5.2.0]' 2 | -runee: JavaSE-1.8 3 | -runbundles: \ 4 | chat.vertx.bootstrap;version=latest,\ 5 | com.googlecode.concurrentlinkedhashmap.lru,\ 6 | com.fasterxml.jackson.core.jackson-annotations,\ 7 | com.fasterxml.jackson.core.jackson-core,\ 8 | com.fasterxml.jackson.core.jackson-databind,\ 9 | org.apache.felix.http.servlet-api,\ 10 | org.apache.commons.collections,\ 11 | org.apache.commons.io,\ 12 | org.apache.commons.lang3,\ 13 | org.ops4j.pax.logging.pax-logging-api,\ 14 | org.ops4j.pax.logging.pax-logging-service,\ 15 | org.apache.felix.configadmin,\ 16 | org.apache.felix.dependencymanager;version='[4,5)',\ 17 | org.apache.felix.dependencymanager.runtime;version='[4,5)',\ 18 | org.apache.felix.dependencymanager.shell;version='[4,5)',\ 19 | org.apache.felix.metatype,\ 20 | org.apache.felix.eventadmin,\ 21 | org.apache.felix.gogo.command,\ 22 | org.apache.felix.gogo.runtime,\ 23 | org.apache.felix.gogo.shell,\ 24 | org.amdatu.configurator.api,\ 25 | org.amdatu.configurator.properties,\ 26 | io.reactivex.rxjava,\ 27 | chat.api;version=latest,\ 28 | chat.vertx.messaging.storage.rest;version=latest,\ 29 | chat.vertx.messaging.storage.mongo;version=latest,\ 30 | org.mongodb.driver-async,\ 31 | org.mongodb.mongo-java-driver,\ 32 | chat.vertx.http;version=latest,\ 33 | chat.vertx.sockjs;version=latest,\ 34 | chat.vertx.mongo;version=latest,\ 35 | io.vertx.core;version=3.2.0,\ 36 | io.netty.buffer,\ 37 | io.netty.codec,\ 38 | io.netty.codec-http,\ 39 | io.netty.common,\ 40 | io.netty.handler,\ 41 | io.netty.transport 42 | -runsystempackages: sun.misc -------------------------------------------------------------------------------- /run/conf/org.ops4j.pax.logging.cfg: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, rootlogger 2 | log4j.appender.rootlogger=org.apache.log4j.ConsoleAppender 3 | log4j.appender.rootlogger.layout=org.apache.log4j.PatternLayout 4 | log4j.appender.rootlogger.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n 5 | log4j.logger.io.netty=warn -------------------------------------------------------------------------------- /run/conf/vertx.mongo.cfg: -------------------------------------------------------------------------------- 1 | url=mongodb://localhost:27017 2 | db=vertxchat -------------------------------------------------------------------------------- /run/src/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/run/src/.gitignore -------------------------------------------------------------------------------- /run/test/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulbakker/osgi-vertx-demo/983b4877615433a33420f735fa5d4f3a91357186/run/test/.gitignore -------------------------------------------------------------------------------- /run/webroot/app/app.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core', "./chat/ChatComponents"], function(exports_1) { 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var core_1, ChatComponents_1; 12 | var AppComponent; 13 | return { 14 | setters:[ 15 | function (core_1_1) { 16 | core_1 = core_1_1; 17 | }, 18 | function (ChatComponents_1_1) { 19 | ChatComponents_1 = ChatComponents_1_1; 20 | }], 21 | execute: function() { 22 | AppComponent = (function () { 23 | function AppComponent() { 24 | } 25 | AppComponent = __decorate([ 26 | core_1.Component({ 27 | selector: 'my-app', 28 | template: "\n

Vertx OSGi demo

\n \n ", 29 | directives: [ChatComponents_1.MessageListing], 30 | styles: ["\n\n "], 31 | }), 32 | __metadata('design:paramtypes', []) 33 | ], AppComponent); 34 | return AppComponent; 35 | })(); 36 | exports_1("AppComponent", AppComponent); 37 | } 38 | } 39 | }); 40 | //# sourceMappingURL=app.js.map -------------------------------------------------------------------------------- /run/webroot/app/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":["AppComponent","AppComponent.constructor"],"mappings":";;;;;;;;;;;;;;;;;;;;;YAGA;gBAAAA;gBAW2BC,CAACA;gBAX5BD;oBAACA,gBAASA,CAACA;wBACPA,QAAQA,EAAEA,QAAQA;wBAClBA,QAAQA,EAAEA,iEAGTA;wBACDA,UAAUA,EAAEA,CAACA,+BAAcA,CAACA;wBAC5BA,MAAMA,EAAEA,CAACA,QAEVA,CAACA;qBACHA,CAACA;;iCAC0BA;gBAADA,mBAACA;YAADA,CAACA,AAX5B,IAW4B;YAX5B,uCAW4B,CAAA"} -------------------------------------------------------------------------------- /run/webroot/app/app.ts: -------------------------------------------------------------------------------- 1 | import {Component} from 'angular2/core'; 2 | import {MessageListing} from "./chat/ChatComponents"; 3 | 4 | @Component({ 5 | selector: 'my-app', 6 | template: ` 7 |

Vertx OSGi demo

8 | 9 | `, 10 | directives: [MessageListing], 11 | styles: [` 12 | 13 | `], 14 | }) 15 | export class AppComponent {} 16 | 17 | 18 | -------------------------------------------------------------------------------- /run/webroot/app/boot.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/platform/browser', './app'], function(exports_1) { 2 | var browser_1, app_1; 3 | return { 4 | setters:[ 5 | function (browser_1_1) { 6 | browser_1 = browser_1_1; 7 | }, 8 | function (app_1_1) { 9 | app_1 = app_1_1; 10 | }], 11 | execute: function() { 12 | browser_1.bootstrap(app_1.AppComponent); 13 | } 14 | } 15 | }); 16 | //# sourceMappingURL=boot.js.map -------------------------------------------------------------------------------- /run/webroot/app/boot.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"boot.js","sourceRoot":"","sources":["boot.ts"],"names":[],"mappings":";;;;;;;;;;;YAGA,mBAAS,CAAC,kBAAY,CAAC,CAAC"} -------------------------------------------------------------------------------- /run/webroot/app/boot.ts: -------------------------------------------------------------------------------- 1 | import {bootstrap} from 'angular2/platform/browser' 2 | import {AppComponent} from './app' 3 | 4 | bootstrap(AppComponent); -------------------------------------------------------------------------------- /run/webroot/app/chat/ChatComponents.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core', "./ChatService", "./Model"], function(exports_1) { 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var core_1, ChatService_1, Model_1; 12 | var MessageListing; 13 | return { 14 | setters:[ 15 | function (core_1_1) { 16 | core_1 = core_1_1; 17 | }, 18 | function (ChatService_1_1) { 19 | ChatService_1 = ChatService_1_1; 20 | }, 21 | function (Model_1_1) { 22 | Model_1 = Model_1_1; 23 | }], 24 | execute: function() { 25 | MessageListing = (function () { 26 | function MessageListing(chatService) { 27 | var _this = this; 28 | this.chatService = chatService; 29 | this.messages = []; 30 | this.message = new Model_1.ChatMessage(); 31 | chatService.listen().subscribe(function (message) { 32 | _this.messages.push(message); 33 | }); 34 | } 35 | MessageListing.prototype.sendMessage = function () { 36 | this.chatService.send(this.message); 37 | this.message = new Model_1.ChatMessage(); 38 | }; 39 | MessageListing = __decorate([ 40 | core_1.Component({ 41 | selector: 'messages', 42 | providers: [ChatService_1.ChatService] 43 | }), 44 | core_1.View({ 45 | styles: [], 46 | template: "\n

Messages

\n
{{msg.text}}
\n \n " 47 | }), 48 | __metadata('design:paramtypes', [ChatService_1.ChatService]) 49 | ], MessageListing); 50 | return MessageListing; 51 | })(); 52 | exports_1("MessageListing", MessageListing); 53 | } 54 | } 55 | }); 56 | //# sourceMappingURL=ChatComponents.js.map -------------------------------------------------------------------------------- /run/webroot/app/chat/ChatComponents.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ChatComponents.js","sourceRoot":"","sources":["ChatComponents.ts"],"names":["MessageListing","MessageListing.constructor","MessageListing.sendMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;YAQA;gBAiBIA,wBAAoBA,WAAyBA;oBAjBjDC,iBA4BCA;oBAXuBA,gBAAWA,GAAXA,WAAWA,CAAcA;oBAH7CA,aAAQA,GAAGA,EAAEA,CAACA;oBACdA,YAAOA,GAAGA,IAAIA,mBAAWA,EAAEA,CAACA;oBAGzBA,WAAWA,CAACA,MAAMA,EAAEA,CAACA,SAASA,CAACA,UAAAA,OAAOA;wBAClCA,KAAIA,CAACA,QAAQA,CAACA,IAAIA,CAACA,OAAOA,CAACA,CAAAA;oBAC/BA,CAACA,CAACA,CAAAA;gBACLA,CAACA;gBAEDD,oCAAWA,GAAXA;oBACIE,IAAIA,CAACA,WAAWA,CAACA,IAAIA,CAACA,IAAIA,CAACA,OAAOA,CAACA,CAAAA;oBACnCA,IAAIA,CAACA,OAAOA,GAAGA,IAAIA,mBAAWA,EAAEA,CAACA;gBACrCA,CAACA;gBA1BLF;oBAACA,gBAASA,CAACA;wBACPA,QAAQA,EAAEA,UAAUA;wBACpBA,SAASA,EAAEA,CAACA,yBAAWA,CAACA;qBAC3BA,CAACA;oBACDA,WAAIA,CAACA;wBACFA,MAAMA,EAAEA,EAAEA;wBACVA,QAAQA,EAAEA,qNAITA;qBACJA,CAACA;;mCAiBDA;gBAADA,qBAACA;YAADA,CAACA,AA5BD,IA4BC;YA5BD,2CA4BC,CAAA"} -------------------------------------------------------------------------------- /run/webroot/app/chat/ChatComponents.ts: -------------------------------------------------------------------------------- 1 | import {Component, View} from 'angular2/core'; 2 | import { HTTP_PROVIDERS } from 'angular2/http' 3 | import {Observable} from 'rxjs/Observable'; 4 | import * as moment from "moment"; 5 | import {ChatService} from "./ChatService"; 6 | import {ChatMessage} from "./Model"; 7 | import {NgForm} from 'angular2/common'; 8 | 9 | @Component({ 10 | selector: 'messages', 11 | providers: [ChatService] 12 | }) 13 | @View({ 14 | styles: [], 15 | template: ` 16 |

Messages

17 |
{{msg.text}}
18 | 19 | ` 20 | }) 21 | export class MessageListing { 22 | 23 | messages = []; 24 | message = new ChatMessage(); 25 | 26 | constructor(private chatService : ChatService) { 27 | chatService.listen().subscribe(message => { 28 | this.messages.push(message) 29 | }) 30 | } 31 | 32 | sendMessage() { 33 | this.chatService.send(this.message) 34 | this.message = new ChatMessage(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /run/webroot/app/chat/ChatService.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core', 'rxjs/Observable'], function(exports_1) { 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var core_1, Observable_1; 12 | var ChatService; 13 | return { 14 | setters:[ 15 | function (core_1_1) { 16 | core_1 = core_1_1; 17 | }, 18 | function (Observable_1_1) { 19 | Observable_1 = Observable_1_1; 20 | }], 21 | execute: function() { 22 | ChatService = (function () { 23 | function ChatService() { 24 | } 25 | ChatService.prototype.listen = function () { 26 | var _this = this; 27 | return Observable_1.Observable.create(function (observer) { 28 | console.log("connecting..."); 29 | _this.eb = new EventBus('http://192.168.0.14:8080/eventbus'); 30 | _this.eb.onopen = function () { 31 | _this.eb.registerHandler('chat', function (err, message) { 32 | console.log(message.body); 33 | observer.next(JSON.parse(message.body)); 34 | }); 35 | }; 36 | }); 37 | }; 38 | ChatService.prototype.send = function (message) { 39 | this.eb.publish('chat', JSON.stringify(message)); 40 | }; 41 | ChatService = __decorate([ 42 | core_1.Injectable(), 43 | __metadata('design:paramtypes', []) 44 | ], ChatService); 45 | return ChatService; 46 | })(); 47 | exports_1("ChatService", ChatService); 48 | } 49 | } 50 | }); 51 | //# sourceMappingURL=ChatService.js.map -------------------------------------------------------------------------------- /run/webroot/app/chat/ChatService.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ChatService.js","sourceRoot":"","sources":["ChatService.ts"],"names":["ChatService","ChatService.constructor","ChatService.listen","ChatService.send"],"mappings":";;;;;;;;;;;;;;;;;;;;;YAKA;gBAAAA;gBAwBAC,CAACA;gBApBGD,4BAAMA,GAANA;oBAAAE,iBAcCA;oBAZGA,MAAMA,CAACA,uBAAUA,CAACA,MAAMA,CAACA,UAAAA,QAAQA;wBAC7BA,OAAOA,CAACA,GAAGA,CAACA,eAAeA,CAACA,CAAAA;wBAE5BA,KAAIA,CAACA,EAAEA,GAAGA,IAAIA,QAAQA,CAACA,mCAAmCA,CAACA,CAACA;wBAE5DA,KAAIA,CAACA,EAAEA,CAACA,MAAMA,GAAGA;4BACbA,KAAIA,CAACA,EAAEA,CAACA,eAAeA,CAACA,MAAMA,EAAEA,UAACA,GAAGA,EAAEA,OAAOA;gCACzCA,OAAOA,CAACA,GAAGA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAAAA;gCACzBA,QAAQA,CAACA,IAAIA,CAACA,IAAIA,CAACA,KAAKA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAACA,CAACA;4BAC5CA,CAACA,CAACA,CAACA;wBACPA,CAACA,CAAAA;oBACLA,CAACA,CAACA,CAACA;gBACPA,CAACA;gBAEDF,0BAAIA,GAAJA,UAAKA,OAAqBA;oBACtBG,IAAIA,CAACA,EAAEA,CAACA,OAAOA,CAACA,MAAMA,EAACA,IAAIA,CAACA,SAASA,CAACA,OAAOA,CAACA,CAACA,CAACA;gBACpDA,CAACA;gBAtBLH;oBAACA,iBAAUA,EAAEA;;gCAwBZA;gBAADA,kBAACA;YAADA,CAACA,AAxBD,IAwBC;YAxBD,qCAwBC,CAAA"} -------------------------------------------------------------------------------- /run/webroot/app/chat/ChatService.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from 'angular2/core' 2 | import {Observable} from 'rxjs/Observable'; 3 | import {ChatMessage} from "./Model"; 4 | 5 | 6 | @Injectable() 7 | export class ChatService { 8 | eb : EventBus_Instance; 9 | 10 | listen() : Observable { 11 | 12 | return Observable.create(observer => { 13 | console.log("connecting...") 14 | 15 | this.eb = new EventBus('http://192.168.0.14:8080/eventbus'); 16 | 17 | this.eb.onopen = () => { 18 | this.eb.registerHandler('chat', (err, message) => { 19 | console.log(message.body) 20 | observer.next(JSON.parse(message.body)); 21 | }); 22 | } 23 | }); 24 | } 25 | 26 | send(message : ChatMessage) { 27 | this.eb.publish('chat',JSON.stringify(message)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /run/webroot/app/chat/Model.js: -------------------------------------------------------------------------------- 1 | System.register([], function(exports_1) { 2 | var ChatMessage; 3 | return { 4 | setters:[], 5 | execute: function() { 6 | ChatMessage = (function () { 7 | function ChatMessage() { 8 | } 9 | return ChatMessage; 10 | })(); 11 | exports_1("ChatMessage", ChatMessage); 12 | } 13 | } 14 | }); 15 | //# sourceMappingURL=Model.js.map -------------------------------------------------------------------------------- /run/webroot/app/chat/Model.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Model.js","sourceRoot":"","sources":["Model.ts"],"names":["ChatMessage","ChatMessage.constructor"],"mappings":";;;;;YAAA;gBAAAA;gBAGAC,CAACA;gBAADD,kBAACA;YAADA,CAACA,AAHD,IAGC;YAHD,qCAGC,CAAA"} -------------------------------------------------------------------------------- /run/webroot/app/chat/Model.ts: -------------------------------------------------------------------------------- 1 | export class ChatMessage { 2 | user : string; 3 | text : string; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /run/webroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CloudRTI demo 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 24 | 25 | 26 | 27 | loading... 28 | 29 | -------------------------------------------------------------------------------- /run/webroot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cloudrti-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "tsc": "tsc", 8 | "tsc:w": "tsc -w", 9 | "lite": "lite-server", 10 | "start": "concurrent \"npm run tsc:w\" \"npm run lite\" " 11 | }, 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "angular2": "2.0.0-beta.0", 16 | "systemjs": "0.19.6", 17 | "es6-promise": "^3.0.2", 18 | "es6-shim": "^0.33.3", 19 | "reflect-metadata": "0.1.2", 20 | "rxjs": "5.0.0-beta.0", 21 | "zone.js": "0.5.10", 22 | "bootstrap": "^3.3.6", 23 | "moment": "2.10.6", 24 | "vertx3-eventbus-client": "^3.1.0" 25 | }, 26 | "devDependencies": { 27 | "concurrently": "^1.0.0", 28 | "lite-server": "^1.3.1", 29 | "typescript": "^1.7.3" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /run/webroot/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "module": "system", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | }, 12 | "exclude": [ 13 | "node_modules" 14 | ] 15 | } -------------------------------------------------------------------------------- /run/webroot/typings/VertxEventBus.d.ts: -------------------------------------------------------------------------------- 1 | interface EventBus_Static { 2 | new(address : string) : EventBus_Instance; 3 | } 4 | 5 | interface EventBus_Instance { 6 | onopen : () => void; 7 | registerHandler(address : string, callback : (err : any, message : any) => void) : void; 8 | send(address : string, message : any) : void; 9 | publish(address : string, message: any) : void; 10 | } 11 | 12 | declare var EventBus : EventBus_Static; -------------------------------------------------------------------------------- /run/webroot/typings/moment/moment-node.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Moment.js 2.8.0 2 | // Project: https://github.com/timrwood/moment 3 | // Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | declare module moment { 7 | 8 | interface MomentInput { 9 | /** Year */ 10 | years?: number; 11 | /** Year */ 12 | year?: number; 13 | /** Year */ 14 | y?: number; 15 | 16 | /** Month */ 17 | months?: number; 18 | /** Month */ 19 | month?: number; 20 | /** Month */ 21 | M?: number; 22 | 23 | /** Week */ 24 | weeks?: number; 25 | /** Week */ 26 | week?: number; 27 | /** Week */ 28 | w?: number; 29 | 30 | /** Day/Date */ 31 | days?: number; 32 | /** Day/Date */ 33 | day?: number; 34 | /** Day/Date */ 35 | date?: number; 36 | /** Day/Date */ 37 | d?: number; 38 | 39 | /** Hour */ 40 | hours?: number; 41 | /** Hour */ 42 | hour?: number; 43 | /** Hour */ 44 | h?: number; 45 | 46 | /** Minute */ 47 | minutes?: number; 48 | /** Minute */ 49 | minute?: number; 50 | /** Minute */ 51 | m?: number; 52 | 53 | /** Second */ 54 | seconds?: number; 55 | /** Second */ 56 | second?: number; 57 | /** Second */ 58 | s?: number; 59 | 60 | /** Millisecond */ 61 | milliseconds?: number; 62 | /** Millisecond */ 63 | millisecond?: number; 64 | /** Millisecond */ 65 | ms?: number; 66 | } 67 | 68 | interface Duration { 69 | humanize(withSuffix?: boolean): string; 70 | 71 | as(units: string): number; 72 | 73 | milliseconds(): number; 74 | asMilliseconds(): number; 75 | 76 | seconds(): number; 77 | asSeconds(): number; 78 | 79 | minutes(): number; 80 | asMinutes(): number; 81 | 82 | hours(): number; 83 | asHours(): number; 84 | 85 | days(): number; 86 | asDays(): number; 87 | 88 | months(): number; 89 | asMonths(): number; 90 | 91 | years(): number; 92 | asYears(): number; 93 | 94 | add(n: number, p: string): Duration; 95 | add(n: number): Duration; 96 | add(d: Duration): Duration; 97 | 98 | subtract(n: number, p: string): Duration; 99 | subtract(n: number): Duration; 100 | subtract(d: Duration): Duration; 101 | 102 | toISOString(): string; 103 | toJSON(): string; 104 | } 105 | 106 | interface Moment { 107 | format(format: string): string; 108 | format(): string; 109 | 110 | fromNow(withoutSuffix?: boolean): string; 111 | 112 | startOf(unitOfTime: string): Moment; 113 | endOf(unitOfTime: string): Moment; 114 | 115 | /** 116 | * Mutates the original moment by adding time. (deprecated in 2.8.0) 117 | * 118 | * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 119 | * @param amount the amount you want to add 120 | */ 121 | add(unitOfTime: string, amount: number): Moment; 122 | /** 123 | * Mutates the original moment by adding time. 124 | * 125 | * @param amount the amount you want to add 126 | * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 127 | */ 128 | add(amount: number, unitOfTime: string): Moment; 129 | /** 130 | * Mutates the original moment by adding time. Note that the order of arguments can be flipped. 131 | * 132 | * @param amount the amount you want to add 133 | * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 134 | */ 135 | add(amount: string, unitOfTime: string): Moment; 136 | /** 137 | * Mutates the original moment by adding time. 138 | * 139 | * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} 140 | */ 141 | add(objectLiteral: MomentInput): Moment; 142 | /** 143 | * Mutates the original moment by adding time. 144 | * 145 | * @param duration a length of time 146 | */ 147 | add(duration: Duration): Moment; 148 | 149 | /** 150 | * Mutates the original moment by subtracting time. (deprecated in 2.8.0) 151 | * 152 | * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 153 | * @param amount the amount you want to subtract 154 | */ 155 | subtract(unitOfTime: string, amount: number): Moment; 156 | /** 157 | * Mutates the original moment by subtracting time. 158 | * 159 | * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 160 | * @param amount the amount you want to subtract 161 | */ 162 | subtract(amount: number, unitOfTime: string): Moment; 163 | /** 164 | * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. 165 | * 166 | * @param amount the amount you want to add 167 | * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 168 | */ 169 | subtract(amount: string, unitOfTime: string): Moment; 170 | /** 171 | * Mutates the original moment by subtracting time. 172 | * 173 | * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} 174 | */ 175 | subtract(objectLiteral: MomentInput): Moment; 176 | /** 177 | * Mutates the original moment by subtracting time. 178 | * 179 | * @param duration a length of time 180 | */ 181 | subtract(duration: Duration): Moment; 182 | 183 | calendar(): string; 184 | calendar(start: Moment): string; 185 | calendar(start: Moment, formats: MomentCalendar): string; 186 | 187 | clone(): Moment; 188 | 189 | /** 190 | * @return Unix timestamp, or milliseconds since the epoch. 191 | */ 192 | valueOf(): number; 193 | 194 | local(): Moment; // current date/time in local mode 195 | 196 | utc(): Moment; // current date/time in UTC mode 197 | 198 | isValid(): boolean; 199 | invalidAt(): number; 200 | 201 | year(y: number): Moment; 202 | year(): number; 203 | quarter(): number; 204 | quarter(q: number): Moment; 205 | month(M: number): Moment; 206 | month(M: string): Moment; 207 | month(): number; 208 | day(d: number): Moment; 209 | day(d: string): Moment; 210 | day(): number; 211 | date(d: number): Moment; 212 | date(): number; 213 | hour(h: number): Moment; 214 | hour(): number; 215 | hours(h: number): Moment; 216 | hours(): number; 217 | minute(m: number): Moment; 218 | minute(): number; 219 | minutes(m: number): Moment; 220 | minutes(): number; 221 | second(s: number): Moment; 222 | second(): number; 223 | seconds(s: number): Moment; 224 | seconds(): number; 225 | millisecond(ms: number): Moment; 226 | millisecond(): number; 227 | milliseconds(ms: number): Moment; 228 | milliseconds(): number; 229 | weekday(): number; 230 | weekday(d: number): Moment; 231 | isoWeekday(): number; 232 | isoWeekday(d: number): Moment; 233 | weekYear(): number; 234 | weekYear(d: number): Moment; 235 | isoWeekYear(): number; 236 | isoWeekYear(d: number): Moment; 237 | week(): number; 238 | week(d: number): Moment; 239 | weeks(): number; 240 | weeks(d: number): Moment; 241 | isoWeek(): number; 242 | isoWeek(d: number): Moment; 243 | isoWeeks(): number; 244 | isoWeeks(d: number): Moment; 245 | weeksInYear(): number; 246 | isoWeeksInYear(): number; 247 | dayOfYear(): number; 248 | dayOfYear(d: number): Moment; 249 | 250 | from(f: Moment|string|number|Date|number[], suffix?: boolean): string; 251 | to(f: Moment|string|number|Date|number[], suffix?: boolean): string; 252 | toNow(withoutPrefix?: boolean): string; 253 | 254 | diff(b: Moment): number; 255 | diff(b: Moment, unitOfTime: string): number; 256 | diff(b: Moment, unitOfTime: string, round: boolean): number; 257 | 258 | toArray(): number[]; 259 | toDate(): Date; 260 | toISOString(): string; 261 | toJSON(): string; 262 | unix(): number; 263 | 264 | isLeapYear(): boolean; 265 | zone(): number; 266 | zone(b: number): Moment; 267 | zone(b: string): Moment; 268 | utcOffset(): number; 269 | utcOffset(b: number): Moment; 270 | utcOffset(b: string): Moment; 271 | daysInMonth(): number; 272 | isDST(): boolean; 273 | 274 | isBefore(): boolean; 275 | isBefore(b: Moment|string|number|Date|number[], granularity?: string): boolean; 276 | 277 | isAfter(): boolean; 278 | isAfter(b: Moment|string|number|Date|number[], granularity?: string): boolean; 279 | 280 | isSame(b: Moment|string|number|Date|number[], granularity?: string): boolean; 281 | isBetween(a: Moment|string|number|Date|number[], b: Moment|string|number|Date|number[], granularity?: string): boolean; 282 | 283 | // Deprecated as of 2.8.0. 284 | lang(language: string): Moment; 285 | lang(reset: boolean): Moment; 286 | lang(): MomentLanguage; 287 | 288 | locale(language: string): Moment; 289 | locale(reset: boolean): Moment; 290 | locale(): string; 291 | 292 | localeData(language: string): Moment; 293 | localeData(reset: boolean): Moment; 294 | localeData(): MomentLanguage; 295 | 296 | // Deprecated as of 2.7.0. 297 | max(date: Moment|string|number|Date|any[]): Moment; 298 | max(date: string, format: string): Moment; 299 | 300 | // Deprecated as of 2.7.0. 301 | min(date: Moment|string|number|Date|any[]): Moment; 302 | min(date: string, format: string): Moment; 303 | 304 | get(unit: string): number; 305 | set(unit: string, value: number): Moment; 306 | set(objectLiteral: MomentInput): Moment; 307 | } 308 | 309 | type formatFunction = () => string; 310 | 311 | interface MomentCalendar { 312 | lastDay?: string | formatFunction; 313 | sameDay?: string | formatFunction; 314 | nextDay?: string | formatFunction; 315 | lastWeek?: string | formatFunction; 316 | nextWeek?: string | formatFunction; 317 | sameElse?: string | formatFunction; 318 | } 319 | 320 | interface BaseMomentLanguage { 321 | months ?: any; 322 | monthsShort ?: any; 323 | weekdays ?: any; 324 | weekdaysShort ?: any; 325 | weekdaysMin ?: any; 326 | relativeTime ?: MomentRelativeTime; 327 | meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; 328 | calendar ?: MomentCalendar; 329 | ordinal ?: (num: number) => string; 330 | } 331 | 332 | interface MomentLanguage extends BaseMomentLanguage { 333 | longDateFormat?: MomentLongDateFormat; 334 | } 335 | 336 | interface MomentLanguageData extends BaseMomentLanguage { 337 | /** 338 | * @param formatType should be L, LL, LLL, LLLL. 339 | */ 340 | longDateFormat(formatType: string): string; 341 | } 342 | 343 | interface MomentLongDateFormat { 344 | L: string; 345 | LL: string; 346 | LLL: string; 347 | LLLL: string; 348 | LT: string; 349 | LTS: string; 350 | l?: string; 351 | ll?: string; 352 | lll?: string; 353 | llll?: string; 354 | lt?: string; 355 | lts?: string; 356 | } 357 | 358 | interface MomentRelativeTime { 359 | future: any; 360 | past: any; 361 | s: any; 362 | m: any; 363 | mm: any; 364 | h: any; 365 | hh: any; 366 | d: any; 367 | dd: any; 368 | M: any; 369 | MM: any; 370 | y: any; 371 | yy: any; 372 | } 373 | 374 | interface MomentStatic { 375 | version: string; 376 | fn: Moment; 377 | 378 | (): Moment; 379 | (date: number): Moment; 380 | (date: number[]): Moment; 381 | (date: string, format?: string, strict?: boolean): Moment; 382 | (date: string, format?: string, language?: string, strict?: boolean): Moment; 383 | (date: string, formats: string[], strict?: boolean): Moment; 384 | (date: string, formats: string[], language?: string, strict?: boolean): Moment; 385 | (date: string, specialFormat: () => void, strict?: boolean): Moment; 386 | (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; 387 | (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; 388 | (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; 389 | (date: Date): Moment; 390 | (date: Moment): Moment; 391 | (date: Object): Moment; 392 | 393 | utc(): Moment; 394 | utc(date: number): Moment; 395 | utc(date: number[]): Moment; 396 | utc(date: string, format?: string, strict?: boolean): Moment; 397 | utc(date: string, format?: string, language?: string, strict?: boolean): Moment; 398 | utc(date: string, formats: string[], strict?: boolean): Moment; 399 | utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; 400 | utc(date: Date): Moment; 401 | utc(date: Moment): Moment; 402 | utc(date: Object): Moment; 403 | 404 | unix(timestamp: number): Moment; 405 | 406 | invalid(parsingFlags?: Object): Moment; 407 | isMoment(): boolean; 408 | isMoment(m: any): boolean; 409 | isDate(m: any): boolean; 410 | isDuration(): boolean; 411 | isDuration(d: any): boolean; 412 | 413 | // Deprecated in 2.8.0. 414 | lang(language?: string): string; 415 | lang(language?: string, definition?: MomentLanguage): string; 416 | 417 | locale(language?: string): string; 418 | locale(language?: string[]): string; 419 | locale(language?: string, definition?: MomentLanguage): string; 420 | 421 | localeData(language?: string): MomentLanguageData; 422 | 423 | longDateFormat: any; 424 | relativeTime: any; 425 | meridiem: (hour: number, minute: number, isLowercase: boolean) => string; 426 | calendar: any; 427 | ordinal: (num: number) => string; 428 | 429 | duration(milliseconds: Number): Duration; 430 | duration(num: Number, unitOfTime: string): Duration; 431 | duration(input: MomentInput): Duration; 432 | duration(object: any): Duration; 433 | duration(): Duration; 434 | 435 | parseZone(date: string): Moment; 436 | 437 | months(): string[]; 438 | months(index: number): string; 439 | months(format: string): string[]; 440 | months(format: string, index: number): string; 441 | monthsShort(): string[]; 442 | monthsShort(index: number): string; 443 | monthsShort(format: string): string[]; 444 | monthsShort(format: string, index: number): string; 445 | 446 | weekdays(): string[]; 447 | weekdays(index: number): string; 448 | weekdays(format: string): string[]; 449 | weekdays(format: string, index: number): string; 450 | weekdaysShort(): string[]; 451 | weekdaysShort(index: number): string; 452 | weekdaysShort(format: string): string[]; 453 | weekdaysShort(format: string, index: number): string; 454 | weekdaysMin(): string[]; 455 | weekdaysMin(index: number): string; 456 | weekdaysMin(format: string): string[]; 457 | weekdaysMin(format: string, index: number): string; 458 | 459 | min(...moments: Moment[]): Moment; 460 | max(...moments: Moment[]): Moment; 461 | 462 | normalizeUnits(unit: string): string; 463 | relativeTimeThreshold(threshold: string): number|boolean; 464 | relativeTimeThreshold(threshold: string, limit:number): boolean; 465 | 466 | /** 467 | * Constant used to enable explicit ISO_8601 format parsing. 468 | */ 469 | ISO_8601(): void; 470 | 471 | defaultFormat: string; 472 | } 473 | 474 | } 475 | 476 | declare module 'moment' { 477 | var moment: moment.MomentStatic; 478 | export = moment; 479 | } 480 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Master Gradle initialization script 3 | * 4 | * Depends on bnd_* values from gradle.properties. 5 | */ 6 | 7 | import aQute.bnd.build.Workspace 8 | import aQute.bnd.osgi.Constants 9 | 10 | /* Add bnd gradle plugin as a script dependency */ 11 | buildscript { 12 | repositories { 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath bnd_plugin 17 | } 18 | /* Pass bnd gradle plugin classpath to rootProject once created */ 19 | def bndPlugin = files(configurations.classpath.files) 20 | gradle.rootProject { rootProject -> 21 | rootProject.ext.bndPlugin = bndPlugin 22 | } 23 | } 24 | 25 | /* Initialize the bnd workspace */ 26 | Workspace.setDriver(Constants.BNDDRIVER_GRADLE) 27 | Workspace.addGestalt(Constants.GESTALT_BATCH, null) 28 | def workspace = new Workspace(rootDir, bnd_cnf) 29 | if (workspace == null) { 30 | throw new GradleException("Unable to load workspace ${rootDir}/${bnd_cnf}") 31 | } 32 | 33 | /* Add cnf project to the graph */ 34 | include bnd_cnf 35 | 36 | /* Start with the declared build project name */ 37 | def defaultProjectName = bnd_build 38 | 39 | /* If in a subproject, use the subproject name */ 40 | for (def currentDir = startParameter.currentDir; currentDir != rootDir; currentDir = currentDir.parentFile) { 41 | defaultProjectName = currentDir.name 42 | } 43 | 44 | /* Build a set of project names we need to include from the specified tasks */ 45 | def projectNames = startParameter.taskNames.collect { taskName -> 46 | def elements = taskName.split(':') 47 | switch (elements.length) { 48 | case 1: 49 | return defaultProjectName 50 | case 2: 51 | return elements[0].empty ? bnd_build : elements[0] 52 | default: 53 | return elements[0].empty ? elements[1] : elements[0] 54 | } 55 | }.toSet() 56 | 57 | /* Include the default project name if in a subproject or no tasks specified */ 58 | if ((startParameter.currentDir != rootDir) || projectNames.empty) { 59 | projectNames += defaultProjectName 60 | } 61 | 62 | /* If bnd_build used but declared empty, add all non-private folders of rootDir */ 63 | if (projectNames.remove('')) { 64 | rootDir.eachDir { 65 | def projectName = it.name 66 | if (!projectName.startsWith('.')) { 67 | projectNames += projectName 68 | } 69 | } 70 | } 71 | 72 | /* Add each project and its dependencies to the graph */ 73 | projectNames.each { projectName -> 74 | include projectName 75 | def project = getBndProject(workspace, projectName) 76 | project?.getDependson()*.getName().each { 77 | include it 78 | } 79 | } 80 | 81 | /* Get the bnd project for the specified project name */ 82 | def getBndProject(Workspace workspace, String projectName) { 83 | def project = workspace.getProject(projectName) 84 | if (project == null) { 85 | return null 86 | } 87 | project.prepare() 88 | if (project.isValid()) { 89 | return project 90 | } 91 | 92 | project.getInfo(workspace, "${rootDir} :") 93 | def errorCount = 0 94 | project.getWarnings().each { 95 | println "Warning: ${it}" 96 | } 97 | project.getErrors().each { 98 | println "Error : ${it}" 99 | errorCount++ 100 | } 101 | if (!project.isOk()) { 102 | def str = 'even though no errors were reported' 103 | if (errorCount == 1) { 104 | str = 'one error was reported' 105 | } else if (errorCount > 1) { 106 | str = "${errorCount} errors were reported" 107 | } 108 | throw new GradleException("Project ${rootDir}/${projectName} is invalid, ${str}") 109 | } 110 | throw new GradleException("Project ${rootDir}/${projectName} is not a valid bnd project") 111 | } 112 | --------------------------------------------------------------------------------