Skip to main content

Posts

Showing posts from 2012

Java Map

Maps in java are very useful for storing key value pairs. Map is an interface and is a part of Collections framework. However there are many implementations of Map interface, here I am discussing only java.util.HashMap and java.util.TreeMap. java.util.HashMap uses its own hashing algorithm to save the keys (You don't have to worry about it !) . The advantages of hashmap is almost equal time consumption in retrieving the keys. Suppose we a million objects as keys in a HashMap then, it takes almost equal time in getting any key (hasmap.get(any key)). This performance comes at a price . You do not get keys in order . The order is completely decided by java. Lets take an example. Let us make Person class whose objects we will store as keys in map. So here is our Person class class Person { private int age = 0; private String name = ""; public Person(String name,int age) { this.name = name; this.age = age; } public static Person[] getPersons(){ return n...

JMS with jboss 4

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBoss//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd"> <jboss> <enterprise-beans> <session> <ejb-name>ejbs/sessionBeans/MyTestSession</ejb-name> <jndi-name>ejb/MyTestSession</jndi-name> </session> <message-driven> <ejb-name>ejbs/mdbs/QueueMdb</ejb-name> <destination-jndi-name>queue/B</destination-jndi-name>             <resource-ref>                 <res-ref-name>QCF</res-ref-name>                 <jndi-name>ConnectionFactory</jndi-name>             </resource-ref>         </message-driven> <message-driven> <ejb-name>ejbs/mdbs/AnotherQueueMDB</ejb-name> <de...

EJB with jboss 4

Running EJB (EJB 2) with jboss (jboss 4) requires some setup. I am trying to explain the steps one needs to for EJB to work with jboss . File 1 :- MyTestSession.java package ejbs.sessionBeans; import java.rmi.RemoteException; import javax.ejb.EJBObject; public interface MyTestSession extends EJBObject{ public String sayHello() throws RemoteException; } File 2 :- MyTestSessionHome.java package ejbs.sessionBeans; import java.rmi.RemoteException; import java.sql.SQLException; import javax.ejb.EJBException; import javax.naming.NamingException; public interface MyTestSessionHome extends javax.ejb.EJBHome{ public MyTestSession create() throws javax.ejb.CreateException,EJBException, RemoteException, NamingException; } File 3 :- MyTestSessionBean.java package ejbs.sessionBeans; import java.rmi.RemoteException; import javax.ejb.EJBException; import javax.ejb.EJBHome; import javax.ejb.EJBObject; import javax.ejb.Handle; import javax.ejb.RemoveException; import ...