Package com.iizigo.webserver
Class InternalWebServer
java.lang.Object
org.eclipse.core.runtime.Plugin
org.eclipse.ui.plugin.AbstractUIPlugin
com.iizigo.webserver.InternalWebServer
- All Implemented Interfaces:
- org.osgi.framework.BundleActivator
The activator class controls the plug-in life cycle for the Internal Web Server using Jetty.
- Author:
- Christopher Mindus
- Field SummaryFields- Fields inherited from class org.eclipse.core.runtime.Plugin- PLUGIN_PREFERENCE_SCOPE, PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescription- getFileUrl- (String fileName) Gets the URL string for a file in the root using the File protocol.- getHTTPFileUrl- (String fileName) Gets the URL string for a file in the root using the HTTP protocol.- static InternalWebServerReturns the shared instance.- intGets the started secure (HTTPS) web server port.Gets the Integrated Jetty Server instance.- getWebServerMapping- (String mappedFile) Gets the map of web server mappings for files.- intGets the started web server port.Loads the HTML file contents encoded in UTF-8 and returns it.- void- start- (org.osgi.framework.BundleContext context) - int- startWebServer- (File parentDir, IExternalBrowserPages extPages, IWSFileProviderServer fileProvider, WebSocketAcceptor acceptor) Starts the web server.- void- stop- (org.osgi.framework.BundleContext context) - boolean- stopWebServer- (long maxTime) Stops the web server.- Methods inherited from class org.eclipse.ui.plugin.AbstractUIPlugin- createImageRegistry, getDialogSettings, getImageRegistry, getPreferenceStore, getWorkbench, imageDescriptorFromPlugin, initializeDefaultPluginPreferences, initializeDefaultPreferences, initializeImageRegistry, loadDialogSettings, loadPreferenceStore, refreshPluginActions, saveDialogSettings, savePreferenceStore, shutdown, startup- Methods inherited from class org.eclipse.core.runtime.Plugin- find, find, getBundle, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString
- Field Details- PLUGIN_IDThe plug-in ID.- See Also:
 
 
- Constructor Details- InternalWebServerpublic InternalWebServer()The constructor
 
- Method Details- start- Specified by:
- startin interface- org.osgi.framework.BundleActivator
- Overrides:
- startin class- AbstractUIPlugin
- Throws:
- Exception
 
- getInstanceReturns the shared instance.- Returns:
- the shared instance.
 
- startWebServerpublic int startWebServer- (File parentDir, IExternalBrowserPages extPages, IWSFileProviderServer fileProvider, WebSocketAcceptor acceptor) Starts the web server.- Parameters:
- parentDir- The directory to use for "quic-work" directory,- nullfor current directory.
- extPages- External pages implementor, null for none.
- fileProvider- File provider interface.
- acceptor- The acceptor for engine requests.
- Returns:
- The port used, 0 for failure.
 
- stopWebServerpublic boolean stopWebServer- (long maxTime) Stops the web server.- Parameters:
- maxTime- Max time to wait for server to stop, <=0 is forever.
- Returns:
- true for success, false for timeout.
 
- getWebServerPortpublic int getWebServerPort()Gets the started web server port.- Returns:
- The port number, zero for not started.
 
- getSecureWebServerPortpublic int getSecureWebServerPort()Gets the started secure (HTTPS) web server port.- Returns:
- The port number, zero for not started.
 
- stop- Specified by:
- stopin interface- org.osgi.framework.BundleActivator
- Overrides:
- stopin class- AbstractUIPlugin
- Throws:
- Exception
 
- getHTTPFileUrlGets the URL string for a file in the root using the HTTP protocol.- Parameters:
- fileName- File name relative the root.
- Returns:
- A String like "http://127.0.0.1:port/name".
 
- loadHTMLLoads the HTML file contents encoded in UTF-8 and returns it.- Parameters:
- fileName- File name relative the root.
- Returns:
- The text or HTML file contents. If there is an error, a HTML document will be returned showing the error.
 
- getFileUrlGets the URL string for a file in the root using the File protocol.- Parameters:
- fileName- File name relative the root.
- Returns:
- A String like "file:...";
 
- getServerGets the Integrated Jetty Server instance.- Returns:
- The integrated web server instance, or nullif not yet started.
 
- getWebServerMappingGets the map of web server mappings for files.- Parameters:
- mappedFile- The file to map.
- Returns:
- The mapping from String (such as "dojo.root" or "iiziRun.root") to File Returns null if not found.