You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/09/21 21:42:44 UTC
svn commit: r290802 [7/10] - in /struts/sandbox/trunk/ti: ./
jars/core/src/java/org/apache/ti/compiler/internal/
jars/core/src/java/org/apache/ti/compiler/internal/genmodel/
jars/core/src/java/org/apache/ti/compiler/internal/grammar/
jars/core/src/java...
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotationParser.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotationParser.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotationParser.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotationParser.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.pageflow.internal.annotationreader;
+
+import org.apache.ti.util.logging.Logger;
+import org.apache.ti.util.xml.DomUtils;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+public final class ProcessedAnnotationParser {
+ private static final Logger _log = Logger.getInstance(ProcessedAnnotationParser.class);
+ private static final String ANNOTATED_ELEMENT = "annotated-element";
+ private static final String ANNOTATION = "annotation";
+ private static final String ANNOTATION_ATTRIBUTE = "annotation-attribute";
+ private static final String ANNOTATION_NAME = "annotation-name";
+ private static final String ATTRIBUTE_NAME = "attribute-name";
+ private static final String ATTRIBUTE_STRING_VALUE = "string-value";
+ private static final String ATTRIBUTE_VALUE = "annotation-value";
+ private static final String ELEMENT_NAME = "element-name";
+ private static final String TYPE_NAME = "type-name";
+
+ /* do not construct */
+ private ProcessedAnnotationParser() {
+ }
+
+ public static ProcessedAnnotations parse(final String annotationsXml, final InputStream is) {
+ assert is != null;
+
+ ProcessedAnnotations processedAnnotations = null;
+
+ try {
+ /* parse the config document */
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document document = db.parse(is);
+ Element root = document.getDocumentElement();
+ String typeName = getElementText(root, TYPE_NAME);
+ assert typeName != null : "Missing the following element: " + TYPE_NAME;
+
+ Map annotatedElements = parseAnnotatedElements(root);
+ processedAnnotations = new ProcessedAnnotations(typeName, annotatedElements);
+ } catch (ParserConfigurationException pce) {
+ _log.error("Error occurred while parsing annotations XML file " + annotationsXml, pce);
+ } catch (SAXException saxe) {
+ _log.error("Error occurred while parsing annotations XML file " + annotationsXml, saxe);
+ } catch (IOException ioe) {
+ _log.error("Error occurred while parsing annotations XML file " + annotationsXml, ioe);
+ }
+
+ return processedAnnotations;
+ }
+
+ private static final Map parseAnnotatedElements(Element parent) {
+ if (parent == null) {
+ return null;
+ }
+
+ List list = DomUtils.getChildElementsByName(parent, ANNOTATED_ELEMENT);
+
+ if ((list == null) || (list.size() == 0)) {
+ return null;
+ }
+
+ HashMap annotatedElements = new HashMap();
+
+ for (int i = 0; i < list.size(); i++) {
+ Element elem = (Element) list.get(i);
+ String name = getElementText(elem, ELEMENT_NAME);
+ assert name != null : "Missing the following element: " + ELEMENT_NAME;
+
+ ProcessedAnnotation[] annotations = parseProcessedAnnotations(elem, ANNOTATION);
+ assert annotations != null : "Missing the following element: " + ANNOTATION;
+
+ annotatedElements.put(name, annotations);
+ }
+
+ return annotatedElements;
+ }
+
+ private static final ProcessedAnnotation[] parseProcessedAnnotations(Element parent, String nodeName) {
+ if (parent == null) {
+ return null;
+ }
+
+ List list = DomUtils.getChildElementsByName(parent, nodeName);
+
+ if ((list == null) || (list.size() == 0)) {
+ return null;
+ }
+
+ ProcessedAnnotation[] annotations = new ProcessedAnnotation[list.size()];
+
+ for (int i = 0; i < list.size(); i++) {
+ Element elem = (Element) list.get(i);
+ String name = getElementText(elem, ANNOTATION_NAME);
+ assert name != null : "Missing the following element: " + ANNOTATION_NAME;
+
+ AnnotationAttribute[] attributes = parseAnnotationAttribute(elem);
+ annotations[i] = new ProcessedAnnotation(name, attributes);
+ }
+
+ return annotations;
+ }
+
+ private static final AnnotationAttribute[] parseAnnotationAttribute(Element parent) {
+ if (parent == null) {
+ return null;
+ }
+
+ List list = DomUtils.getChildElementsByName(parent, ANNOTATION_ATTRIBUTE);
+
+ if ((list == null) || (list.size() == 0)) {
+ return null;
+ }
+
+ AnnotationAttribute[] attributes = new AnnotationAttribute[list.size()];
+
+ for (int i = 0; i < list.size(); i++) {
+ Element elem = (Element) list.get(i);
+ String name = getElementText(elem, ATTRIBUTE_NAME);
+ assert name != null : "Missing the following element: " + ATTRIBUTE_NAME;
+
+ String value = getElementText(elem, ATTRIBUTE_STRING_VALUE);
+
+ if (value != null) {
+ attributes[i] = new AnnotationAttribute(name, value);
+ } else {
+ ProcessedAnnotation[] annotations = parseProcessedAnnotations(elem, ATTRIBUTE_VALUE);
+ attributes[i] = new AnnotationAttribute(name, annotations);
+ }
+ }
+
+ return attributes;
+ }
+
+ private static String getElementText(Element parent, String elementName) {
+ Element child = DomUtils.getChildElementByName(parent, elementName);
+
+ if (child != null) {
+ String text = DomUtils.getElementText(child);
+
+ if (text != null) {
+ return (text.length() == 0) ? null : text;
+ }
+ }
+
+ return null;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotations.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotations.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotations.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/internal/annotationreader/ProcessedAnnotations.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.pageflow.internal.annotationreader;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public class ProcessedAnnotations {
+ private String _typeName;
+ private Map _annotatedElements;
+
+ public ProcessedAnnotations() {
+ }
+
+ public ProcessedAnnotations(String typeName, Map annotatedElements) {
+ _typeName = typeName;
+ _annotatedElements = annotatedElements;
+ }
+
+ public String getTypeName() {
+ return _typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ _typeName = typeName;
+ }
+
+ public Map getAnnotatedElements() {
+ return _annotatedElements;
+ }
+
+ public void setAnnotatedElements(Map annotatedElements) {
+ _annotatedElements = annotatedElements;
+ }
+}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/NavigateToPageResult.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/NavigateToPageResult.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/NavigateToPageResult.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/NavigateToPageResult.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,7 @@
package org.apache.ti.pageflow.xwork;
import com.opensymphony.xwork.ActionInvocation;
+
import org.apache.ti.pageflow.FlowControllerException;
import org.apache.ti.pageflow.Forward;
import org.apache.ti.pageflow.NoCurrentPageFlowException;
@@ -27,8 +28,8 @@
import org.apache.ti.pageflow.internal.InternalUtils;
import org.apache.ti.util.logging.Logger;
-public class NavigateToPageResult extends NavigateToResult {
-
+public class NavigateToPageResult
+ extends NavigateToResult {
private static final Logger _log = Logger.getInstance(NavigateToPageResult.class);
/**
@@ -46,7 +47,7 @@
if (curJpf == null) {
FlowControllerException ex = new NoCurrentPageFlowException(this);
InternalUtils.throwPageFlowException(ex);
- assert false; // throwPageFlowException() must throw.
+ assert false; // throwPageFlowException() must throw.
}
PreviousPageInfo prevPageInfo;
@@ -54,18 +55,21 @@
switch (getPreviousPageIndex()) {
case 0:
prevPageInfo = curJpf.getCurrentPageInfo();
+
break;
case 1:
prevPageInfo = curJpf.getPreviousPageInfo();
+
break;
default:
assert false : getPreviousPageIndex() + " is not a valid previous-page index";
+
// of course, in the future, we should support any index, up to an app-configured max
prevPageInfo = curJpf.getCurrentPageInfo();
}
-
+
// The previous result has already been initialized from the previous Forward.
// 1) Initialize from *this* forward, overwriting previously-initialized values.
// 2) Apply the previous Forward (sets values in the request).
@@ -74,10 +78,15 @@
PageFlowActionContext actionContext = (PageFlowActionContext) invocation.getInvocationContext();
Forward currentForward = actionContext.getForward();
assert currentForward != null : "no forward found in context for Result \"" + getName() + '"';
+
PageFlowResult prevResult = prevPageInfo.getResult();
Forward previousForward = prevPageInfo.getForward();
- prevResult.initFrom(currentForward, actionContext);
- if (previousForward != null) prevResult.applyForward(previousForward, actionContext);
+ prevResult.initFrom(currentForward, actionContext, false);
+
+ if (previousForward != null) {
+ prevResult.applyForward(previousForward, actionContext);
+ }
+
prevResult.applyForward(currentForward, actionContext);
actionContext.setPreviousPageInfo(prevPageInfo);
prevResult.finishExecution(currentForward, actionContext);
@@ -91,7 +100,7 @@
String fwdPath = retFwd.getPath();
String newQueryString = fwd.getQueryString();
int existingQueryPos = fwdPath.indexOf( '?' );
-
+
//
// If the new forward (the one with ti.NavigateTo.currentPage/previousPage) has a query string, use that.
// Otherwise, if the old forward has no query string, restore the one from the PreviousPageInfo if
@@ -107,7 +116,7 @@
{
retFwd.setPath( fwdPath + getQueryString( fwd, prevPageInfo ) );
}
-
+
*/
/*
protected Forward applyForward(Forward fwd, ModuleConfig altModuleConfig) {
@@ -116,46 +125,46 @@
// in the ActionConteext, but if it's a shared flow, then we don't want to use that.
//
PageFlowController curJpf = PageFlowUtils.getCurrentPageFlow();
-
+
if ( curJpf == null )
{
FlowControllerException ex = new NoCurrentPageFlowException( this );
InternalUtils.throwPageFlowException( ex);
assert false; // throwPageFlowException() must throw.
}
-
+
PreviousPageInfo prevPageInfo;
-
+
switch ( getPreviousPageIndex() )
{
case 0:
prevPageInfo = curJpf.getCurrentPageInfo();
break;
-
+
case 1:
prevPageInfo = curJpf.getPreviousPageInfo();
break;
-
+
default:
assert false : getPreviousPageIndex() + " is not a valid previous-page index";
// of course, in the future, we should support any index, up to an app-configured max
prevPageInfo = curJpf.getCurrentPageInfo();
}
-
+
Forward retFwd = doReturnToPage(fwd, prevPageInfo, curJpf);
-
+
if ( prevPageInfo != null )
{
- PageFlowActionContext actionContext = PageFlowActionContext.getContext();
+ PageFlowActionContext actionContext = PageFlowActionContext.getContext();
//mapping = prevPageInfo.getAction();
//if ( form == null ) form = prevPageInfo.getFormBean();
}
-
+
if ( _log.isDebugEnabled() )
{
_log.debug( "navigate-to-page: " + ( fwd != null ? fwd.getPath() : "[null]" ) );
}
-
+
return retFwd;
}
@@ -167,24 +176,24 @@
{
_log.info( "Attempted return-to-page, but previous page info was missing." );
}
-
+
FlowControllerException ex = new NoPreviousPageException( this, currentPageFlow );
InternalUtils.throwPageFlowException( ex);
}
-
+
//
// Figure out what URI to return to, and set the original form in the request or session.
- //
+ //
Forward retFwd = prevPageInfo.getResult();
PageFlowAction prevAction = prevPageInfo.getAction();
- PageFlowActionContext actionContext = PageFlowActionContext.getContext();
-
+ PageFlowActionContext actionContext = PageFlowActionContext.getContext();
+
//
// Restore any forms that are specified by this forward (overwrite the original forms).
//
PageFlowUtils.setOutputForms( retFwd, false );
InternalUtils.addActionOutputs( retFwd.getActionOutputs(), false );
-
+
//
// If the user hit the previous page directly (without going through an action), prevMapping will be null.
//
@@ -196,20 +205,20 @@
//
Object currentForm = actionContext.getAction().getFormBean();
if ( currentForm != null ) PageFlowUtils.setOutputForm( currentForm, false );
-
+
//
// Initialize the page with the original form it got forwarded (but we don't overwrite the form that was
// set above).
//
InternalUtils.setFormInScope( prevAction.getFormBeanAttribute(), prevPageInfo.getFormBean(), false );
}
-
+
//
// If we're forwarding to a page in a different pageflow, we need to make sure the returned forward has
// the right namespace, and that it has contextRelative=true.
//
FlowController flowController = actionContext.getFlowController();
-
+
if ( ! retFwd.getPath().startsWith( "/" ) && flowController != currentPageFlow )
{
assert false : "NYI";
@@ -219,13 +228,13 @@
true );
}
-
+
if ( _log.isDebugEnabled() )
{
_log.debug( "Return-to-page in PageFlowController " + flowController.getClass().getName()
+ ": original URI " + retFwd.getPath() );
}
-
+
if ( retFwd != null )
{
//
@@ -233,14 +242,14 @@
// use the redirect value from the original forward.
//
if ( ! hasExplicitRedirectValue() ) setRedirect( fwd.isRedirect() );
-
+
//
// If there's a query string, override the previous query string.
//
String fwdPath = retFwd.getPath();
String newQueryString = fwd.getQueryString();
int existingQueryPos = fwdPath.indexOf( '?' );
-
+
//
// If the new forward (the one with ti.NavigateTo.currentPage/previousPage) has a query string, use that.
// Otherwise, if the old forward has no query string, restore the one from the PreviousPageInfo if
@@ -257,19 +266,18 @@
retFwd.setPath( fwdPath + getQueryString( fwd, prevPageInfo ) );
}
}
-
-
+
+
actionContext.setPreviousPageInfo( prevPageInfo );
return retFwd;
}
*/
-
protected boolean shouldSavePreviousPageInfo() {
return _previousPageIndex > 0;
}
public String getNavigateToAsString() {
- return _previousPageIndex > 0 ? "ti.NavigateTo.previousPage" : "ti.NavigateTo.currentPage"; // TODO: constant
+ return (_previousPageIndex > 0) ? "ti.NavigateTo.previousPage" : "ti.NavigateTo.currentPage"; // TODO: constant
}
public boolean isPath() {
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/PageFlowResult.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/PageFlowResult.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/PageFlowResult.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/xwork/PageFlowResult.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,7 @@
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.Result;
+
import org.apache.ti.pageflow.*;
import org.apache.ti.pageflow.handler.ForwardRedirectHandler;
import org.apache.ti.pageflow.handler.Handlers;
@@ -30,19 +31,19 @@
import org.apache.ti.util.logging.Logger;
import java.io.Serializable;
+
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-public abstract class PageFlowResult implements Result {
-
+public abstract class PageFlowResult
+ implements Result {
private static final Logger _log = Logger.getInstance(PageFlowResult.class);
-
-
- private static final Map/*< String, Class >*/ PRIMITIVE_TYPES = new HashMap/*< String, Class >*/();
+ private static final Map /*< String, Class >*/ PRIMITIVE_TYPES = new HashMap /*< String, Class >*/();
static {
PRIMITIVE_TYPES.put("boolean", boolean.class);
@@ -72,8 +73,9 @@
PageFlowActionContext actionContext = (PageFlowActionContext) invocation.getInvocationContext();
Forward fwd = actionContext.getForward();
assert fwd != null : "no forward found in context for Result \"" + getName() + '"';
+
if (!preprocess(fwd, actionContext)) {
- initFrom(fwd, actionContext);
+ initFrom(fwd, actionContext, true);
applyForward(fwd, actionContext);
finishExecution(fwd, actionContext);
}
@@ -177,10 +179,9 @@
_externalRedirect = externalRedirect;
}
- private static class ActionOutput implements Serializable {
-
+ private static class ActionOutput
+ implements Serializable {
private static final long serialVersionUID = 1;
-
private String _actionOutputName;
private String _type;
private boolean _isNullable;
@@ -207,6 +208,7 @@
protected void setActionOutput(int n, String concatenatedVals) {
String[] vals = concatenatedVals.split("\\|");
assert vals.length == 3 : vals.length;
+
String name = vals[2];
String type = vals[0];
boolean isNullable = Boolean.valueOf(vals[1]).booleanValue();
@@ -307,13 +309,17 @@
_inheritedPath = inheritedPath;
}
- protected void initFrom(Forward fwd, PageFlowActionContext actionContext) {
+ protected void initFrom(Forward fwd, PageFlowActionContext actionContext, boolean checkForErrors) {
// If there was a path specified on the Forward (programmatically), use that.
// TODO: enforce an annotation attribute that allows this; otherwise, throw.
- if (fwd.getPath() != null) setLocation(fwd.getPath());
-
+ if (fwd.getPath() != null) {
+ setLocation(fwd.getPath());
+ }
+
// Add query params to the path.
- if (fwd.getQueryString() != null) setLocation(getLocation() + fwd.getQueryString());
+ if (fwd.getQueryString() != null) {
+ setLocation(getLocation() + fwd.getQueryString());
+ }
Class returnFormClass = null;
@@ -330,10 +336,15 @@
if (_outputFormBeanMember != null) {
try {
- assert flowController != null; // should be set in initialize()
+ assert flowController != null; // should be set in initialize()
+
Field field = flowController.getClass().getDeclaredField(_outputFormBeanMember);
returnFormClass = field.getType();
- if (!Modifier.isPublic(field.getModifiers())) field.setAccessible(true);
+
+ if (!Modifier.isPublic(field.getModifiers())) {
+ field.setAccessible(true);
+ }
+
Object form = field.get(flowController);
if (form != null) {
@@ -350,35 +361,36 @@
} catch (NoSuchFieldException e) {
assert false : "could not find field " + _outputFormBeanMember; // compiler should catch this
} catch (IllegalAccessException e) {
- assert false; // should not get here -- field is accessible.
+ assert false; // should not get here -- field is accessible.
}
}
- checkOutputFormBeans(fwd, returnFormClass, flowController);
- checkActionOutputs(fwd, actionContext);
-
-
- //
- // Throw an exception if this is a redirect, and if there was an output form or an action output added.
- // Output forms and action outputs are carried in the request, and will be lost on redirects.
- //
- if (isRedirect()) {
- if (_actionOutputDeclarations != null && !_actionOutputDeclarations.isEmpty()) {
- FlowControllerException ex =
- new IllegalActionOutputException(_name, flowController,
- (String) _actionOutputDeclarations.keySet().iterator().next());
- InternalUtils.throwPageFlowException(ex);
- }
+ if (checkForErrors) {
+ checkOutputFormBeans(fwd, returnFormClass, flowController);
+ checkActionOutputs(fwd, actionContext);
- List outputForms = fwd.getOutputFormBeans();
- if (outputForms != null && !outputForms.isEmpty()) {
- FlowControllerException ex =
- new IllegalRedirectOutputFormException(_name, flowController,
- outputForms.get(0).getClass().getName());
- InternalUtils.throwPageFlowException(ex);
+ //
+ // Throw an exception if this is a redirect, and if there was an output form or an action output added.
+ // Output forms and action outputs are carried in the request, and will be lost on redirects.
+ //
+ if (isRedirect()) {
+ if ((_actionOutputDeclarations != null) && !_actionOutputDeclarations.isEmpty()) {
+ FlowControllerException ex = new IllegalActionOutputException(_name, flowController,
+ (String) _actionOutputDeclarations.keySet()
+ .iterator()
+ .next());
+ InternalUtils.throwPageFlowException(ex);
+ }
+
+ List outputForms = fwd.getOutputFormBeans();
+
+ if ((outputForms != null) && !outputForms.isEmpty()) {
+ FlowControllerException ex = new IllegalRedirectOutputFormException(_name, flowController,
+ outputForms.get(0).getClass().getName());
+ InternalUtils.throwPageFlowException(ex);
+ }
}
}
-
}
private void checkOutputFormBeans(Forward fwd, Class returnFormClass, FlowController flowController) {
@@ -386,14 +398,14 @@
// Make sure that if there's currently an output form, that it confirms to the return-form-type.
//
List outputForms = fwd.getOutputFormBeans();
- if (returnFormClass != null && outputForms != null && outputForms.size() > 0) {
+
+ if ((returnFormClass != null) && (outputForms != null) && (outputForms.size() > 0)) {
Object outputForm = outputForms.get(0);
if (!returnFormClass.isInstance(outputForm)) {
- FlowControllerException ex =
- new IllegalOutputFormTypeException(getName(), flowController,
- outputForm.getClass().getName(),
- returnFormClass.getName());
+ FlowControllerException ex = new IllegalOutputFormTypeException(getName(), flowController,
+ outputForm.getClass().getName(),
+ returnFormClass.getName());
InternalUtils.throwPageFlowException(ex);
}
}
@@ -404,7 +416,9 @@
* in production mode
*/
private void checkActionOutputs(Forward fwd, PageFlowActionContext actionContext) {
- if (_actionOutputDeclarations == null) return;
+ if (_actionOutputDeclarations == null) {
+ return;
+ }
boolean isInProductionMode = AdapterManager.getContainerAdapter().isInProductionMode();
Map fwdActionOutputs = fwd.getActionOutputs();
@@ -412,19 +426,18 @@
for (Iterator i = _actionOutputDeclarations.values().iterator(); i.hasNext();) {
ActionOutput actionOutput = (ActionOutput) i.next();
- if (!actionOutput.getNullable()
- && (fwdActionOutputs == null || fwdActionOutputs.get(actionOutput.getName()) == null)) {
+ if (!actionOutput.getNullable() &&
+ ((fwdActionOutputs == null) || (fwdActionOutputs.get(actionOutput.getName()) == null))) {
FlowController flowController = actionContext.getFlowController();
- FlowControllerException ex =
- new MissingActionOutputException(flowController, actionOutput.getName(), getName());
+ FlowControllerException ex = new MissingActionOutputException(flowController, actionOutput.getName(), getName());
InternalUtils.throwPageFlowException(ex);
}
-
+
//
// If we're *not* in production mode, do some (expensive) checks to ensure that the types for the
// action outputs match their declared types.
//
- if (!isInProductionMode && fwdActionOutputs != null) {
+ if (!isInProductionMode && (fwdActionOutputs != null)) {
Object actualActionOutput = fwdActionOutputs.get(actionOutput.getName());
if (actualActionOutput != null) {
@@ -442,9 +455,9 @@
try {
expectedType = Class.forName(expectedTypeName);
} catch (ClassNotFoundException e) {
- _log.error("Could not load expected action output type " + expectedTypeName
- + " for action output '" + actionOutput.getName() + "' on forward '"
- + getName() + "'; skipping type check.");
+ _log.error("Could not load expected action output type " + expectedTypeName + " for action output '" +
+ actionOutput.getName() + "' on forward '" + getName() + "'; skipping type check.");
+
continue;
}
}
@@ -453,18 +466,17 @@
int actualArrayDims = 0;
InternalStringBuilder arraySuffix = new InternalStringBuilder();
- while (actualType.isArray() && actualArrayDims <= expectedArrayDims) {
+ while (actualType.isArray() && (actualArrayDims <= expectedArrayDims)) {
++actualArrayDims;
arraySuffix.append("[]");
actualType = actualType.getComponentType();
}
- if (actualArrayDims != expectedArrayDims || !expectedType.isAssignableFrom(actualType)) {
+ if ((actualArrayDims != expectedArrayDims) || !expectedType.isAssignableFrom(actualType)) {
FlowController fc = actionContext.getFlowController();
- FlowControllerException ex =
- new MismatchedActionOutputException(fc, actionOutput.getName(), getName(),
- expectedTypeName,
- actualType.getName() + arraySuffix);
+ FlowControllerException ex = new MismatchedActionOutputException(fc, actionOutput.getName(), getName(),
+ expectedTypeName,
+ actualType.getName() + arraySuffix);
InternalUtils.throwPageFlowException(ex);
}
}
@@ -486,8 +498,7 @@
return false;
}
- protected void doForward(String path)
- throws PageFlowException {
+ protected void doForward(String path) throws PageFlowException {
if (!processPageForward(path)) {
ForwardRedirectHandler fwdRedirectHandler = Handlers.get().getForwardRedirectHandler();
fwdRedirectHandler.forward(path);
@@ -501,7 +512,6 @@
//
PageFlowUtils.setOutputForms(fwd, true);
InternalUtils.addActionOutputs(fwd.getActionOutputs(), true);
-
}
/**
@@ -513,11 +523,11 @@
Handlers handlers = Handlers.get();
ForwardRedirectHandler fwdRedirectHandler = handlers.getForwardRedirectHandler();
FlowController fc = actionContext.getFlowController();
-
+
// Register this module as the one that's handling the action.
assert fc != null;
InternalUtils.setForwardingModule(fc.getNamespace());
-
+
//
// Save info on this forward for return-to="currentPage" or return-to="previousPage". But, don't save
// the info if the current forward is a return-to="currentPage" -- we don't want this to turn into
@@ -527,12 +537,16 @@
Object formBean = actionContext.getFormBean();
fc.savePreviousPageInfo(this, fwd, formBean);
}
-
+
// Try to get a resolved path from the forward; otherwise, just use the configured path.
String path = getLocation();
- if (path == null) path = getLocation();
- boolean startsWithSlash = path.length() > 0 && path.charAt(0) == '/';
-
+
+ if (path == null) {
+ path = getLocation();
+ }
+
+ boolean startsWithSlash = (path.length() > 0) && (path.charAt(0) == '/');
+
//
// If the URI is absolute (e.g., starts with "http:"), do a redirect to it no matter what.
//
@@ -556,10 +570,10 @@
// off the shared flow module prefix "/-" and replace it with "/").
//
ModuleConfig mc = actionContext.getModuleConfig();
-
+
// TODO: ACTION_EXTENSION can no longer be a constant -- we support arbitrary Servlet mappings
- if (mc.isSharedFlow() && !fwdURI.endsWith(PageFlowConstants.ACTION_EXTENSION)
- && fwdURI.startsWith(InternalConstants.SHARED_FLOW_MODULE_PREFIX)) {
+ if (mc.isSharedFlow() && !fwdURI.endsWith(PageFlowConstants.ACTION_EXTENSION) &&
+ fwdURI.startsWith(InternalConstants.SHARED_FLOW_MODULE_PREFIX)) {
fwdURI = '/' + fwdURI.substring(InternalConstants.SHARED_FLOW_MODULE_PREFIX_LEN);
}
}
@@ -573,7 +587,6 @@
return path;
}
-
protected abstract boolean shouldSavePreviousPageInfo();
/**
@@ -581,7 +594,4 @@
* navigateTo=ti.NavigateTo.currentPage).
*/
public abstract boolean isPath();
-
}
-
-
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/processor/chain/pageflow/InitPageFlow.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/processor/chain/pageflow/InitPageFlow.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/processor/chain/pageflow/InitPageFlow.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/processor/chain/pageflow/InitPageFlow.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,7 @@
import org.apache.commons.chain.web.WebContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.ti.core.urls.TemplatedURLFormatter;
import org.apache.ti.core.urltemplates.URLTemplatesFactory;
import org.apache.ti.pageflow.ContainerAdapter;
@@ -37,26 +38,30 @@
import org.apache.ti.pageflow.internal.InternalConstants;
import org.apache.ti.pageflow.internal.ProcessPopulate;
import org.apache.ti.processor.chain.InitXWork;
-import org.apache.ti.schema.config.PrefixHandlers;
import org.apache.ti.util.SourceResolver;
import org.apache.ti.util.config.ConfigInitializationException;
import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.PrefixHandlerConfig;
+import org.apache.ti.util.xml.XmlInputStreamResolver;
+import java.io.IOException;
+import java.io.InputStream;
import java.io.Serializable;
+
+import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Map;
-public class InitPageFlow implements Command {
+import java.util.Map;
+public class InitPageFlow
+ implements Command {
private static final Log log = LogFactory.getLog(InitXWork.class);
private static final String ALREADY_INIT_ATTR = InternalConstants.ATTR_PREFIX + "contextInit";
-
private SourceResolver _sourceResolver;
private Handlers _handlers;
-
- private static class TransientFlag implements Serializable {
-
+ private static class TransientFlag
+ implements Serializable {
private static final long serialVersionUID = 1;
private transient boolean _flag;
@@ -71,15 +76,19 @@
public boolean execute(Context context) throws Exception {
// TODO: turn this whole thing into a chain
-
log.debug("Initializing Page Flow");
+
WebContext webContext = (WebContext) context;
Map appScope = webContext.getApplicationScope();
// If the flag is present, but was serialized, then the webapp was redeployed. At this point, we want
// to go through the init logic again.
TransientFlag flag = (TransientFlag) appScope.get(ALREADY_INIT_ATTR);
- if (flag != null && flag.isSet()) return false;
+
+ if ((flag != null) && flag.isSet()) {
+ return false;
+ }
+
appScope.put(ALREADY_INIT_ATTR, new TransientFlag());
//
@@ -87,15 +96,14 @@
// config (static) isn't the same as the scope for PageFlowActionServlet, which may get created and destroyed
// within a classloader (which is the case during StrutsTestCase tests).
//
- if (! ConfigUtil.isInit()) {
+ if (!ConfigUtil.isInit()) {
try {
- URL configInput = _sourceResolver.resolve(InternalConstants.NETUI_CONFIG_PATH, webContext);
- ConfigUtil.init(configInput);
- }
- catch (ConfigInitializationException e) {
+ ConfigUtil.init(new NetUIConfigResolver(webContext));
+ } catch (ConfigInitializationException e) {
log.fatal("Could not initialize from " + InternalConstants.NETUI_CONFIG_PATH, e);
- IllegalStateException ie =
- new IllegalStateException("Could not initialize from " + InternalConstants.NETUI_CONFIG_PATH);
+
+ IllegalStateException ie = new IllegalStateException("Could not initialize from " +
+ InternalConstants.NETUI_CONFIG_PATH);
ie.initCause(e);
throw ie;
}
@@ -105,14 +113,13 @@
_handlers.initApplication(appScope);
FlowControllerFactory.init(appScope);
FacesBackingBeanFactory.init(appScope);
- initPrefixHandlers(appScope);
+ initPrefixHandlers();
// Create a URLTemplatesFactory (may be container specific from the ContainerAdapter) and the the default
// TemplatedURLFormatter (registered in the netui config). These classes are used by the URLRewriterService.
- TemplatedURLFormatter formatter =
- TemplatedURLFormatter.initApplication(appScope, new DefaultTemplatedURLFormatter());
+ TemplatedURLFormatter formatter = TemplatedURLFormatter.initApplication(appScope, new DefaultTemplatedURLFormatter());
URLTemplatesFactory.initApplication(webContext, new DefaultURLTemplatesFactory(), formatter, containerAdapter,
- _sourceResolver);
+ _sourceResolver);
//
// Initialize the request interceptors and action interceptors.
@@ -128,41 +135,40 @@
* The prefix handlers are registered with ProcessPopulate and are typically implemented as
* public inner classes in the tags that require prefix handlers.
*/
- private static void initPrefixHandlers(Map appScope) {
- PrefixHandlers ph = ConfigUtil.getConfig().getPrefixHandlers();
- if (ph == null) {
+ private static void initPrefixHandlers() {
+ PrefixHandlerConfig[] prefixHandlers = ConfigUtil.getConfig().getPrefixHandlers();
+
+ if (prefixHandlers == null) {
return;
}
- PrefixHandlers.PrefixHandler[] prefixHandlers = ph.getPrefixHandlerArray();
- if (prefixHandlers != null) {
- for (int i = 0; i < prefixHandlers.length; i++) {
- try {
- Class prefixClass = Class.forName(prefixHandlers[i].getHandlerClass());
- String name = prefixHandlers[i].getName();
- if (name == null || name.equals("")) {
- log.warn("The name for the prefix handler '" + prefixHandlers[i].getHandlerClass()
- + "' must not be null");
- continue;
- }
- Object o = prefixClass.newInstance();
- if (!(o instanceof RequestParameterHandler)) {
- log.warn("The class '" + prefixHandlers[i].getHandlerClass()
- + "' must be an instance of RequestParameterHandler");
- continue;
- }
- ProcessPopulate.registerPrefixHandler(name, (RequestParameterHandler) o);
- }
- catch (ClassNotFoundException e) {
- log.warn("Class '" + prefixHandlers[i].getHandlerClass() + "' not found", e);
- }
- catch (IllegalAccessException e) {
- log.warn("Illegal access on Class '" + prefixHandlers[i].getHandlerClass() + '\'', e);
+ for (int i = 0; i < prefixHandlers.length; i++) {
+ try {
+ Class prefixClass = Class.forName(prefixHandlers[i].getHandlerClass());
+ String name = prefixHandlers[i].getName();
+
+ if ((name == null) || name.equals("")) {
+ log.warn("The name for the prefix handler '" + prefixHandlers[i].getHandlerClass() + "' must not be null");
+
+ continue;
}
- catch (InstantiationException e) {
- log.warn("InstantiationException on Class '" + prefixHandlers[i].getHandlerClass() + '\'',
- e.getCause());
+
+ Object o = prefixClass.newInstance();
+
+ if (!(o instanceof RequestParameterHandler)) {
+ log.warn("The class '" + prefixHandlers[i].getHandlerClass() +
+ "' must be an instance of RequestParameterHandler");
+
+ continue;
}
+
+ ProcessPopulate.registerPrefixHandler(name, (RequestParameterHandler) o);
+ } catch (ClassNotFoundException e) {
+ log.warn("Class '" + prefixHandlers[i].getHandlerClass() + "' not found", e);
+ } catch (IllegalAccessException e) {
+ log.warn("Illegal access on Class '" + prefixHandlers[i].getHandlerClass() + "'", e);
+ } catch (InstantiationException e) {
+ log.warn("InstantiationException on Class '" + prefixHandlers[i].getHandlerClass() + "'", e.getCause());
}
}
}
@@ -173,5 +179,30 @@
public void setSourceResolver(SourceResolver sourceResolver) {
_sourceResolver = sourceResolver;
+ }
+
+ private class NetUIConfigResolver
+ extends XmlInputStreamResolver {
+ private WebContext _webContext = null;
+
+ private NetUIConfigResolver(WebContext servletContext) {
+ _webContext = servletContext;
+ }
+
+ public String getResourcePath() {
+ return InternalConstants.NETUI_CONFIG_PATH;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ try {
+ URL url = _sourceResolver.resolve(getResourcePath(), _webContext);
+
+ return (url != null) ? url.openStream() : null;
+ } catch (MalformedURLException e) {
+ assert false : "should never get MalformedURLException here";
+
+ return null;
+ }
+ }
}
}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/script/ExpressionEvaluatorFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/script/ExpressionEvaluatorFactory.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/script/ExpressionEvaluatorFactory.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/script/ExpressionEvaluatorFactory.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,10 @@
*/
package org.apache.ti.script;
-import org.apache.ti.schema.config.ExpressionLanguages;
-import org.apache.ti.schema.config.ExpressionLanguages.ExpressionLanguage;
-import org.apache.ti.schema.config.NetuiConfigDocument.NetuiConfig;
import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.ExpressionLanguageConfig;
+import org.apache.ti.util.config.bean.ExpressionLanguagesConfig;
+import org.apache.ti.util.config.bean.NetUIConfig;
import org.apache.ti.util.logging.Logger;
import java.util.HashMap;
@@ -30,9 +30,7 @@
* Get an expression evaluator.
*/
public class ExpressionEvaluatorFactory {
-
private static final Logger _logger = Logger.getInstance(ExpressionEvaluatorFactory.class);
-
private static final HashMap FACTORY_MAP = new HashMap();
private static ExpressionEngineFactory DEFAULT_FACTORY;
@@ -42,8 +40,9 @@
} catch (Exception e) {
DEFAULT_FACTORY = null;
- if (_logger.isErrorEnabled())
+ if (_logger.isErrorEnabled()) {
_logger.error("An exception occurred loading the expression evaluator configuration. Cause: " + e, e);
+ }
}
}
@@ -66,14 +65,17 @@
assert DEFAULT_FACTORY != null;
assert FACTORY_MAP != null;
- if (name == null)
+ if (name == null) {
return DEFAULT_FACTORY.getInstance();
- else if (FACTORY_MAP.containsKey(name))
+ } else if (FACTORY_MAP.containsKey(name)) {
return ((ExpressionEngineFactory) FACTORY_MAP.get(name)).getInstance();
+ }
String msg = "An ExpressionEvaluator named \"" + name + "\" is not available.";
- if (_logger.isErrorEnabled())
+
+ if (_logger.isErrorEnabled()) {
_logger.error(msg);
+ }
throw new IllegalArgumentException(msg);
}
@@ -81,65 +83,84 @@
private static final ExpressionEngineFactory initialize(Map factoryMap) {
assert factoryMap != null;
- NetuiConfig config = ConfigUtil.getConfig();
- assert config != null;
+ NetUIConfig config = ConfigUtil.getConfig();
- ExpressionLanguages languages = config.getExpressionLanguages();
- assert languages != null;
+ ExpressionLanguagesConfig elConfig = config.getExpressionLanguages();
+ assert elConfig != null;
- ExpressionLanguage[] array = languages.getExpressionLanguageArray();
- assert array != null;
+ ExpressionLanguageConfig[] els = elConfig.getExpressionLanguages();
+ assert els != null;
- for (int i = 0; i < array.length; i++) {
- String name = array[i].getName();
- String className = array[i].getFactoryClass();
-
- ExpressionEngineFactory factory = null;
- try {
- Class type = Class.forName(className);
- factory = (ExpressionEngineFactory) type.newInstance();
- } catch (ClassNotFoundException cnf) {
- if (_logger.isWarnEnabled())
- _logger.warn("Could not create an ExpressionEngineFactory for type \"" + className +
- "\" because the implementation class could not be found.");
-
- continue;
- } catch (Exception ex) {
- assert ex instanceof IllegalAccessException || ex instanceof InstantiationException;
-
- if (_logger.isWarnEnabled())
- _logger.warn("Could not create an ExpressionEngineFactory for type \"" + className +
- "\" because an error occurred creating the factory. Cause: " + ex, ex);
- continue;
- }
+ if (els != null) {
+ for (int i = 0; i < els.length; i++) {
+ String name = els[i].getName();
+ String className = els[i].getFactoryClass();
+
+ ExpressionEngineFactory factory = null;
+
+ try {
+ Class type = Class.forName(className);
+ factory = (ExpressionEngineFactory) type.newInstance();
+ } catch (ClassNotFoundException cnf) {
+ if (_logger.isWarnEnabled()) {
+ _logger.warn("Could not create an ExpressionEngineFactory for type \"" + className +
+ "\" because the implementation class could not be found.");
+ }
+
+ continue;
+ } catch (Exception ex) {
+ assert ex instanceof IllegalAccessException || ex instanceof InstantiationException;
+
+ if (_logger.isWarnEnabled()) {
+ _logger.warn("Could not create an ExpressionEngineFactory for type \"" + className +
+ "\" because an error occurred creating the factory. Cause: " + ex, ex);
+ }
+
+ continue;
+ }
+
+ if (factoryMap.containsKey(name)) {
+ if (_logger.isWarnEnabled()) {
+ _logger.warn("Overwriting a previously defined ExpressionEngineFactory named \"" + name +
+ "\" with a new ExpressionEngineFactory of type \"" + className + "\"");
+ } else {
+ _logger.info("Adding an ExpressionEngineFactory named \"" + name + "\" with implementation \"" +
+ className + "\"");
+ }
+ }
- if (factoryMap.containsKey(name))
- if (_logger.isWarnEnabled())
- _logger.warn("Overwriting a previously defined ExpressionEngineFactory named \"" + name +
- "\" with a new ExpressionEngineFactory of type \"" + className + "\"");
- else
- _logger.info("Adding an ExpressionEngineFactory named \"" + name + "\" with implementation \"" + className + "\"");
-
- factoryMap.put(name, factory);
+ factoryMap.put(name, factory);
+ }
}
ExpressionEngineFactory defaultEngineFactory = null;
- String defaultLanguage = languages.getDefaultLanguage();
+ String defaultLanguage = elConfig.getDefaultLanguage();
+
if (defaultLanguage != null) {
defaultEngineFactory = (ExpressionEngineFactory) factoryMap.get(defaultLanguage);
+
if (defaultEngineFactory != null) {
- if (_logger.isInfoEnabled())
- _logger.info("Using a default expression evaluator of type \"" + factoryMap.get(defaultLanguage).getClass().getName() + "\"");
+ if (_logger.isInfoEnabled()) {
+ _logger.info("Using a default expression evaluator of type \"" +
+ factoryMap.get(defaultLanguage).getClass().getName() + "\"");
+ }
} else {
- String msg =
- "The default ExpressionEvaluator named \"" + defaultLanguage + "\" was specified, but the ExpressionEngineFactory could not be found.";
- if (_logger.isWarnEnabled()) _logger.warn(msg);
+ String msg = "The default ExpressionEvaluator named \"" + defaultLanguage +
+ "\" was specified, but the ExpressionEngineFactory could not be found.";
+
+ if (_logger.isWarnEnabled()) {
+ _logger.warn(msg);
+ }
throw new RuntimeException(msg);
}
} else {
String msg = "There is no default expression engine specified.";
- if (_logger.isErrorEnabled()) _logger.error(msg);
+
+ if (_logger.isErrorEnabled()) {
+ _logger.error(msg);
+ }
+
throw new RuntimeException(msg);
}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigInitializationException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigInitializationException.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigInitializationException.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigInitializationException.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,7 @@
*/
package org.apache.ti.util.config;
+
/**
* <p/>
* Exception thrown when an error occurs loading the NetUI configuration file
@@ -24,8 +25,7 @@
* </p>
*/
public class ConfigInitializationException
- extends Exception {
-
+ extends RuntimeException {
/**
* Default constructor.
*/
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigUtil.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigUtil.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigUtil.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/ConfigUtil.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,152 +17,73 @@
*/
package org.apache.ti.util.config;
-import org.apache.ti.schema.config.NetuiConfigDocument;
-import org.apache.ti.schema.config.NetuiConfigDocument.NetuiConfig;
-import org.apache.ti.util.internal.InternalStringBuilder;
+import org.apache.ti.util.config.bean.NetUIConfig;
+import org.apache.ti.util.config.parser.NetUIConfigParser;
import org.apache.ti.util.logging.Logger;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
+import org.apache.ti.util.xml.XmlInputStreamResolver;
/**
- * <p/>
+ * <p>
* Utility class for reading properties from the NetUI configuration file.
- * <br/>
- * <br/>
- * The webapp runtime is read from the URL passed to the {@link #init} method.
- * The configuration should be initialized with this method and a valid URL
- * before the first time the {@link #getConfig()} method is called. If the configuration
- * has not been initialized, {@link #getConfig()} will initialize a bare bones runtime
+ * </p>
+ * <p>
+ * The webapp runtime is read from the {@link XmlInputStreamResolver} passed to the
+ * {@link #init(XmlInputStreamResolver)} method. The configuration should be initialized with
+ * this method before the first call to the {@link #getConfig()} method. If the configuration
+ * has not been initialized, {@link #getConfig()} will initialize a default, minimal runtime
* configuration. Depending on the web application, this default configuration
* may lead to runtime errors.
- * <br/>
- * <br/>
* </p>
*/
public class ConfigUtil {
-
- // @todo: need to change NetuiConfigDocument.NetuiConfig to NetUIConfig
- // @todo: need to provide a read-only implementation so that users can't edit the config file on the fly
-
private static final Logger LOGGER = Logger.getInstance(ConfigUtil.class);
-
- private static final String DEFAULT_CONFIG = "org/apache/ti/util/config/struts-ti-config-default.xml";
-
- private static NetuiConfigDocument _config = null;
+ private static NetUIConfig CONFIG_BEAN = null;
/* do not construct */
protected ConfigUtil() {
}
/**
- * <p/>
- * Initialize the NetUI configuration data.
- * <br/>
- * <br/>
- * This method can be called exactly once in a J2EE web application. The
- * URL parameter should reference a
- * netui-config.xml file. If an error occurs loading the configuration
- * file, a {@link ConfigInitializationException} will be thrown.
+ * <p>
+ * Initialize the NetUI configuration JavaBean.
+ * </p>
+ * <p>
+ * This method can be called exactly once in the a given J2EE web application. The provided
+ * {@link XmlInputStreamResolver} is used to resolve an {@link java.io.InputStream} that references
+ * a NetUI config file instance. If an error occurs loading the configuration, a
+ * {@link ConfigInitializationException} exception will be thrown.
* </p>
*
- * @param url the URL from which to read the configuration file
+ * @param xmlInputStreamResolver a resolver that can provide an InputStream to the config file
* @throws ConfigInitializationException thrown when an error occurs loading the configuration file
- * or when the configuration is reinitialized.
+ * or when the configuration is reinitialized.
*/
- public static final void init(URL url)
+ public static void init(XmlInputStreamResolver xmlInputStreamResolver)
throws ConfigInitializationException {
- if (_config != null)
+ if (CONFIG_BEAN != null) {
throw new ConfigInitializationException("Config initialization already completed; unable to reload the NetUI config file.");
+ }
- internalInit(url);
+ internalInit(xmlInputStreamResolver);
}
- public static final boolean isInit() {
- return (_config != null);
+ protected static void internalInit(XmlInputStreamResolver xmlInputStreamResolver) {
+ NetUIConfigParser configParser = new NetUIConfigParser();
+ CONFIG_BEAN = configParser.parse(xmlInputStreamResolver);
}
- /**
- * Internal method used to re-initialize the static class member that holds the
- * ConfigDocument. Note, this method does <b>no</b> checks to ensure that an
- * existing document is being overwritten. The behavior of ConfigUtil clients
- * is undefined if their initial configuration is re-loaded.
- *
- * @param url The URL that contains the config document to load
- * @throws ConfigInitializationException thrown when an error occurs loading the
- * configuration file.
- */
- protected static final void internalInit(URL url)
- throws ConfigInitializationException {
-
- // when initialized with a null URL, revert to using a default, barebones config file
- if (url == null) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- url = cl.getResource(DEFAULT_CONFIG);
-
- if (url == null)
- throw new ConfigInitializationException("The NetUI runtime could not find the default config file. " +
- "The webapp may not function properly.");
-
- if (LOGGER.isInfoEnabled())
- LOGGER.info("Loading the default NetUI config file. The runtime will be configured " +
- "with a set of minimum parameters.");
- }
-
- if (_config == null) {
- try {
- XmlOptions loadOptions = new XmlOptions();
- loadOptions.setLoadLineNumbers();
- _config = NetuiConfigDocument.Factory.parse(url, loadOptions);
- }
- // XmlException | IOException
- catch (Exception ex) {
- assert ex instanceof XmlException || ex instanceof IOException;
-
- throw new ConfigInitializationException("Unable load the NetUI config file. Cause: " + ex, ex);
- }
- }
-
- assert _config != null;
-
- // Validate the document.
- XmlOptions validateOptions = new XmlOptions();
- ArrayList errorList = new ArrayList();
- validateOptions.setErrorListener(errorList);
- boolean isValid = _config.validate(validateOptions);
-
- // Throw an exception if the XML is invalid.
- if (!isValid) {
- InternalStringBuilder msg = new InternalStringBuilder("Invalid NetUI configuration file.");
-
- for (int i = 0; i < errorList.size(); i++) {
- XmlError error = (XmlError) errorList.get(i);
- msg.append("\n line ");
- msg.append(error.getLine());
- msg.append(": ");
- msg.append(error.getMessage());
- msg.append(" (");
- msg.append(error.getCursorLocation().toString());
- msg.append(")");
- }
-
- throw new ConfigInitializationException(msg.toString());
- }
+ public static boolean isInit() {
+ return CONFIG_BEAN != null;
}
/**
- * Get the NetUI configuration object.
+ * Get the NetUI configuration JavaBean.
*
- * @return a configuration bean that contains data
- * parsed from the netui-config.xml file.
+ * @return a JavaBean that provides configuration information for the NetUI runtime.
*/
- public static NetuiConfig getConfig() {
- if (_config != null) {
- return _config.getNetuiConfig();
+ public static NetUIConfig getConfig() {
+ if (CONFIG_BEAN != null) {
+ return CONFIG_BEAN;
}
/*
If the config file wasn't initialized, attempt to initialize a configuration
@@ -172,9 +93,10 @@
/*
This hopefully never happens and would only occur if the default config file isn't found in the util JAR.
*/
- if (LOGGER.isErrorEnabled())
+ if (LOGGER.isErrorEnabled()) {
LOGGER.error("An error occurred parsing the default config file. " +
- "The NetUI runtime is not properly configured.");
+ "The NetUI runtime is not properly configured.");
+ }
throw new IllegalStateException("The NetUI runtime could not find the default config file. The webapp may not function properly.");
}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/BindingContextConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/BindingContextConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/BindingContextConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/BindingContextConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,40 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class BindingContextConfig {
+ private String _name;
+ private String _factoryClass;
+
+ public BindingContextConfig(String name, String factoryClass) {
+ _name = name;
+ _factoryClass = factoryClass;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getFactoryClass() {
+ return _factoryClass;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/CustomPropertyConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/CustomPropertyConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/CustomPropertyConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/CustomPropertyConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,40 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class CustomPropertyConfig {
+ private String _name;
+ private String _value;
+
+ public CustomPropertyConfig(String name, String value) {
+ _name = name;
+ _value = value;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getValue() {
+ return _value;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/DocType.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/DocType.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/DocType.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/DocType.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,101 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public final class DocType
+ implements java.io.Serializable {
+ public static final int INT_HTML4_LOOSE = 0;
+ public static final int INT_HTML4_LOOSE_QUIRKS = 1;
+ public static final int INT_XHTML1_TRANSITIONAL = 2;
+
+ /**
+ */
+ public static final DocType HTML4_LOOSE = new DocType(INT_HTML4_LOOSE);
+
+ /**
+ */
+ public static final DocType HTML4_LOOSE_QUIRKS = new DocType(INT_HTML4_LOOSE_QUIRKS);
+
+ /**
+ */
+ public static final DocType XHTML1_TRANSITIONAL = new DocType(INT_XHTML1_TRANSITIONAL);
+ private int _val;
+
+ private DocType(int val) {
+ _val = val;
+ }
+
+ /**
+ * Convert this doc type to a readable String.
+ * @return the readable doc type name
+ */
+ public String toString() {
+ switch (_val) {
+ case INT_HTML4_LOOSE:
+ return "html4-loose";
+
+ case INT_HTML4_LOOSE_QUIRKS:
+ return "html4-loose-quirks";
+
+ case INT_XHTML1_TRANSITIONAL:
+ return "xhtml1-transitional";
+ }
+
+ String message = "Encountered an unknown doc type with value \"" + _val + "\"";
+ assert false : message;
+ throw new IllegalStateException(message);
+ }
+
+ /**
+ * Equals method.
+ * @param value value to check
+ * @return <code>true</code> if this doc type matches the <code>value</code>; <code>false</code> otherwise.
+ */
+ public boolean equals(Object value) {
+ if (value == this) {
+ return true;
+ }
+
+ if ((value == null) || !(value instanceof DocType)) {
+ return false;
+ }
+
+ return ((DocType) value)._val == _val;
+ }
+
+ /**
+ * Hash code.
+ * @return the hash code
+ */
+ public int hashCode() {
+ return _val;
+ }
+
+ /**
+ * The doc type's int value.
+ *
+ * @return the doc type's value
+ */
+ public int getValue() {
+ return _val;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguageConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguageConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguageConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguageConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,46 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class ExpressionLanguageConfig {
+ private String _name;
+ private String _factoryClass;
+ private BindingContextConfig[] _bindingContexts;
+
+ public ExpressionLanguageConfig(String name, String factoryClass, BindingContextConfig[] bindingContexts) {
+ _name = name;
+ _factoryClass = factoryClass;
+ _bindingContexts = bindingContexts;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getFactoryClass() {
+ return _factoryClass;
+ }
+
+ public BindingContextConfig[] getBindingContexts() {
+ return _bindingContexts;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguagesConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguagesConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguagesConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/ExpressionLanguagesConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,40 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class ExpressionLanguagesConfig {
+ private String _defaultLanguage;
+ private ExpressionLanguageConfig[] _expressionLanguages;
+
+ public ExpressionLanguagesConfig(String defaultLanguage, ExpressionLanguageConfig[] expressionLanguages) {
+ _defaultLanguage = defaultLanguage;
+ _expressionLanguages = expressionLanguages;
+ }
+
+ public String getDefaultLanguage() {
+ return _defaultLanguage;
+ }
+
+ public ExpressionLanguageConfig[] getExpressionLanguages() {
+ return _expressionLanguages;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/GlobalPageFlowActionInterceptorConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/GlobalPageFlowActionInterceptorConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/GlobalPageFlowActionInterceptorConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/GlobalPageFlowActionInterceptorConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,41 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class GlobalPageFlowActionInterceptorConfig {
+ private SimpleActionInterceptorConfig[] _simpleActionInterceptor;
+ private InterceptorConfig[] _actionInterceptor;
+
+ public GlobalPageFlowActionInterceptorConfig(SimpleActionInterceptorConfig[] simpleActionInterceptor,
+ InterceptorConfig[] actionInterceptor) {
+ _simpleActionInterceptor = simpleActionInterceptor;
+ _actionInterceptor = actionInterceptor;
+ }
+
+ public SimpleActionInterceptorConfig[] getSimpleActionInterceptors() {
+ return _simpleActionInterceptor;
+ }
+
+ public InterceptorConfig[] getActionInterceptors() {
+ return _actionInterceptor;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/HandlerConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/HandlerConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/HandlerConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/HandlerConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,40 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class HandlerConfig {
+ private String _handlerClass;
+ private CustomPropertyConfig[] _customProperties;
+
+ public HandlerConfig(String handlerClass, CustomPropertyConfig[] customProperties) {
+ _handlerClass = handlerClass;
+ _customProperties = customProperties;
+ }
+
+ public String getHandlerClass() {
+ return _handlerClass;
+ }
+
+ public CustomPropertyConfig[] getCustomProperties() {
+ return _customProperties;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IdJavascript.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IdJavascript.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IdJavascript.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IdJavascript.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,101 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public final class IdJavascript
+ implements java.io.Serializable {
+ public static final int INT_DEFAULT = 0;
+ public static final int INT_LEGACY = 1;
+ public static final int INT_LEGACY_ONLY = 2;
+
+ /**
+ */
+ public static final IdJavascript DEFAULT = new IdJavascript(INT_DEFAULT);
+
+ /**
+ */
+ public static final IdJavascript LEGACY = new IdJavascript(INT_LEGACY);
+
+ /**
+ */
+ public static final IdJavascript LEGACY_ONLY = new IdJavascript(INT_LEGACY_ONLY);
+ private int _val;
+
+ private IdJavascript(int val) {
+ _val = val;
+ }
+
+ /**
+ * Convert this id javascript to a readable String.
+ * @return the readable id javascript name
+ */
+ public String toString() {
+ switch (_val) {
+ case INT_DEFAULT:
+ return "default";
+
+ case INT_LEGACY:
+ return "legacy";
+
+ case INT_LEGACY_ONLY:
+ return "legacyOnly";
+ }
+
+ String message = "Encountered an unknown id javascript with value \"" + _val + "\"";
+ assert false : message;
+ throw new IllegalStateException(message);
+ }
+
+ /**
+ * Equals method.
+ * @param value value to check
+ * @return <code>true</code> if this id javascript matches the <code>value</code>; <code>false</code> otherwise.
+ */
+ public boolean equals(Object value) {
+ if (value == this) {
+ return true;
+ }
+
+ if ((value == null) || !(value instanceof IdJavascript)) {
+ return false;
+ }
+
+ return ((IdJavascript) value)._val == _val;
+ }
+
+ /**
+ * Hash code.
+ * @return the hash code
+ */
+ public int hashCode() {
+ return _val;
+ }
+
+ /**
+ * The id javascript's int value.
+ *
+ * @return the id javascript's value
+ */
+ public int getValue() {
+ return _val;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/InterceptorConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/InterceptorConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/InterceptorConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/InterceptorConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,40 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class InterceptorConfig {
+ private String _interceptorClass;
+ private CustomPropertyConfig[] _customProperties;
+
+ public InterceptorConfig(String interceptorClass, CustomPropertyConfig[] customProperties) {
+ _interceptorClass = interceptorClass;
+ _customProperties = customProperties;
+ }
+
+ public String getInterceptorClass() {
+ return _interceptorClass;
+ }
+
+ public CustomPropertyConfig[] getCustomProperties() {
+ return _customProperties;
+ }
+}
Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IteratorFactoryConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IteratorFactoryConfig.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IteratorFactoryConfig.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/bean/IteratorFactoryConfig.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,40 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.ti.util.config.bean;
+
+
+/**
+ *
+ */
+public class IteratorFactoryConfig {
+ private String _name;
+ private String _factoryClass;
+
+ public IteratorFactoryConfig(String name, String factoryClass) {
+ _name = name;
+ _factoryClass = factoryClass;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getFactoryClass() {
+ return _factoryClass;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org