Esempio n. 1
0
  /**
   * Main constructor used from POA::create_POA. This need only be visible within the POA package.
   */
  Policies(Policy[] policies, int id) throws InvalidPolicy {
    // Make sure the defaults are set according to the POA spec
    this();

    defaultObjectCopierFactoryId = id;

    if (policies == null) return;

    // Set to record all indices in policies for which errors
    // were observed.
    BitSet errorSet = new BitSet(policies.length);

    for (short i = 0; i < policies.length; i++) {
      Policy policy = policies[i];
      int POAPolicyValue = getPOAPolicyValue(policy);

      // Save the policy in policyMap to support
      // POA.get_effective_policy, if it was not already saved
      // in policyMap.
      Integer key = new Integer(policy.policy_type());
      Policy prev = (Policy) (policyMap.get(key));
      if (prev == null) policyMap.put(key, policy);

      if (POAPolicyValue >= 0) {
        setPolicyValue(key.intValue(), POAPolicyValue);

        // if the value of this POA policy was previously set to a
        // different value than the current value given in
        // POAPolicyValue, record an error.
        if ((prev != null) && (getPOAPolicyValue(prev) != POAPolicyValue)) errorSet.set(i);
      }
    }

    // Check for bad policy combinations

    // NON_RETAIN requires USE_DEFAULT_SERVANT or USE_SERVANT_MANAGER
    if (!retainServants() && useActiveMapOnly()) {
      addToErrorSet(policies, SERVANT_RETENTION_POLICY_ID.value, errorSet);
      addToErrorSet(policies, REQUEST_PROCESSING_POLICY_ID.value, errorSet);
    }

    // IMPLICIT_ACTIVATION requires SYSTEM_ID and RETAIN
    if (isImplicitlyActivated()) {
      if (!retainServants()) {
        addToErrorSet(policies, IMPLICIT_ACTIVATION_POLICY_ID.value, errorSet);
        addToErrorSet(policies, SERVANT_RETENTION_POLICY_ID.value, errorSet);
      }

      if (!isSystemAssignedIds()) {
        addToErrorSet(policies, IMPLICIT_ACTIVATION_POLICY_ID.value, errorSet);
        addToErrorSet(policies, ID_ASSIGNMENT_POLICY_ID.value, errorSet);
      }
    }

    checkForPolicyError(errorSet);
  }