Пример #1
0
  /**
   * Method that gets the initial context with the parameters to establish the connection
   *
   * @param params load the URl, the EAR JNDI Name and the security credentials for the initial
   *     connection if this object is null load the values from a properties files
   * @return The Initial Context to make the JNDI Connection
   * @throws NamingException An exception if some of the given parameters could not load in the
   *     Context
   */
  public Context getInitialContext(Map<String, String> params) throws NamingException {
    Properties properties = new Properties();

    if (null != params) {

      String usr = params.get(LOCATOR_USER);
      if (null != usr) properties.put(Context.SECURITY_PRINCIPAL, usr);

      String pwd = params.get(LOCATOR_PWD);
      if (null != pwd) properties.put(Context.SECURITY_CREDENTIALS, pwd);
    }

    properties.put(
        Context.INITIAL_CONTEXT_FACTORY,
        bundleManager.getProperty(Context.INITIAL_CONTEXT_FACTORY));
    properties.put(Context.URL_PKG_PREFIXES, bundleManager.getProperty(Context.URL_PKG_PREFIXES));

    properties.put(Context.PROVIDER_URL, bundleManager.getProperty(Context.PROVIDER_URL));

    return new InitialContext(properties);
  }
Пример #2
0
 private ServiceLocator(Map<String, String> params) {
   bundleManager = new ResourceBundleManager(PROPERTIES_PATH);
   EAR_JNDI_NAME = bundleManager.getProperty(EAR_JNDI_NAME_KEY);
   this.setContextParams(params);
 }
Пример #3
0
 private ServiceLocator() {
   bundleManager = new ResourceBundleManager(PROPERTIES_PATH);
   EAR_JNDI_NAME = bundleManager.getProperty(EAR_JNDI_NAME_KEY);
 }