Author: tv
Date: Mon Mar 4 18:30:25 2019
New Revision: 1854787
URL: http://svn.apache.org/viewvc?rev=1854787&view=rev
Log:
Address some FindBugs and PMD complaints
Modified:
turbine/core/trunk/src/java/org/apache/turbine/Turbine.java
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java
turbine/core/trunk/src/java/org/apache/turbine/pipeline/PipelineData.java
turbine/core/trunk/src/java/org/apache/turbine/pipeline/Valve.java
turbine/core/trunk/src/java/org/apache/turbine/pipeline/ValveContext.java
turbine/core/trunk/src/java/org/apache/turbine/services/BaseServiceBroker.java
turbine/core/trunk/src/java/org/apache/turbine/services/TurbineServiceProvider.java
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JsonRpcService.java
turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java
turbine/core/trunk/src/java/org/apache/turbine/services/pull/RunDataApplicationTool.java
turbine/core/trunk/src/java/org/apache/turbine/services/pull/TurbinePullService.java
turbine/core/trunk/src/java/org/apache/turbine/services/rundata/DefaultTurbineRunData.java
turbine/core/trunk/src/java/org/apache/turbine/services/rundata/TurbineRunDataService.java
turbine/core/trunk/src/java/org/apache/turbine/services/schedule/JobQueue.java
turbine/core/trunk/src/java/org/apache/turbine/services/session/SessionService.java
turbine/core/trunk/src/java/org/apache/turbine/services/template/TemplateService.java
turbine/core/trunk/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
turbine/core/trunk/src/java/org/apache/turbine/services/ui/UIService.java
turbine/core/trunk/src/java/org/apache/turbine/services/uniqueid/TurbineUniqueIdService.java
turbine/core/trunk/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java
turbine/core/trunk/src/test/org/apache/turbine/modules/scheduledjobs/SimpleJob.java
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=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/Turbine.java (original)
+++ turbine/core/trunk/src/java/org/apache/turbine/Turbine.java Mon Mar 4
18:30:25 2019
@@ -393,7 +393,7 @@ public class Turbine extends HttpServlet
confFile = findInitParameter(context, config,
TurbineConfig.PROPERTIES_PATH_KEY,
null);
- if (StringUtils.isNotEmpty((confFile)))
+ if (StringUtils.isNotEmpty(confFile))
{
confStyle = ConfigurationStyle.PROPERTIES;
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/om/security/DefaultUserImpl.java
Mon Mar 4 18:30:25 2019
@@ -401,7 +401,7 @@ public class DefaultUserImpl implements
* @return A Java Date with the last access date for the user.
*/
@Override
- public java.util.Date getLastAccessDate()
+ public Date getLastAccessDate()
{
if (lastAccessDate == null)
{
@@ -417,7 +417,7 @@ public class DefaultUserImpl implements
@Override
public void setLastAccessDate()
{
- lastAccessDate = new java.util.Date();
+ lastAccessDate = new Date();
}
/**
@@ -630,9 +630,9 @@ public class DefaultUserImpl implements
* @return The creation date of the user
*/
@Override
- public java.util.Date getCreateDate()
+ public Date getCreateDate()
{
- return (java.util.Date)getPerm(CREATE_DATE, new java.util.Date());
+ return (Date)getPerm(CREATE_DATE, new Date());
}
/**
@@ -641,7 +641,7 @@ public class DefaultUserImpl implements
* @param createDate The new creation date of the user
*/
@Override
- public void setCreateDate(java.util.Date createDate)
+ public void setCreateDate(Date createDate)
{
setPerm(CREATE_DATE, createDate);
}
@@ -652,9 +652,9 @@ public class DefaultUserImpl implements
* @return The date of the last login of the user
*/
@Override
- public java.util.Date getLastLogin()
+ public Date getLastLogin()
{
- return (java.util.Date) getPerm(User.LAST_LOGIN);
+ return (Date) getPerm(User.LAST_LOGIN);
}
/**
@@ -663,7 +663,7 @@ public class DefaultUserImpl implements
* @param lastLogin The new the date of the last login of the user
*/
@Override
- public void setLastLogin(java.util.Date lastLogin)
+ public void setLastLogin(Date lastLogin)
{
setPerm(User.LAST_LOGIN, lastLogin);
}
@@ -677,7 +677,7 @@ public class DefaultUserImpl implements
public boolean hasLoggedIn()
{
Boolean loggedIn = (Boolean) getTemp(User.HAS_LOGGED_IN);
- return (loggedIn != null && loggedIn.booleanValue());
+ return loggedIn != null && loggedIn.booleanValue();
}
/**
@@ -704,7 +704,7 @@ public class DefaultUserImpl implements
public boolean isConfirmed()
{
String value = getConfirmed();
- return (value != null && value.equals(User.CONFIRM_DATA));
+ return value != null && value.equals(User.CONFIRM_DATA);
}
/**
@@ -716,7 +716,7 @@ public class DefaultUserImpl implements
public void updateLastLogin()
throws Exception
{
- setLastLogin(new java.util.Date());
+ setLastLogin(new Date());
}
/* (non-Javadoc)
Modified:
turbine/core/trunk/src/java/org/apache/turbine/pipeline/PipelineData.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/pipeline/PipelineData.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/pipeline/PipelineData.java
(original)
+++ turbine/core/trunk/src/java/org/apache/turbine/pipeline/PipelineData.java
Mon Mar 4 18:30:25 2019
@@ -44,7 +44,7 @@ public interface PipelineData extends Au
* @param name the key class
* @param value the value map
*/
- public void put(Class<?> name, Map<Class<?>, ? super Object> value);
+ void put(Class<?> name, Map<Class<?>, ? super Object> value);
/**
* Get the configured map of objects for the given key
@@ -52,7 +52,7 @@ public interface PipelineData extends Au
* @param name the key class
* @return the value map or null if no such key exists
*/
- public Map<Class<?>, ? super Object> get(Class<?> name);
+ Map<Class<?>, ? super Object> get(Class<?> name);
/**
* Get a value from the configured map of objects for the given keys
@@ -64,5 +64,5 @@ public interface PipelineData extends Au
*
* @return the inner value or null if no such keys exist
*/
- public <T> T get(Class<?> key, Class<T> innerKey);
+ <T> T get(Class<?> key, Class<T> innerKey);
}
Modified: turbine/core/trunk/src/java/org/apache/turbine/pipeline/Valve.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/pipeline/Valve.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/pipeline/Valve.java
(original)
+++ turbine/core/trunk/src/java/org/apache/turbine/pipeline/Valve.java Mon Mar
4 18:30:25 2019
@@ -89,13 +89,13 @@ public interface Valve
* @throws IOException Thrown by a subsequent Valve.
* @throws TurbineException Thrown by a subsequent Valve.
*/
- public void invoke(PipelineData pipelineData, ValveContext context)
+ void invoke(PipelineData pipelineData, ValveContext context)
throws IOException, TurbineException;
/**
* Initialize the valve before using in a pipeline.
* @throws Exception if initialization fails
*/
- public void initialize()
+ void initialize()
throws Exception;
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/pipeline/ValveContext.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/pipeline/ValveContext.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/pipeline/ValveContext.java
(original)
+++ turbine/core/trunk/src/java/org/apache/turbine/pipeline/ValveContext.java
Mon Mar 4 18:30:25 2019
@@ -64,6 +64,6 @@ public interface ValveContext
* @throws TurbineException No further Valves configured in the
* Pipeline currently being processed.
*/
- public void invokeNext(PipelineData pipelineData)
+ void invokeNext(PipelineData pipelineData)
throws IOException, TurbineException;
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/BaseServiceBroker.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/BaseServiceBroker.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/BaseServiceBroker.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/BaseServiceBroker.java
Mon Mar 4 18:30:25 2019
@@ -258,7 +258,7 @@ public abstract class BaseServiceBroker
String key = keys.next();
String[] keyParts = StringUtils.split(key, ".");
- if ((keyParts.length == 3)
+ if (keyParts.length == 3
&& (keyParts[0] + ".").equals(SERVICE_PREFIX)
&& ("." + keyParts[2]).equals(CLASSNAME_SUFFIX))
{
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/TurbineServiceProvider.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/TurbineServiceProvider.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/TurbineServiceProvider.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/TurbineServiceProvider.java
Mon Mar 4 18:30:25 2019
@@ -39,7 +39,7 @@ public interface TurbineServiceProvider
* @return an instance of the service
* @throws InstantiationException the service could not be instantiated
*/
- public Object get(String roleName) throws InstantiationException;
+ Object get(String roleName) throws InstantiationException;
/**
* Releases the instance you got before. This is only really
@@ -47,12 +47,12 @@ public interface TurbineServiceProvider
*
* @param component the component to release
*/
- public void release(Object component);
+ void release(Object component);
/**
* Is the service known to the service container?
* @param roleName the name of the requested service
* @return true if the service is known to the provider
*/
- public boolean exists(String roleName);
+ boolean exists(String roleName);
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/avaloncomponent/Log4j2Logger.java
Mon Mar 4 18:30:25 2019
@@ -49,7 +49,7 @@ public final class Log4j2Logger
* the message
*/
@Override
- public final void debug(final String message)
+ public void debug(final String message)
{
m_logger.debug(message);
}
@@ -63,7 +63,7 @@ public final class Log4j2Logger
* the throwable
*/
@Override
- public final void debug(final String message, final Throwable throwable)
+ public void debug(final String message, final Throwable throwable)
{
m_logger.debug(message, throwable);
}
@@ -74,7 +74,7 @@ public final class Log4j2Logger
* @return true if "debug" messages will be logged
*/
@Override
- public final boolean isDebugEnabled()
+ public boolean isDebugEnabled()
{
return m_logger.isDebugEnabled();
}
@@ -86,7 +86,7 @@ public final class Log4j2Logger
* the message
*/
@Override
- public final void info(final String message)
+ public void info(final String message)
{
m_logger.info(message);
}
@@ -100,7 +100,7 @@ public final class Log4j2Logger
* the throwable
*/
@Override
- public final void info(final String message, final Throwable throwable)
+ public void info(final String message, final Throwable throwable)
{
m_logger.info(message, throwable);
}
@@ -111,7 +111,7 @@ public final class Log4j2Logger
* @return true if "info" messages will be logged
*/
@Override
- public final boolean isInfoEnabled()
+ public boolean isInfoEnabled()
{
return m_logger.isInfoEnabled();
}
@@ -123,7 +123,7 @@ public final class Log4j2Logger
* the message
*/
@Override
- public final void warn(final String message)
+ public void warn(final String message)
{
m_logger.warn(message);
}
@@ -137,7 +137,7 @@ public final class Log4j2Logger
* the throwable
*/
@Override
- public final void warn(final String message, final Throwable throwable)
+ public void warn(final String message, final Throwable throwable)
{
m_logger.warn(message, throwable);
}
@@ -148,7 +148,7 @@ public final class Log4j2Logger
* @return true if "warn" messages will be logged
*/
@Override
- public final boolean isWarnEnabled()
+ public boolean isWarnEnabled()
{
return m_logger.isWarnEnabled();
}
@@ -160,7 +160,7 @@ public final class Log4j2Logger
* the message
*/
@Override
- public final void error(final String message)
+ public void error(final String message)
{
m_logger.error(message);
}
@@ -174,7 +174,7 @@ public final class Log4j2Logger
* the throwable
*/
@Override
- public final void error(final String message, final Throwable throwable)
+ public void error(final String message, final Throwable throwable)
{
m_logger.error(message, throwable);
}
@@ -185,7 +185,7 @@ public final class Log4j2Logger
* @return true if "error" messages will be logged
*/
@Override
- public final boolean isErrorEnabled()
+ public boolean isErrorEnabled()
{
return m_logger.isErrorEnabled();
}
@@ -197,7 +197,7 @@ public final class Log4j2Logger
* the message
*/
@Override
- public final void fatalError(final String message)
+ public void fatalError(final String message)
{
m_logger.fatal(message);
}
@@ -211,7 +211,7 @@ public final class Log4j2Logger
* the throwable
*/
@Override
- public final void fatalError(final String message, final Throwable
throwable)
+ public void fatalError(final String message, final Throwable throwable)
{
m_logger.fatal(message, throwable);
}
@@ -222,7 +222,7 @@ public final class Log4j2Logger
* @return true if "fatalError" messages will be logged
*/
@Override
- public final boolean isFatalErrorEnabled()
+ public boolean isFatalErrorEnabled()
{
return m_logger.isFatalEnabled();
}
@@ -237,7 +237,7 @@ public final class Log4j2Logger
* @return the new logger
*/
@Override
- public final Logger getChildLogger(final String name)
+ public Logger getChildLogger(final String name)
{
return new Log4j2Logger(LogManager.getLogger(m_logger.getName() + "."
+ name));
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JsonRpcService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JsonRpcService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JsonRpcService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/jsonrpc/JsonRpcService.java
Mon Mar 4 18:30:25 2019
@@ -38,7 +38,7 @@ public interface JsonRpcService
extends Service
{
/** TurbineJsonRpcService. */
- public static final String SERVICE_NAME = "JsonRpcService";
+ String SERVICE_NAME = "JsonRpcService";
/**
* Process a JSON RPC call
@@ -47,7 +47,7 @@ public interface JsonRpcService
* @param request the request
* @return the return object of the JSON RPC call
*/
- public Object processCall(CharArrayWriter cdata,
+ Object processCall(CharArrayWriter cdata,
JSONRPCBridge json_bridge, HttpServletRequest request);
/**
@@ -57,7 +57,7 @@ public interface JsonRpcService
* @param key the name of the object in the session
* @param value the object to register
*/
- public void registerObject(HttpSession session, String key, Object value);
+ void registerObject(HttpSession session, String key, Object value);
/**
* Register an object with the {@link JSONRPCBridge} globally
@@ -65,7 +65,7 @@ public interface JsonRpcService
* @param key the name of the object in the session
* @param value the object to register
*/
- public void registerObjectGlobal(String key, Object value);
+ void registerObjectGlobal(String key, Object value);
/**
* Get the {@link JSONRPCBridge} from the session
@@ -73,12 +73,12 @@ public interface JsonRpcService
* @param session the session
* @return the {@link JSONRPCBridge} instance
*/
- public JSONRPCBridge getBridge(HttpSession session);
+ JSONRPCBridge getBridge(HttpSession session);
/**
* Remove the {@link JSONRPCBridge} from the session
*
* @param session the session
*/
- public void clearBridge(HttpSession session);
+ void clearBridge(HttpSession session);
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/pull/PipelineDataApplicationTool.java
Mon Mar 4 18:30:25 2019
@@ -51,7 +51,7 @@ public interface PipelineDataApplication
*
* @param data initialization data
*/
- public void init(Object data);
+ void init(Object data);
/**
* Refresh the application tool. This is
@@ -62,5 +62,5 @@ public interface PipelineDataApplication
*
* @param data The current PipelineData Object
*/
- public void refresh(PipelineData data);
+ void refresh(PipelineData data);
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/pull/RunDataApplicationTool.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/pull/RunDataApplicationTool.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/pull/RunDataApplicationTool.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/pull/RunDataApplicationTool.java
Mon Mar 4 18:30:25 2019
@@ -52,7 +52,7 @@ public interface RunDataApplicationTool
*
* @param data initialization data
*/
- public void init(Object data);
+ void init(Object data);
/**
* Refresh the application tool. This is
@@ -63,6 +63,5 @@ public interface RunDataApplicationTool
*
* @param data The current RunData Object
*/
- public void refresh(RunData data);
-
+ void refresh(RunData data);
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/pull/TurbinePullService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/pull/TurbinePullService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/pull/TurbinePullService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/pull/TurbinePullService.java
Mon Mar 4 18:30:25 2019
@@ -339,8 +339,7 @@ public class TurbinePullService
log.info("Tool {} to add to the context as '${}'",
toolClassName, toolName);
}
- // NoClassDefFoundError + ClassNotFoundException
- catch (Throwable e)
+ catch (NoClassDefFoundError | ClassNotFoundException e)
{
log.error("Cannot instantiate tool class {}", toolClassName,
e);
}
@@ -403,13 +402,10 @@ public class TurbinePullService
.getInstance()
.getService(TurbineUserManager.ROLE);
- if (!userManager.isAnonymousUser(user))
+ if (!userManager.isAnonymousUser(user) && user.hasLoggedIn())
{
- if (user.hasLoggedIn())
- {
- populateWithSessionTools(authorizedTools, context, data, user);
- populateWithPermTools(persistentTools, context, data, user);
- }
+ populateWithSessionTools(authorizedTools, context, data, user);
+ populateWithPermTools(persistentTools, context, data, user);
}
}
@@ -425,9 +421,7 @@ public class TurbinePullService
@Override
public void populateContext(Context context, PipelineData pipelineData)
{
- // Map runDataMap = (Map) pipelineData.get(RunData.class);
- // RunData data = (RunData)runDataMap.get(RunData.class);
- RunData data = (RunData)pipelineData;
+ RunData data = getRunData(pipelineData);
populateWithRequestTools(context, pipelineData);
// session tools (whether session-only or persistent are
@@ -447,20 +441,17 @@ public class TurbinePullService
// We should either store the session pull tools in the session or
// make Turbine.loginAction() copy the session pull tools into the
// new user object.
- populateWithSessionTools(sessionTools, context, pipelineData, user);
+ populateWithSessionTools(sessionTools, context, data, user);
TurbineUserManager userManager =
(TurbineUserManager)TurbineServices
.getInstance()
.getService(TurbineUserManager.ROLE);
- if (!userManager.isAnonymousUser(user))
+ if (!userManager.isAnonymousUser(user) && user.hasLoggedIn())
{
- if (user.hasLoggedIn())
- {
- populateWithSessionTools(authorizedTools, context,
pipelineData, user);
- populateWithPermTools(persistentTools, context, pipelineData,
user);
- }
+ populateWithSessionTools(authorizedTools, context, data, user);
+ populateWithPermTools(persistentTools, context, pipelineData,
user);
}
}
@@ -471,9 +462,8 @@ public class TurbinePullService
*/
private void populateWithGlobalTools(Context context)
{
- for (Iterator<ToolData> it = globalTools.iterator(); it.hasNext();)
+ for (ToolData toolData : globalTools)
{
- ToolData toolData = it.next();
try
{
Object tool = toolData.toolClass.newInstance();
@@ -496,14 +486,13 @@ public class TurbinePullService
* Populate the given context with the request-scope tools
*
* @param context a Velocity Context to populate
- * @param pipelineData a RunData instance
+ * @param data a RunData or PipelineData instance
*/
- private void populateWithRequestTools(Context context, RunData data)
+ private void populateWithRequestTools(Context context, Object data)
{
// Iterate the tools
- for (Iterator<ToolData> it = requestTools.iterator(); it.hasNext();)
+ for (ToolData toolData : requestTools)
{
- ToolData toolData = it.next();
try
{
// Fetch Object through the Pool.
@@ -523,130 +512,12 @@ public class TurbinePullService
}
}
-
- /**
- * Populate the given context with the request-scope tools
- *
- * @param context a Velocity Context to populate
- * @param pipelineData a RunData instance
- */
- private void populateWithRequestTools(Context context, PipelineData
pipelineData)
- {
- // Iterate the tools
- for (Iterator<ToolData> it = requestTools.iterator(); it.hasNext();)
- {
- ToolData toolData = it.next();
- try
- {
- // Fetch Object through the Pool.
- Object tool = pool.getInstance(toolData.toolClass);
-
- initTool(tool, pipelineData);
-
- // put the tool in the context
- context.put(toolData.toolName, tool);
- }
- catch (Exception e)
- {
- log.error("Could not instantiate request tool {} from a {}
object",
- toolData.toolName, toolData.toolClassName, e);
- }
- }
- }
-
- /**
- * Populate the given context with the session-scoped tools.
- *
- * @param tools The list of tools with which to populate the
- * session.
- * @param context The context to populate.
- * @param pipelineData The current RunData object
- * @param user The <code>User</code> object whose storage to
- * retrieve the tool from.
- */
- private void populateWithSessionTools(List<ToolData> tools, Context
context,
- PipelineData pipelineData, User user)
- {
- //Map runDataMap = (Map)pipelineData.get(RunData.class);
- //RunData data = (RunData) runDataMap.get(RunData.class);
- RunData runData = (RunData)pipelineData;
- // Iterate the tools
- for (Iterator<ToolData> it = tools.iterator(); it.hasNext();)
- {
- ToolData toolData = it.next();
- try
- {
- // ensure that tool is created only once for a user
- // by synchronizing against the user object
- synchronized (runData.getSession())
- {
- // first try and fetch the tool from the user's
- // hashtable
- Object tool = runData.getSession().getAttribute(
- SESSION_TOOLS_ATTRIBUTE_PREFIX
- + toolData.toolClassName);
-
- if (tool == null)
- {
- // if not there, an instance must be fetched from
- // the pool
- tool = pool.getInstance(toolData.toolClass);
-
- // session tools are init'd with the User object
- initTool(tool, user);
- }
-
- // *NOT* else
- if(tool != null)
- {
- // store the newly created tool in the session
- runData.getSession().setAttribute(
- SESSION_TOOLS_ATTRIBUTE_PREFIX
- + tool.getClass().getName(), tool);
-
- // This is a semantics change. In the old
- // Turbine, Session tools were initialized and
- // then refreshed every time they were pulled
- // into the context if "refreshToolsPerRequest"
- // was wanted.
- //
- // RunDataApplicationTools now have a parameter
- // for refresh. If it is not refreshed immediately
- // after init(), the parameter value will be undefined
- // until the 2nd run. So we refresh all the session
- // tools on every run, even if we just init'ed it.
- //
-
- if (refreshToolsPerRequest)
- {
- refreshTool(tool, pipelineData);
- }
-
- // put the tool in the context
- log.debug("Adding {} to ctx as {}", tool,
toolData.toolName);
- context.put(toolData.toolName, tool);
- }
- else
- {
- log.info("Tool {} was null, skipping it.",
toolData.toolName);
- }
- }
- }
- catch (Exception e)
- {
- log.error("Could not instantiate session tool {} from a {}
object",
- toolData.toolName, toolData.toolClassName, e);
- }
- }
- }
-
/**
* Populate the given context with the session-scoped tools.
*
- * @param tools The list of tools with which to populate the
- * session.
+ * @param tools The list of tools with which to populate the session.
* @param context The context to populate.
- * @param pipelineData The current RunData object
+ * @param data The current RunData object
* @param user The <code>User</code> object whose storage to
* retrieve the tool from.
*/
@@ -654,9 +525,8 @@ public class TurbinePullService
RunData data, User user)
{
// Iterate the tools
- for (Iterator<ToolData> it = tools.iterator(); it.hasNext();)
+ for (ToolData toolData : tools)
{
- ToolData toolData = it.next();
try
{
// ensure that tool is created only once for a user
@@ -723,105 +593,22 @@ public class TurbinePullService
}
}
-
-
- /**
- * Populate the given context with the perm-scoped tools.
- *
- * @param tools The list of tools with which to populate the
- * session.
- * @param context The context to populate.
- * @param pipelineData The current RunData object
- * @param user The <code>User</code> object whose storage to
- * retrieve the tool from.
- */
- private void populateWithPermTools(List<ToolData> tools, Context context,
- PipelineData pipelineData, User user)
- {
- // Iterate the tools
- for (Iterator<ToolData> it = tools.iterator(); it.hasNext();)
- {
- ToolData toolData = it.next();
- try
- {
- // ensure that tool is created only once for a user
- // by synchronizing against the user object
- synchronized (user)
- {
- // first try and fetch the tool from the user's
- // hashtable
- Object tool = user.getPerm(toolData.toolClassName);
-
- if (tool == null)
- {
- // if not there, an instance must be fetched from
- // the pool
- tool = pool.getInstance(toolData.toolClass);
-
- // session tools are init'd with the User object
- initTool(tool, user);
-
- // store the newly created tool in the user's hashtable
- user.setPerm(toolData.toolClassName, tool);
- }
-
- // *NOT* else
- if(tool != null)
- {
- // This is a semantics change. In the old
- // Turbine, Session tools were initialized and
- // then refreshed every time they were pulled
- // into the context if "refreshToolsPerRequest"
- // was wanted.
- //
- // RunDataApplicationTools now have a parameter
- // for refresh. If it is not refreshed immediately
- // after init(), the parameter value will be undefined
- // until the 2nd run. So we refresh all the session
- // tools on every run, even if we just init'ed it.
- //
-
- if (refreshToolsPerRequest)
- {
- refreshTool(tool, pipelineData);
- }
-
- // put the tool in the context
- log.debug("Adding {} to ctx as {}", tool,
toolData.toolName);
- log.warn("Persistent scope tools are deprecated.");
- context.put(toolData.toolName, tool);
- }
- else
- {
- log.info("Tool {} was null, skipping it.",
toolData.toolName);
- }
- }
- }
- catch (Exception e)
- {
- log.error("Could not instantiate perm tool {} from a {}
object",
- toolData.toolName, toolData.toolClassName, e);
- }
- }
- }
-
/**
* Populate the given context with the perm-scoped tools.
*
* @param tools The list of tools with which to populate the
* session.
* @param context The context to populate.
- * @param pipelineData The current RunData object
+ * @param data The current RunData or PipelineData object
* @param user The <code>User</code> object whose storage to
* retrieve the tool from.
*/
private void populateWithPermTools(List<ToolData> tools, Context context,
- RunData data, User user)
+ Object data, User user)
{
// Iterate the tools
- for (Iterator<ToolData> it = tools.iterator(); it.hasNext();)
+ for (ToolData toolData : tools)
{
- ToolData toolData = it.next();
try
{
// ensure that tool is created only once for a user
@@ -846,7 +633,7 @@ public class TurbinePullService
}
// *NOT* else
- if(tool != null)
+ if (tool != null)
{
// This is a semantics change. In the old
// Turbine, Session tools were initialized and
@@ -1045,7 +832,8 @@ public class TurbinePullService
private RunData getRunData(PipelineData pipelineData)
{
- if(!(pipelineData instanceof RunData)){
+ if (!(pipelineData instanceof RunData))
+ {
throw new RuntimeException("Can't cast to rundata from pipeline
data.");
}
return (RunData)pipelineData;
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=1854787&r1=1854786&r2=1854787&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 Mar 4 18:30:25 2019
@@ -262,8 +262,7 @@ public class DefaultTurbineRunData
ParameterParser parameters = getParameterParser();
HttpServletRequest request = getRequest();
- if ((parameters != null) &&
- (parameters.getRequest() != request))
+ if (parameters != null && parameters.getRequest() != request)
{
parameters.setRequest(request);
}
@@ -283,8 +282,7 @@ public class DefaultTurbineRunData
CookieParser cookies = getCookieParser();
HttpServletRequest request = getRequest();
- if ((cookies != null) &&
- (cookies.getRequest() != request))
+ if (cookies != null && cookies.getRequest() != request)
{
cookies.setData(request, getResponse());
}
@@ -363,7 +361,8 @@ 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.
+ * To delete ACL from session use key {@link
TurbineConstants#ACL_SESSION_KEY}.
+ * Invalidate session, if session persist.
*
* @param acl an access control list.
*/
@@ -381,8 +380,8 @@ public class DefaultTurbineRunData
@Override
public boolean hasAction()
{
- return (StringUtils.isNotEmpty(this.action)
- && !this.action.equalsIgnoreCase("null"));
+ return StringUtils.isNotEmpty(this.action)
+ && !this.action.equalsIgnoreCase("null");
}
/**
@@ -395,7 +394,7 @@ public class DefaultTurbineRunData
@Override
public String getAction()
{
- return (hasAction() ? this.action : "");
+ return hasAction() ? this.action : "";
}
/**
@@ -501,7 +500,7 @@ public class DefaultTurbineRunData
@Override
public String getScreen()
{
- return (hasScreen() ? this.screen : "");
+ return hasScreen() ? this.screen : "";
}
/**
@@ -698,7 +697,7 @@ public class DefaultTurbineRunData
@Override
public String getTitle()
{
- return (this.title == null ? "" : this.title);
+ return this.title == null ? "" : this.title;
}
/**
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/rundata/TurbineRunDataService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/rundata/TurbineRunDataService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/rundata/TurbineRunDataService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/rundata/TurbineRunDataService.java
Mon Mar 4 18:30:25 2019
@@ -129,8 +129,7 @@ public class TurbineRunDataService
value = conf.getString(key);
for (int j = 0; j < plist.length; j++)
{
- if (key.endsWith(plist[j]) &&
- (key.length() > (plist[j].length() + 1)))
+ if (key.endsWith(plist[j]) && key.length() >
plist[j].length() + 1)
{
key = key.substring(0, key.length() -
plist[j].length() - 1);
config = (String[]) configurations.get(key);
@@ -221,9 +220,7 @@ public class TurbineRunDataService
// to each and every module. Since each thread has its own RunData
// object, it is not necessary to perform synchronization for
// the data within this object.
- if ((req == null)
- || (res == null)
- || (config == null))
+ if (req == null || res == null || config == null)
{
throw new IllegalArgumentException("HttpServletRequest, "
+ "HttpServletResponse or ServletConfig was null.");
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/schedule/JobQueue.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/schedule/JobQueue.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/schedule/JobQueue.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/schedule/JobQueue.java
Mon Mar 4 18:30:25 2019
@@ -188,7 +188,7 @@ public class JobQueue<J extends JobEntry
{
Long time1 = Long.valueOf(o1.getNextRuntime());
Long time2 = Long.valueOf(o2.getNextRuntime());
- return (time1.compareTo(time2));
+ return time1.compareTo(time2);
}
};
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/session/SessionService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/session/SessionService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/session/SessionService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/session/SessionService.java
Mon Mar 4 18:30:25 2019
@@ -22,6 +22,7 @@ package org.apache.turbine.services.sess
import java.util.Collection;
+
import javax.servlet.http.HttpSession;
import org.apache.turbine.om.security.User;
@@ -43,7 +44,7 @@ public interface SessionService extends
/**
* The key under which this service is stored in TurbineServices.
*/
- static final String SERVICE_NAME = "SessionService";
+ String SERVICE_NAME = "SessionService";
/**
* Gets all active sessions
@@ -114,5 +115,4 @@ public interface SessionService extends
* @return Collection of HtttSession objects
*/
Collection<HttpSession> getSessionsForUser(User user);
-
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/template/TemplateService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/template/TemplateService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/template/TemplateService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/template/TemplateService.java
Mon Mar 4 18:30:25 2019
@@ -43,7 +43,7 @@ public interface TemplateService
/**
* The key under which this service is stored in TurbineServices.
*/
- static final String SERVICE_NAME = "TemplateService";
+ String SERVICE_NAME = "TemplateService";
/** Default Template Name. */
String DEFAULT_TEMPLATE_KEY = "default.template";
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/template/TurbineTemplateService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/template/TurbineTemplateService.java
Mon Mar 4 18:30:25 2019
@@ -340,7 +340,7 @@ public class TurbineTemplateService
int dotIndex = template.lastIndexOf(EXTENSION_SEPARATOR);
- return (dotIndex < 0) ? getDefaultExtension() :
template.substring(dotIndex + 1);
+ return dotIndex < 0 ? getDefaultExtension() :
template.substring(dotIndex + 1);
}
@@ -434,7 +434,7 @@ public class TurbineTemplateService
@Override
public String getDefaultPageName(String template)
{
- return (mapperRegistry[PAGE_KEY]).getDefaultName(template);
+ return mapperRegistry[PAGE_KEY].getDefaultName(template);
}
/**
@@ -448,7 +448,7 @@ public class TurbineTemplateService
@Override
public String getDefaultScreenName(String template)
{
- return (mapperRegistry[SCREEN_KEY]).getDefaultName(template);
+ return mapperRegistry[SCREEN_KEY].getDefaultName(template);
}
/**
@@ -462,7 +462,7 @@ public class TurbineTemplateService
@Override
public String getDefaultLayoutName(String template)
{
- return (mapperRegistry[LAYOUT_KEY]).getDefaultName(template);
+ return mapperRegistry[LAYOUT_KEY].getDefaultName(template);
}
/**
@@ -476,7 +476,7 @@ public class TurbineTemplateService
@Override
public String getDefaultNavigationName(String template)
{
- return (mapperRegistry[NAVIGATION_KEY]).getDefaultName(template);
+ return mapperRegistry[NAVIGATION_KEY].getDefaultName(template);
}
/**
@@ -490,7 +490,7 @@ public class TurbineTemplateService
@Override
public String getDefaultLayoutTemplateName(String template)
{
- return (mapperRegistry[LAYOUT_TEMPLATE_KEY]).getDefaultName(template);
+ return mapperRegistry[LAYOUT_TEMPLATE_KEY].getDefaultName(template);
}
/**
@@ -505,8 +505,7 @@ public class TurbineTemplateService
{
ParameterParser pp = pipelineData.get(Turbine.class,
ParameterParser.class);
String template = pp.get(URIConstants.CGI_TEMPLATE_PARAM);
- return (template != null) ?
- getDefaultPageName(template) : getDefaultPage();
+ return template != null ? getDefaultPageName(template) :
getDefaultPage();
}
/**
@@ -521,8 +520,7 @@ public class TurbineTemplateService
{
ParameterParser pp = pipelineData.get(Turbine.class,
ParameterParser.class);
String template = pp.get(URIConstants.CGI_TEMPLATE_PARAM);
- return (template != null) ?
- getDefaultLayoutName(template) : getDefaultLayout();
+ return template != null ? getDefaultLayoutName(template) :
getDefaultLayout();
}
/**
@@ -537,7 +535,7 @@ public class TurbineTemplateService
public String getScreenName(String template)
throws Exception
{
- return (mapperRegistry[SCREEN_KEY]).getMappedName(template);
+ return mapperRegistry[SCREEN_KEY].getMappedName(template);
}
/**
@@ -552,7 +550,7 @@ public class TurbineTemplateService
public String getLayoutName(String template)
throws Exception
{
- return (mapperRegistry[LAYOUT_KEY]).getMappedName(template);
+ return mapperRegistry[LAYOUT_KEY].getMappedName(template);
}
/**
@@ -567,7 +565,7 @@ public class TurbineTemplateService
public String getNavigationName(String template)
throws Exception
{
- return (mapperRegistry[NAVIGATION_KEY]).getMappedName(template);
+ return mapperRegistry[NAVIGATION_KEY].getMappedName(template);
}
/**
@@ -583,7 +581,7 @@ public class TurbineTemplateService
public String getScreenTemplateName(String template)
throws Exception
{
- return (mapperRegistry[SCREEN_TEMPLATE_KEY]).getMappedName(template);
+ return mapperRegistry[SCREEN_TEMPLATE_KEY].getMappedName(template);
}
/**
@@ -598,7 +596,7 @@ public class TurbineTemplateService
public String getLayoutTemplateName(String template)
throws Exception
{
- return (mapperRegistry[LAYOUT_TEMPLATE_KEY]).getMappedName(template);
+ return mapperRegistry[LAYOUT_TEMPLATE_KEY].getMappedName(template);
}
/**
@@ -614,7 +612,7 @@ public class TurbineTemplateService
public String getNavigationTemplateName(String template)
throws Exception
{
- return
(mapperRegistry[NAVIGATION_TEMPLATE_KEY]).getMappedName(template);
+ return mapperRegistry[NAVIGATION_TEMPLATE_KEY].getMappedName(template);
}
/**
@@ -807,12 +805,12 @@ public class TurbineTemplateService
tm.setDefaultProperty(mapperDefaultProperty[i]);
tm.setSeparator(mapperSeparator[i]);
- if ((mapperLoader[i] != null) && (tm instanceof ClassMapper))
+ if (mapperLoader[i] != null && tm instanceof ClassMapper)
{
((ClassMapper) tm).setLoader(mapperLoader[i]);
}
- if ((mapperPrefix[i] != null) && (tm instanceof
BaseTemplateMapper))
+ if (mapperPrefix[i] != null && tm instanceof BaseTemplateMapper)
{
((BaseTemplateMapper) tm).setPrefix(mapperPrefix[i]);
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/ui/UIService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/ui/UIService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
--- turbine/core/trunk/src/java/org/apache/turbine/services/ui/UIService.java
(original)
+++ turbine/core/trunk/src/java/org/apache/turbine/services/ui/UIService.java
Mon Mar 4 18:30:25 2019
@@ -38,26 +38,26 @@ public interface UIService extends Servi
/**
* The service identifier.
*/
- public String SERVICE_NAME = "UIService";
+ String SERVICE_NAME = "UIService";
/**
* Refresh all skins.
*/
- public void refresh();
+ void refresh();
/**
* Refresh a particular skin.
*
* @param skinName the name of the skin to clear.
*/
- public void refresh(String skinName);
+ void refresh(String skinName);
/**
* Provide access to the list of available skin names.
*
* @return the available skin names.
*/
- public String[] getSkinNames();
+ String[] getSkinNames();
/**
* Get the name of the default skin name for the web application from the
@@ -68,7 +68,7 @@ public interface UIService extends Servi
*
* @return the name of the default skin for the web application.
*/
- public String getWebappSkinName();
+ String getWebappSkinName();
/**
* Retrieve a skin property from the named skin. If the property is not
@@ -84,7 +84,7 @@ public interface UIService extends Servi
* default skin), the webapp skin, the default skin or <code>null</code>,
* depending on whether or not the property or skins exist.
*/
- public String get(String skinName, String key);
+ String get(String skinName, String key);
/**
* Retrieve a skin property from the default skin for the webapp. If the
@@ -98,7 +98,7 @@ public interface UIService extends Servi
* default skin), the default skin or <code>null</code>, depending on
* whether or not the property or skins exist.
*/
- public String get(String key);
+ String get(String key);
/**
* Retrieve the URL for an image that is part of a skin. The images are
@@ -114,7 +114,7 @@ public interface UIService extends Servi
* @param serverData the serverData to use as the basis for the URL.
* @return the image URL
*/
- public String image(String skinName, String imageId, ServerData
serverData);
+ String image(String skinName, String imageId, ServerData serverData);
/**
* Retrieve the URL for an image that is part of a skin. The images are
@@ -124,7 +124,7 @@ public interface UIService extends Servi
* @param imageId the id of the image whose URL will be generated.
* @return the image URL
*/
- public String image(String skinName, String imageId);
+ String image(String skinName, String imageId);
/**
* Retrieve the URL for the style sheet that is part of a skin. The style
is
@@ -140,7 +140,7 @@ public interface UIService extends Servi
* @param serverData the serverData to use as the basis for the URL.
* @return the CSS URL
*/
- public String getStylecss(String skinName, ServerData serverData);
+ String getStylecss(String skinName, ServerData serverData);
/**
* Retrieve the URL for the style sheet that is part of a skin. The style
is
@@ -150,7 +150,7 @@ public interface UIService extends Servi
* @param skinName the name of the skin to retrieve the style sheet from.
* @return the CSS URL
*/
- public String getStylecss(String skinName);
+ String getStylecss(String skinName);
/**
* Retrieve the URL for a given script that is part of a skin. The script
is
@@ -166,7 +166,7 @@ public interface UIService extends Servi
* @param serverData the serverData to use as the basis for the URL.
* @return the script URL
*/
- public String getScript(String skinName, String filename,
+ String getScript(String skinName, String filename,
ServerData serverData);
/**
@@ -177,6 +177,6 @@ public interface UIService extends Servi
* @param filename the name of the script file.
* @return the script URL
*/
- public String getScript(String skinName, String filename);
+ String getScript(String skinName, String filename);
}
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/uniqueid/TurbineUniqueIdService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/uniqueid/TurbineUniqueIdService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/uniqueid/TurbineUniqueIdService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/uniqueid/TurbineUniqueIdService.java
Mon Mar 4 18:30:25 2019
@@ -1,6 +1,8 @@
package org.apache.turbine.services.uniqueid;
+import java.nio.charset.StandardCharsets;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -22,6 +24,7 @@ package org.apache.turbine.services.uniq
import java.security.MessageDigest;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.codec.binary.Base64;
import org.apache.logging.log4j.LogManager;
@@ -46,11 +49,11 @@ public class TurbineUniqueIdService
private static final Logger log =
LogManager.getLogger(TurbineUniqueIdService.class);
/** The identifier of this instance of turbine. */
- protected static String turbineId = "UNKNOWN";
+ private static String turbineId = "UNKNOWN";
- protected static String turbineURL = "UNKNOWN";
+ private static String turbineURL = "UNKNOWN";
- protected static int counter;
+ private static AtomicInteger counter;
/**
@@ -63,19 +66,22 @@ public class TurbineUniqueIdService
{
try
{
+ counter = new AtomicInteger();
+
// This might be a problem if the unique Id Service runs
// before Turbine got its first request. In this case,
// getDefaultServerData will return just a dummy value
// which is the same for all instances of Turbine.
//
// TODO This needs definitely further working.
- String url = Turbine.getDefaultServerData().toString();
+ turbineURL = Turbine.getDefaultServerData().toString();
MessageDigest md = MessageDigest.getInstance("MD5");
- byte [] bytesId = md.digest(url.getBytes("UTF-8"));
- turbineId = new String(Base64.encodeBase64(bytesId),"UTF-8");
+ byte [] bytesId =
md.digest(turbineURL.getBytes(StandardCharsets.UTF_8));
+ turbineId = new String(Base64.encodeBase64(bytesId),
+ StandardCharsets.UTF_8);
- log.info("This is Turbine instance running at: {}", url);
+ log.info("This is Turbine instance running at: {}", turbineURL);
log.info("The instance id is #{}", turbineId);
setInit(true);
}
@@ -99,8 +105,8 @@ public class TurbineUniqueIdService
* <p> Returns an identifier of this Turbine instance that is unique
* both on the server and worldwide. This identifier is computed
* as an MD5 sum of the URL (including schema, address, port if
- * different that 80/443 respecively, context and servlet name).
- * There is an overwhelming probalility that this id will be
+ * different that 80/443 respectively, context and servlet name).
+ * There is an overwhelming probability that this id will be
* different that all other Turbine instances online.
*
* @return A String with the instance identifier.
@@ -113,7 +119,7 @@ public class TurbineUniqueIdService
/**
* <p> Returns an identifier that is unique within this turbine
- * instance, but does not have random-like apearance.
+ * instance, but does not have random-like appearance.
*
* @return A String with the non-random looking instance
* identifier.
@@ -121,11 +127,7 @@ public class TurbineUniqueIdService
@Override
public String getUniqueId()
{
- int current;
- synchronized (TurbineUniqueIdService.class)
- {
- current = counter++;
- }
+ int current = counter.getAndIncrement();
String id = Integer.toString(current);
// If you manage to get more than 100 million of ids, you'll
Modified:
turbine/core/trunk/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java
(original)
+++
turbine/core/trunk/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java
Mon Mar 4 18:30:25 2019
@@ -127,7 +127,7 @@ public class TurbineVelocityService
{
try
{
- initVelocity();
+ velocity = getInitializedVelocityEngine();
// We can only load the Pull Model ToolBox
// if the Pull service has been listed in the TR.props
@@ -455,8 +455,9 @@ public class TurbineVelocityService
* Turbine configuration which relates to velocity.
*
* @throws Exception An Error occurred.
+ * @return an initialized VelocityEngine instance
*/
- private synchronized void initVelocity()
+ private VelocityEngine getInitializedVelocityEngine()
throws Exception
{
// Get the configuration for this service.
@@ -467,9 +468,11 @@ public class TurbineVelocityService
// backward compatibility, can be overridden in the configuration
conf.setProperty(RuntimeConstants.RUNTIME_LOG_NAME, "velocity");
- velocity = new VelocityEngine();
+ VelocityEngine velocity = new VelocityEngine();
setVelocityProperties(velocity, conf);
velocity.init();
+
+ return velocity;
}
Modified:
turbine/core/trunk/src/test/org/apache/turbine/modules/scheduledjobs/SimpleJob.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/modules/scheduledjobs/SimpleJob.java?rev=1854787&r1=1854786&r2=1854787&view=diff
==============================================================================
---
turbine/core/trunk/src/test/org/apache/turbine/modules/scheduledjobs/SimpleJob.java
(original)
+++
turbine/core/trunk/src/test/org/apache/turbine/modules/scheduledjobs/SimpleJob.java
Mon Mar 4 18:30:25 2019
@@ -35,8 +35,7 @@ import org.apache.turbine.services.sched
* @author <a href="mailto:[email protected]">Eric Pugh</a>
* @version $Id$
*/
-public class SimpleJob
- extends ScheduledJob
+public class SimpleJob implements ScheduledJob
{
/** Logging */
private static Log log = LogFactory.getLog(SimpleJob.class);