summaryrefslogtreecommitdiff
path: root/TAO/tests/GIOP_Fragments/Java_Big_Reply/server.java
blob: c89b7595e7fd258845f30395bdf0855f07adab4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// $Id$

// If this server is compiled and run with the JDK ORB, it will
// fragment the GIOP Messages sent when get_big_reply() is called.

import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import Test.Big_ReplyPOA;

class Big_ReplyImpl extends Big_ReplyPOA
{
  private org.omg.CORBA.ORB orb_;

  public byte[] get_big_reply () {
    byte [] seq = new byte [1000000];
    for (int i = 0; i < seq.length; i++)
      seq [i] = 'A';
    return seq;
  }

  public void setORB (org.omg.CORBA.ORB orb_val) {
    orb_ = orb_val;
  }

  public void ping () {
  }

  public void shutdown () {
    orb_.shutdown (false);
  }
}


public class server
{
  public static void main (String args[]) {
    try {
      ORB orb = ORB.init (args, null);
      POA poa = org.omg.PortableServer.POAHelper.narrow (
                       orb.resolve_initial_references ("RootPOA"));

      Big_ReplyImpl servant = new Big_ReplyImpl ();
      servant.setORB (orb);
      poa.activate_object (servant);

      String filename = new String ("server.ior");
      String ior = orb.object_to_string (servant._this ());
      java.io.FileWriter file = new java.io.FileWriter (filename);
      file.write (ior);
      file.flush ();
      file.close ();

      poa.the_POAManager ().activate ();
      System.out.println ("Ready...");
      orb.run ();
    }
    catch (Exception e) {
      System.err.println ("ERROR: " + e);
      e.printStackTrace (System.out);
    }
  }
}