dims 01/10/01 11:27:11
Modified: src/org/apache/cocoon/components/classloader Tag:
cocoon_20_branch RepositoryClassLoader.java
src/org/apache/cocoon/servlet Tag: cocoon_20_branch
CocoonServlet.java
webapp/WEB-INF Tag: cocoon_20_branch web.xml
Log:
- Fixing the loading of classes from extra-classpath.
- Support for setting proxy server/port information in web.xml.
Revision Changes Path
No revision
No revision
1.1.1.1.2.2 +19 -1
xml-cocoon2/src/org/apache/cocoon/components/classloader/RepositoryClassLoader.java
Index: RepositoryClassLoader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/classloader/RepositoryClassLoader.java,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2
--- RepositoryClassLoader.java 2001/08/20 14:07:26 1.1.1.1.2.1
+++ RepositoryClassLoader.java 2001/10/01 18:27:11 1.1.1.1.2.2
@@ -27,7 +27,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.1.1.2.1 $ $Date: 2001/08/20 14:07:26 $
+ * @version CVS $Revision: 1.1.1.1.2.2 $ $Date: 2001/10/01 18:27:11 $
*/
public class RepositoryClassLoader extends URLClassLoader implements Loggable {
@@ -92,6 +92,24 @@
public void addDirectory(File repository) throws IOException {
try {
this.addURL(repository.getCanonicalFile().toURL());
+ } catch (MalformedURLException mue) {
+ log.error("The repository had a bad URL", mue);
+ throw new IOException("Could not add repository");
+ }
+ }
+
+ /**
+ * Add a directory to the list of searchable repositories.
+ * This methods ensures that no directory is specified more than once.
+ *
+ * @param directoryName The path directory
+ * @exception IOException Non-existent, non-readable or non-directory
+ * repository
+ */
+ public void addDirectory(String repository) throws IOException {
+ try {
+ File file = new File(repository);
+ this.addURL(file.getCanonicalFile().toURL());
} catch (MalformedURLException mue) {
log.error("The repository had a bad URL", mue);
throw new IOException("Could not add repository");
No revision
No revision
1.13.2.24 +60 -1 xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
Index: CocoonServlet.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
retrieving revision 1.13.2.23
retrieving revision 1.13.2.24
diff -u -r1.13.2.23 -r1.13.2.24
--- CocoonServlet.java 2001/10/01 14:56:50 1.13.2.23
+++ CocoonServlet.java 2001/10/01 18:27:11 1.13.2.24
@@ -67,7 +67,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a>
- * @version CVS $Revision: 1.13.2.23 $ $Date: 2001/10/01 14:56:50 $
+ * @version CVS $Revision: 1.13.2.24 $ $Date: 2001/10/01 18:27:11 $
*/
public class CocoonServlet extends HttpServlet {
@@ -110,6 +110,7 @@
private String parentComponentManagerClass;
protected String forceLoadParameter;
+ protected String forceSystemProperty;
private boolean addClassDirs;
/**
@@ -140,6 +141,8 @@
log.debug("load-class was not set - defaulting to false?");
}
+ this.forceSystemProperty = conf.getInitParameter("force-property");
+
value = conf.getInitParameter("init-classloader");
this.addClassDirs = "true".equalsIgnoreCase(value) ||
"yes".equalsIgnoreCase(value);
if(value == null) {
@@ -315,6 +318,14 @@
(s.charAt(1) == ':')) {
log.debug ("extraClassPath is absolute: " + s);
sb.append(s);
+
+ if (this.addClassDirs) {
+ try {
+ classLoader.addDirectory(s.toString());
+ } catch (Exception e) {
+ log.debug("Could not add " + s.toString());
+ }
+ }
} else {
if(s.indexOf("${")!=-1) {
int startToken = s.indexOf("${");
@@ -326,9 +337,23 @@
value.append(s.substring(endToken+1));
sb.append(value.toString());
log.debug ("extraClassPath is not absolute replacing using
token: [" + token + "] : " + value.toString());
+ if (this.addClassDirs) {
+ try {
+ classLoader.addDirectory(value.toString());
+ } catch (Exception e) {
+ log.debug("Could not add " + value.toString());
+ }
+ }
} else {
log.debug ("extraClassPath is not absolute pre-pending
context path: " + this.servletContext.getRealPath("/") + s);
sb.append(this.servletContext.getRealPath("/") + s);
+ if (this.addClassDirs) {
+ try {
+
classLoader.addDirectory(this.servletContext.getRealPath("/") + s);
+ } catch (Exception e) {
+ log.debug("Could not add " +
this.servletContext.getRealPath("/") + s);
+ }
+ }
}
}
}
@@ -463,6 +488,39 @@
}
/**
+ * Handle the "force-property" parameter.
+ *
+ * If you need to force more than one property to load, then
+ * separate each entry with whitespace, a comma, or a semi-colon.
+ * Cocoon will strip any whitespace from the entry.
+ *
+ * @throws ServletException
+ */
+ private void forceProperty() {
+ if (this.forceSystemProperty != null) {
+ StringTokenizer tokenizer = new StringTokenizer(forceSystemProperty, "
\t\r\n\f;,", false);
+
+ java.util.Properties systemProps = System.getProperties();
+ while (tokenizer.hasMoreTokens()) {
+ final String property = tokenizer.nextToken().trim();
+ if(property.indexOf('=')==-1)
+ continue;
+ try {
+
+ String key = property.substring(0,property.indexOf('='));
+ String value = property.substring(property.indexOf('=')+1);
+ log.debug("setting " + key + "=" + value);
+ systemProps.setProperty(key,value);
+ } catch (Exception e) {
+ log.warn("Could not set property: " + property, e);
+ // Do not throw an exception, because it is not a fatal error.
+ }
+ }
+ System.setProperties(systemProps);
+ }
+ }
+
+ /**
* Process the specified <code>HttpServletRequest</code> producing output
* on the specified <code>HttpServletResponse</code>.
*/
@@ -722,6 +780,7 @@
this.appContext.put(Constants.CONTEXT_CLASSPATH, this.getClassPath());
this.forceLoad();
+ this.forceProperty();
try {
URL configFile = (URL)
this.appContext.get(Constants.CONTEXT_CONFIG_URL);
No revision
No revision
1.1.1.1.2.11 +11 -0 xml-cocoon2/webapp/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/WEB-INF/web.xml,v
retrieving revision 1.1.1.1.2.10
retrieving revision 1.1.1.1.2.11
diff -u -r1.1.1.1.2.10 -r1.1.1.1.2.11
--- web.xml 2001/09/19 08:28:28 1.1.1.1.2.10
+++ web.xml 2001/10/01 18:27:11 1.1.1.1.2.11
@@ -123,6 +123,17 @@
</init-param>
<!--
+ This parameter allows to specify system properties that may be needed.
+ <init-param>
+ <param-name>force-property</param-name>
+ <param-value>
+ http.proxyHost=myproxy.mycompany.com
+ http.proxyPort=80
+ </param-value>
+ </init-param>
+ -->
+
+ <!--
This parameter allows to specify where Cocoon should put files
which are uploaded by the upload.xsp sample. The path specified
is always relative to the context path of the servlet.
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]