Anpassung an tools-ng, Modifikationen bei URL resource: protocol

git-svn-id: https://svn.libreccm.org/ccm/trunk@149 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2009-04-24 22:24:58 +00:00
parent 54aac049a1
commit 6c3a76f4e5
7 changed files with 93 additions and 17 deletions

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved. * Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
* Copyright (C) 2009 Peter Boy (pb@zes.uni-bremen.de) All Rights Reserved.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -60,7 +61,7 @@ import org.apache.log4j.Logger;
*/ */
public final class CCMResourceManager { public final class CCMResourceManager {
public final static String versionId = public final static String versionId =
"$Id: CCM.java 1393 2006-11-28 09:12:32Z sskracic $" + "$Id: CCMResourceManager.java 1393 2006-11-28 09:12:32Z sskracic $" +
"$Author: pboy $" + "$Author: pboy $" +
"$DateTime: 2009/01/10 18:10:38 $"; "$DateTime: 2009/01/10 18:10:38 $";
@ -160,12 +161,12 @@ public final class CCMResourceManager {
* <b>Note! API changed!</b> * <b>Note! API changed!</b>
* *
* Originally it is used to determine all file object locations of a * Originally it is used to determine all file object locations of a
* CCMResourceManager installation, during the installation step as well as * CCM installation, during the installation step as well as
* while running the application inside a servlet container. The CCM installation * while running the application inside a servlet container. The CCM installation
* of a servlet container used to use a non-standard layout. It is based upon a * of a servlet container used to use a non-standard layout. It is based upon a
* system wide environment variable CCM_HOME to determine the home directory. * system wide environment variable CCM_HOME to determine the home directory.
* *
* The dependence from a system wide environment variable prevents a servlet * The dependency from a system wide environment variable prevents a servlet
* container to run multiple instances of CCM. In addition to it CCM will * container to run multiple instances of CCM. In addition to it CCM will
* be migrated to be installable in a standard way to a standard container. * be migrated to be installable in a standard way to a standard container.
* Therefore all file locations will be given to the applications * Therefore all file locations will be given to the applications
@ -176,23 +177,42 @@ public final class CCMResourceManager {
* <b>It may be removed in the future!</b> Or it may be moved to * <b>It may be removed in the future!</b> Or it may be moved to
* c.ad.packaging for assistence of the installation step only. * c.ad.packaging for assistence of the installation step only.
* *
* MODIFIED:
* CCM_HOME is now interpreted as the path to the applications base
* directory (web application context).
*
* @return Directory location in the servers file system as File object. * @return Directory location in the servers file system as File object.
*/ */
static final File getHomeDirectory() { static final File getHomeDirectory() {
final String home = System.getProperty("ccm.home");
String home = System.getProperty("ccm.home");
if (home == null) { if (home == null) {
throw new IllegalStateException throw new IllegalStateException
("The ccm.home system property is null or not defined"); ("The ccm.home system property is null or not defined");
} }
final File file = new File(home); // make a guess, weather ist is old style (i.e. referring to the containers
// base directory and therefor does not contain the webapps part) or
if (!file.exists()) { // new style referring to the apps base directory (and therefor containing
throw new IllegalStateException // the webapps part)
("The file given in the ccm.home system property " + if (home.indexOf("webapps") > 0 ){
"does not exist"); // should be new style
} }
else {
// presumably old style, add path to standard context name
home += "/webapps/ROOT)";
}
File file = new File(home);
// No need to require that home exists (indeed, during install it will not).
// Should be created by invoking method if not.
// if (!file.exists()) {
// throw new IllegalStateException
// ("The file given in the ccm.home system property " +
// "does not exist");
// }
if (!file.isDirectory()) { if (!file.isDirectory()) {
throw new IllegalStateException throw new IllegalStateException
@ -296,7 +316,9 @@ public final class CCMResourceManager {
// temporary: enforce that BaseDir is ROOT! // temporary: enforce that BaseDir is ROOT!
m_baseDir.renameTo(new File(m_baseDir.getParent(),"ROOT")); // removed, all modules are now installed into one context and
// its name is specified in project.xml
// m_baseDir.renameTo(new File(m_baseDir.getParent(),"ROOT"));
// eventually: check if dir exists, create it if not. // eventually: check if dir exists, create it if not.
if (!m_baseDir.exists()) { if (!m_baseDir.exists()) {
@ -327,8 +349,9 @@ public final class CCMResourceManager {
// environment variable. // environment variable.
// During transition phase only! Must be removed when the new // During transition phase only! Must be removed when the new
// standard compliant installation method is fully in place // standard compliant installation method is fully in place
m_baseDir = new File(new File(CCMResourceManager.getHomeDirectory(), // MODIFIED
"webapps"), "ROOT"); // HomeDirectory now specifies the applications context dir.
m_baseDir = CCMResourceManager.getHomeDirectory();
// eventually: check if dir exists, create it if not. // eventually: check if dir exists, create it if not.
if (!m_baseDir.exists()) { if (!m_baseDir.exists()) {

View File

@ -154,6 +154,32 @@ public abstract class AbstractParameter implements Parameter {
* Calls {@link #doRead(ParameterReader,ErrorList)}. * Calls {@link #doRead(ParameterReader,ErrorList)}.
* *
* @see Parameter#read(ParameterReader,ErrorList) * @see Parameter#read(ParameterReader,ErrorList)
*
* From Parameter#read(ParameterReader,ErrorList):
* Gets the parameter value as a Java object. The value will have
* a specific runtime type and so may be appropriately cast.
*
* Reading typically follows the following procedure:
*
* <ul>
* <li>Read the literal string value associated with the
* parameter from <code>reader</code></li>
*
* <li>Convert the literal string value into an approprite Java
* object</li>
* </ul>
*
* If at any point in the process an error is encountered, it is
* added to <code>errors</code>. Callers of this method will
* typically construct an <code>ErrorList</code> in which to
* collect errors.
*
* @param reader The <code>ParameterReader</code> from which to
* recover a string literal value; it cannot be null
* @param errors The <code>ErrorList</code> in which to collect
* any errors encountered; it cannot be null
* @return The Java object value of the parameter
*
*/ */
public final Object read(final ParameterReader reader, public final Object read(final ParameterReader reader,
final ErrorList errors) { final ErrorList errors) {

View File

@ -98,14 +98,29 @@ public abstract class AbstractParameterContext implements ParameterContext {
} }
/** /**
* @see ParameterContext#get(Parameter) * From ParameterContext#get(Parameter):
* Gets the unmarshaled value of <code>param</code>. If the
* loaded value is null, <code>param.getDefaultValue()</code> is
* returned.
*
* @param param The named <code>Parameter</code> whose value to
* retrieve; it cannot be null
* @return The unmarshaled Java object value of <code>param</code>
*/ */
public Object get(final Parameter param) { public Object get(final Parameter param) {
return get(param, param.getDefaultValue()); return get(param, param.getDefaultValue());
} }
/** /**
* @see ParameterContext#get(Parameter,Object) * From ParameterContext#get(Parameter,Object)
* Gets the unmarshaled value of <code>param</code>, returning
* <code>dephalt</code> if <code>param</code>'s value is null.
*
* @param param The <code>Parameter</code> whose value to
* retrieve; it cannot be null
* @param dephalt The fallback default value; it may be null
* @return The unmarshaled Java object value of <code>param</code>
* or <code>dephalt</code> if the former is null
*/ */
public Object get(final Parameter param, final Object dephault) { public Object get(final Parameter param, final Object dephault) {
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
@ -139,6 +154,8 @@ public abstract class AbstractParameterContext implements ParameterContext {
} }
/** /**
*
*
* Reads and unmarshals all values associated with the registered * Reads and unmarshals all values associated with the registered
* parameters from <code>reader</code>. Any errors are returned. * parameters from <code>reader</code>. Any errors are returned.
* *
@ -156,7 +173,15 @@ public abstract class AbstractParameterContext implements ParameterContext {
} }
/** /**
* @see ParameterContext#load(ParameterReader,ErrorList) * From ParameterContext#load(ParameterReader,ErrorList):
* Reads and unmarshals all values associated with the registered
* parameters from <code>reader</code>. If any errors are
* encountered, they are added to <code>errors</code>.
*
* @param reader The <code>ParameterReader</code> from which to
* fetch the values; it cannot be null
* @param errors The <code>ErrorList</code> that captures any
* errors while loading; it cannot be null
*/ */
public final void load(final ParameterReader reader, public final void load(final ParameterReader reader,
final ErrorList errors) { final ErrorList errors) {

View File

@ -31,7 +31,9 @@ import org.apache.log4j.Logger;
* InputStream for the given Resource. If it does not, and if it is * InputStream for the given Resource. If it does not, and if it is
* required, it logs an error. Otherwise, it returns null. * required, it logs an error. Otherwise, it returns null.
* *
* @deprecated Use {@link URLParameter} instead. * Had been deprecated for a while in favour of an URLParameter and a
* application specific resource: protocol extension (c.ad.util.protocol.resource).
* As of version 6.5 reverted to ResourceParameter to avoid non-standard extensions.
* *
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: ResourceParameter.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: ResourceParameter.java 287 2005-02-22 00:29:02Z sskracic $