Exemplo n.º 1
0
  /**
   * Copies or connects an object. Used by local stubs to copy an actual parameter, result object,
   * or exception.
   *
   * @param obj the object to copy.
   * @param orb the ORB.
   * @return the copy or connected object.
   * @exception RemoteException if the object could not be copied or connected.
   */
  public Object copyObject(Object obj, org.omg.CORBA.ORB orb) throws RemoteException {
    if (orb instanceof ORB) {
      ORB lorb = (ORB) orb;

      try {
        try {
          // This gets the copier for the current invocation, which was
          // previously set by preinvoke.
          return lorb.peekInvocationInfo().getCopierFactory().make().copy(obj);
        } catch (java.util.EmptyStackException exc) {
          // copyObject was invoked outside of an invocation, probably by
          // a test.  Get the default copier from the ORB.
          // XXX should we just make the default copier available directly
          // and avoid constructing one on each call?
          CopierManager cm = lorb.getCopierManager();
          ObjectCopier copier = cm.getDefaultObjectCopierFactory().make();
          return copier.copy(obj);
        }
      } catch (ReflectiveCopyException exc) {
        RemoteException rexc = new RemoteException();
        rexc.initCause(exc);
        throw rexc;
      }
    } else {
      org.omg.CORBA_2_3.portable.OutputStream out =
          (org.omg.CORBA_2_3.portable.OutputStream) orb.create_output_stream();
      out.write_value((Serializable) obj);
      org.omg.CORBA_2_3.portable.InputStream in =
          (org.omg.CORBA_2_3.portable.InputStream) out.create_input_stream();
      return in.read_value();
    }
  }
 private static StructMember[] systemExceptionMembers(ORB orb) {
   if (members == null) {
     members = new StructMember[3];
     members[0] = new StructMember("id", orb.create_string_tc(0), null);
     members[1] = new StructMember("minor", orb.get_primitive_tc(TCKind.tk_long), null);
     members[2] = new StructMember("completed", orb.get_primitive_tc(TCKind.tk_long), null);
   }
   return members;
 }
Exemplo n.º 3
0
  public IORTemplateImpl(InputStream is) {
    ORB orb = (ORB) (is.orb());
    IdentifiableFactoryFinder finder = orb.getTaggedProfileTemplateFactoryFinder();

    oktemp = orb.getObjectKeyFactory().createTemplate(is);
    EncapsulationUtility.readIdentifiableSequence(this, finder, is);

    makeImmutable();
  }
  protected void setLocatedIOR(IOR ior) {
    ORB orb = (ORB) messageMediator.getBroker();

    CorbaContactInfoListIterator iterator =
        (CorbaContactInfoListIterator)
            ((CorbaInvocationInfo) orb.getInvocationInfo()).getContactInfoListIterator();

    // REVISIT - this most likely causes reportRedirect to happen twice.
    // Once here and once inside the request dispatcher.
    iterator.reportRedirect((CorbaContactInfo) messageMediator.getContactInfo(), ior);
  }
  /**
   * Create a naming context servant. Runs the super constructor.
   *
   * @param orb an ORB object.
   * @exception java.lang.Exception a Java exception.
   */
  public NamingContextImpl(ORB orb, POA poa) throws java.lang.Exception {
    super();
    this.orb = orb;
    wrapper = NamingSystemException.get(orb, CORBALogDomains.NAMING_UPDATE);

    insImpl = new InterOperableNamingImpl();
    this.nsPOA = poa;
    readLogger = orb.getLogger(CORBALogDomains.NAMING_READ);
    updateLogger = orb.getLogger(CORBALogDomains.NAMING_UPDATE);
    lifecycleLogger = orb.getLogger(CORBALogDomains.NAMING_LIFECYCLE);
  }
  /** @return the Java serialization encoding version. */
  public static byte getEncodingVersion(ORB orb, IOR ior) {

    // Is Java serialization enabled?
    // Check the JavaSerializationComponent (tagged component)
    // in the IIOPProfile. If present, the peer ORB's GIOP is capable
    // of using Java serialization instead of CDR serialization.
    // In such a case, use Java serialization, iff the java serialization
    // versions match.

    if (orb.getORBData().isJavaSerializationEnabled()) {
      IIOPProfile prof = ior.getProfile();
      IIOPProfileTemplate profTemp = (IIOPProfileTemplate) prof.getTaggedProfileTemplate();
      java.util.Iterator iter = profTemp.iteratorById(ORBConstants.TAG_JAVA_SERIALIZATION_ID);
      if (iter.hasNext()) {
        JavaSerializationComponent jc = (JavaSerializationComponent) iter.next();
        byte jcVersion = jc.javaSerializationVersion();
        if (jcVersion >= Message.JAVA_ENC_VERSION) {
          return Message.JAVA_ENC_VERSION;
        } else if (jcVersion > Message.CDR_ENC_VERSION) {
          return jc.javaSerializationVersion();
        } else {
          // throw error?
          // Since encodingVersion is <= 0 (CDR_ENC_VERSION).
        }
      }
    }
    return Message.CDR_ENC_VERSION; // default
  }
Exemplo n.º 7
0
 public void insert_fixed(java.math.BigDecimal value) {
   typeCode =
       TypeCodeImpl.convertToNative(
           orb, orb.create_fixed_tc(TypeCodeImpl.digits(value), TypeCodeImpl.scale(value)));
   object = value;
   isInitialized = true;
 }
Exemplo n.º 8
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.º 9
0
 /** See the description of the <a href="#anyOps">general Any operations.</a> */
 public void insert_any(Any a) {
   // debug.log ("insert_any");
   typeCode = orb.get_primitive_tc(TCKind._tk_any);
   object = a;
   stream = null;
   isInitialized = true;
 }
 /**
  * Creates a new ServerRequestInfo implementation. The constructor is package scope since no other
  * package need create an instance of this class.
  */
 ServerRequestInfoImpl(ORB myORB) {
   super(myORB);
   startingPointCall = CALL_RECEIVE_REQUEST_SERVICE_CONTEXT;
   intermediatePointCall = CALL_RECEIVE_REQUEST;
   endingPointCall = CALL_SEND_REPLY;
   serverRequestId = myORB.getPIHandler().allocateServerRequestId();
 }
Exemplo n.º 11
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.º 12
0
  /**
   * Returns true if it was accurately determined that the remote ORB is a foreign (non-JavaSoft)
   * ORB. Note: If passed the ORBSingleton, this will return false.
   */
  public static boolean isForeignORB(ORB orb) {
    if (orb == null) return false;

    try {
      return orb.getORBVersion().equals(ORBVersionFactory.getFOREIGN());
    } catch (SecurityException se) {
      return false;
    }
  }
Exemplo n.º 13
0
  /**
   * *********************************************************************** These are methods from
   * com.sun.corba.se.impl.se.core.ORB
   * **********************************************************************
   */
  private synchronized ORB getFullORB() {
    if (fullORB == null) {
      Properties props = new Properties();
      fullORB = new ORBImpl();
      fullORB.set_parameters(props);
    }

    return fullORB;
  }
Exemplo n.º 14
0
 /*      */ public AnyImpl(ORB paramORB) /*      */ {
   /*  177 */ this.orb = paramORB;
   /*  178 */ this.wrapper = ORBUtilSystemException.get(paramORB, "rpc.presentation");
   /*      */
   /*  181 */ this.typeCode = paramORB.get_primitive_tc(0);
   /*  182 */ this.stream = null;
   /*  183 */ this.object = null;
   /*  184 */ this.value = 0L;
   /*      */
   /*  186 */ this.isInitialized = true;
   /*      */ }
Exemplo n.º 15
0
 /** See the description of the <a href="#anyOps">general Any operations.</a> */
 public void insert_long(int l) {
   // debug.log ("insert_long");
   // A long value is applicable to enums as well, so don't erase the enum type code
   // in case it was initialized that way before.
   int kind = realType().kind().value();
   if (kind != TCKind._tk_long && kind != TCKind._tk_enum) {
     typeCode = orb.get_primitive_tc(TCKind._tk_long);
   }
   value = l;
   isInitialized = true;
 }
Exemplo n.º 16
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.º 17
0
  /**
   * A constructor that sets the Any to contain a null. It also marks the value as being invalid so
   * that extractions throw an exception until an insertion has been performed.
   */
  public AnyImpl(ORB orb) {
    this.orb = orb;
    wrapper =
        ORBUtilSystemException.get(
            (com.sun.corba.se.spi.orb.ORB) orb, CORBALogDomains.RPC_PRESENTATION);

    typeCode = orb.get_primitive_tc(TCKind._tk_null);
    stream = null;
    object = null;
    value = 0;
    // null is a valid value
    isInitialized = true;
  }
Exemplo n.º 18
0
  public ServerSocket createServerSocket(String type, InetSocketAddress inetSocketAddress)
      throws IOException {
    ServerSocketChannel serverSocketChannel = null;
    ServerSocket serverSocket = null;

    if (orb.getORBData().acceptorSocketType().equals(ORBConstants.SOCKETCHANNEL)) {
      serverSocketChannel = ServerSocketChannel.open();
      serverSocket = serverSocketChannel.socket();
    } else {
      serverSocket = new ServerSocket();
    }
    serverSocket.bind(inetSocketAddress);
    return serverSocket;
  }
Exemplo n.º 19
0
  /**
   * This is used to create the TypeCode for a null reference. It also handles backwards
   * compatibility with JDK 1.3.x.
   *
   * <p>This method will not return null.
   */
  private TypeCode createTypeCodeForNull(org.omg.CORBA.ORB orb) {
    if (orb instanceof ORB) {

      ORB ourORB = (ORB) orb;

      // Preserve backwards compatibility with Kestrel and Ladybird
      // by not fully implementing interop issue resolution 3857,
      // and returning a null TypeCode with a tk_value TCKind.
      // If we're not talking to Kestrel or Ladybird, fall through
      // to the abstract interface case (also used for foreign ORBs).
      if (!ORBVersionFactory.getFOREIGN().equals(ourORB.getORBVersion())
          && ORBVersionFactory.getNEWER().compareTo(ourORB.getORBVersion()) > 0) {

        return orb.get_primitive_tc(TCKind.tk_value);
      }
    }

    // Use tk_abstract_interface as detailed in the resolution

    // REVISIT: Define this in IDL and get the ID in generated code
    String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0";

    return orb.create_abstract_interface_tc(abstractBaseID, "");
  }
Exemplo n.º 20
0
  /**
   * returns an input stream that an Any value can be marshaled out of.
   *
   * @result the InputStream to marshal value of Any out of.
   */
  public org.omg.CORBA.portable.InputStream create_input_stream() {
    //
    // We create a new InputStream so that multiple threads can call here
    // and read the streams in parallel without thread safety problems.
    //
    // debug.log ("create_input_stream");
    if (AnyImpl.isStreamed[realType().kind().value()]) {
      return stream.dup();
    } else {
      OutputStream os = (OutputStream) orb.create_output_stream();
      TCUtility.marshalIn(os, realType(), value, object);

      return os.create_input_stream();
    }
  }
Exemplo n.º 21
0
  public void insert_Value(Serializable v) {
    // debug.log ("insert_Value");
    object = v;

    TypeCode tc;

    if (v == null) {
      tc = orb.get_primitive_tc(TCKind.tk_value);
    } else {
      // See note in getPrimitiveTypeCodeForClass.  We
      // have to use the latest type code fixes in this
      // case since there is no way to know what ORB will
      // actually send this Any.  In RMI-IIOP, when using
      // Util.writeAny, we can do the versioning correctly,
      // and use the insert_Value(Serializable, TypeCode)
      // method.
      //
      // The ORB singleton uses the latest version.
      tc = createTypeCodeForClass(v.getClass(), (ORB) ORB.init());
    }

    typeCode = TypeCodeImpl.convertToNative(orb, tc);
    isInitialized = true;
  }
Exemplo n.º 22
0
 /*      */ public void insert_Value(Serializable paramSerializable) /*      */ {
   /* 1143 */ this.object = paramSerializable;
   /*      */ TypeCode localTypeCode;
   /* 1147 */ if (paramSerializable == null) {
     /* 1148 */ localTypeCode = this.orb.get_primitive_tc(TCKind.tk_value);
     /*      */ }
   /*      */ else
   /*      */ {
     /* 1159 */ localTypeCode =
         createTypeCodeForClass(paramSerializable.getClass(), (ORB) ORB.init());
     /*      */ }
   /*      */
   /* 1162 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, localTypeCode);
   /* 1163 */ this.isInitialized = true;
   /*      */ }
Exemplo n.º 23
0
  /** See the description of the <a href="#anyOps">general Any operations.</a> */
  public void insert_Object(org.omg.CORBA.Object o) {
    // debug.log ("insert_Object");
    if (o == null) {
      typeCode = orb.get_primitive_tc(TCKind._tk_objref);
    } else {
      if (StubAdapter.isStub(o)) {
        String[] ids = StubAdapter.getTypeIds(o);
        typeCode = new TypeCodeImpl(orb, TCKind._tk_objref, ids[0], "");
      } else {
        throw wrapper.badInsertobjParam(CompletionStatus.COMPLETED_MAYBE, o.getClass().getName());
      }
    }

    object = o;
    isInitialized = true;
  }
Exemplo n.º 24
0
  public Socket createSocket(String type, InetSocketAddress inetSocketAddress) throws IOException {
    SocketChannel socketChannel = null;
    Socket socket = null;

    if (orb.getORBData().connectionSocketType().equals(ORBConstants.SOCKETCHANNEL)) {
      socketChannel = SocketChannel.open(inetSocketAddress);
      socket = socketChannel.socket();
    } else {
      socket = new Socket(inetSocketAddress.getHostName(), inetSocketAddress.getPort());
    }

    // Disable Nagle's algorithm (i.e., always send immediately).
    socket.setTcpNoDelay(true);

    return socket;
  }
Exemplo n.º 25
0
  public void run() {
    // do the actual invocation
    _req.doInvocation();

    // for the asynchronous case, note that the response has been
    // received.
    synchronized (_req) {
      // update local boolean indicator
      _req.gotResponse = true;

      // notify any client waiting on a 'get_response'
      _req.notify();
    }

    if (_notifyORB == true) {
      _orb.notifyORB();
    }
  }
Exemplo n.º 26
0
  /**
   * Obtains an IOR for the object reference obj, first connecting it to the ORB if necessary.
   *
   * @return IOR the IOR that represents this objref. This will never be null.
   * @exception BAD_OPERATION if the object could not be connected, if a connection attempt was
   *     needed.
   * @exception BAD_PARAM if obj is a local object, or else was created by a foreign ORB.
   */
  public static IOR connectAndGetIOR(ORB orb, org.omg.CORBA.Object obj) {
    IOR result;
    try {
      result = getIOR(obj);
    } catch (BAD_OPERATION bop) {
      if (StubAdapter.isStub(obj)) {
        try {
          StubAdapter.connect(obj, orb);
        } catch (java.rmi.RemoteException exc) {
          throw wrapper.connectingServant(exc);
        }
      } else {
        orb.connect(obj);
      }

      result = getIOR(obj);
    }

    return result;
  }
Exemplo n.º 27
0
  //
  // If the InputStream is a CDRInputStream then we can copy the bytes
  // since it is in our format and does not have alignment issues.
  //
  public void read_value(org.omg.CORBA.portable.InputStream in, TypeCode tc) {
    // debug.log ("read_value");
    //
    // Assume that someone isn't going to think they can keep reading
    // from this stream after calling us. That would be likely for
    // an IIOPInputStream but if it is an AnyInputStream then they
    // presumably obtained it via our create_output_stream() so they could
    // write the contents of an IDL data type to it and then call
    // create_input_stream() for us to read it. This is how Helper classes
    // typically implement the insert() method.
    // We should probably document this behavior in the 1.1 revision
    // task force.
    //

    typeCode = TypeCodeImpl.convertToNative(orb, tc);
    int kind = realType().kind().value();
    if (kind >= isStreamed.length) {
      throw wrapper.invalidIsstreamedTckind(CompletionStatus.COMPLETED_MAYBE, new Integer(kind));
    }

    if (AnyImpl.isStreamed[kind]) {
      if (in instanceof AnyInputStream) {
        // could only have been created here
        stream = (CDRInputStream) in;
      } else {
        org.omg.CORBA_2_3.portable.OutputStream out =
            (org.omg.CORBA_2_3.portable.OutputStream) orb.create_output_stream();
        typeCode.copy((org.omg.CORBA_2_3.portable.InputStream) in, out);
        stream = (CDRInputStream) out.create_input_stream();
      }
    } else {
      java.lang.Object[] objholder = new java.lang.Object[1];
      objholder[0] = object;
      long[] longholder = new long[1];
      TCUtility.unmarshalIn(in, realType(), longholder, objholder);
      value = longholder[0];
      object = objholder[0];
      stream = null;
    }
    isInitialized = true;
  }
Exemplo n.º 28
0
  /** See the description of the <a href="#anyOps">general Any operations.</a> */
  public void insert_wstring(String s) {
    // debug.log ("insert_wstring");
    // Make sure type code information for bounded strings is not erased
    if (typeCode.kind() == TCKind.tk_wstring) {
      int length = 0;
      try {
        length = typeCode.length();
      } catch (BadKind bad) {
        throw wrapper.badkindCannotOccur();
      }

      // Check if bounded strings length is not exceeded
      if (length != 0 && s != null && s.length() > length) {
        throw wrapper.badStringBounds(new Integer(s.length()), new Integer(length));
      }
    } else {
      typeCode = orb.get_primitive_tc(TCKind._tk_wstring);
    }
    object = s;
    isInitialized = true;
  }
Exemplo n.º 29
0
 private void createListenerThread(EventHandler eventHandler) {
   if (orb.transportDebugFlag) {
     dprint(".createListenerThread: " + eventHandler);
   }
   Acceptor acceptor = eventHandler.getAcceptor();
   ListenerThread listenerThread = new ListenerThreadImpl(orb, acceptor, this);
   listenerThreads.put(eventHandler, listenerThread);
   Throwable throwable = null;
   try {
     orb.getThreadPoolManager().getThreadPool(0).getWorkQueue(0).addWork((Work) listenerThread);
   } catch (NoSuchThreadPoolException e) {
     throwable = e;
   } catch (NoSuchWorkQueueException e) {
     throwable = e;
   }
   if (throwable != null) {
     RuntimeException rte = new RuntimeException(throwable.toString());
     rte.initCause(throwable);
     throw rte;
   }
 }
Exemplo n.º 30
0
 private void createReaderThread(EventHandler eventHandler) {
   if (orb.transportDebugFlag) {
     dprint(".createReaderThread: " + eventHandler);
   }
   Connection connection = eventHandler.getConnection();
   ReaderThread readerThread = new ReaderThreadImpl(orb, connection, this);
   readerThreads.put(eventHandler, readerThread);
   Throwable throwable = null;
   try {
     orb.getThreadPoolManager().getThreadPool(0).getWorkQueue(0).addWork((Work) readerThread);
   } catch (NoSuchThreadPoolException e) {
     throwable = e;
   } catch (NoSuchWorkQueueException e) {
     throwable = e;
   }
   if (throwable != null) {
     RuntimeException rte = new RuntimeException(throwable.toString());
     rte.initCause(throwable);
     throw rte;
   }
 }