Information

2
Story Points

Technologies

Decompiled Java File
package mx.com.bcm.banamex.ae.negocio.design;

import java.util.Hashtable;
import java.util.Map;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

public class ServiceLocator {
   private InitialContext context;
   private static Map service = new Hashtable();
   private static ServiceLocator me = new ServiceLocator();

   public static ServiceLocator getInstance() {
      return me;
   }

   public Class remoteloockUp(String jndiName, Class a) {
      Object obje = this.loockUp(jndiName);
      return (Class)PortableRemoteObject.narrow(obje, a);
   }

   private Hashtable getConnection() {
      Hashtable properties = new Hashtable();
      properties.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
      properties.put("java.naming.provider.url", "iiop://localhost:2809");
      return properties;
   }

   public Object loockUp(String jndiName) {
      Object obj = null;
      Hashtable properties = this.getConnection();
      if(service.containsKey(jndiName)) {
         return service.get(jndiName);
      } else {
         try {
            this.context = new InitialContext(properties);
            obj = this.context.lookup(jndiName);
         } catch (NamingException var5) {
            System.out.println("Naming Exception occurred :");
            var5.printStackTrace();
         }

         service.put(jndiName, obj);
         return obj;
      }
   }
}
Page generated: Oct 19, 2017 2:34:18 PM