Archive for the ‘ Uncategorized ’ Category

Creating a custom measure in sonar

Hi All,

I was working on sonar analysis and created a custom measure. (Well I have used reference from sonar repository).

I thought of sharing information on sonar, how we can add a new measure and customize the analysis.

Please refer to the document attached.Sonar Plugin

More plugins can be found at : http://svn.codehaus.org/sonar-plugins/trunk

 

Advertisements

Porting Web application to GGTS IDE

Hello,

When we port any web application into GGTS, sometimes build is not successful using IDE. We just simply add our application to sever and publish it but alas! ¬†ūüė¶ Our application is not deployed properly into deployment directory of server.

I have faces this sever issue for long time then i looked into .settings folder and could see in ‘org.eclipse.wst.common.component’ file we have options to set our build option to copy our resources from source to destination deployment directory.

Here you can add your properties.

In case your jar files are not copied to destination and you are using maven for build then you will have problem to provide source folder name, so here is the workaround.

Build your application using maven and find the path of lib folders then give this folder as source.

sample:¬†¬†<wb-resource deploy-path=”/WEB-INF/lib” source-path=”/target/{context-name}/WEB-INF/lib” />

Sunil

 

Accepting multiple date formats using rich calendar

Accepting multiple date formats using rich calendar

https://community.jboss.org/wiki/AcceptingMultipleDateFormatsInRichcalendar

Preventing cloning of Object in while using singleton design pattern

Hi All,

Using singleton design pattern is a best way to access a valuable resource. In this case we do use Singleton design pattern and stops clients classes to create multiple instances of the Class.

But there is a loophole in this pattern and one can create instance of the Singleton class using object cloning.

So we should prevent cloning of object in this class as well if required.

Code given below gives a brief idea of how to stop client class to clone an object.

package com.sun;

/** * @author Sunil Chauraha */

class Clone1 implements  Cloneable{

@Override protected Object clone() throws CloneNotSupportedException

throw new CloneNotSupportedException(“Cloning of this class is not supported by me…”);

}
public class CloneTest  {

public static void main(String[] args) {

try{

Clone1 clone1 = new Clone1();

Clone1  clone2 = (Clone1)clone1.clone();

}catch (CloneNotSupportedException e) {

System.err.println(e.getMessage()+”: “+e);

}

}

}

Class loading and java reflection

Here is some simple example of class loading and java reflection.

package com.sun;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.sun1.TestClass;
public class MainClass {
@SuppressWarnings(“unchecked”)
public static void main(String[] args) {
System.out.println(“Testing classloading…”);
try{
Class clazz = Class.forName(“com.sun1.TestClass”);
Method [] methods = clazz.getDeclaredMethods();
TestClass tc = new TestClass();
for (Method method : methods) {
try{
method.invoke(tc, new Object[]{“Sunil Chauraha”});
}catch(InvocationTargetException e){
System.err.println(e.getMessage());
}catch (IllegalAccessException e) {
System.err.println(e.getMessage());
}
}
}catch(ClassNotFoundException cnf){
System.err.println(cnf.getMessage()+” : “+cnf);
}
}
}

package com.sun1;
public class TestClass {
public void pring(String value){
System.out.println(“The value passed is : “+value);
}
}

UML Diagram and Eclipse

Hello………….

Here are the links for uml plug in configuration with eclipse.

http://www.seasar.org/en/tutorial/eclipse/uml_omondo/index.html

http://www.vogella.de/articles/UML/article.html#umltools_diagram

Global warming

When the word “Global warming” comes into mind or on voice or in ears. I start thinking who is responsible for this ever ending problem? I think, in fact i am sure that me, you and they all are responsible for this outcome. As a human being what we are doing or what we have done or what we are going to do. Some where that follows¬†Einstein’s E=MC2 and produces unnecessary energy and the global warming increases by 0.000000001 % or more.

My dear friend please think something outstanding or wonderful thing that can decrease the rate of increase in¬†temperature……… Continue reading