Advertisement
Guest User

Start.java

a guest
Aug 15th, 2012
4,551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1. package grahamsprojclient.main;
  2.  
  3. import grahamsprojserver.session.delegate.GrahamsProjBean;
  4. import grahamsprojserver.session.interfaces.GrahamsProjBeanRemote;
  5. import java.util.Hashtable;
  6. import java.util.Properties;
  7. import javax.naming.Context;
  8. import javax.naming.InitialContext;
  9. import javax.naming.NamingException;
  10.  
  11. /*
  12.  * To change this template, choose Tools | Templates
  13.  * and open the template in the editor.
  14.  */
  15.  
  16. /**
  17.  *
  18.  * @author gbaldeck
  19.  */
  20. public class Start {
  21.  
  22.     /**
  23.      * @param args the command line arguments
  24.      */
  25.     public static void main(String[] args) throws Exception {
  26.        
  27.         testItAll();
  28.     }
  29.    
  30.     private static void testItAll() throws NamingException {
  31.         System.out.println("Testing has begun!!!");
  32.        
  33.         GrahamsProjBeanRemote testMe = connectToStatelessBean();
  34.        
  35.         testMe.test();
  36.     }
  37.    
  38.     private static GrahamsProjBeanRemote connectToStatelessBean() throws NamingException {
  39.         Properties jndiProperties = new Properties();
  40.         jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
  41.         jndiProperties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
  42.         jndiProperties.put(javax.naming.Context.PROVIDER_URL, "remote://localhost:4447");
  43.         jndiProperties.put(javax.naming.Context.SECURITY_PRINCIPAL, "userA");
  44.         jndiProperties.put(javax.naming.Context.SECURITY_CREDENTIALS, "airit");
  45.         final Context context = new InitialContext(jndiProperties);
  46.        
  47.         final String appName = "GrahamsProjServer";
  48.         final String moduleName = "GrahamsProjServer";
  49.         final String distinctName = "";
  50.         final String beanName = GrahamsProjBean.class.getSimpleName();
  51.         final String viewClassName = GrahamsProjBeanRemote.class.getName();
  52.        
  53.         System.out.println("ejb:"+appName+"/"+moduleName+"/"+distinctName+"/"+beanName+"!"+viewClassName);
  54.        
  55.         return (GrahamsProjBeanRemote) context.lookup("ejb:"+appName+"/"+moduleName+"/"+distinctName+"/"+beanName+"!"+viewClassName);
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement