hashCode and equals method

In java world, hashCode & equals method plays a very important role. Uses of equals():- In java, equals() method used to assure equality of object and it should follow mathematics rule of equality. Reflexive: Always, a = a. In Java, a.equals(a) should always be true. Symmetric: If a = b, then b = a. In Java, if a.equals(b) is … Continue reading hashCode and equals method

Thread synchronization, object level locking and class level locking

Object level locking:- Synchronization means synchronizing state changes of Object and that we can achieve it via synchronizing block in any java class. Suppose we have a java class with few instance variable whose values get changed i.e state of objects for that class get changed time to time. To avoid data corruption or inconsistency, … Continue reading Thread synchronization, object level locking and class level locking

Java Monitoring API (Jamon)

JAMon is a free Java monitoring API , used to monitor your application or fine tuning your application performance. Do following steps to use JAmon in your code copy jamon-2.7.jar in classpath Add these lines to your code where to like to monitor // start the JAMon monitor Monitor mon = MonitorFactory.start(“Your Label”); … your … Continue reading Java Monitoring API (Jamon)

How To Load Multiple Spring Bean Configuration File

Loading Multiple Spring Bean Configuration File  Put all spring xml files under project classpath.  Define one main module beans configuration file. Say AppContext.xml <beans xmlns=”http://www.springframework.org/schema/beans&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd”&gt;   <import resource=”classpath:AppServicesContext.xml”/> <import resource=”classpath:AppConnectionContext.xml”/> <import resource=”classpath:AppModuleA.xml”/> <import resource=”classpath:AppModuleB.xml”/> </beans> Now you can load a single xml file like this : ApplicationContext context = new ClassPathXmlApplicationContext(“AppContext.xml”);  

Using Property File in Spring

Often times, Spring developers keep there configuration value in XML file itself. Say for example DB setting as <bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”> <property name=”driverClassName” value=”com.mysql.jdbc.Driver” /> <property name=”url” value=”jdbc:mysql://localhost:3306/rr” /> <property name=”username” value=”root” /> <property name=”password” value=”password” /> </bean> But, in a corporate environment, deployment detail is usually only can ‘touch’ by your system or database … Continue reading Using Property File in Spring