You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by tv...@apache.org on 2018/07/30 19:54:05 UTC
svn commit: r1837086 - in /turbine/core/trunk: pom.xml
src/changes/changes.xml src/java/org/apache/turbine/Turbine.java
src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java
src/java/org/apache/turbine/util/TurbineConfig.java
Author: tv
Date: Mon Jul 30 19:54:04 2018
New Revision: 1837086
URL: http://svn.apache.org/viewvc?rev=1837086&view=rev
Log:
Update servlet-api dependency to 3.1.0
Turbine is now annotated with Servlet 3.0 annotations
Modified:
turbine/core/trunk/pom.xml
turbine/core/trunk/src/changes/changes.xml
turbine/core/trunk/src/java/org/apache/turbine/Turbine.java
turbine/core/trunk/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java
turbine/core/trunk/src/java/org/apache/turbine/util/TurbineConfig.java
Modified: turbine/core/trunk/pom.xml
URL: http://svn.apache.org/viewvc/turbine/core/trunk/pom.xml?rev=1837086&r1=1837085&r2=1837086&view=diff
==============================================================================
--- turbine/core/trunk/pom.xml (original)
+++ turbine/core/trunk/pom.xml Mon Jul 30 19:54:04 2018
@@ -821,8 +821,8 @@
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: turbine/core/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/changes/changes.xml?rev=1837086&r1=1837085&r2=1837086&view=diff
==============================================================================
--- turbine/core/trunk/src/changes/changes.xml (original)
+++ turbine/core/trunk/src/changes/changes.xml Mon Jul 30 19:54:04 2018
@@ -24,20 +24,40 @@
</properties>
<body>
- <release version="4.0.2" date="in Subversion">
+ <release version="4.1" date="in Subversion">
+ <action type="update" dev="tv">
+ IMPORTANT: Update HtmlPageAttributes to deliver a default Doctype for HTML 5
+ Add a test.
+ </action>
+ <action type="update" dev="tv">
+ IMPORTANT: Update dependency servlet-api to 3.1.0
+ Adjust settings and services accordingly. The Turbine servlet is now annotated
+ as @WebServlet with reasonable defaults, so a web.xml is no longer needed.
+ </action>
+ <action type="add" dev="tv">
+ Add DefaultSetEncodingValve to concentrate handling of input and output encoding.
+ If required, add this valve at first position to your pipeline descriptor.
+ Move all charset and locale related methods to org.apache.turbine.util.LocaleUtils
+ Deprecate Turbine.getDefaultInputEncoding()
+ </action>
+ <action type="update" dev="tv">
+ Update dependency velocity to 2.0
+ Adjust settings and services accordingly. Examples are in CompleteTurbineResources.properties.
+ Look for [backward compatibility with Velocity 1.x] for easy migration
+ </action>
</release>
<release version="4.0.1" date="2018-02-21">
- <action type="update" dev="gk">
+ <action type="update" dev="gk">
Security methods replaceRole and revokeAll(Role, flag), Interface changes: SecurityService's addUser method and UserManager's createAccount, getAnonymousUser, getACL methods may now throw UnknownEntityException additionally.
- </action>
- <action type="update" dev="painter">
+ </action>
+ <action type="update" dev="painter">
input.encoding property (velocity) is set now default for locale.default.charset (both default to ISO-8859-1).
</action>
<action type="update" dev="gk">
Updated dependency versions: commons-codec to 1.11, commons-beanutils to 1.9.3, mockito-core to 2.13.0.
</action>
<action type="fix" dev="gk" due-to="Jeffery Painter">
- Each call in Turbine managers to the user delegate with a user object parameter now gets the wrapped user (the userDelegate).
+ Each call in Turbine managers to the user delegate with a user object parameter now gets the wrapped user (the userDelegate).
</action>
</release>
<release version="4.0" date="2017-11-06">
Modified: turbine/core/trunk/src/java/org/apache/turbine/Turbine.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/Turbine.java?rev=1837086&r1=1837085&r2=1837086&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/Turbine.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/Turbine.java Mon Jul 30 19:54:04 2018
@@ -32,6 +32,8 @@ import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -59,6 +61,7 @@ import org.apache.turbine.services.Servi
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.rundata.RunDataService;
import org.apache.turbine.services.template.TemplateService;
+import org.apache.turbine.util.LocaleUtils;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.ServerData;
import org.apache.turbine.util.TurbineConfig;
@@ -102,8 +105,18 @@ import org.apache.turbine.util.uri.URICo
* @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
* @version $Id$
*/
-public class Turbine
- extends HttpServlet
+@WebServlet(
+ name = "Turbine",
+ urlPatterns = {"/app"},
+ loadOnStartup = 1,
+ initParams={ @WebInitParam(name = TurbineConstants.APPLICATION_ROOT_KEY,
+ value = TurbineConstants.APPLICATION_ROOT_DEFAULT),
+ @WebInitParam(name = TurbineConstants.LOGGING_ROOT_KEY,
+ value = TurbineConstants.LOGGING_ROOT_DEFAULT),
+ @WebInitParam(name = TurbineConfig.PROPERTIES_PATH_KEY,
+ value = TurbineConfig.PROPERTIES_PATH_DEFAULT) } )
+
+public class Turbine extends HttpServlet
{
/** Serialversion */
private static final long serialVersionUID = -6317118078613623990L;
@@ -162,9 +175,6 @@ public class Turbine
/** Our internal configuration object */
private static Configuration configuration = null;
- /** Default Input encoding if the servlet container does not report an encoding */
- private static String inputEncoding = TurbineConstants.PARAMETER_ENCODING_DEFAULT;
-
/** Which configuration method is being used */
private enum ConfigurationStyle
{
@@ -368,16 +378,6 @@ public class Turbine
configuration.setProperty(TurbineConstants.APPLICATION_ROOT_KEY, applicationRoot);
configuration.setProperty(TurbineConstants.WEBAPP_ROOT_KEY, webappRoot);
- // Get the default input defaultEncoding
- inputEncoding = configuration.getString(
- TurbineConstants.PARAMETER_ENCODING_KEY,
- TurbineConstants.PARAMETER_ENCODING_DEFAULT);
-
- if (log.isDebugEnabled())
- {
- log.debug("Input Encoding has been set to " + inputEncoding);
- }
-
getServiceManager().setConfiguration(configuration);
// Initialize the service manager. Services
@@ -1035,7 +1035,7 @@ public class Turbine
@Deprecated
public static String getDefaultInputEncoding()
{
- return inputEncoding;
+ return LocaleUtils.getDefaultInputEncoding();
}
/**
Modified: turbine/core/trunk/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java?rev=1837086&r1=1837085&r2=1837086&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java Mon Jul 30 19:54:04 2018
@@ -37,7 +37,6 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fulcrum.mimetype.MimeTypeService;
import org.apache.fulcrum.parser.CookieParser;
import org.apache.fulcrum.parser.ParameterParser;
import org.apache.fulcrum.pool.Recyclable;
@@ -47,10 +46,10 @@ import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
import org.apache.turbine.om.security.User;
import org.apache.turbine.pipeline.DefaultPipelineData;
-import org.apache.turbine.services.ServiceManager;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.template.TemplateService;
import org.apache.turbine.util.FormMessages;
+import org.apache.turbine.util.LocaleUtils;
import org.apache.turbine.util.ServerData;
import org.apache.turbine.util.SystemError;
import org.apache.turbine.util.template.TemplateInfo;
@@ -87,12 +86,6 @@ public class DefaultTurbineRunData
*/
private boolean disposed;
- /** The default locale. */
- private static Locale defaultLocale = null;
-
- /** The default charset. */
- private static String defaultCharSet = null;
-
/** Cached action name to execute for this request. */
private String action;
@@ -158,7 +151,7 @@ public class DefaultTurbineRunData
private final Map<String, Object> debugVariables = new HashMap<String, Object>();
/** Logging */
- private static Log log = LogFactory.getLog(DefaultTurbineRunData.class);
+ private static final Log log = LogFactory.getLog(DefaultTurbineRunData.class);
/**
* Attempts to get the User object from the session. If it does
@@ -204,91 +197,6 @@ public class DefaultTurbineRunData
}
/**
- * Gets the default locale defined by properties named
- * "locale.default.lang" and "locale.default.country".
- *
- * This changed from earlier Turbine versions that you can
- * rely on getDefaultLocale() to never return null.
- *
- * @return A Locale object.
- */
- protected static Locale getDefaultLocale()
- {
- if (defaultLocale == null)
- {
- /* Get the default locale and cache it in a static variable. */
- String lang = Turbine.getConfiguration()
- .getString(TurbineConstants.LOCALE_DEFAULT_LANGUAGE_KEY,
- TurbineConstants.LOCALE_DEFAULT_LANGUAGE_DEFAULT);
-
- String country = Turbine.getConfiguration()
- .getString(TurbineConstants.LOCALE_DEFAULT_COUNTRY_KEY,
- TurbineConstants.LOCALE_DEFAULT_COUNTRY_DEFAULT);
-
-
- // We ensure that lang and country is never null
- defaultLocale = new Locale(lang, country);
- }
- return defaultLocale;
- }
-
- /**
- * Gets the default charset defined by a property named
- * "locale.default.charset" or by the specified locale.
- * If the specified locale is null, the default locale is applied.
- *
- * @return the name of the default charset or null.
- */
- protected String getDefaultCharSet()
- {
- log.debug("getDefaultCharSet()");
-
- if (defaultCharSet == null)
- {
- /* Get the default charset and cache it in a static variable. */
- defaultCharSet = Turbine.getConfiguration()
- .getString(TurbineConstants.LOCALE_DEFAULT_CHARSET_KEY,
- TurbineConstants.LOCALE_DEFAULT_CHARSET_DEFAULT);
- log.debug("defaultCharSet = " + defaultCharSet + " (From Properties)");
- }
-
- String charset = defaultCharSet;
-
- if (StringUtils.isEmpty(charset)) // this might not occur actually, as a default is always set
- {
- log.debug("charset is empty!");
- /* Default charset isn't specified, get the locale specific one. */
- Locale locale = getLocale();
- if (locale == null)
- {
- locale = getDefaultLocale();
- log.debug("Locale was null, is now " + locale + " (from getDefaultLocale())");
- }
-
- log.debug("Locale is " + locale);
-
- if (!locale.equals(Locale.US))
- {
- log.debug("We don't have US Locale!");
- ServiceManager serviceManager = TurbineServices.getInstance();
- MimeTypeService mimeTypeService=null;
- try {
- mimeTypeService= (MimeTypeService)serviceManager.getService(MimeTypeService.ROLE);
- }
- catch (Exception e){
- throw new RuntimeException(e);
- }
- charset = mimeTypeService.getCharSet(locale);
-
- log.debug("Charset now " + charset);
- }
- }
-
- log.debug("Returning default Charset of " + charset);
- return charset;
- }
-
- /**
* Constructs a run data object.
*/
public DefaultTurbineRunData()
@@ -455,7 +363,7 @@ public class DefaultTurbineRunData
/**
* Sets the access control list.
- *
+ *
* To delete ACL from session use key {@link TurbineConstants#ACL_SESSION_KEY}. Invalidate session, if session persist.
*
* @param acl an access control list.
@@ -931,7 +839,7 @@ public class DefaultTurbineRunData
Locale locale = get(Turbine.class, Locale.class);
if (locale == null)
{
- locale = getDefaultLocale();
+ locale = LocaleUtils.getDefaultLocale();
}
return locale;
}
@@ -978,12 +886,10 @@ public class DefaultTurbineRunData
if (StringUtils.isEmpty(charSet))
{
log.debug("Charset was null!");
- return getDefaultCharSet();
- }
- else
- {
- return charSet;
+ charSet = LocaleUtils.getDefaultCharSet();
}
+
+ return charSet;
}
/**
@@ -1018,7 +924,7 @@ public class DefaultTurbineRunData
{
if (contentType.startsWith("text/"))
{
- return contentType + "; charset=" + getDefaultCharSet();
+ return contentType + "; charset=" + LocaleUtils.getDefaultCharSet();
}
return contentType;
Modified: turbine/core/trunk/src/java/org/apache/turbine/util/TurbineConfig.java
URL: http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/util/TurbineConfig.java?rev=1837086&r1=1837085&r2=1837086&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/util/TurbineConfig.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/util/TurbineConfig.java Mon Jul 30 19:54:04 2018
@@ -29,15 +29,24 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
+import java.util.EventListener;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRegistration.Dynamic;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
@@ -598,4 +607,328 @@ public class TurbineConfig
{
throw new UnsupportedOperationException();
}
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public int getEffectiveMajorVersion()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public int getEffectiveMinorVersion()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public boolean setInitParameter(String name, String value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Dynamic addServlet(String servletName, String className)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Dynamic addServlet(String servletName, Servlet servlet)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public ServletRegistration getServletRegistration(String servletName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Map<String, ? extends ServletRegistration> getServletRegistrations()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public FilterRegistration getFilterRegistration(String filterName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Map<String, ? extends FilterRegistration> getFilterRegistrations()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public SessionCookieConfig getSessionCookieConfig()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public void addListener(String className)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public <T extends EventListener> void addListener(T t)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public void addListener(Class<? extends EventListener> listenerClass)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public JspConfigDescriptor getJspConfigDescriptor()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public ClassLoader getClassLoader()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public void declareRoles(String... roleNames)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not implemented.
+ *
+ * A method in ServletContext interface that is not implemented and will
+ * throw <code>UnsuportedOperationException</code> upon invocation
+ */
+ @Override
+ public String getVirtualServerName()
+ {
+ throw new UnsupportedOperationException();
+ }
}