Java Code Examples for org.omg.CORBA.portable.ObjectImpl

The following are top voted examples for showing how to use org.omg.CORBA.portable.ObjectImpl. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 2
Project: openjdk-jdk10   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 3
Project: openjdk9   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 4
Project: lookaside_java-1.8.0-openjdk   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 5
Project: jdk8u_corba   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 6
Project: javify   File: PolicyHelper.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Project: javify   File: NamingContextHelper.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 8
Project: javify   File: GiopIo.java   View source code 6 votes vote down vote up
/**
 * 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);";
}
 
Example 9
Project: javify   File: ContextContinuation.java   View source code 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 10
Project: javify   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 11
Project: javify   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Project: javify   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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));
        }
    }
}
 
Example 13
Project: javify   File: SimpleDelegate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 14
Project: jvm-stm   File: PolicyHelper.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 15
Project: jvm-stm   File: NamingContextHelper.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 16
Project: jvm-stm   File: GiopIo.java   View source code 6 votes vote down vote up
/**
 * 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);";
}
 
Example 17
Project: jvm-stm   File: ContextContinuation.java   View source code 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 18
Project: jvm-stm   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 19
Project: jvm-stm   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 20
Project: jvm-stm   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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));
        }
    }
}
 
Example 21
Project: jvm-stm   File: SimpleDelegate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 22
Project: infobip-open-jdk-8   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 23
Project: openjdk-source-code-learn   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 24
Project: OLD-OpenJDK8   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 25
Project: JamVM-PH   File: PolicyHelper.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 26
Project: JamVM-PH   File: NamingContextHelper.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 27
Project: JamVM-PH   File: GiopIo.java   View source code 6 votes vote down vote up
/**
 * 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);";
}
 
Example 28
Project: JamVM-PH   File: ContextContinuation.java   View source code 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 29
Project: JamVM-PH   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 30
Project: JamVM-PH   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 31
Project: JamVM-PH   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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));
        }
    }
}
 
Example 32
Project: JamVM-PH   File: SimpleDelegate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 33
Project: openjdk-orb   File: StubAdapter.java   View source code 6 votes vote down vote up
/** 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() ;
    }
}
 
Example 34
Project: classpath   File: PolicyHelper.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 35
Project: classpath   File: NamingContextHelper.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 36
Project: classpath   File: GiopIo.java   View source code 6 votes vote down vote up
/**
 * 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);";
}
 
Example 37
Project: classpath   File: ContextContinuation.java   View source code 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 38
Project: classpath   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 39
Project: classpath   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 40
Project: classpath   File: OrbFunctional.java   View source code 6 votes vote down vote up
/**
 * 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));
        }
    }
}