0 Replies Latest reply on May 18, 2010 9:38 AM by bhavsar.er

    how to call SLSB from struts action class ?

    bhavsar.er

      Hi,

       

      Please note that i am using ejb 3.0 first time and having all Stateless beans in my application at present. we are using struts action classes for accessing SLSB in the following manner. Kindly let me know are we doing it in the right manner ?

       

      public class EksServiceFactory {
         
          private static EksServiceFactory factory = null;
          private static Map<String,Object> localsMap = null;
          private Context ctx=null;

       

          private EksServiceFactory() throws NamingException {
              ctx = new InitialContext();
              localsMap = new HashMap<String, Object>();
          }

       

          public static synchronized EksServiceFactory getInstance() throws NamingException{
              if(factory == null){
                  factory = new EksServiceFactory();
              }
              return factory;       
          }

       

          public Object getEksService(String jndiName) throws NamingException {   
              Object obj = localsMap.get(jndiName);
              if(obj==null) {
                  obj = ctx.lookup(jndiName);
                  localsMap.put(jndiName, obj);
              }       
              return obj;
          }   
      } getEksService(String jndiName) throws NamingException {   

              EksService eksService = (EksService)localsMap.get(jndiName);
              if(eksService==null) {
                  eksService = (EksService)ctx.lookup(jndiName);
                  localsMap.put(jndiName, eksService);
              }       
              return eksService;
          }   
      }