dims 01/07/13 07:15:52
Modified: src/org/apache/cocoon/components/source Tag:
cocoon_20_branch URLSource.java
Log:
Use Reflection to call getUserInfo - still keep compatability with JDK1.2.2
Carsten,
Can you check if this works for you.
Thanks,
dims
Revision Changes Path
No revision
No revision
1.1.2.5 +21 -7
xml-cocoon2/src/org/apache/cocoon/components/source/URLSource.java
Index: URLSource.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/URLSource.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- URLSource.java 2001/07/13 11:26:46 1.1.2.4
+++ URLSource.java 2001/07/13 14:15:44 1.1.2.5
@@ -15,6 +15,7 @@
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
+import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import org.apache.avalon.framework.component.ComponentException;
@@ -31,7 +32,7 @@
* Description of a source which is described by an URL.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/07/13 11:26:46 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/07/13 14:15:44 $
*/
public final class URLSource
@@ -90,12 +91,11 @@
try {
if (this.connection == null) {
this.connection = this.url.openConnection();
- /* The following requires a jdk 1.3
- String userInfo = this.url.getUserInfo();
+ /* The following requires a jdk 1.3 */
+ String userInfo = this.url.getUserInfo();
if (this.url.getProtocol().startsWith("http") == true &&
userInfo != null) {
this.connection.setRequestProperty("Authorization","Basic
"+this.encodeBASE64(userInfo));
}
- */
}
this.lastModificationDate = this.connection.getLastModified();
this.contentLength = this.connection.getContentLength();
@@ -136,15 +136,29 @@
} else {
if (this.connection == null) {
this.connection = this.url.openConnection();
- /* The following requires a jdk 1.3
- String userInfo = this.url.getUserInfo();
+ /* The following requires a jdk 1.3 */
+ String userInfo = getUserInfo(url);
if (this.url.getProtocol().startsWith("http") == true && userInfo
!= null) {
this.connection.setRequestProperty("Authorization","Basic
"+encodeBASE64(userInfo));
}
- */
}
return this.connection.getInputStream();
}
+ }
+
+ private String getUserInfo(URL url)
+ {
+ try {
+ //System.out.println(">>>> getUserInfo: " + url);
+ Class paramTypes[] = new Class[0];
+ Object params[] = new Object[0];
+ Method method = URL.class.getMethod("getUserInfo",paramTypes);
+ return (String) method.invoke(url,params);
+ } catch (Exception e){
+ //System.out.println("Exception in getUserInfo (likely to happen on
JDK-1.2.2 and below):" + e);
+ //e.printStackTrace();
+ }
+ return null;
}
/**
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]