Exemplo n.º 1
0
  /**
   * Writes any java.lang.Object as a CORBA any.
   *
   * @param out the stream in which to write the any.
   * @param obj the object to write as an any.
   */
  public void writeAny(org.omg.CORBA.portable.OutputStream out, java.lang.Object obj) {
    org.omg.CORBA.ORB orb = out.orb();

    // Create Any
    Any any = orb.create_any();

    // Make sure we have a connected object...
    java.lang.Object newObj = Utility.autoConnect(obj, orb, false);

    if (newObj instanceof org.omg.CORBA.Object) {
      any.insert_Object((org.omg.CORBA.Object) newObj);
    } else {
      if (newObj == null) {
        // Handle the null case, including backwards
        // compatibility issues
        any.insert_Value(null, createTypeCodeForNull(orb));
      } else {
        if (newObj instanceof Serializable) {
          // If they're our Any and ORB implementations,
          // we may want to do type code related versioning.
          TypeCode tc = createTypeCode((Serializable) newObj, any, orb);
          if (tc == null) any.insert_Value((Serializable) newObj);
          else any.insert_Value((Serializable) newObj, tc);
        } else if (newObj instanceof Remote) {
          ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
        } else {
          ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
        }
      }
    }

    out.write_any(any);
  }
Exemplo n.º 2
0
  /**
   * Test that jacorb handles some self-constructed broken typecodes well. The constructed typecode
   * is in principal recursive, but not flagged as such.
   */
  public void testBrokenRecursiveTypecode() {
    Any innerAny = orb.create_any();
    innerAny.insert_long(4711);

    StructMember[] members = {new StructMember("myAny", innerAny.type(), null)};

    TypeCode innerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            members);

    TypeCode outerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            new StructMember[] {new StructMember("foo", innerTc, null)});

    org.jacorb.orb.CDROutputStream out = new org.jacorb.orb.CDROutputStream(orb);
    out.write_TypeCode(outerTc);
    org.jacorb.orb.CDRInputStream in = new org.jacorb.orb.CDRInputStream(orb, out.getBufferCopy());

    out = new org.jacorb.orb.CDROutputStream(orb);

    // need to write out typecode, to check it's consistency completely
    out.write_TypeCode(in.read_TypeCode());
  }
 /*    */ public static void insert(Any paramAny, IORInterceptor_3_0 paramIORInterceptor_3_0)
       /*    */ {
   /* 17 */ OutputStream localOutputStream = paramAny.create_output_stream();
   /* 18 */ paramAny.type(type());
   /* 19 */ write(localOutputStream, paramIORInterceptor_3_0);
   /* 20 */ paramAny.read_value(localOutputStream.create_input_stream(), type());
   /*    */ }
Exemplo n.º 4
0
 // This method could very well be moved into TypeCodeImpl or a common utility class,
 // but is has to be in this package.
 public static Any extractAnyFromStream(TypeCode memberType, InputStream input, ORB orb) {
   Any returnValue = orb.create_any();
   OutputStream out = returnValue.create_output_stream();
   TypeCodeImpl.convertToNative(orb, memberType).copy(input, out);
   returnValue.read_value(out.create_input_stream(), memberType);
   return returnValue;
 }
Exemplo n.º 5
0
  public void foo() throws InterceptorOrderingException {
    try {
      Current current = (Current) orb.resolve_initial_references("PICurrent");

      Any any = current.get_slot(MyInitializer.slot_id);

      String s = any.extract_string();
      System.out.println("TestObjectImpl.foo, extracted from PICurrent: >>" + s + "<<");

      String expectedPiFlow =
          "JacOrbRocks:receive_request_service_contexts:preinvoke:receive_request:foo";
      if (!expectedPiFlow.equals(s)) {
        System.out.println("### THROWING EX " + expectedPiFlow + " and " + s);
        throw new InterceptorOrderingException();
      }

      System.out.println("TestObjectImpl.foo calling bar()");
      TestObjectHelper.narrow(_this_object()).bar();

    } catch (InterceptorOrderingException e) {
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 /*     */ public static void insert(Any paramAny, ValueMember[] paramArrayOfValueMember)
       /*     */ {
   /*  49 */ OutputStream localOutputStream = paramAny.create_output_stream();
   /*  50 */ paramAny.type(type());
   /*  51 */ write(localOutputStream, paramArrayOfValueMember);
   /*  52 */ paramAny.read_value(localOutputStream.create_input_stream(), type());
   /*     */ }
Exemplo n.º 7
0
  public void receive_request_service_contexts(ServerRequestInfo ri) {
    ServiceContext ctx;
    try {
      ctx = ri.get_request_service_context(SERVICE_ID);
    } catch (org.omg.CORBA.BAD_PARAM e) {
      logger.debug(
          "tid=" + Thread.currentThread().getName() + "," + "**Service context was not specified");
      return;
    }

    if (null == ctx) {
      logger.debug("tid=" + Thread.currentThread().getName() + "," + "**Service context is null");
      return;
    }

    try {
      Any slotDataAsAny = codec.decode(ctx.context_data);

      // Get the slot data as a string
      String slotDataAsStr;
      if (null == (slotDataAsStr = slotDataAsAny.extract_string())) {
        logger.debug("slotDataAsStr=<null>");
      } else {
        logger.debug("slotDataAsStr=" + slotDataAsStr);
      }

      slotDataAsStr += ":receive_request_service_contexts";

      slotDataAsAny.insert_string(slotDataAsStr);

      ri.set_slot(slot_id, slotDataAsAny);
    } catch (Exception e) {
      throw new INTERNAL("Caught " + e);
    }
  }
 public static SystemException extractSystemException(Any any) {
   InputStream in = any.create_input_stream();
   ORB orb = (ORB) (in.orb());
   if (!isSystemExceptionTypeCode(any.type(), orb)) {
     throw wrapper.unknownDsiSysex(CompletionStatus.COMPLETED_MAYBE);
   }
   return ORBUtility.readSystemException(in);
 }
Exemplo n.º 9
0
 /*      */ public Any extractAny(TypeCode paramTypeCode, ORB paramORB) /*      */ {
   /* 1315 */ Any localAny = paramORB.create_any();
   /* 1316 */ org.omg.CORBA.portable.OutputStream localOutputStream =
       localAny.create_output_stream();
   /* 1317 */ TypeCodeImpl.convertToNative(paramORB, paramTypeCode)
       .copy(this.stream, localOutputStream);
   /* 1318 */ localAny.read_value(localOutputStream.create_input_stream(), paramTypeCode);
   /* 1319 */ return localAny;
   /*      */ }
Exemplo n.º 10
0
 /**
  * Static method for writing a CORBA standard exception to an Any.
  *
  * @param any The Any to write the SystemException into.
  */
 public static void insertSystemException(SystemException ex, Any any) {
   OutputStream out = any.create_output_stream();
   ORB orb = (ORB) (out.orb());
   String name = ex.getClass().getName();
   String repID = ORBUtility.repositoryIdOf(name);
   out.write_string(repID);
   out.write_long(ex.minor);
   out.write_long(ex.completed.value());
   any.read_value(out.create_input_stream(), getSystemExceptionTypeCode(orb, repID, name));
 }
Exemplo n.º 11
0
  public void setUpTest() throws Exception {
    trueAny = getClientORB().create_any();
    trueAny.insert_boolean(true);

    falseAny = getClientORB().create_any();
    falseAny.insert_boolean(false);

    fifoOrder = getClientORB().create_any();
    fifoOrder.insert_short(FifoOrder.value);

    lifoOrder = getClientORB().create_any();
    lifoOrder.insert_short(LifoOrder.value);

    deadlineOrder = getClientORB().create_any();
    deadlineOrder.insert_short(DeadlineOrder.value);

    priorityOrder = getClientORB().create_any();
    priorityOrder.insert_short(PriorityOrder.value);

    anyOrder = getClientORB().create_any();
    anyOrder.insert_short(AnyOrder.value);

    bestEffort = getClientORB().create_any();
    bestEffort.insert_short(BestEffort.value);

    persistent = getClientORB().create_any();
    persistent.insert_short(Persistent.value);
  }
Exemplo n.º 12
0
 /*      */ public static Any extractAnyFromStream(
     TypeCode paramTypeCode, org.omg.CORBA.portable.InputStream paramInputStream, ORB paramORB)
       /*      */ {
   /* 1325 */ Any localAny = paramORB.create_any();
   /* 1326 */ org.omg.CORBA.portable.OutputStream localOutputStream =
       localAny.create_output_stream();
   /* 1327 */ TypeCodeImpl.convertToNative(paramORB, paramTypeCode)
       .copy(paramInputStream, localOutputStream);
   /* 1328 */ localAny.read_value(localOutputStream.create_input_stream(), paramTypeCode);
   /* 1329 */ return localAny;
   /*      */ }
Exemplo n.º 13
0
  public byte[] encode_value(Any data) throws InvalidTypeForEncoding {
    final CDROutputStream out = new CDROutputStream(orb);

    try {
      out.setGIOPMinor(giopMinor);

      out.beginEncapsulatedArray();
      data.write_value(out);

      /*
      closing must not be done, since it will patch the
      array with a size!

      try
      {
      out.endEncapsulation();
      }
      catch (java.io.IOException e)
      {
      }
      */

      /*
       * We have to copy anyway since we need an exact-sized array.
       * Closing afterwards, to return buffer to BufferManager.
       */
      byte[] result = out.getBufferCopy();

      return result;
    } finally {
      out.close();
    }
  }
Exemplo n.º 14
0
  //
  // Create a new AnyImpl which is a copy of obj.
  //
  public AnyImpl(ORB orb, Any obj) {
    this(orb);

    if ((obj instanceof AnyImpl)) {
      AnyImpl objImpl = (AnyImpl) obj;
      typeCode = objImpl.typeCode;
      value = objImpl.value;
      object = objImpl.object;
      isInitialized = objImpl.isInitialized;

      if (objImpl.stream != null) stream = objImpl.stream.dup();

    } else {
      read_value(obj.create_input_stream(), obj.type());
    }
  }
 /** Extract the exception from the given {@link Any}. */
 public static InvalidName extract(Any a) {
   try {
     return ((InvalidNameHolder) a.extract_Streamable()).value;
   } catch (ClassCastException ex) {
     throw new BAD_OPERATION();
   }
 }
Exemplo n.º 16
0
 /*      */ public AnyImpl(ORB paramORB, Any paramAny) /*      */ {
   /*  193 */ this(paramORB);
   /*      */
   /*  195 */ if ((paramAny instanceof AnyImpl)) {
     /*  196 */ AnyImpl localAnyImpl = (AnyImpl) paramAny;
     /*  197 */ this.typeCode = localAnyImpl.typeCode;
     /*  198 */ this.value = localAnyImpl.value;
     /*  199 */ this.object = localAnyImpl.object;
     /*  200 */ this.isInitialized = localAnyImpl.isInitialized;
     /*      */
     /*  202 */ if (localAnyImpl.stream != null)
       /*  203 */ this.stream = localAnyImpl.stream.dup();
     /*      */ }
   /*      */ else {
     /*  206 */ read_value(paramAny.create_input_stream(), paramAny.type());
     /*      */ }
   /*      */ }
Exemplo n.º 17
0
  public Any decode_value(byte[] data, TypeCode tc) throws FormatMismatch, TypeMismatch {
    final CDRInputStream in = new CDRInputStream(orb, data);

    try {
      in.setGIOPMinor(giopMinor);

      in.openEncapsulatedArray();
      Any result = orb.create_any();
      result.read_value(in, tc);

      // not necessary, since stream is never used again
      // in.closeEncasupaltion();

      return result;
    } finally {
      in.close();
    }
  }
 /**
  * Extract the TaggedComponent from given Any. This method uses the TaggedComponentHolder.
  *
  * @throws BAD_OPERATION if the passed Any does not contain TaggedComponent.
  */
 public static TaggedComponent extract(Any any) {
   try {
     return ((TaggedComponentHolder) any.extract_Streamable()).value;
   } catch (ClassCastException cex) {
     BAD_OPERATION bad = new BAD_OPERATION("TaggedComponent expected");
     bad.minor = Minor.Any;
     bad.initCause(cex);
     throw bad;
   }
 }
 /** Extract the naming context from the given {@link Any}. */
 public static NamingContextExt extract(Any a) {
   try {
     return ((NamingContextExtHolder) a.extract_Streamable()).value;
   } catch (ClassCastException ex) {
     BAD_OPERATION bad = new BAD_OPERATION("NamingContextExt expected");
     bad.initCause(ex);
     bad.minor = Minor.Any;
     throw bad;
   }
 }
Exemplo n.º 20
0
  /**
   * <code>test192Op</code> dummy impl.
   *
   * @return an <code>boolean</code> value depending upon the result of the interceptors. true for
   *     local; false for not local.
   */
  public boolean test192Op() {
    boolean result = false;

    try {
      Current current = (Current) orb.resolve_initial_references("PICurrent");

      Any anyName = current.get_slot(SInitializer.slotID);

      result = anyName.extract_boolean();
    } catch (InvalidSlot e) {
      e.printStackTrace();
      throw new INTERNAL(e.toString());
    } catch (InvalidName e) {
      e.printStackTrace();
      throw new INTERNAL(e.toString());
    }

    return result;
  }
Exemplo n.º 21
0
  public AdminPropertySet(Configuration config) {
    super();

    try {
      int _maxConsumersDefault =
          config.getAttributeAsInteger(
              Attributes.MAX_NUMBER_CONSUMERS, Default.DEFAULT_MAX_NUMBER_CONSUMERS);
      Any _maxConsumersDefaultAny = sORB.create_any();
      _maxConsumersDefaultAny.insert_long(_maxConsumersDefault);

      //////////////////////////////

      int _maxSuppliersDefault =
          config.getAttributeAsInteger(
              Attributes.MAX_NUMBER_SUPPLIERS, Default.DEFAULT_MAX_NUMBER_SUPPLIERS);

      Any _maxSuppliersDefaultAny = sORB.create_any();
      _maxSuppliersDefaultAny.insert_long(_maxSuppliersDefault);

      //////////////////////////////

      int _maxQueueLength =
          config.getAttributeAsInteger(
              Attributes.MAX_QUEUE_LENGTH, Default.DEFAULT_MAX_QUEUE_LENGTH);

      Any _maxQueueLengthAny = sORB.create_any();
      _maxQueueLengthAny.insert_long(_maxQueueLength);

      //////////////////////////////

      boolean _rejectNewEvents =
          config
              .getAttribute(Attributes.REJECT_NEW_EVENTS, Default.DEFAULT_REJECT_NEW_EVENTS)
              .equals("on");

      Any _rejectNewEventsAny = sORB.create_any();
      _rejectNewEventsAny.insert_boolean(_rejectNewEvents);

      //////////////////////////////

      defaultProperties_ =
          new Property[] {
            new Property(MaxConsumers.value, _maxConsumersDefaultAny),
            new Property(MaxSuppliers.value, _maxSuppliersDefaultAny),
            new Property(MaxQueueLength.value, _maxQueueLengthAny),
            new Property(RejectNewEvents.value, _rejectNewEventsAny)
          };

      set_admin(defaultProperties_);
    } catch (ConfigurationException ex) {
      throw new INTERNAL("Configuration exception" + ex);
    }
  }
 /**
  * Extract the ObjectNotActive from given Any.
  *
  * @throws BAD_OPERATION if the passed Any does not contain ObjectNotActive.
  */
 public static ObjectNotActive extract(Any any) {
   try {
     EmptyExceptionHolder h = (EmptyExceptionHolder) any.extract_Streamable();
     return (ObjectNotActive) h.value;
   } catch (ClassCastException cex) {
     BAD_OPERATION bad = new BAD_OPERATION("ObjectNotActive expected");
     bad.minor = Minor.Any;
     bad.initCause(cex);
     throw bad;
   }
 }
Exemplo n.º 23
0
  private void addStringToSlotId(String methodName, ServerRequestInfo ri) {
    try {
      Any slotDataAsAny = ri.get_slot(slot_id);

      // Get the slot data as a string
      String s = null;
      String slotDataAsStr = "<no_slot_data>";
      if (slotDataAsAny.type().kind().value() != org.omg.CORBA.TCKind._tk_null
          && null != (s = slotDataAsAny.extract_string())) {
        slotDataAsStr = s;
      }

      slotDataAsStr += ":" + methodName;

      slotDataAsAny.insert_string(slotDataAsStr);

      ri.set_slot(slot_id, slotDataAsAny);
    } catch (Exception e) {
      throw new INTERNAL("Caught " + e);
    }
  }
Exemplo n.º 24
0
  /** Throws a ForwardRequest */
  public void send_request(ClientRequestInfo ri) throws ForwardRequest {

    String objectIdString = null;

    try {
      RCobjectId = JavaIdlRCServiceInit._poa.reference_to_id(ri.effective_target());
      objectIdString = new String(RCobjectId);

      if (JavaIdlRCServiceInit.RC_ID.equals(objectIdString)) {
        Any indicator = ri.get_slot(IndicatorSlotId);
        if (indicator.type().kind().equals(TCKind.tk_null)) {
          ri.add_request_service_context(RCctx, false);
        }
      }
    } catch (Exception ex) {
      jtsLogger.i18NLogger.warn_orbspecific_jacorb_recoverycoordinators_ClientForwardInterceptor_4(
          ex);
    }

    if (!in_loop) {
      in_loop = true;
      if (JavaIdlRCServiceInit.RC_ID.equals(objectIdString)) {

        if (ri.effective_target()._is_a(RecoveryCoordinatorHelper.id())) {
          /*
           * Extract the substring of the ObjectId that contains the Uid and
           * the Process Id and pass it to the data of the service context
           */
          RCobjectId = extractObjectId(objectIdString).getBytes(StandardCharsets.UTF_8);
          RCctx = new ServiceContext(RecoveryContextId, RCobjectId);
          in_loop = false;
          throw new ForwardRequest(reco);
        } else {
          in_loop = false;
        }
      }
      in_loop = false;
    }
  }
Exemplo n.º 25
0
  /**
   * checks for equality between Anys.
   *
   * @param otherAny the Any to be compared with.
   * @result true if the Anys are equal, false otherwise.
   */
  public boolean equal(Any otherAny) {
    // debug.log ("equal");

    if (otherAny == this) return true;

    // first check for typecode equality.
    // note that this will take aliases into account
    if (!typeCode.equal(otherAny.type())) return false;

    // Resolve aliases here
    TypeCode realType = realType();

    // _REVISIT_ Possible optimization for the case where
    // otherAny is a AnyImpl and the endianesses match.
    // Need implementation of CDRInputStream.equals()
    // For now we disable this to encourage testing the generic,
    // unoptimized code below.
    // Unfortunately this generic code needs to copy the whole stream
    // at least once.
    //    if (AnyImpl.isStreamed[realType.kind().value()]) {
    //        if (otherAny instanceof AnyImpl) {
    //            return ((AnyImpl)otherAny).stream.equals(stream);
    //        }
    //    }
    switch (realType.kind().value()) {
        // handle primitive types
      case TCKind._tk_null:
      case TCKind._tk_void:
        return true;
      case TCKind._tk_short:
        return (extract_short() == otherAny.extract_short());
      case TCKind._tk_long:
        return (extract_long() == otherAny.extract_long());
      case TCKind._tk_ushort:
        return (extract_ushort() == otherAny.extract_ushort());
      case TCKind._tk_ulong:
        return (extract_ulong() == otherAny.extract_ulong());
      case TCKind._tk_float:
        return (extract_float() == otherAny.extract_float());
      case TCKind._tk_double:
        return (extract_double() == otherAny.extract_double());
      case TCKind._tk_boolean:
        return (extract_boolean() == otherAny.extract_boolean());
      case TCKind._tk_char:
        return (extract_char() == otherAny.extract_char());
      case TCKind._tk_wchar:
        return (extract_wchar() == otherAny.extract_wchar());
      case TCKind._tk_octet:
        return (extract_octet() == otherAny.extract_octet());
      case TCKind._tk_any:
        return extract_any().equal(otherAny.extract_any());
      case TCKind._tk_TypeCode:
        return extract_TypeCode().equal(otherAny.extract_TypeCode());
      case TCKind._tk_string:
        return extract_string().equals(otherAny.extract_string());
      case TCKind._tk_wstring:
        return (extract_wstring().equals(otherAny.extract_wstring()));
      case TCKind._tk_longlong:
        return (extract_longlong() == otherAny.extract_longlong());
      case TCKind._tk_ulonglong:
        return (extract_ulonglong() == otherAny.extract_ulonglong());

      case TCKind._tk_objref:
        return (extract_Object().equals(otherAny.extract_Object()));
      case TCKind._tk_Principal:
        return (extract_Principal().equals(otherAny.extract_Principal()));

      case TCKind._tk_enum:
        return (extract_long() == otherAny.extract_long());
      case TCKind._tk_fixed:
        return (extract_fixed().compareTo(otherAny.extract_fixed()) == 0);
      case TCKind._tk_except:
      case TCKind._tk_struct:
      case TCKind._tk_union:
      case TCKind._tk_sequence:
      case TCKind._tk_array:
        InputStream copyOfMyStream = this.create_input_stream();
        InputStream copyOfOtherStream = otherAny.create_input_stream();
        return equalMember(realType, copyOfMyStream, copyOfOtherStream);

        // Too complicated to handle value types the way we handle
        // other complex types above. Don't try to decompose it here
        // for faster comparison, just use Object.equals().
      case TCKind._tk_value:
      case TCKind._tk_value_box:
        return extract_Value().equals(otherAny.extract_Value());

      case TCKind._tk_alias:
        throw wrapper.errorResolvingAlias();

      case TCKind._tk_longdouble:
        // Unspecified for Java
        throw wrapper.tkLongDoubleNotSupported();

      default:
        throw wrapper.typecodeNotSupported();
    }
  }
Exemplo n.º 26
0
 public static void insert(final Any any, final SASCurrent s) {
   any.insert_Object(s);
 }
Exemplo n.º 27
0
  // Needed for equal() in order to achieve linear performance for complex types.
  // Uses up (recursively) copies of the InputStream in both Anys that got created in equal().
  private boolean equalMember(TypeCode memberType, InputStream myStream, InputStream otherStream) {
    // Resolve aliases here
    TypeCode realType = realType(memberType);

    try {
      switch (realType.kind().value()) {
          // handle primitive types
        case TCKind._tk_null:
        case TCKind._tk_void:
          return true;
        case TCKind._tk_short:
          return (myStream.read_short() == otherStream.read_short());
        case TCKind._tk_long:
          return (myStream.read_long() == otherStream.read_long());
        case TCKind._tk_ushort:
          return (myStream.read_ushort() == otherStream.read_ushort());
        case TCKind._tk_ulong:
          return (myStream.read_ulong() == otherStream.read_ulong());
        case TCKind._tk_float:
          return (myStream.read_float() == otherStream.read_float());
        case TCKind._tk_double:
          return (myStream.read_double() == otherStream.read_double());
        case TCKind._tk_boolean:
          return (myStream.read_boolean() == otherStream.read_boolean());
        case TCKind._tk_char:
          return (myStream.read_char() == otherStream.read_char());
        case TCKind._tk_wchar:
          return (myStream.read_wchar() == otherStream.read_wchar());
        case TCKind._tk_octet:
          return (myStream.read_octet() == otherStream.read_octet());
        case TCKind._tk_any:
          return myStream.read_any().equal(otherStream.read_any());
        case TCKind._tk_TypeCode:
          return myStream.read_TypeCode().equal(otherStream.read_TypeCode());
        case TCKind._tk_string:
          return myStream.read_string().equals(otherStream.read_string());
        case TCKind._tk_wstring:
          return (myStream.read_wstring().equals(otherStream.read_wstring()));
        case TCKind._tk_longlong:
          return (myStream.read_longlong() == otherStream.read_longlong());
        case TCKind._tk_ulonglong:
          return (myStream.read_ulonglong() == otherStream.read_ulonglong());

        case TCKind._tk_objref:
          return (myStream.read_Object().equals(otherStream.read_Object()));
        case TCKind._tk_Principal:
          return (myStream.read_Principal().equals(otherStream.read_Principal()));

        case TCKind._tk_enum:
          return (myStream.read_long() == otherStream.read_long());
        case TCKind._tk_fixed:
          return (myStream.read_fixed().compareTo(otherStream.read_fixed()) == 0);
        case TCKind._tk_except:
        case TCKind._tk_struct:
          {
            int length = realType.member_count();
            for (int i = 0; i < length; i++) {
              if (!equalMember(realType.member_type(i), myStream, otherStream)) {
                return false;
              }
            }
            return true;
          }
        case TCKind._tk_union:
          {
            Any myDiscriminator = orb.create_any();
            Any otherDiscriminator = orb.create_any();
            myDiscriminator.read_value(myStream, realType.discriminator_type());
            otherDiscriminator.read_value(otherStream, realType.discriminator_type());

            if (!myDiscriminator.equal(otherDiscriminator)) {
              return false;
            }
            TypeCodeImpl realTypeCodeImpl = TypeCodeImpl.convertToNative(orb, realType);
            int memberIndex = realTypeCodeImpl.currentUnionMemberIndex(myDiscriminator);
            if (memberIndex == -1) throw wrapper.unionDiscriminatorError();

            if (!equalMember(realType.member_type(memberIndex), myStream, otherStream)) {
              return false;
            }
            return true;
          }
        case TCKind._tk_sequence:
          {
            int length = myStream.read_long();
            otherStream.read_long(); // just so that the two stream are in sync
            for (int i = 0; i < length; i++) {
              if (!equalMember(realType.content_type(), myStream, otherStream)) {
                return false;
              }
            }
            return true;
          }
        case TCKind._tk_array:
          {
            int length = realType.member_count();
            for (int i = 0; i < length; i++) {
              if (!equalMember(realType.content_type(), myStream, otherStream)) {
                return false;
              }
            }
            return true;
          }

          // Too complicated to handle value types the way we handle
          // other complex types above. Don't try to decompose it here
          // for faster comparison, just use Object.equals().
        case TCKind._tk_value:
        case TCKind._tk_value_box:
          org.omg.CORBA_2_3.portable.InputStream mine =
              (org.omg.CORBA_2_3.portable.InputStream) myStream;
          org.omg.CORBA_2_3.portable.InputStream other =
              (org.omg.CORBA_2_3.portable.InputStream) otherStream;
          return mine.read_value().equals(other.read_value());

        case TCKind._tk_alias:
          // error resolving alias above
          throw wrapper.errorResolvingAlias();

        case TCKind._tk_longdouble:
          throw wrapper.tkLongDoubleNotSupported();

        default:
          throw wrapper.typecodeNotSupported();
      }
    } catch (BadKind badKind) { // impossible
      throw wrapper.badkindCannotOccur();
    } catch (Bounds bounds) { // impossible
      throw wrapper.boundsCannotOccur();
    }
  }
Exemplo n.º 28
0
 public static SASCurrent extract(final Any any) {
   return narrow(any.extract_Object());
 }
Exemplo n.º 29
0
  public void establish_components(IORInfo info) {

    // get the OTSPolicy and InvocationPolicy objects

    OTSPolicy otsPolicy = null;

    try {
      otsPolicy = (OTSPolicy) info.get_effective_policy(OTS_POLICY_TYPE.value);
    } catch (INV_POLICY e) {
      // ignore. This implies an policy was not explicitly set.
      // A default value will be used instead.
    }

    InvocationPolicy invPolicy = null;
    try {
      invPolicy = (InvocationPolicy) info.get_effective_policy(INVOCATION_POLICY_TYPE.value);
    } catch (INV_POLICY e) {
      // ignore. This implies an policy was not explicitly set.
      // A default value will be used instead.
    }

    // get OTSPolicyValue and InvocationPolicyValue from policy objects.

    short otsPolicyValue = FORBIDS.value; // default value
    short invPolicyValue = EITHER.value; // default value

    if (otsPolicy != null) {
      otsPolicyValue = otsPolicy.value();
    }

    if (invPolicy != null) {
      invPolicyValue = invPolicy.value();
    }

    // use codec to encode policy value into an CDR encapsulation.

    Any otsAny = ORB.init().create_any();
    Any invAny = ORB.init().create_any();

    otsAny.insert_short(otsPolicyValue);
    invAny.insert_short(invPolicyValue);

    byte[] otsCompValue = null;
    byte[] invCompValue = null;
    try {
      otsCompValue = this.codec.encode_value(otsAny);
      invCompValue = this.codec.encode_value(invAny);
    } catch (InvalidTypeForEncoding e) {
      throw new INTERNAL();
    }

    // create IOR TaggedComponents for OTSPolicy and InvocationPolicy.

    TaggedComponent otsComp = new TaggedComponent(TAG_OTS_POLICY.value, otsCompValue);
    TaggedComponent invComp = new TaggedComponent(TAG_INV_POLICY.value, invCompValue);

    // add ior components.

    info.add_ior_component(otsComp);
    info.add_ior_component(invComp);
  }
Exemplo n.º 30
0
 /*      */ private boolean equalMember(
     TypeCode paramTypeCode,
     org.omg.CORBA.portable.InputStream paramInputStream1,
     org.omg.CORBA.portable.InputStream paramInputStream2)
       /*      */ {
   /*  369 */ TypeCode localTypeCode = realType(paramTypeCode);
   /*      */ try
   /*      */ {
     /*      */ int j;
     /*      */ int m;
     /*  372 */ switch (localTypeCode.kind().value())
     /*      */ {
         /*      */ case 0:
         /*      */ case 1:
         /*  376 */ return true;
         /*      */ case 2:
         /*  378 */ return paramInputStream1.read_short() == paramInputStream2.read_short();
         /*      */ case 3:
         /*  380 */ return paramInputStream1.read_long() == paramInputStream2.read_long();
         /*      */ case 4:
         /*  382 */ return paramInputStream1.read_ushort() == paramInputStream2.read_ushort();
         /*      */ case 5:
         /*  384 */ return paramInputStream1.read_ulong() == paramInputStream2.read_ulong();
         /*      */ case 6:
         /*  386 */ return paramInputStream1.read_float() == paramInputStream2.read_float();
         /*      */ case 7:
         /*  388 */ return paramInputStream1.read_double() == paramInputStream2.read_double();
         /*      */ case 8:
         /*  390 */ return paramInputStream1.read_boolean() == paramInputStream2.read_boolean();
         /*      */ case 9:
         /*  392 */ return paramInputStream1.read_char() == paramInputStream2.read_char();
         /*      */ case 26:
         /*  394 */ return paramInputStream1.read_wchar() == paramInputStream2.read_wchar();
         /*      */ case 10:
         /*  396 */ return paramInputStream1.read_octet() == paramInputStream2.read_octet();
         /*      */ case 11:
         /*  398 */ return paramInputStream1.read_any().equal(paramInputStream2.read_any());
         /*      */ case 12:
         /*  400 */ return paramInputStream1
             .read_TypeCode()
             .equal(paramInputStream2.read_TypeCode());
         /*      */ case 18:
         /*  402 */ return paramInputStream1.read_string().equals(paramInputStream2.read_string());
         /*      */ case 27:
         /*  404 */ return paramInputStream1
             .read_wstring()
             .equals(paramInputStream2.read_wstring());
         /*      */ case 23:
         /*  406 */ return paramInputStream1.read_longlong() == paramInputStream2.read_longlong();
         /*      */ case 24:
         /*  408 */ return paramInputStream1.read_ulonglong()
             == paramInputStream2.read_ulonglong();
         /*      */ case 14:
         /*  411 */ return paramInputStream1.read_Object().equals(paramInputStream2.read_Object());
         /*      */ case 13:
         /*  413 */ return paramInputStream1
             .read_Principal()
             .equals(paramInputStream2.read_Principal());
         /*      */ case 17:
         /*  416 */ return paramInputStream1.read_long() == paramInputStream2.read_long();
         /*      */ case 28:
         /*  418 */ return paramInputStream1.read_fixed().compareTo(paramInputStream2.read_fixed())
             == 0;
         /*      */ case 15:
         /*      */ case 22:
         /*  421 */ int i = localTypeCode.member_count();
         /*  422 */ for (int k = 0; k < i; k++) {
           /*  423 */ if (!equalMember(
               localTypeCode.member_type(k), paramInputStream1, paramInputStream2)) {
             /*  424 */ return false;
             /*      */ }
           /*      */ }
         /*  427 */ return true;
         /*      */ case 16:
         /*  430 */ Any localAny1 = this.orb.create_any();
         /*  431 */ Any localAny2 = this.orb.create_any();
         /*  432 */ localAny1.read_value(paramInputStream1, localTypeCode.discriminator_type());
         /*  433 */ localAny2.read_value(paramInputStream2, localTypeCode.discriminator_type());
         /*      */
         /*  435 */ if (!localAny1.equal(localAny2)) {
           /*  436 */ return false;
           /*      */ }
         /*  438 */ TypeCodeImpl localTypeCodeImpl =
             TypeCodeImpl.convertToNative(this.orb, localTypeCode);
         /*  439 */ int n = localTypeCodeImpl.currentUnionMemberIndex(localAny1);
         /*  440 */ if (n == -1) {
           /*  441 */ throw this.wrapper.unionDiscriminatorError();
           /*      */ }
         /*  443 */ if (!equalMember(
             localTypeCode.member_type(n), paramInputStream1, paramInputStream2)) {
           /*  444 */ return false;
           /*      */ }
         /*  446 */ return true;
         /*      */ case 19:
         /*  449 */ j = paramInputStream1.read_long();
         /*  450 */ paramInputStream2.read_long();
         /*  451 */ for (m = 0; m < j; m++) {
           /*  452 */ if (!equalMember(
               localTypeCode.content_type(), paramInputStream1, paramInputStream2)) {
             /*  453 */ return false;
             /*      */ }
           /*      */ }
         /*  456 */ return true;
         /*      */ case 20:
         /*  459 */ j = localTypeCode.member_count();
         /*  460 */ for (m = 0; m < j; m++) {
           /*  461 */ if (!equalMember(
               localTypeCode.content_type(), paramInputStream1, paramInputStream2)) {
             /*  462 */ return false;
             /*      */ }
           /*      */ }
         /*  465 */ return true;
         /*      */ case 29:
         /*      */ case 30:
         /*  473 */ org.omg.CORBA_2_3.portable.InputStream localInputStream1 =
             (org.omg.CORBA_2_3.portable.InputStream) paramInputStream1;
         /*      */
         /*  475 */ org.omg.CORBA_2_3.portable.InputStream localInputStream2 =
             (org.omg.CORBA_2_3.portable.InputStream) paramInputStream2;
         /*      */
         /*  477 */ return localInputStream1.read_value().equals(localInputStream2.read_value());
         /*      */ case 21:
         /*  481 */ throw this.wrapper.errorResolvingAlias();
         /*      */ case 25:
         /*  484 */ throw this.wrapper.tkLongDoubleNotSupported();
         /*      */ }
     /*      */
     /*  487 */ throw this.wrapper.typecodeNotSupported();
     /*      */ }
   /*      */ catch (BadKind localBadKind) {
     /*  490 */ throw this.wrapper.badkindCannotOccur();
   } catch (Bounds localBounds) {
     /*      */ }
   /*  492 */ throw this.wrapper.boundsCannotOccur();
   /*      */ }