S A M P L E   P R O J E C T  
   { 
      try 
      { 
         return super.clone(); 
      } 
      catch( CloneNotSupportedException cnse ) 
      { 
         // This never happens 
         return null; 
      } 
   } 
} 
Coding the clients 
Coding the client is pretty simple in the first place. The client only has to look up the Home 
Interface of the EJB it wants talk to, create or find an instance of this EJB through the 
Home Interface. Now methods on the EJB can be invoked and so on to perform the client's 
tasks. A simple client look like this: 
package test.client; 
import javax.naming.InitialContext; 
import javax.rmi.PortableRemoteObject;  
import test.interfaces.TestSession; 
import test.interfaces.TestSessionHome; 
public class TestClient { 
   public static void main(String[] args){ 
      try { 
         InitialContext lContext = new InitialContext(); 
         TestSessionHome lHome = (TestSessionHome) lContext.lookup( "ejb/test/TestSession" 
); 
         TestSession lSession = lHome.create(); 
         // Get a new Id of the Test Entity 
         int lId = lSession.getNewEntityId(); 
         System.out.println( "New Entity Id is: " + lId ); 
         lSession.remove(); 
      } catch( Exception e ){ 
         e.printStackTrace(); 
      } 
   } 
} 
How to Run the Template 
Now we are ready to let this simple test compile, deploy and run. Three steps are necessary 
to do so: 
    
Ensure that your JBoss instance is running (which  jboss.home  property in the file 
 .ant.properties  points to) 
32






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

best web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved