activation.idl revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#include "Interceptors.idl"
27
28module PortableActivationIDL {
29    /** Possible values for endpointType argument on Server.getEndpoint()
30    * If you change the value of this constant then update
31    * core.EndPoint accordingly.  It has a duplicate definition
32    * to avoid a compilation dependency.
33    */
34    const string IIOP_CLEAR_TEXT = "IIOP_CLEAR_TEXT";
35
36    /** Raised if getEndpoint is called on a server callback object for
37    * an invalid endpoint type
38    */
39    exception NoSuchEndPoint {} ;
40
41    /** Raised if an attempt is made to retrieve ports corresponding to
42    * non-registered ORB
43    */
44    exception InvalidORBid {} ;
45
46    /** Raised if an operation is attempted against an invalid server ID.
47    */
48    exception ServerNotRegistered {
49	PortableInterceptor::ServerId serverId ;
50    };
51
52    /** Raised if an operation is attempted for a server that is not running,
53    * and the server is required to be running for the operation.
54    */
55    exception ServerNotActive {
56	PortableInterceptor::ServerId serverId ;
57    };
58
59    /** Raised if an operation is attempted against a server that is in a 
60    * hold down state.  A server becomes held down if it fails to activate
61    * within 10 seconds.
62    */
63    exception ServerHeldDown {
64	PortableInterceptor::ServerId serverId ;
65    };
66
67    /** Raised if an attempt is made to activate a server that is already 
68    * running.
69    */
70    exception ServerAlreadyActive{
71	PortableInterceptor::ServerId serverId ;
72    };
73
74    /** Raised if an attempt is made to register a serverdef with the
75    * same applicationName as an existing serverdef.
76    */
77    exception ServerAlreadyRegistered {
78	PortableInterceptor::ServerId serverId;
79    };
80
81    /** Raised if an attempt is made to install a server that is currently 
82    * installed.  Note that a newly created server starts out in an uninstalled
83    * state.
84    */
85    exception ServerAlreadyInstalled {
86	PortableInterceptor::ServerId serverId;
87    } ;
88
89    /** Raised if an attempt is made to uninstall a server that is currently 
90    * uninstalled.  Note that a newly created server starts out in an 
91    * uninstalled
92    * state.
93    */
94    exception ServerAlreadyUninstalled {
95	PortableInterceptor::ServerId serverId;
96    } ;
97
98    /** Raised if an attempt is made to register an invalid serverdef.
99    */
100    exception BadServerDefinition {
101	string reason;
102    };
103
104    /** Raised if an attempt is made to register endpoints for the
105     * same ORB again
106     */
107    exception ORBAlreadyRegistered {
108	PortableInterceptor::ORBId orbId;
109    };
110
111    /** Type of TCP port number, used in structures that describe 
112    * transport endpoints.  The valid range is actually 0-65535, but
113    * we use a long here to avoid signed/unsigned conversion headaches
114    * in Java.
115    */
116    typedef long TCPPort ;
117
118    /** Sequence of server Ids, used for queries about servers.
119    */
120    typedef sequence<PortableInterceptor::ServerId> ServerIds;
121
122    /** End point information for one particular kind of port associated with an 
123    * an ORB.  This is only used in the
124    * Activator interface, which must always run on the same host as the daemon,
125    * therefore we do not need the host name here.
126    */
127    struct EndPointInfo {
128	string endpointType;
129	TCPPort port;
130    };
131
132    /** A list of endpoint information for a particular ORB.  
133    */
134    typedef sequence<EndPointInfo> EndpointInfoList;
135
136    /** struct contain ORB and port info for a particular type of endpoint.
137    * This is only used in the
138    * Activator interface, which must always run on the same host as the daemon,
139    * therefore we do not need the host name here.
140    */
141    struct ORBPortInfo {
142	PortableInterceptor::ORBId orbId;
143	TCPPort port;
144    };
145
146    /** A list of ORB and port information for a particular endpoint type.
147    */
148    typedef sequence<ORBPortInfo> ORBPortInfoList;
149
150    /** A list of ORB IDs.
151    */
152    typedef sequence<PortableInterceptor::ORBId> ORBidList;
153
154    /** Server callback interface, passed to Activator in registerServer method.
155    */
156    interface ServerProxy {
157	/** Shutdown this server.  Returns after orb.shutdown() completes.
158	*/
159	void shutdown();
160
161	/** Install the server.  Returns after the install hook completes
162	* execution in the server.
163	*/
164	void install();
165
166	/** Uninstall the server.  Returns after the uninstall hook
167	* completes execution.
168	*/
169	void uninstall();
170    };
171
172    /** ORB callback interface, passed to Activator in registerORB method.
173    */
174    interface ORBProxy {
175	/** Method used to cause ORB to activate the named adapter, if possible.
176	* This will cause the named POA to register itself with the activator as
177	* a side effect.  This should always happen before this call can complete.
178	* This method returns true if adapter activation succeeded, otherwise it
179	* returns false.
180	*/
181	boolean activate_adapter( in PortableInterceptor::AdapterName name ) ;
182    } ;
183    
184    interface Activator {
185	/*******************************************************
186	*		    Server State Change Methods
187	********************************************************/
188
189    	/** A new ORB started server registers itself with the Activator
190	*/
191    	void registerServer(in PortableInterceptor::ServerId serverId, in ServerProxy serverObj) 
192	    raises (ServerNotRegistered);
193
194	/** A server is shutting down that was started by this activator.
195	* Complete termination of the server is detected by the death of the
196	* process implementing the server.
197	*/
198	void serverGoingDown( in PortableInterceptor::ServerId serverId ) ;
199
200	/** Called whenever an ORB instance is created.  This registers
201	* the transport endpoints and the ORB proxy callback object.
202	* Note that we cannot detect when an ORB shuts down, although
203	* all of the POA shutdowns should still be reported.
204	*/
205	void registerORB( in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId, 
206	    in ORBProxy orb, in EndpointInfoList endPointInfo) 
207	    raises (ServerNotRegistered,NoSuchEndPoint, ORBAlreadyRegistered) ;
208
209	/** Construct or find an ORBD object template corresponding to the 
210	* server's object template and return it.  Called whenever a 
211	* persistent POA is created.
212	*/
213	PortableInterceptor::ObjectReferenceTemplate registerPOA( 
214	    in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId, 
215	    in PortableInterceptor::ObjectReferenceTemplate poaTemplate ) ;
216 
217	/** Called whenever a POA is destroyed.
218	*/
219	void poaDestroyed( 
220	    in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId, 
221	    in PortableInterceptor::ObjectReferenceTemplate poaTemplate ) ;       
222
223	/*******************************************************
224	*		    Server Control Methods
225	********************************************************/
226
227	/** If the server is not running, start it up.  This is allowed
228	* whether or not the server has been installed.
229	*/
230	void activate(in PortableInterceptor::ServerId serverId) 
231	    raises (ServerAlreadyActive, ServerNotRegistered, ServerHeldDown);
232
233	/** If the server is running, shut it down
234	*/
235	void shutdown(in PortableInterceptor::ServerId serverId) 
236	    raises (ServerNotActive, ServerNotRegistered);
237
238	/** Invoke the server install hook.  If the server is not 
239	* currently running, this method will activate it.
240	*/
241	void install(in PortableInterceptor::ServerId serverId) 
242	    raises (ServerNotRegistered, ServerHeldDown, 
243		ServerAlreadyInstalled);
244
245	/** Invoke the server uninstall hook.  If the server is not
246	* currently running, this method will activate it.
247	* After this hook completes, the server may still be running.
248	*/
249	void uninstall(in PortableInterceptor::ServerId serverId) 
250	    raises (ServerNotRegistered, ServerHeldDown, 
251		ServerAlreadyUninstalled);
252
253	/*******************************************************
254	*		    Accessors
255	********************************************************/
256
257	/** list active servers
258	*/
259	ServerIds getActiveServers();
260
261	/** list all registered ORBs for a server
262	*/
263	ORBidList getORBNames(in PortableInterceptor::ServerId serverId)
264	    raises (ServerNotRegistered);
265
266	/** Find the server template that corresponds to the ORBD's
267	* adapter id.
268	*/
269	PortableInterceptor::ObjectReferenceTemplate lookupPOATemplate( 
270	    in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId, 
271	    in PortableInterceptor::AdapterName orbAdapterName ) ;
272    };
273
274    interface Locator {
275	/** struct to return the list of endpoints for a server for a specific
276	* endpoint type.  
277	*/
278	struct ServerLocationPerType {
279	    string hostname;
280	    ORBPortInfoList ports;
281        };
282
283	/** struct to return the list of endpoints for a server for a specific
284	* ORB
285	*/
286	struct ServerLocationPerORB {
287	    string hostname;
288	    EndpointInfoList ports;
289        };
290
291	/** locate server - returns the port with a specific type for all registered
292	* ORBs of an active server.
293	* Starts the server if it is not already running.
294	*/
295	ServerLocationPerType locateServer(
296	    in PortableInterceptor::ServerId serverId,
297	    in string endPoint) 
298	    raises(NoSuchEndPoint, ServerNotRegistered, ServerHeldDown);
299
300	/** locate server - returns all ports registered with a specified ORB for
301	* an active server
302	* Starts the server if it is not already running.
303	*/
304	ServerLocationPerORB locateServerForORB(
305	    in PortableInterceptor::ServerId serverId,
306	    in PortableInterceptor::ORBId orbId) 
307	    raises(InvalidORBid, ServerNotRegistered, ServerHeldDown);
308
309	/** get the port for the endpoint of the locator
310	*/
311	TCPPort getEndpoint(in string endPointType)
312	    raises(NoSuchEndPoint);
313
314	/** Useful from external BadServerIdHandlers which need
315	* to pick a particular port type.
316	*/
317	TCPPort getServerPortForType(
318            in ServerLocationPerORB location,
319	    in string endPointType)
320	    raises(NoSuchEndPoint);
321    };
322
323    /** Interface used to combine the Activator and Locator when both are
324    * implemented together in the same process, as is currently the case
325    * for our implementation.
326    */
327    interface ServerManager : Activator, Locator { };
328
329    /** Interface used to support binding references in the bootstrap name
330    * service.
331    */
332    interface InitialNameService {
333	exception NameAlreadyBound {};
334
335	/** bind initial name
336	*/
337	void bind (
338	    in string name,
339	    in Object obj,
340	    in boolean isPersistant) raises (NameAlreadyBound);
341    };
342
343    interface Repository {
344	/** server program definition.  
345	*/
346	struct ServerDef {
347	    string  applicationName;	// alias used for servers with identical
348					// serverName values.
349	    string  serverName;		// Class name of server's main class.
350	    string  serverClassPath;	// class path used to run the server.
351	    string  serverArgs;		// arguments passed to the server
352	    string  serverVmArgs;	// arguments passed to the server's Java VM1
353	    boolean isInstalled;	// Whether or not the server has been installed
354	};
355	
356	/** register server definition.
357	* This returns the serverId of the server.  A newly created server is
358	* always uninstalled.
359	*/
360	PortableInterceptor::ServerId registerServer (in ServerDef serverDef) 
361	    raises (ServerAlreadyRegistered, BadServerDefinition);
362	
363	/** unregister server definition
364	*/
365	void unregisterServer (in PortableInterceptor::ServerId serverId) 
366	    raises (ServerNotRegistered);
367
368	/** get server definition
369	*/
370	ServerDef getServer(in PortableInterceptor::ServerId serverId) 
371	    raises (ServerNotRegistered);
372
373	/** Return whether the server has been installed
374	*/
375	boolean isInstalled( in PortableInterceptor::ServerId serverId ) 
376	    raises (ServerNotRegistered);
377
378	/** Mark the server as being installed.  Raises ServerAlreadyInstalled
379	* if the server is currently marked as installed.
380	*/
381	void install( in PortableInterceptor::ServerId serverId ) 
382	    raises (ServerNotRegistered, ServerAlreadyInstalled) ;
383
384	/** Mark the server as being uninstalled.  Raises ServerAlreadyUninstalled
385	* if the server is currently marked as uninstalled.
386	*/
387	void uninstall( in PortableInterceptor::ServerId serverId ) 
388	    raises (ServerNotRegistered, ServerAlreadyUninstalled) ;
389
390	/** list registered servers
391	*/
392	ServerIds listRegisteredServers ();
393
394	/** Type used for a list of application names
395	*/
396	typedef sequence<string>    AppNames ;
397
398	/** Returns list of ALL applicationNames defined in ServerDefs of registered 
399	* servers.
400	*/
401	AppNames   getApplicationNames();
402
403	/** Find the ServerID associated with the given application name.
404	*/
405	PortableInterceptor::ServerId getServerID( in string applicationName ) 
406		raises (ServerNotRegistered) ;
407    };
408};
409