KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > runtime > ServiceImpl


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@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): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.ccm.runtime;
31
32 import org.objectweb.corba.runtime.*;
33
34 /**
35  ** <p>Default implementation of the <tt>Service</tt> OMG IDL interface.</p>
36  **/

37 public class ServiceImpl
38 extends org.omg.CORBA.LocalObject JavaDoc
39 implements Service
40 {
41     // service
42
private String JavaDoc _service_id;
43     private String JavaDoc _impl_uuid;
44     private CORBAServiceRef _corba_service_ref;
45     private java.util.Hashtable JavaDoc _internals;
46     private java.util.Hashtable JavaDoc _policy_factories;
47     private String JavaDoc _orb_init;
48     private org.coach.ECA.CallControllerFactory _controller_factory;
49     private org.coach.ECA.ServiceInitializer _service_initializer;
50     private CallControllerInitInfoImpl _controller_iinfo;
51
52     // default constructor
53
public
54     ServiceImpl(String JavaDoc sid, String JavaDoc uuid)
55     {
56         _service_id = sid;
57         _impl_uuid = uuid;
58         _corba_service_ref = null;
59         _internals = new java.util.Hashtable JavaDoc();
60         _policy_factories = new java.util.Hashtable JavaDoc();
61         _orb_init = null;
62         _controller_factory = null;
63
64         _controller_iinfo = null;
65     }
66
67     //
68
// internal state getter/setter
69
//
70

71     private CallControllerInitInfoImpl
72     getControllerIInfo()
73     {
74         if (_controller_iinfo==null) {
75             // create call controller init info
76
_controller_iinfo = new CallControllerInitInfoImpl();
77             // set slot factory
78
// not mandatory (=> use singleton factory)
79
}
80
81         return _controller_iinfo;
82     }
83
84     //
85
// IDL:org/objectweb/ccm/runtime/Service:1.0
86
//
87

88     final public String JavaDoc
89     service_id()
90     {
91         return _service_id;
92     }
93
94     final public String JavaDoc
95     implementation_uuid()
96     {
97         return _impl_uuid;
98     }
99
100     final public org.omg.CORBA.Object JavaDoc
101     get_service_internal(String JavaDoc sid)
102     {
103         return (org.omg.CORBA.Object JavaDoc)_internals.get(sid);
104     }
105
106     final public Policy
107     create_policy(String JavaDoc ptype, String JavaDoc pvalue)
108     {
109         // create corba policy
110
org.coach.ECA.PolicyFactory pfact = (org.coach.ECA.PolicyFactory)_policy_factories.get(ptype);
111         org.omg.CORBA.Policy JavaDoc pol = pfact.create_policy(ptype, pvalue);
112
113         // create new Policy
114
PolicyImpl policy = new PolicyImpl(this, pol);
115
116         // store ?
117

118         //
119
return policy;
120     }
121
122     //
123
// public operations
124
//
125

126     final public CORBAServiceRef
127     getCorbaServiceRef()
128     {
129         return _corba_service_ref;
130     }
131
132     final public void
133     setCorbaServiceRef(CORBAServiceRef csref)
134     {
135         _corba_service_ref = csref;
136     }
137
138     final public org.coach.ECA.ServiceInitializer
139     getServiceInitializer()
140     {
141         return _service_initializer;
142     }
143
144     final public void
145     setServiceInitializer(org.coach.ECA.ServiceInitializer sinit)
146     {
147         _service_initializer = sinit;
148     }
149
150     final public void
151     addServiceInternal(String JavaDoc sid, org.omg.CORBA.Object JavaDoc internal)
152     {
153         _internals.put(sid, internal);
154     }
155
156     final public void
157     addPolicyFactory(String JavaDoc ptype, org.coach.ECA.PolicyFactory fact)
158     {
159         _policy_factories.put(ptype, fact);
160     }
161
162     final public String JavaDoc
163     getORBInitializer()
164     {
165         return _orb_init;
166     }
167
168     final public void
169     setORBInitializer(String JavaDoc orbinit)
170     {
171         _orb_init = orbinit;
172     }
173
174     final public void
175     setCallControllerFactory(org.coach.ECA.CallControllerFactory fact)
176     {
177         _controller_factory = fact;
178     }
179
180     final public org.coach.ECA.CallController
181     createCallController(Policy pol)
182     {
183         return _controller_factory.create_call_controller(pol.corba_policy(), getControllerIInfo());
184     }
185 }
186
Popular Tags