Class CodebaseServer
- All Implemented Interfaces:
Runnable
Note: There can be at most one CodebaseServer instance per JVM.
- Version:
- 1.0, 01-Nov-99 Initial release
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final SimpleDateFormat
private static final byte[]
private static final byte[]
private static final byte[]
private PrintStream
private final byte[]
private static final byte[]
static int
Deprecated.The preferred field to check is serverPort as this field is mutable unfortunately; it remains solely to maintain backward compatibility.final int
This is the inbound ServerSocket port number providing both the HTTP client tag and codebase jar service.private final ServerSocket
private final byte[]
private final byte[]
private final byte[]
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionCodebaseServer
(String[] jars, int port, String client, String title, String vendor, String icon, String splash) The main constructor will start up the server's codebase transport mechanism on the specified port.CodebaseServer
(String base, int port) This constructor simply calls the three argument constructor, providing the standard cajo generic graphical client as the client argument.CodebaseServer
(String base, int port, String client) This constructor will start up the server's codebase transport mechanism on the specified port, using the specified codebase jar file, with the specified clent. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
The application creates a utility server to share any jar and class files in its working directory and subdirectories.void
run()
The server thread method, it will send the proxy codebase, and it will also support installing the hostingClient
, or application specific host, in a Java-enabled browser, or as a web start application via JNLP.void
setLog
(OutputStream log) This method can be used to log the client requests of the Codebase server.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
formatter
-
bye
private static final byte[] bye -
apl
private static final byte[] apl -
jws
private static final byte[] jws -
jarHdr
private static final byte[] jarHdr -
classHdr
private static final byte[] classHdr -
imgHdr
private static final byte[] imgHdr -
end
private static final byte[] end -
out
private static final byte[] out -
top
private final byte[] top -
mid
private final byte[] mid -
tip
private final byte[] tip -
xml
private final byte[] xml -
ss
-
log
-
serverPort
public final int serverPortThis is the inbound ServerSocket port number providing both the HTTP client tag and codebase jar service. If the server is behind a firewall, this port, must be made accessible from outside. If the port argument used in the constructor was zero, it will use an anonymous port; i.e. one selected by the OS from any ports available at runtime. In that case, the port actually offered by the operating system will be stored here automatically, following construction. -
port
public static int portDeprecated.The preferred field to check is serverPort as this field is mutable unfortunately; it remains solely to maintain backward compatibility.This is the inbound ServerSocket port number providing both the HTTP client tag and codebase jar service. If the server is behind a firewall, this port, must be made accessible from outside. If the port argument used in the constructor was zero, it will use an anonymous port; i.e. one selected by the OS from any ports available at runtime. In that case, the port actually offered by the operating system will be stored here automatically, following construction.
-
-
Constructor Details
-
CodebaseServer
public CodebaseServer(String[] jars, int port, String client, String title, String vendor, String icon, String splash) throws IOException The main constructor will start up the server's codebase transport mechanism on the specified port. To shut the service down, call its inherited interrupt method. All other constructors in this class call it.- Parameters:
jars
- An array of strings representing the path and filename of a library jar needed by the client application. The CodebaseServer will serve them to the remote JVM. The server will first search for the jar in its own executable jar file, if that fails, then it will check the local filesystem. The jars could represent individual proxies, or general-purpose shared libraries.The first jar named in the array will be assumed to be the jar containing the main client class.
Note: if this value is null, it indicates that the proxy codebase is not in a jar. The server will then look first in its own jar file for the class files to send, and if not found, it will next look in its working directory. This feature provides an extremely simple, essentially zero-configuration, approach to proxy codebase service.
As a special safety feature, if the jar from which the service items are running is given the specialinvalid input: '<'/> name service.jar it not be allowed to be requested over the network. This would be important for example, if you did not wish to share the server.jar file.
port
- The TCP port on which to serve the codebase, and client applet. It can be zero, to use an anonymous port. If zero, the actual port selected by the OS at runtime will be stored in theserverPort
member.client
- The name of the graphical client class to be furnished as an Applet, or via WebStart. For example, the generic cajo standard graphical proxy is: gnu.cajo.invoke.Clienttitle
- The optional application specific titile to show in the browser, when running as an applet.vendor
- The optional vendor name of the WebStart application.icon
- The optional custom desktop icon to represent the WebStart application, it can also be null. It is typically of the form "images/icon.gif", where it will be requested from the server. The image can be in either GIF or JPEG format.splash
- The optional splash screen image to represent the WebStart application while it is loading, it can also be null. It is typically of the form "images/splash.jpeg", where it will be requested from the server. The image can be in either GIF or JPEG format.- Throws:
IOException
- If the HTTP socket providing the codebase and applet tag service could not be created.
-
CodebaseServer
This constructor will start up the server's codebase transport mechanism on the specified port, using the specified codebase jar file, with the specified clent.- Parameters:
base
- The path and name of the file containing the proxy codebase jar file.port
- The TCP port on which to serve the codebase, and client applet.client
- The name of the graphical client class to be furnished as an Applet, or via WebStart.- Throws:
IOException
- If the HTTP socket providing the codebase and applet tag service could not be created.
-
CodebaseServer
This constructor simply calls the three argument constructor, providing the standard cajo generic graphical client as the client argument.- Parameters:
base
- The path and name of the file containing the proxy codebase jar file.port
- The TCP port on which to serve the codebase, and client applet.- Throws:
IOException
- If the HTTP socket providing the codebase and applet tag service could not be created.
-
-
Method Details
-
setLog
This method can be used to log the client requests of the Codebase server. The log can range from System.out, to a network socket OutputStream.Note: Only one log stream can be assigned to the CodebaseServer at any given time.
- Parameters:
log
- The OutputStream to record the client requests. If this argument is null, no change will take place.
-
run
public void run()The server thread method, it will send the proxy codebase, and it will also support installing the hostingClient
, or application specific host, in a Java-enabled browser, or as a web start application via JNLP.The format of a browser's proxy request URL one required, and five optional parameters, utilizing the following format:
http://serverHost[:serverPort]/[clientPort][:localPort][-proxyName][!]
Where the parameters have the following meanings:
- serverHost The domain name, or IP address of the proxy server.
- serverPort The port number of the applet/codebases service, unspecified it will be 80.
- clientPort The client's external port number on which the remote proxy can be reached. It is often explicitly specified when the client is behind a firewall, or is using port translation. Unspecified, it will be the same as the localPort value, described next.
- localPort The client's internal port number on which the remote proxy can be reached. Unspecified, it will be selected anonymously by the client at runtime.
- proxyName The registered name of the proxy serving object, by default "main", however a single server can support multiple service objects.
- ! This operator causes the proxy to be sent using JNLP. This will launch the proxy as an application on the client using WebStart.
To unspecify any optional object, simply omit it, from the URL, along with its preceeding delimiter, if any. The order of the arguments must be maintained however.
Note: other object servers can share this instance, by placing their proxy classes or jar files in the same working directory. However, those object servers will not be able to use the client service feature, as it is unique to the VM in which the CodebaseServer is running.
As a safety precaution, the server will send any requested jar or class file in or below its working directory except the jar file of the server itself. Typically people do not want to give this file out.
-
main
The application creates a utility server to share any jar and class files in its working directory and subdirectories. It is very useful in application development. If a port number is provided as an argument, it will be used, otherwise it will be opened on an anonymous port.- Throws:
Exception
-