You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by se...@apache.org on 2003/09/18 07:27:40 UTC
cvs commit: jakarta-turbine-2/proposals/seade/SystemProperties readme.txt
seade 2003/09/17 22:27:40
Added: proposals/seade/UIService/org/apache/turbine/services/ui
TurbineUI.java TurbineUIService.java UIService.java
UITool.java
proposals/seade/SystemProperties/org/apache/turbine/services/systemproperties
TurbineSystemPropertiesService.java
SystemPropertiesService.java
proposals/seade/UIService readme.txt
proposals/seade/SystemProperties readme.txt
Log:
Add proposals for UI and SystemProperties services.
Revision Changes Path
1.1 jakarta-turbine-2/proposals/seade/UIService/org/apache/turbine/services/ui/TurbineUI.java
Index: TurbineUI.java
===================================================================
package org.apache.turbine.services.ui;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.util.ServerData;
/**
* This is a convenience class provided to allow access to the UIService
* through static methods. The UIService should ALWAYS be accessed via
* either this class or UITool.
*
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id: TurbineUI.java,v 1.1 2003/09/18 05:27:40 seade Exp $
* @see UIService
* @see UITool
*/
public class TurbineUI
{
/**
* Refresh all skins.
*/
public static void refresh()
{
((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).refresh();
}
/**
* Refresh a particular skin.
*
* @param skinName the name of the skin to clear.
*/
public static void refresh(String skinName)
{
((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).refresh(skinName);
}
/**
* Provide access to the list of available skin names.
*
* @return the available skin names.
*/
public static String[] getSkinNames()
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).getSkinNames();
}
/**
* Get the name of the default skin name for the web application from the
* TurbineResources.propertiess file. If the property is not present the
* name of the default skin will be returned. Note that the web application
* skin name may be something other than default, in which case its
* properties will default to the skin with the name "default".
*
* @return the name of the default skin for the web application.
*/
public static String getWebappSkinName()
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).getWebappSkinName();
}
/**
* Retrieve a skin property from the named skin. If the property is not
* defined in the named skin the value for the default skin will be
* provided. If the named skin does not exist then the skin configured for
* the webapp will be used. If the webapp skin does not exist the default
* skin will be used. If the default skin does not exist then
* <code>null</code> will be returned.
*
* @param skinName the name of the skin to retrieve the property from.
* @param key the key to retrieve from the skin.
* @return the value of the property for the named skin (defaulting to the
* default skin), the webapp skin, the default skin or <code>null</code>,
* depending on whether or not the property or skins exist.
*/
public static String get(String skinName, String key)
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).get(skinName, key);
}
// /**
// * Retrieve a skin property from the default skin for the webapp. If the
// * property is not defined in the webapp skin the value for the default skin
// * will be provided. If the webapp skin does not exist the default skin
// * will be used. If the default skin does not exist then <code>null</code>
// * will be returned.
// *
// * @param key the key to retrieve.
// * @return the value of the property for the webapp skin (defaulting to the
// * default skin), the default skin or <code>null</code>, depending on
// * whether or not the property or skins exist.
// */
// public static String get(String key)
// {
// return ((UIService) TurbineServices.getInstance()
// .getService(UIService.SERVICE_NAME)).get(getWebappSkinName(), key);
// }
/**
* Retrieve the URL for an image that is part of a skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the image(String image)
* method would probably be enough, but I'm not absolutely positive.
*
* @param skinName the name of the skin to retrieve the image from.
* @param imageId the id of the image whose URL will be generated.
* @param data the RunData to use as the source of the ServerData to use as
* the basis for the URL.
*/
public static String image(String skinName, String imageId,
ServerData serverData)
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME))
.image(skinName, imageId, serverData);
}
// public static String image(String skinName, String imageId, RunData data)
// {
// return image(skinName, imageId, data.getServerData());
// }
/**
* Retrieve the URL for an image that is part of a skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* @param skinName the name of the skin to retrieve the image from.
* @param imageId the id of the image whose URL will be generated.
*/
public static String image(String skinName, String imageId)
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).image(skinName, imageId);
}
/**
* Retrieve the URL for the style sheet that is part of a skin. The style is
* stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the style() method would
* probably be enough, but I'm not absolutely positive.
*
* @param skinName the name of the skin to retrieve the style sheet from.
* @param data the RunData to use as the source of the ServerData to use as
* the basis for the URL.
*/
public static String getStylecss(String skinName, ServerData serverData)
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME))
.getStylecss(skinName, serverData);
}
// public static String getStylecss(String skinName, RunData data)
// {
// return getStylecss(skinName, data.getServerData());
// }
/**
* Retrieve the URL for the style sheet that is part of a skin. The style is
* stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* @param skinName the name of the skin to retrieve the style sheet from.
*/
public static String getStylecss(String skinName)
{
return ((UIService) TurbineServices.getInstance()
.getService(UIService.SERVICE_NAME)).getStylecss(skinName);
}
}
1.1 jakarta-turbine-2/proposals/seade/UIService/org/apache/turbine/services/ui/TurbineUIService.java
Index: TurbineUIService.java
===================================================================
package org.apache.turbine.services.ui;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.util.HashMap;
import java.util.Properties;
import org.apache.turbine.Turbine;
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.TurbineBaseService;
import org.apache.turbine.services.pull.TurbinePull;
import org.apache.turbine.util.ServerData;
import org.apache.turbine.util.uri.DataURI;
/**
* The UI service provides for shared access to User Interface (skin) files,
* as well as the ability for non-default skin files to inherit properties from
* a default skin. Use TurbineUI to access skin properties from your screen
* classes and action code. UITool is provided as a pull tool for accessing
* skin properties from your templates.
*
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id: TurbineUIService.java,v 1.1 2003/09/18 05:27:40 seade Exp $
* @see UIService
* @see UITool
*/
public class TurbineUIService
extends TurbineBaseService
implements UIService
{
/**
* A FilenameFilter that returns only directories.
* todo Replace with commons-io DirectoryFileFilter
*/
private class DirectoryFileFilter implements FilenameFilter
{
public boolean accept(File dir, String fileName)
{
File file = new File(dir, fileName);
if (file.isDirectory())
{
return true;
}
return false;
}
}
private static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(TurbineUIService.class);
/**
* The location of the skins within the application
* resources directory.
*/
private static final String SKINS_DIRECTORY = "/ui/skins";
/**
* The name of the directory where images are
* stored for this skin.
*/
private static final String IMAGES_DIRECTORY = "/images";
/**
* Property tag for the skin that is to be
* used for the web application.
*/
private static final String SKIN_PROPERTY = "tool.ui.skin";
/**
* Default skin name. This name actually represents
* a directory in the WEBAPP/resources/ui/skins
* directory. There is a file called skin.props
* which actually contains the name/value pairs.
*/
public static final String SKIN_PROPERTY_DEFAULT = "default";
/**
* The skins directory.
*/
private static final String skinsDirectory
= TurbinePull.getAbsolutePathToResourcesDirectory()
+ SKINS_DIRECTORY;
/**
* The file within the skin directory that actually
* contains the name/value pairs for the skin.
*/
private static final String SKIN_PROPS_FILE = "skin.props";
/**
* The file name for the skin style sheet.
*/
private static final String SKIN_CSS_FILE = "skin.css";
/**
* The directory where application tool resources are stored.
*/
private static String resourcesDirectory;
/**
* The skin Properties store.
*/
private HashMap skins = new HashMap();
/**
* Refresh the service by clearing all skins.
*/
public void refresh()
{
clearSkins();
}
/**
* Refresh a particular skin by clearing it.
*
* @param skinName the name of the skin to clear.
*/
public void refresh(String skinName)
{
clearSkin(skinName);
}
/**
* Retrieve the Properties for a specific skin. If they are not yet loaded
* they will be. If the specified skin does not exist properties for the
* default skin configured for the webapp will be returned and an error
* level message will be written to the log. If the webapp skin does not
* exist the default skin will be used and id that doesn't exist an empty
* Properties will be returned.
*
* @param skinName the name of the skin whose properties are to be
* retrieved.
* @return the Properties for the named skin or the properties for the
* default skin configured for the webapp if the named skin does not exist.
*/
private Properties getSkinProperties(String skinName)
{
Properties skinProperties = (Properties) skins.get(skinName);
return null != skinProperties ? skinProperties : loadSkin(skinName);
}
/**
* Retrieve a skin property from the named skin. If the property is not
* defined in the named skin the value for the default skin will be
* provided. If the named skin does not exist then the skin configured for
* the webapp will be used. If the webapp skin does not exist the default
* skin will be used. If the default skin does not exist then
* <code>null</code> will be returned.
*
* @param skinName the name of the skin to retrieve the property from.
* @param key the key to retrieve from the skin.
* @return the value of the property for the named skin (defaulting to the
* 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)
{
Properties skinProperties = getSkinProperties(skinName);
return skinProperties.getProperty(key);
}
/**
* Provide access to the list of available skin names.
*
* @return the available skin names.
*/
public String[] getSkinNames()
{
File skinsDir = new File(skinsDirectory);
return skinsDir.list(new DirectoryFileFilter());
}
/**
* Clear the map of stored skins.
*/
private void clearSkins()
{
synchronized (skins)
{
skins = new HashMap();
}
log.debug("All skins were cleared.");
}
/**
* Clear a particular skin from the map of stored skins.
*
* @param skinName the name of the skin to clear.
*/
private void clearSkin(String skinName)
{
synchronized (skins)
{
if (!skinName.equals(SKIN_PROPERTY_DEFAULT))
{
skins.remove(SKIN_PROPERTY_DEFAULT);
}
skins.remove(skinName);
}
log.debug("The skin \"" + skinName
+ "\" was cleared (will also clear \"default\" skin).");
}
/**
* Load the specified skin.
*
* @param skinName the name of the skin to load.
* @return the Properties for the named skin if it exists, or the skin
* configured for the web application if it does not exist, or the default
* skin if that does not exist, or an empty Parameters object if even that
* cannot be found.
*
* @param skinName the name of the skin whose Properties is to be retrieved.
* @return the properties for the named skin, the webapp skin, the default
* skin or an empty Properties, depending on which skins exist.
*/
private synchronized Properties loadSkin(String skinName)
{
Properties defaultSkinProperties = null;
if (!skinName.equals(SKIN_PROPERTY_DEFAULT))
{
defaultSkinProperties = getSkinProperties(SKIN_PROPERTY_DEFAULT);
}
// The following line is okay even for default.
Properties skinProperties = new Properties(defaultSkinProperties);
try
{
log.debug("Loading selected skin from: " + skinsDirectory + "/"
+ skinName + "/" + SKIN_PROPS_FILE);
FileInputStream is = new FileInputStream(
skinsDirectory + "/" + skinName + "/" + SKIN_PROPS_FILE);
skinProperties.load(is);
}
catch (Exception e)
{
log.error("Cannot load skin: " + skinName, e);
if (!skinName.equals(getWebappSkinName())
&& !skinName.equals(SKIN_PROPERTY_DEFAULT))
{
log.error("Attempting to return the skin configured for "
+ "webapp instead of " + skinName);
return getSkinProperties(getWebappSkinName());
}
else if (!skinName.equals(SKIN_PROPERTY_DEFAULT))
{
log.error("Attempting to return the default skin instead of "
+ skinName);
return getSkinProperties(SKIN_PROPERTY_DEFAULT);
}
else
{
log.error("No skins available - returning an empty Properties");
return new Properties();
}
}
// Replace in skins HashMap
synchronized (skins)
{
skins.put(skinName, skinProperties);
}
return skinProperties;
}
/**
* Get the name of the default skin name for the web application from the
* TurbineResources.propertiess file. If the property is not present the
* name of the default skin will be returned. Note that the web application
* skin name may be something other than default, in which case its
* properties will default to the skin with the name "default".
*
* @return the name of the default skin for the web application.
*/
public String getWebappSkinName()
{
return Turbine.getConfiguration()
.getString(SKIN_PROPERTY, SKIN_PROPERTY_DEFAULT);
}
/**
* Retrieve the URL for an image that is part of a skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the image(String image)
* method would probably be enough, but I'm not absolutely positive.
*
* @param skinName the name of the skin to retrieve the image from.
* @param imageId the id of the image whose URL will be generated.
* @param serverData the serverData to use as the basis for the URL.
*/
public String image(String skinName, String imageId, ServerData serverData)
{
DataURI du = new DataURI(serverData);
StringBuffer sb = new StringBuffer();
sb.append(resourcesDirectory).
append(SKINS_DIRECTORY).
append("/").
append(skinName).
append(IMAGES_DIRECTORY).
append("/").
append(imageId);
du.setScriptName(sb.toString());
return du.getAbsoluteLink();
}
/**
* Retrieve the URL for an image that is part of a skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* @param skinName the name of the skin to retrieve the image from.
* @param imageId the id of the image whose URL will be generated.
*/
public String image(String skinName, String imageId)
{
ServerData sd = Turbine.getDefaultServerData();
DataURI du = new DataURI(sd);
StringBuffer sb = new StringBuffer();
sb.append(resourcesDirectory).
append(SKINS_DIRECTORY).
append("/").
append(skinName).
append(IMAGES_DIRECTORY).
append("/").
append(imageId);
du.setScriptName(sb.toString());
return du.getAbsoluteLink();
}
/**
* Retrieve the URL for the style sheet that is part of a skin. The style is
* stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the style() method would
* probably be enough, but I'm not absolutely positive.
*
* @param skinName the name of the skin to retrieve the style sheet from.
* @param serverData the serverData to use as the basis for the URL.
*/
public String getStylecss(String skinName, ServerData serverData)
{
DataURI du = new DataURI(serverData);
StringBuffer sb = new StringBuffer();
sb.append(resourcesDirectory).
append(SKINS_DIRECTORY).
append("/").
append(skinName).
append("/").
append(SKIN_CSS_FILE);
du.setScriptName(sb.toString());
return du.getAbsoluteLink();
}
/**
* Retrieve the URL for the style sheet that is part of a skin. The style is
* stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* @param skinName the name of the skin to retrieve the style sheet from.
*/
public String getStylecss(String skinName)
{
ServerData sd = Turbine.getDefaultServerData();
DataURI du = new DataURI(sd);
StringBuffer sb = new StringBuffer();
sb.append(resourcesDirectory).
append(SKINS_DIRECTORY).
append("/").
append(skinName).
append("/").
append(SKIN_CSS_FILE);
du.setScriptName(sb.toString());
return du.getAbsoluteLink();
}
// ---- Service initilization ------------------------------------------
/**
* Initializes the service.
*/
public void init() throws InitializationException
{
// Ensure PullService has been initialised.
getServiceBroker().initService("PullService");
// Get the resources directory that is specificed in the TR.props or
// default to "resources", relative to the webapp.
resourcesDirectory = TurbinePull.getResourcesDirectory();
setInit(true);
}
/**
* Returns to uninitialized state.
*/
public void shutdown()
{
clearSkins();
setInit(false);
}
}
1.1 jakarta-turbine-2/proposals/seade/UIService/org/apache/turbine/services/ui/UIService.java
Index: UIService.java
===================================================================
package org.apache.turbine.services.ui;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.turbine.services.Service;
import org.apache.turbine.util.ServerData;
/**
* The UI service provides for shared access to User Interface (skin) files,
* as well as the ability for non-default skin files to inherit properties from
* a default skin. Use TurbineUI to access skin properties from your screen
* classes and action code. UITool is provided as a pull tool for accessing
* skin properties from your templates.
*
* <p>Skins are lazy loaded in that they are not loaded until first used.
*
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id: UIService.java,v 1.1 2003/09/18 05:27:40 seade Exp $
* @see UIService
* @see UITool
*/
public interface UIService extends Service
{
/**
* The service identifier.
*/
public String SERVICE_NAME = "UIService";
/**
* Refresh all skins.
*/
public void refresh();
/**
* Refresh a particular skin.
*
* @param skinName the name of the skin to clear.
*/
public void refresh(String skinName);
/**
* Provide access to the list of available skin names.
*
* @return the available skin names.
*/
public String[] getSkinNames();
/**
* Get the name of the default skin name for the web application from the
* TurbineResources.propertiess file. If the property is not present the
* name of the default skin will be returned. Note that the web application
* skin name may be something other than default, in which case its
* properties will default to the skin with the name "default".
*
* @return the name of the default skin for the web application.
*/
public String getWebappSkinName();
/**
* Retrieve a skin property from the named skin. If the property is not
* defined in the named skin the value for the default skin will be
* provided. If the named skin does not exist then the skin configured for
* the webapp will be used. If the webapp skin does not exist the default
* skin will be used. If the default skin does not exist then
* <code>null</code> will be returned.
*
* @param skinName the name of the skin to retrieve the property from.
* @param key the key to retrieve from the skin.
* @return the value of the property for the named skin (defaulting to the
* 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);
/**
* Retrieve the URL for an image that is part of a skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the image(String image)
* method would probably be enough, but I'm not absolutely positive.
*
* @param skinName the name of the skin to retrieve the image from.
* @param imageId the id of the image whose URL will be generated.
* @param serverData the serverData to use as the basis for the URL.
*/
public String image(String skinName, String imageId, ServerData serverData);
/**
* Retrieve the URL for an image that is part of a skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* @param skinName the name of the skin to retrieve the image from.
* @param imageId the id of the image whose URL will be generated.
*/
public String image(String skinName, String imageId);
/**
* Retrieve the URL for the style sheet that is part of a skin. The style is
* stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the style() method would
* probably be enough, but I'm not absolutely positive.
*
* @param skinName the name of the skin to retrieve the style sheet from.
* @param serverData the serverData to use as the basis for the URL.
*/
public String getStylecss(String skinName, ServerData serverData);
/**
* Retrieve the URL for the style sheet that is part of a skin. The style is
* stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* @param skinName the name of the skin to retrieve the style sheet from.
*/
public String getStylecss(String skinName);
}
1.1 jakarta-turbine-2/proposals/seade/UIService/org/apache/turbine/services/ui/UITool.java
Index: UITool.java
===================================================================
package org.apache.turbine.services.ui;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.turbine.om.security.User;
import org.apache.turbine.services.pull.ApplicationTool;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.ServerData;
/**
* Manages all UI elements for a Turbine Application. Any UI element can be
* accessed in any template using the $ui handle (assuming you use the default
* PullService configuration). So, for example, you could access the background
* colour for your pages by using $ui.bgcolor
* <p>
* This implementation provides a single level of inheritance in that if a
* property does not exist in a non-default skin, the value from the default
* skin will be used. By only requiring values different to those stored in
* the default skin to appear in the non-default skins the amount of memory
* consumed in cases where the UserManager insance is used at a non-global
* scope will potentially be reduced due to the fact that a shared instance of
* the default skin properties can be used. Note that this inheritance only
* applies to property values - it does not apply to any images or stylesheets
* that may form part of your skins.
* <p>
* This is an application pull tool for the template system. You should not
* use it in a normal application!
* <p>
*
* This is an application pull tool for the template system. You should
* <b>not</b> use it in a normal application (use UIService instead).
*
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id: UITool.java,v 1.1 2003/09/18 05:27:40 seade Exp $
* @see UIService
*/
public class UITool implements ApplicationTool
{
/** Logging */
private static Log log = LogFactory.getLog(UITool.class);
/**
* Attribute name of skinName value in User's temp hashmap.
*/
public static final String SKIN_ATTRIBUTE =
UITool.class.getName()+ ".skin";
/**
* The actual skin being used for the webapp.
*/
private String skinName;
/**
* Refresh the tool.
*/
public void refresh()
{
TurbineUI.refresh(getSkin());
log.debug("UITool refreshed for skin: " + getSkin());
}
/**
* Provide access to the list of available skin names.
*
* @return the available skin names.
*/
public String[] getSkinNames()
{
return TurbineUI.getSkinNames();
}
/**
* Get the name of the default skin name for the web application from the
* TurbineResources.propertiess file. If the property is not present the
* name of the default skin will be returned. Note that the web application
* skin name may be something other than default, in which case its
* properties will default to the skin with the name "default".
*
* @return the name of the default skin for the web application.
*/
public String getWebappSkinName()
{
return TurbineUI.getWebappSkinName();
}
/**
* Retrieve a skin property. If the property is not defined in the current
* skin the value for the default skin will be provided. If the current
* skin does not exist then the skin configured for the webapp will be used.
* If the webapp skin does not exist the default skin will be used. If the
* default skin does not exist then <code>null</code> will be returned.
*
* @param key the key to retrieve from the skin.
* @return the value of the property for the named skin (defaulting to the
* 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 key)
{
return TurbineUI.get(getSkin(), key);
}
/**
* Retrieve the skin name.
*/
public String getSkin()
{
return skinName;
}
/**
* Set the skin name to the skin from the TurbineResources.properties file.
* If the property is not present use the "default" skin.
*/
public void setSkin()
{
skinName = TurbineUI.getWebappSkinName();
}
/**
* Set the skin name to the specified skin.
*
* @param skinName the skin name to use.
*/
public void setSkin(String skinName)
{
this.skinName = skinName;
}
/**
* Set the skin name when the tool is configured to be loaded on a
* per-request basis. By default it calls getSkin to return the skin
* specified in TurbineResources.properties. Developers can write a subclass
* of UITool that overrides this method to determine the skin to use based
* on information held in the request.
*
* @param data a RunData instance
*/
protected void setSkin(RunData data)
{
setSkin();
}
/**
* Set the skin name when the tool is configured to be loaded on a
* per-session basis. If the user's temp hashmap contains a value in the
* attribute specified by the String constant SKIN_ATTRIBUTE then that is
* returned. Otherwise it calls getSkin to return the skin specified in
* TurbineResources.properties.
*
* @param user a User instance
*/
protected void setSkin(User user)
{
if (user.getTemp(SKIN_ATTRIBUTE) == null)
{
setSkin();
}
else
{
setSkin((String) user.getTemp(SKIN_ATTRIBUTE));
}
}
/**
* Set the skin name in the user's temp hashmap for the current session.
*
* @param user a User instance
* @param skin the skin name for the session
*/
public static void setSkin(User user, String skin)
{
user.setTemp(SKIN_ATTRIBUTE, skin);
}
/**
* Retrieve the URL for an image that is part of the skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the image(String image)
* method would probably be enough, but I'm not absolutely positive.
*
* @param imageId the id of the image whose URL will be generated.
* @param data the RunDate to use as the source of the ServerData to use as
* the basis for the URL.
*/
public String image(String imageId, RunData data)
{
return image(imageId, data.getServerData());
}
/**
* Retrieve the URL for an image that is part of the skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the image(String image)
* method would probably be enough, but I'm not absolutely positive.
*
* @param imageId the id of the image whose URL will be generated.
* @param serverData the serverData to use as the basis for the URL.
*/
public String image(String imageId, ServerData serverData)
{
return TurbineUI.image(getSkin(), imageId, serverData);
}
/**
* Retrieve the URL for an image that is part of the skin. The images are
* stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
*
* @param imageId the id of the image whose URL will be generated.
*/
public String image(String imageId)
{
return TurbineUI.image(getSkin(), imageId);
}
/**
* Retrieve the URL for the style sheet that is part of the skin. The style
* is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the style() method would
* probably be enough, but I'm not absolutely positive.
*
* @param data the RunDate to use as the source of the ServerData to use as
* the basis for the URL.
*/
public String getStylecss(RunData data)
{
return getStylecss(data.getServerData());
}
/**
* Retrieve the URL for the style sheet that is part of the skin. The style
* is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*
* <p>Use this if for some reason your server name, server scheme, or server
* port change on a per request basis. I'm not sure if this would happend in
* a load balanced situation. I think in most cases the style() method would
* probably be enough, but I'm not absolutely positive.
*
* @param serverData the serverData to use as the basis for the URL.
*/
public String getStylecss(ServerData serverData)
{
return TurbineUI.getStylecss(getSkin(), serverData);
}
/**
* Retrieve the URL for the style sheet that is part of the skin. The style
* is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the
* filename skin.css
*/
public String getStylecss()
{
return TurbineUI.getStylecss(getSkin());
}
/**
* Initialize the UIManager object.
*
* @param data This is null, RunData or User depending upon specified tool scope.
*/
public void init(Object data)
{
if (data == null)
{
log.debug("UITool scope is global");
setSkin();
}
else if (data instanceof RunData)
{
log.debug("UITool scope is request");
setSkin((RunData) data);
}
else if (data instanceof User)
{
log.debug("UITool scope is session");
setSkin((User) data);
}
}
}
1.1 jakarta-turbine-2/proposals/seade/SystemProperties/org/apache/turbine/services/systemproperties/TurbineSystemPropertiesService.java
Index: TurbineSystemPropertiesService.java
===================================================================
package org.apache.turbine.services.systemproperties;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.Iterator;
import java.util.Properties;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.TurbineBaseService;
/**
* The SystemPropertiesService provides a convenient way of getting properties
* defined in TurbineResources.properties into System.properties.
*
* <p>Properties defined as:<br/ >
* <code>services.SystemPropertiesService.name = value</code><br/ >
* will be added to System.properties as<br/ >
* <code>name=value</code><br/ >
* Suggested use is to configure mail.host for JavaMail thus:<br/ >
* <code>services.SystemPropertiesService.mail.host = localhost</code>
*
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id: TurbineSystemPropertiesService.java,v 1.1 2003/09/18 05:27:40 seade Exp $
*/
public class TurbineSystemPropertiesService
extends TurbineBaseService
implements SystemPropertiesService
{
private static Log log
= LogFactory.getLog(TurbineSystemPropertiesService.class);
// ---- Service initilization ------------------------------------------
/**
* Initializes the service.
*/
public void init() throws InitializationException
{
Configuration conf = getConfiguration();
Properties systemProperties = System.getProperties();
for (Iterator iter = conf.getKeys(); iter.hasNext();)
{
String key = (String) iter.next();
if (key.equals("classname") || key.equals("earlyInit"))
{
continue;
}
if (log.isDebugEnabled())
{
log.debug("Setting System property \"" + key + "\" to \""
+ conf.getString(key) + "\"");
}
systemProperties.setProperty(key, conf.getString(key));
}
setInit(true);
}
}
1.1 jakarta-turbine-2/proposals/seade/SystemProperties/org/apache/turbine/services/systemproperties/SystemPropertiesService.java
Index: SystemPropertiesService.java
===================================================================
package org.apache.turbine.services.systemproperties;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.turbine.services.Service;
/**
* The SystemPropertiesService provides a convenient way of getting properties
* defined in TurbineResources.properties into System.properties.
*
* <p>Properties defined as:<br/ >
* <code>services.SystemPropertiesService.name = value</code><br/ >
* will be added to System.properties as<br/ >
* <code>name=value</code><br/ >
* Suggested use is to configure mail.host for JavaMail thus:<br/ >
* <code>services.SystemPropertiesService.mail.host = localhost</code>
*
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id: SystemPropertiesService.java,v 1.1 2003/09/18 05:27:40 seade Exp $
*/
public interface SystemPropertiesService extends Service
{
/**
* The service identifier.
*/
public String SERVICE_NAME = "SystemPropertiesService";
}
1.1 jakarta-turbine-2/proposals/seade/UIService/readme.txt
Index: readme.txt
===================================================================
This service and associated pull tool provide an enhanced replacement for the
existing UIManager pull tool. Major enhancements include:
* Skin properties are shared between all users with lazy loading.
* Non-default skin files inherit properties from the default skin
* Access to skin properties from screen and action classes is now provided for
* Access is provided to the list of available skins
This service is dependant on PullService only in that it makes use of
TurbinePull.getResourcesDirectory() during initialization. It may be a good
idea to duplicate small amount of underlying code in order to eliminate this
dependency.
Configuration:
# -------------------------------------------------------------------
#
# S E R V I C E S
#
# -------------------------------------------------------------------
...
services.UIService.classname = org.apache.turbine.services.ui.TurbineUIService
#services.UIService.earlyInit = true
...
# -------------------------------------------------------------------
#
# P U L L S E R V I C E
#
# -------------------------------------------------------------------
...
tool.session.ui = org.apache.turbine.services.ui.UITool
tool.ui.skin = default
...
1.1 jakarta-turbine-2/proposals/seade/SystemProperties/readme.txt
Index: readme.txt
===================================================================
The SystemProperties service aims to provide a convenient way of getting
properties defined in TurbineResources.properties into System.properties.
This is a very trivial service - I am completely open to alternative ways of
achieving the same end result.
Note that VelocityEmail grabs mail.server from TR.props and passes it through
to commons-email. It is a bit of a pain to have to remember to do this every
time when commons-email is used directly and when a system property is provided
for this very purpose.
I propose that VelocityEmail and related classes be updated to no longer set
the mail host so that there is a single consistent means of setting it. An
alternative to this proposal would be a very specific EmailInit service that
loads the TR.props mail.server value into System.properties mail.host).
Configuration:
# -------------------------------------------------------------------
#
# S E R V I C E S
#
# -------------------------------------------------------------------
...
services.SystemPropertiesService.classname = org.apache.turbine.services.systemproperties.TurbineSystemPropertiesService
services.SystemPropertiesService.earlyInit = true
...
# -------------------------------------------------------------------
#
# S Y S T E M P R O P E R T I E S S E R V I C E
#
# -------------------------------------------------------------------
# Properties defined as:
# services.SystemPropertiesService.name = value
# will be added to System.properties as
# name=value
# Suggested use is to configure mail.host for commons-email and JavaMail thus:
# services.SystemPropertiesService.mail.host = localhost
# -------------------------------------------------------------------
services.SystemPropertiesService.mail.host = localhost