org.systinet.wasp
Class Wasp

java.lang.Object
  extended byorg.systinet.wasp.Wasp

public class Wasp
extends java.lang.Object

This static class allows you to initialize Wasp with custom settings (see init(Map) and init(String)) as well as destroy the server (see destroy()), start transport servers of your choice (see startServer(String)) and translate between relative and absolute paths of services (see getLocalPath(String), getAbsolutePath(String)).

A typical usage is starting and destroying WSO2 SOA Enablement Server, for instance HTTP server:

 // init is optional (we can set 'wasp.location' property when Java is started)
 Wasp.init("/home/googoo/wasp45");
 Wasp.startServer("http");
 ...
 Wasp.destroy();

Since:
4.5
Component:
Core

Method Summary
static void destroy()
          Stops all transport servers and destroys WSO2 SOA Enablement Server.
static java.lang.String[] getAbsolutePath(java.lang.String path)
          Returns all possible endpoints for local path of current started transports or null if no server transport is available.
static java.lang.String getAbsolutePath(java.lang.String scheme, java.lang.String path)
          Returns the first endpoint for local path of current started transports registered for given scheme or null if no such server transport is available.
static java.util.Map getInitialArguments()
          Returns the initial arguments when WSO2 SOA Enablement Server was initialized.
static java.lang.String getLocalPath(java.lang.String endpoint)
          Returns null if the endpoint does not point to any local server accepting incoming messages or the local path (without the WSO2 SOA Enablement Server context) of the endpoint.
static java.lang.String getWaspLocation()
          Returns the URL of the system WSO2 SOA Enablement Server directory.
static void init()
          Initializes WSO2 SOA Enablement Server with default settings.
static void init(java.util.Map arguments)
          Initializes WSO2 SOA Enablement Server with given arguments.
static void init(java.lang.String waspLocation)
          Initializes WSO2 SOA Enablement Server with specified wasp.location property.
static Transport startServer(java.lang.String endpoint)
          Starts a new server on given endpoint or gets the server if it's already started.
static Transport startServer(java.lang.String scheme, Configurable configuration)
          Starts a new server with given configuration:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static final void init()
                       throws WaspInternalException
Initializes WSO2 SOA Enablement Server with default settings.

Throws:
WaspInternalException - when some internal error occurs
See Also:
init(Map)

init

public static final void init(java.lang.String waspLocation)
                       throws WaspInternalException
Initializes WSO2 SOA Enablement Server with specified wasp.location property.

Parameters:
waspLocation - directory where WSO2 SOA Enablement Server was installed to (path on local filesystem i.e. c:\wasp)
Throws:
WaspInternalException - when some internal error occurs
See Also:
init(Map)

init

public static final void init(java.util.Map arguments)
                       throws WaspInternalException
Initializes WSO2 SOA Enablement Server with given arguments. If given argument isn't specified in the map it's taken from META-INF/wasp.properties property file which is loaded as resource from class loader. If the argument isn't in this file, the default value is taken - parameter in brackets.

Possible arguments:

wasp.location - installed location
wasp.config.location - relative (to wasp.location) path of configuration file (conf/clientconf.xml)
wasp.config.include - list of additional configs to include, delimited by commas
wasp.configurator.class - which org.idoox.config.Configurator implementation is used (com.idoox.config.xml.XMLConfigurator)
idoox.debug.level - determines the number of logging messages (2 - errors, warnings)
idoox.debug.logger - specifies logging system, e.g. log4j, if you do not want to use log4j set this property to waspLogger (waspLogger)
log4j.configuration - specifies path to the property configuration file for lo4j. If it contains relarive path then it will be evaluated relatively to wasp.location
wasp.impl.classpath - classpath of WSO2 SOA Enablement Server implementation
wasp.shutdownhook - if true WSO2 SOA Enablement Server should be automatically destroyed just before JVM is destroyed, false - if client wants to manage shutdown process (true)

Level of logging can be: 0 - none, 1 - errors, 2 - warnings, 3 - infos, 4 - debugs (it must be non-stripped distribution).

Parameters:
arguments - map of initial arguments
Throws:
WaspInternalException - when some internal error occurs

destroy

public static final void destroy()
Stops all transport servers and destroys WSO2 SOA Enablement Server.


startServer

public static final Transport startServer(java.lang.String endpoint)
                                   throws TransportStartException,
                                          java.net.MalformedURLException,
                                          WaspInternalException
Starts a new server on given endpoint or gets the server if it's already started. If the WSO2 SOA Enablement Server was not initialized it is automatically initialized. Endpoint where the server should be started is a string like https - starts HTTPS server on port from configuration or it is a string like http://googoo:8080/wasp which means that HTTP server should be started on port 8080 with context /wasp. The endpoint string is passed to Transport.start(URI) method.
Note: You can stop the server by calling Transport.stop() method on particular transport.

Parameters:
endpoint - address where to start server
Returns:
started transport
Throws:
TransportStartException - when some error occurs during transport starting
WaspInternalException - when some error occurs during WSO2 SOA Enablement Server initialization
java.net.MalformedURLException - when the endpoint is not valid URL
See Also:
Transport.start(org.idoox.transport.URI)

startServer

public static final Transport startServer(java.lang.String scheme,
                                          Configurable configuration)
                                   throws TransportStartException,
                                          WaspInternalException
Starts a new server with given configuration:
 Configurable config = Configurator.newRuntimeConfigurable();
 HttpServerConfig httpConfig = (HttpServerConfig)config.narrow(HttpServerConfig.class);
 httpConfig.setPort(4040);
 httpConfig.setMaxThreads(50);
 httpConfig.setMaxReadTime(10000);
 Wasp.startServer("http", config);

Passed configuration takes default values from a server transport which is registered as default server transport for given scheme. It can not be reused for another server configuration because the started server has registered listener (Configurable.addVetoableChangeListener(java.beans.VetoableChangeListener)) on the configurable and it acts accordingly on given change. If the WSO2 SOA Enablement Server was not initialized it is automatically initialized.

Parameters:
scheme - the transport scheme
configuration - additional onfiguration for started transport
Returns:
started transport
Throws:
TransportStartException - when some error occurs during transport starting
WaspInternalException - when some error occurs during WSO2 SOA Enablement Server initialization
See Also:
startServer(String), Transport.start(org.idoox.transport.URI)

getLocalPath

public static final java.lang.String getLocalPath(java.lang.String endpoint)
                                           throws java.net.MalformedURLException
Returns null if the endpoint does not point to any local server accepting incoming messages or the local path (without the WSO2 SOA Enablement Server context) of the endpoint. For example, if WSO2 SOA Enablement Server is deployed to http://localhost:6060/wasp, then call with the endpoint http://localhost:6060/wasp/a/ returns /a/ path, while http://localhost:6060/wasp1/a/ or http://localhost/wasp/a/ (default port for HTTP is 80) returns null.

Parameters:
endpoint - the endpoint being tested
Returns:
the local path of the endpoint or null
Throws:
java.net.MalformedURLException - when the endpoint is not valid URL

getAbsolutePath

public static final java.lang.String getAbsolutePath(java.lang.String scheme,
                                                     java.lang.String path)
                                              throws java.net.MalformedURLException
Returns the first endpoint for local path of current started transports registered for given scheme or null if no such server transport is available. For example, for http scheme and /Hello path it returns http://localhost:6060/Hello.

Parameters:
scheme - scheme of the transport
path - the local path of the endpoint
Returns:
endpoint or null
Throws:
java.net.MalformedURLException - when server endpoint is not valid URL

getAbsolutePath

public static final java.lang.String[] getAbsolutePath(java.lang.String path)
                                                throws java.net.MalformedURLException
Returns all possible endpoints for local path of current started transports or null if no server transport is available. For example, for /Hello path it returns http://localhost:6060/Hello and https://localhost:6062/Hello endpoints.

Parameters:
path - the local path of the endpoint
Returns:
array of endpoints or null
Throws:
java.net.MalformedURLException - when some server endpoint is not valid URL

getWaspLocation

public static final java.lang.String getWaspLocation()
Returns the URL of the system WSO2 SOA Enablement Server directory.

Returns:
location of WSO2 SOA Enablement Server or null if the WSO2 SOA Enablement Server isn't initialized

getInitialArguments

public static final java.util.Map getInitialArguments()
Returns the initial arguments when WSO2 SOA Enablement Server was initialized. See init(java.util.Map) for list of these arguments.

Returns:
initial arguments map