Wednesday, May 18, 2011

use maven to create a basic project

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.2 -DgroupId=com.travelsoft.services -DartifactId=HostServices

When Agile/Scrum should NOT be used

Today I read this article, it is very interesting. And I agree most of the points he list there. Details please check. http://blog.matrixresources.com/blog/when-agilescrum-should-not-be-used

Below are the list of quotes which I think are useful.

1. Non-High Profile Project
2. Stable Technology
3. No Major Process Innovation
4. Requirements are Stable
5. Quick Time to Market not Needed

Resource Characteristics:

1. Inability to Co-located
2. Low Cost Talent Available
3. Team Size Varies
Company Characteristics:

1. Command and Control Company Culture: “dictator” type project management
2. Contracts Require Full Scope and Documentation

Tuesday, May 17, 2011

Encrypt a password in JPA persistent.xml

Below is a example how to encrypt password in JPA persistent.

1. Generate a encrypted password (See previous blog)
2. Add below entrance into spring applicationcontext.xml




PBEWithMD5AndDES


JAMES_PWD


4





strongHibernateStringEncryptor







3. change persistent.xml




value="org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider"/>

How to encrypt password in spring configuration file

I just finish a project which use "jasypt" to encrypt the password in spring configuration file. Below are the steps and notes.

1. Regarding Maven entrance, please check below

org.jasypt
jasypt
1.7.1

2. Develop a program to encrypt password.

StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm("PBEWithMD5AndDES");
encryptor.setPassword("JAMES_PWD"); // could be got from web, env variable...
return encryptor.encrypt(input) ;
3. Create a environment variable to hold temporary password
APP_ENCRYPTION_PASSWORD = JAMES_PWD

4. Change your spring configuration file to read property from file.


class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">





class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">


-->






class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">



classpath:connection.properties



Tuesday, April 26, 2011

Comments after reading Test First development blog

Today, I read this very interesting blog regarding Test first development, link is below.
http://xebee.xebia.in/2011/04/26/take-aways-from-dr-venkats-session-on-test-first-development/

There are something really draw my attentions:

1. the importance of creating an environment to make people do the right thing than to force them to do it. The right environment can be created through leading by example and assertive communication
2. Hiring by attitude, and train for skill.
3. he gave a magnificent example by citing a movie "A Few Good Men". He told that during an argument inside the court in the movie, someone quoted a rule. And then, Tom Cruise came with the rule book in his hand asking the other person to show him rules for each and everything that he did ( "You eat 3 times a day, can you show it in the rule book. Oh God, How can you eat 3 times a day when its not written in the rule book").
4. in the end, he said, sometimes its almost impossible to correct things and then you can say to yourself that its just a job. In my home, I can do and will do things exactly the way I like, however, in a job, this might not be the case.

Wednesday, April 20, 2011

How to get file from filename

Recently I had a issue regarding how to read a file, as in eclipse environment and actually server environment, the relative directory is different, it caused a lot of problem, below it is a example which works for both environment.

File file ;
URL url = this.getClass().getClassLoader().getResource(fileName);

try {
file = new File(url.toURI());
} catch(URISyntaxException e) {
file = new File(url.getPath());
}

or to a string

URL loadedResource = this.getClass().getClassLoader().getResource(fileName);


InputStream inputStream = loadedResource.openStream();

BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
inputStream.close();
return sb.toString();

Tuesday, April 12, 2011

How to get salary increase by Eric spiegel

5) A developer’s best chance at achieving a maximum salary increase is to negotiate during the hiring process. Once you are on board, you are at the company’s mercy unless you bail

Very interesting idea I have to agree