コード例 #1
0
  /**
   * @param properties - service properties
   * @throws InvalidRMIServiceException <br>
   *     If null properties provided, default properties will be used. <br>
   *     If non-null properties provided, only three properties will be used for RMI calls: <br>
   *     a) Context.SECURITY_PRINCIPAL <br>
   *     b) Context.PROVIDER_URL <br>
   *     c) Context.SECURITY_CREDENTIALS <br>
   *     If any of them missing in the input, the corresponding default properties will be used.
   *     <br>
   *     If the input properties are NOT sufficient for initializing a service, return null. <br>
   */
  public RMIIQMAppModuleServices(Properties properties) throws InvalidRMIServiceException {
    super();
    //        Utils.printTrace(false);
    //        Utils.printMessage("start ... " + Utils.convertToString(new java.util.Date()));

    // collect the configured properties and default properties
    Properties tmpProps = RMIIQMAppModuleServicesConstants.getDefaultProperties();
    if (properties != null) {
      if (properties.containsKey(Context.SECURITY_PRINCIPAL)) {
        tmpProps.setProperty( //
            Context.SECURITY_PRINCIPAL, //
            properties.getProperty(Context.SECURITY_PRINCIPAL));
      }
      if (properties.containsKey(Context.PROVIDER_URL)) {
        tmpProps.setProperty( //
            Context.PROVIDER_URL, //
            properties.getProperty(Context.PROVIDER_URL));
      }
      if (properties.containsKey(Context.SECURITY_CREDENTIALS)) {
        tmpProps.setProperty( //
            Context.SECURITY_CREDENTIALS, //
            properties.getProperty(Context.SECURITY_CREDENTIALS));
      }
    }
    if (!this.validateJNDIProperties(tmpProps)) {
      Utils.printTrace(false);
      Utils.printMessage("!!!!! invalid properties for JNDI initialization !!!!!");
      Utils.printMessage(tmpProps.toString());
      //            tmpProps.list(System.out);
      // TODO , question: is it right to exit here, instead of throwing exceptions?
      return;
    } else {
      appServiceProperties = tmpProps;
      //            if (appServiceProperties.containsKey("print.service.properties")
      //                &&
      // appServiceProperties.get("print.service.properties").toString().equalsIgnoreCase("Y")) {
      //                Utils.printMessage(appServiceProperties.toString());
      ////                appServiceProperties.list(System.out);
      //            }
    }
    try {
      initJNDI(appServiceProperties);
      //            CurrencyLookupVO.set(this.getCurrencyLookup());
      //            MarketLookupVO.set(this.getMarketLookup());
      //            ModelMetadataLookupVO.set(this.getModelMetadataLookup());
      AttributeConverter.init(this);
    } catch (NamingException e) {
      throw new InvalidRMIServiceException(e);
    } catch (InvalidServiceMethodCallException | JSONException ex) {
      throw new InvalidRMIServiceException(ex);
    }
  }
コード例 #2
0
  /**
   * No properties will be accepted, even the default ones This constructor will provide local
   * services instead of remote calling
   *
   * @param userName weblogic-user
   * @param pwd weblogic-pwd
   * @throws com.tr.rdss.generic.model.iqm.concordance.util.InvalidRMIServiceException
   */
  public RMIIQMAppModuleServices(String userName, String pwd) throws InvalidRMIServiceException {
    Properties property = new Properties();

    property.put(Context.SECURITY_PRINCIPAL, userName);
    property.put(Context.SECURITY_CREDENTIALS, pwd);

    try {
      initJNDI(appServiceProperties);
      AttributeConverter.init(this);
    } catch (NamingException e) {
      throw new InvalidRMIServiceException(e);
    } catch (InvalidServiceMethodCallException | JSONException ex) {
      throw new InvalidRMIServiceException(ex);
    }
  }