Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1E16B18F07 for ; Wed, 17 Jun 2015 21:09:08 +0000 (UTC) Received: (qmail 75392 invoked by uid 500); 17 Jun 2015 21:09:02 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 75263 invoked by uid 500); 17 Jun 2015 21:09:02 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 74565 invoked by uid 99); 17 Jun 2015 21:09:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2015 21:09:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F27CFE3C67; Wed, 17 Jun 2015 21:09:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lukaszlenart@apache.org To: commits@struts.apache.org Date: Wed, 17 Jun 2015 21:09:13 -0000 Message-Id: <5858b533dea84dcd9f6bda7f76b66664@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [13/57] [partial] struts git commit: Merges xwork packages into struts http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkException.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkException.java b/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkException.java deleted file mode 100644 index 8445a1c..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkException.java +++ /dev/null @@ -1,154 +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.util.location.Locatable; -import com.opensymphony.xwork2.util.location.Location; -import com.opensymphony.xwork2.util.location.LocationUtils; - - -/** - * A generic runtime exception that optionally contains Location information - * - * @author Jason Carreira - */ -public class XWorkException extends RuntimeException implements Locatable { - - private Location location; - - - /** - * Constructs a XWorkException with no detail message. - */ - public XWorkException() { - } - - /** - * Constructs a XWorkException with the specified - * detail message. - * - * @param s the detail message. - */ - public XWorkException(String s) { - this(s, null, null); - } - - /** - * Constructs a XWorkException with the specified - * detail message and target. - * - * @param s the detail message. - * @param target the target of the exception. - */ - public XWorkException(String s, Object target) { - this(s, null, target); - } - - /** - * Constructs a XWorkException with the root cause - * - * @param cause The wrapped exception - */ - public XWorkException(Throwable cause) { - this(null, cause, null); - } - - /** - * Constructs a XWorkException with the root cause and target - * - * @param cause The wrapped exception - * @param target The target of the exception - */ - public XWorkException(Throwable cause, Object target) { - this(null, cause, target); - } - - /** - * Constructs a XWorkException with the specified - * detail message and exception cause. - * - * @param s the detail message. - * @param cause the wrapped exception - */ - public XWorkException(String s, Throwable cause) { - this(s, cause, null); - } - - - /** - * Constructs a XWorkException with the specified - * detail message, cause, and target - * - * @param s the detail message. - * @param cause The wrapped exception - * @param target The target of the exception - */ - public XWorkException(String s, Throwable cause, Object target) { - super(s, cause); - - this.location = LocationUtils.getLocation(target); - if (this.location == Location.UNKNOWN) { - this.location = LocationUtils.getLocation(cause); - } - } - - - /** - * Gets the underlying cause - * - * @return the underlying cause, null if no cause - * @deprecated Use {@link #getCause()} - */ - @Deprecated public Throwable getThrowable() { - return getCause(); - } - - - /** - * Gets the location of the error, if available - * - * @return the location, null if not available - */ - public Location getLocation() { - return this.location; - } - - - /** - * Returns a short description of this throwable object, including the - * location. If no detailed message is available, it will use the message - * of the underlying exception if available. - * - * @return a string representation of this Throwable. - */ - @Override - public String toString() { - String msg = getMessage(); - if (msg == null && getCause() != null) { - msg = getCause().getMessage(); - } - - if (location != null) { - if (msg != null) { - return msg + " - " + location.toString(); - } else { - return location.toString(); - } - } else { - return msg; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkJUnit4TestCase.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkJUnit4TestCase.java b/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkJUnit4TestCase.java deleted file mode 100644 index 86a33c6..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkJUnit4TestCase.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.ConfigurationException; -import com.opensymphony.xwork2.config.ConfigurationManager; -import com.opensymphony.xwork2.config.ConfigurationProvider; -import com.opensymphony.xwork2.inject.*; -import com.opensymphony.xwork2.test.StubConfigurationProvider; -import com.opensymphony.xwork2.util.XWorkTestCaseHelper; -import com.opensymphony.xwork2.util.location.LocatableProperties; -import org.junit.After; -import org.junit.Before; - -public abstract class XWorkJUnit4TestCase { - - protected ConfigurationManager configurationManager; - protected Configuration configuration; - protected Container container; - protected ActionProxyFactory actionProxyFactory; - - @Before - public void setUp() throws Exception { - configurationManager = XWorkTestCaseHelper.setUp(); - configuration = configurationManager.getConfiguration(); - container = configuration.getContainer(); - actionProxyFactory = container.getInstance(ActionProxyFactory.class); - } - - @After - public 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); - } - - protected void loadButAdd(final Class type, final Object impl) { - loadButAdd(type, Container.DEFAULT_NAME, impl); - } - - protected void loadButAdd(final Class type, final String name, final Object impl) { - loadConfigurationProviders(new StubConfigurationProvider() { - @Override - public void register(ContainerBuilder builder, - LocatableProperties props) throws ConfigurationException { - builder.factory(type, name, new Factory() { - public Object create(Context context) throws Exception { - return impl; - } - - }, Scope.SINGLETON); - } - }); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java b/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java deleted file mode 100644 index d187acc..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkMessages.java +++ /dev/null @@ -1,31 +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; - - -/** - * Contains constants for some default XWork messages. - * - * @author Jason Carreira - */ -public interface XWorkMessages { - - public static final String ACTION_EXECUTION_ERROR = "xwork.error.action.execution"; - public static final String MISSING_ACTION_EXCEPTION = "xwork.exception.missing-action"; - public static final String MISSING_PACKAGE_ACTION_EXCEPTION = "xwork.exception.missing-package-action"; - public static final String DEFAULT_INVALID_FIELDVALUE = "xwork.default.invalid.fieldvalue"; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java b/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java deleted file mode 100644 index c9b4e32..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/XWorkTestCase.java +++ /dev/null @@ -1,90 +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.ConfigurationManager; -import com.opensymphony.xwork2.config.ConfigurationProvider; -import com.opensymphony.xwork2.inject.*; -import com.opensymphony.xwork2.test.StubConfigurationProvider; -import com.opensymphony.xwork2.util.XWorkTestCaseHelper; -import com.opensymphony.xwork2.util.location.LocatableProperties; -import junit.framework.TestCase; - - -/** - * Base JUnit TestCase to extend for XWork specific JUnit tests. Uses - * the generic test setup for logic. - * - * @author plightbo - */ -public abstract class XWorkTestCase extends TestCase { - - protected ConfigurationManager configurationManager; - protected Configuration configuration; - protected Container container; - protected ActionProxyFactory actionProxyFactory; - - public XWorkTestCase() { - super(); - } - - @Override - protected void setUp() throws Exception { - configurationManager = XWorkTestCaseHelper.setUp(); - configuration = configurationManager.getConfiguration(); - container = configuration.getContainer(); - actionProxyFactory = container.getInstance(ActionProxyFactory.class); - } - - @Override - 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); - } - - protected void loadButAdd(final Class type, final Object impl) { - loadButAdd(type, Container.DEFAULT_NAME, impl); - } - - protected void loadButAdd(final Class type, final String name, final Object impl) { - loadConfigurationProviders(new StubConfigurationProvider() { - @Override - public void register(ContainerBuilder builder, - LocatableProperties props) throws ConfigurationException { - builder.factory(type, name, new Factory() { - public Object create(Context context) throws Exception { - return impl; - } - - }, Scope.SINGLETON); - } - }); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/BeanSelectionProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/BeanSelectionProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/BeanSelectionProvider.java deleted file mode 100644 index d6cef8b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/BeanSelectionProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.opensymphony.xwork2.config; - -/** - * When implemented allows to alias already existing beans - */ -public interface BeanSelectionProvider extends ConfigurationProvider { - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/Configuration.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/Configuration.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/Configuration.java deleted file mode 100644 index be1359d..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/Configuration.java +++ /dev/null @@ -1,98 +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.config; - -import com.opensymphony.xwork2.config.entities.PackageConfig; -import com.opensymphony.xwork2.config.entities.UnknownHandlerConfig; -import com.opensymphony.xwork2.inject.Container; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - - -/** - * XWork configuration. - * - * @author Mike - */ -public interface Configuration extends Serializable { - - void rebuildRuntimeConfiguration(); - - PackageConfig getPackageConfig(String name); - - Set getPackageConfigNames(); - - Map getPackageConfigs(); - - /** - * The current runtime configuration. Currently, if changes have been made to the Configuration since the last - * time buildRuntimeConfiguration() was called, you'll need to make sure to. - * - * @return the current runtime configuration - */ - RuntimeConfiguration getRuntimeConfiguration(); - - void addPackageConfig(String name, PackageConfig packageConfig); - - /** - * Removes a package from the the list of packages. Changes to the configuration won't take effect until buildRuntimeConfiguration - * is called. - * @param packageName the name of the package to remove - * @return the package removed (if any) - */ - PackageConfig removePackageConfig(String packageName); - - /** - * Allow the Configuration to clean up any resources that have been used. - */ - void destroy(); - - /** - * @deprecated Since 2.1 - * @param providers - * @throws ConfigurationException - */ - @Deprecated void reload(List providers) throws ConfigurationException; - - /** - * @since 2.1 - * @param containerProviders - * @throws ConfigurationException - */ - List reloadContainer(List containerProviders) throws ConfigurationException; - - /** - * @return the container - */ - Container getContainer(); - - Set getLoadedFileNames(); - - /** - * @since 2.1 - * @return list of unknown handlers - */ - List getUnknownHandlerStack(); - - /** - * @since 2.1 - * @param unknownHandlerStack - */ - void setUnknownHandlerStack(List unknownHandlerStack); -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java deleted file mode 100644 index fcbb11b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java +++ /dev/null @@ -1,87 +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.config; - -import com.opensymphony.xwork2.XWorkException; - - -/** - * ConfigurationException - * - * @author Jason Carreira - */ -public class ConfigurationException extends XWorkException { - - /** - * Constructs a ConfigurationException with no detail message. - */ - public ConfigurationException() { - } - - /** - * Constructs a ConfigurationException with the specified - * detail message. - * - * @param s the detail message. - */ - public ConfigurationException(String s) { - super(s); - } - - /** - * Constructs a ConfigurationException with the specified - * detail message. - * - * @param s the detail message. - */ - public ConfigurationException(String s, Object target) { - super(s, target); - } - - /** - * Constructs a ConfigurationException with no detail message. - */ - public ConfigurationException(Throwable cause) { - super(cause); - } - - /** - * Constructs a ConfigurationException with no detail message. - */ - public ConfigurationException(Throwable cause, Object target) { - super(cause, target); - } - - /** - * Constructs a ConfigurationException with the specified - * detail message. - * - * @param s the detail message. - */ - public ConfigurationException(String s, Throwable cause) { - super(s, cause); - } - - /** - * Constructs a ConfigurationException with the specified - * detail message. - * - * @param s the detail message. - */ - public ConfigurationException(String s, Throwable cause, Object target) { - super(s, cause, target); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java deleted file mode 100644 index 38920f7..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationManager.java +++ /dev/null @@ -1,232 +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.config; - -import com.opensymphony.xwork2.XWorkConstants; -import com.opensymphony.xwork2.config.impl.DefaultConfiguration; -import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; -import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - - -/** - * ConfigurationManager - central for XWork Configuration management, including - * its ConfigurationProvider. - * - * @author Jason Carreira - * @author tm_jee - * @version $Date$ $Id$ - */ -public class ConfigurationManager { - - protected static final Logger LOG = LogManager.getLogger(ConfigurationManager.class); - protected Configuration configuration; - protected Lock providerLock = new ReentrantLock(); - private List containerProviders = new CopyOnWriteArrayList<>(); - private List packageProviders = new CopyOnWriteArrayList<>(); - protected String defaultFrameworkBeanName; - private boolean providersChanged = false; - private boolean reloadConfigs = true; // for the first time - - public ConfigurationManager() { - this("xwork"); - } - - public ConfigurationManager(String name) { - this.defaultFrameworkBeanName = name; - } - - /** - * Get the current XWork configuration object. By default an instance of DefaultConfiguration will be returned - * - * @see com.opensymphony.xwork2.config.impl.DefaultConfiguration - */ - public synchronized Configuration getConfiguration() { - if (configuration == null) { - setConfiguration(createConfiguration(defaultFrameworkBeanName)); - try { - configuration.reloadContainer(getContainerProviders()); - } catch (ConfigurationException e) { - setConfiguration(null); - throw new ConfigurationException("Unable to load configuration.", e); - } - } else { - conditionalReload(); - } - - return configuration; - } - - protected Configuration createConfiguration(String beanName) { - return new DefaultConfiguration(beanName); - } - - public synchronized void setConfiguration(Configuration configuration) { - this.configuration = configuration; - } - - /** - * Get the current list of ConfigurationProviders. If no custom ConfigurationProviders have been added, this method - * will return a list containing only the default ConfigurationProvider, XMLConfigurationProvider. if a custom - * ConfigurationProvider has been added, then the XmlConfigurationProvider must be added by hand. - *

- *

- * TODO: the lazy instantiation of XmlConfigurationProvider should be refactored to be elsewhere. the behavior described above seems unintuitive. - * - * @return the list of registered ConfigurationProvider objects - * @see ConfigurationProvider - */ - public List getContainerProviders() { - providerLock.lock(); - try { - if (containerProviders.size() == 0) { - containerProviders.add(new XWorkConfigurationProvider()); - containerProviders.add(new XmlConfigurationProvider("xwork.xml", false)); - } - - return containerProviders; - } finally { - providerLock.unlock(); - } - } - - /** - * Set the list of configuration providers - * - * @param containerProviders list of {@link ConfigurationProvider} to be set - */ - public void setContainerProviders(List containerProviders) { - providerLock.lock(); - try { - this.containerProviders = new CopyOnWriteArrayList<>(containerProviders); - providersChanged = true; - } finally { - providerLock.unlock(); - } - } - - /** - * adds a configuration provider to the List of ConfigurationProviders. a given ConfigurationProvider may be added - * more than once - * - * @param provider the ConfigurationProvider to register - */ - public void addContainerProvider(ContainerProvider provider) { - if (!containerProviders.contains(provider)) { - containerProviders.add(provider); - providersChanged = true; - } - } - - public void clearContainerProviders() { - for (ContainerProvider containerProvider : containerProviders) { - clearContainerProvider(containerProvider); - } - containerProviders.clear(); - providersChanged = true; - } - - private void clearContainerProvider(ContainerProvider containerProvider) { - try { - containerProvider.destroy(); - } catch (Exception e) { - LOG.warn("Error while destroying container provider [{}]", containerProvider.toString(), e); - } - } - - /** - * Destroy its managing Configuration instance - */ - public synchronized void destroyConfiguration() { - clearContainerProviders(); // let's destroy the ConfigurationProvider first - containerProviders = new CopyOnWriteArrayList(); - if (configuration != null) - configuration.destroy(); // let's destroy it first, before nulling it. - configuration = null; - } - - - /** - * Reloads the Configuration files if the configuration files indicate that they need to be reloaded. - */ - public synchronized void conditionalReload() { - if (reloadConfigs || providersChanged) { - LOG.debug("Checking ConfigurationProviders for reload."); - List providers = getContainerProviders(); - boolean reload = needReloadContainerProviders(providers); - if (!reload) { - reload = needReloadPackageProviders(); - } - if (reload) { - reloadProviders(providers); - } - updateReloadConfigsFlag(); - providersChanged = false; - } - } - - private void updateReloadConfigsFlag() { - reloadConfigs = Boolean.parseBoolean(configuration.getContainer().getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION)); - if (LOG.isDebugEnabled()) { - LOG.debug("Updating [{}], current value is [{}], new value [{}]", - XWorkConstants.RELOAD_XML_CONFIGURATION, String.valueOf(reloadConfigs), String.valueOf(reloadConfigs)); - } - } - - private boolean needReloadPackageProviders() { - if (packageProviders != null) { - for (PackageProvider provider : packageProviders) { - if (provider.needsReload()) { - LOG.info("Detected package provider [{}] needs to be reloaded. Reloading all providers.", provider); - return true; - } - } - } - return false; - } - - private boolean needReloadContainerProviders(List providers) { - for (ContainerProvider provider : providers) { - if (provider.needsReload()) { - LOG.info("Detected container provider [{}] needs to be reloaded. Reloading all providers.", provider); - return true; - } - } - return false; - } - - private void reloadProviders(List providers) { - for (ContainerProvider containerProvider : containerProviders) { - try { - containerProvider.destroy(); - } catch (Exception e) { - LOG.warn("error while destroying configuration provider [{}]", containerProvider, e); - } - } - packageProviders = this.configuration.reloadContainer(providers); - } - - public synchronized void reload() { - packageProviders = getConfiguration().reloadContainer(getContainerProviders()); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java deleted file mode 100644 index 146532b..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationProvider.java +++ /dev/null @@ -1,22 +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.config; - -/** - * Interface to be implemented by all forms of XWork configuration classes. - */ -public interface ConfigurationProvider extends ContainerProvider, PackageProvider { -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java deleted file mode 100644 index e7ba7a6..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ConfigurationUtil.java +++ /dev/null @@ -1,83 +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.config; - -import com.opensymphony.xwork2.config.entities.PackageConfig; -import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; - -/** - * ConfigurationUtil - * - * @author Jason Carreira Created May 23, 2003 11:22:49 PM - */ -public class ConfigurationUtil { - - private static final Logger LOG = LogManager.getLogger(ConfigurationUtil.class); - - private ConfigurationUtil() { - } - - /** - * Get the {@link PackageConfig} elements with the specified names. - * @param configuration Configuration from which to find the package elements - * @param parent Comma separated list of parent package names - * @return The package elements that correspond to the names in the {@code parent} parameter. - */ - public static List buildParentsFromString(Configuration configuration, String parent) { - List parentPackageNames = buildParentListFromString(parent); - List parentPackageConfigs = new ArrayList<>(); - for (String parentPackageName : parentPackageNames) { - PackageConfig parentPackageContext = configuration.getPackageConfig(parentPackageName); - - if (parentPackageContext != null) { - parentPackageConfigs.add(parentPackageContext); - } - } - - return parentPackageConfigs; - } - - /** - * Splits the string into a list using a comma as the token separator. - * @param parent The comma separated string. - * @return A list of tokens from the specified string. - */ - public static List buildParentListFromString(String parent) { - if (StringUtils.isEmpty(parent)) { - return Collections.emptyList(); - } - - StringTokenizer tokenizer = new StringTokenizer(parent, ","); - List parents = new ArrayList<>(); - - while (tokenizer.hasMoreTokens()) { - String parentName = tokenizer.nextToken().trim(); - - if (StringUtils.isNotEmpty(parentName)) { - parents.add(parentName); - } - } - - return parents; - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java deleted file mode 100644 index de943f0..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java +++ /dev/null @@ -1,57 +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.config; - -import com.opensymphony.xwork2.inject.ContainerBuilder; -import com.opensymphony.xwork2.util.location.LocatableProperties; - - -/** - * Provides beans and constants/properties for the Container - * - * @since 2.1 - */ -public interface ContainerProvider { - - /** - * Called before removed from the configuration manager - */ - public void destroy(); - - /** - * Initializes with the configuration - * @param configuration The configuration - * @throws ConfigurationException If anything goes wrong - */ - public void init(Configuration configuration) throws ConfigurationException; - - /** - * Tells whether the ContainerProvider should reload its configuration - * - * @return true, whether the ContainerProvider should reload its configuration, falseotherwise. - */ - public boolean needsReload(); - - /** - * Registers beans and properties for the Container - * - * @param builder The builder to register beans with - * @param props The properties to register constants with - * @throws ConfigurationException If anything goes wrong - */ - public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java deleted file mode 100644 index 392b138..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.opensymphony.xwork2.config; - -import com.opensymphony.xwork2.FileManagerFactory; -import com.opensymphony.xwork2.inject.ContainerBuilder; -import com.opensymphony.xwork2.inject.Scope; -import com.opensymphony.xwork2.util.location.LocatableProperties; - -/** - * Allows to specify custom {@link FileManagerFactory} - */ -public class FileManagerFactoryProvider implements ContainerProvider { - - private Class factoryClass; - - public FileManagerFactoryProvider(Class factoryClass) { - this.factoryClass = factoryClass; - } - - public void destroy() { - } - - public void init(Configuration configuration) throws ConfigurationException { - } - - public boolean needsReload() { - return false; - } - - public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { - builder.factory(FileManagerFactory.class, factoryClass.getSimpleName(), factoryClass, Scope.SINGLETON); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java deleted file mode 100644 index 100f458..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.opensymphony.xwork2.config; - -import com.opensymphony.xwork2.FileManager; -import com.opensymphony.xwork2.inject.ContainerBuilder; -import com.opensymphony.xwork2.inject.Scope; -import com.opensymphony.xwork2.util.location.LocatableProperties; - -/** - * Allows to specify custom {@link FileManager} by user - */ -public class FileManagerProvider implements ContainerProvider { - - private Class fileManagerClass; - private String name; - - public FileManagerProvider(Class fileManagerClass, String name) { - this.fileManagerClass = fileManagerClass; - this.name = name; - } - - public void destroy() { - } - - public void init(Configuration configuration) throws ConfigurationException { - } - - public boolean needsReload() { - return false; - } - - public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException { - builder.factory(FileManager.class, name, fileManagerClass, Scope.SINGLETON); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java deleted file mode 100644 index dd0dfae..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/PackageProvider.java +++ /dev/null @@ -1,46 +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.config; - -/** - * Provides configuration packages. The separate init and loadPackages calls are due to the need to - * preserve backwards compatibility with the 2.0 {@link ConfigurationProvider} interface - * - * @since 2.1 - */ -public interface PackageProvider { - - /** - * Initializes with the configuration - * @param configuration The configuration - * @throws ConfigurationException If anything goes wrong - */ - public void init(Configuration configuration) throws ConfigurationException; - - /** - * Tells whether the PackageProvider should reload its configuration - * - * @return true, whether the PackageProvider should reload its configuration, falseotherwise. - */ - public boolean needsReload(); - - /** - * Loads the packages for the configuration. - * @throws ConfigurationException - */ - public void loadPackages() throws ConfigurationException; - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java deleted file mode 100644 index 00f1adb..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/ReferenceResolverException.java +++ /dev/null @@ -1,43 +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.config; - -import com.opensymphony.xwork2.XWorkException; - - -/** - * Exception when a reference can't be resolved. - * - * @author Mike - */ -public class ReferenceResolverException extends XWorkException { - - public ReferenceResolverException() { - super(); - } - - public ReferenceResolverException(String s) { - super(s); - } - - public ReferenceResolverException(String s, Throwable cause) { - super(s, cause); - } - - public ReferenceResolverException(Throwable cause) { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java deleted file mode 100644 index f24c766..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/RuntimeConfiguration.java +++ /dev/null @@ -1,53 +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.config; - -import com.opensymphony.xwork2.config.entities.ActionConfig; - -import java.io.Serializable; -import java.util.Map; - - -/** - * RuntimeConfiguration - * - * @author Jason Carreira - * Created Feb 25, 2003 10:56:02 PM - */ -public interface RuntimeConfiguration extends Serializable { - - /** - * get the fully expanded ActionConfig for a specified namespace and (action) name - * - * @param namespace the namespace of the Action. if this is null, then the empty namespace, "", will be used - * @param name the name of the Action. may not be null. - * @return the requested ActionConfig or null if there was no ActionConfig associated with the specified namespace - * and name - */ - ActionConfig getActionConfig(String namespace, String name); - - /** - * returns a Map of all the registered ActionConfigs. Again, these ActionConfigs are fully expanded so that any - * inherited interceptors, results, etc. will be included - * - * @return a Map of Map keyed by namespace and name respectively such that - *

-     *                 ActionConfig config = (ActionConfig)((Map)getActionConfigs.get(namespace)).get(name);
-     *                 
- * should return a valid config for valid namespace/name pairs - */ - Map> getActionConfigs(); -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ActionConfig.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ActionConfig.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ActionConfig.java deleted file mode 100644 index d796c02..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ActionConfig.java +++ /dev/null @@ -1,351 +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.config.entities; - -import com.opensymphony.xwork2.util.location.Located; -import com.opensymphony.xwork2.util.location.Location; -import org.apache.commons.lang3.StringUtils; - -import java.io.Serializable; -import java.util.*; - - -/** - * Contains everything needed to configure and execute an action: - *
    - *
  • methodName - the method name to execute on the action. If this is null, the Action will be cast to the Action - * Interface and the execute() method called
  • - *
  • clazz - the class name for the action
  • - *
  • params - the params to be set for this action just before execution
  • - *
  • results - the result map {String -> View class}
  • - *
  • resultParameters - params for results {String -> Map}
  • - *
  • typeConverter - the Ognl TypeConverter to use when getting/setting properties
  • - *
- * - * @author Mike - * @author Rainer Hermanns - * @version $Revision$ - */ -public class ActionConfig extends Located implements Serializable { - - public static final String DEFAULT_METHOD = "execute"; - public static final String WILDCARD = "*"; - - protected List interceptors; // a list of interceptorMapping Objects eg. List - protected Map params; - protected Map results; - protected List exceptionMappings; - protected String className; - protected String methodName; - protected String packageName; - protected String name; - protected Set allowedMethods; - - protected ActionConfig(String packageName, String name, String className) { - this.packageName = packageName; - this.name = name; - this.className = className; - params = new LinkedHashMap(); - results = new LinkedHashMap(); - interceptors = new ArrayList(); - exceptionMappings = new ArrayList(); - allowedMethods = new HashSet(); - } - - /** - * Clones an ActionConfig, copying data into new maps and lists - * @param orig The ActionConfig to clone - * @Since 2.1 - */ - protected ActionConfig(ActionConfig orig) { - this.name = orig.name; - this.className = orig.className; - this.methodName = orig.methodName; - this.packageName = orig.packageName; - this.params = new LinkedHashMap<>(orig.params); - this.interceptors = new ArrayList<>(orig.interceptors); - this.results = new LinkedHashMap<>(orig.results); - this.exceptionMappings = new ArrayList<>(orig.exceptionMappings); - this.allowedMethods = new HashSet<>(orig.allowedMethods); - this.location = orig.location; - } - - public String getName() { - return name; - } - - public String getClassName() { - return className; - } - - public List getExceptionMappings() { - return exceptionMappings; - } - - public List getInterceptors() { - return interceptors; - } - - public Set getAllowedMethods() { - return allowedMethods; - } - - /** - * Returns name of the action method - * - * @return name of the method to execute - */ - public String getMethodName() { - return methodName; - } - - /** - * @return Returns the packageName. - */ - public String getPackageName() { - return packageName; - } - - public Map getParams() { - return params; - } - - public Map getResults() { - return results; - } - - public boolean isAllowedMethod(String method) { - if (allowedMethods.size() == 1 && WILDCARD.equals(allowedMethods.iterator().next())) { - return true; - } else { - return method.equals(methodName != null ? methodName : DEFAULT_METHOD) || allowedMethods.contains(method); - } - } - - @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ActionConfig)) { - return false; - } - - final ActionConfig actionConfig = (ActionConfig) o; - - if ((className != null) ? (!className.equals(actionConfig.className)) : (actionConfig.className != null)) { - return false; - } - - if ((name != null) ? (!name.equals(actionConfig.name)) : (actionConfig.name != null)) { - return false; - } - - if ((interceptors != null) ? (!interceptors.equals(actionConfig.interceptors)) : (actionConfig.interceptors != null)) - { - return false; - } - - if ((methodName != null) ? (!methodName.equals(actionConfig.methodName)) : (actionConfig.methodName != null)) { - return false; - } - - if ((params != null) ? (!params.equals(actionConfig.params)) : (actionConfig.params != null)) { - return false; - } - - if ((results != null) ? (!results.equals(actionConfig.results)) : (actionConfig.results != null)) { - return false; - } - - if ((allowedMethods != null) ? (!allowedMethods.equals(actionConfig.allowedMethods)) : (actionConfig.allowedMethods != null)) { - return false; - } - - return true; - } - - @Override public int hashCode() { - int result; - result = (interceptors != null ? interceptors.hashCode() : 0); - result = 31 * result + (params != null ? params.hashCode() : 0); - result = 31 * result + (results != null ? results.hashCode() : 0); - result = 31 * result + (exceptionMappings != null ? exceptionMappings.hashCode() : 0); - result = 31 * result + (className != null ? className.hashCode() : 0); - result = 31 * result + (methodName != null ? methodName.hashCode() : 0); - result = 31 * result + (packageName != null ? packageName.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (allowedMethods != null ? allowedMethods.hashCode() : 0); - return result; - } - - @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("{ActionConfig "); - sb.append(name).append(" ("); - sb.append(className); - if (methodName != null) { - sb.append(".").append(methodName).append("()"); - } - sb.append(")"); - sb.append(" - ").append(location); - sb.append("}"); - return sb.toString(); - } - - /** - * The builder for this object. An instance of this object is the only way to construct a new instance. The - * purpose is to enforce the immutability of the object. The methods are structured in a way to support chaining. - * After setting any values you need, call the {@link #build()} method to create the object. - */ - public static class Builder implements InterceptorListHolder{ - - protected ActionConfig target; - private boolean gotMethods; - - public Builder(ActionConfig toClone) { - target = new ActionConfig(toClone); - addAllowedMethod(toClone.getAllowedMethods()); - } - - public Builder(String packageName, String name, String className) { - target = new ActionConfig(packageName, name, className); - } - - public Builder packageName(String name) { - target.packageName = name; - return this; - } - - public Builder name(String name) { - target.name = name; - return this; - } - - public Builder className(String name) { - target.className = name; - return this; - } - - public Builder defaultClassName(String name) { - if (StringUtils.isEmpty(target.className)) { - target.className = name; - } - return this; - } - - public Builder methodName(String method) { - target.methodName = method; - return this; - } - - public Builder addExceptionMapping(ExceptionMappingConfig exceptionMapping) { - target.exceptionMappings.add(exceptionMapping); - return this; - } - - public Builder addExceptionMappings(Collection mappings) { - target.exceptionMappings.addAll(mappings); - return this; - } - - public Builder exceptionMappings(Collection mappings) { - target.exceptionMappings.clear(); - target.exceptionMappings.addAll(mappings); - return this; - } - - public Builder addInterceptor(InterceptorMapping interceptor) { - target.interceptors.add(interceptor); - return this; - } - - public Builder addInterceptors(List interceptors) { - target.interceptors.addAll(interceptors); - return this; - } - - public Builder interceptors(List interceptors) { - target.interceptors.clear(); - target.interceptors.addAll(interceptors); - return this; - } - - public Builder addParam(String name, String value) { - target.params.put(name, value); - return this; - } - - public Builder addParams(Map params) { - target.params.putAll(params); - return this; - } - - public Builder addResultConfig(ResultConfig resultConfig) { - target.results.put(resultConfig.getName(), resultConfig); - return this; - } - - public Builder addResultConfigs(Collection configs) { - for (ResultConfig rc : configs) { - target.results.put(rc.getName(), rc); - } - return this; - } - - public Builder addResultConfigs(Map configs) { - target.results.putAll(configs); - return this; - } - - public Builder addAllowedMethod(String methodName) { - target.allowedMethods.add(methodName); - return this; - } - - public Builder addAllowedMethod(Collection methods) { - if (methods != null) { - gotMethods = true; - target.allowedMethods.addAll(methods); - } - return this; - } - - public Builder location(Location loc) { - target.location = loc; - return this; - } - - public ActionConfig build() { - embalmTarget(); - ActionConfig result = target; - target = new ActionConfig(target); - return result; - } - - protected void embalmTarget() { - if (!gotMethods && target.allowedMethods.isEmpty()) { - target.allowedMethods.add(WILDCARD); - } - - target.params = Collections.unmodifiableMap(target.params); - target.results = Collections.unmodifiableMap(target.results); - target.interceptors = Collections.unmodifiableList(target.interceptors); - target.exceptionMappings = Collections.unmodifiableList(target.exceptionMappings); - target.allowedMethods = Collections.unmodifiableSet(target.allowedMethods); - } - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ExceptionMappingConfig.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ExceptionMappingConfig.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ExceptionMappingConfig.java deleted file mode 100644 index 21a791e..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/ExceptionMappingConfig.java +++ /dev/null @@ -1,181 +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.config.entities; - -import com.opensymphony.xwork2.util.location.Located; -import com.opensymphony.xwork2.util.location.Location; - -import java.io.Serializable; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Configuration for exception mapping. - * - * @author Rainer Hermanns - * @author Matthew E. Porter (matthew dot porter at metissian dot com) - */ -public class ExceptionMappingConfig extends Located implements Serializable { - - protected String name; - protected String exceptionClassName; - protected String result; - protected Map params; - - protected ExceptionMappingConfig(String name, String exceptionClassName, String result) { - this.name = name; - this.exceptionClassName = exceptionClassName; - this.result = result; - this.params = new LinkedHashMap<>(); - } - - protected ExceptionMappingConfig(ExceptionMappingConfig target) { - this.name = target.name; - this.exceptionClassName = target.exceptionClassName; - this.result = target.result; - this.params = new LinkedHashMap<>(target.params); - this.location = target.location; - } - - public String getName() { - return name; - } - - public String getExceptionClassName() { - return exceptionClassName; - } - - public String getResult() { - return result; - } - - public Map getParams() { - return params; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ExceptionMappingConfig)) { - return false; - } - - final ExceptionMappingConfig exceptionMappingConfig = (ExceptionMappingConfig) o; - - if ((name != null) ? (!name.equals(exceptionMappingConfig.name)) : (exceptionMappingConfig.name != null)) { - return false; - } - - if ((exceptionClassName != null) ? (!exceptionClassName.equals(exceptionMappingConfig.exceptionClassName)) : (exceptionMappingConfig.exceptionClassName != null)) - { - return false; - } - - if ((result != null) ? (!result.equals(exceptionMappingConfig.result)) : (exceptionMappingConfig.result != null)) - { - return false; - } - - if ((params != null) ? (!params.equals(exceptionMappingConfig.params)) : (exceptionMappingConfig.params != null)) - { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int hashCode; - hashCode = ((name != null) ? name.hashCode() : 0); - hashCode = (29 * hashCode) + ((exceptionClassName != null) ? exceptionClassName.hashCode() : 0); - hashCode = (29 * hashCode) + ((result != null) ? result.hashCode() : 0); - hashCode = (29 * hashCode) + ((params != null) ? params.hashCode() : 0); - - return hashCode; - } - - @Override - public String toString() { - return "ExceptionMappingConfig: [" + name + "] handle [" - + exceptionClassName + "] to result [" + result + "] with params " + params; - } - - /** - * The builder for this object. An instance of this object is the only way to construct a new instance. The - * purpose is to enforce the immutability of the object. The methods are structured in a way to support chaining. - * After setting any values you need, call the {@link #build()} method to create the object. - */ - public static class Builder{ - - protected ExceptionMappingConfig target; - - public Builder(ExceptionMappingConfig toClone) { - target = new ExceptionMappingConfig(toClone); - } - - public Builder(String name, String exceptionClassName, String result) { - target = new ExceptionMappingConfig(name, exceptionClassName, result); - } - - public Builder name(String name) { - target.name = name; - return this; - } - - public Builder exceptionClassName(String name) { - target.exceptionClassName = name; - return this; - } - - public Builder result(String result) { - target.result = result; - return this; - } - - public Builder addParam(String name, String value) { - target.params.put(name, value); - return this; - } - - public Builder addParams(Map params) { - target.params.putAll(params); - return this; - } - - public Builder location(Location loc) { - target.location = loc; - return this; - } - - public ExceptionMappingConfig build() { - embalmTarget(); - ExceptionMappingConfig result = target; - target = new ExceptionMappingConfig(target); - return result; - } - - protected void embalmTarget() { - target.params = Collections.unmodifiableMap(target.params); - } - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorConfig.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorConfig.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorConfig.java deleted file mode 100644 index b04bbd9..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorConfig.java +++ /dev/null @@ -1,158 +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.config.entities; - -import com.opensymphony.xwork2.util.location.Located; -import com.opensymphony.xwork2.util.location.Location; - -import java.io.Serializable; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Configuration for Interceptors. - *

- * In the xml configuration file this is defined as the interceptors tag. - * - * @author Mike - */ -public class InterceptorConfig extends Located implements Serializable { - - protected Map params; - protected String className; - protected String name; - - protected InterceptorConfig(String name, String className) { - this.params = new LinkedHashMap<>(); - this.name = name; - this.className = className; - } - - protected InterceptorConfig(InterceptorConfig orig) { - this.name = orig.name; - this.className = orig.className; - this.params = new LinkedHashMap<>(orig.params); - this.location = orig.location; - } - - public String getClassName() { - return className; - } - - public String getName() { - return name; - } - - public Map getParams() { - return params; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof InterceptorConfig)) { - return false; - } - - final InterceptorConfig interceptorConfig = (InterceptorConfig) o; - - if ((className != null) ? (!className.equals(interceptorConfig.className)) : (interceptorConfig.className != null)) { - return false; - } - - if ((name != null) ? (!name.equals(interceptorConfig.name)) : (interceptorConfig.name != null)) { - return false; - } - - if ((params != null) ? (!params.equals(interceptorConfig.params)) : (interceptorConfig.params != null)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result; - result = ((name != null) ? name.hashCode() : 0); - result = (29 * result) + ((className != null) ? className.hashCode() : 0); - result = (29 * result) + ((params != null) ? params.hashCode() : 0); - - return result; - } - - @Override - public String toString() { - return "InterceptorConfig: [" + name + "] => [" + className + "] with params " + params; - } - - /** - * The builder for this object. An instance of this object is the only way to construct a new instance. The - * purpose is to enforce the immutability of the object. The methods are structured in a way to support chaining. - * After setting any values you need, call the {@link #build()} method to create the object. - */ - public static final class Builder { - protected InterceptorConfig target; - - public Builder(String name, String className) { - target = new InterceptorConfig(name, className); - } - - public Builder(InterceptorConfig orig) { - target = new InterceptorConfig(orig); - } - - public Builder name(String name) { - target.name = name; - return this; - } - - public Builder className(String name) { - target.className = name; - return this; - } - - public Builder addParam(String name, String value) { - target.params.put(name, value); - return this; - } - - public Builder addParams(Map params) { - target.params.putAll(params); - return this; - } - - public Builder location(Location loc) { - target.location = loc; - return this; - } - - public InterceptorConfig build() { - embalmTarget(); - InterceptorConfig result = target; - target = new InterceptorConfig(target); - return result; - } - - protected void embalmTarget() { - target.params = Collections.unmodifiableMap(target.params); - } - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorListHolder.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorListHolder.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorListHolder.java deleted file mode 100644 index 4323116..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorListHolder.java +++ /dev/null @@ -1,31 +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.config.entities; - -import java.util.List; - -/** - * InterceptorListHolder - * - * @author Jason Carreira - * Created Jun 1, 2003 1:02:48 AM - */ -public interface InterceptorListHolder { - - InterceptorListHolder addInterceptor(InterceptorMapping interceptor); - - InterceptorListHolder addInterceptors(List interceptors); -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorLocator.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorLocator.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorLocator.java deleted file mode 100644 index aa74960..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorLocator.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.opensymphony.xwork2.config.entities; - -/** - * Defines an object that can be used to retrieve interceptor configuration - */ -public interface InterceptorLocator { - - /** - * Gets an interceptor configuration object. - * @param name The interceptor or interceptor stack name - * @return Either an {@link InterceptorConfig} or {@link InterceptorStackConfig} object - */ - Object getInterceptorConfig(String name); -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java deleted file mode 100644 index 846575e..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java +++ /dev/null @@ -1,71 +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.config.entities; - -import com.opensymphony.xwork2.interceptor.Interceptor; - -import java.io.Serializable; - -/** - * InterceptorMapping - * - * @author Rainer Hermanns - * @version $Id$ - */ -public class InterceptorMapping implements Serializable { - - private String name; - private Interceptor interceptor; - - public InterceptorMapping(String name, Interceptor interceptor) { - this.name = name; - this.interceptor = interceptor; - } - - public String getName() { - return name; - } - - public Interceptor getInterceptor() { - return interceptor; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - final InterceptorMapping that = (InterceptorMapping) o; - - if (name != null ? !name.equals(that.name) : that.name != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result; - result = (name != null ? name.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "InterceptorMapping: [" + name + "] => [" + interceptor.getClass().getName() + ']'; - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/31af5842/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorStackConfig.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorStackConfig.java b/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorStackConfig.java deleted file mode 100644 index b9e2f78..0000000 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorStackConfig.java +++ /dev/null @@ -1,182 +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.config.entities; - -import com.opensymphony.xwork2.util.location.Located; -import com.opensymphony.xwork2.util.location.Location; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - - -/** - * Configuration for InterceptorStack. - *

- * In the xml configuration file this is defined as the interceptor-stack tag. - * - * @author Mike - * @author Rainer Hermanns - */ -public class InterceptorStackConfig extends Located implements Serializable { - - private static final long serialVersionUID = 2897260918170270343L; - - /** - * A list of InterceptorMapping object - */ - protected List interceptors; - protected String name; - - /** - * Creates an InterceptorStackConfig object. - */ - protected InterceptorStackConfig() { - this.interceptors = new ArrayList(); - } - - /** - * Creates an InterceptorStackConfig object with a particular name. - * - * @param name - */ - protected InterceptorStackConfig(InterceptorStackConfig orig) { - this.name = orig.name; - this.interceptors = new ArrayList<>(orig.interceptors); - this.location = orig.location; - } - - - /** - * Returns a Collection of InterceptorMapping objects. - * - * @return - */ - public Collection getInterceptors() { - return interceptors; - } - - /** - * Get the name of this interceptor stack configuration. - * - * @return String - */ - public String getName() { - return name; - } - - /** - * An InterceptorStackConfig object is equals with o only if - *

    - *
  • o is an InterceptorStackConfig object
  • - *
  • both names are equals
  • - *
  • all of their InterceptorMappings are equals
  • - *
- */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof InterceptorStackConfig)) { - return false; - } - - final InterceptorStackConfig interceptorStackConfig = (InterceptorStackConfig) o; - - if ((interceptors != null) ? (!interceptors.equals(interceptorStackConfig.interceptors)) : (interceptorStackConfig.interceptors != null)) { - return false; - } - - if ((name != null) ? (!name.equals(interceptorStackConfig.name)) : (interceptorStackConfig.name != null)) { - return false; - } - - return true; - } - - /** - * Generate hashcode based on InterceptorStackConfig's name and its - * InterceptorMappings. - */ - @Override - public int hashCode() { - int result; - result = ((name != null) ? name.hashCode() : 0); - result = (29 * result) + ((interceptors != null) ? interceptors.hashCode() : 0); - - return result; - } - - @Override - public String toString() { - return "InterceptorStackConfig: [" + name + "] contains " + interceptors; - } - - /** - * The builder for this object. An instance of this object is the only way to construct a new instance. The - * purpose is to enforce the immutability of the object. The methods are structured in a way to support chaining. - * After setting any values you need, call the {@link #build()} method to create the object. - */ - public static class Builder implements InterceptorListHolder { - protected InterceptorStackConfig target; - - public Builder(String name) { - target = new InterceptorStackConfig(); - target.name = name; - } - - public Builder name(String name) { - target.name = name; - return this; - } - - /** - * Add an InterceptorMapping object. - */ - public Builder addInterceptor(InterceptorMapping interceptor) { - target.interceptors.add(interceptor); - return this; - } - - /** - * Add a List of InterceptorMapping objects. - */ - public Builder addInterceptors(List interceptors) { - target.interceptors.addAll(interceptors); - return this; - } - - public Builder location(Location loc) { - target.location = loc; - return this; - } - - public InterceptorStackConfig build() { - embalmTarget(); - InterceptorStackConfig result = target; - target = new InterceptorStackConfig(target); - return result; - } - - protected void embalmTarget() { - target.interceptors = Collections.unmodifiableList(target.interceptors); - } - } -}