Sunday, May 11, 2008

Java One 2008, day four, part one

Started the day with the always impression Gossiling demo-on-keynote. As every he is a joy to watch and always brings some really interesting projects to the stage.

First up was the visual vm which is best decribed as a lightweight vm profiling and debugging tool. It can connect to any running VM, although it has more features on JDK 6. I like the ability to dump all stack and indeed dump the heap for an already running process without the need to know in advance of starting the debugger. Can be extended too for things like service monitoring, can see this would be a very valuable tool to have in the box.

Next was the javascript support in netbeans that did some very cool type inferance, which is no mean trick with a weakly type languages like javascript. Only support debugging in Firefox, I am pretty sure JDeveloper does IE aswell. (Go go JDeveloper)

The next topic was game development, covering DarkStar and JMonkeyEngine which are server and client engines repectively. Very interesing to see just how good 3D games are in Java these days, specially with a MMO engine like DarkStar.

The presentation ended up with bits on CERN and JMars. CERN uses Java to run just about everything and NASA has most of there visualization software for mars project in java. Used everyday to find landing sites.

Sentilla also did bit; but it wasn't that impressive. Still I have there dev kit now I wonder how far I will get with it.

First presentation of the day was TS-5796 JavaFX Pattern but that will have to wait for another day, time to think about getting on the plane...

Java One 2008, day three

You will have to excuse the lack of cross references to session id in this post, I am writing it at SF airport after a lovely day on the cable cars and down by fisherman's key.

Started the day with NIO.2 or N^2IO depending on who you ask. This is a task to complete the job of filling out the APIs for nio introduced quite some time ago. (Although most people still wont use it directly you will find it underneath most network operations)

The focus in JDK 7 will be to provide a "proper" file system API with methods than throw usefull exceptions rather than just returning the very so useless "false". There is a default "FileSystem"; but the opportunity exists to implement new custom file systems. Where you would normally use File instead you might now use FileRef and Path but there are helper methods to convert in both directions.

There is a new channel type called SeekableByteChannel which is the equivalent of RandomAccessFile in nio. I suspect that most people will be sticking with streams though until and just making use of the extended create operations. In general any method of File has a much better version of FileRef and you can replace "file.move(...)" with "file.getPathRef.move(...)" and get an incremental upgrade to the new API.

There is also some quite cool stuff to down with support for symbolic links and file system attribute models for different platforms. Finally there is support for file system eventing. This allows you to monitor a file or directory for updates. Much better than having to ask for hte lastUpdated flag of each file when you flick focus back to an IDE for example.

Oh and a proper scallable way of getting directory listing that doesn't just block on network drives, about time too!

The presentation then went of to talk about true asynchronous channels. These provide an API very similar to the JAX-WS client API; but with more control over how threads are managed internally. I must find out how to take control of the threads in the JAX-WS client model. This should improve performance in Coment applications, the Grizzly bloke reported at least a 10% speed increase in 1.8 with JDK 7 support. (But that information didn't get to me until later on that day, the joys of writing on past tense.)

Finally the presentation briefly covered better multicast support, although to be honest this isn't used particlarly often but is good to know all the same.

Next up was the TS-5415 Servlets 3.0 presentation, again the key topic of conversation appeared to be asynchronous interfaces. The new specification provide support for suspending and restarting data flow in particlar this helps with comet style application as it now longer required one thread per request. Instead "idle" connections can be parked until some event wake them up and requires a thread for some work to be done in them. This is not going to be production until '09 though as it need to sync with JEE6 although I guess the open source bods will have an implementation much sooner.

They have also gone a long way to update the programming model to take into account the changes to the programming langauges. You can now do an annotation based servlet that looks very similar to the JAX-RS specification, indeed the HTTP operation type parameters are shared. So you servlet might now look like:

@Servlet(urlMaping = "/foo")
public HelloServlet
{

   @GET
   public void doGetOperation(...)
   {
   }

}

Personally I am not 100% sure that this style of programming makes sense in this context; but I am willing to see it tried. A bit of my still like interfaces for this kind of stuff. But having said that composition is better in the long run than inheritance so we will just have to see how it goes.

They have also done some work to change the deployment model. For of all web.xml is optional, and if required can be split up into easier to manage fragments. There is also a programatic API that does much of what web.xml does, this will hopefully work around much of the boiler plate that you end up typing in when you want to use 'clever' framework X.

One final nice change is the ability to deploy an EJB in the war file. This might not seem like much but things get complicated packaging wise. You either have to duplicate the EJB interface in both the ear and war or create a shared jar file to contain it.

I did then briefly go to TS-7477 101 ways to interoperation with .NET which was a dissapointment and I didn't stay long; but I did walk away with a Microsoft/Java dual marketed pen drive. I wish I had gone to TS-6128 which was more about WS interop, I did pull the powerpoint though so hopefully there is anough in there to get me going. (Otherwise Sun will eventually get around to publishing the presentations as web casts.)

The last, and probably one of the best presentations of the day was TS-5186 Design Patterns Reconsidered. (You can find more stuff on this here, I am not sure I can do it justice.) It was a quick walk though although I could quite happily given this chap me ears for two or three hours.

He started the presentation by bashing singletons, which always get a presenter in my good books, covering the normal points about how hard it makes testing/ slash know what the hell the code is going to do next. As I would expect he doesn't critise the idea of holding onto a single object; just how it is implemented. Instead he quite rightly suggets using DI to managed and inject a refernece to the object as required, much better.

He covered the template patter and how it makes the code much harder to evolve all very good points. Suggested that composition is a much better way to go, which I agree with, and that perhaps this is even easier with some closure proposals as you don't end up having to define n interfaces for n injection points.

He skipped over proxy which is a shame, but when spent quite a bit of time on the Visitor pattern. Again this can make it very hard to evolve your system to include new types. In particular he suggested closured might make it much easier to do the visitor pattern in a flexible way. You might have something like:

for walkModel(model,
              {Node n => n....// get next node},   // Stratergy
              {Node n => if (n.getName().equals("foo") break;}); 

Could be a really powerfull syntax, he also had a real nice catagorization of visitor types which I will shamelessles copy here:

  • "Collector" : gather a sub set of nodes from the model
  • "Finder" : find one particular node and exit
  • "Event" : walk the model and generate events, like the DOM->Sax bridge
  • "Transform" : modify the model, could be real dangerous
  • "Validation" : check the data in the model

Again well worth looking his his website and watching the presentation when it becomes avaliable.

Last presentation of the night was one of writing java implementations for Quicklook and Spotlight on OS X given by my friend Tim and he work collegue John. You can get the code from sf, but theirs was one of the few presentations where the demos to get a geniun round of applause. Mike from apple took question at the end; but as expected didn't resolve the 32bit intel mac issue. Grrr all my macs are 32bit.

Did bump into some BEA engineers, hi Mykola and Hang, and we swapped experiences of working for Oracle in line whilst waiting to get into the concert. They seem jolly nice chaps and I will look forward to working with them in the future as they happen to work on the web services stack in web logic. The gods of networking were smiling on me this evening.

Then up to the Bueno Yeuna gardens for a bit of beer food and music. Turns out to be a bit cold up there so after a few sets we went along the road to the thirsty bear for some beer and tapas. Then back to hte Nikko with my brain buzzing again from all the stuff I have been trying to learn.

Saturday, May 10, 2008

Java One 2008, very much over

Still have a few days worth of notes to write up; but java one is closed and the center packed up. My head is full of new stuff, and I am worried someone will ask me to learn something tommorrow and my head will explode! I bought some noise cancelling headphones just in case, not sure if that will help. :-)

In case you are wondering quite a bit of business did get done, I met face-2-face and hopefully made some new friends both in oracle and the soon to be oracle parts of BEA. New directions have been taken with regard to the abbot/costello project, or at least we have an understanding of where we need to take it. And maybe just maybe we made some people think......

I a few hours in SF tommorrow morning, hoping to pop over and see some tall ships in the morning; otherwise it is off to the MOMA for me. Then off to the airport for the slow drag back to blightly.

Java One 2008, day two

Gosh it is friday and I have only written up my notes for tuesday. Time certainly flies here. I resolved to take it a little bit easier, and say eat or something, on tuesday.

So the day started with the Oracle keynote, quite a good one as generally I don't find much of interest in there for an Oracle developer. Lots of good stuff using web center and bea stuff we so recently aquired. Indeed the crowd around me seem suitable impressed with this enterprise 2.0 demo.

The first session of the day was TS-5579 Closures Cookbook presented by Neal Gafter of the BGGA proposal. So we were looking a one possible solution; but one that was strangly compelling.

So the presentation was focused around the languages changes required to support the following time general call:


public void timeWithNoReturn()
  throws MyException
{
   time(“opName”, {=>
      // some statements that can throw MyException
   });
}

public int timeWithReturn()
  throws MyException
{
   time(“opName”, {=>
     // Note the return is from the "timeWithReturn" and will bypass anything
     // except finally blocks

     return ...compute result...;
   });
}

Looks simple enough? Well when you follow the presentation though you come accross several issues. For example in the return case you will end up with a compile error because there is not guarenteed return from the second method. Also with the current type system it would be hard to define multiple throws types in the API. Take a look at the API, with some annotations added to show new language features.


// Note "throws X" this generic type can have multiple Exceptions defined for it
// R is type "Void" in the non-return case and
// R is type "Nothing" which is a special type which signal the tool that the 
// operation never really returns, think of System.exit(...) which should never 
// return

interface Block {
  R execute() throws X;
}

public  R time(
  String opName, Block block) throws X {
    long startTime = System.nanoTime();
    boolean success = true;
    try {
      R ret = block.execute();
      // In the return case you never get to this statement; but the 
      // finaly statement is run
      return ret;
    } catch (final Throwable ex) {
 
      // Notice the "final" in the catch clause, this allows us to rethrow
      // Throwable without having to delcare that in the operation definition.

      success = false;
      throw ex;
    } finally {
      recordTiming(
        "opName", System.nanoTime() - startTime, success);
    }
}

Another example is a closure for making sure streams are closed out, a very common issue, here a function type is used rather than an interface:


// Note function type takes as parameter C that returns X and throws X.


R withStream(C c, { C ==> R throws X } block)
  throws X, IOException {

  try {
    return block.invoke(c);
  } finally {
    c.close();
  }
}

// So code might look like, note the simplified syntax

withStream (InputStream s = getInputStream())
{
   // Do somethign
}

There are other examples particularly with the "for" loop modifier so that the closure can properly use break and continue. But you will need to look into the proposals for more information.

Still not suggestion that a choice has been made as to which of the closure proposals is the best though.... hopefully in time for JDK 7.

Next up was TS-5286 which focused on Web Beans which is very similar to the functionality seen in Spring 2.5. Use of Meta or Annotation on Annotations in order to guide how things are put together. Not entirely sure whether this is more valuable as a component, or just something that is a retreat of other work. Intereesting design all the same.

I then popped into TS-5535 which was about tying java service together in a restfull way. Unfortunately it appear to cover much of the TS and BOF I have talked about before so I decided to take a walk over to the Alumin lounge to take my mind off the upcoming presentation. Just down the road as the crow flies in the intercontinental, there was also the promise of the gift but apparently that doesn't work if you are also a presenter. Oh well.

Then it was back to the session for my presentation with Manoj. (TS-5318) This appeared to go okay, and indeed appeared to go over okay based on feedback from people in the audience. I apparently did talk a little bit to fast so my "jokes" might have been lost as the audience was used to proper English. Still 3-400 people and not a large number of people left which I take to be a good sign

[Interestingly Manoj went to a Metro presentation on Friday and one of the questions was whether they were going to do an async annotation like we had been talked about. Luckily Manoj was on hand to give his card to the sun folks and re-inforce the point. Nice to know we had some effect and were presenting something that they people were going to be interested in]

Left the room with a real buzz, met a nice chap from Venzuila, I think, he is going to get in touch next week. Stupid me for not taking any business cards.

I tried to go to "TS-6213 Boldly going where java..." which started with Terracotta but I kinda lost focus and decided to crawl the Pavillion a little bit. I am not saying that the ability to automatically sync data between VMs is interesting, I just wasn't in the mood. But more on my adventures in the pavillion in another post.

The last session of the day was BOF-5661 which gave a nice introduction to Comet and a mind blowing technology called "Reverse-Ajax". So Comet is a style of programming where the server pushed events to the client asynchronously. The name comet has been picked to be a generic term withouth out any clever agenda. In general though the web page has the normal socket open along with a second that provide a channel for the server to update the client.

The astute amoung you will know that a particlar server can only deal with so many threads and therefore open connections at a time. There are ways to work around this that are dealt with in Servlet 3.0 and NIO.2; but there are servers you can use for this that know how to keep up connections without loading up the number of threads. In particular cometd was metioned.

Now once you have a connection you can update the client, this generally involves lot of script in the browser a whole bunch of clients were presented that allow the java on the server to update the HTML page either with partial updates or just blocks of java script to be run on all of the clients. Really very cool stuff, blew my mind for the evening.

With that I was off to the pub with a few friends from NJ. Though it was best to eat properly for a change!

Friday, May 9, 2008

Norwalk like virus outbreak at JavaOne

Hmm, now wash your hands. The nasty thing is that can catch if off frabrics, glad I am not flying out tonight. Could turn into a scene from an horror film!

@AsyncWebService in BEA Weblogic

Had a nice chat with the bods on the BEA stand today amoungst other things I found out how to do the equivalent of the @AsyncWebService annotation that we have been working on in OC4J. Turns out it was just staring me in the face and that they just use different terminology. (Need to use the buffered and callback features)

So to compare this is our version:


@WebService
@AsyncWebService
public class StockQuote
{
   public float getStockQuote(String ticker)
   {
      return 100f;
   }
}

So the basic version for stock quote would look like:


@WebService(...)
@WLHttpTransport(...)
@BufferQueue(name="my.jms.queue")

public class StockQuote {


  @Callback
  private StockQuoteResponse _response;


  @WebMethod()
  @MessageBuffer(retryCount=10, retryDelay="10 seconds")
  @Oneway()

  public void getStockPrice(String ticker) {
    _response.getStockPriceResponse(100f);

  }
}

The downside is that at least based on the documentation I have is that you cannot do this with JAX-WS. This might be something they have fixed in the 10.3 build; but I haven't got my hands on this yet to take a look. I will drill down with the BEA people as we have contact to find out how this is resolved in 10.3.

Asynchronicity is real theme of JavaOne 2008

Although the official theme is "Java One and You" the unofficial theme seems to be asynchronicity in various for. Whether it be in the "New New IO" API (N^2IO), the Fork/Joint concurrency proposal, reverse AJAX, comet, Servlets 3.0 and indeed my own presentation the main focus was dealing with the fact that the world is no synchronous.

It is interesting that similer problems result in similar solutions. For example the N^2IO API uses the same form as the JAX-WS client generation. Although it does give some control over the thread for the callback which the JAX-WS doesn as far as I know.

All very cool stuff.