Search This Blog

Thursday, October 2, 2008

acceleo-the modelling tool

MDA with Eclipse : Acceleo 2.0.0 generates JEE applications
Model Driven Engineering refers to the systematic use of models as primary engineering artifacts throughout the engineering lifecycle, the set of tools needed to apply such an approach is made of graphical modelers (UML), interoperability layers (XML/XMI imports and exports) and tools to take advantage of this models using "Model to Text" transformations.

IT companies used to buy expensive proprietary solutions for these needs, thanks to the Eclipse project and some high quality free software plugins one may now have a full featured IDE with modeling support.

Acceleo is one of these tools, the latest release brings open-source generator modules for many technologies (JEE, Php, CSharp, Python...) These modules are by a team of architects trying to provide state of the art code architecture using well-tried framework and best practices. The JEE generator is directly inspired by the Sun blueprints with Struts and Hibernate. Spring support is on its way and should be integrated for the next release.

The Eclipse ecosystem is now providing nice open-source UML modelers such as Topcased. Using this modeler one is able to design a sofware system using Class diagrams.

These diagrams may be annotated using Stereotypes in order to add semantic information. Basically two main stereotypes are used on UML classes :
  • Screen : mean this class is a screen, each association going from a screen to another meaning I'm able to navigate from this screen to this other screen.
  • Entity : mean this class is a business object that should be persisted.
As many technologies trying to avoid strong coupling, JEE tends to be quite verbose. Using a MDA approach one can greatly improve its productivity and its software consistency generating files. As an example an Entity "Book" generates:
  • Book.java DTO
  • BookDAO.java
  • ProjectDAOFactory.java
  • BookDAOImpl.java
  • book.hbm.xml
  • dao.properties
  • project-ddl.sql
  • project-constraints.sql
  • hibernate.config.xml
A "Welcome" screen will produce:
  • Welcome.jsp
  • WelcomeAction
  • WelcomeForm
  • tiles-def.xml
  • struts-config.xml
  • validator.xml
  • web.xml
  • context.xml
  • Welcome.css
  • Welcome.js
Changing a screen, adding for instance an association to another screen, will cause the update of the struts-config.xml and associated files.

Note the fact that as soon as an entity or a screen is designed and the corresponding code has been generated you're able to deploy the software on application servers. This capability is useful for quick prototyping, encouraging exchanges with the final customer.

The screencasts describes the use of the module: modeling, generating, adding a new business entity and a new screen and then generating again the whole architecture without loosing the previous customizations.
Other features for the JEE module are described on the JEE module official web page.

This pragmatic vision is enforced by an efficient tooling: writing generation templates is made easy thanks to a simple syntax and full-featured editors (highlighting, error detections and completion). This set of tool has been validated with success on real-world projects.

Acceleo is not just a template language and provides behavior to keep user code. That means once you've generated your software and you complete the source code, this so-called "user code" won't be lost when you re-generate information.

Emphasizing the Eclipse integration, it provides a seamless use of the MDA approach for the developers.
"Ready to use" bundles are available providing Acceleo, the set of JEE, CSharp, Php and other modules, and an UML2 modeler.

Thanks to many projects Eclipse is now providing a full set of modeling tools, do you use or plan to use them? Have you tried to apply a model driven approach on any project?").substring(0,300);
return _diggURL ;
}
Model Driven Engineering refers to the systematic use of models as primary engineering artifacts throughout the engineering lifecycle, the set of tools needed to apply such an approach is made of graphical modelers (UML), interoperability layers (XML/XMI imports and exports) and tools to take advantage of this models using "Model to Text" transformations.IT companies used to buy expensive proprietary solutions for these needs, thanks to the Eclipse project and some high quality free software plugins one may now have a full featured IDE with modeling support.Acceleo is one of these tools, the latest release brings open-source generator modules for many technologies (JEE, Php, CSharp, Python...) These modules are by a team of architects trying to provide state of the art code architecture using well-tried framework and best practices. The JEE generator is directly inspired by the Sun blueprints with Struts and Hibernate. Spring support is on its way and should be integrated for the next release.The Eclipse ecosystem is now providing nice open-source UML modelers such as Topcased. Using this modeler one is able to design a sofware system using Class diagrams. These diagrams may be annotated using Stereotypes in order to add semantic information. Basically two main stereotypes are used on UML classes :
Screen : mean this class is a screen, each association going from a screen to another meaning I'm able to navigate from this screen to this other screen.
Entity : mean this class is a business object that should be persisted.As many technologies trying to avoid strong coupling, JEE tends to be quite verbose. Using a MDA approach one can greatly improve its productivity and its software consistency generating files. As an example an Entity "Book" generates:
Book.java DTO
BookDAO.java
ProjectDAOFactory.java
BookDAOImpl.java
book.hbm.xml
dao.properties
project-ddl.sql
project-constraints.sql
hibernate.config.xmlA "Welcome" screen will produce:
Welcome.jsp
WelcomeAction
WelcomeForm
tiles-def.xml
struts-config.xml
validator.xml
web.xml
context.xml
Welcome.css
Welcome.jsChanging a screen, adding for instance an association to another screen, will cause the update of the struts-config.xml and associated files.Note the fact that as soon as an entity or a screen is designed and the corresponding code has been generated you're able to deploy the software on application servers. This capability is useful for quick prototyping, encouraging exchanges with the final customer.The screencasts describes the use of the module: modeling, generating, adding a new business entity and a new screen and then generating again the whole architecture without loosing the previous customizations.Other features for the JEE module are described on the JEE module official web page. This pragmatic vision is enforced by an efficient tooling: writing generation templates is made easy thanks to a simple syntax and full-featured editors (highlighting, error detections and completion). This set of tool has been validated with success on real-world projects.Acceleo is not just a template language and provides behavior to keep user code. That means once you've generated your software and you complete the source code, this so-called "user code" won't be lost when you re-generate information.Emphasizing the Eclipse integration, it provides a seamless use of the MDA approach for the developers."Ready to use" bundles are available providing Acceleo, the set of JEE, CSharp, Php and other modules, and an UML2 modeler. Thanks to many projects Eclipse is now providing a full set of modeling tools, do you use or plan to use them? Have you tried to apply a model driven approach on any project?

Tuesday, August 12, 2008

using ajax in an elegant way without dojo

//------------------------------------Library--------------------------------

//------takes a formid and returns elements inside in a format to -----------
//----------------send by ajax with post(not get)----

function getForm(formid)
{
var getstr='';
var obj=document.getElementById(formid)? document.getElementById(formid) : document.forms[formid];
var inputobjs=null;
inputobjs=obj.getElementsByTagName("INPUT");
for (i=0; i
{
var inpobj=inputobjs[i];
if (inpobj.tagName == "INPUT")
{
if (inpobj.type == "text")
{
getstr +="&" + inpobj.name + "=" + inpobj.value;
}
if (inpobj.type == "hidden")
{
getstr +="&" + inpobj.name + "=" + inpobj.value;
}
if (inpobj.type == "password")
{
getstr +="&" + inpobj.name + "=" + inpobj.value;
}
if (inpobj.type == "checkbox")
{
if (inpobj.checked)
{
getstr +="&" + inpobj.name + "=" + inpobj.value;
}
}
if (inpobj.type == "radio")
{
if (inpobj.checked)
{
getstr +="&" + inpobj.name + "=" + inpobj.value;
}

}
}
}
var selobjs=null;
selobjs=obj.getElementsByTagName("SELECT");
for (i=0; i
{
var sel = selobjs[i];
getstr +="&" + sel.name + "=" + sel.options[sel.selectedIndex].value;
}

var txtAreaobjs=null;
txtAreaobjs=obj.getElementsByTagName("TEXTAREA");
for (i=0; i
{
var txtAr = txtAreaobjs[i];
getstr +="&" + txtAr.name + "=" + ((txtAr.value=="")?txtAr.innerHTML:txtAr.value);
}


return getstr;
}


//---------------------use to send data(postdata) using ajax--------------------

function fetchData(dataSource, postData, callback)
{
httpRequest = false;
if (window.XMLHttpRequest)
{
httpRequest = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
try
{
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
httpRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e)
{
alert("fetchData, e: " + e);
}
}
}
else
{
return false;
}
httpRequest.onreadystatechange = callback;
httpRequest.open("POST", dataSource, true);
httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if (postData == null)
{
httpRequest.send(null);
} else
{
var params = postData;
httpRequest.send(params);
}
}

//------------------------------------Usage--------------------------------
function submitAccessMaster(savetype)
{
//getform method retrieves all the values inside a form
fetchData(ProjAccessPath+'/hercules.do?do=accessmasterSet', getForm('iacmform'), updateAccessMaster);
}

function updateAccessMaster()
{ dojo.byId('iacserror').innerHTML="Saving";
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
var data=httpRequest.responseXML;
var acmins=data.getElementsByTagName("acmins")[0];
var insstatus=setAcsJSLine(acmins,"status");
var message=setAcsJSLine(acmins,"message");
var savetype=setAcsJSLine(acmins,"savetype");
if (insstatus=="success")
{
var acno=setAcsJSLineSerRslt(acmins,"acno");
var acname=setAcsJSLineSerRslt(acmins,"acname");
var acreorder=setAcsJSLineSerRslt(acmins,"reorder");
if(savetype=="Add")
{
var tbl=dojo.byId('searchresulttable');
var trow = tbl.insertRow(1);
trow.id='tr'+acno;
trow.onclick = function () {
klik(acno);
getAccessoryMaster(acno);
}
var tdno = trow.insertCell(0);
var tdname = trow.insertCell(1);
var tdreorder = trow.insertCell(2);
applytdstyle(tdno);
applytdstyle(tdname);
applytdstyle(tdreorder);
tdno.innerHTML=acno;
tdname.innerHTML=acname;
tdreorder.innerHTML=acreorder;
}
else if(savetype=="Edit")
{
var row = dojo.byId('tr'+acno);
var tdno = row.cells[0];
var tdname = row.cells[1];
var tdreorder = row.cells[2];
applytdstyle(tdno);
applytdstyle(tdname);
applytdstyle(tdreorder);
tdno.innerHTML=acno;
tdname.innerHTML=acname;
tdreorder.innerHTML=acreorder;
}

dojo.byId('accessnoTop').value=acno;
klik(acno);
}
else
{
if(savetype=="Add")
{
addnewStyle();
}
else if(savetype=="Edit")
{
doEditStyle();
}
}
dojo.byId('iacserror').innerHTML=message;
}
else
{
alert("Error retreiving data.");
}
}
}

//------------------------------------Library--------------------------------
function setFormData(formid,fmCntsName,fmCntsXml,XmlParent)
{
if(fmCntsName.length!=fmCntsXml.length)
{
alert("Mismatch in Names and XmlValues to set..");
return;
}

for( i=0; i < fmCntsName.length;i++)
{
document.getElementById(formid).elements[fmCntsName[i]].value=
setAcsJSLine(XmlParent,fmCntsXml[i]);
}
}
//---------------------------------------Usage---------------------------------

setFormData('iacmform',['accessdesc','uom','category','accesssalevalue','reorderlevel'],
['desc','uom','cat','sale','re'],ac);

Sunday, July 20, 2008

HTML Select Options via ajax

InnerHTML won't work with ie and firefox in HTML select,
but using ajax if we retrieve a page with<option>
tag, there is a good work around

from
http://elmicoxcodes.blogspot.com/2007/02/innerhtml-and-select-option-in-ie.html




Monday, June 30, 2008

Adding events and styles that work in both firefox2.0/3.0 and IE6.0

For Events in a table row
trow.onclick = function () {
fun1(acno); fun2(acno); } where trow=document.getElementById('id_row');

For styles in a table row

function applytdstyle(tdobj)
{
tdobj.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";
tdobj.style.fontSize="11px";
tdobj.style.color= "#666666";
tdobj.style.lineHeight="15px";
tdobj.style.paddingRight="2px";
tdobj.style.textAlign="center";
tdobj.style.borderBottom="solid 1px #d8d8d8";
tdobj.style.borderLeft="solid 1px #d8d8d8";
}
where tdobj=document.getElementById('id_col');

To insert a row with column and to get values from a row

Add
var tbl=dojo.byId('searchresulttable');
var trow = tbl.insertRow(1);
trow.id='tr'+acno;
trow.onclick = function () {
fun1(acno);
fun2(acno);
}
var tdno = trow.insertCell(0);
var tdname = trow.insertCell(1);
var tdreorder = trow.insertCell(2);
applytdstyle(tdno);
applytdstyle(tdname);
tdno.innerHTML=acno;
tdname.innerHTML=acname;

Get
var row = dojo.byId('tr'+acno);
var tdno = row.cells[0];
var tdname = row.cells[1];
applytdstyle(tdno);
applytdstyle(tdname);
tdno.innerHTML=acno;
tdname.innerHTML=acname;
------------------------------------------------
I believe these tips will be helpful for someone.

Eclipse plugin management easier way

Make a folder for each third party plugins...
if you do it by help-software updates-find and install ie, easy by specifying new path, else make a folder manually and in the help-softwareUpdates-ManageConfiguration...Add a link to the newly formed folder ie, enough
..else you can make use of links

Thursday, June 26, 2008

basic query order in Oracle


1. FROM/WHERE

2. ROWNUM is assigned

3. SELECT

4. GROUP BY

5. HAVING

6. ORDER BY












Tuesday, June 10, 2008

Custom Dojo Build

1. Add ant.bat to environment variable(if eclipse installed it is in its plugin folder otherwise download)
2. Put buildscripts,release,tests,src (with all files of dojo) and demo folders inside dojo folder.
3. Copy dojo.js,README and LICENSE files to the dojofolder
(the files are available from http://svn.dojotoolkit.org/branches/0.4/)
4. Put lib, profiles folder inside buildscripts folder.
5. Add these files(from above link inside buildscripts folder) build.xml,build_notice.txt,
buildUtil.js,buildUtilXd.js,copyright.txt,dojoGuardEnd.js,dojoGuardStart.js,
flattenResources.js,internStrings.js,makeDojoJs.js,stripComments.js,xdgen.js
6. Add ant_apache_bsf.jar,ant_dojotest.jar,bsf.jar,custom_rhino.jar,js.jar to lib folder.
7. Add foo.profile.js file inside profiles folder

its contents
____________

var dependencies = [
"dojo.event.*",
"dojo.widget.Menu2",
"dojo.widget.TabContainer",
"dojo.widget.Tooltip",
"dojo.widget.ContentPane",
"dojo.widget.LinkPane",
"dojo.widget.Button"
];

load("getDependencyList.js");

ie, required widgets depends upon your page.

8. Then run the command inside buildscripts folder

ant -Dprofile=foo -Dstrip_and_compress=true clean release

9. You can add options to get the css integrated into file and to remove comments

ant -Dprofile=foo -Dstrip_and_compress=true clean release intern-strings strip-resource-comments

Technorati Tags:

Wednesday, June 4, 2008

J2EE light weight framework platforms

Tomcat - Application Server
Hibernate - ORM
Struts2 - Multi-Action Web Framework
JSP - View Template
Dojo- Rich Client Widgets
Acegi - Authentication and authorization.
SiteMesh - Web page layout and decoration framework.
Quartz - Enterprise job scheduler.
Log4j - Logging Tool
OSCache - Simple Cache and Web Cache solution
bIRT Report - Report Engine
Lucene - Search engine
TPTP - unit test
Accele0->eclipse uml modelling mapping to struts & hibernate

Friday, May 30, 2008

Integrating BIRT with hibernate and struts (deploy in server tomcat)

Download WebViewer Example inside birt-runtime-2_2_2.zip from eclipse web site.
if you are using jdbc driver in hibernate copy that driver into WebViewerExample\WEB-INF\platform\plugins\org.eclipse.birt.report.data.oda.jdbc_2.2.2.r22x_v20071206\drivers
then merge your application's web.xml with the webviewerExample's web.xml. Then Copy
\article\sources\sources\src\org\eclipse\birt\samples\scripted\hibernate\CustomerList to your class. use your own hibernate factory and Abstractclass inside your application.
Also you should add mail.jar to the lib

Now design your report with scripted data source,
and write following script at its open

importPackage(Packages.org.eclipse.birt.samples.scripted.hibernate);
(if you have out the customerList in yourpackage then write
importPackage(Packages.yourpackage)
cul = CustomerList();
customers = cul.listCustomers("from Customer");
iterator = customers.iterator();


The Customers should be updated to your Abstract Class


write following script at its fetch

if(iterator.hasNext() == false ){
return false;
}

var customer = iterator.next( );

row["CUSTOMERNUMBER"] = customer.getCustomerNumber();
row["COUNTRY"] = customer.getCountry();
row["CONTACTLASTNAME"] = customer.getContactLastName();
row["CONTACTFIRSTNAME"] = customer.getContactFirstName();
row["PHONE"] = customer.getPhone();
row["SALESREPEMPLOYEENUMBER"] = customer.getSalesRepEmployeeNumber();
row["CUSTOMERNAME"] = customer.getCustomerName();

return true;

write following script at its closecul = null;
customers = null;
iterator = null;



You should update (BIRT Report Tool from Eclipse Site)
Help»Find and Install»Find new»Castillo-&amp»Editor and Report»Birt

If you are connected through proxy
Go to Windows»preferences»Find and Install
Set up the proxy settings and enable it.

you should do it each time(Dont know why aand how to over come it)


The Report Designer comes with Birt is of great help. You can create a simple report.
Add columns to datasource for scripted data set.

Following Attachments will be of great help.

article.rar

This attatchment contains a good tutorial and a sample file , ie, enough for a starting with WebViewerExample from eclipse website


Technorati Tags:

Saturday, May 17, 2008

Basic procedure/activities when an application calls a libray procedure

when an user application calls a libray procedure it puts some value according to the system service required into a register and int 30 will be executed.
When this is executed Operating systm system service will be called and sytem changes to kernel mode also, so that system service can call privileged instruction set.

In linux system service is exectued by a s/s interrupt which transfers the call to the architecture specific entry.s where a method system_entry is there and according to the number in the register this will executes the needed System service

Also every systm call is specified using a number in linux the relation can be seen in the asm/unistd.h file

Also the error returned status will be stored in the globakl variable errnoh which is stored in the errno.h file
Error constants can also be seen here.

Process Related
For each process that is maintained by the system a double linked list of struct task_struct(which is stored in <sched.h>) is stored

Inorder to spped the search a hash list is also kept in fork.c which names #pdhash

J2EE jboss-jvm_bind problem

J2EE

jboss-jvm_bind problem

go to windows console ie, comman prompt type:- netstat -ao you can see all the process ids that bind to every port of the system. Select the pid that binds to port that need to be used by jboss usually(1097 for jndi lookup...) go to windows task manager(ctrl+alt+delete) then go to process tab From the view menu select columns check out PID check box Find the process that matches the process id from netstat -ao kill or close that application