Saturday, September 8, 2012

Cost estimation of a software

Agenda -

Process of Estimation

Amount of work (LOC , Function Point , Object point)

Cost Estimation

Non equation based

Expert Judgement /Planning Poker
Analogy
Parkinson
Price-to-win:
Bottom up
Bottom Down

Equation based

 COCOMO
 COCOMO II
 SLIM





Thursday, July 12, 2012

Self-Integrity Check FAILED: java.lang.SecurityException: The jar file is not signed

I digged in this a lot .
This problem came when I exported executable Jar from eclipse I tried to connection a third party software which uses encryption for getting and sending messages .
If you bundle dependent jars in that executable jar JDK thinks that you have manipulated those jars and throws this security exception .
For creating executable Jar if you are using many thrid party jars always export those jars in folder with that jar otherwise be ready for exception  "Self-Integrity Check FAILED: java.lang.SecurityException: The jar file is not signed".
Many software write their own code for  jar integrity check (ie JAR provider details  ie manifest .mf file etc )to avoid malware and tampering of Jars .

In case of web applicartion this might come in case of JBOSS 5.1(if you migrate from 4.XX) for this case you have to move encryption jars to EAR level and set class path to those.

You can write you own code to verify integrity of jar .
for more details visit
How to Implement a Provider for the JavaTM Cryptography Extension

Thursday, May 31, 2012

Web Crawler and Search Engine with Apache Lucene and Tika.


Saturday, May 26, 2012

Cloud Computing demystified ...

Road Map :

1. Cloud computing is throwback to old mainframes
2.Need of cloud computing
3.Cloud Architecture
4.Impact on future
5.Impact on Developers ..
6.Currently available clouds
7. Security aspect of cloud.

Monday, March 19, 2012

Multiple active screens in pure MVC how to manage notification for particular screen ?

Inherently pure MVC does not provide support for managing multiple screens of same type in one flex application .There need a tweak in application for this .

Approach

1. Mediator Registration Names
Make name of mediator unique so that it will not be ignored as in case you register mediator with same name again for another same screen.
Sample code

In command or in view
var mediator:MyScreenMediator = new MyScreenMediator(this);
MyFacade.getInstance().registerMediator(mediator);
In MyScreenMediator.as

      public class MyScreenMediator extends Mediator
{
public static const NAME:String = "MyScreenMediator";
public function MyScreenMediator(viewComponent:MyScreen=null)
{
super(NAME + viewComponent.uid, viewComponent);
}
}
You can use this also
super(NAME + tinestamp, viewComponent); 

2. Introducing unique identifier for each screen so that mediator instance of that screen only able to listen its screen and not other screen .
You can use uid of screen for creating identifier .


Detailed implementation

1.Create a custom object for communication Object with command , proxy and mediator which will carry data and id of screen
 package salpe.model
{
public class MessageBody
{
//window ID
private var _id:String ;
// data
private var _data:Object;
public function MessageBody(id:String, data:Object)
{
_id = id;
_data = data;
}
public function get windowBranchId():String{
return _id;
}
public function get data():Object{
return _data;
}
}
}
2. Create interface which will be implemented by all screen which can be opened in multiple windows.
Better write base component and extend it .

Like >> MultiWindowVBox.mxml
 <?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
implements="salpe.model.interfaces.IMultiWindowSupportable">
<mx:Script>
<![CDATA[
private var _windowBranchId:String= "";
public function get windowBranchId():String{
return _windowBranchId;
}
public function set windowBranchId(id:String):void{
_windowBranchId = id;
}
]]>
</mx:Script>
</mx:VBox>

3. Write Base mediator which will be extended by mediators of screens which will be opened in multiple windows

 package salpe.view.mediators
{
salpe.model.MessageBody;
salpe.model.interfaces.IMultiWindowSupportable;
import mx.core.UIComponent;
import org.puremvc.as3.multicore.interfaces.IMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
import org.puremvc.as3.multicore.patterns.observer.Notification;
public class MultiWindowSupportBaseMediator extends Mediator implements IMediator
{
public function MultiWindowSupportBaseMediator(NAME:String ,viewComponent:Object)
{
super(NAME, viewComponent);
}
override public function handleNotification( note:INotification ):void{
var messageBody:MessageBody = note.getBody()as MessageBody;
if(null == messageBody){
// if this is not Custom notification
handleCustomNotifications(note);
}else{
//If this is Custom notification
// Check for target screen
if(!isMyNotification(MessageBody)){
return ;
}
var body :Object = MessageBody.data;
var mynote:Notification = new Notification(note.getName(),body,note.getType());
handleCustomNotifications(mynote);
}
}
public function isMyNotification(body:MessageBody):Boolean{
if(body.windowBranchId == (viewComponent as IMultiWindowSupportable).windowBranchId){
trace(body.windowBranchId);
return true;
}
return false;
}
public function handleCustomNotifications(note:INotification ):void {
throw new Error( "Abstract method" );
}
}
}
4. Facade of pure MVC

 package salpe.facade
{
public class MyFacade extends Facade implements IFacade
{
}
}

5. Create you screen

MyScreen.mxml


 <?xml version="1.0" encoding="utf-8"?>
<custom:MultiWindowVBox
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()"
xmlns:custom="salpe.view.components.custom.*">
<mx:Script>
<![CDATA[
[bindable]private var _count:Number = 0;
//Register Mediator -
private function init():void{
var mediator:MyScreenMediator = new MyScreenMediator(this);
MyFacade.getInstance().registerMediator(mediator);
}
public function increaseCountNotification():void{
MyFacade.sendNotification("INCREASE_COUNT",new MessageBody(windowBranchId,_count),"REQUEST");
}
public function increaseCount():void{
_count++;
}
]]>
</mx:Script>
<sas:Label text="WELCOME TO MULTIPLE WINDOW {_count}" />
<mx:Button id="myButton" label="Increase Count on This screen Only "
click="increaseCountNotification();"/>
</custom:MultiWindowVBox>


6.In Mediator MyScreenMediator.as

Handle "INCREASE_COUNT" Notification here .This notification will be ignored by all other screens as windowBrandId is different for each screen .

 package salpe.view.mediators
{
import salpe.view.components.MyScreen;
import mx.collections.ArrayCollection;
import org.puremvc.as3.multicore.interfaces.IMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
public class MyScreenMediator extends MultiWindowSupportBaseMediator
{
public static const NAME:String = "MyScreenMediator";
public function MyScreenMediator(viewComp:MyScreen=null)
{
// Register with unique Name
super(NAME + viewComp.uid, viewComp);
}
override public function listNotificationInterests():Array
{
return [
"INCREASE_COUNT"
];
}
override public function handleCustomNotifications(note:INotification):void
{
var name:String = note.getName();
var body:Object = note.getBody();
var type:String = note.getType();
switch(name){
case "INCREASE_COUNT":
(viewComponent as MyScreen).increaseCount();
break;
}
}
}

Thursday, January 19, 2012

One or more resources have the target of 'head', but no 'head' component has been defined within the view.

This error comes due to wrong namespace reference to your header tag. In JSF all html tags are used with prefix <h:YOU_HTML_TEG>

Your template before error

BasicTemplate.xhtml



<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">


<f:view>

<head>

<link href="css/default.css" rel="stylesheet" type="text/css" />
<title><ui:insert name="title">FREE ENGLISH WORDS</ui:insert></title>

</head>


<body>

<div id="header">
<ui:insert name="header">
<!-- include your header file or uncomment the include below and create header.xhtml in this directory -->
<ui:include src="./SALHeader.xhtml"/>
</ui:insert>
</div>


<div id="content">
<ui:insert name="content">
Content area. See comments below this line in the source.
<!-- include your content file or uncomment the include below and create content.xhtml in this directory -->
<!-- <div> -->
<!-- <ui:include src="content.xhtml"/> -->
<!-- </div> -->
</ui:insert>
</div>

<div id="footer">
<ui:insert name="footer">
<!-- include your header file or uncomment the include below and create footer.xhtml in this directory -->
<ui:include src="./SALFooter.xhtml"/>
</ui:insert>
</div>

</body>
</f:view>
</html>




After Error Removed

BasicTemplate.xhtml



<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">


<f:view>

<h:head>

<link href="css/default.css" rel="stylesheet" type="text/css" />
<title><ui:insert name="title">FREE ENGLISH WORDS</ui:insert></title>

</h:head>


<body>

<div id="header">
<ui:insert name="header">
<!-- include your header file or uncomment the include below and create header.xhtml in this directory -->
<ui:include src="./SALHeader.xhtml"/>
</ui:insert>
</div>


<div id="content">
<ui:insert name="content">
Content area. See comments below this line in the source.
<!-- include your content file or uncomment the include below and create content.xhtml in this directory -->
<!-- <div> -->
<!-- <ui:include src="content.xhtml"/> -->
<!-- </div> -->
</ui:insert>
</div>

<div id="footer">
<ui:insert name="footer">
<!-- include your header file or uncomment the include below and create footer.xhtml in this directory -->
<ui:include src="./SALFooter.xhtml"/>
</ui:insert>
</div>

</body>
</f:view>
</html>

Wednesday, January 18, 2012

Hibernet - Partial Loading of entity ,

May be for optimization of JVM memory we need partial loaded object with only specified fields with values from DB .
Without using projection you can get such partially loaded by using transformer .
But I think following code is elegant example ..


1. DB TABLE

USER_TABLE , DB Table >>

columns

USER_ID (INT(10))
USER_NAME(VARCHAR(50))


2. MODEL CLASS

User.java - Model Class

 Public class User{
private int userId;
private String userName ;
..
..
..
AND MANY OTHER PROPERTIES
// Getters and Setters for id and name and for other props
}


3. Hibernet settings

In hibernet config xml



 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.salpe.dao.model.User"
lazy="false" table="USER_TABLE" >
<id name="userId" column="USER_ID"/>
<property name="userName" column="USER_NAME" />
---
------
----
<!--MANY OTHER PROPERTIES -->
</class>
</hibernate-mapping>

4. DAO class

SessionFactoryUtil >> Way to get hibernet session 
 Public class UserDaoImpl {
public static List<User> getPariallyLoadedUsers(int userId){
Criteria crit = SessionFactoryUtil.getInstance().getCurrentSession()
.createCriteria(User.class);
ProjectionList usrList = Projections.projectionList();
// Laoding only user id and user name and Other properties as Null or default 0 ;
proList.add(Projections.property("userId"),"userId");
proList.add(Projections.property("userName"),"userName");
crit.setProjection(usrList);
crit.add(Restrictions.eq("userId",Integer.toString(projectId)));
crit.setResultTransformer(
Transformers.aliasToBean(User.class));
List<User> list = crit.list();
return list;
}

NOTE : FOR DB OPTIMIZATION IS BETTER TO OPTIMIZE ON NUMBER OF ROWS QUERY IS FETCHING RATHER THAN ON NUMBER OF FIELDS/COLUMNS.But I am giving this as just example .