This begin with the thought on how to get a handy too to handle the tiny programming works I have to do very often, and has many foundation between(such as text manipulating, http site data fetch and processing, xml processing, html processing, sold data updating or data migration).
I’ll write an article to explain the this later.
The link for Jersey is https://github.com/guitarpoet/jersey and the README of it is below.
Jersey also contains a package manager called jpm, so you just need to provide an ivy module file, then you can get all the plugin and plugin dependencies using maven distribution.
The concept of Jersey is as list bellow:
- Pluggable: Jersey is pluggable, you can install any plugin to it, and the plugin is just a java jar. All the plugins are deactivate at the start of the enviromnent, you can activate the plugins using Spring(Jersey provides you the functions to do that).
- Configurable: Jersey provides the configuration basics based on Java’s properties, and all the configuration for application and plugins contains within the same configuration file
- Discoverable: You can list all the provided function and provided modules using native functions.
- Docable: Jersey provides the doc method for all the function and plugin modules, you can read the documentation of the function and modules using man function, and even have a pager function to view the pages.
- Easy to be server: Since Java has many good embedded services, Jersey using Apache Derby to provide Database service and using Jetty to provide http server service, I also have a small CMS system written using the mvc and http plugin of Jersey
- Easy to use: Jersey providing the pacakge management system based on the Famous Maven and Ivy, so you can download every plugin and plugin dependencies using Ivy’s module file.
- Powerful: Jersey is based on Java, so it can take advantage of current Java and opensource Java libraries to provide powerful functions, it can use JDBC to access Database, using Commons DBCP to make the database connection pool, it can use Solr client to access the Apache Solr, it can use Log4J to handle the logging things and even using JBoss Drools to do the Rule matching.
All the native functions and native modules is initiliazed at the intializing of the environment, all the plugins you want to use, need to be installed into the lib folder first, configure it correctly in the configuration file, then using require function to require the intialize script for this plugin.
Jersey is used using commandline, you can run the console using just jersey command. Or jersey a.js b.js c.js to run the script file one by one.
Jersey accept -c option to get the option file location (default is config.properties), and -s to get the script file(This only used for standard in, standard in file for Jersey is – )
Here is docs for some native functions that Jersey provided, you can list all the native functions using function functions().
- require: Require the library using the resouce location, support file:file and classpath: protocol.
- config: Read the configuration from system.properties or list all the properties
- functions: List all the functions this shell provided.
- modules:Prints all the modules that have loaded.
Here is the docs for some native modules that Jersey provided, you can lis all the native modules using function modules().
- console: The console object.
- file: The file utils.
- csv: The csv utils service.
- sutils: The string utils service.
- std/date: This provides date
- std/evn.rhino: This provide env, to use library like jQuery
- std/man: This provide the manual function for all the native function and modules
- std/jquery: This provides the famous jQuery
- std/underscore: This provides underscore
You can load your scripts using classpath protocol too.