Rev 1312 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | fvelez | 1 | /* |
2 | BERSERK - a BusinEss Runtime and SEcurity Resources Kit |
||
3 | Copyright (C) 2003 Goncalo Luiz |
||
4 | |||
5 | This library is free software; you can redistribute it and/or |
||
6 | modify it under the terms of the GNU Lesser General Public |
||
7 | License as published by the Free Software Foundation; either |
||
8 | version 2.1 of the License, or (at your option) any later version. |
||
9 | |||
10 | This library is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
13 | Lesser General Public License for more details. |
||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public |
||
16 | License along with this library; if not, write to the Free Software |
||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | |||
19 | To contact Goncalo Luiz use the following e-mail address (use an @ instead of the _): |
||
20 | gedl_mega.ist.utl.pt |
||
21 | */ |
||
22 | package pt.utl.ist.berserk.logic.serviceManager; |
||
23 | import pt.utl.ist.berserk.ServiceRequest; |
||
24 | import pt.utl.ist.berserk.ServiceResponse; |
||
25 | import pt.utl.ist.berserk.logic.filterManager.FilteringResult; |
||
26 | import pt.utl.ist.berserk.logic.filterManager.IFilterBroker; |
||
27 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.ExecutedFilterException; |
||
28 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.FilterChainFailedException; |
||
29 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.ServiceManagerException; |
||
1312 | jmachado | 30 | |
1603 | jmachado | 31 | |
1 | fvelez | 32 | /** |
33 | * The ServiceInvoker subclass that simply invokes the services |
||
34 | * without adding any special functionality. |
||
35 | * |
||
36 | * @author Joao Pereira |
||
37 | * @version revision by Goncalo Luiz (gedl \AT/ rnl \DOT/ ist \DOT/ utl \DOT/ pt) at June the 15th, 2004 |
||
38 | **/ |
||
39 | public class SimpleServiceInvoker extends ServiceInvoker |
||
40 | { |
||
41 | public final static SimpleServiceInvoker invocador = new SimpleServiceInvoker(); |
||
42 | public final 5+0%2Fdocs%2Fapi+Object">Object invoke( |
||
43 | 5+0%2Fdocs%2Fapi+Object">Object requester, |
||
44 | IService service, |
||
45 | 1.5.0/docs/api/java/lang/String.html">String methodName, |
||
46 | 5+0%2Fdocs%2Fapi+Object">Object[] arguments, |
||
47 | 1.5.0/docs/api/java/lang/String.html">String[] names, |
||
48 | IFilterBroker broker) |
||
49 | throws ServiceManagerException,1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
50 | { |
||
51 | ServiceRequest request = new ServiceRequest (requester,arguments,names,service,methodName); |
||
52 | ServiceResponse response = new ServiceResponse(); |
||
53 | boolean passedPre = false; |
||
54 | boolean passedPost = false; |
||
55 | FilteringResult filteringResult=null; |
||
56 | try |
||
57 | { |
||
58 | filteringResult = broker.executePreFiltering(request, response); |
||
59 | passedPre = filteringResult.isSuccess(); |
||
60 | } |
||
61 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
||
62 | { |
||
63 | throw new ExecutedFilterException( |
||
64 | "a not 'FilterException' exception occured while executing pre filter chain", |
||
65 | e); |
||
66 | } |
||
67 | if (passedPre) |
||
68 | //the thown exceptions will go up |
||
69 | response.setReturnObject(doInvocation(request.getService(), methodName, request.getArguments())); |
||
70 | else |
||
71 | throw new FilterChainFailedException( |
||
72 | "failed to execute preFiltering on service" + service.getClass(),filteringResult); |
||
73 | try |
||
74 | { |
||
75 | filteringResult = broker.executePostFiltering(request, response); |
||
76 | passedPost = filteringResult.isSuccess(); |
||
77 | } |
||
78 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
||
79 | { |
||
80 | throw new ExecutedFilterException( |
||
81 | "a not 'FilterException' exception occured while executing post filter chain", |
||
82 | e); |
||
83 | } |
||
84 | if (passedPost) |
||
85 | { |
||
86 | // the sucessfull case |
||
87 | return response.getReturnObject(); |
||
88 | } |
||
89 | else |
||
90 | throw new FilterChainFailedException( |
||
91 | "failed to execute postFiltering on service" + service.getClass(),filteringResult); |
||
92 | } |
||
1312 | jmachado | 93 | |
94 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
95 | public 5+0%2Fdocs%2Fapi+Object">Object checkFilters(5+0%2Fdocs%2Fapi+Object">Object requester, IService service, 1.5.0/docs/api/java/lang/String.html">String methodName, 5+0%2Fdocs%2Fapi+Object">Object[] arguments, 1.5.0/docs/api/java/lang/String.html">String[] names, IFilterBroker filterBroker) throws ServiceManagerException, 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
1603 | jmachado | 96 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("NotImplemented"); |
1312 | jmachado | 97 | } |
1 | fvelez | 98 | } |