|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
NetService provides methods for sending and receiving HTTP messages, subcribing and unsubcribing to message topics, and other network related functions.
| Method Summary | |
void |
closePushConnection()
Closes the current push connection. |
java.net.URL |
createFullyQualifiedUrl(java.lang.String url)
Creates a full url based on current context information. |
java.net.URL |
createFullyQualifiedUrl(java.lang.String baseUrl,
java.lang.String url)
Creates a fully qualified URL out of a base url and a relative url. |
java.net.URL |
createFullyQualifiedUrl(java.lang.String baseUrl,
java.lang.String applicationPath,
java.lang.String url,
boolean keepContextPath)
Creates a fully qualified URL out of a base url, an optional applicationPath and a relative url. |
HttpRequest |
createHttpRequest(java.lang.String url)
Creates an HTTP request that can then be sent to the server. |
java.net.URL |
getServerUrl()
Returns something like "http://localhost:8080 |
void |
openBrowser(java.lang.String url)
Opens a browser window with the given url. |
void |
openBrowser(java.lang.String url,
java.lang.String target)
Opens a browser window with the given url in the specified target frame. |
void |
openPushConnection()
Opens the push connection. |
void |
publish(java.lang.String topic,
byte[] content)
Publishes a byte[] on the given topic. |
void |
publish(java.lang.String topic,
Document content)
Publishes a Document on the given topic. |
void |
publish(java.lang.String topic,
Element content)
Publishes an Element on the given topic. |
void |
publish(java.lang.String topic,
java.io.Serializable content)
Publishes a Serializable object on the given topic. |
void |
publish(java.lang.String topic,
java.lang.String content)
Publishes a String on the given topic. |
void |
publish(java.lang.String topic,
XmlSerializable content)
Publishes a XmlSerializable object on the given topic. |
HttpResponse |
retrieve(HttpRequest request)
Gets a response from a url by making a request based on the input HttpRequest object. |
HttpResponse |
retrieve(java.lang.String url)
Gets an HttpResponse object from the provided string url. |
HttpResponse |
retrieveAndProcess(HttpRequest request)
Sends the the given request - the response is assumed to be XML and is parsed automatically by the client. |
HttpResponse |
retrieveAndProcess(java.lang.String url)
Sends to the given url - the response is assumed to be in XML format and is processed automatically by the client. |
void |
retrieveAndProcessAsynchronously(HttpRequest request,
NetServiceListener listener)
Asynchronously sends the the given request - the response is assumed to be XML and is parsed automatically by the client. |
void |
retrieveAndProcessAsynchronously(java.lang.String url,
NetServiceListener listener)
Asynchronously sends to the given url - the response is assumed to be in XML format and will be processed automatically by the client. |
void |
retrieveAsynchronously(HttpRequest request,
NetServiceListener listener)
Asynchronously gets a response from an url by making a request based on the input HttpRequest object. |
void |
retrieveAsynchronously(java.lang.String url,
NetServiceListener listener)
Asynchronously gets an HttpResponse object from the provided string url. |
void |
startPolling()
Starts a polling thread where client will send periodic request to the Nexaweb servlet. |
void |
stopPolling()
Stops the current polling thread. |
void |
subscribe(java.lang.String[] topics,
MessageListener listener)
Subscribes to a set of topics. |
void |
subscribe(java.lang.String topic,
MessageListener listener)
Subscribes to a topic. |
void |
synchronize()
Synchronize data with the server. |
void |
unsubscribe(java.lang.String topic)
Unsubscribes a topic for all listeners. |
void |
unsubscribe(java.lang.String topic,
MessageListener listener)
Unsubscribes a topic for one listener. |
| Method Detail |
public void openBrowser(java.lang.String url)
throws java.net.MalformedURLException
java.net.MalformedURLException
public void openBrowser(java.lang.String url,
java.lang.String target)
throws java.net.MalformedURLException
url - A full url or partial url relative to current server and applicationtarget - The name of the frame/window to open the url in.
java.net.MalformedURLExceptionpublic java.net.URL getServerUrl()
public java.net.URL createFullyQualifiedUrl(java.lang.String url)
throws java.net.MalformedURLException
java.net.MalformedURLException - if the string passed in is null or a bad url string
public java.net.URL createFullyQualifiedUrl(java.lang.String baseUrl,
java.lang.String url)
throws java.net.MalformedURLException
baseUrl - Something like http://localhost:8080/myApp/pages/url - Something like ../myimages/myImage.gif
java.net.MalformedURLException
public java.net.URL createFullyQualifiedUrl(java.lang.String baseUrl,
java.lang.String applicationPath,
java.lang.String url,
boolean keepContextPath)
throws java.net.MalformedURLException
baseUrl - Something like http://localhost:8080/myApp/path/pages, ending slash is needed if it's only a path.url - Something like ../myimages/myImage.gifkeepContextPath - if this is false and url has leading slash, the contextPath will come from url parameter
java.net.MalformedURLExceptionpublic HttpRequest createHttpRequest(java.lang.String url)
url - The url to the server page. This follows the rules
of createFullyQualifiedUrl. If the url doesn't have a leading slash, the
current application context will be used.
public HttpResponse retrieveAndProcess(java.lang.String url)
throws NetServiceException
NetServiceException, - a wrapper exception of either a failed network call or a failed response processing.
Check the getCausalThrowable() and printStackTrace()
method to find out details.
The network cause could be MalformedURLException, FileNotFoundException, ConnectionException,
IOException etc.
MalformedURLException: when a URL object can't be formed from the input url. This
exception extends IOException and should be caught earlier
than IOException.
FileNotFoundException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException. If the url
is in the classpath:// format or loading context, this exception means loading this resource
returns null.
ConnectException: when the server is not reacheable. Note: Not all the JVM can detect
server throws a ConnectException error. Sometimes, this error falls to 500 or
IOException error. This exception extends IOException and should be caught
earlier than IOException.
IOException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException.
The process cause could be ParserException etc.
com.nexaweb.xml.ParserException: when the data contains a malformed XML; however,
any XML up to the point of malformed data will be processed and executed. Also note
that a well-formed but non-relevant XML, will be ignored during the processing and
will not trigger an exception.
NetServiceException
public void retrieveAndProcessAsynchronously(java.lang.String url,
NetServiceListener listener)
url - The destination url relative to the application context path.listener - The listener to asynchronously call back when the retrieve
is finished or an error occurs.
public HttpResponse retrieveAndProcess(HttpRequest request)
throws NetServiceException
NetServiceException, - a wrapper exception of either a failed network call or a failed response processing.
Check the getCausalThrowable() and printStackTrace()
method to find out details.
The network cause could be MalformedURLException, FileNotFoundException, ConnectionException,
IOException etc.
MalformedURLException: when a URL object can't be formed from the input url. This
exception extends IOException and should be caught earlier
than IOException.
FileNotFoundException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException. If the url
is in the classpath:// format or loading context, this exception means loading this resource
returns null.
ConnectException: when the server is not reacheable. Note: Not all the JVM can detect
server throws a ConnectException error. Sometimes, this error falls to 500 or
IOException error. This exception extends IOException and should be caught
earlier than IOException.
IOException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException.
The process cause could be ParserException etc.
com.nexaweb.xml.ParserException: when the data contains a malformed XML; however,
any XML up to the point of malformed data will be processed and executed. Also note
that a well-formed but non-relevant XML, will be ignored during the processing and
will not trigger an exception.
NetServiceException
public void retrieveAndProcessAsynchronously(HttpRequest request,
NetServiceListener listener)
public HttpResponse retrieve(java.lang.String url)
throws NetServiceException
NetServiceException, - a wrapper exception. Check the getCause() method to find out details.
The cause could be MalformedURLException, FileNotFoundException, ConnectionException,
IOException.
MalformedURLException: when a URL object can't be formed from the input url. This
exception extends IOException and should be caught earlier
than IOException.
FileNotFoundException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException. If the url
is in the classpath:// format or loading context, this exception means loading this resource
returns null.
ConnectException: when the server is not reacheable. Note: Not all the JVM can detect
server throws a ConnectException error. Sometimes, this error falls to 500 or
IOException error. This exception extends IOException and should be caught
earlier than IOException.
IOException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException.
NetServiceException
public void retrieveAsynchronously(java.lang.String url,
NetServiceListener listener)
listener - The listener to asynchronously call back when the retrieve
is finished or an error occurs.
public HttpResponse retrieve(HttpRequest request)
throws NetServiceException
NetServiceException, - a wrapper exception. Check the getCause() method to find out details.
The cause could be MalformedURLException, FileNotFoundException, ConnectionException,
IOException.
MalformedURLException: when a URL object can't be formed from the input url. This
exception extends IOException and should be caught earlier
than IOException.
FileNotFoundException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException. If the url
is in the classpath:// format or loading context, this exception means loading this resource
returns null.
ConnectException: when the server is not reacheable. Note: Not all the JVM can detect
server throws a ConnectException error. Sometimes, this error falls to 500 or
IOException error. This exception extends IOException and should be caught
earlier than IOException.
IOException: when the server side page can't be found or
server returns http 404 status code. Note: Not all the JVM can detect server
throws a 404 error. Sometimes, 404 error falls to 500 or IOException error. This
exception extends IOException and should be caught earlier than IOException.
NetServiceException
public void retrieveAsynchronously(HttpRequest request,
NetServiceListener listener)
listener - The listener to asynchronously call back when the retrieve
is finished or an error occurs.
public void synchronize()
throws NetServiceException
NetServiceException
public void openPushConnection()
throws java.net.ProtocolException,
NetServiceException
java.net.ProtocolException - when a JVM is detected not supporting a push connection. There is not request sent to the server.
NetServiceException - when there is an exception when trying to establsh a push connection with the server.public void closePushConnection()
public void subscribe(java.lang.String topic,
MessageListener listener)
throws NetServiceException
topic - The non-null name of the topic.listener - The listener that will process the topic content.
NetServiceException
java.lang.IllegalArgumentException - Thrown if the topic contains a '*',
which is reserved for future use, or either the topic or the listener
is null.
public void subscribe(java.lang.String[] topics,
MessageListener listener)
throws NetServiceException
topics - The topic array.listener - The listener that will process the topic content.
NetServiceException
java.lang.IllegalArgumentException - Thrown if the topic contains a '*',
which is reserved for future use, or either the topic or the listener
is null.
public void unsubscribe(java.lang.String topic)
throws NetServiceException
topic - The non-null name of the topic.
NetServiceException
java.lang.IllegalArgumentException - Thrown if the topic is null.
public void unsubscribe(java.lang.String topic,
MessageListener listener)
throws NetServiceException
subscribe method.
After removing one listener, if there are still other listerners for the same topic, the remaing listeners will continue to be notified when messages arrive.
topic - The non-null name of the topic.listener - A listener instance
NetServiceException
java.lang.IllegalArgumentException - Thrown if either the topic or the listener
is null.
public void publish(java.lang.String topic,
Document content)
throws NetServiceException
topic - The topic this message should be published on.content - The Document to publish.
NetServiceException
public void publish(java.lang.String topic,
Element content)
throws NetServiceException
topic - The topic this message should be published on.content - The Element to publish.
NetServiceException
public void publish(java.lang.String topic,
java.io.Serializable content)
throws NetServiceException
topic - The topic this message should be published on.content - The Serializable object to publish.
NetServiceException
public void publish(java.lang.String topic,
XmlSerializable content)
throws NetServiceException
topic - The topic this message should be published on.content - The XmlSerializable object to publish.
NetServiceException
public void publish(java.lang.String topic,
byte[] content)
throws NetServiceException
topic - The topic this message should be published on.content - The byte[] to publish.
NetServiceException
public void publish(java.lang.String topic,
java.lang.String content)
throws NetServiceException
topic - The topic this message should be published on.content - The String to publish.
NetServiceExceptionpublic void startPolling()
public void stopPolling()
throws java.net.ProtocolException
java.net.ProtocolException - when reliable messaging is enabled, calling this method
will throw ProtocolException.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||