~ubuntu-branches/ubuntu/wily/libpgjava/wily

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/example/corba/StockItemImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Gybas
  • Date: 2002-02-06 23:43:06 UTC
  • Revision ID: james.westby@ubuntu.com-20020206234306-hsg7suqr8q56qg40
Tags: upstream-7.2
ImportĀ upstreamĀ versionĀ 7.2

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
 * $Id: StockItemImpl.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
 
9
 */
 
10
public class StockItemImpl extends stock._StockItemImplBase
 
11
{
 
12
        private StockDB db;
 
13
        private String instanceName;
 
14
 
 
15
        public StockItemImpl(String[] args, String iname)
 
16
        {
 
17
                super();
 
18
                try
 
19
                {
 
20
                        db = new StockDB();
 
21
                        db.connect(args[1], args[2], args[3]);
 
22
                        System.out.println("StockDB object " + iname + " created");
 
23
                        instanceName = iname;
 
24
                }
 
25
                catch (Exception e)
 
26
                {
 
27
                        e.printStackTrace();
 
28
                }
 
29
        }
 
30
 
 
31
        /*
 
32
         * This is defined in stock.idl
 
33
         *
 
34
         * It sets the item to view
 
35
         */
 
36
        public void fetchItem(int id) throws stock.StockException
 
37
        {
 
38
                try
 
39
                {
 
40
                        db.fetchItem(id);
 
41
                }
 
42
                catch (Exception e)
 
43
                {
 
44
                        throw new stock.StockException(e.toString());
 
45
                }
 
46
        }
 
47
 
 
48
 
 
49
        /*
 
50
         * This is defined in stock.idl
 
51
         *
 
52
         * It sets the item to view
 
53
         */
 
54
        public int newItem() throws stock.StockException
 
55
        {
 
56
                try
 
57
                {
 
58
                        return db.newItem();
 
59
                }
 
60
                catch (Exception e)
 
61
                {
 
62
                        throw new stock.StockException(e.toString());
 
63
                }
 
64
        }
 
65
 
 
66
        /*
 
67
         * This is defined in stock.idl
 
68
         *
 
69
         * It returns the description of a Stock item
 
70
         */
 
71
        public String getDescription() throws stock.StockException
 
72
        {
 
73
                try
 
74
                {
 
75
                        return db.getDescription();
 
76
                }
 
77
                catch (Exception e)
 
78
                {
 
79
                        throw new stock.StockException(e.toString());
 
80
                }
 
81
        }
 
82
 
 
83
        /*
 
84
         * This is defined in stock.idl
 
85
         *
 
86
         * It returns the description of a Stock item
 
87
         */
 
88
        public int getAvailable() throws stock.StockException
 
89
        {
 
90
                try
 
91
                {
 
92
                        return db.getAvailable();
 
93
                }
 
94
                catch (Exception e)
 
95
                {
 
96
                        throw new stock.StockException(e.toString());
 
97
                }
 
98
        }
 
99
 
 
100
        /*
 
101
         * This is defined in stock.idl
 
102
         *
 
103
         * It returns the description of a Stock item
 
104
         */
 
105
        public int getOrdered() throws stock.StockException
 
106
        {
 
107
                try
 
108
                {
 
109
                        return db.getOrdered();
 
110
                }
 
111
                catch (Exception e)
 
112
                {
 
113
                        throw new stock.StockException(e.toString());
 
114
                }
 
115
        }
 
116
 
 
117
        /*
 
118
         * This is defined in stock.idl
 
119
         *
 
120
         * It returns the description of a Stock item
 
121
         */
 
122
        public boolean isItemValid() throws stock.StockException
 
123
        {
 
124
                try
 
125
                {
 
126
                        return db.isItemValid();
 
127
                }
 
128
                catch (Exception e)
 
129
                {
 
130
                        throw new stock.StockException(e.toString());
 
131
                }
 
132
        }
 
133
 
 
134
        /*
 
135
         * This is defined in stock.idl
 
136
         *
 
137
         * It returns the description of a Stock item
 
138
         */
 
139
        public void addNewStock(int id) throws stock.StockException
 
140
        {
 
141
                try
 
142
                {
 
143
                        db.addNewStock(id);
 
144
                }
 
145
                catch (Exception e)
 
146
                {
 
147
                        throw new stock.StockException(e.toString());
 
148
                }
 
149
        }
 
150
 
 
151
        /*
 
152
         * This is defined in stock.idl
 
153
         *
 
154
         * It returns the description of a Stock item
 
155
         */
 
156
        public void removeStock(int id) throws stock.StockException
 
157
        {
 
158
                try
 
159
                {
 
160
                        db.removeStock(id);
 
161
                }
 
162
                catch (Exception e)
 
163
                {
 
164
                        throw new stock.StockException(e.toString());
 
165
                }
 
166
        }
 
167
 
 
168
        /*
 
169
         * This is defined in stock.idl
 
170
         *
 
171
         * It returns the description of a Stock item
 
172
         */
 
173
        public void orderStock(int id) throws stock.StockException
 
174
        {
 
175
                try
 
176
                {
 
177
                        db.orderStock(id);
 
178
                }
 
179
                catch (Exception e)
 
180
                {
 
181
                        throw new stock.StockException(e.toString());
 
182
                }
 
183
        }
 
184
 
 
185
        /*
 
186
         * This returns the highest id used, hence the number of items available
 
187
         */
 
188
        public int getLastID() throws stock.StockException
 
189
        {
 
190
                try
 
191
                {
 
192
                        return db.getLastID();
 
193
                }
 
194
                catch (Exception e)
 
195
                {
 
196
                        throw new stock.StockException(e.toString());
 
197
                }
 
198
        }
 
199
 
 
200
        /*
 
201
         * This is used by our Dispenser
 
202
         */
 
203
        public String getInstanceName()
 
204
        {
 
205
                return instanceName;
 
206
        }
 
207
}
 
208