http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java deleted file mode 100644 index 92f7ba7..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.config.Configuration; -import com.opensymphony.xwork2.config.ConfigurationException; -import com.opensymphony.xwork2.config.entities.ActionConfig; -import com.opensymphony.xwork2.config.entities.UnknownHandlerConfig; -import com.opensymphony.xwork2.inject.Container; -import com.opensymphony.xwork2.inject.Inject; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -/** - * Default implementation of UnknownHandlerManager - * - * @see com.opensymphony.xwork2.UnknownHandlerManager - */ -public class DefaultUnknownHandlerManager implements UnknownHandlerManager { - - private Container container; - - protected ArrayList<UnknownHandler> unknownHandlers; - - @Inject - public void setContainer(Container container) { - this.container = container; - try { - build(); - } catch (Exception e) { - throw new ConfigurationException(e); - } - } - - /** - * Builds a list of UnknownHandlers in the order specified by the configured "unknown-handler-stack". - * If "unknown-handler-stack" was not configured, all UnknownHandlers will be returned, in no specific order - */ - protected void build() throws Exception { - Configuration configuration = container.getInstance(Configuration.class); - ObjectFactory factory = container.getInstance(ObjectFactory.class); - - if (configuration != null && container != null) { - List<UnknownHandlerConfig> unkownHandlerStack = configuration.getUnknownHandlerStack(); - unknownHandlers = new ArrayList<>(); - - if (unkownHandlerStack != null && !unkownHandlerStack.isEmpty()) { - //get UnknownHandlers in the specified order - for (UnknownHandlerConfig unknownHandlerConfig : unkownHandlerStack) { - UnknownHandler uh = factory.buildUnknownHandler(unknownHandlerConfig.getName(), new HashMap<String, Object>()); - unknownHandlers.add(uh); - } - } else { - //add all available UnknownHandlers - Set<String> unknownHandlerNames = container.getInstanceNames(UnknownHandler.class); - for (String unknownHandlerName : unknownHandlerNames) { - UnknownHandler uh = container.getInstance(UnknownHandler.class, unknownHandlerName); - unknownHandlers.add(uh); - } - } - } - } - - /** - * Iterate over UnknownHandlers and return the result of the first one that can handle it - */ - public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) { - for (UnknownHandler unknownHandler : unknownHandlers) { - Result result = unknownHandler.handleUnknownResult(actionContext, actionName, actionConfig, resultCode); - if (result != null) { - return result; - } - } - - return null; - } - - /** - * Iterate over UnknownHandlers and return the result of the first one that can handle it - * - * @throws NoSuchMethodException - */ - public Object handleUnknownMethod(Object action, String methodName) throws NoSuchMethodException { - for (UnknownHandler unknownHandler : unknownHandlers) { - Object result = unknownHandler.handleUnknownActionMethod(action, methodName); - if (result != null) { - return result; - } - } - - return null; - } - - /** - * Iterate over UnknownHandlers and return the result of the first one that can handle it - */ - public ActionConfig handleUnknownAction(String namespace, String actionName) { - for (UnknownHandler unknownHandler : unknownHandlers) { - ActionConfig result = unknownHandler.handleUnknownAction(namespace, actionName); - if (result != null) { - return result; - } - } - - return null; - } - - public boolean hasUnknownHandlers() { - return unknownHandlers != null && !unknownHandlers.isEmpty(); - } - - public List<UnknownHandler> getUnknownHandlers() { - return unknownHandlers; - } -}
http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java deleted file mode 100644 index 5c6806b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.opensymphony.xwork2; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Collection; - -/** - * Basic interface to access file on the File System and to monitor changes - */ -public interface FileManager { - - /** - * Enables configs reloading when config file changed - * - * @param reloadingConfigs {@link XWorkConstants#RELOAD_XML_CONFIGURATION} - */ - void setReloadingConfigs(boolean reloadingConfigs); - - /** - * Checks if given file changed and must be reloaded if {@link #setReloadingConfigs(boolean)} is true - * - * @param fileName to check - * @return true if file changed - */ - boolean fileNeedsReloading(String fileName); - - /** - * Checks if file represented by provided URL should be reloaded - * - * @param fileUrl url to a file - * @return true if file exists and should be reloaded, if url is null return false - */ - boolean fileNeedsReloading(URL fileUrl); - - /** - * Loads opens the named file and returns the InputStream - * - * @param fileUrl - the URL of the file to open - * @return an InputStream of the file contents or null - * @throws IllegalArgumentException if there is no file with the given file name - */ - InputStream loadFile(URL fileUrl); - - /** - * Adds file to list of monitored files if {@link #setReloadingConfigs(boolean)} is true - * - * @param fileUrl {@link URL} to file to be monitored - */ - void monitorFile(URL fileUrl); - - /** - * Convert URLs to URLs with "file" protocol - * @param url URL to convert to a jar url - * @return a URL to a file, or null if the URL external form cannot be parsed - */ - URL normalizeToFileProtocol(URL url); - - /** - * Indicate if given implementation supports current OS File System - * - * @return true if supports current OS File System - */ - boolean support(); - - /** - * User's implementation should return false as then it will be taken in first place - * - * @return true if it's a framework provided implementation - */ - boolean internal(); - - Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/FileManagerFactory.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/FileManagerFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/FileManagerFactory.java deleted file mode 100644 index f0eafc0..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/FileManagerFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.opensymphony.xwork2; - -/** - * Factory that creates FileManager, default to {@link com.opensymphony.xwork2.util.fs.DefaultFileManager} - */ -public interface FileManagerFactory { - - void setReloadingConfigs(String reloadingConfigs); - - FileManager getFileManager(); - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/InvalidMetadataException.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/InvalidMetadataException.java b/xwork-core/src/main/java/com/opensymphony/xwork2/InvalidMetadataException.java deleted file mode 100644 index eb556f5..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/InvalidMetadataException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -/** - * <code>InvalidMetadataException</code> - * - * @author Rainer Hermanns - * @version $Id$ - */ -public class InvalidMetadataException extends RuntimeException { - - /** - * Create a new <code>InvalidMetadataException</code> with the supplied error message. - * - * @param msg the error message - */ - public InvalidMetadataException(String msg) { - super(msg); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/LocaleProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/LocaleProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/LocaleProvider.java deleted file mode 100644 index 6fc4ea9..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/LocaleProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import java.util.Locale; - - -/** - * Indicates that the implementing class can provide its own {@link Locale}. - * <p/> - * This is useful for when an action may wish override the default locale. All that is - * needed is to implement this interface and return your own custom locale. - * The {@link TextProvider} interface uses this interface heavily for retrieving - * internationalized messages from resource bundles. - * - * @author Jason Carreira - */ -public interface LocaleProvider { - - /** - * Gets the provided locale. - * - * @return the locale. - */ - Locale getLocale(); - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/MockActionInvocation.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/MockActionInvocation.java b/xwork-core/src/main/java/com/opensymphony/xwork2/MockActionInvocation.java deleted file mode 100644 index 3eea89b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/MockActionInvocation.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -/** - * Mock for an {@link ActionInvocation}. - * - * @author plightbo - * @deprecated Please use @see com.opensymphony.xwork2.mock.MockActionInvocation instead - */ -@Deprecated public class MockActionInvocation extends com.opensymphony.xwork2.mock.MockActionInvocation { -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/ModelDriven.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ModelDriven.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ModelDriven.java deleted file mode 100644 index 2f5f6c7..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ModelDriven.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - - -/** - * ModelDriven Actions provide a model object to be pushed onto the ValueStack - * in addition to the Action itself, allowing a FormBean type approach like Struts. - * - * @author Jason Carreira - */ -public interface ModelDriven<T> { - - /** - * Gets the model to be pushed onto the ValueStack instead of the Action itself. - * - * @return the model - */ - T getModel(); - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java deleted file mode 100644 index f1a6c7f..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.config.ConfigurationException; -import com.opensymphony.xwork2.config.entities.ActionConfig; -import com.opensymphony.xwork2.config.entities.InterceptorConfig; -import com.opensymphony.xwork2.config.entities.ResultConfig; -import com.opensymphony.xwork2.conversion.TypeConverter; -import com.opensymphony.xwork2.factory.*; -import com.opensymphony.xwork2.inject.Container; -import com.opensymphony.xwork2.inject.Inject; -import com.opensymphony.xwork2.interceptor.Interceptor; -import com.opensymphony.xwork2.util.ClassLoaderUtil; -import com.opensymphony.xwork2.validator.Validator; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.Serializable; -import java.util.Map; - - -/** - * ObjectFactory is responsible for building the core framework objects. Users may register their - * own implementation of the ObjectFactory to control instantiation of these Objects. - * <p/> - * This default implementation uses the {@link #buildBean(Class,java.util.Map) buildBean} - * method to create all classes (interceptors, actions, results, etc). - * <p/> - * - * @author Jason Carreira - */ -public class ObjectFactory implements Serializable { - - private static final Logger LOG = LogManager.getLogger(ObjectFactory.class); - - private transient ClassLoader ccl; - private Container container; - - private ActionFactory actionFactory; - private ResultFactory resultFactory; - private InterceptorFactory interceptorFactory; - private ValidatorFactory validatorFactory; - private ConverterFactory converterFactory; - private UnknownHandlerFactory unknownHandlerFactory; - - @Inject(value="objectFactory.classloader", required=false) - public void setClassLoader(ClassLoader cl) { - this.ccl = cl; - } - - @Inject - public void setContainer(Container container) { - this.container = container; - } - - @Inject - public void setActionFactory(ActionFactory actionFactory) { - this.actionFactory = actionFactory; - } - - @Inject - public void setResultFactory(ResultFactory resultFactory) { - this.resultFactory = resultFactory; - } - - @Inject - public void setInterceptorFactory(InterceptorFactory interceptorFactory) { - this.interceptorFactory = interceptorFactory; - } - - @Inject - public void setValidatorFactory(ValidatorFactory validatorFactory) { - this.validatorFactory = validatorFactory; - } - - @Inject - public void setConverterFactory(ConverterFactory converterFactory) { - this.converterFactory = converterFactory; - } - - @Inject - public void setUnknownHandlerFactory(UnknownHandlerFactory unknownHandlerFactory) { - this.unknownHandlerFactory = unknownHandlerFactory; - } - - /** - * @deprecated Since 2.1 - */ - @Deprecated public static ObjectFactory getObjectFactory() { - return ActionContext.getContext().getContainer().getInstance(ObjectFactory.class); - } - - /** - * Allows for ObjectFactory implementations that support - * Actions without no-arg constructors. - * - * @return true if no-arg constructor is required, false otherwise - */ - public boolean isNoArgConstructorRequired() { - return true; - } - - /** - * Utility method to obtain the class matched to className. Caches look ups so that subsequent - * lookups will be faster. - * - * @param className The fully qualified name of the class to return - * @return The class itself - * @throws ClassNotFoundException - */ - public Class getClassInstance(String className) throws ClassNotFoundException { - if (ccl != null) { - return ccl.loadClass(className); - } - - return ClassLoaderUtil.loadClass(className, this.getClass()); - } - - /** - * Build an instance of the action class to handle a particular request (eg. web request) - * @param actionName the name the action configuration is set up with in the configuration - * @param namespace the namespace the action is configured in - * @param config the action configuration found in the config for the actionName / namespace - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - * @return instance of the action class to handle a web request - * @throws Exception - */ - public Object buildAction(String actionName, String namespace, ActionConfig config, Map<String, Object> extraContext) throws Exception { - return actionFactory.buildAction(actionName, namespace, config, extraContext); - } - - /** - * Build a generic Java object of the given type. - * - * @param clazz the type of Object to build - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - */ - public Object buildBean(Class clazz, Map<String, Object> extraContext) throws Exception { - return clazz.newInstance(); - } - - /** - * @param obj - */ - protected Object injectInternalBeans(Object obj) { - if (obj != null && container != null) { - container.inject(obj); - } - return obj; - } - - /** - * Build a generic Java object of the given type. - * - * @param className the type of Object to build - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - */ - public Object buildBean(String className, Map<String, Object> extraContext) throws Exception { - return buildBean(className, extraContext, true); - } - - /** - * Build a generic Java object of the given type. - * - * @param className the type of Object to build - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - */ - public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception { - Class clazz = getClassInstance(className); - Object obj = buildBean(clazz, extraContext); - if (injectInternal) { - injectInternalBeans(obj); - } - return obj; - } - - /** - * Builds an Interceptor from the InterceptorConfig and the Map of - * parameters from the interceptor reference. Implementations of this method - * should ensure that the Interceptor is parameterized with both the - * parameters from the Interceptor config and the interceptor ref Map (the - * interceptor ref params take precedence), and that the Interceptor.init() - * method is called on the Interceptor instance before it is returned. - * - * @param interceptorConfig the InterceptorConfig from the configuration - * @param interceptorRefParams a Map of params provided in the Interceptor reference in the - * Action mapping or InterceptorStack definition - */ - public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map<String, String> interceptorRefParams) throws ConfigurationException { - return interceptorFactory.buildInterceptor(interceptorConfig, interceptorRefParams); - } - - /** - * Build a Result using the type in the ResultConfig and set the parameters in the ResultConfig. - * - * @param resultConfig the ResultConfig found for the action with the result code returned - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - */ - public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception { - return resultFactory.buildResult(resultConfig, extraContext); - } - - /** - * Build a Validator of the given type and set the parameters on it - * - * @param className the type of Validator to build - * @param params property name -> value Map to set onto the Validator instance - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - */ - public Validator buildValidator(String className, Map<String, Object> params, Map<String, Object> extraContext) throws Exception { - return validatorFactory.buildValidator(className, params, extraContext); - } - - /** - * Build converter of given type - * - * @param converterClass to instantiate - * @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext} - * @return instance of converterClass with inject dependencies - */ - public TypeConverter buildConverter(Class<? extends TypeConverter> converterClass, Map<String, Object> extraContext) throws Exception { - return converterFactory.buildConverter(converterClass, extraContext); - } - - /** - * Builds unknown handler - * - * @param unknownHandlerName - * @param extraContext - * @return - * @throws Exception - */ - public UnknownHandler buildUnknownHandler(String unknownHandlerName, Map<String, Object> extraContext) throws Exception { - return unknownHandlerFactory.buildUnknownHandler(unknownHandlerName, extraContext); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/Preparable.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/Preparable.java b/xwork-core/src/main/java/com/opensymphony/xwork2/Preparable.java deleted file mode 100644 index 58a2412..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/Preparable.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - - -/** - * Preparable Actions will have their <code>prepare()</code> method called if the {@link com.opensymphony.xwork2.interceptor.PrepareInterceptor} - * is applied to the ActionConfig. - * - * @author Jason Carreira - * @see com.opensymphony.xwork2.interceptor.PrepareInterceptor - */ -public interface Preparable { - - /** - * This method is called to allow the action to prepare itself. - * - * @throws Exception thrown if a system level exception occurs. - */ - void prepare() throws Exception; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/ResourceBundleTextProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ResourceBundleTextProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ResourceBundleTextProvider.java deleted file mode 100644 index 1415e71..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ResourceBundleTextProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - -import java.util.ResourceBundle; - -/** - * Extension Interface for TextProvider to help supporting ResourceBundles. - * - * @author Rene Gielen - */ -public interface ResourceBundleTextProvider extends TextProvider { - - /** - * Set the resource bundle to use. - * - * @param bundle the bundle to use. - */ - void setBundle(ResourceBundle bundle); - - /** - * Set the class to use for reading the resource bundle. - * - * @param clazz the class to use for loading. - */ - void setClazz(Class clazz); - - /** - * Set the LocaleProvider to use. - * - * @param localeProvider the LocaleProvider to use. - */ - void setLocaleProvider(LocaleProvider localeProvider); - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/Result.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/Result.java b/xwork-core/src/main/java/com/opensymphony/xwork2/Result.java deleted file mode 100644 index 3d65377..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/Result.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - -import java.io.Serializable; - - -/** - * All results (except for <code>Action.NONE</code>) of an {@link Action} are mapped to a View implementation. - * <p/> - * Examples of Views might be: - * <ul> - * <li>SwingPanelView - pops up a new Swing panel</li> - * <li>ActionChainView - executes another action</li> - * <li>SerlvetRedirectView - redirects the HTTP response to a URL</li> - * <li>ServletDispatcherView - dispatches the HTTP response to a URL</li> - * </ul> - * - * @author plightbo - */ -public interface Result extends Serializable { - - /** - * Represents a generic interface for all action execution results. - * Whether that be displaying a webpage, generating an email, sending a JMS message, etc. - * - * @param invocation the invocation context. - * @throws Exception can be thrown. - */ - public void execute(ActionInvocation invocation) throws Exception; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/TestNGXWorkTestCase.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/TestNGXWorkTestCase.java b/xwork-core/src/main/java/com/opensymphony/xwork2/TestNGXWorkTestCase.java deleted file mode 100644 index 823e764..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/TestNGXWorkTestCase.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.config.Configuration; -import com.opensymphony.xwork2.config.ConfigurationManager; -import com.opensymphony.xwork2.config.ConfigurationProvider; -import com.opensymphony.xwork2.config.impl.MockConfiguration; -import com.opensymphony.xwork2.inject.Container; -import com.opensymphony.xwork2.util.XWorkTestCaseHelper; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; - -/** - * Base test class for TestNG unit tests. Provides common XWork variables - * and performs XWork setup and teardown processes - */ -public class TestNGXWorkTestCase { - - protected ConfigurationManager configurationManager; - protected Configuration configuration; - protected Container container; - protected ActionProxyFactory actionProxyFactory; - - @BeforeTest - protected void setUp() throws Exception { - configurationManager = XWorkTestCaseHelper.setUp(); - configuration = new MockConfiguration(); - ((MockConfiguration) configuration).selfRegister(); - container = configuration.getContainer(); - actionProxyFactory = container.getInstance(ActionProxyFactory.class); - } - - @AfterTest - protected void tearDown() throws Exception { - XWorkTestCaseHelper.tearDown(configurationManager); - configurationManager = null; - configuration = null; - container = null; - actionProxyFactory = null; - } - - protected void loadConfigurationProviders(ConfigurationProvider... providers) { - configurationManager = XWorkTestCaseHelper.loadConfigurationProviders(configurationManager, providers); - configuration = configurationManager.getConfiguration(); - container = configuration.getContainer(); - actionProxyFactory = container.getInstance(ActionProxyFactory.class); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/TextProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/TextProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/TextProvider.java deleted file mode 100644 index aed8479..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/TextProvider.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.util.ValueStack; - -import java.util.List; -import java.util.ResourceBundle; - - -/** - * Provides access to {@link ResourceBundle}s and their underlying text messages. - * Implementing classes can delegate {@link TextProviderSupport}. Messages will be - * searched in multiple resource bundles, starting with the one associated with - * this particular class (action in most cases), continuing to try the message - * bundle associated with each superclass as well. It will stop once a bundle is - * found that contains the given text. This gives a cascading style that allow - * global texts to be defined for an application base class. - * <p/> - * You can override {@link LocaleProvider#getLocale()} to change the behaviour of how - * to choose locale for the bundles that are returned. Typically you would - * use the {@link LocaleProvider} interface to get the users configured locale. - * <p/> - * When you want to use your own implementation for Struts 2 project you have to define following - * bean and constant in struts.xml: - * <bean class="org.demo.MyTextProvider" name="myTextProvider" type="com.opensymphony.xwork2.TextProvider" /> - * <constant name="struts.xworkTextProvider" value="myTextProvider" /> - * <p/> - * if you want to also use your implementation for framework's messages define another constant (remember to put - * into it all framework messages) - * <constant name="system" value="myTextProvider" /> - * <p/> - * Take a look on {@link com.opensymphony.xwork2.ActionSupport} for example TextProvider implemntation. - * - * @author Jason Carreira - * @author Rainer Hermanns - * @see LocaleProvider - * @see TextProviderSupport - */ -public interface TextProvider { - - /** - * Checks if a message key exists. - * - * @param key message key to check for - * @return boolean true if key exists, false otherwise. - */ - boolean hasKey(String key); - - /** - * Gets a message based on a message key or if no message is found the provided key - * is returned. - * - * @param key the resource bundle key that is to be searched for - * @return the message as found in the resource bundle, or the provided key if none is found. - */ - String getText(String key); - - /** - * Gets a message based on a key, or, if the message is not found, a supplied - * default value is returned. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - String getText(String key, String defaultValue); - - /** - * Gets a message based on a key using the supplied obj, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param obj obj to be used in a {@link java.text.MessageFormat} message - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - String getText(String key, String defaultValue, String obj); - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat} or the provided key if no message is found. - * - * @param key the resource bundle key that is to be searched for - * @param args a list args to be used in a {@link java.text.MessageFormat} message - * @return the message as found in the resource bundle, or the provided key if none is found. - */ - String getText(String key, List<?> args); - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or the provided key if no message is found. - * - * @param key the resource bundle key that is to be searched for - * @param args an array args to be used in a {@link java.text.MessageFormat} message - * @return the message as found in the resource bundle, or the provided key if none is found. - */ - String getText(String key, String[] args); - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param args a list args to be used in a {@link java.text.MessageFormat} message - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - String getText(String key, String defaultValue, List<?> args); - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param args an array args to be used in a {@link java.text.MessageFormat} message - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - String getText(String key, String defaultValue, String[] args); - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. Instead of using the value stack in the ActionContext - * this version of the getText() method uses the provided value stack. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param args a list args to be used in a {@link java.text.MessageFormat} message - * @param stack the value stack to use for finding the text - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - String getText(String key, String defaultValue, List<?> args, ValueStack stack); - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. Instead of using the value stack in the ActionContext - * this version of the getText() method uses the provided value stack. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param args an array args to be used in a {@link java.text.MessageFormat} message - * @param stack the value stack to use for finding the text - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - String getText(String key, String defaultValue, String[] args, ValueStack stack); - - /** - * Get the named bundle, such as "com/acme/Foo". - * - * @param bundleName the name of the resource bundle, such as <code>"com/acme/Foo"</code>. - * @return the bundle - */ - ResourceBundle getTexts(String bundleName); - - /** - * Get the resource bundle associated with the implementing class (usually an action). - * - * @return the bundle - */ - ResourceBundle getTexts(); -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java deleted file mode 100644 index 331d534..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.inject.Inject; - -import java.util.ResourceBundle; - -/** - * This factory enables users to provide and correctly initialize a custom TextProvider. - * - * @author Oleg Gorobets - * @author Rene Gielen - */ -public class TextProviderFactory { - - private TextProvider textProvider; - - @Inject - public void setTextProvider(TextProvider textProvider) { - this.textProvider = textProvider; - } - - public TextProvider createInstance(Class clazz, LocaleProvider provider) { - TextProvider instance = getTextProvider(clazz, provider); - if (instance instanceof ResourceBundleTextProvider) { - ((ResourceBundleTextProvider) instance).setClazz(clazz); - ((ResourceBundleTextProvider) instance).setLocaleProvider(provider); - } - return instance; - } - - public TextProvider createInstance(ResourceBundle bundle, LocaleProvider provider) { - TextProvider instance = getTextProvider(bundle, provider); - if (instance instanceof ResourceBundleTextProvider) { - ((ResourceBundleTextProvider) instance).setBundle(bundle); - ((ResourceBundleTextProvider) instance).setLocaleProvider(provider); - } - return instance; - } - - protected TextProvider getTextProvider(Class clazz, LocaleProvider provider) { - if (this.textProvider == null) { - return new TextProviderSupport(clazz, provider); - } else { - return textProvider; - } - } - - private TextProvider getTextProvider(ResourceBundle bundle, LocaleProvider provider) { - if (this.textProvider == null) { - return new TextProviderSupport(bundle, provider); - } else { - return textProvider; - } - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java b/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java deleted file mode 100644 index 8b641a4..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/TextProviderSupport.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.inject.Inject; -import com.opensymphony.xwork2.util.LocalizedTextUtil; -import com.opensymphony.xwork2.util.ValueStack; - -import java.util.*; - - -/** - * Default TextProvider implementation. - * - * @author Jason Carreira - * @author Rainer Hermanns - */ -public class TextProviderSupport implements ResourceBundleTextProvider { - - private Class clazz; - private LocaleProvider localeProvider; - private ResourceBundle bundle; - - /** - * Default constructor - */ - public TextProviderSupport() { - } - - /** - * Constructor. - * - * @param clazz a clazz to use for reading the resource bundle. - * @param provider a locale provider. - */ - public TextProviderSupport(Class clazz, LocaleProvider provider) { - this.clazz = clazz; - this.localeProvider = provider; - } - - /** - * Constructor. - * - * @param bundle the resource bundle. - * @param provider a locale provider. - */ - public TextProviderSupport(ResourceBundle bundle, LocaleProvider provider) { - this.bundle = bundle; - this.localeProvider = provider; - } - - /** - * @param bundle the resource bundle. - */ - public void setBundle(ResourceBundle bundle) { - this.bundle = bundle; - } - - /** - * @param clazz a clazz to use for reading the resource bundle. - */ - public void setClazz(Class clazz) { - this.clazz = clazz; - } - - - /** - * @param localeProvider a locale provider. - */ - @Inject - public void setLocaleProvider(LocaleProvider localeProvider) { - this.localeProvider = localeProvider; - } - - - /** - * Checks if a key is available in the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. - */ - public boolean hasKey(String key) { - String message; - if (clazz != null) { - message = LocalizedTextUtil.findText(clazz, key, getLocale(), null, new Object[0] ); - } else { - message = LocalizedTextUtil.findText(bundle, key, getLocale(), null, new Object[0]); - } - return message != null; - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. - * - * @param key name of text to be found - * @return value of named text or the provided key if no value is found - */ - public String getText(String key) { - return getText(key, key, Collections.emptyList()); - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. If no text is found for this text name, the default value is returned. - * - * @param key name of text to be found - * @param defaultValue the default value which will be returned if no text is found - * @return value of named text or the provided defaultValue if no value is found - */ - public String getText(String key, String defaultValue) { - return getText(key, defaultValue, Collections.emptyList()); - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. If no text is found for this text name, the default value is returned. - * - * @param key name of text to be found - * @param defaultValue the default value which will be returned if no text is found - * @return value of named text or the provided defaultValue if no value is found - */ - public String getText(String key, String defaultValue, String arg) { - List<Object> args = new ArrayList<>(); - args.add(arg); - return getText(key, defaultValue, args); - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. If no text is found for this text name, the default value is returned. - * - * @param key name of text to be found - * @param args a List of args to be used in a MessageFormat message - * @return value of named text or the provided key if no value is found - */ - public String getText(String key, List<?> args) { - return getText(key, key, args); - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. If no text is found for this text name, the default value is returned. - * - * @param key name of text to be found - * @param args an array of args to be used in a MessageFormat message - * @return value of named text or the provided key if no value is found - */ - public String getText(String key, String[] args) { - return getText(key, key, args); - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. If no text is found for this text name, the default value is returned. - * - * @param key name of text to be found - * @param defaultValue the default value which will be returned if no text is found - * @param args a List of args to be used in a MessageFormat message - * @return value of named text or the provided defaultValue if no value is found - */ - public String getText(String key, String defaultValue, List<?> args) { - Object[] argsArray = ((args != null && !args.equals(Collections.emptyList())) ? args.toArray() : null); - if (clazz != null) { - return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, argsArray); - } else { - return LocalizedTextUtil.findText(bundle, key, getLocale(), defaultValue, argsArray); - } - } - - /** - * Get a text from the resource bundles associated with this action. - * The resource bundles are searched, starting with the one associated - * with this particular action, and testing all its superclasses' bundles. - * It will stop once a bundle is found that contains the given text. This gives - * a cascading style that allow global texts to be defined for an application base - * class. If no text is found for this text name, the default value is returned. - * - * @param key name of text to be found - * @param defaultValue the default value which will be returned if no text is found - * @param args an array of args to be used in a MessageFormat message - * @return value of named text or the provided defaultValue if no value is found - */ - public String getText(String key, String defaultValue, String[] args) { - if (clazz != null) { - return LocalizedTextUtil.findText(clazz, key, getLocale(), defaultValue, args); - } else { - return LocalizedTextUtil.findText(bundle, key, getLocale(), defaultValue, args); - } - } - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. Instead of using the value stack in the ActionContext - * this version of the getText() method uses the provided value stack. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param args a list args to be used in a {@link java.text.MessageFormat} message - * @param stack the value stack to use for finding the text - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - public String getText(String key, String defaultValue, List<?> args, ValueStack stack) { - Object[] argsArray = ((args != null) ? args.toArray() : null); - Locale locale; - if (stack == null){ - locale = getLocale(); - }else{ - locale = (Locale) stack.getContext().get(ActionContext.LOCALE); - } - if (locale == null) { - locale = getLocale(); - } - if (clazz != null) { - return LocalizedTextUtil.findText(clazz, key, locale, defaultValue, argsArray, stack); - } else { - return LocalizedTextUtil.findText(bundle, key, locale, defaultValue, argsArray, stack); - } - } - - - /** - * Gets a message based on a key using the supplied args, as defined in - * {@link java.text.MessageFormat}, or, if the message is not found, a supplied - * default value is returned. Instead of using the value stack in the ActionContext - * this version of the getText() method uses the provided value stack. - * - * @param key the resource bundle key that is to be searched for - * @param defaultValue the default value which will be returned if no message is found - * @param args an array args to be used in a {@link java.text.MessageFormat} message - * @param stack the value stack to use for finding the text - * @return the message as found in the resource bundle, or defaultValue if none is found - */ - public String getText(String key, String defaultValue, String[] args, ValueStack stack) { - Locale locale; - if (stack == null){ - locale = getLocale(); - }else{ - locale = (Locale) stack.getContext().get(ActionContext.LOCALE); - } - if (locale == null) { - locale = getLocale(); - } - if (clazz != null) { - return LocalizedTextUtil.findText(clazz, key, locale, defaultValue, args, stack); - } else { - return LocalizedTextUtil.findText(bundle, key, locale, defaultValue, args, stack); - } - - } - - /** - * Get the named bundle. - * <p/> - * You can override the getLocale() methodName to change the behaviour of how - * to choose locale for the bundles that are returned. Typically you would - * use the TextProvider interface to get the users configured locale, or use - * your own methodName to allow the user to select the locale and store it in - * the session (by using the SessionAware interface). - * - * @param aBundleName bundle name - * @return a resource bundle - */ - public ResourceBundle getTexts(String aBundleName) { - return LocalizedTextUtil.findResourceBundle(aBundleName, getLocale()); - } - - /** - * Get the resource bundle associated with this action. - * This will be based on the actual subclass that is used. - * - * @return resouce bundle - */ - public ResourceBundle getTexts() { - if (clazz != null) { - return getTexts(clazz.getName()); - } - return bundle; - } - - /** - * Get's the locale from the localeProvider. - * - * @return the locale from the localeProvider. - */ - private Locale getLocale() { - return localeProvider.getLocale(); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/Unchainable.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/Unchainable.java b/xwork-core/src/main/java/com/opensymphony/xwork2/Unchainable.java deleted file mode 100644 index 19d88ef..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/Unchainable.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -/** - * Simple marker interface to indicate an object should <b>not</b> have its properties copied during chaining. - * - * @see com.opensymphony.xwork2.interceptor.ChainingInterceptor - */ -public interface Unchainable { -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java b/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java deleted file mode 100644 index faabfc0..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.config.entities.ActionConfig; - -/** - * Handles cases when the result or action is unknown. - * <p/> - * This allows other classes like Struts plugins to provide intelligent defaults easier. - */ -public interface UnknownHandler { - - /** - * Handles the case when an action configuration is unknown. Implementations can return a new ActionConfig - * to be used to process the request. - * - * @param namespace The namespace - * @param actionName The action name - * @return An generated ActionConfig, can return <tt>null</tt> - * @throws XWorkException - */ - public ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException; - - /** - * Handles the case when a result cannot be found for an action and result code. - * - * @param actionContext The action context - * @param actionName The action name - * @param actionConfig The action config - * @param resultCode The returned result code - * @return A result to be executed, can return <tt>null</tt> - * @throws XWorkException - */ - public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws XWorkException; - - /** - * Handles the case when an action method cannot be found. This method is responsible both for finding the method and executing it. - * - * @since 2.1 - * @param action The action object - * @param methodName The method name to call - * @return The result returned from invoking the action method, can return <tt>null</tt> - * @deprecated @throws NoSuchMethodException If the method cannot be found should return null instead, - * don't throw exception as other UnknownHandles won't be invoked - * 'throws NoSuchMethodException' signature will be removed with next - * major release - */ - public Object handleUnknownActionMethod(Object action, String methodName) throws NoSuchMethodException; -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java deleted file mode 100644 index 325c0ff..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/UnknownHandlerManager.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.config.entities.ActionConfig; - -import java.util.List; - -/** - * An unknown handler manager contains a list of UnknownHandler and iterates on them by order - * - * @see com.opensymphony.xwork2.DefaultUnknownHandlerManager - */ -public interface UnknownHandlerManager { - Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode); - - Object handleUnknownMethod(Object action, String methodName) throws NoSuchMethodException; - - ActionConfig handleUnknownAction(String namespace, String actionName); - - boolean hasUnknownHandlers(); - - List<UnknownHandler> getUnknownHandlers(); -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/Validateable.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/Validateable.java b/xwork-core/src/main/java/com/opensymphony/xwork2/Validateable.java deleted file mode 100644 index 889a284..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/Validateable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - - -/** - * Provides an interface in which a call for a validation check can be done. - * - * @author Jason Carreira - * @see ActionSupport - * @see com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor - */ -public interface Validateable { - - /** - * Performs validation. - */ - void validate(); - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAware.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAware.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAware.java deleted file mode 100644 index 4ae5e84..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAware.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2002-2007,2009 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 com.opensymphony.xwork2; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ValidationAware classes can accept Action (class level) or field level error messages. Action level messages are kept - * in a Collection. Field level error messages are kept in a Map from String field name to a List of field error msgs. - * - * @author plightbo - */ -public interface ValidationAware { - - /** - * Set the Collection of Action-level String error messages. - * - * @param errorMessages Collection of String error messages - */ - void setActionErrors(Collection<String> errorMessages); - - /** - * Get the Collection of Action-level error messages for this action. Error messages should not - * be added directly here, as implementations are free to return a new Collection or an - * Unmodifiable Collection. - * - * @return Collection of String error messages - */ - Collection<String> getActionErrors(); - - /** - * Set the Collection of Action-level String messages (not errors). - * - * @param messages Collection of String messages (not errors). - */ - void setActionMessages(Collection<String> messages); - - /** - * Get the Collection of Action-level messages for this action. Messages should not be added - * directly here, as implementations are free to return a new Collection or an Unmodifiable - * Collection. - * - * @return Collection of String messages - */ - Collection<String> getActionMessages(); - - /** - * Set the field error map of fieldname (String) to Collection of String error messages. - * - * @param errorMap field error map - */ - void setFieldErrors(Map<String, List<String>> errorMap); - - /** - * Get the field specific errors associated with this action. Error messages should not be added - * directly here, as implementations are free to return a new Collection or an Unmodifiable - * Collection. - * - * @return Map with errors mapped from fieldname (String) to Collection of String error messages - */ - Map<String, List<String>> getFieldErrors(); - - /** - * Add an Action-level error message to this Action. - * - * @param anErrorMessage the error message - */ - void addActionError(String anErrorMessage); - - /** - * Add an Action-level message to this Action. - * - * @param aMessage the message - */ - void addActionMessage(String aMessage); - - /** - * Add an error message for a given field. - * - * @param fieldName name of field - * @param errorMessage the error message - */ - void addFieldError(String fieldName, String errorMessage); - - /** - * Check whether there are any Action-level error messages. - * - * @return true if any Action-level error messages have been registered - */ - boolean hasActionErrors(); - - /** - * Checks whether there are any Action-level messages. - * - * @return true if any Action-level messages have been registered - */ - boolean hasActionMessages(); - - /** - * Checks whether there are any action errors or field errors. - * <p/> - * <b>Note</b>: that this does not have the same meaning as in WW 1.x. - * - * @return <code>(hasActionErrors() || hasFieldErrors())</code> - */ - boolean hasErrors(); - - /** - * Check whether there are any field errors associated with this action. - * - * @return whether there are any field errors - */ - boolean hasFieldErrors(); - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java deleted file mode 100644 index 520513b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ValidationAwareSupport.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import java.io.Serializable; -import java.util.*; - -/** - * Provides a default implementation of ValidationAware. Returns new collections for - * errors and messages (defensive copy). - * - * @author Jason Carreira - * @author tm_jee - * @version $Date$ $Id$ - */ -public class ValidationAwareSupport implements ValidationAware, Serializable { - - private Collection<String> actionErrors; - private Collection<String> actionMessages; - private Map<String, List<String>> fieldErrors; - - - public synchronized void setActionErrors(Collection<String> errorMessages) { - this.actionErrors = errorMessages; - } - - public synchronized Collection<String> getActionErrors() { - return new LinkedList<>(internalGetActionErrors()); - } - - public synchronized void setActionMessages(Collection<String> messages) { - this.actionMessages = messages; - } - - public synchronized Collection<String> getActionMessages() { - return new LinkedList<>(internalGetActionMessages()); - } - - public synchronized void setFieldErrors(Map<String, List<String>> errorMap) { - this.fieldErrors = errorMap; - } - - public synchronized Map<String, List<String>> getFieldErrors() { - return new LinkedHashMap<>(internalGetFieldErrors()); - } - - public synchronized void addActionError(String anErrorMessage) { - internalGetActionErrors().add(anErrorMessage); - } - - public synchronized void addActionMessage(String aMessage) { - internalGetActionMessages().add(aMessage); - } - - public synchronized void addFieldError(String fieldName, String errorMessage) { - final Map<String, List<String>> errors = internalGetFieldErrors(); - List<String> thisFieldErrors = errors.get(fieldName); - - if (thisFieldErrors == null) { - thisFieldErrors = new ArrayList<>(); - errors.put(fieldName, thisFieldErrors); - } - - thisFieldErrors.add(errorMessage); - } - - public synchronized boolean hasActionErrors() { - return (actionErrors != null) && !actionErrors.isEmpty(); - } - - public synchronized boolean hasActionMessages() { - return (actionMessages != null) && !actionMessages.isEmpty(); - } - - public synchronized boolean hasErrors() { - return (hasActionErrors() || hasFieldErrors()); - } - - public synchronized boolean hasFieldErrors() { - return (fieldErrors != null) && !fieldErrors.isEmpty(); - } - - private Collection<String> internalGetActionErrors() { - if (actionErrors == null) { - actionErrors = new ArrayList<>(); - } - - return actionErrors; - } - - private Collection<String> internalGetActionMessages() { - if (actionMessages == null) { - actionMessages = new ArrayList<>(); - } - - return actionMessages; - } - - private Map<String, List<String>> internalGetFieldErrors() { - if (fieldErrors == null) { - fieldErrors = new LinkedHashMap<>(); - } - - return fieldErrors; - } - - /** - * Clears field errors map. - * <p/> - * Will clear the map that contains field errors. - */ - public synchronized void clearFieldErrors() { - internalGetFieldErrors().clear(); - } - - /** - * Clears action errors list. - * <p/> - * Will clear the list that contains action errors. - */ - public synchronized void clearActionErrors() { - internalGetActionErrors().clear(); - } - - /** - * Clears messages list. - * <p/> - * Will clear the list that contains action messages. - */ - public synchronized void clearMessages() { - internalGetActionMessages().clear(); - } - - /** - * Clears all error list/maps. - * <p/> - * Will clear the map and list that contain - * field errors and action errors. - */ - public synchronized void clearErrors() { - internalGetFieldErrors().clear(); - internalGetActionErrors().clear(); - } - - /** - * Clears all error and messages list/maps. - * <p/> - * Will clear the maps/lists that contain - * field errors, action errors and action messages. - */ - public synchronized void clearErrorsAndMessages() { - internalGetFieldErrors().clear(); - internalGetActionErrors().clear(); - internalGetActionMessages().clear(); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/XWork.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/XWork.java b/xwork-core/src/main/java/com/opensymphony/xwork2/XWork.java deleted file mode 100644 index fddc75b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/XWork.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2002-2006,2009 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 com.opensymphony.xwork2; - -import com.opensymphony.xwork2.config.Configuration; -import com.opensymphony.xwork2.config.ConfigurationManager; -import com.opensymphony.xwork2.util.logging.LoggerFactory; - -import java.util.Collections; -import java.util.Map; - -/** - * Simple facade to make using XWork standalone easier - */ -public class XWork { - - ConfigurationManager configurationManager; - - public XWork() { - this(new ConfigurationManager()); - } - - public XWork(ConfigurationManager mgr) { - this.configurationManager = mgr; - } - - public void setLoggerFactory(LoggerFactory factory) { - LoggerFactory.setLoggerFactory(factory); - } - - /** - * Executes an action - * - * @param namespace The namespace - * @param name The action name - * @param method The method name - * @throws Exception If anything goes wrong - */ - public void executeAction(String namespace, String name, String method) throws XWorkException { - Map<String, Object> extraContext = Collections.emptyMap(); - executeAction(namespace, name, method, extraContext); - } - - /** - * Executes an action with extra context information - * - * @param namespace The namespace - * @param name The action name - * @param method The method name - * @param extraContext A map of extra context information - * @throws Exception If anything goes wrong - */ - public void executeAction(String namespace, String name, String method, Map<String, Object> extraContext) throws XWorkException { - Configuration config = configurationManager.getConfiguration(); - try { - ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy( - namespace, name, method, extraContext, true, false); - - proxy.execute(); - } catch (Exception e) { - throw new XWorkException(e); - } finally { - ActionContext.setContext(null); - } - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkConstants.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkConstants.java b/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkConstants.java deleted file mode 100644 index 433b005..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.opensymphony.xwork2; - -/** - * Constants used across framework - */ -public final class XWorkConstants { - - public static final String COLLECTION_CONVERTER = "collectionConverter"; - public static final String DATE_CONVERTER = "dateConverter"; - public static final String NUMBER_CONVERTER = "numberConverter"; - public static final String STRING_CONVERTER = "stringConverter"; - public static final String ARRAY_CONVERTER = "arrayConverter"; - public static final String DEV_MODE = "devMode"; - public static final String LOG_MISSING_PROPERTIES = "logMissingProperties"; - public static final String ENABLE_OGNL_EXPRESSION_CACHE = "enableOGNLExpressionCache"; - public static final String ENABLE_OGNL_EVAL_EXPRESSION = "enableOGNLEvalExpression"; - public static final String RELOAD_XML_CONFIGURATION = "reloadXmlConfiguration"; - public static final String ALLOW_STATIC_METHOD_ACCESS = "allowStaticMethodAccess"; - public static final String XWORK_LOGGER_FACTORY = "xwork.loggerFactory"; - - public static final String OGNL_EXCLUDED_CLASSES = "ognlExcludedClasses"; - public static final String OGNL_EXCLUDED_PACKAGE_NAME_PATTERNS = "ognlExcludedPackageNamePatterns"; - - public static final String ADDITIONAL_EXCLUDED_PATTERNS = "additionalExcludedPatterns"; - public static final String ADDITIONAL_ACCEPTED_PATTERNS = "additionalAcceptedPatterns"; - - public static final String OVERRIDE_EXCLUDED_PATTERNS = "overrideExcludedPatterns"; - public static final String OVERRIDE_ACCEPTED_PATTERNS = "overrideAcceptedPatterns"; - -}
