User: user57
Date: 02/02/14 22:14:17
Added: src/main/org/jboss/net/protocol/resource Handler.java
ResourceURLConnection.java package.html
Log:
o importing the useful bits from the bliss cl.
o plus some bits from server/*/util/* have been moved to util.jmx
Revision Changes Path
1.1
jboss-common/src/main/org/jboss/net/protocol/resource/Handler.java
Index: Handler.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.net.protocol.resource;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
/**
* A protocol handler for the 'resource' protocol. Provides
* access to system resources.
*
* @version <tt>$Revision: 1.1 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public class Handler
extends URLStreamHandler
{
public URLConnection openConnection(final URL url)
throws IOException
{
return new ResourceURLConnection(url);
}
}
1.1
jboss-common/src/main/org/jboss/net/protocol/resource/ResourceURLConnection.java
Index: ResourceURLConnection.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.net.protocol.resource;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import java.net.URL;
import java.net.MalformedURLException;
import java.security.Permission;
/**
* Provides access to system resources as a URLConnection.
*
* @version <tt>$Revision: 1.1 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public class ResourceURLConnection
extends URLConnection
{
private URL delegateUrl;
private URLConnection delegateConnection;
public ResourceURLConnection(final URL url)
throws MalformedURLException, IOException
{
super(url);
delegateUrl = makeDelegateUrl(url);
delegateConnection = delegateUrl.openConnection();
}
private URL makeDelegateUrl(final URL url)
throws MalformedURLException, IOException
{
String name = url.getHost();
String file = url.getFile();
if (file != null && !file.equals("")) {
name += file;
}
URL _url = ClassLoader.getSystemResource(name);
if (_url == null)
throw new IOException("could not locate resource: " + name);
return _url;
}
public void connect() throws IOException {
delegateConnection.connect();
}
public Object getContent() throws IOException {
return delegateConnection.getContent();
}
public String getContentType() {
return delegateConnection.getContentType();
}
public InputStream getInputStream() throws IOException {
return delegateConnection.getInputStream();
}
public String getHeaderField(final String name) {
return delegateConnection.getHeaderField(name);
}
public Permission getPermission() throws IOException {
return delegateConnection.getPermission();
}
}
1.1
jboss-common/src/main/org/jboss/net/protocol/resource/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- $Id: package.html,v 1.1 2002/02/15 06:14:17 user57 Exp $ -->
<!--
JBoss: The OpenSource J2EE WebOS
Distributable under LGPL license.
See terms of license at gnu.org.
-->
</head>
<body bgcolor="white">
<p>Provides a system 'resource' access protocol handler.
<h2>Package Specification</h2>
<ul>
<li><a href="javascript: alert('not available')">Not Available</a>
</ul>
<h2>Related Documentation</h2>
<ul>
<li><a href="javascript: alert('not available')">Not Available</a>
</ul>
<h2>Package Status</h2>
<ul>
<li><font color="green"><b>STABLE</b></font>
</ul>
<h2>Todo</h2>
<ul>
<li>???
</ul>
<!-- Put @see and @since tags down here. -->
</body>
</html>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development