| 1 |
Helma NG |
|---|
| 2 |
======== |
|---|
| 3 |
|
|---|
| 4 |
This is the README file for the 0.2 release of Helma NG, a Javascript |
|---|
| 5 |
runtime and web application framework written in Java. "NG" stands for |
|---|
| 6 |
"next generation", meaning that it is a more of a rewrite of Helma 1 than |
|---|
| 7 |
simply a new version. |
|---|
| 8 |
|
|---|
| 9 |
Helma NG consists of several parts: |
|---|
| 10 |
|
|---|
| 11 |
1) The Helma Shell |
|---|
| 12 |
2) The Helma Runtime |
|---|
| 13 |
3) The Helma Web Framework |
|---|
| 14 |
|
|---|
| 15 |
Helma Shell |
|---|
| 16 |
=========== |
|---|
| 17 |
|
|---|
| 18 |
To start the Helma shell run the following command in a shell window: |
|---|
| 19 |
|
|---|
| 20 |
java -jar shell.jar |
|---|
| 21 |
|
|---|
| 22 |
This starts the Helma shell with the current directory in its module path. |
|---|
| 23 |
The module path is the list of places Helma looks for scripts when asked to |
|---|
| 24 |
import something. It should contain your application directory. Helma always |
|---|
| 25 |
adds the modules directory to the end of the module path. |
|---|
| 26 |
|
|---|
| 27 |
You can also specify one or more script directories in the command line that |
|---|
| 28 |
will be added to the shell's module path: |
|---|
| 29 |
|
|---|
| 30 |
java -jar shell.jar demo/ |
|---|
| 31 |
|
|---|
| 32 |
You can also pass a script file. The file will be immediately evaluated before |
|---|
| 33 |
entering shell mode, and its containing directory will be added to the module |
|---|
| 34 |
path. |
|---|
| 35 |
|
|---|
| 36 |
Helma Runtime |
|---|
| 37 |
============= |
|---|
| 38 |
|
|---|
| 39 |
The command line syntax for the Helma Runtime is similar to that of the Shell, |
|---|
| 40 |
except that you use run.jar instead of shell.jar. If you pass a Javascript file |
|---|
| 41 |
as first argument, Helma will evaluate the file and try to invoke function main() |
|---|
| 42 |
on it. |
|---|
| 43 |
|
|---|
| 44 |
java -jar run.jar somepath/mainfile.js |
|---|
| 45 |
|
|---|
| 46 |
If you pass a directory instead of a string file, Helma will look for a file |
|---|
| 47 |
called "main.js" in the given directory and use that as main script file. |
|---|
| 48 |
|
|---|
| 49 |
You can also add any number of additional script directories on the command line |
|---|
| 50 |
that will be added to the Helma module path. |
|---|
| 51 |
|
|---|
| 52 |
Helma Web Framework |
|---|
| 53 |
=================== |
|---|
| 54 |
|
|---|
| 55 |
The Helma Web Framework is a web application framework written mostly in JavaScript |
|---|
| 56 |
built on top of the Helma Runtime. |
|---|
| 57 |
|
|---|
| 58 |
To run the demo application that is part of Helma NG run the following command: |
|---|
| 59 |
|
|---|
| 60 |
java -jar run.jar demo/main.js |
|---|
| 61 |
|
|---|
| 62 |
This starts and serves the demo web app on port 8080: |
|---|
| 63 |
|
|---|
| 64 |
http://localhost:8080/ |
|---|
| 65 |
|
|---|
| 66 |
The demo app showcases a number of tools and libraries to build web apps. |
|---|
| 67 |
As Helma NG is still pretty young, many features found in Helma 1.6 are still |
|---|
| 68 |
missing, most notably a persistence layer. These features are currently being |
|---|
| 69 |
implemented. |
|---|
| 70 |
|
|---|
| 71 |
The exciting thing is thatit will be possible to implement much of it in |
|---|
| 72 |
Javascript, meaning you can help doing so without hacking on helma core. |
|---|
| 73 |
The new modular concept will even allow to use helma with several frameworks, |
|---|
| 74 |
even on the same server instance. |
|---|
| 75 |
|
|---|
| 76 |
Visit http://dev.helma.org/ng/ and join the Helma NG mailing list to keep up |
|---|
| 77 |
with Helma NG core and module development! |
|---|
| 78 |
|
|---|
| 79 |
Global Functions |
|---|
| 80 |
================ |
|---|
| 81 |
|
|---|
| 82 |
In addition to standard Javascript functionality, some useful functions |
|---|
| 83 |
Helma adds are: |
|---|
| 84 |
|
|---|
| 85 |
importModule(module); |
|---|
| 86 |
importModule(module, as); |
|---|
| 87 |
importFromModule(module, func1, ...) |
|---|
| 88 |
|
|---|
| 89 |
These functions load Javascript modules and add them to the current scope. |
|---|
| 90 |
see http://dev.helma.org/ng/Modules+and+Scopes/ for more info. |
|---|
| 91 |
|
|---|
| 92 |
Helma first tries to resolve the path relative to the location of the |
|---|
| 93 |
module calling this method. If that fails, it looks for the resource |
|---|
| 94 |
in the repository path, which usually consists of the current directory |
|---|
| 95 |
(shell) or app directory (web apps) and the modules directory. |
|---|
| 96 |
|
|---|
| 97 |
The module path can be set by passing one or more script directories on |
|---|
| 98 |
the command line. As a fallback, Helma checks the helma.modulepath |
|---|
| 99 |
System property: |
|---|
| 100 |
|
|---|
| 101 |
java -Dhelma.modulepath=myapp,mylibs,modules -jar shell.jar |
|---|
| 102 |
|
|---|
| 103 |
importJar(jarfile) |
|---|
| 104 |
|
|---|
| 105 |
This function adds a jar (Java archive) to the classpath. by default, |
|---|
| 106 |
all jar files in the lib directory are included in the classpath. You |
|---|
| 107 |
can add also other jar files by starting helma with |
|---|
| 108 |
|
|---|
| 109 |
java -Dhelma.classpath=foo.jar,lib0/,lib1/*,lib2/** -jar shell.jar |
|---|
| 110 |
|
|---|
| 111 |
getResource(path) |
|---|
| 112 |
|
|---|
| 113 |
This loads a resource object. See the importModule functions above for a |
|---|
| 114 |
detailed explanation of helma.modulepath and resource lookup. |
|---|
| 115 |
|
|---|
| 116 |
Building Helma |
|---|
| 117 |
============== |
|---|
| 118 |
|
|---|
| 119 |
To build helma yourself follow these steps: |
|---|
| 120 |
|
|---|
| 121 |
Check out helma from subversion: |
|---|
| 122 |
|
|---|
| 123 |
svn co https://dev.helma.org/svn/helma-ng/trunk/ helma-ng |
|---|
| 124 |
|
|---|
| 125 |
Change to the helma-ng directory and run ant to compile: |
|---|
| 126 |
|
|---|
| 127 |
ant jar |
|---|
| 128 |
|
|---|
| 129 |
If this succeeds you should be able to start the helma shell and runtime |
|---|
| 130 |
as described above. |
|---|