01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.compiler.genmodel;
20:
21: import org.apache.beehive.netui.compiler.model.ExceptionContainer;
22: import org.apache.beehive.netui.compiler.model.ExceptionModel;
23: import org.apache.beehive.netui.compiler.model.StrutsApp;
24: import org.apache.beehive.netui.compiler.model.XmlModelWriter;
25: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
26: import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration;
27: import org.apache.beehive.netui.compiler.CompilerUtils;
28: import org.w3c.dom.Element;
29:
30: /**
31: * Generates to a Struts ExceptionConfig object that delegates to an ExceptionConfig in a different module.
32: */
33: public class DelegatingExceptionModel extends ExceptionModel {
34: private static final String EXCEPTION_CONFIG_CLASSNAME = PAGEFLOW_PACKAGE
35: + ".config.DelegatingExceptionConfig";
36:
37: protected DelegatingExceptionModel(ExceptionContainer container,
38: GenStrutsApp parentApp, AnnotationInstance ann,
39: TypeDeclaration containingType) {
40: super (parentApp);
41: setType(CompilerUtils.getLoadableName(CompilerUtils
42: .getDeclaredType(ann, TYPE_ATTR, true)));
43: setClassName(EXCEPTION_CONFIG_CLASSNAME);
44:
45: String modulePath = CompilerUtils
46: .inferModulePathFromType(containingType);
47: if (parentApp instanceof GenSharedFlowStrutsApp) {
48: // modify the module config path for a shared flow
49: modulePath = "/" + StrutsApp.STRUTS_CONFIG_SEPARATOR
50: + modulePath.substring(1);
51: }
52: addSetProperty("delegateModulePath", modulePath);
53: addSetProperty("delegateActionPath", container.getActionPath());
54:
55: if (parentApp.getFlowControllerInfo()
56: .getMergedControllerAnnotation().isInheritLocalPaths()) {
57: addSetProperty("inheritLocalPaths", "true");
58: }
59: }
60:
61: protected void addSetProperty(XmlModelWriter xw, Element element,
62: String propertyName, String propertyValue) {
63: setCustomProperty(xw, element, propertyName, propertyValue,
64: EXCEPTION_CONFIG_CLASSNAME);
65: }
66: }
|