1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.profiler.impl; |
18 |
|
|
19 |
|
import java.security.Principal; |
20 |
|
import java.util.Collection; |
21 |
|
import java.util.Collections; |
22 |
|
import java.util.HashMap; |
23 |
|
import java.util.Iterator; |
24 |
|
import java.util.Map; |
25 |
|
import java.util.Properties; |
26 |
|
|
27 |
|
import javax.security.auth.Subject; |
28 |
|
|
29 |
|
import org.apache.commons.logging.Log; |
30 |
|
import org.apache.commons.logging.LogFactory; |
31 |
|
import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport; |
32 |
|
import org.apache.jetspeed.profiler.ProfileLocator; |
33 |
|
import org.apache.jetspeed.profiler.Profiler; |
34 |
|
import org.apache.jetspeed.profiler.ProfilerException; |
35 |
|
import org.apache.jetspeed.profiler.rules.PrincipalRule; |
36 |
|
import org.apache.jetspeed.profiler.rules.ProfileResolvers; |
37 |
|
import org.apache.jetspeed.profiler.rules.ProfilingRule; |
38 |
|
import org.apache.jetspeed.profiler.rules.RuleCriterion; |
39 |
|
import org.apache.jetspeed.profiler.rules.impl.AbstractProfilingRule; |
40 |
|
import org.apache.jetspeed.profiler.rules.impl.PrincipalRuleImpl; |
41 |
|
import org.apache.jetspeed.request.RequestContext; |
42 |
|
import org.apache.jetspeed.security.SecurityHelper; |
43 |
|
import org.apache.jetspeed.security.UserPrincipal; |
44 |
|
import org.apache.jetspeed.security.impl.UserPrincipalImpl; |
45 |
|
import org.apache.ojb.broker.query.Criteria; |
46 |
|
import org.apache.ojb.broker.query.QueryFactory; |
47 |
|
import org.springframework.beans.BeansException; |
48 |
|
import org.springframework.beans.factory.BeanFactory; |
49 |
|
import org.springframework.beans.factory.BeanFactoryAware; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
public class JetspeedProfilerImpl extends InitablePersistenceBrokerDaoSupport |
58 |
|
implements Profiler, BeanFactoryAware |
59 |
|
{ |
60 |
|
|
61 |
|
public final static String DEFAULT_RULE = "j1"; |
62 |
|
|
63 |
|
|
64 |
0 |
protected final static Log log = LogFactory.getLog(JetspeedProfilerImpl.class); |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
0 |
public final static Principal DEFAULT_RULE_PRINCIPAL = new UserPrincipalImpl("*"); |
70 |
|
|
71 |
|
|
72 |
0 |
private String locatorBean = "ProfileLocator"; |
73 |
|
|
74 |
|
|
75 |
|
private Class prRuleClass; |
76 |
|
|
77 |
0 |
private String principalRuleBean = "PrincipalRule"; |
78 |
|
|
79 |
|
|
80 |
0 |
private String profilingRuleStandardBean = "StandardProfilingRule"; |
81 |
|
|
82 |
|
|
83 |
0 |
private String profilingRuleFallbackBean = "RoleFallbackProfilingRule"; |
84 |
|
|
85 |
|
|
86 |
0 |
private Class profilingRuleClass = AbstractProfilingRule.class; |
87 |
|
|
88 |
|
|
89 |
0 |
private String defaultRule = DEFAULT_RULE; |
90 |
|
|
91 |
0 |
private Map principalRules = Collections.synchronizedMap(new HashMap()); |
92 |
|
|
93 |
0 |
private Map rulesPerPrincipal = Collections.synchronizedMap(new HashMap()); |
94 |
|
|
95 |
|
private ProfileResolvers resolvers; |
96 |
|
|
97 |
|
|
98 |
0 |
private String ruleCriterionBean = "RuleCriterion"; |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
private BeanFactory beanFactory; |
104 |
|
|
105 |
|
public JetspeedProfilerImpl(String repositoryPath, |
106 |
|
ProfileResolvers resolvers) |
107 |
|
{ |
108 |
0 |
super(repositoryPath); |
109 |
0 |
this.resolvers = resolvers; |
110 |
0 |
} |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
public JetspeedProfilerImpl(String repositoryPath, String defaultRule, |
128 |
|
ProfileResolvers resolvers) throws ClassNotFoundException |
129 |
|
{ |
130 |
0 |
this(repositoryPath, resolvers); |
131 |
0 |
this.defaultRule = defaultRule; |
132 |
0 |
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
public JetspeedProfilerImpl(String repositoryPath, String defaultRule, |
139 |
|
Properties properties, ProfileResolvers resolvers) |
140 |
|
throws ClassNotFoundException |
141 |
|
{ |
142 |
0 |
this(repositoryPath, defaultRule, resolvers); |
143 |
0 |
initModelClasses(properties); |
144 |
|
|
145 |
0 |
} |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
public JetspeedProfilerImpl(String repositoryPath, String defaultRule, |
151 |
|
ProfileResolvers resolvers, Map ruleConstructors, |
152 |
|
String ruleCriterionBean) throws ClassNotFoundException |
153 |
|
{ |
154 |
0 |
this(repositoryPath, defaultRule, resolvers); |
155 |
0 |
this.ruleCriterionBean = ruleCriterionBean; |
156 |
0 |
initRuleClasses(ruleConstructors); |
157 |
0 |
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
public void setDefaultRule(String defaultRule) |
164 |
|
{ |
165 |
0 |
this.defaultRule = defaultRule; |
166 |
0 |
} |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
private void initModelClasses(Properties properties) |
173 |
|
throws ClassNotFoundException |
174 |
|
{ |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
0 |
} |
187 |
|
|
188 |
|
public ProfileLocator getProfile(RequestContext context, String locatorName) |
189 |
|
throws ProfilerException |
190 |
|
{ |
191 |
|
|
192 |
0 |
Subject subject = context.getSubject(); |
193 |
0 |
if (subject == null) |
194 |
|
{ |
195 |
0 |
String msg = "Invalid (null) Subject in request pipeline"; |
196 |
0 |
log.error(msg); |
197 |
0 |
throw new ProfilerException(msg); |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
0 |
Principal principal = SecurityHelper.getBestPrincipal(subject, |
202 |
|
UserPrincipal.class); |
203 |
0 |
if (principal == null) |
204 |
|
{ |
205 |
0 |
String msg = "Could not find a principle for subject in request pipeline"; |
206 |
0 |
log.error(msg); |
207 |
0 |
throw new ProfilerException(msg); |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
0 |
ProfilingRule rule = getRuleForPrincipal(principal, locatorName); |
212 |
0 |
if (null == rule) |
213 |
|
{ |
214 |
0 |
log.warn("Could not find profiling rule for principal: " |
215 |
|
+ principal); |
216 |
0 |
rule = this.getDefaultRule(); |
217 |
|
} |
218 |
|
|
219 |
0 |
if (null == rule) |
220 |
|
{ |
221 |
0 |
String msg = "Couldn't find any profiling rules including default rule for principal " |
222 |
|
+ principal; |
223 |
0 |
log.error(msg); |
224 |
0 |
throw new ProfilerException(msg); |
225 |
|
} |
226 |
|
|
227 |
0 |
return rule.apply(context, this); |
228 |
|
} |
229 |
|
|
230 |
|
public ProfileLocator getDefaultProfile(RequestContext context, |
231 |
|
String locatorName) throws ProfilerException |
232 |
|
{ |
233 |
|
|
234 |
0 |
ProfilingRule rule = getRuleForPrincipal(DEFAULT_RULE_PRINCIPAL, |
235 |
|
locatorName); |
236 |
0 |
if (null == rule) |
237 |
|
{ |
238 |
0 |
log.warn("Could not find profiling rule for principal: " |
239 |
|
+ DEFAULT_RULE_PRINCIPAL); |
240 |
0 |
rule = this.getDefaultRule(); |
241 |
|
} |
242 |
|
|
243 |
0 |
if (null == rule) |
244 |
|
{ |
245 |
0 |
String msg = "Couldn't find any profiling rules including default rule for principal " |
246 |
|
+ DEFAULT_RULE_PRINCIPAL; |
247 |
0 |
log.error(msg); |
248 |
0 |
throw new ProfilerException(msg); |
249 |
|
} |
250 |
|
|
251 |
0 |
return rule.apply(context, this); |
252 |
|
} |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
public ProfileLocator getProfile(RequestContext context, ProfilingRule rule) |
261 |
|
throws ProfilerException |
262 |
|
{ |
263 |
|
|
264 |
0 |
return rule.apply(context, this); |
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
public ProfilingRule getRuleForPrincipal(Principal principal, |
274 |
|
String locatorName) |
275 |
|
{ |
276 |
0 |
ProfilingRule rule = null; |
277 |
|
|
278 |
0 |
PrincipalRule pr = lookupPrincipalRule(principal.getName(), locatorName); |
279 |
|
|
280 |
|
|
281 |
0 |
if (pr == null) |
282 |
|
{ |
283 |
|
|
284 |
0 |
rule = getRule(locatorName); |
285 |
|
|
286 |
0 |
if (rule == null) |
287 |
|
{ |
288 |
|
|
289 |
0 |
rule = getDefaultRule(); |
290 |
|
} |
291 |
0 |
pr = new PrincipalRuleImpl(); |
292 |
0 |
pr.setLocatorName(locatorName); |
293 |
0 |
pr.setPrincipalName(principal.getName()); |
294 |
0 |
pr.setProfilingRule(rule); |
295 |
0 |
principalRules.put(makePrincipalRuleKey(principal.getName(), |
296 |
|
locatorName), pr); |
297 |
|
} else |
298 |
|
{ |
299 |
|
|
300 |
0 |
rule = pr.getProfilingRule(); |
301 |
|
} |
302 |
|
|
303 |
0 |
return rule; |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
private Class getPrincipalRuleClass() |
312 |
|
{ |
313 |
0 |
if (this.prRuleClass == null) |
314 |
|
{ |
315 |
|
try |
316 |
|
{ |
317 |
0 |
PrincipalRule tempRule = createPrincipalRule(); |
318 |
0 |
this.prRuleClass = tempRule.getClass(); |
319 |
0 |
} catch (Exception e) |
320 |
|
{ |
321 |
0 |
e.printStackTrace(); |
322 |
0 |
} |
323 |
|
} |
324 |
0 |
return this.prRuleClass; |
325 |
|
} |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
public void setRuleForPrincipal(Principal principal, ProfilingRule rule, |
334 |
|
String locatorName) |
335 |
|
{ |
336 |
0 |
Criteria c = new Criteria(); |
337 |
0 |
c.addEqualTo("principalName", principal.getName()); |
338 |
0 |
c.addEqualTo("locatorName", locatorName); |
339 |
0 |
PrincipalRule pr = (PrincipalRule) getPersistenceBrokerTemplate() |
340 |
|
.getObjectByQuery( |
341 |
|
QueryFactory.newQuery(getPrincipalRuleClass(), c)); |
342 |
|
|
343 |
0 |
if (pr == null) |
344 |
|
{ |
345 |
0 |
pr = new PrincipalRuleImpl(); |
346 |
0 |
pr.setPrincipalName(principal.getName()); |
347 |
0 |
pr.setLocatorName(locatorName); |
348 |
0 |
pr.setProfilingRule(rule); |
349 |
|
} |
350 |
0 |
rule.setResolvers(resolvers); |
351 |
0 |
pr.setProfilingRule(rule); |
352 |
0 |
getPersistenceBrokerTemplate().store(pr); |
353 |
0 |
principalRules.put(makePrincipalRuleKey(principal.getName(), |
354 |
|
locatorName), pr); |
355 |
0 |
this.rulesPerPrincipal.remove(principal.getName()); |
356 |
0 |
} |
357 |
|
|
358 |
|
private String makePrincipalRuleKey(String principal, String locator) |
359 |
|
{ |
360 |
0 |
return principal + ":" + locator; |
361 |
|
} |
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
private PrincipalRule lookupPrincipalRule(String principal, |
372 |
|
String locatorName) |
373 |
|
{ |
374 |
0 |
PrincipalRule pr = (PrincipalRule) principalRules |
375 |
|
.get(makePrincipalRuleKey(principal, locatorName)); |
376 |
0 |
if (pr != null) { return pr; } |
377 |
0 |
Criteria c = new Criteria(); |
378 |
0 |
c.addEqualTo("principalName", principal); |
379 |
0 |
c.addEqualTo("locatorName", locatorName); |
380 |
|
|
381 |
0 |
pr = (PrincipalRule) getPersistenceBrokerTemplate().getObjectByQuery( |
382 |
|
QueryFactory.newQuery(getPrincipalRuleClass(), c)); |
383 |
|
|
384 |
0 |
principalRules.put(makePrincipalRuleKey(principal, locatorName), pr); |
385 |
0 |
if (pr != null) pr.getProfilingRule().setResolvers(resolvers); |
386 |
0 |
return pr; |
387 |
|
} |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
public ProfilingRule getDefaultRule() |
395 |
|
{ |
396 |
0 |
return getRule(this.defaultRule); |
397 |
|
} |
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
public Collection getRules() |
405 |
|
{ |
406 |
0 |
Collection rules = getPersistenceBrokerTemplate().getCollectionByQuery( |
407 |
|
QueryFactory.newQuery(profilingRuleClass, new Criteria())); |
408 |
0 |
Iterator r = rules.iterator(); |
409 |
0 |
while (r.hasNext()) |
410 |
|
{ |
411 |
0 |
ProfilingRule rule = (ProfilingRule) r.next(); |
412 |
0 |
rule.setResolvers(resolvers); |
413 |
0 |
} |
414 |
0 |
return rules; |
415 |
|
} |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
public ProfilingRule getRule(String id) |
423 |
|
{ |
424 |
0 |
Criteria c = new Criteria(); |
425 |
0 |
c.addEqualTo("id", id); |
426 |
|
|
427 |
0 |
ProfilingRule rule = (ProfilingRule) getPersistenceBrokerTemplate() |
428 |
|
.getObjectByQuery(QueryFactory.newQuery(profilingRuleClass, c)); |
429 |
0 |
if (rule != null) |
430 |
|
{ |
431 |
0 |
rule.setResolvers(resolvers); |
432 |
|
} |
433 |
0 |
return rule; |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
public String[] getLocatorNamesForPrincipal(Principal principal) |
442 |
|
{ |
443 |
0 |
Criteria c = new Criteria(); |
444 |
0 |
c.addEqualTo("principalName", principal.getName()); |
445 |
|
|
446 |
0 |
Collection result = getPersistenceBrokerTemplate() |
447 |
|
.getCollectionByQuery( |
448 |
|
QueryFactory.newQuery(getPrincipalRuleClass(), c)); |
449 |
0 |
if (result.size() == 0) { return new String[] |
450 |
|
{}; } |
451 |
0 |
String[] names = new String[result.size()]; |
452 |
0 |
Iterator it = result.iterator(); |
453 |
0 |
int ix = 0; |
454 |
0 |
while (it.hasNext()) |
455 |
|
{ |
456 |
0 |
PrincipalRule pr = (PrincipalRule) it.next(); |
457 |
0 |
names[ix] = pr.getLocatorName(); |
458 |
0 |
pr.getProfilingRule().setResolvers(resolvers); |
459 |
0 |
ix++; |
460 |
0 |
} |
461 |
0 |
return names; |
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
|
469 |
|
public Collection getRulesForPrincipal(Principal principal) |
470 |
|
{ |
471 |
|
|
472 |
0 |
Collection rules = (Collection) this.rulesPerPrincipal.get(principal |
473 |
|
.getName()); |
474 |
0 |
if (rules != null) return rules; |
475 |
0 |
Criteria c = new Criteria(); |
476 |
0 |
c.addEqualTo("principalName", principal.getName()); |
477 |
0 |
rules = getPersistenceBrokerTemplate().getCollectionByQuery( |
478 |
|
QueryFactory.newQuery(getPrincipalRuleClass(), c)); |
479 |
0 |
Iterator r = rules.iterator(); |
480 |
0 |
while (r.hasNext()) |
481 |
|
{ |
482 |
0 |
PrincipalRule pr = (PrincipalRule) r.next(); |
483 |
0 |
ProfilingRule rule = pr.getProfilingRule(); |
484 |
0 |
if (rule != null) rule.setResolvers(resolvers); |
485 |
0 |
} |
486 |
0 |
this.rulesPerPrincipal.put(principal.getName(), rules); |
487 |
0 |
return rules; |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
|
public Map getProfileLocators(RequestContext context, Principal principal) |
497 |
|
throws ProfilerException |
498 |
|
{ |
499 |
0 |
Map locators = new HashMap(); |
500 |
0 |
Collection rules = getRulesForPrincipal(principal); |
501 |
|
|
502 |
0 |
Iterator it = rules.iterator(); |
503 |
0 |
while (it.hasNext()) |
504 |
|
{ |
505 |
0 |
PrincipalRule pr = (PrincipalRule) it.next(); |
506 |
0 |
locators.put(pr.getLocatorName(), getProfile(context, pr |
507 |
|
.getLocatorName())); |
508 |
0 |
} |
509 |
0 |
return locators; |
510 |
|
} |
511 |
|
|
512 |
|
public Map getDefaultProfileLocators(RequestContext context) |
513 |
|
throws ProfilerException |
514 |
|
{ |
515 |
0 |
Map locators = new HashMap(); |
516 |
|
|
517 |
0 |
Collection rules = getRulesForPrincipal(DEFAULT_RULE_PRINCIPAL); |
518 |
|
|
519 |
0 |
Iterator it = rules.iterator(); |
520 |
0 |
while (it.hasNext()) |
521 |
|
{ |
522 |
0 |
PrincipalRule pr = (PrincipalRule) it.next(); |
523 |
0 |
locators.put(pr.getLocatorName(), getDefaultProfile(context, pr |
524 |
|
.getLocatorName())); |
525 |
0 |
} |
526 |
0 |
return locators; |
527 |
|
} |
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
public void storeProfilingRule(ProfilingRule rule) throws ProfilerException |
535 |
|
{ |
536 |
0 |
getPersistenceBrokerTemplate().store(rule); |
537 |
0 |
} |
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
public void deleteProfilingRule(ProfilingRule rule) |
545 |
|
throws ProfilerException |
546 |
|
{ |
547 |
0 |
getPersistenceBrokerTemplate().delete(rule); |
548 |
0 |
} |
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
|
public void storePrincipalRule(PrincipalRule rule) throws ProfilerException |
556 |
|
{ |
557 |
0 |
getPersistenceBrokerTemplate().store(rule); |
558 |
0 |
} |
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
public void deletePrincipalRule(PrincipalRule rule) |
566 |
|
throws ProfilerException |
567 |
|
{ |
568 |
0 |
getPersistenceBrokerTemplate().delete(rule); |
569 |
0 |
rulesPerPrincipal.remove(rule.getPrincipalName()); |
570 |
0 |
String key = this.makePrincipalRuleKey(rule.getPrincipalName(), rule.getLocatorName()); |
571 |
0 |
principalRules.remove(key); |
572 |
0 |
} |
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException |
581 |
|
{ |
582 |
0 |
this.beanFactory = beanFactory; |
583 |
0 |
} |
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
private void initRuleClasses(Map beans) throws ClassNotFoundException |
593 |
|
{ |
594 |
|
|
595 |
0 |
String beanName = ""; |
596 |
|
try |
597 |
|
{ |
598 |
0 |
if ((beanName = (String) beans.get("locator")) != null) |
599 |
|
{ |
600 |
0 |
this.locatorBean = beanName; |
601 |
|
} |
602 |
0 |
} catch (Exception e) |
603 |
|
{ |
604 |
0 |
String msg = "Exception in setting locatorbeanName : " |
605 |
|
+ e.getLocalizedMessage(); |
606 |
0 |
log.error(msg); |
607 |
0 |
} |
608 |
|
try |
609 |
|
{ |
610 |
0 |
if ((beanName = (String) beans.get("principal")) != null) |
611 |
|
{ |
612 |
0 |
this.principalRuleBean = beanName; |
613 |
|
} |
614 |
0 |
} catch (Exception e) |
615 |
|
{ |
616 |
0 |
String msg = "Exception in setting principalRulebeanName : " |
617 |
|
+ e.getLocalizedMessage(); |
618 |
0 |
log.error(msg); |
619 |
0 |
} |
620 |
|
try |
621 |
|
{ |
622 |
0 |
if ((beanName = (String) beans.get("standard")) != null) |
623 |
|
{ |
624 |
0 |
this.profilingRuleStandardBean = beanName; |
625 |
|
} |
626 |
0 |
} catch (Exception e) |
627 |
|
{ |
628 |
0 |
String msg = "Exception in setting profilingRuleStandardbeanName : " |
629 |
|
+ e.getLocalizedMessage(); |
630 |
0 |
log.error(msg); |
631 |
0 |
} |
632 |
|
try |
633 |
|
{ |
634 |
0 |
if ((beanName = (String) beans.get("fallback")) != null) |
635 |
|
{ |
636 |
0 |
this.profilingRuleFallbackBean = beanName; |
637 |
|
} |
638 |
0 |
} catch (Exception e) |
639 |
|
{ |
640 |
0 |
String msg = "Exception in setting profilingRuleFallback : " |
641 |
|
+ e.getLocalizedMessage(); |
642 |
0 |
log.error(msg); |
643 |
0 |
} |
644 |
|
|
645 |
0 |
} |
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
public ProfilingRule createProfilingRule(boolean standard) |
653 |
|
throws ClassNotFoundException |
654 |
|
{ |
655 |
|
try |
656 |
|
{ |
657 |
0 |
if (standard) |
658 |
0 |
return (ProfilingRule) beanFactory.getBean( |
659 |
|
this.profilingRuleStandardBean, ProfilingRule.class); |
660 |
|
else |
661 |
0 |
return (ProfilingRule) beanFactory.getBean( |
662 |
|
this.profilingRuleFallbackBean, ProfilingRule.class); |
663 |
|
|
664 |
0 |
} catch (BeansException e) |
665 |
|
{ |
666 |
0 |
throw new ClassNotFoundException("Spring failed to create the " |
667 |
|
+ (standard ? "standard" : "fallback") |
668 |
|
+ " profiling rule bean.", e); |
669 |
|
} |
670 |
|
} |
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
public ProfileLocator createLocator(RequestContext context) |
678 |
|
{ |
679 |
|
try |
680 |
|
{ |
681 |
0 |
ProfileLocator locator = (ProfileLocator) beanFactory.getBean( |
682 |
|
this.locatorBean, ProfileLocator.class); |
683 |
0 |
locator.init(this, context.getPath()); |
684 |
0 |
return locator; |
685 |
0 |
} catch (Exception e) |
686 |
|
{ |
687 |
0 |
log.error("Failed to create locator for " + this.locatorBean |
688 |
|
+ " error : " + e.getLocalizedMessage()); |
689 |
|
} |
690 |
0 |
return null; |
691 |
|
} |
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
|
696 |
|
|
697 |
|
|
698 |
|
public PrincipalRule createPrincipalRule() throws ClassNotFoundException |
699 |
|
{ |
700 |
|
try |
701 |
|
{ |
702 |
0 |
PrincipalRule principalRule = (PrincipalRule) beanFactory.getBean( |
703 |
|
this.principalRuleBean, PrincipalRule.class); |
704 |
0 |
return principalRule; |
705 |
0 |
} catch (Exception e) |
706 |
|
{ |
707 |
0 |
log.error("Failed to create principalRule for " + principalRuleBean |
708 |
|
+ " error : " + e.getLocalizedMessage()); |
709 |
0 |
throw new ClassNotFoundException("Spring failed to create the " |
710 |
|
+ " principal rule bean.", e); |
711 |
|
} |
712 |
|
|
713 |
|
} |
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
|
|
720 |
|
public RuleCriterion createRuleCriterion() throws ClassNotFoundException |
721 |
|
{ |
722 |
|
try |
723 |
|
{ |
724 |
0 |
RuleCriterion ruleCriterion = (RuleCriterion) beanFactory.getBean( |
725 |
|
this.ruleCriterionBean, RuleCriterion.class); |
726 |
0 |
return ruleCriterion; |
727 |
0 |
} catch (Exception e) |
728 |
|
{ |
729 |
0 |
log.error("Failed to create principalRule for " + ruleCriterionBean |
730 |
|
+ " error : " + e.getLocalizedMessage()); |
731 |
0 |
throw new ClassNotFoundException("Spring failed to create the " |
732 |
|
+ " rule criterion bean.", e); |
733 |
|
} |
734 |
|
|
735 |
|
} |
736 |
|
|
737 |
|
} |