KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > corba > TheTradingService


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Sylvain Leblanc.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.corba;
28
29 /**
30  * This class encapsulates the CORBA::CosTrading trader singleton object.
31  *
32  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
33  *
34  * @version 0.1
35  */

36
37 public abstract class TheTradingService
38 {
39     // ==================================================================
40
//
41
// Internal state.
42
//
43
// ==================================================================
44

45     /**
46      * To store the CosTrading::Lookup singleton object.
47      */

48     private static org.omg.CosTrading.Lookup trader_ = null;
49
50     /**
51      * To store the CosTradingRepos::ServiceTypeRepository singleton object.
52      */

53     private static org.omg.CosTradingRepos.ServiceTypeRepository repos_ = null;
54
55     // ==================================================================
56
//
57
// Constructor.
58
//
59
// ==================================================================
60

61     /**
62      ** The default constructor.
63      **/

64     private
65     TheTradingService()
66     {
67     }
68
69     // ==================================================================
70
//
71
// Internal methods.
72
//
73
// ==================================================================
74

75     // ==================================================================
76
//
77
// Public methods.
78
//
79
// ==================================================================
80

81     /**
82      * Obtain the CosTrading::Lookup singleton object.
83      *
84      * @return The CosTrading::Lookup singleton object.
85      */

86     public static org.omg.CosTrading.Lookup
87     getLookup()
88     {
89         if(trader_ == null)
90         {
91             org.omg.CORBA.Object JavaDoc trader_ref = null;
92             try {
93                 trader_ref = TheORB.getORB().resolve_initial_references("TradingService");
94             } catch (org.omg.CORBA.ORBPackage.InvalidName JavaDoc ex) {
95                 // Trading service init ref has not been set.
96
return null;
97             }
98             setTrader(org.omg.CosTrading.LookupHelper.narrow(trader_ref));
99         }
100         return trader_;
101     }
102
103     /**
104      * Obtain the CosTrading::Register singleton object.
105      *
106      * @return The CosTrading::Register singleton object.
107      */

108     public static org.omg.CosTrading.Register
109     getRegister()
110     {
111         if (getLookup() == null) return null;
112         return getLookup().register_if();
113     }
114
115     /**
116      * Obtain the CosTrading::Register singleton object.
117      *
118      * @return The CosTrading::Register singleton object.
119      */

120     public static org.omg.CosTradingRepos.ServiceTypeRepository
121     getRepository()
122     {
123         if(repos_ == null)
124         {
125             getLookup();
126         }
127         return repos_;
128     }
129
130     /**
131      * Set the CORBA::Repository singleton object.
132      *
133      * @param repository The CORBA::Repository singleton object.
134      */

135     public static void
136     setTrader(org.omg.CosTrading.Lookup trader)
137     {
138         trader_ = trader;
139
140         org.omg.CORBA.Object JavaDoc to_narrow = trader_.admin_if().type_repos();
141         repos_ = org.omg.CosTradingRepos.ServiceTypeRepositoryHelper.narrow(to_narrow);
142     }
143
144 }
145
Popular Tags