Java Code Examples for gnu.CORBA.IOR

The following are top voted examples for showing how to use gnu.CORBA.IOR. 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: javify   File: ORB_1_4.java   Source Code and License 6 votes vote down vote up
/**
 * Create IOR and allow registered interceptors to add additional components.
 */
protected IOR createIOR(cObject ref)
  throws BAD_OPERATION
{
  IOR ior = super.createIOR(ref);
  if (iIor != null)
    {
      AOM.Obj obj = rootPOA.findIorKey(ior.key);

      gnuPOA poa;

      // Null means that the object was connected to the ORB directly.
      if (obj == null)
        poa = rootPOA;
      else
        poa = obj.poa;

      gnuIorInfo info = new gnuIorInfo(this, poa, ior);

      // This may modify the ior.
      iIor.establish_components(info);
      iIor.components_established(info);
    }
  return ior;
}
 
Example 2
Project: javify   File: CodeSetServiceContext.java   Source Code and License 6 votes vote down vote up
/**
 * Select the suitable encoding that is defined in the provided profile.
 *
 * TODO character encoding. Now the encoding can be set, but it is ignored.
 * If you take this task, scan 'TODO character encoding' for
 * relevant places.
 */
public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
  if (profile.negotiated != null)
    return profile.negotiated;

  CodeSetServiceContext use = new CodeSetServiceContext();

  use.char_data =
    negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);

  use.wide_char_data =
    negotiate(profile.wide, STANDARD.wide_char_data, CharSets_OSF.UTF16);

  profile.negotiated = use;

  return use;
}
 
Example 3
Project: javify   File: ErrorMessage.java   Source Code and License 6 votes vote down vote up
/**
 * Send the error message to the given IOR address.
 *
 * @param ior the IOR address (host and port, other fields
 * are not used).
 *
 * @param orb the ORB, sending the error message.
 */
public void send(IOR ior, ORB orb)
{
  try
    {
      Socket socket;

      if (orb instanceof OrbFunctional)
        socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
          ior.Internet.host, ior.Internet.port);
      else
        socket = new Socket(ior.Internet.host, ior.Internet.port);

      OutputStream socketOutput = socket.getOutputStream();
      write(socketOutput);
      socketOutput.close();
      socket.close();
    }
  catch (IOException ex)
    {
      MARSHAL t = new MARSHAL();
      t.minor = Minor.Header;
      t.initCause(ex);
      throw t;
    }
}
 
Example 4
Project: jvm-stm   File: ORB_1_4.java   Source Code and License 6 votes vote down vote up
/**
 * Create IOR and allow registered interceptors to add additional components.
 */
protected IOR createIOR(cObject ref)
  throws BAD_OPERATION
{
  IOR ior = super.createIOR(ref);
  if (iIor != null)
    {
      AOM.Obj obj = rootPOA.findIorKey(ior.key);

      gnuPOA poa;

      // Null means that the object was connected to the ORB directly.
      if (obj == null)
        poa = rootPOA;
      else
        poa = obj.poa;

      gnuIorInfo info = new gnuIorInfo(this, poa, ior);

      // This may modify the ior.
      iIor.establish_components(info);
      iIor.components_established(info);
    }
  return ior;
}
 
Example 5
Project: jvm-stm   File: CodeSetServiceContext.java   Source Code and License 6 votes vote down vote up
/**
 * Select the suitable encoding that is defined in the provided profile.
 *
 * TODO character encoding. Now the encoding can be set, but it is ignored.
 * If you take this task, scan 'TODO character encoding' for
 * relevant places.
 */
public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
  if (profile.negotiated != null)
    return profile.negotiated;

  CodeSetServiceContext use = new CodeSetServiceContext();

  use.char_data =
    negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);

  use.wide_char_data =
    negotiate(profile.wide, STANDARD.wide_char_data, CharSets_OSF.UTF16);

  profile.negotiated = use;

  return use;
}
 
Example 6
Project: jvm-stm   File: ErrorMessage.java   Source Code and License 6 votes vote down vote up
/**
 * Send the error message to the given IOR address.
 *
 * @param ior the IOR address (host and port, other fields
 * are not used).
 * 
 * @param orb the ORB, sending the error message.
 */
public void send(IOR ior, ORB orb)
{
  try
    {
      Socket socket;
      
      if (orb instanceof OrbFunctional)
        socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
          ior.Internet.host, ior.Internet.port);
      else
        socket = new Socket(ior.Internet.host, ior.Internet.port);

      OutputStream socketOutput = socket.getOutputStream();
      write(socketOutput);
      socketOutput.close();
      socket.close();
    }
  catch (IOException ex)
    {
      MARSHAL t = new MARSHAL();
      t.minor = Minor.Header;
      t.initCause(ex);
      throw t;
    }
}
 
Example 7
Project: JamVM-PH   File: ORB_1_4.java   Source Code and License 6 votes vote down vote up
/**
 * Create IOR and allow registered interceptors to add additional components.
 */
protected IOR createIOR(cObject ref)
  throws BAD_OPERATION
{
  IOR ior = super.createIOR(ref);
  if (iIor != null)
    {
      AOM.Obj obj = rootPOA.findIorKey(ior.key);

      gnuPOA poa;

      // Null means that the object was connected to the ORB directly.
      if (obj == null)
        poa = rootPOA;
      else
        poa = obj.poa;

      gnuIorInfo info = new gnuIorInfo(this, poa, ior);

      // This may modify the ior.
      iIor.establish_components(info);
      iIor.components_established(info);
    }
  return ior;
}
 
Example 8
Project: JamVM-PH   File: CodeSetServiceContext.java   Source Code and License 6 votes vote down vote up
/**
 * Select the suitable encoding that is defined in the provided profile.
 *
 * TODO character encoding. Now the encoding can be set, but it is ignored.
 * If you take this task, scan 'TODO character encoding' for
 * relevant places.
 */
public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
  if (profile.negotiated != null)
    return profile.negotiated;

  CodeSetServiceContext use = new CodeSetServiceContext();

  use.char_data =
    negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);

  use.wide_char_data =
    negotiate(profile.wide, STANDARD.wide_char_data, CharSets_OSF.UTF16);

  profile.negotiated = use;

  return use;
}
 
Example 9
Project: JamVM-PH   File: ErrorMessage.java   Source Code and License 6 votes vote down vote up
/**
 * Send the error message to the given IOR address.
 *
 * @param ior the IOR address (host and port, other fields
 * are not used).
 * 
 * @param orb the ORB, sending the error message.
 */
public void send(IOR ior, ORB orb)
{
  try
    {
      Socket socket;
      
      if (orb instanceof OrbFunctional)
        socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
          ior.Internet.host, ior.Internet.port);
      else
        socket = new Socket(ior.Internet.host, ior.Internet.port);

      OutputStream socketOutput = socket.getOutputStream();
      write(socketOutput);
      socketOutput.close();
      socket.close();
    }
  catch (IOException ex)
    {
      MARSHAL t = new MARSHAL();
      t.minor = Minor.Header;
      t.initCause(ex);
      throw t;
    }
}
 
Example 10
Project: classpath   File: ORB_1_4.java   Source Code and License 6 votes vote down vote up
/**
 * Create IOR and allow registered interceptors to add additional components.
 */
protected IOR createIOR(cObject ref)
  throws BAD_OPERATION
{
  IOR ior = super.createIOR(ref);
  if (iIor != null)
    {
      AOM.Obj obj = rootPOA.findIorKey(ior.key);

      gnuPOA poa;

      // Null means that the object was connected to the ORB directly.
      if (obj == null)
        poa = rootPOA;
      else
        poa = obj.poa;

      gnuIorInfo info = new gnuIorInfo(this, poa, ior);

      // This may modify the ior.
      iIor.establish_components(info);
      iIor.components_established(info);
    }
  return ior;
}
 
Example 11
Project: classpath   File: CodeSetServiceContext.java   Source Code and License 6 votes vote down vote up
/**
 * Select the suitable encoding that is defined in the provided profile.
 *
 * TODO character encoding. Now the encoding can be set, but it is ignored.
 * If you take this task, scan 'TODO character encoding' for
 * relevant places.
 */
public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
  if (profile.negotiated != null)
    return profile.negotiated;

  CodeSetServiceContext use = new CodeSetServiceContext();

  use.char_data =
    negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);

  use.wide_char_data =
    negotiate(profile.wide, STANDARD.wide_char_data, CharSets_OSF.UTF16);

  profile.negotiated = use;

  return use;
}
 
Example 12
Project: classpath   File: ErrorMessage.java   Source Code and License 6 votes vote down vote up
/**
 * Send the error message to the given IOR address.
 *
 * @param ior the IOR address (host and port, other fields
 * are not used).
 *
 * @param orb the ORB, sending the error message.
 */
public void send(IOR ior, ORB orb)
{
  try
    {
      Socket socket;

      if (orb instanceof OrbFunctional)
        socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
          ior.Internet.host, ior.Internet.port);
      else
        socket = new Socket(ior.Internet.host, ior.Internet.port);

      OutputStream socketOutput = socket.getOutputStream();
      write(socketOutput);
      socketOutput.close();
      socket.close();
    }
  catch (IOException ex)
    {
      MARSHAL t = new MARSHAL();
      t.minor = Minor.Header;
      t.initCause(ex);
      throw t;
    }
}
 
Example 13
Project: javify   File: CodeSetServiceContext.java   Source Code and License 5 votes vote down vote up
/**
 * Negotiate about the character encoding. Prefer our native encoding,
 * if no, prefer IORs native encoding, if no, find any encoding,
 * supported by both sides, if no, return the specified final decission.
 *
 * @param profile the component profile in IOR.
 * @param our_native our native encoding
 * @param final_decission the encoding that must be returned if no
 * compromise is found.
 *
 * @return the resulted encoding.
 */
protected static int negotiate(IOR.CodeSets_profile.CodeSet_component profile,
                               int our_native, int final_decission
                              )
{
  // If our and IORs native sets match, use the native set.
  if (profile.native_set == our_native)
    return our_native;

  // If the native sets do not match, but the IOR says it
  // supports our native set, use our native set.
  if (profile.conversion != null)
    for (int i = 0; i < profile.conversion.length; i++)
      {
        if (our_native == profile.conversion [ i ])
          return our_native;
      }

  // At this point, we suggest to use the IORs native set.
  int[] allSupported = CharSets_OSF.getSupportedCharSets();

  for (int s = 0; s < allSupported.length; s++)
    if (allSupported [ s ] == profile.native_set)
      return profile.native_set;

  // Any compromise left?
  if (profile.conversion != null)
    for (int s = 0; s < allSupported.length; s++)
      for (int i = 0; i < profile.conversion.length; i++)
        if (allSupported [ s ] == profile.conversion [ i ])
          return allSupported [ s ];

  // Return the CORBA default char encoding.
  return final_decission;
}
 
Example 14
Project: javify   File: gnuIorInfo.java   Source Code and License 5 votes vote down vote up
/**
 * Create an instance.
 */
public gnuIorInfo(ORB_1_4 an_orb, gnuPOA a_poa, IOR an_ior)
{
  orb = an_orb;
  poa = a_poa;
  ior = an_ior;
}
 
Example 15
Project: jvm-stm   File: CodeSetServiceContext.java   Source Code and License 5 votes vote down vote up
/**
 * Negotiate about the character encoding. Prefer our native encoding,
 * if no, prefer IORs native encoding, if no, find any encoding,
 * supported by both sides, if no, return the specified final decission.
 *
 * @param profile the component profile in IOR.
 * @param our_native our native encoding
 * @param final_decission the encoding that must be returned if no
 * compromise is found.
 *
 * @return the resulted encoding.
 */
protected static int negotiate(IOR.CodeSets_profile.CodeSet_component profile,
                               int our_native, int final_decission
                              )
{
  // If our and IORs native sets match, use the native set.
  if (profile.native_set == our_native)
    return our_native;

  // If the native sets do not match, but the IOR says it
  // supports our native set, use our native set.
  if (profile.conversion != null)
    for (int i = 0; i < profile.conversion.length; i++)
      {
        if (our_native == profile.conversion [ i ])
          return our_native;
      }

  // At this point, we suggest to use the IORs native set.
  int[] allSupported = CharSets_OSF.getSupportedCharSets();

  for (int s = 0; s < allSupported.length; s++)
    if (allSupported [ s ] == profile.native_set)
      return profile.native_set;

  // Any compromise left?
  if (profile.conversion != null)
    for (int s = 0; s < allSupported.length; s++)
      for (int i = 0; i < profile.conversion.length; i++)
        if (allSupported [ s ] == profile.conversion [ i ])
          return allSupported [ s ];

  // Return the CORBA default char encoding.
  return final_decission;
}
 
Example 16
Project: jvm-stm   File: gnuIorInfo.java   Source Code and License 5 votes vote down vote up
/**
 * Create an instance.
 */
public gnuIorInfo(ORB_1_4 an_orb, gnuPOA a_poa, IOR an_ior)
{
  orb = an_orb;
  poa = a_poa;
  ior = an_ior;
}
 
Example 17
Project: JamVM-PH   File: CodeSetServiceContext.java   Source Code and License 5 votes vote down vote up
/**
 * Negotiate about the character encoding. Prefer our native encoding,
 * if no, prefer IORs native encoding, if no, find any encoding,
 * supported by both sides, if no, return the specified final decission.
 *
 * @param profile the component profile in IOR.
 * @param our_native our native encoding
 * @param final_decission the encoding that must be returned if no
 * compromise is found.
 *
 * @return the resulted encoding.
 */
protected static int negotiate(IOR.CodeSets_profile.CodeSet_component profile,
                               int our_native, int final_decission
                              )
{
  // If our and IORs native sets match, use the native set.
  if (profile.native_set == our_native)
    return our_native;

  // If the native sets do not match, but the IOR says it
  // supports our native set, use our native set.
  if (profile.conversion != null)
    for (int i = 0; i < profile.conversion.length; i++)
      {
        if (our_native == profile.conversion [ i ])
          return our_native;
      }

  // At this point, we suggest to use the IORs native set.
  int[] allSupported = CharSets_OSF.getSupportedCharSets();

  for (int s = 0; s < allSupported.length; s++)
    if (allSupported [ s ] == profile.native_set)
      return profile.native_set;

  // Any compromise left?
  if (profile.conversion != null)
    for (int s = 0; s < allSupported.length; s++)
      for (int i = 0; i < profile.conversion.length; i++)
        if (allSupported [ s ] == profile.conversion [ i ])
          return allSupported [ s ];

  // Return the CORBA default char encoding.
  return final_decission;
}
 
Example 18
Project: JamVM-PH   File: gnuIorInfo.java   Source Code and License 5 votes vote down vote up
/**
 * Create an instance.
 */
public gnuIorInfo(ORB_1_4 an_orb, gnuPOA a_poa, IOR an_ior)
{
  orb = an_orb;
  poa = a_poa;
  ior = an_ior;
}
 
Example 19
Project: classpath   File: CodeSetServiceContext.java   Source Code and License 5 votes vote down vote up
/**
 * Negotiate about the character encoding. Prefer our native encoding,
 * if no, prefer IORs native encoding, if no, find any encoding,
 * supported by both sides, if no, return the specified final decission.
 *
 * @param profile the component profile in IOR.
 * @param our_native our native encoding
 * @param final_decission the encoding that must be returned if no
 * compromise is found.
 *
 * @return the resulted encoding.
 */
protected static int negotiate(IOR.CodeSets_profile.CodeSet_component profile,
                               int our_native, int final_decission
                              )
{
  // If our and IORs native sets match, use the native set.
  if (profile.native_set == our_native)
    return our_native;

  // If the native sets do not match, but the IOR says it
  // supports our native set, use our native set.
  if (profile.conversion != null)
    for (int i = 0; i < profile.conversion.length; i++)
      {
        if (our_native == profile.conversion [ i ])
          return our_native;
      }

  // At this point, we suggest to use the IORs native set.
  int[] allSupported = CharSets_OSF.getSupportedCharSets();

  for (int s = 0; s < allSupported.length; s++)
    if (allSupported [ s ] == profile.native_set)
      return profile.native_set;

  // Any compromise left?
  if (profile.conversion != null)
    for (int s = 0; s < allSupported.length; s++)
      for (int i = 0; i < profile.conversion.length; i++)
        if (allSupported [ s ] == profile.conversion [ i ])
          return allSupported [ s ];

  // Return the CORBA default char encoding.
  return final_decission;
}
 
Example 20
Project: classpath   File: gnuIorInfo.java   Source Code and License 5 votes vote down vote up
/**
 * Create an instance.
 */
public gnuIorInfo(ORB_1_4 an_orb, gnuPOA a_poa, IOR an_ior)
{
  orb = an_orb;
  poa = a_poa;
  ior = an_ior;
}
 
Example 21
Project: javify   File: Main.java   Source Code and License 4 votes vote down vote up
private void run(String[] args)
{
  Parser parser = initializeParser();
  parser.parse(args);

  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();
      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      File dataDirectory = new File(directory);
      System.out.println("Persistent data stored at "
                         + dataDirectory.getAbsolutePath());
      dataDirectory.mkdirs();

      // / TODO support more starting modes.
      NamingContextExt namer = new Ext(
                                       new PersistentContext(
                                                             orb,
                                                             dataDirectory,
                                                             cold));

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      System.out.println("GNU Classpath persistent naming service "
                         + "started at " + iorr.Internet.host + ":"
                         + iorr.Internet.port + " key 'NameService'.\n\n"
                         + "Copyright (C) 2008 Free Software Foundation\n"
                         + "This tool comes with ABSOLUTELY NO WARRANTY. "
                         + "This is free software, and you are\nwelcome to "
                         + "redistribute it under conditions, defined in "
                         + "GNU Classpath license.\n\n" + ior);

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (FileNotFoundException e)
    {
      throw new RuntimeException(e);
    }
  finally
    {
      // Restore the default value for allocating ports for the subsequent
      // objects.
      OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
    }
}
 
Example 22
Project: javify   File: NamingServiceTransient.java   Source Code and License 4 votes vote down vote up
/**
 * Start the naming service on the current host at the given port.
 *
 * @param portArgument the port on which the service will be
 * started, or -1 to use the default port, 900
 * @param fileArgument if non-null, store the IOR string of this
 * naming service in a file by this name
 */
public static void start(int portArgument, String fileArgument)
{
  int port = PORT;

  if (portArgument > -1)
    port = portArgument;

  String iorf = fileArgument;
  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();

      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      NamingContextExt namer = new Ext(new TransientContext());

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (Exception e)
    {
      System.err.println("ERROR: " + e);
      e.printStackTrace(System.err);
    }

  // Restore the default value for allocating ports for the subsequent
  // objects.
  OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
 
Example 23
Project: javify   File: gnuServantObject.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR as it would be for this object.
 */
public IOR getIor()
{
  return orb.getLocalIor(this);
}
 
Example 24
Project: javify   File: LocalDelegate.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR of the connected object.
 */
public IOR getIor()
{
  return object.getIor();
}
 
Example 25
Project: javify   File: AbstractCdrOutput.java   Source Code and License 4 votes vote down vote up
/**
 * Read the CORBA object. The object is written form of the plain (not a
 * string-encoded) IOR profile without the heading endian indicator. The
 * responsible method for reading such data is {@link IOR.write_no_endian}.
 *
 * The null value is written as defined in OMG specification (zero length
 * string, followed by an empty set of profiles).
 */
public void write_Object(org.omg.CORBA.Object x)
{
  ORB w_orb = orb;
  if (x instanceof IorProvider)
    {
      ((IorProvider) x).getIor()._write_no_endian(this);
      return;
    }
  else if (x == null)
    {
      IOR.write_null(this);
      return;
    }
  else if (x instanceof ObjectImpl)
    {
      Delegate d = ((ObjectImpl) x)._get_delegate();

      if (d instanceof IorProvider)
        {
          ((IorProvider) d).getIor()._write_no_endian(this);
          return;
        }
      else
        {
          ORB d_orb = d.orb(x);
          if (d_orb != null)
            w_orb = d_orb;
        }
    }

  // Either this is not an ObjectImpl or it has the
  // unexpected delegate. Try to convert via ORBs
  // object_to_string().
  if (w_orb != null)
    {
      IOR ior = IOR.parse(w_orb.object_to_string(x));
      ior._write_no_endian(this);
      return;
    }
  else
    throw new BAD_OPERATION(
      "Please set the ORB for this stream, cannot write "
        + x.getClass().getName());
}
 
Example 26
Project: jvm-stm   File: Main.java   Source Code and License 4 votes vote down vote up
private void run(String[] args)
{
  Parser parser = initializeParser();
  parser.parse(args);

  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();
      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      File dataDirectory = new File(directory);
      System.out.println("Persistent data stored at "
                         + dataDirectory.getAbsolutePath());
      dataDirectory.mkdirs();

      // / TODO support more starting modes.
      NamingContextExt namer = new Ext(
                                       new PersistentContext(
                                                             orb,
                                                             dataDirectory,
                                                             cold));

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      System.out.println("GNU Classpath persistent naming service "
                         + "started at " + iorr.Internet.host + ":"
                         + iorr.Internet.port + " key 'NameService'.\n\n"
                         + "Copyright (C) 2008 Free Software Foundation\n"
                         + "This tool comes with ABSOLUTELY NO WARRANTY. "
                         + "This is free software, and you are\nwelcome to "
                         + "redistribute it under conditions, defined in "
                         + "GNU Classpath license.\n\n" + ior);

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (FileNotFoundException e)
    {
      throw new RuntimeException(e);
    }
  finally
    {
      // Restore the default value for allocating ports for the subsequent
      // objects.
      OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
    }
}
 
Example 27
Project: jvm-stm   File: NamingServiceTransient.java   Source Code and License 4 votes vote down vote up
/**
 * Start the naming service on the current host at the given port.
 * 
 * @param portArgument the port on which the service will be
 * started, or -1 to use the default port, 900
 * @param fileArgument if non-null, store the IOR string of this
 * naming service in a file by this name
 */
public static void start(int portArgument, String fileArgument)
{
  int port = PORT;

  if (portArgument > -1)
    port = portArgument;

  String iorf = fileArgument;
  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();

      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      NamingContextExt namer = new Ext(new TransientContext());

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (Exception e)
    {
      System.err.println("ERROR: " + e);
      e.printStackTrace(System.err);
    }

  // Restore the default value for allocating ports for the subsequent
  // objects.
  OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
 
Example 28
Project: jvm-stm   File: gnuServantObject.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR as it would be for this object.
 */
public IOR getIor()
{
  return orb.getLocalIor(this);    
}
 
Example 29
Project: jvm-stm   File: LocalDelegate.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR of the connected object.
 */
public IOR getIor()
{
  return object.getIor();
}
 
Example 30
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 4 votes vote down vote up
/**
 * Read the CORBA object. The object is written form of the plain (not a
 * string-encoded) IOR profile without the heading endian indicator. The
 * responsible method for reading such data is {@link IOR.write_no_endian}.
 * 
 * The null value is written as defined in OMG specification (zero length
 * string, followed by an empty set of profiles).
 */
public void write_Object(org.omg.CORBA.Object x)
{
  ORB w_orb = orb;
  if (x instanceof IorProvider)
    {
      ((IorProvider) x).getIor()._write_no_endian(this);
      return;
    }
  else if (x == null)
    {
      IOR.write_null(this);
      return;
    }
  else if (x instanceof ObjectImpl)
    {
      Delegate d = ((ObjectImpl) x)._get_delegate();

      if (d instanceof IorProvider)
        {
          ((IorProvider) d).getIor()._write_no_endian(this);
          return;
        }
      else
        {
          ORB d_orb = d.orb(x);
          if (d_orb != null)
            w_orb = d_orb;
        }
    }

  // Either this is not an ObjectImpl or it has the
  // unexpected delegate. Try to convert via ORBs
  // object_to_string().
  if (w_orb != null)
    {
      IOR ior = IOR.parse(w_orb.object_to_string(x));
      ior._write_no_endian(this);
      return;
    }
  else
    throw new BAD_OPERATION(
      "Please set the ORB for this stream, cannot write "
        + x.getClass().getName());
}
 
Example 31
Project: JamVM-PH   File: Main.java   Source Code and License 4 votes vote down vote up
private void run(String[] args)
{
  Parser parser = initializeParser();
  parser.parse(args);

  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();
      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      File dataDirectory = new File(directory);
      System.out.println("Persistent data stored at "
                         + dataDirectory.getAbsolutePath());
      dataDirectory.mkdirs();

      // / TODO support more starting modes.
      NamingContextExt namer = new Ext(
                                       new PersistentContext(
                                                             orb,
                                                             dataDirectory,
                                                             cold));

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      System.out.println("GNU Classpath persistent naming service "
                         + "started at " + iorr.Internet.host + ":"
                         + iorr.Internet.port + " key 'NameService'.\n\n"
                         + "Copyright (C) 2008 Free Software Foundation\n"
                         + "This tool comes with ABSOLUTELY NO WARRANTY. "
                         + "This is free software, and you are\nwelcome to "
                         + "redistribute it under conditions, defined in "
                         + "GNU Classpath license.\n\n" + ior);

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (FileNotFoundException e)
    {
      throw new RuntimeException(e);
    }
  finally
    {
      // Restore the default value for allocating ports for the subsequent
      // objects.
      OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
    }
}
 
Example 32
Project: JamVM-PH   File: NamingServiceTransient.java   Source Code and License 4 votes vote down vote up
/**
 * Start the naming service on the current host at the given port.
 * 
 * @param portArgument the port on which the service will be
 * started, or -1 to use the default port, 900
 * @param fileArgument if non-null, store the IOR string of this
 * naming service in a file by this name
 */
public static void start(int portArgument, String fileArgument)
{
  int port = PORT;

  if (portArgument > -1)
    port = portArgument;

  String iorf = fileArgument;
  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();

      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      NamingContextExt namer = new Ext(new TransientContext());

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (Exception e)
    {
      System.err.println("ERROR: " + e);
      e.printStackTrace(System.err);
    }

  // Restore the default value for allocating ports for the subsequent
  // objects.
  OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
 
Example 33
Project: JamVM-PH   File: gnuServantObject.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR as it would be for this object.
 */
public IOR getIor()
{
  return orb.getLocalIor(this);    
}
 
Example 34
Project: JamVM-PH   File: LocalDelegate.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR of the connected object.
 */
public IOR getIor()
{
  return object.getIor();
}
 
Example 35
Project: JamVM-PH   File: AbstractCdrOutput.java   Source Code and License 4 votes vote down vote up
/**
 * Read the CORBA object. The object is written form of the plain (not a
 * string-encoded) IOR profile without the heading endian indicator. The
 * responsible method for reading such data is {@link IOR.write_no_endian}.
 * 
 * The null value is written as defined in OMG specification (zero length
 * string, followed by an empty set of profiles).
 */
public void write_Object(org.omg.CORBA.Object x)
{
  ORB w_orb = orb;
  if (x instanceof IorProvider)
    {
      ((IorProvider) x).getIor()._write_no_endian(this);
      return;
    }
  else if (x == null)
    {
      IOR.write_null(this);
      return;
    }
  else if (x instanceof ObjectImpl)
    {
      Delegate d = ((ObjectImpl) x)._get_delegate();

      if (d instanceof IorProvider)
        {
          ((IorProvider) d).getIor()._write_no_endian(this);
          return;
        }
      else
        {
          ORB d_orb = d.orb(x);
          if (d_orb != null)
            w_orb = d_orb;
        }
    }

  // Either this is not an ObjectImpl or it has the
  // unexpected delegate. Try to convert via ORBs
  // object_to_string().
  if (w_orb != null)
    {
      IOR ior = IOR.parse(w_orb.object_to_string(x));
      ior._write_no_endian(this);
      return;
    }
  else
    throw new BAD_OPERATION(
      "Please set the ORB for this stream, cannot write "
        + x.getClass().getName());
}
 
Example 36
Project: classpath   File: Main.java   Source Code and License 4 votes vote down vote up
private void run(String[] args)
{
  Parser parser = initializeParser();
  parser.parse(args);

  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();
      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      File dataDirectory = new File(directory);
      System.out.println("Persistent data stored at "
                         + dataDirectory.getAbsolutePath());
      dataDirectory.mkdirs();

      // / TODO support more starting modes.
      NamingContextExt namer = new Ext(
                                       new PersistentContext(
                                                             orb,
                                                             dataDirectory,
                                                             cold));

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      System.out.println("GNU Classpath persistent naming service "
                         + "started at " + iorr.Internet.host + ":"
                         + iorr.Internet.port + " key 'NameService'.\n\n"
                         + "Copyright (C) 2012 Free Software Foundation\n"
                         + "This tool comes with ABSOLUTELY NO WARRANTY. "
                         + "This is free software, and you are\nwelcome to "
                         + "redistribute it under conditions, defined in "
                         + "GNU Classpath license.\n\n" + ior);

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (FileNotFoundException e)
    {
      throw new RuntimeException(e);
    }
  finally
    {
      // Restore the default value for allocating ports for the subsequent
      // objects.
      OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
    }
}
 
Example 37
Project: classpath   File: NamingServiceTransient.java   Source Code and License 4 votes vote down vote up
/**
 * Start the naming service on the current host at the given port.
 *
 * @param portArgument the port on which the service will be
 * started, or -1 to use the default port, 900
 * @param fileArgument if non-null, store the IOR string of this
 * naming service in a file by this name
 */
public static void start(int portArgument, String fileArgument)
{
  int port = PORT;

  if (portArgument > -1)
    port = portArgument;

  String iorf = fileArgument;
  try
    {
      // Create and initialize the ORB
      final OrbFunctional orb = new OrbFunctional();

      OrbFunctional.setPort(port);

      // Create the servant and register it with the ORB
      NamingContextExt namer = new Ext(new TransientContext());

      // Case with the key "NameService".
      orb.connect(namer, "NameService".getBytes());

      // Storing the IOR reference.
      String ior = orb.object_to_string(namer);
      IOR iorr = IOR.parse(ior);
      if (iorf != null)
        {
          FileOutputStream f = new FileOutputStream(iorf);
          PrintStream p = new PrintStream(f);
          p.print(ior);
          p.close();
        }

      new Thread()
      {
        public void run()
        {
          // Wait for invocations from clients.
          orb.run();
        }
      }.start();
    }
  catch (Exception e)
    {
      System.err.println("ERROR: " + e);
      e.printStackTrace(System.err);
    }

  // Restore the default value for allocating ports for the subsequent
  // objects.
  OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
 
Example 38
Project: classpath   File: gnuServantObject.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR as it would be for this object.
 */
public IOR getIor()
{
  return orb.getLocalIor(this);
}
 
Example 39
Project: classpath   File: LocalDelegate.java   Source Code and License 4 votes vote down vote up
/**
 * Get the IOR of the connected object.
 */
public IOR getIor()
{
  return object.getIor();
}
 
Example 40
Project: classpath   File: AbstractCdrOutput.java   Source Code and License 4 votes vote down vote up
/**
 * Read the CORBA object. The object is written form of the plain (not a
 * string-encoded) IOR profile without the heading endian indicator. The
 * responsible method for reading such data is {@link IOR.write_no_endian}.
 *
 * The null value is written as defined in OMG specification (zero length
 * string, followed by an empty set of profiles).
 */
public void write_Object(org.omg.CORBA.Object x)
{
  ORB w_orb = orb;
  if (x instanceof IorProvider)
    {
      ((IorProvider) x).getIor()._write_no_endian(this);
      return;
    }
  else if (x == null)
    {
      IOR.write_null(this);
      return;
    }
  else if (x instanceof ObjectImpl)
    {
      Delegate d = ((ObjectImpl) x)._get_delegate();

      if (d instanceof IorProvider)
        {
          ((IorProvider) d).getIor()._write_no_endian(this);
          return;
        }
      else
        {
          ORB d_orb = d.orb(x);
          if (d_orb != null)
            w_orb = d_orb;
        }
    }

  // Either this is not an ObjectImpl or it has the
  // unexpected delegate. Try to convert via ORBs
  // object_to_string().
  if (w_orb != null)
    {
      IOR ior = IOR.parse(w_orb.object_to_string(x));
      ior._write_no_endian(this);
      return;
    }
  else
    throw new BAD_OPERATION(
      "Please set the ORB for this stream, cannot write "
        + x.getClass().getName());
}