1 package org.bsf.remoting; 2 3 import org.bsf.remoting.EJBDefinition; 4 import org.bsf.remoting.http.HttpServiceFactory; 5 6 10 public class SampleMain { 11 12 15 private static HttpServiceFactory factory = 16 new HttpServiceFactory("localhost", 8080,"remoting"); 17 18 21 26 private static final EJBDefinition TEST_SESSION = new EJBDefinition( 27 "ejb/TestSession","org.bsf.remoting.StatelessTestHome", 28 "org.bsf.remoting.StatelessTest" 29 ); 30 31 32 33 public static void main(String [] args) { 34 35 StatelessTest myService = (StatelessTest) 37 factory.getService(TEST_SESSION); 38 39 try { 40 String upperWord = myService.upper("word"); 42 System.out.println("Result : " + upperWord); 43 44 StatefulTest myStateful = myService.createStateful(); 47 String name = myStateful.getEJBName(); 48 System.out.println("Statefull EJB Name : " + name); 49 50 51 factory.setLogin("myLogin"); 53 factory.setPassword("myPass"); 54 55 if ("myLogin".equals(myService.getCallerPrincipal())){ 57 System.out.println("That's me"); 58 } 59 60 61 } catch (java.rmi.RemoteException e) { 62 e.printStackTrace(); 63 } 64 } 65 } 66 | Popular Tags |