Saturday, January 26, 2013

BBB-FORGE


BBB-FORGE
Prerequisites for BBB:
NPM (associate node tool)

Story:
One of the powerful frameworks to build a device agnostic / platform agnostic web app is using a RESTful backend and a backbone frontend.
Now, consider doing a web-app would involve at-least the following:
Backend to frontend.
a) Creating a Schema of the entity model that your app demands. (Scheme)
b) Mechanism to persist and retrieve these entities.       (Persistence Layer)
c) Mechanism to expose these entities over http and     (RESTful services)
d) Maintain / Validate / Manipulate / etc... these over the client browser.            (Client framework).

Let us come to what software we would use,
I am pretty impatient and want my webapp to be available in a jiffy.

Database:
I would consider an in-memory DB to any of the other costly (w.r.t time / energy) setups Oracle / Sql Server, etc.
So what are my options, a) HSQLDB or b) SQLite (file based)?
Of course of the MySQL is one extensively provided by website vendors, but I would rather consider something I don’t need to do a JDBC Uri.


I would not like to write all my create / update / insert statements for setting up a base DB,
What are the alternatives? I want someone who can understand the need of creating a project
Which has persistence framework defined and is also intelligent of creating DB scheme based on my pojo model?

What if I am reluctant to write my pojo's defining entities?
Is there anyone who can ask me few simple questions and create my entities??

What else do I demand from this aid?
Can this aid expose over in a RESTful way all my entity models?

Wow... so we are saying that a tool
Which will ask me few questions like, what is the entity you want to create?
What fields does the entity hold?
Create Scheme + Persistence entity model + RESTful services on these entities.





Action:
Installation of Forge:
http://forge.jboss.org/

Method 1:
Download + extract + run.
As simple as that.

Method 2:
Go to eclipse market place and search for jBoss Tools.
Install all of the tools (nearly 50 of them).


Using Forge:

Open the command prompt and type forge.
In eclipse, Window --> show View --> search forge.
Click on the green triangle to start forge.

-- Unless otherwise specified, assert all the questions.

Creating a new project using Forge
new-project --named <ProjectName> --topLevelPackage <TopLevelJavaPackage>


Talk about Persistance
Configure DB connections.

 persistence setup --provider HIBERNATE --container JBOSS_AS7


Creating entities:
entity --named Tweets

field string --named tweetTxt
field string --named tweetID

RESTful entities:
rest setup --activatorType APP_CLASS

rest endpoint-from-entity --contentType application/json <TOP LEVEL model Package>

You are done of defining schema + writing ORM layer + exposing these as RESTful services, by running just 7 commands.
Use mvn commands to package the above app for server side deployment.







The client side story
-----------------------------------------------------------------
bbb comes to the rescue.



npm install -g bbb

Once you have it,
Create HTML5 web-app by

bbb init

Create modules in the app by

bbb init:modules
Provide the module name when asked, and happy UI designing then on.


-----------------------------------------------------------------


References: