Wednesday, July 17, 2013

Maven


Test Single test class

>mvn clean test -Dtest=classname

Spring Tutorial

Spring IOC container.

  1. BeanFactory container
  2. Application Context container.
Difference between BeanFactory and Application context container and there internals.

Spring Bean Definition:

Lazy-init: Indicates whether or not this bean is to be lazily initialized. If false, it will be instantiated on startup by 
 bean factories that perform eager initialization of singletons. The default is "false". Note: This attribute will not be inherited by child bean definitions. Hence, it needs to be specified per concrete bean definition. 

init-method: The name of the custom initialization method to invoke after setting bean properties. The method must have no arguments, but may throw any exception. 

<!-- A bean definition with lazy init set on --> 
<bean id="..." class="..." lazy-init="true"> 
<!-- collaborators and configuration for this bean go here --> </bean> 

<!-- A bean definition with initialization method --> 
<bean id="..." class="..." init-method="..."> 
<!-- collaborators and configuration for this bean go here --> </bean> 

<!-- A bean definition with destruction method --> 
<bean id="..." class="..." destroy-method="..."> 
<!-- collaborators and configuration for this bean go here --> </bean>









Friday, June 28, 2013

MongoDB Warning: ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

Steps to resolve this problem.

1. stop the mongod process.
2. excecute the below command in the terminal. 
    $ ulimit -n 10000 
3. restart your mongod process.


Wednesday, January 30, 2013

Threads Synchronisation

Synchronized method:

case 1: non-static-methods: If a thread is accessing synchronized method of an object, then any another thread can not access any of the synchronized methods/synchronized blocks of that object.

case 2: static-methods: If synchronized method is declared static and if a thread is accessing that method, then any other thread can not access any of the static synchronized method of that class. the above statement is true even if the objects are different.

Synchronized blocks:

case 1:
Synchronized(this){
...
}

If a thread enters Synchronized block, then no other thread can access synchronized blocks and synchronized methods of that object.  

case 2:
Synchronized(obj){
...
}
If a thread enters the synchronized block as shown above. the lock is acquired on obj. so no other threads can access the synchronized methods and blocks of that obj.

case 3:
Synchronized(obj.class){
...
}
The only difference between the above case and this case is, lock is acquired at class level.