Installation |
We begin by assuming that you have unzipped 'seppia.zip' in the following directory
C:\seppia
Below are the files and directories you can now see.
|
This is it: any Seppia Application is going to look like this whether it is going to be a financial application or a game.
Only it might have more modules (folders in the modules directory), more jar files (jar files under the 'jars' folder in each module), and
more javascripts.
Running The Seppia Application |
If you want to run it just move into the directory and type
|
We are obviously assuming that java is pointing to the java virtual machine. Depending on which machine you are working (Windows, Unix, Linux ,...)
you might decide to write the appropriate batch/script. But your batch/script should not do anything more than that.
Any Seppia Application infact must be started in that way drastically reducing the need for a batch or shell script to launch a Java application.
The classic "Hello World" in Seppia |
To do this we need to create a new module with the a new javascript that does the job.
Let's call the new module "org.seppia.tutorial.helloworld"
Let's write the new javascript "HelloWorld.js" with the following content:
|
This is what we should see now:
|
Ok now the final bit is to redirect "org.seppia.bootstrap.StartUp.js" so to run "HelloWorld.js".
So "StartUp.js" becomes:
|
Again this is a classical operation in Seppia, i.e.: every seppia application
redirects org.seppia.bootstrap.StartUp.js to launch another script.
This is what we should see now:
|
Another Example |
The next example is going to show you how Seppia let your javascript interact
with your java code.
We suppose you have written (or downloaded from the net) a basic geometrical
package for the jdk.
The package might have classes like Line, Circle, Triangle, Rectangle, Shape and
so on.
So let's suppose the Rectangle class looks like this:
|
The classes Circle and Triangle are going to have the method
called 'getArea()' as well.
Circle will have a constructor which receives a double (its radius) while
Triangle will have a constructor with three parameters: one for each side.
The first step is to package your classes into a jar file. Let's call it:
"geomtool.jar". This jar file needs to be placed into the jars folder
of the module.Let's call our module "org.seppia.tutorial.geom"
Then one or more javascript files can be written to work with it. For the
purpose of the simple program we want to write we could go away with just one
javascript instead we will write two javascripts to have an opportunity to
explain more about their interaction.
File: AreaCalculator.js
|
File: GeomRunner.js
// this javascript launches the AreaCalculator |
org.seppia.bootstrap.StartUp is redirected to launch GeomRunner
|
This is the structure of the files we should see now:
|
and this is what happens when we launch it:
|
At this point we hope that your reaction is a "Wow !!!"
as you begin to see how javascripts and jars work together within the seppia
Framework.
The module org.seppia.tutorial.geom infact identifies a mostly
self-contained part of your system deployed a single,coherent unit with its jars
folder and its javascripts folder
AreaCalculator is a javascript that when executed builds a javascript object to
offer some services. By being able to access the classes in the geomtool.jar the
implementation of its services is relatively straight-forward.
Those services (the returned javascript object) could then be used by another module.
GeomRunner is the entry point of the module a tiny program that prints out the areas of a circle and a
rectangle. It runs "AreaCalculator.js" and then relies on its services
to perform its task. As GeomRunner does not rely upon geomtool.jar it could
easily deployed in another module.
Conclusions |
The scope of this tutorial was to provide you with a quick introduction to
the Seppia Technology.
In order to keep it very concise we obviously omitted many aspects of it.
We hope you can see beyond the simplicity of the tutorial's examples and see
where you can use Seppia in your projects.
At this stage we would recommend you to continue to familiarize yourself with
the concepts behind Seppia, by downloading some sample modules (if you have not
done it already) and by writing a few yourself.
So remember: Seppia is just a simple framework to produce component-based
software with java and javascript.