org.openide.util
Class HttpServer

java.lang.Object
  |
  +--org.openide.util.HttpServer

public abstract class HttpServer
extends Object

Maps internal NetBeans resources such as repository objects to URLs. The mapping is delegated to an HTTP server module, which registers to do the mapping. It is also responsible for actually serving the individual data objects from the Repository and resources from the system classpath.


Inner Class Summary
static interface HttpServer.Impl
          Implementation of the HTTP server.
 
Method Summary
static boolean allowAccess(InetAddress addr)
          Requests the server to allow access to it from a given IP address.
static void deregisterServer(HttpServer.Impl server)
          Deregister the system HTTP server.
static URL getRepositoryRoot()
          Map the repository root to a URL.
static URL getRepositoryURL(FileObject fo)
          Map a file object to a URL.
static URL getResourceRoot()
          Get URL root for a resource from system classpath.
static URL getResourceURL(String resourcePath)
          Map a resource path to a URL.
static void registerServer(HttpServer.Impl server)
          Register the system HTTP server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerServer

public static void registerServer(HttpServer.Impl server)
                           throws SecurityException
Register the system HTTP server. Typically this would be done in ModuleInstall.installed() or ModuleInstall.restored().
Parameters:
server - the server to register
Throws:
SecurityException - if there was already one registered

deregisterServer

public static void deregisterServer(HttpServer.Impl server)
                             throws SecurityException
Deregister the system HTTP server. Typically this would be done in ModuleInstall.uninstalled().
Parameters:
server - the server to deregister
Throws:
SecurityException - if the specified server was not the installed one

getRepositoryURL

public static URL getRepositoryURL(FileObject fo)
                            throws MalformedURLException,
                                   UnknownHostException
Map a file object to a URL. Should ensure that the file object is accessible via the given URL.
Parameters:
fo - the file object to represent
Returns:
a URL providing access to it
Throws:
MalformedURLException - for the usual reasons
UnknownHostException - for the usual reasons, or if there is no registered server

getRepositoryRoot

public static URL getRepositoryRoot()
                             throws MalformedURLException,
                                    UnknownHostException
Map the repository root to a URL. This URL should serve a page from which repository objects are accessible. This means that it should serve a package-oriented view of the Repository, corresponding to a merge of all files present in the root folders of visible file systems.
Returns:
a URL
Throws:
MalformedURLException - for the usual reasons
UnknownHostException - for the usual reasons, or if there is no registered server

getResourceURL

public static URL getResourceURL(String resourcePath)
                          throws MalformedURLException,
                                 UnknownHostException
Map a resource path to a URL. Should ensure that the resource is accessible via the given URL.
Parameters:
resourcePath - path of the resource in classloader format (e.g. /some/path/resources/icon32.gif)
Returns:
a URL providing access to it
Throws:
MalformedURLException - for the usual reasons
UnknownHostException - for the usual reasons, or if there is no registered server
See Also:
ClassLoader.getResource(java.lang.String), TopManager.systemClassLoader()

getResourceRoot

public static URL getResourceRoot()
                           throws MalformedURLException,
                                  UnknownHostException
Get URL root for a resource from system classpath.
Parameters:
resourcePath - the resource path
Returns:
the URL
Throws:
MalformedURLException - for the usual reasons
UnknownHostException - for the usual reasons
See Also:
getResourceURL(java.lang.String)

allowAccess

public static boolean allowAccess(InetAddress addr)
                           throws UnknownHostException
Requests the server to allow access to it from a given IP address. This can be useful if a module wishes another machine to be able to access the server, such as a machine running a deployment server. The server may or may not grant access to the IP address, for example if the user does not wish to grant access to the IP address.
Parameters:
addr - address for which access is requested
Returns:
true if access has been granted


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.