├── .gitignore
├── LICENSE
├── README.md
├── nb-configuration.xml
├── pom.xml
└── src
└── main
├── java
└── org
│ └── glassfish
│ └── javaee
│ └── javascript
│ └── backend
│ ├── chat
│ ├── ChatMessage.java
│ └── ChatServer.java
│ └── todo
│ ├── DefaultToDoItemRepository.java
│ ├── DefaultToDoService.java
│ ├── JsonMoxyConfigurationContextResolver.java
│ ├── RestConfiguration.java
│ ├── ToDoItem.java
│ ├── ToDoItemRepository.java
│ ├── ToDoResource.java
│ └── ToDoService.java
├── resources
├── META-INF
│ └── persistence.xml
├── create-script.sql
├── drop-script.sql
└── load-script.sql
└── webapp
├── WEB-INF
├── beans.xml
├── glassfish-web.xml
└── web.xml
├── backend.html
├── chat.jsp
├── css
├── .gitkeep
├── chat
│ └── application.css
├── lib
│ └── angular-growl.min.css
└── todo
│ └── application.css
├── images
└── remove.png
├── index.html
├── javascript
├── chat
│ ├── application.js
│ ├── controllers.js
│ ├── directives.js
│ └── services.js
├── lib
│ └── angular-growl.min.js
└── todo
│ ├── application.js
│ ├── controllers.js
│ ├── directives.js
│ └── services.js
└── todo.jsp
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Package Files #
4 | *.jar
5 | *.war
6 | *.ear
7 | .classpath
8 | .project
9 | .settings
10 | target
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1
2 |
3 | 1. Definitions.
4 |
5 | 1.1. "Contributor" means each individual or entity that creates or contributes to the creation of
6 |
7 | Modifications.
8 |
9 | 1.2. "Contributor Version" means the combination of the Original Software, prior Modifications used by a
10 |
11 | Contributor (if any), and the Modifications made by that particular Contributor.
12 |
13 | 1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, or (c) the combination of
14 |
15 | files containing Original Software with files containing Modifications, in each case including portions
16 |
17 | thereof.
18 |
19 | 1.4. "Executable" means the Covered Software in any form other than Source Code.
20 |
21 | 1.5. "Initial Developer" means the individual or entity that first makes Original Software available under
22 |
23 | this License.
24 |
25 | 1.6. "Larger Work" means a work which combines Covered Software or portions thereof with code not governed
26 |
27 | by the terms of this License.
28 |
29 | 1.7. "License" means this document.
30 |
31 | 1.8. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of
32 |
33 | the initial grant or subsequently acquired, any and all of the rights conveyed herein.
34 |
35 | 1.9. "Modifications" means the Source Code and Executable form of any of the following:
36 |
37 | A. Any file that results from an addition to, deletion from or modification of the contents of a file
38 |
39 | containing Original Software or previous Modifications;
40 |
41 | B. Any new file that contains any part of the Original Software or previous Modification; or
42 |
43 | C. Any new file that is contributed or otherwise made available under the terms of this License.
44 |
45 | 1.10. "Original Software" means the Source Code and Executable form of computer software code that is
46 |
47 | originally released under this License.
48 |
49 | 1.11. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without
50 |
51 | limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
52 |
53 | 1.12. "Source Code" means (a) the common form of computer software code in which modifications are made
54 |
55 | and (b) associated documentation included in or with such code.
56 |
57 | 1.13. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with
58 |
59 | all of the terms of, this License. For legal entities, "You" includes any entity which controls, is controlled
60 |
61 | by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct
62 |
63 | or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b)
64 |
65 | ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
66 |
67 | 2. License Grants.
68 |
69 | 2.1. The Initial Developer Grant.
70 |
71 | Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property
72 |
73 | claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
74 |
75 | (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer,
76 |
77 | to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions
78 |
79 | thereof), with or without Modifications, and/or as part of a Larger Work; and
80 |
81 | (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have
82 |
83 | made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions
84 |
85 | thereof).
86 |
87 | (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first
88 |
89 | distributes or otherwise makes the Original Software available to a third party under the terms of this
90 |
91 | License.
92 |
93 | (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from
94 |
95 | the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or
96 |
97 | (ii) the combination of the Original Software with other software or devices.
98 |
99 | 2.2. Contributor Grant.
100 |
101 | Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property
102 |
103 | claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
104 |
105 | (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use,
106 |
107 | reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor
108 |
109 | (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as
110 |
111 | part of a Larger Work; and
112 |
113 | (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that
114 |
115 | Contributor either alone and/or in combination with its Contributor Version (or portions of such combination),
116 |
117 | to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that
118 |
119 | Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its
120 |
121 | Contributor Version (or portions of such combination).
122 |
123 | (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first
124 |
125 | distributes or otherwise makes the Modifications available to a third party.
126 |
127 | (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor
128 |
129 | has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of
130 |
131 | Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software
132 |
133 | (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered
134 |
135 | Software in the absence of Modifications made by that Contributor.
136 |
137 | 3. Distribution Obligations.
138 |
139 | 3.1. Availability of Source Code.
140 |
141 | Any Covered Software that You distribute or otherwise make available in Executable form must also be made
142 |
143 | available in Source Code form and that Source Code form must be distributed only under the terms of this
144 |
145 | License. You must include a copy of this License with every copy of the Source Code form of the Covered
146 |
147 | Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in
148 |
149 | Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on
150 |
151 | or through a medium customarily used for software exchange.
152 |
153 | 3.2. Modifications.
154 |
155 | The Modifications that You create or to which You contribute are governed by the terms of this License.
156 |
157 | You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient
158 |
159 | rights to grant the rights conveyed by this License.
160 |
161 | 3.3. Required Notices.
162 |
163 | You must include a notice in each of Your Modifications that identifies You as the Contributor of the
164 |
165 | Modification. You may not remove or alter any copyright, patent or trademark notices contained within the
166 |
167 | Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or
168 |
169 | the Initial Developer.
170 |
171 | 3.4. Application of Additional Terms.
172 |
173 | You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts
174 |
175 | the applicable version of this License or the recipients' rights hereunder. You may choose to offer, and to
176 |
177 | charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered
178 |
179 | Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any
180 |
181 | Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability
182 |
183 | obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every
184 |
185 | Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty,
186 |
187 | support, indemnity or liability terms You offer.
188 |
189 | 3.5. Distribution of Executable Versions.
190 |
191 | You may distribute the Executable form of the Covered Software under the terms of this License or under
192 |
193 | the terms of a license of Your choice, which may contain terms different from this License, provided that You
194 |
195 | are in compliance with the terms of this License and that the license for the Executable form does not attempt
196 |
197 | to limit or alter the recipient's rights in the Source Code form from the rights set forth in this License. If
198 |
199 | You distribute the Covered Software in Executable form under a different license, You must make it absolutely
200 |
201 | clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or
202 |
203 | Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability
204 |
205 | incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
206 |
207 | 3.6. Larger Works.
208 |
209 | You may create a Larger Work by combining Covered Software with other code not governed by the terms of
210 |
211 | this License and distribute the Larger Work as a single product. In such a case, You must make sure the
212 |
213 | requirements of this License are fulfilled for the Covered Software.
214 |
215 | 4. Versions of the License.
216 |
217 | 4.1. New Versions.
218 |
219 | Oracle is the initial license steward and may publish revised and/or new versions of this License from
220 |
221 | time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no
222 |
223 | one other than the license steward has the right to modify this License.
224 |
225 | 4.2. Effect of New Versions.
226 |
227 | You may always continue to use, distribute or otherwise make the Covered Software available under the
228 |
229 | terms of the version of the License under which You originally received the Covered Software. If the Initial
230 |
231 | Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made
232 |
233 | available under any subsequent version of the License, You must distribute and make the Covered Software
234 |
235 | available under the terms of the version of the License under which You originally received the Covered
236 |
237 | Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available
238 |
239 | under the terms of any subsequent version of the License published by the license steward.
240 |
241 | 4.3. Modified Versions.
242 |
243 | When You are an Initial Developer and You want to create a new license for Your Original Software, You may
244 |
245 | create and use a modified version of this License if You: (a) rename the license and remove any references to
246 |
247 | the name of the license steward (except to note that the license differs from this License); and (b) otherwise
248 |
249 | make it clear that the license contains terms which differ from this License.
250 |
251 | 5. DISCLAIMER OF WARRANTY.
252 |
253 | COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER
254 |
255 | EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS,
256 |
257 | MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
258 |
259 | OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
260 |
261 | INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION.
262 |
263 | THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS
264 |
265 | AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
266 |
267 | 6. TERMINATION.
268 |
269 | 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with
270 |
271 | terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by
272 |
273 | their nature, must remain in effect beyond the termination of this License shall survive.
274 |
275 | 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial
276 |
277 | Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred
278 |
279 | to as "Participant") alleging that the Participant Software (meaning the Contributor Version where the
280 |
281 | Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly
282 |
283 | or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such
284 |
285 | Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under
286 |
287 | Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and
288 |
289 | automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw
290 |
291 | Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to
292 |
293 | a written agreement with Participant.
294 |
295 | 6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software
296 |
297 | directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement)
298 |
299 | prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by
300 |
301 | such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of
302 |
303 | any payment or license.
304 |
305 | 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been
306 |
307 | validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by
308 |
309 | any distributor) shall survive termination.
310 |
311 | 7. LIMITATION OF LIABILITY.
312 |
313 | UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR
314 |
315 | OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR
316 |
317 | ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
318 |
319 | CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK
320 |
321 | STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH
322 |
323 | PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY
324 |
325 | TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
326 |
327 | PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
328 |
329 | CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
330 |
331 | 8. U.S. GOVERNMENT END USERS.
332 |
333 | The Covered Software is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995),
334 |
335 | consisting of "commercial computer software" (as that term is defined at 48 C.F.R. ? 252.227-7014(a)(1)) and
336 |
337 | "commercial computer software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 1995).
338 |
339 | Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government
340 |
341 | End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause
342 |
343 | is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government
344 |
345 | rights in computer software under this License.
346 |
347 | 9. MISCELLANEOUS.
348 |
349 | This License represents the complete agreement concerning subject matter hereof. If any provision of this
350 |
351 | License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it
352 |
353 | enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained
354 |
355 | within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such
356 |
357 | jurisdiction's conflict-of-law provisions. Any litigation relating to this License shall be subject to the
358 |
359 | jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the
360 |
361 | Original Software, with the losing party responsible for costs, including, without limitation, court costs and
362 |
363 | reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the
364 |
365 | International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a
366 |
367 | contract shall be construed against the drafter shall not apply to this License. You agree that You alone are
368 |
369 | responsible for compliance with the United States export administration regulations (and the export control
370 |
371 | laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered
372 |
373 | Software.
374 |
375 | 10. RESPONSIBILITY FOR CLAIMS.
376 |
377 | As between Initial Developer and the Contributors, each party is responsible for claims and damages
378 |
379 | arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with
380 |
381 | Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is
382 |
383 | intended or shall be deemed to constitute any admission of liability.
384 |
385 | ----------
386 | NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
387 | The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-
388 |
389 | of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal
390 |
391 | Courts of the Northern District of California and the state courts of the State of California, with venue lying
392 |
393 | in Santa Clara County, California.
394 |
395 |
396 |
397 |
398 | The GNU General Public License (GPL) Version 2, June 1991
399 |
400 |
401 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
402 |
403 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not
404 |
405 | allowed.
406 |
407 | Preamble
408 |
409 | The licenses for most software are designed to take away your freedom to share and change it. By contrast, the
410 |
411 | GNU General Public License is intended to guarantee your freedom to share and change free software--to make
412 |
413 | sure the software is free for all its users. This General Public License applies to most of the Free Software
414 |
415 | Foundation's software and to any other program whose authors commit to using it. (Some other Free Software
416 |
417 | Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your
418 |
419 | programs, too.
420 |
421 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are
422 |
423 | designed to make sure that you have the freedom to distribute copies of free software (and charge for this
424 |
425 | service if you wish), that you receive source code or can get it if you want it, that you can change the
426 |
427 | software or use pieces of it in new free programs; and that you know you can do these things.
428 |
429 | To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you
430 |
431 | to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute
432 |
433 | copies of the software, or if you modify it.
434 |
435 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the
436 |
437 | recipients all the rights that you have. You must make sure that they, too, receive or can get the source code.
438 |
439 | And you must show them these terms so they know their rights.
440 |
441 | We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives
442 |
443 | you legal permission to copy, distribute and/or modify the software.
444 |
445 | Also, for each author's protection and ours, we want to make certain that everyone understands that there is no
446 |
447 | warranty for this free software. If the software is modified by someone else and passed on, we want its
448 |
449 | recipients to know that what they have is not the original, so that any problems introduced by others will not
450 |
451 | reflect on the original authors' reputations.
452 |
453 | Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that
454 |
455 | redistributors of a free program will individually obtain patent licenses, in effect making the program
456 |
457 | proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or
458 |
459 | not licensed at all.
460 |
461 | The precise terms and conditions for copying, distribution and modification follow.
462 |
463 |
464 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
465 |
466 | 0. This License applies to any program or other work which contains a notice placed by the copyright holder
467 |
468 | saying it may be distributed under the terms of this General Public License. The "Program", below, refers to
469 |
470 | any such program or work, and a "work based on the Program" means either the Program or any derivative work
471 |
472 | under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with
473 |
474 | modifications and/or translated into another language. (Hereinafter, translation is included without limitation
475 |
476 | in the term "modification".) Each licensee is addressed as "you".
477 |
478 | Activities other than copying, distribution and modification are not covered by this License; they are outside
479 |
480 | its scope. The act of running the Program is not restricted, and the output from the Program is covered only if
481 |
482 | its contents constitute a work based on the Program (independent of having been made by running the Program).
483 |
484 | Whether that is true depends on what the Program does.
485 |
486 | 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium,
487 |
488 | provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and
489 |
490 | disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any
491 |
492 | warranty; and give any other recipients of the Program a copy of this License along with the Program.
493 |
494 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty
495 |
496 | protection in exchange for a fee.
497 |
498 | 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the
499 |
500 | Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that
501 |
502 | you also meet all of these conditions:
503 |
504 | a) You must cause the modified files to carry prominent notices stating that you changed the files and the
505 |
506 | date of any change.
507 |
508 | b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived
509 |
510 | from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the
511 |
512 | terms of this License.
513 |
514 | c) If the modified program normally reads commands interactively when run, you must cause it, when started
515 |
516 | running for such interactive use in the most ordinary way, to print or display an announcement including an
517 |
518 | appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a
519 |
520 | warranty) and that users may redistribute the program under these conditions, and telling the user how to view
521 |
522 | a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an
523 |
524 | announcement, your work based on the Program is not required to print an announcement.)
525 |
526 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived
527 |
528 | from the Program, and can be reasonably considered independent and separate works in themselves, then this
529 |
530 | License, and its terms, do not apply to those sections when you distribute them as separate works. But when you
531 |
532 | distribute the same sections as part of a whole which is a work based on the Program, the distribution of the
533 |
534 | whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole,
535 |
536 | and thus to each and every part regardless of who wrote it.
537 |
538 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by
539 |
540 | you; rather, the intent is to exercise the right to control the distribution of derivative or collective works
541 |
542 | based on the Program.
543 |
544 | In addition, mere aggregation of another work not based on the Program with the Program (or with a work based
545 |
546 | on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope
547 |
548 | of this License.
549 |
550 | 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or
551 |
552 | executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
553 |
554 | a) Accompany it with the complete corresponding machine-readable source code, which must be distributed
555 |
556 | under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
557 |
558 | b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge
559 |
560 | no more than your cost of physically performing source distribution, a complete machine-readable copy of the
561 |
562 | corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily
563 |
564 | used for software interchange; or,
565 |
566 | c) Accompany it with the information you received as to the offer to distribute corresponding source code.
567 |
568 | (This alternative is allowed only for noncommercial distribution and only if you received the program in object
569 |
570 | code or executable form with such an offer, in accord with Subsection b above.)
571 |
572 | The source code for a work means the preferred form of the work for making modifications to it. For an
573 |
574 | executable work, complete source code means all the source code for all modules it contains, plus any
575 |
576 | associated interface definition files, plus the scripts used to control compilation and installation of the
577 |
578 | executable. However, as a special exception, the source code distributed need not include anything that is
579 |
580 | normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on)
581 |
582 | of the operating system on which the executable runs, unless that component itself accompanies the executable.
583 |
584 | If distribution of executable or object code is made by offering access to copy from a designated place, then
585 |
586 | offering equivalent access to copy the source code from the same place counts as distribution of the source
587 |
588 | code, even though third parties are not compelled to copy the source along with the object code.
589 |
590 | 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this
591 |
592 | License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will
593 |
594 | automatically terminate your rights under this License. However, parties who have received copies, or rights,
595 |
596 | from you under this License will not have their licenses terminated so long as such parties remain in full
597 |
598 | compliance.
599 |
600 | 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you
601 |
602 | permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if
603 |
604 | you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the
605 |
606 | Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying,
607 |
608 | distributing or modifying the Program or works based on it.
609 |
610 | 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically
611 |
612 | receives a license from the original licensor to copy, distribute or modify the Program subject to these terms
613 |
614 | and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted
615 |
616 | herein. You are not responsible for enforcing compliance by third parties to this License.
617 |
618 | 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not
619 |
620 | limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that
621 |
622 | contradict the conditions of this License, they do not excuse you from the conditions of this License. If you
623 |
624 | cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent
625 |
626 | obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license
627 |
628 | would not permit royalty-free redistribution of the Program by all those who receive copies directly or
629 |
630 | indirectly through you, then the only way you could satisfy both it and this License would be to refrain
631 |
632 | entirely from distribution of the Program.
633 |
634 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance
635 |
636 | of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
637 |
638 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or
639 |
640 | to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the
641 |
642 | free software distribution system, which is implemented by public license practices. Many people have made
643 |
644 | generous contributions to the wide range of software distributed through that system in reliance on consistent
645 |
646 | application of that system; it is up to the author/donor to decide if he or she is willing to distribute
647 |
648 | software through any other system and a licensee cannot impose that choice.
649 |
650 | This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this
651 |
652 | License.
653 |
654 | 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by
655 |
656 | copyrighted interfaces, the original copyright holder who places the Program under this License may add an
657 |
658 | explicit geographical distribution limitation excluding those countries, so that distribution is permitted only
659 |
660 | in or among countries not thus excluded. In such case, this License incorporates the limitation as if written
661 |
662 | in the body of this License.
663 |
664 | 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time
665 |
666 | to time. Such new versions will be similar in spirit to the present version, but may differ in detail to
667 |
668 | address new problems or concerns.
669 |
670 | Each version is given a distinguishing version number. If the Program specifies a version number of this
671 |
672 | License which applies to it and "any later version", you have the option of following the terms and conditions
673 |
674 | either of that version or of any later version published by the Free Software Foundation. If the Program does
675 |
676 | not specify a version number of this License, you may choose any version ever published by the Free Software
677 |
678 | Foundation.
679 |
680 | 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are
681 |
682 | different, write to the author to ask for permission. For software which is copyrighted by the Free Software
683 |
684 | Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be
685 |
686 | guided by the two goals of preserving the free status of all derivatives of our free software and of promoting
687 |
688 | the sharing and reuse of software generally.
689 |
690 | NO WARRANTY
691 |
692 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
693 |
694 | PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
695 |
696 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
697 |
698 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
699 |
700 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE
701 |
702 | COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
703 |
704 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY
705 |
706 | OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
707 |
708 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
709 |
710 | THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
711 |
712 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
713 |
714 | OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
715 |
716 | END OF TERMS AND CONDITIONS
717 |
718 |
719 | How to Apply These Terms to Your New Programs
720 |
721 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to
722 |
723 | achieve this is to make it free software which everyone can redistribute and change under these terms.
724 |
725 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source
726 |
727 | file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright"
728 |
729 | line and a pointer to where the full notice is found.
730 |
731 | One line to give the program's name and a brief idea of what it does.
732 |
733 | Copyright (C)
734 |
735 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General
736 |
737 | Public License as published by the Free Software Foundation; either version 2 of the License, or (at your
738 |
739 | option) any later version.
740 |
741 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
742 |
743 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
744 |
745 | more details.
746 |
747 | You should have received a copy of the GNU General Public License along with this program; if not, write to
748 |
749 | the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
750 |
751 | Also add information on how to contact you by electronic and paper mail.
752 |
753 | If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
754 |
755 | Gnomovision version 69, Copyright (C) year name of author
756 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are
757 |
758 | welcome to redistribute it under certain conditions; type `show c' for details.
759 |
760 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public
761 |
762 | License. Of course, the commands you use may be called something other than `show w' and `show c'; they could
763 |
764 | even be mouse-clicks or menu items--whatever suits your program.
765 |
766 | You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright
767 |
768 | disclaimer" for the program, if necessary. Here is a sample; alter the names:
769 |
770 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at
771 |
772 | compilers) written by James Hacker.
773 |
774 | signature of Ty Coon, 1 April 1989
775 | Ty Coon, President of Vice
776 |
777 | This General Public License does not permit incorporating your program into proprietary programs. If your
778 |
779 | program is a subroutine library, you may consider it more useful to permit linking proprietary applications
780 |
781 | with the library. If this is what you want to do, use the GNU Library General Public License instead of this
782 |
783 | License.
784 |
785 |
786 | "CLASSPATH" EXCEPTION TO THE GPL VERSION 2
787 |
788 | Certain source files distributed by Oracle are subject to the following clarification and special exception to
789 |
790 | the GPL Version 2, but only where Oracle has expressly included in the particular source file's header the
791 |
792 | words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in
793 |
794 | the License file that accompanied this code."
795 |
796 | Linking this library statically or dynamically with other modules is making a combined work based on this
797 |
798 | library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole
799 |
800 | combination.
801 |
802 | As a special exception, the copyright holders of this library give you permission to link this library with
803 |
804 | independent modules to produce an executable, regardless of the license terms of these independent modules, and
805 |
806 | to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for
807 |
808 | each linked independent module, the terms and conditions of the license of that module. An independent module
809 |
810 | is a module which is not derived from or based on this library. If you modify this library, you may extend
811 |
812 | this exception to your version of the library, but you are not obligated to do so. If you do not wish to do
813 |
814 | so, delete this exception statement from your version.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Using JavaScript/HTML5 Rich Clients with Java EE 7
2 | ==================================================
3 | This project demonstrates how you can utilize today's most popular JavaScript frameworks like Angular,
4 | Backbone, Knockout and Ember to utilize the core strengths of Java EE.
5 |
6 | It is a Java EE 7 server-side application with an AngularJS front-end consisting of a chat application (powered by
7 | WebSocket) and a to-do list application (powered by REST). The server-side is implemented using
8 | the Java API for WebSocket, JSON-P, JAX-RS 2, CDI, Bean Validation, EJB 3 and JPA.
9 |
10 | The application is secured. Before running the application, you must setup the right GlassFish security
11 | realm using the instructions below. You can also set the username/passwords
12 | via the database scripts in the source code. The passwords are stored as SHA-256
13 | hashes. The current users are reza, nicole and zehra. The passwords are set to secret1. When using the
14 | application, the browser will warn you about the self-signed SSL certificate that GlassFish uses by default.
15 | Simply ignore the warning, it's harmless.
16 |
17 | The project is in standard Maven format. You should be able to open it using any IDE that supports Maven and
18 | run it using any Java EE 7 container. However, we used NetBeans and GlassFish 4. Note that the project uses
19 | the default Derby database that comes with GlassFish.
20 |
21 | Setup Instructions
22 | ------------------
23 | Here are the instructions to get up and running using NetBeans and GlassFish:
24 |
25 | * Install JDK 7
26 | * Install GlassFish 4+
27 | * Install the NetBeans 7.4+ Java EE version (GlassFish 4.1+ will only work with NetBeans 8.0.1+)
28 | * Setup GlassFish in NetBeans (make sure Derby is started with GlassFish)
29 | * Make sure you have GlassFish up and running.
30 | * Execute the following asadmin command to remove any conflicting authentication
31 | realms you might have. A conflict is unlikely, so the command will probably
32 | fail, which is fine.
33 | ```
34 | asadmin delete-auth-realm javascript-realm
35 | ```
36 | * For GlassFish versions up to GlassFish 4.1 (but not including it) execute the
37 | following asadmin command to create the authentication realm we need:
38 | ```
39 | asadmin create-auth-realm --classname com.sun.enterprise.security.ee.auth.realm.jdbc.JDBCRealm --property jaas-context=jdbcRealm:datasource-jndi=jdbc/__default:user-table=javascript_users:user-name-column=username:password-column=password:group-table=javascript_groups:group-name-column=group_name javascript-realm
40 | ```
41 | * For GlassFish 4.1 and above execute the following asadmin command:
42 | ```
43 | asadmin create-auth-realm --classname com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm --property jaas-context=jdbcRealm:datasource-jndi=jdbc/__default:user-table=javascript_users:user-name-column=username:password-column=password:group-table=javascript_groups:group-name-column=group_name javascript-realm
44 | ```
45 | * Open and build the project
46 | * Run the project on GlassFish 4
47 | * Open up a browser and go to [http://localhost:8080/javaee-javascript](http://localhost:8080/javaee-javascript)
--------------------------------------------------------------------------------
/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
43 | The JavaScript backend consists of a chat WebSocket API
9 | and a to do list REST API implemented using the Java
10 | API for WebSocket, JSON-P, JAX-RS 2 and Java EE 7. Note that while the endpoints in this application are not fully secured
12 | but uses TLS/SSL, in a real application they should be secured, likely using
13 | some sort of federated security scheme. The WebSocket chat endpoint is at:
15 |
16 | wss://localhost:8181/javaee-javascript/chat. The
17 | endpoint communicates via JSON. Once connected, a client
18 | can send a chat message using this format:
19 | Java EE as JavaScript Backend
8 |
20 | {"user": "the name of the user",
21 | "message": "the chat message"}
22 |
23 | Each chat message sent to the server will be echoed back to all
24 | currently connected clients including the client that sent the
25 | message. The server will also include the timestamp on the server
26 | when the message was received. The chat messages echoed back
27 | from the server will follow this format:
28 |
29 | {"user": "the name of the user that sent the message",
30 | "message": "the echoed chat message",
31 | "timestamp": "the server timestamp - MM/dd/yyyy h:mm:ss a z"}
32 |
33 |
The REST endpoint is available at 35 | https://localhost:8181/javaee-javascript/resources/todo. The 36 | REST endpoint also communicates with the client using JSON. 37 | To do items are stored under various usernames. To retrieve 38 | the current to do items for a given user, the client must issue 39 | a GET request to this URL: 40 | https://localhost:8181/javaee-javascript/resources/todo/{username}. 41 | The server will respond with the list of current to do items for the 42 | user following this format: 43 |
44 | [{"id": "to do item ID", 45 | "description": "item 1 description", 46 | "completed": "true|false"}, 47 | {"id": "to do item ID", 48 | "description": "item 2 description", 49 | "completed": "true|false"} 50 | ...] 51 |52 | To add an item for a user, the client must issue a POST request to 53 | this URL: 54 | https://localhost:8181/javaee-javascript/resources/todo/{username}. 55 | The POST body must follow this format: 56 |
57 | {"description": "item description"} 58 |59 | An ID will be automatically assigned and the item will be assumed to be 60 | incomplete. The POST response will return the ID assigned to the item as plain text (not JSON). 61 | To modify a to do item, the client must issue a PUT 62 | request to this URL: 63 | https://localhost:8181/javaee-javascript/resources/todo/{username}/{id}. 64 | The PUT request body must follow this format: 65 |
66 | {"id": "to do item ID", 67 | "description": "item description", 68 | "completed": "true|false"} 69 |70 | To delete a to do item, the client must issue a DELETE request to 71 | this URL: 72 | https://localhost:8181/javaee-javascript/resources/todo/{username}/{id}. 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/main/webapp/chat.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
This application demonstrates how Java EE 7 can be an extremely 9 | effective backend for JavaScript/HTML5 rich clients. The application 10 | shows the use of APIs like WebSocket, JSON-P, JAX-RS, CDI, 11 | Bean Validation, EJB 3 and JPA. AngularJS is used as the JavaScript 12 | front-end framework. However, the choice of AngularJS is somewhat 13 | arbitrary and not central to the application. The concepts and backend 14 | could also be utilized by Backbone.js, Ember.js, KnockoutJS, JQuery or 15 | perhaps even plain JavaScript.
16 |17 | There are two main parts of the application: 18 |
19 |Note that while this page is not secured, both the interfaces are 24 | secured using HTTP BASIC authentication and SSL. You 25 | can set the usernames and SHA-256 encrypted passwords in the SQL load 26 | scripts of the application source.
27 |The backend REST and WebSocket APIs are documented 28 | here.
29 | 30 | -------------------------------------------------------------------------------- /src/main/webapp/javascript/chat/application.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var chatApplication = angular.module('chatApplication', ['chatControllers', 4 | 'chatServices', 'chatDirectives', 'angular-growl']); 5 | 6 | chatApplication.config(['growlProvider', function(growlProvider) { 7 | growlProvider.globalTimeToLive(2000); 8 | }]); -------------------------------------------------------------------------------- /src/main/webapp/javascript/chat/controllers.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var chatControllers = angular.module('chatControllers', []); 4 | 5 | chatControllers.controller('ChatController', ['$scope', 'growl', 'Chat', 6 | function($scope, growl, Chat) { 7 | $scope.user = principal; 8 | $scope.messages = []; 9 | $scope.newMessage = ''; 10 | 11 | Chat.setListener( 12 | function(message) { 13 | $scope.messages.push(message); 14 | $scope.newMessage = ''; 15 | $scope.$apply(); 16 | }, 17 | function(error) { 18 | growl.addErrorMessage(error); 19 | $scope.$apply(); 20 | }); 21 | 22 | $scope.send = function() { 23 | Chat.send(principal, $scope.newMessage); 24 | }; 25 | }]); -------------------------------------------------------------------------------- /src/main/webapp/javascript/chat/directives.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var chatDirectives = angular.module('chatDirectives', []); 3 | 4 | /** 5 | * Scrolls the element to the bottom when the expression passed in via the 6 | * attribute becomes true 7 | */ 8 | chatDirectives.directive('autoScroll', function($timeout) { 9 | return function(scope, element, attributes) { 10 | scope.$watch(attributes.autoScroll, function() { 11 | $timeout(function() { 12 | jQuery(element).animate( 13 | {scrollTop: jQuery(element).prop("scrollHeight")}, 'slow'); 14 | }, 0, false); 15 | }); 16 | }; 17 | }); -------------------------------------------------------------------------------- /src/main/webapp/javascript/chat/services.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var chatServices = angular.module('chatServices', []); 4 | 5 | chatServices.factory('Chat', [function() { 6 | return new function() { 7 | var websocket = new WebSocket('wss://localhost:8181/javaee-javascript/chat'); 8 | this.send = function(sender, value) { 9 | websocket.send(JSON.stringify({user: sender, message: value})); 10 | }; 11 | this.setListener = function(messageListener, errorListener) { 12 | websocket.onmessage = function(message) { 13 | var parsedMessage = JSON.parse(message.data); 14 | 15 | if (!parsedMessage.error) { 16 | messageListener(parsedMessage); 17 | } else { 18 | errorListener(parsedMessage.error); 19 | } 20 | }; 21 | }; 22 | }; 23 | }]); -------------------------------------------------------------------------------- /src/main/webapp/javascript/lib/angular-growl.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * angular-growl - v0.4.0 - 2013-11-19 3 | * https://github.com/marcorinck/angular-growl 4 | * Copyright (c) 2013 Marco Rinck; Licensed MIT 5 | */ 6 | angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope",function(a){"use strict";return{restrict:"A",template:'