01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.xwork.interceptor;
06:
07: import com.opensymphony.xwork.ActionInvocation;
08: import com.opensymphony.xwork.config.ConfigurationManager;
09: import com.opensymphony.xwork.config.ExternalReferenceResolver;
10: import com.opensymphony.xwork.config.entities.PackageConfig;
11:
12: /**
13: * <!-- START SNIPPET: description -->
14: * TODO: Give a description of the Interceptor.
15: * <!-- END SNIPPET: description -->
16: *
17: * <!-- START SNIPPET: parameters -->
18: * TODO: Describe the paramters for this Interceptor.
19: * <!-- END SNIPPET: parameters -->
20: *
21: * <!-- START SNIPPET: extending -->
22: * TODO: Discuss some possible extension of the Interceptor.
23: * <!-- END SNIPPET: extending -->
24: *
25: * <pre>
26: * <!-- START SNIPPET: example -->
27: * <!-- TODO: Describe how the Interceptor reference will effect execution -->
28: * <action name="someAction" class="com.examples.SomeAction">
29: * TODO: fill in the interceptor reference.
30: * <interceptor-ref name=""/>
31: * <result name="success">good_result.ftl</result>
32: * </action>
33: * <!-- END SNIPPET: example -->
34: * </pre>
35: *
36: * @author Ross
37: * <p/>
38: * Resolves external references using the <code>ExternalReferenceResolver</code> configured on the package
39: * Reference Resolution is encapsulated in an interceptor so that the user can configure when references should
40: * be resloved
41: */
42: public class ExternalReferencesInterceptor extends AroundInterceptor {
43:
44: protected void after(ActionInvocation dispatcher, String result)
45: throws Exception {
46: }
47:
48: protected void before(ActionInvocation invocation) throws Exception {
49: String packageName = invocation.getProxy().getConfig()
50: .getPackageName();
51: PackageConfig packageConfig = ConfigurationManager
52: .getConfiguration().getPackageConfig(packageName);
53:
54: if (packageConfig != null) {
55: ExternalReferenceResolver erResolver = packageConfig
56: .getExternalRefResolver();
57:
58: if (erResolver != null) {
59: erResolver.resolveReferences(invocation);
60: }
61: }
62: }
63: }
|