Java 类org.omg.CORBA.portable.ObjectImpl 实例源码

项目:OpenJSharp    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:openjdk-jdk10    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:openjdk9    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:jdk8u_corba    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:javify    文件:PolicyHelper.java   
/**
 * Cast the passed object into the Policy. If the
 * object has a different java type, create an instance
 * of the _PolicyStub, using the same delegate, as for
 * the passed parameter. Hence, unlike java type cast,
 * this method may return a different object, than has been passed.
 *
 * @param obj the object to narrow.
 * @return narrowed instance.
 * @throws BAD_PARAM if the passed object is not a Policy.
 */
public static Policy narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof Policy)
    return (Policy) obj;
  else
    {
      // Check for the policy id cannot be performed because
      // this helper must read various subclasses of the Policy,
      // and the IOR profile currently supports only one id.

      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _PolicyStub(delegate);
    }
}
项目:javify    文件:NamingContextHelper.java   
/**
 * Cast the passed object into the NamingContext. If the
 * object has a different java type, create an instance
 * of the NamingContext, using the same delegate, as for
 * the passed parameter.
 *
 * If the object repository Id indicates that it is an instance of
 *  {@link NamingContextExt} that is a subclass of the NamingContext,
 * the functionality is  delegated to {@link NamingContextHelper#narrow}.
 *
 * @param obj the object to cast.
 * @return casted instance.
 *
 * @throws BAD_PARAM if the passed object is not an instance of
 * {@link NamingContext} or {@link NamingContextExt}.
 */
public static NamingContext narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof NamingContext)
    return (NamingContext) obj;
  else if (obj._is_a(id()))
    {
      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _NamingContextStub(delegate);
    }
  else if (obj._is_a(NamingContextExtHelper.id()))
    return NamingContextExtHelper.narrow(obj);
  else
    throw new BAD_PARAM();
}
项目:javify    文件:GiopIo.java   
/**
 * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
 * stream is always named "out".
 *
 * @param c
 *          the class of the object being written
 * @param variable
 *          the variable, where the object value is stored
 * @param r
 *          the parent generator, used to name the class
 * @return the write statement.
 */
public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
{
  if (c.equals(boolean.class))
    return "out.write_boolean(" + variable + ");";
  if (c.equals(byte.class))
    return "out.write_octet(" + variable + ");";
  else if (c.equals(short.class))
    return "out.write_int(" + variable + ");";
  else if (c.equals(int.class))
    return "out.write_long(" + variable + ");";
  else if (c.equals(long.class))
    return "out.write_long_long(" + variable + ");";
  else if (c.equals(double.class))
    return "out.write_double(" + variable + ");";
  else if (c.equals(float.class))
    return "out.write_float(" + variable + ");";
  else if (c.equals(char.class))
    return "out.write_char(" + variable + ");";
  else if (Remote.class.isAssignableFrom(c))
    return "Util.writeRemoteObject(out, " + variable + ");";
  else if (ObjectImpl.class.isAssignableFrom(c))
    return "out.write_Object(" + variable + ");";
  else
    return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
}
项目:javify    文件:ContextContinuation.java   
/**
 * Returs the full name of this naming context. The returned string is not a
 * JNDI composite name and should not be passed directly to the methods of the
 * naming context. This implementation returns the IOR.
 *
 * @return the full name of this naming context, in its own namespace.
 * @throws OperationNotSupportedException
 *           if the naming system, represented by this context, does not
 *           support the notation of the full name.
 * @throws NamingException
 */
public String getNameInNamespace() throws NamingException
{
  if (orb != null)
    return orb.object_to_string(service);
  else
    {
      try
        {
          ObjectImpl impl = (ObjectImpl) service;
          return impl._orb().object_to_string(impl);
        }
      catch (ClassCastException e)
        {
          throw new UnsupportedOperationException();
        }
    }
}
项目:javify    文件:OrbFunctional.java   
/**
 * Get the IOR reference string for the given object. The string embeds
 * information about the object repository Id, its access key and the server
 * internet address and port. With this information, the object can be found
 * by another ORB, possibly located on remote computer.
 *
 * @param forObject CORBA object
 * @return the object IOR representation.
 *
 * @throws BAD_PARAM if the object has not been previously connected to this
 * ORB.
 *
 * @throws BAD_OPERATION in the unlikely case if the local host address cannot
 * be resolved.
 *
 * @see string_to_object(String)
 */
public String object_to_string(org.omg.CORBA.Object forObject)
{
  // Handle the case when the object is known, but not local.
  if (forObject instanceof ObjectImpl)
    {
      Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
      if (delegate instanceof SimpleDelegate)
        return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
    }

  // Handle the case when the object is local.
  Connected_objects.cObject rec = connected_objects.getKey(forObject);

  if (rec == null)
    throw new BAD_PARAM("The object " + forObject +
      " has not been previously connected to this ORB"
    );

  IOR ior = createIOR(rec);

  return ior.toStringifiedReference();
}
项目:javify    文件:OrbFunctional.java   
/**
 * Create IOR for the given object references.
 */
protected IOR createIOR(Connected_objects.cObject ref)
  throws BAD_OPERATION
{
  IOR ior = new IOR();
  ior.key = ref.key;
  ior.Internet.port = ref.port;

  if (ref.object instanceof ObjectImpl)
    {
      ObjectImpl imp = (ObjectImpl) ref.object;
      if (imp._ids().length > 0)
        ior.Id = imp._ids() [ 0 ];
    }
  if (ior.Id == null)
    ior.Id = ref.object.getClass().getName();

  ior.Internet.host = CollocatedOrbs.localHost;
  ior.Internet.port = ref.port;

  return ior;
}
项目:javify    文件:OrbFunctional.java   
/**
 * Prepare object for connecting it to this ORB.
 *
 * @param object the object being connected.
 *
 * @throws BAD_PARAM if the object does not implement the
 * {@link InvokeHandler}).
 */
protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
  throws BAD_PARAM
{
  /*
   * if (!(object instanceof InvokeHandler)) throw new
   * BAD_PARAM(object.getClass().getName() + " does not implement
   * InvokeHandler. " );
   */

  // If no delegate is set, set the default delegate.
  if (object instanceof ObjectImpl)
    {
      ObjectImpl impl = (ObjectImpl) object;
      try
        {
          if (impl._get_delegate() == null)
            impl._set_delegate(new SimpleDelegate(this, ior));
        }
      catch (BAD_OPERATION ex)
        {
          // Some colaborants may throw this exception.
          impl._set_delegate(new SimpleDelegate(this, ior));
        }
    }
}
项目:javify    文件:SimpleDelegate.java   
/**
 * Check if this object can be referenced by the given repository id.
 *
 * @param target the CORBA object, must be an instance of
 * {@link org.omg.CORBA.portable.ObjectImpl}.
 *
 * @param repositoryIdentifer the repository id.
 *
 * @return true if the passed parameter is a repository id of this
 * CORBA object.
 */
public boolean is_a(org.omg.CORBA.Object target, String repositoryIdentifer)
{
  if (!(target instanceof ObjectImpl))
    throw new NO_IMPLEMENT("Supported only for org.omg.CORBA.portable.ObjectImpl");

  ObjectImpl imp = (ObjectImpl) target;
  String[] ids = imp._ids();

  for (int i = 0; i < ids.length; i++)
    {
      if (ids [ i ].equals(repositoryIdentifer))
        return true;
    }
  return false;
}
项目:jvm-stm    文件:PolicyHelper.java   
/**
 * Cast the passed object into the Policy. If the
 * object has a different java type, create an instance
 * of the _PolicyStub, using the same delegate, as for
 * the passed parameter. Hence, unlike java type cast,
 * this method may return a different object, than has been passed.
 *
 * @param obj the object to narrow.
 * @return narrowed instance.
 * @throws BAD_PARAM if the passed object is not a Policy.
 */
public static Policy narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof Policy)
    return (Policy) obj;
  else
    {
      // Check for the policy id cannot be performed because
      // this helper must read various subclasses of the Policy,
      // and the IOR profile currently supports only one id.

      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _PolicyStub(delegate);
    }
}
项目:jvm-stm    文件:NamingContextHelper.java   
/**
 * Cast the passed object into the NamingContext. If the
 * object has a different java type, create an instance
 * of the NamingContext, using the same delegate, as for
 * the passed parameter.
 *
 * If the object repository Id indicates that it is an instance of
 *  {@link NamingContextExt} that is a subclass of the NamingContext,
 * the functionality is  delegated to {@link NamingContextHelper#narrow}.
 *
 * @param obj the object to cast.
 * @return casted instance.
 *
 * @throws BAD_PARAM if the passed object is not an instance of
 * {@link NamingContext} or {@link NamingContextExt}.
 */
public static NamingContext narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof NamingContext)
    return (NamingContext) obj;
  else if (obj._is_a(id()))
    {
      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _NamingContextStub(delegate);
    }
  else if (obj._is_a(NamingContextExtHelper.id()))
    return NamingContextExtHelper.narrow(obj);
  else
    throw new BAD_PARAM();
}
项目:jvm-stm    文件:GiopIo.java   
/**
 * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
 * stream is always named "out".
 * 
 * @param c
 *          the class of the object being written
 * @param variable
 *          the variable, where the object value is stored
 * @param r
 *          the parent generator, used to name the class
 * @return the write statement.
 */
public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
{
  if (c.equals(boolean.class))
    return "out.write_boolean(" + variable + ");";
  if (c.equals(byte.class))
    return "out.write_octet(" + variable + ");";
  else if (c.equals(short.class))
    return "out.write_int(" + variable + ");";
  else if (c.equals(int.class))
    return "out.write_long(" + variable + ");";
  else if (c.equals(long.class))
    return "out.write_long_long(" + variable + ");";
  else if (c.equals(double.class))
    return "out.write_double(" + variable + ");";
  else if (c.equals(float.class))
    return "out.write_float(" + variable + ");";
  else if (c.equals(char.class))
    return "out.write_char(" + variable + ");";
  else if (Remote.class.isAssignableFrom(c))
    return "Util.writeRemoteObject(out, " + variable + ");";
  else if (ObjectImpl.class.isAssignableFrom(c))
    return "out.write_Object(" + variable + ");";
  else
    return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
}
项目:jvm-stm    文件:ContextContinuation.java   
/**
 * Returs the full name of this naming context. The returned string is not a
 * JNDI composite name and should not be passed directly to the methods of the
 * naming context. This implementation returns the IOR.
 * 
 * @return the full name of this naming context, in its own namespace.
 * @throws OperationNotSupportedException
 *           if the naming system, represented by this context, does not
 *           support the notation of the full name.
 * @throws NamingException
 */
public String getNameInNamespace() throws NamingException
{
  if (orb != null)
    return orb.object_to_string(service);
  else
    {
      try
        {
          ObjectImpl impl = (ObjectImpl) service;
          return impl._orb().object_to_string(impl);
        }
      catch (ClassCastException e)
        {
          throw new UnsupportedOperationException();
        }
    }
}
项目:jvm-stm    文件:OrbFunctional.java   
/**
 * Get the IOR reference string for the given object. The string embeds
 * information about the object repository Id, its access key and the server
 * internet address and port. With this information, the object can be found
 * by another ORB, possibly located on remote computer.
 *
 * @param forObject CORBA object
 * @return the object IOR representation.
 *
 * @throws BAD_PARAM if the object has not been previously connected to this
 * ORB.
 *
 * @throws BAD_OPERATION in the unlikely case if the local host address cannot
 * be resolved.
 *
 * @see string_to_object(String)
 */
public String object_to_string(org.omg.CORBA.Object forObject)
{
  // Handle the case when the object is known, but not local.
  if (forObject instanceof ObjectImpl)
    {
      Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
      if (delegate instanceof SimpleDelegate)
        return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
    }

  // Handle the case when the object is local.
  Connected_objects.cObject rec = connected_objects.getKey(forObject);

  if (rec == null)
    throw new BAD_PARAM("The object " + forObject +
      " has not been previously connected to this ORB"
    );

  IOR ior = createIOR(rec);

  return ior.toStringifiedReference();
}
项目:jvm-stm    文件:OrbFunctional.java   
/**
 * Create IOR for the given object references.
 */
protected IOR createIOR(Connected_objects.cObject ref)
  throws BAD_OPERATION
{
  IOR ior = new IOR();
  ior.key = ref.key;
  ior.Internet.port = ref.port;

  if (ref.object instanceof ObjectImpl)
    {
      ObjectImpl imp = (ObjectImpl) ref.object;
      if (imp._ids().length > 0)
        ior.Id = imp._ids() [ 0 ];
    }
  if (ior.Id == null)
    ior.Id = ref.object.getClass().getName();

  ior.Internet.host = CollocatedOrbs.localHost;
  ior.Internet.port = ref.port;

  return ior;
}
项目:jvm-stm    文件:OrbFunctional.java   
/**
 * Prepare object for connecting it to this ORB.
 *
 * @param object the object being connected.
 *
 * @throws BAD_PARAM if the object does not implement the
 * {@link InvokeHandler}).
 */
protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
  throws BAD_PARAM
{
  /*
   * if (!(object instanceof InvokeHandler)) throw new
   * BAD_PARAM(object.getClass().getName() + " does not implement
   * InvokeHandler. " );
   */

  // If no delegate is set, set the default delegate.
  if (object instanceof ObjectImpl)
    {
      ObjectImpl impl = (ObjectImpl) object;
      try
        {
          if (impl._get_delegate() == null)
            impl._set_delegate(new SimpleDelegate(this, ior));
        }
      catch (BAD_OPERATION ex)
        {
          // Some colaborants may throw this exception.
          impl._set_delegate(new SimpleDelegate(this, ior));
        }
    }
}
项目:jvm-stm    文件:SimpleDelegate.java   
/**
 * Check if this object can be referenced by the given repository id.
 *
 * @param target the CORBA object, must be an instance of
 * {@link org.omg.CORBA.portable.ObjectImpl}.
 *
 * @param repositoryIdentifer the repository id.
 *
 * @return true if the passed parameter is a repository id of this
 * CORBA object.
 */
public boolean is_a(org.omg.CORBA.Object target, String repositoryIdentifer)
{
  if (!(target instanceof ObjectImpl))
    throw new NO_IMPLEMENT("Supported only for org.omg.CORBA.portable.ObjectImpl");

  ObjectImpl imp = (ObjectImpl) target;
  String[] ids = imp._ids();

  for (int i = 0; i < ids.length; i++)
    {
      if (ids [ i ].equals(repositoryIdentifer))
        return true;
    }
  return false;
}
项目:infobip-open-jdk-8    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:openjdk-source-code-learn    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:OLD-OpenJDK8    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:JamVM-PH    文件:PolicyHelper.java   
/**
 * Cast the passed object into the Policy. If the
 * object has a different java type, create an instance
 * of the _PolicyStub, using the same delegate, as for
 * the passed parameter. Hence, unlike java type cast,
 * this method may return a different object, than has been passed.
 *
 * @param obj the object to narrow.
 * @return narrowed instance.
 * @throws BAD_PARAM if the passed object is not a Policy.
 */
public static Policy narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof Policy)
    return (Policy) obj;
  else
    {
      // Check for the policy id cannot be performed because
      // this helper must read various subclasses of the Policy,
      // and the IOR profile currently supports only one id.

      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _PolicyStub(delegate);
    }
}
项目:JamVM-PH    文件:NamingContextHelper.java   
/**
 * Cast the passed object into the NamingContext. If the
 * object has a different java type, create an instance
 * of the NamingContext, using the same delegate, as for
 * the passed parameter.
 *
 * If the object repository Id indicates that it is an instance of
 *  {@link NamingContextExt} that is a subclass of the NamingContext,
 * the functionality is  delegated to {@link NamingContextHelper#narrow}.
 *
 * @param obj the object to cast.
 * @return casted instance.
 *
 * @throws BAD_PARAM if the passed object is not an instance of
 * {@link NamingContext} or {@link NamingContextExt}.
 */
public static NamingContext narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof NamingContext)
    return (NamingContext) obj;
  else if (obj._is_a(id()))
    {
      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _NamingContextStub(delegate);
    }
  else if (obj._is_a(NamingContextExtHelper.id()))
    return NamingContextExtHelper.narrow(obj);
  else
    throw new BAD_PARAM();
}
项目:JamVM-PH    文件:GiopIo.java   
/**
 * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
 * stream is always named "out".
 * 
 * @param c
 *          the class of the object being written
 * @param variable
 *          the variable, where the object value is stored
 * @param r
 *          the parent generator, used to name the class
 * @return the write statement.
 */
public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
{
  if (c.equals(boolean.class))
    return "out.write_boolean(" + variable + ");";
  if (c.equals(byte.class))
    return "out.write_octet(" + variable + ");";
  else if (c.equals(short.class))
    return "out.write_int(" + variable + ");";
  else if (c.equals(int.class))
    return "out.write_long(" + variable + ");";
  else if (c.equals(long.class))
    return "out.write_long_long(" + variable + ");";
  else if (c.equals(double.class))
    return "out.write_double(" + variable + ");";
  else if (c.equals(float.class))
    return "out.write_float(" + variable + ");";
  else if (c.equals(char.class))
    return "out.write_char(" + variable + ");";
  else if (Remote.class.isAssignableFrom(c))
    return "Util.writeRemoteObject(out, " + variable + ");";
  else if (ObjectImpl.class.isAssignableFrom(c))
    return "out.write_Object(" + variable + ");";
  else
    return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
}
项目:JamVM-PH    文件:ContextContinuation.java   
/**
 * Returs the full name of this naming context. The returned string is not a
 * JNDI composite name and should not be passed directly to the methods of the
 * naming context. This implementation returns the IOR.
 * 
 * @return the full name of this naming context, in its own namespace.
 * @throws OperationNotSupportedException
 *           if the naming system, represented by this context, does not
 *           support the notation of the full name.
 * @throws NamingException
 */
public String getNameInNamespace() throws NamingException
{
  if (orb != null)
    return orb.object_to_string(service);
  else
    {
      try
        {
          ObjectImpl impl = (ObjectImpl) service;
          return impl._orb().object_to_string(impl);
        }
      catch (ClassCastException e)
        {
          throw new UnsupportedOperationException();
        }
    }
}
项目:JamVM-PH    文件:OrbFunctional.java   
/**
 * Get the IOR reference string for the given object. The string embeds
 * information about the object repository Id, its access key and the server
 * internet address and port. With this information, the object can be found
 * by another ORB, possibly located on remote computer.
 *
 * @param forObject CORBA object
 * @return the object IOR representation.
 *
 * @throws BAD_PARAM if the object has not been previously connected to this
 * ORB.
 *
 * @throws BAD_OPERATION in the unlikely case if the local host address cannot
 * be resolved.
 *
 * @see string_to_object(String)
 */
public String object_to_string(org.omg.CORBA.Object forObject)
{
  // Handle the case when the object is known, but not local.
  if (forObject instanceof ObjectImpl)
    {
      Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
      if (delegate instanceof SimpleDelegate)
        return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
    }

  // Handle the case when the object is local.
  Connected_objects.cObject rec = connected_objects.getKey(forObject);

  if (rec == null)
    throw new BAD_PARAM("The object " + forObject +
      " has not been previously connected to this ORB"
    );

  IOR ior = createIOR(rec);

  return ior.toStringifiedReference();
}
项目:JamVM-PH    文件:OrbFunctional.java   
/**
 * Create IOR for the given object references.
 */
protected IOR createIOR(Connected_objects.cObject ref)
  throws BAD_OPERATION
{
  IOR ior = new IOR();
  ior.key = ref.key;
  ior.Internet.port = ref.port;

  if (ref.object instanceof ObjectImpl)
    {
      ObjectImpl imp = (ObjectImpl) ref.object;
      if (imp._ids().length > 0)
        ior.Id = imp._ids() [ 0 ];
    }
  if (ior.Id == null)
    ior.Id = ref.object.getClass().getName();

  ior.Internet.host = CollocatedOrbs.localHost;
  ior.Internet.port = ref.port;

  return ior;
}
项目:JamVM-PH    文件:OrbFunctional.java   
/**
 * Prepare object for connecting it to this ORB.
 *
 * @param object the object being connected.
 *
 * @throws BAD_PARAM if the object does not implement the
 * {@link InvokeHandler}).
 */
protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
  throws BAD_PARAM
{
  /*
   * if (!(object instanceof InvokeHandler)) throw new
   * BAD_PARAM(object.getClass().getName() + " does not implement
   * InvokeHandler. " );
   */

  // If no delegate is set, set the default delegate.
  if (object instanceof ObjectImpl)
    {
      ObjectImpl impl = (ObjectImpl) object;
      try
        {
          if (impl._get_delegate() == null)
            impl._set_delegate(new SimpleDelegate(this, ior));
        }
      catch (BAD_OPERATION ex)
        {
          // Some colaborants may throw this exception.
          impl._set_delegate(new SimpleDelegate(this, ior));
        }
    }
}
项目:JamVM-PH    文件:SimpleDelegate.java   
/**
 * Check if this object can be referenced by the given repository id.
 *
 * @param target the CORBA object, must be an instance of
 * {@link org.omg.CORBA.portable.ObjectImpl}.
 *
 * @param repositoryIdentifer the repository id.
 *
 * @return true if the passed parameter is a repository id of this
 * CORBA object.
 */
public boolean is_a(org.omg.CORBA.Object target, String repositoryIdentifer)
{
  if (!(target instanceof ObjectImpl))
    throw new NO_IMPLEMENT("Supported only for org.omg.CORBA.portable.ObjectImpl");

  ObjectImpl imp = (ObjectImpl) target;
  String[] ids = imp._ids();

  for (int i = 0; i < ids.length; i++)
    {
      if (ids [ i ].equals(repositoryIdentifer))
        return true;
    }
  return false;
}
项目:openjdk-orb    文件:StubAdapter.java   
/** Given any Tie, return the corresponding object refernce, activating
 * the Servant if necessary.
 */
public static org.omg.CORBA.Object activateTie( Tie tie )
{
    /** Any implementation of Tie should be either a Servant or an ObjectImpl,
     * depending on which style of code generation is used.  rmic -iiop by
     * default results in an ObjectImpl-based Tie, while rmic -iiop -poa
     * results in a Servant-based Tie.  Dynamic RMI-IIOP also uses Servant-based
     * Ties (see impl.presentation.rmi.ReflectiveTie).
     */
    if (tie instanceof ObjectImpl) {
        return tie.thisObject() ;
    } else if (tie instanceof Servant) {
        Servant servant = (Servant)tie ;
        return activateServant( servant ) ;
    } else {
        throw wrapper.badActivateTieCall() ;
    }
}
项目:classpath    文件:PolicyHelper.java   
/**
 * Cast the passed object into the Policy. If the
 * object has a different java type, create an instance
 * of the _PolicyStub, using the same delegate, as for
 * the passed parameter. Hence, unlike java type cast,
 * this method may return a different object, than has been passed.
 *
 * @param obj the object to narrow.
 * @return narrowed instance.
 * @throws BAD_PARAM if the passed object is not a Policy.
 */
public static Policy narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof Policy)
    return (Policy) obj;
  else
    {
      // Check for the policy id cannot be performed because
      // this helper must read various subclasses of the Policy,
      // and the IOR profile currently supports only one id.

      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _PolicyStub(delegate);
    }
}
项目:classpath    文件:NamingContextHelper.java   
/**
 * Cast the passed object into the NamingContext. If the
 * object has a different java type, create an instance
 * of the NamingContext, using the same delegate, as for
 * the passed parameter.
 *
 * If the object repository Id indicates that it is an instance of
 *  {@link NamingContextExt} that is a subclass of the NamingContext,
 * the functionality is  delegated to {@link NamingContextHelper#narrow}.
 *
 * @param obj the object to cast.
 * @return casted instance.
 *
 * @throws BAD_PARAM if the passed object is not an instance of
 * {@link NamingContext} or {@link NamingContextExt}.
 */
public static NamingContext narrow(org.omg.CORBA.Object obj)
{
  if (obj == null)
    return null;
  else if (obj instanceof NamingContext)
    return (NamingContext) obj;
  else if (obj._is_a(id()))
    {
      Delegate delegate = ((ObjectImpl) obj)._get_delegate();
      return new _NamingContextStub(delegate);
    }
  else if (obj._is_a(NamingContextExtHelper.id()))
    return NamingContextExtHelper.narrow(obj);
  else
    throw new BAD_PARAM();
}
项目:classpath    文件:GiopIo.java   
/**
 * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
 * stream is always named "out".
 *
 * @param c
 *          the class of the object being written
 * @param variable
 *          the variable, where the object value is stored
 * @param r
 *          the parent generator, used to name the class
 * @return the write statement.
 */
public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
{
  if (c.equals(boolean.class))
    return "out.write_boolean(" + variable + ");";
  if (c.equals(byte.class))
    return "out.write_octet(" + variable + ");";
  else if (c.equals(short.class))
    return "out.write_int(" + variable + ");";
  else if (c.equals(int.class))
    return "out.write_long(" + variable + ");";
  else if (c.equals(long.class))
    return "out.write_long_long(" + variable + ");";
  else if (c.equals(double.class))
    return "out.write_double(" + variable + ");";
  else if (c.equals(float.class))
    return "out.write_float(" + variable + ");";
  else if (c.equals(char.class))
    return "out.write_char(" + variable + ");";
  else if (Remote.class.isAssignableFrom(c))
    return "Util.writeRemoteObject(out, " + variable + ");";
  else if (ObjectImpl.class.isAssignableFrom(c))
    return "out.write_Object(" + variable + ");";
  else
    return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
}
项目:classpath    文件:ContextContinuation.java   
/**
 * Returs the full name of this naming context. The returned string is not a
 * JNDI composite name and should not be passed directly to the methods of the
 * naming context. This implementation returns the IOR.
 *
 * @return the full name of this naming context, in its own namespace.
 * @throws OperationNotSupportedException
 *           if the naming system, represented by this context, does not
 *           support the notation of the full name.
 * @throws NamingException
 */
public String getNameInNamespace() throws NamingException
{
  if (orb != null)
    return orb.object_to_string(service);
  else
    {
      try
        {
          ObjectImpl impl = (ObjectImpl) service;
          return impl._orb().object_to_string(impl);
        }
      catch (ClassCastException e)
        {
          throw new UnsupportedOperationException();
        }
    }
}
项目:classpath    文件:OrbFunctional.java   
/**
 * Get the IOR reference string for the given object. The string embeds
 * information about the object repository Id, its access key and the server
 * internet address and port. With this information, the object can be found
 * by another ORB, possibly located on remote computer.
 *
 * @param forObject CORBA object
 * @return the object IOR representation.
 *
 * @throws BAD_PARAM if the object has not been previously connected to this
 * ORB.
 *
 * @throws BAD_OPERATION in the unlikely case if the local host address cannot
 * be resolved.
 *
 * @see string_to_object(String)
 */
public String object_to_string(org.omg.CORBA.Object forObject)
{
  // Handle the case when the object is known, but not local.
  if (forObject instanceof ObjectImpl)
    {
      Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
      if (delegate instanceof SimpleDelegate)
        return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
    }

  // Handle the case when the object is local.
  Connected_objects.cObject rec = connected_objects.getKey(forObject);

  if (rec == null)
    throw new BAD_PARAM("The object " + forObject +
      " has not been previously connected to this ORB"
    );

  IOR ior = createIOR(rec);

  return ior.toStringifiedReference();
}
项目:classpath    文件:OrbFunctional.java   
/**
 * Create IOR for the given object references.
 */
protected IOR createIOR(Connected_objects.cObject ref)
  throws BAD_OPERATION
{
  IOR ior = new IOR();
  ior.key = ref.key;
  ior.Internet.port = ref.port;

  if (ref.object instanceof ObjectImpl)
    {
      ObjectImpl imp = (ObjectImpl) ref.object;
      if (imp._ids().length > 0)
        ior.Id = imp._ids() [ 0 ];
    }
  if (ior.Id == null)
    ior.Id = ref.object.getClass().getName();

  ior.Internet.host = CollocatedOrbs.localHost;
  ior.Internet.port = ref.port;

  return ior;
}
项目:classpath    文件:OrbFunctional.java   
/**
 * Prepare object for connecting it to this ORB.
 *
 * @param object the object being connected.
 *
 * @throws BAD_PARAM if the object does not implement the
 * {@link InvokeHandler}).
 */
protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
  throws BAD_PARAM
{
  /*
   * if (!(object instanceof InvokeHandler)) throw new
   * BAD_PARAM(object.getClass().getName() + " does not implement
   * InvokeHandler. " );
   */

  // If no delegate is set, set the default delegate.
  if (object instanceof ObjectImpl)
    {
      ObjectImpl impl = (ObjectImpl) object;
      try
        {
          if (impl._get_delegate() == null)
            impl._set_delegate(new SimpleDelegate(this, ior));
        }
      catch (BAD_OPERATION ex)
        {
          // Some colaborants may throw this exception.
          impl._set_delegate(new SimpleDelegate(this, ior));
        }
    }
}