Example #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);
  }
  /** The CORBA::RepositoryId of the exception to be returned to the client. */
  public String received_exception_id() {
    checkAccess(MID_RECEIVED_EXCEPTION_ID);

    if (cachedReceivedExceptionId == null) {
      String result = null;

      if (exception == null) {
        // Note: exception should never be null here since we will
        // throw a BAD_INV_ORDER if this is not called from
        // receive_exception.
        throw wrapper.exceptionWasNull();
      } else if (exception instanceof SystemException) {
        String name = exception.getClass().getName();
        result = ORBUtility.repositoryIdOf(name);
      } else if (exception instanceof ApplicationException) {
        result = ((ApplicationException) exception).getId();
      }

      // _REVISIT_ We need to be able to handle a UserException in the
      // DII case.  How do we extract the ID from a UserException?

      cachedReceivedExceptionId = result;
    }

    return cachedReceivedExceptionId;
  }
 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);
 }
 /**
  * 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));
 }
Example #5
0
  /**
   * Utility method for insert_Value and Util.writeAny.
   *
   * <p>The ORB passed in should have the desired ORBVersion. It is used to generate the type codes.
   */
  public TypeCode createTypeCodeForClass(java.lang.Class c, ORB tcORB) {
    // Look in the cache first
    TypeCodeImpl classTC = tcORB.getTypeCodeForClass(c);
    if (classTC != null) return classTC;

    // All cases need to be able to create repository IDs.
    //
    // See bug 4391648 for more info about the tcORB in this
    // case.
    RepositoryIdStrings repStrs = RepositoryIdFactory.getRepIdStringsFactory();

    // Assertion: c instanceof Serializable?

    if (c.isArray()) {
      // Arrays - may recurse for multi-dimensional arrays
      Class componentClass = c.getComponentType();
      TypeCode embeddedType;
      if (componentClass.isPrimitive()) {
        embeddedType = getPrimitiveTypeCodeForClass(componentClass, tcORB);
      } else {
        embeddedType = createTypeCodeForClass(componentClass, tcORB);
      }
      TypeCode t = tcORB.create_sequence_tc(0, embeddedType);

      String id = repStrs.createForJavaType(c);

      return tcORB.create_value_box_tc(id, "Sequence", t);
    } else if (c == java.lang.String.class) {
      // Strings
      TypeCode t = tcORB.create_string_tc(0);

      String id = repStrs.createForJavaType(c);

      return tcORB.create_value_box_tc(id, "StringValue", t);
    }

    // Anything else
    // We know that this is a TypeCodeImpl since it is our ORB
    classTC =
        (TypeCodeImpl)
            ValueUtility.createTypeCodeForClass(tcORB, c, ORBUtility.createValueHandler());
    // Intruct classTC to store its buffer
    classTC.setCaching(true);
    // Update the cache
    tcORB.setTypeCodeForClass(c, classTC);
    return classTC;
  }
Example #6
0
 /*      */ public TypeCode createTypeCodeForClass(Class paramClass, ORB paramORB) /*      */ {
   /* 1212 */ TypeCodeImpl localTypeCodeImpl = paramORB.getTypeCodeForClass(paramClass);
   /* 1213 */ if (localTypeCodeImpl != null) {
     /* 1214 */ return localTypeCodeImpl;
     /*      */ }
   /*      */
   /* 1220 */ RepositoryIdStrings localRepositoryIdStrings =
       RepositoryIdFactory.getRepIdStringsFactory();
   /*      */ java.lang.Object localObject1;
   /*      */ java.lang.Object localObject2;
   /* 1226 */ if (paramClass.isArray())
   /*      */ {
     /* 1228 */ localObject1 = paramClass.getComponentType();
     /*      */
     /* 1230 */ if (((Class) localObject1).isPrimitive()) {
       /* 1231 */ localObject2 = getPrimitiveTypeCodeForClass((Class) localObject1, paramORB);
       /*      */ }
     /*      */ else {
       /* 1234 */ localObject2 = createTypeCodeForClass((Class) localObject1, paramORB);
       /*      */ }
     /*      */
     /* 1237 */ TypeCode localTypeCode = paramORB.create_sequence_tc(0, (TypeCode) localObject2);
     /*      */
     /* 1239 */ String str = localRepositoryIdStrings.createForJavaType(paramClass);
     /*      */
     /* 1241 */ return paramORB.create_value_box_tc(str, "Sequence", localTypeCode);
     /* 1242 */ }
   if (paramClass == String.class)
   /*      */ {
     /* 1244 */ localObject1 = paramORB.create_string_tc(0);
     /*      */
     /* 1246 */ localObject2 = localRepositoryIdStrings.createForJavaType(paramClass);
     /*      */
     /* 1248 */ return paramORB.create_value_box_tc(
         (String) localObject2, "StringValue", (TypeCode) localObject1);
     /*      */ }
   /*      */
   /* 1253 */ localTypeCodeImpl =
       (TypeCodeImpl)
           ValueUtility.createTypeCodeForClass(
               paramORB, paramClass, ORBUtility.createValueHandler());
   /*      */
   /* 1256 */ localTypeCodeImpl.setCaching(true);
   /*      */
   /* 1258 */ paramORB.setTypeCodeForClass(paramClass, localTypeCodeImpl);
   /* 1259 */ return localTypeCodeImpl;
   /*      */ }
 private void dprint(String msg) {
   ORBUtility.dprint("ReaderThreadImpl", msg);
 }
 /*     */ protected void dprint(String paramString) /*     */ {
   /* 213 */ ORBUtility.dprint("SocketOrChannelContactInfoImpl", paramString);
   /*     */ }
Example #9
0
 private void dprint(String msg) {
   ORBUtility.dprint("SelectorImpl", msg);
 }
  public static synchronized void dprintTrace(Object obj, String msg) {
    ORBUtility.dprint(obj, msg);

    Throwable thr = new Throwable();
    printStackTrace(thr.getStackTrace());
  }
 public synchronized void dprint(String msg) {
   ORBUtility.dprint(this, msg);
 }
Example #12
0
 protected void dprint(String msg) {
   ORBUtility.dprint("CorbaOutboundConnectionCacheImpl", msg);
 }