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/08/07 20:27:19 UTC
svn commit: r230688 - in /struts/sandbox/trunk/ti: ./
src/java/org/apache/ti/config/ src/java/org/apache/ti/processor/chain/
src/java/org/apache/ti/processor/chain/webwork/
Author: mrdon
Date: Sun Aug 7 11:27:17 2005
New Revision: 230688
URL: http://svn.apache.org/viewcvs?rev=230688&view=rev
Log:
* Integrated webwork global settings by hiding them behind ti settings
* Changing to jdtcore version that ibiblio had
* Adding automatic setting of config reloading when in dev mode
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/TiConfiguration.java
Modified:
struts/sandbox/trunk/ti/project.xml
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/spring-config-servlet.xml
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java
Modified: struts/sandbox/trunk/ti/project.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/project.xml?rev=230688&r1=230687&r2=230688&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/project.xml (original)
+++ struts/sandbox/trunk/ti/project.xml Sun Aug 7 11:27:17 2005
@@ -276,7 +276,7 @@
<dependency>
<groupId>eclipse</groupId>
<artifactId>jdtcore</artifactId>
- <version>3.1.0</version>
+ <version>3.0.1</version>
<properties>
<war.bundle>true</war.bundle>
</properties>
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/spring-config-servlet.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/spring-config-servlet.xml?rev=230688&r1=230687&r2=230688&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/spring-config-servlet.xml (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/spring-config-servlet.xml Sun Aug 7 11:27:17 2005
@@ -50,6 +50,11 @@
<property name="compilingObjectFactory" ref="compilingObjectFactory" />
<property name="devMode"><value>${ti.devMode}</value></property>
</bean>
+
+ <bean id="initWebWork" class="org.apache.ti.processor.chain.webwork.InitWebWork">
+ <property name="devMode"><value>${ti.devMode}</value></property>
+ </bean>
+
<bean id="initControllerContext" class="org.apache.ti.processor.chain.InitControllerContext">
<property name="controllerContext" ref="controllerContext" />
</bean>
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml?rev=230688&r1=230687&r2=230688&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml Sun Aug 7 11:27:17 2005
@@ -52,7 +52,7 @@
<chain name="init" >
<command name="initXWork" />
- <command name="initWebWork" className="org.apache.ti.processor.chain.webwork.InitWebWork"/>
+ <command name="initWebWork" />
</chain>
<chain name="process-action" className="org.apache.ti.processor.chain.ProcessActionChain">
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java?rev=230688&r1=230687&r2=230688&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/InitWebWork.java Sun Aug 7 11:27:17 2005
@@ -38,8 +38,21 @@
private static final Log log = LogFactory.getLog(InitWebWork.class);
+ private boolean devMode = false;
+
+ public void setDevMode(boolean devMode) {
+ this.devMode = devMode;
+ }
+
public boolean execute(Context origctx) {
- log.debug("Initializing webwork");
+ log.warn("Initializing webwork");
+
+ Configuration c = new TiConfiguration(origctx);
+ Configuration.setConfiguration(c);
+
+ if (devMode) {
+ c.set("webwork.configuration.xml.reload", "true");
+ }
LocalizedTextUtil.addDefaultResourceBundle("com/opensymphony/webwork/webwork-messages");
Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/TiConfiguration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/TiConfiguration.java?rev=230688&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/TiConfiguration.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/webwork/TiConfiguration.java Sun Aug 7 11:27:17 2005
@@ -0,0 +1,172 @@
+/*
+ * $Id: Init.java 230535 2005-08-06 07:56:40Z mrdon $
+ *
+ * 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.
+ */
+package org.apache.ti.processor.chain.webwork;
+
+import java.util.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.webwork.config.Configuration;
+import com.opensymphony.webwork.config.*;
+import com.opensymphony.xwork.util.LocalizedTextUtil;
+
+/**
+ * Initializes by replacing default factories
+ */
+public class TiConfiguration extends DefaultConfiguration {
+
+ private static final Log log = LogFactory.getLog(TiConfiguration.class);
+
+ private static final String WEBWORK_PREFIX = "webwork.";
+ private static final String TI_PREFIX = "ti.";
+
+ private Properties props;
+ private Configuration config;
+
+ public TiConfiguration(Map config) {
+ props = new Properties();
+ Map.Entry entry;
+ String key, newkey;
+ for (Iterator i = config.entrySet().iterator(); i.hasNext(); ) {
+ entry = (Map.Entry)i.next();
+ key = (String)entry.getKey();
+ if (key.startsWith(TI_PREFIX) && entry.getValue() instanceof String) {
+ newkey = WEBWORK_PREFIX + key.substring(TI_PREFIX.length());
+ props.setProperty(newkey, (String)entry.getValue());
+ }
+ }
+ init();
+ }
+
+ /**
+ * Creates a new DefaultConfiguration object by loading all property files
+ * and creating an internal {@link DelegatingConfiguration} object. All calls to get and set
+ * in this class will call that configuration object.
+ */
+ private void init() {
+ // Create default implementations
+ // Use default properties and webwork.properties
+ ArrayList list = new ArrayList();
+
+ try {
+ list.add(new PropertiesConfiguration("com/opensymphony/webwork/default"));
+ } catch (Exception e) {
+ log.error("Could not find com/opensymphony/webwork/default.properties", e);
+ }
+
+ Configuration[] configList = new Configuration[list.size()];
+ config = new DelegatingConfiguration((Configuration[]) list.toArray(configList));
+
+ // Add list of additional properties configurations
+ try {
+ StringTokenizer configFiles = new StringTokenizer((String) config.getImpl("webwork.custom.properties"), ",");
+
+ while (configFiles.hasMoreTokens()) {
+ String name = configFiles.nextToken();
+
+ try {
+ list.add(new PropertiesConfiguration(name));
+ } catch (Exception e) {
+ log.error("Could not find " + name + ".properties. Skipping");
+ }
+ }
+
+ configList = new Configuration[list.size()];
+ config = new DelegatingConfiguration((Configuration[]) list.toArray(configList));
+ } catch (IllegalArgumentException e) {
+ }
+
+ // Add addtional list of i18n global resource bundles
+ try {
+ StringTokenizer bundleFiles = new StringTokenizer((String) config.getImpl("webwork.custom.i18n.resources"), ", ");
+
+ while (bundleFiles.hasMoreTokens()) {
+ String name = bundleFiles.nextToken();
+
+ try {
+ log.info("Loading global messages from " + name);
+ LocalizedTextUtil.addDefaultResourceBundle(name);
+ } catch (Exception e) {
+ log.error("Could not find " + name + ".properties. Skipping");
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ // webwork.custom.i18n.resources wasn't provided
+ }
+ }
+
+ //~ Methods ////////////////////////////////////////////////////////////////
+
+ /**
+ * Sets the given property - delegates to the internal config implementation.
+ *
+ * @see #set(String, Object)
+ */
+ public void setImpl(String aName, Object aValue) throws IllegalArgumentException, UnsupportedOperationException {
+ config.setImpl(aName, aValue);
+ }
+
+ /**
+ * Gets the specified property - delegates to the internal config implementation.
+ *
+ * @see #get(String)
+ */
+ public Object getImpl(String aName) throws IllegalArgumentException {
+ // Delegate
+ String val = props.getProperty(aName);
+ if (val == null) {
+ return config.getImpl(aName);
+ } else {
+ return val;
+ }
+ }
+
+ /**
+ * Determines whether or not a value has been set - delegates to the internal config implementation.
+ *
+ * @see #isSet(String)
+ */
+ public boolean isSetImpl(String aName) {
+ String val = props.getProperty(aName);
+ if (val == null) {
+ return config.isSetImpl(aName);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns a list of all property names - delegates to the internal config implementation.
+ *
+ * @see #list()
+ */
+ public Iterator listImpl() {
+ ArrayList settingList = new ArrayList();
+ Iterator list = config.listImpl();
+
+ while (list.hasNext()) {
+ settingList.add(list.next());
+ }
+ list = props.keySet().iterator();
+ while (list.hasNext()) {
+ settingList.add(list.next());
+ }
+ return settingList.iterator();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org