hi all,
today we had a review on the jaggery2 process.
jaggery 2 can be accessed via command line using ./jjs command
here is the summary what we have implemented so far
1.) we registered a global object to nashorn global called
'jaggery'.this obj
takecare all the house keeping stuff of jaggery2.
you can call this object from command line just using 'var jaggery
= jaggery'
these are the properties implemented in jaggery obj
* version - - jaggery version(return 'jaggery
2.0')
* moduleLoadList - - module loaded to the jaggery
* arch - - platform architecture jaggery
running on
* platform
* argv - - conatain all the argument pass
to jaggery
* cwd - - current working dir
there is a special function in jaggery object call
'bind'.access via
var foo = jag.bind(param);
at the moment user can supply two parameters, 'natives' and
'contextify'
bind function make a glue between java and js
*a parameter to bind*
1. 'natives'
to get script object which contain all the core module
content to
the js environment
eg: var natives = jag.bind('natives');
var path = natives.path;
2. 'contextify'
script object contain three methods
* isContext(not implemented)
* makeContext
* contextifyScript
2.) jaggery.js file implemented the core module loading system.
3.) user defined module will load to jaggery via module.js
file.'module' is a core
module which is require by jaggery.js file when jaggery2 star.
inside user js file user can require a module using following
syntax
* var foo = require('foo') ,
var foo = require('./foo')
var foo = require('../foo');
var foo = require('/home/buddhi/jaggery/foo ');
this foo can be a core module,js file or folder as a module.user
can require
js file by ommiting file extension(or user can mention extension
as well)
if module is a folder as a module jaggery2 tries to read
package.json
inside that module foler.if no package.json then reads
index.js(using .jag
extension is not implemented yet)
all of above algorithms were written.but still we tested first
scenario(if
module is a core module)
user must use keyword 'exports' to expose properties of one js
file to
outside world
eg: in foo.js file --- >exports.name = 'buddhi';
then in bar.js file if bar.js file require foo.js
var foo = require('foo');
print(foo.name);
4.) path.js implemented all path relevant manpilation. only works for
unix
systems(single root systems)
functions in path.js
* normalize(path); - - normalize a path taking
care of ../
and ./
parts of a path string
* join(path1 ,[paths ...]) - - join paths
* resolve(path1, [paths ...]) - - resolve to abs path
* relative(path1, path2) - - if two path relative
to each other
* baseName(path) - - base name of the path
* dirName(path) - - dir name of the path
* extName(path) - - extension name of the
file
* isAbsolute(path) - - is absolute path
* getRoot(path) - - root dir of the path
use ant to build project.(Nas/make/build.xml)
--
Thanks & Best Regards,
*Buddhi Nipun Mihara*
Software Engineer(intern)
WSO2, Inc.:http://wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev