Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, August 30, 2012

How to know the version of the java/j2ee application deployed?



Many occasions, you might have come across the circumstances where you may want to know the version of the application deployed for particular instances like System testing, UAT and production. Possible situations are,
1. As part of post deployment activity, you may wanted to ensure the whether the deployed build(s) is successfully deployed or not.
2. To see the version of the build deployed in production (to know the stable version of the build). You might have seen many open source applications for this. 

Ant target to achieve the same:


Java Class file that can read the MANIFEST.MF file attributes:
Code is self explanatory.   We have a small piece of Code to get the ServertContext from FacesContext.  If you are not using JSF, replace with relevant code base.





JSF presentation file used to display the MANIFEST.MF file attributes:
Below is the design view of the presentation. Bean attribute values will be populated using VersionInfoMFReader.java class file as mentioned above. Here, presentation values will be populated from the bean as below.




We have implemented the above version info reader in our application. Sample application screen print attached below. 







Monday, March 19, 2012

Java Anti Patterns:


I had gone through core java design patterns last week (I am sure I will consolidate my learning with simple examples and post you in my blog. I will try to keep as much as my own examples).

We have a proverb in our native language that “If you wanna become good doctor, you should have killed 100+ patients”. What they try to say here is if we want to give the best, we should have experience/come across as many nastiest.  

So, before I start my Java design patterns, I had gone through few Java Anti patterns which are readily available in the internet. I found the below link gives you Insite on Java Anti patterns. Hope you enjoy as well.

Please share me if you find any good link for Java Anti patterns.

http://www.odi.ch/prog/design/newbies.php

Saturday, February 4, 2012

Password Encryption using Java

Hi Guyz,

My Business Unit is in the process of creating a new development process tool something like Teamtracker for Internal purpose. I was identified as a secondary developer to complete the tool three weeks back. Almost 70% of the development activities have been completed so far. Within an application, we have list of users and their credential details, roles and projects etc.. and those details were stored in database as a plain text.

Early this week I got a requirement from my BA to replace the exiting “plain text” passwords to “hash codes“ and he gave me only 2 hrs to complete the requirement. I was afraid to take that task when I heard it from him. Since the application is built with Spring framework, I thought I can apply ACEGI framework to apply security with in the application. Considering the fact TIME (Existing application code rewrite and the estimation – always worrying factor), thought of do some Google Search and see if I can find anything exciting.

I found a very interesting article on Password Encryption using java code (http://www.devbistro.com/articles/Java/Password-Encryption). Beauty of this article is it is self explanatory, it doesn't require any third party jar files. With in 15 mins of time, I was able to complete the requirement.

Thought of sharing my learning’s to my readers as well. Hope you also enjoy! Happy programming.


Cheers

Nanjudan Chinnasamy

Saturday, August 13, 2011

Java Inner Class

/*
*
*
*/
package com.blx.learn.java.core.innerclass;

/**
* This is an example Java Inner class which demonstrate various Inner classes
* available
*
* @author Nanjundan Chinnasamy
* @version 1.0
*
*/
public class LearnInnerClass {

/**
* This is a sample Member Inner class defined inside a class
*
* This inner class is instance specific to the outer class
* (LearnInnerClass). Object can be created for this class using Outer class
* object.
*
* @author Nanjundan Chinnasamy
* @version 1.0
*/
class MemberInnerClass {

/**
* Member class method
*/
public void testMethod() {
System.out.println("This is member class testMethod method");
}

/**
* Static class method
*/
public void memberlassMthd() {
// To access member class method
this.testMethod();
// To access outer class method
LearnInnerClass.this.testMethod();
}
}

/**
* This is a sample Static Member Inner class defined inside a class. Member
* class defined as static. Like other static methods, member class has
* access to all.
*
* @author Nanjundan Chinnasamy
* @version 1.0
*
*/
static class StaticMemberInnerClass {

/**
* Static class method
*/
public void testMethod() {
System.out.println("This is static class testMethod method");
}

/**
* Static class method
*/
public void staticMemClassMthd() {
this.testMethod();
}

}

/**
* Method to testMethod local Inner class
*/
void localClassMethod() {

/**
* This is local class exists inside the method. This can be reference
* only within this method.
*
* @author Nanjundan Chinnasamy
* @version 1.0
*
*/
class LocalInnerClass {
public void testMethod() {
System.out.println("This is local class testMethod mthod.");
}
}
// To access local class methods
new LocalInnerClass().testMethod();
// To access outer class methods
testMethod();

}

/**
* Method to testMethod anonymous inner class
*
*/
void anonymousClassMethod() {

/**
* Anonymous Inner class declared inside a method without any name. JVM
* will create its own name during the compile time.
*
* Such implementation might required the places where to create an
* object instances w/o creating sub class and override their methods
*
* @author Nanjundan Chinnasamy
*
* @version 1.0
*/
Runnable runnable = new Runnable() {
@Override
public void run() {
System.out.println("This is anonymous inner class");
}
};
Thread thread = new Thread(runnable);
thread.run();
}

/**
* This is an out class testMethod method
*/
void testMethod() {
System.out.println("I am outer class testMethod method");
}

/**
* @param args
*/
public static void main(String[] args) {

// This is for static member class
LearnInnerClass.StaticMemberInnerClass staticMemberInnerClass = new StaticMemberInnerClass();
staticMemberInnerClass.staticMemClassMthd();

// This is for member class
MemberInnerClass memberInnerClass = new LearnInnerClass().new MemberInnerClass();
memberInnerClass.testMethod();

// This is for Local Inner class
LearnInnerClass outerClassForLocInnTst = new LearnInnerClass();
outerClassForLocInnTst.localClassMethod();

// This is for anonymous inner class
LearnInnerClass outerClassForAnomysClassTst = new LearnInnerClass();
outerClassForAnomysClassTst.anonymousClassMethod();

}

}


Output:
This is static class testMethod method
This is member class testMethod method
This is local class testMethod mthod.
I am outer class testMethod method
This is anonymous inner class

Pega Decisioning Consultant - Mission Test Quiz & Answers

The Pega Certified Decisioning Consultant (PCDC) certification is for professionals participating in the design and development of a Pega ...