Whats new in JavaFX1.2 release for WebServices
I wanted to cover what is new in JavaFX 1.2 for WebService.
Feed API
Mobile-friendly, streaming API. Each Entry or Item is delivered incrementally as
it is parsed
● Atom: Feed followed by zero or more Entries
● RSS: Channel followed by zero or more Items
FeedTask
The FeedTask abstract class
Base class for Atom and RSS Tasks
► location:String // feed URL
► interval:Duration // poll interval
► onException:function(ex:java.lang.Exception)
► onForeignEvent:function(event:Event)
the onForeignEvent callback reports events that are not in the native namespace
AtomTask
class AtomTask extends FeedTask
► onFeed:function(feed:Feed)
► onEntry:function(entry:Entry)
Example
AtomTask {
location:”http://blogs.sun.com/.../atom”
interval:2h
onFeed:function(feed:Feed) {
title = feed.title.text
}
onEntry:function(entry:Entry) {
show(entry)
}
}.start()
RssTask
class RssTask extends FeedTask
► onChannel:function(channel:Channel)
► onItem:function(item:Item)
Example
RssTask {
location:”http://developers.sun.com/rss/javafx.xml”
interval:1h
onChannel:function(channel:Channel) {
title = channel.title
}
onItem:function(item:Item) {
show(item)
}
}.start()
Changes in Existing APIs
a) "enqueue" method in HttpRequest is replaced with "start" method. start makes more sense.
b) HttpRequest Bulk Data Read
"sink" attribute is added in HttpRequest.
For downloading large For downloading large data, typically media. Specify a destination for data and start as usual
sink:java.io.OutputStream
def bos = new java.io.ByteArrayOutputStream()
def http = HttpRequest {
location:“http://javafx.com/xyz/test.flv”
sink: bos
}.start()
when done, bos should contain the contents of "http://javafx.com/xyz/test.flv"
c) HttpRequest: Bulk Data Write.
For uploading large data, typically media. Specify a source of data and start as usual
source:java.io.InputStream
def is = ... // image or video stream
def http = HttpRequest {
location:“http://cloud.sun.com/uploads”
method:HttpRequest.POST
headers:[HttpHeader.basicAuth(user,password)]
source:is
}.start()
when done, the contents of is should be available at the upload location specified.
e) HttpRequest: Setting Request Headers
Set the headers var to set HTTP request headers
headers:HttpHeader[]f) HttpRequest: Get Response Headers
headers: [
HttpHeader {
name:HttpHeader.CONTENT_TYPE
value:”image/jpeg”
},
// convenience function for creating an HTTP Basic Auth header
HttpHeader.basicAuth(username, password)
]
Get all header names and values
► responseHeaders:HttpHeader[]
Using callback
► onResponseHeaders:function(headerNames: String[])
Get specific header by name
► getResponseHeaderNames():String[]
► getResponseHeaderValue(name:String):String
Example
def etag = getResponseHeaderValue(HttpHeader.ETAG)
It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.
Posted by Abercrombie and Fitch on November 08, 2009 at 01:51 PM IST #