ffead.server.doc
Component.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * Component.h
18  *
19  * Created on: Jan 29, 2010
20  * Author: sumeet
21  */
22 
23 #ifndef COMPONENT_H_
24 #define COMPONENT_H_
25 #include "string"
26 #include "Message.h"
27 #include "ConnectionSettings.h"
28 #include "Cibernate.h"
29 using namespace std;
31 private:
32  string classn;
33  string methName;
34  string retType;
35  string address;
36  vector<string> allwugList;
37  vector<string> blkdugList;
38  vector<string> allwList;
39  vector<string> blkdList;
40 public:
42  virtual ~ComponentService(){}
43  friend class ComponentGen;
44 };
45 class Component {
46  void* invokeServiceInternal(string serviceName,vector<void*> args);
47  string name;
48  string desc;
49  bool ajaxAvail;
50  bool websAvail;
51  bool methinvAvail;
52  bool autoTranx;
53  bool thrdPerReq;
54  int thrdPoolSize;
55  int dbconpoolSize;
56  string authFrom;
57  ConnectionSettings authDets;
58  bool authMode;
59  vector<string> protocols;
60  vector<string> allwList;
61  vector<string> blkdList;
62  bool session;
63  map<string,ComponentService> services;
64  Cibernate *chib;
65 public:
66  Component(string name,string desc,bool ajav,bool wsav,bool miav,bool autotx,bool thrdpr,int thrdpsiz,int dbcps,string authfr,ConnectionSettings authdet,string authmod,
67  vector<string> protocol,vector<string> alwls,vector<string> blkls,bool sess,map<string,ComponentService> service){}
68  Component();
69  virtual ~Component();
70  void init();
71  void destroy();
72  bool isAvaibleForMI(bool);//is available for method invocation
73  bool isWebService(bool);//is exposed as a web service
74  bool isAJAXAvailable(bool);//is avaiable to javascript as a service
75  //Synchronize all required methods for concurrency control
76 
77  //Database and Trnsaction related functions
78  Connection getReadConnection();
79  Connection getWriteConnection();
80  void closeConnection();
81  void startTransaction();
82  void endTransaction();
83  void commit();
84  void rollback();
85  void execute();
86  Cibernate* getCibernate();
87 
88  //Security, Authentication and Authorization functions
89  bool setMode(string mode);//ldap|database|filesystem
90  void setDetails();//Details about the file/db or ldap connecn and parameters ConnectionSettings
91  bool isAuthorizedTo();//Task
92  bool allowAccess();
93  bool isAccesAllowed();
94 
95  //Messaging services
96  void setMode(bool);//true for asynchronous and false for synchronous
97  bool sendMessage(Message);
98  Message readMessage();
99  void registerRemoteEventHandler();
100  void unRegisterRemoteEventHandler();
101 
102  bool calledFromHTTPAJAX();
103  bool calledFromHTTPREQU();
104  bool calledFromHTTPSOAP();
105  bool calledFromMETHINVK();
106  bool calledFromPROGCNTX();
107 
108  void* invokeService(string serviceName,vector<void*> args);
109 
110  string getName() const
111  {
112  return name;
113  }
114 
115  void setName(string name)
116  {
117  this->name = name;
118  }
119 
120  string getDesc() const
121  {
122  return desc;
123  }
124 
125  void setDesc(string desc)
126  {
127  this->desc = desc;
128  }
129 
130  bool getAjaxAvail() const
131  {
132  return ajaxAvail;
133  }
134 
135  void setAjaxAvail(bool ajaxAvail)
136  {
137  this->ajaxAvail = ajaxAvail;
138  }
139 
140  bool getWebsAvail() const
141  {
142  return websAvail;
143  }
144 
145  void setWebsAvail(bool websAvail)
146  {
147  this->websAvail = websAvail;
148  }
149 
150  bool getMethinvAvail() const
151  {
152  return methinvAvail;
153  }
154 
155  void setMethinvAvail(bool methinvAvail)
156  {
157  this->methinvAvail = methinvAvail;
158  }
159 
160  bool getAutoTranx() const
161  {
162  return autoTranx;
163  }
164 
165  void setAutoTranx(bool autoTranx)
166  {
167  this->autoTranx = autoTranx;
168  }
169 
170  bool getThrdPerReq() const
171  {
172  return thrdPerReq;
173  }
174 
175  void setThrdPerReq(bool thrdPerReq)
176  {
177  this->thrdPerReq = thrdPerReq;
178  }
179 
180  int getThrdPoolSize() const
181  {
182  return thrdPoolSize;
183  }
184 
185  void setThrdPoolSize(int thrdPoolSize)
186  {
187  this->thrdPoolSize = thrdPoolSize;
188  }
189 
190  int getDbconpoolSize() const
191  {
192  return dbconpoolSize;
193  }
194 
195  void setDbconpoolSize(int dbconpoolSize)
196  {
197  this->dbconpoolSize = dbconpoolSize;
198  }
199 
200  string getAuthFrom() const
201  {
202  return authFrom;
203  }
204 
205  void setAuthFrom(string authFrom)
206  {
207  this->authFrom = authFrom;
208  }
209 
210  ConnectionSettings getAuthDets() const
211  {
212  return authDets;
213  }
214 
215  void setAuthDets(ConnectionSettings authDets)
216  {
217  this->authDets = authDets;
218  }
219 
220  bool getAuthMode() const
221  {
222  return authMode;
223  }
224 
225  void setAuthMode(bool authMode)
226  {
227  this->authMode = authMode;
228  }
229 
230  vector<string> getProtocols() const
231  {
232  return protocols;
233  }
234 
235  void setProtocols(vector<string> protocols)
236  {
237  this->protocols = protocols;
238  }
239 
240  vector<string> getAllwList() const
241  {
242  return allwList;
243  }
244 
245  void setAllwList(vector<string> allwList)
246  {
247  this->allwList = allwList;
248  }
249 
250  vector<string> getBlkdList() const
251  {
252  return blkdList;
253  }
254 
255  void setBlkdList(vector<string> blkdList)
256  {
257  this->blkdList = blkdList;
258  }
259 
260  bool getSession() const
261  {
262  return session;
263  }
264 
265  void setSession(bool session)
266  {
267  this->session = session;
268  }
269 
270  map<string,ComponentService> getServices() const
271  {
272  return services;
273  }
274 
275  void setServices(map<string,ComponentService> services)
276  {
277  this->services = services;
278  }
279 };
280 
281 #endif /* COMPONENT_H_ */