~ubuntu-branches/ubuntu/precise/libpgjava/precise

« back to all changes in this revision

Viewing changes to example/corba/StockServer.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2008-04-26 22:01:11 UTC
  • mfrom: (3.1.4 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080426220111-yasgxtas5smx2qm3
Tags: 8.2-504-2
* Updated description to mention PostgreSQL 8.3 as supported.
  Closes: #398348
* Removed libpgjava transitional package. Closes: #477557
* Moved debhelper and cdbs from Build-Depends-Indep to Build-Depends.
* Added Homepage, Vcs-Svn and Vcs-Browser fields.
* Added watch file.
* Added myself to Uploaders.
* Removed Stafan and Wolfgang from Uploaders.
* Updated Standards-Version to 3.7.3
* Updated debhelper level to 5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package example.corba;
2
 
 
3
 
import org.omg.CosNaming.*;
4
 
 
5
 
/*
6
 
 * This class implements the server side of the example.
7
 
 *
8
 
 * $PostgreSQL: pgjdbc/example/corba/StockServer.java,v 1.7 2004/11/09 08:43:20 jurka Exp $
9
 
 */
10
 
public class StockServer
11
 
{
12
 
    public static void main(String[] args)
13
 
    {
14
 
        int numInstances = 3;
15
 
 
16
 
        try
17
 
        {
18
 
            // Initialise the ORB
19
 
            org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
20
 
 
21
 
            // Create the StockDispenser object
22
 
            StockDispenserImpl dispenser = new StockDispenserImpl(args, "Stock Dispenser", numInstances);
23
 
 
24
 
            // Export the new object
25
 
            orb.connect(dispenser);
26
 
 
27
 
            // Get the naming service
28
 
            org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService");
29
 
            if (nameServiceObj == null)
30
 
            {
31
 
                System.err.println("nameServiceObj = null");
32
 
                return ;
33
 
            }
34
 
 
35
 
            org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj);
36
 
            if (nameService == null)
37
 
            {
38
 
                System.err.println("nameService = null");
39
 
                return ;
40
 
            }
41
 
 
42
 
            // bind the dispenser into the naming service
43
 
            NameComponent[] dispenserName = {
44
 
                                                new NameComponent("StockDispenser", "Stock")
45
 
                                            };
46
 
            nameService.rebind(dispenserName, dispenser);
47
 
 
48
 
            // Now wait forever for the current thread to die
49
 
            Thread.currentThread().join();
50
 
        }
51
 
        catch (Exception e)
52
 
        {
53
 
            e.printStackTrace();
54
 
        }
55
 
    }
56
 
}
57
 
 
58