RegistrationManager.cpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 
39 #include "RegistrationManager.hpp"
40 #include "ServiceMessage.hpp"
41 #include "ServiceException.hpp"
42 
43 
44 /**
45  * It will remove all the registration entries for a specific process
46  *
47  * @param session The session identifier.
48  */
50 {
51  // delete all of the entries associated with this process.
53  exits.freeProcessEntries(session);
55 }
56 
57 
58 /**
59  * Dispatch a registration operation to the appropriate
60  * subsystem handler.
61  *
62  * @param message The inbound message.
63  */
65 {
66  RegistrationTable *table = NULL;
67  switch ((RegistrationType)message.parameter1)
68  {
69  case FunctionAPI:
70  table = &functions;
71  break;
72  case ExitAPI:
73  table = &exits;
74  break;
75  case SubcomAPI:
76  table = &commandHandlers;
77  break;
78  default:
79  message.setExceptionInfo(SERVER_FAILURE, "Invalid registration type");
80  return;
81  }
82 
83 
84  // now that we have the appropriate subsystem targetted, dispatch the
85  // real operation.
86  switch (message.operation)
87  {
88  // registration manager operations
89  case REGISTER_LIBRARY:
90  table->registerLibraryCallback(message);
91  break;
93  table->registerCallback(message);
94  break;
95  case REGISTER_DROP:
96  table->dropCallback(message);
97  break;
99  table->dropLibraryCallback(message);
100  break;
101  case REGISTER_QUERY:
102  table->queryCallback(message);
103  break;
105  table->queryLibraryCallback(message);
106  break;
108  table->queryCallback(message);
109  break;
110  case UPDATE_CALLBACK:
111  table->updateCallback(message);
112  break;
113 
114  default:
115  message.setExceptionInfo(SERVER_FAILURE, "Invalid registration manager operation");
116  // make sure the data message buffer is not passed back.
117  message.freeMessageData();
118  break;
119  }
120 }
121 
122 
123 /**
124  * Perform any cleanup of process-specific resources
125  * when the process terminates.
126  *
127  * @param session The session id of the session going away.
128  */
130 {
131  // just free up any registrations associated with this
132  // session.
133  freeProcessRegistrations(session);
134 }
@ SERVER_FAILURE
RegistrationType
@ ExitAPI
@ SubcomAPI
@ FunctionAPI
uintptr_t SessionID
@ REGISTER_LOAD_LIBRARY
@ REGISTER_QUERY_LIBRARY
@ REGISTER_DROP_LIBRARY
@ REGISTER_ENTRYPOINT
@ REGISTER_DROP
@ REGISTER_LIBRARY
@ REGISTER_QUERY
@ UPDATE_CALLBACK
void queryLibraryCallback(ServiceMessage &message)
void updateCallback(ServiceMessage &message)
void queryCallback(ServiceMessage &message)
void freeProcessEntries(SessionID session)
void registerLibraryCallback(ServiceMessage &message)
void registerCallback(ServiceMessage &message)
void dropLibraryCallback(ServiceMessage &message)
void dropCallback(ServiceMessage &message)
void dispatch(ServiceMessage &message)
void cleanupProcessResources(SessionID session)
void freeProcessRegistrations(SessionID session)
void setExceptionInfo(ErrorCode error, const char *message)
ServerOperation operation
uintptr_t parameter1