Val's Blog
Lots of stuff for Web 2.0 freaks and Java addicts
Feeds RSS | Atom | RDF
 
 
C.A.R. Hoare: "The unavoidable price of reliability is simplicity."
[ Login ]

April 2005
SunMonTueWedThuFriSat
      1  2 
 3  4  5  6  7  8  9 
 10  11  12  13  14  15  16 
 17  18  19  20  21  22  23 
 24  25  26  27  28  29  30 
Mar  |  Today  |  May
XML Feeds   Subscribe with Bloglines

Javaranch Sheriff   My LinkedIn Profile
Drop me a line or two   Bloglines Blogroll
JavaRSS   Referers
How cool are you?   My Reviews

Next trips...
SpringOne 2008 (Jun 11-12, 08)
Ajax Exp. 2008 (Sep 29-Oct 1, 08)
Top 10 entries (#hits)
(As of Nov 30, 2007)


Top 10 entries (#hits/day)
Come Back (5.032)
(As of Nov 30, 2007)
Recent Blog Entries
Recent Blog Comments
Re: Review of "Marketing Management 12th"
i know marketing management by kotler is good book but the problem is that the management part of this book is totally missing as fare as i know managemet is complete different subject and it should not be mixed i am student of MBA i was looking at ass...

Re: Review of "Pro Spring"
Using simple POJOs + factories without Spring for "echo" and "counter" would be a lot more easier. No need to write those XML files... So, in this case using Spring makes me write a lot more code... (OK, you can generate everything with the help of And...

pls urgent
Hi I am trying to generate the word doc but i m not understanding wats happening any one pls figure it out /* * WordAPI.java * * Created on May 30, 2006, 10:50 AM * * To change this template, choose Tools | Template Manager * and open the te...
Archives (# entries)
Links
Other Blogs
Other Blogs

Reviewing
Reading
Locations of visitors to this page
What they once said...
 

I have been interested in AOP stuff ever since the first time the acronym has been pronounced. Since then, I'm trying to get my eyes and brain cells on each and every AOP article and book on the subject. Two years ago, I asked O'Reilly whether they would be interested in a book about AspectJ and/or AOP. Mike and Brett were quite interested but at some point the whole thing just went down the sink. What really matters to me is that they finally got someone (Russell Miles) to write their "AspectJ Cookbook" which I have been delighted to review. Thanks O'Reilly for contributing this title to my AOP bookshelf.

My 8-horseshoes review follows (also available at Javaranch.com):

Undeniably, the aspect-oriented paradigm has gained a significant momentum in the academic world over the past years and is increasingly acquiring ground and broad support in industrial settings as well. Until now we have experienced four editions of the famous AOSD conference, the publication of a dozen books fully dedicated to aspect-oriented matters as well as the birth of numerous frameworks, libraries and languages, such as AspectJ which is commonly considered as the most popular and mature AOP language. The increasing popularity of AspectJ is thus directly proportional to the growing need for a consolidated AOP code base that shall help people solve their everyday programming tasks.

In AspectJ Cookbook, Russell Miles has successfully put together more than 350 pages of high quality material freshly unloaded from his AOP backpack just for you. Sure as hell you already have a dozen versions of the logging aspect in your pockets, but do you know how to efficiently validate method parameters, how to transparently remote a class using RMI, how to implement GoF patterns in a non invasive way, and how to seamlessly enable caching in your code? I thought so.

Aside from the fact that this book could have contained twice its actual page count, it is a pure product of a pragmatist for pragmatists. You won’t find endless and tiring stories, just a fair load of ready to use AOP code organized along O’Reilly’s famous problem/solution/discussion cookbook format. If you are still wondering whether AOP will take off some day, well, stop thinking and start acting!

The third edition of the Java Language Specification (JLS) has just came out of the oven five years after the publication of the second edition. Needless to say that this new release contains the largest set of changes since the inception of the Java programming language. It includes all the novelties that have been incorporated in the latest Java 5 release, such as generics, enhanced for loop, autoboxing, typesafe enumerations, varargs, static imports and metadata annotations. Finally, a third breath for all Java professionnals!!

You may get a feel of what's in there before the printed book hits the store by dowloading the PDF edition (6173 KB) on Sun's website.

Happy reading :)

In a previous installment, I wrote about the problematic of effectively piloting Microsoft Word from a Java application. The solution was a little bit clumsy but it worked fine for the needs I had at that time. The idea was to create a Word template and to define bookmarks within the document that would act as anchors that could be referenced from within my Java application. Then, Java calls would be forwarded to Word using some sort of native Word wrapper accessible as a Java proxy. That's it... A couple minutes and I could generate Word documents.

Lately, I was in need of a similar solution for the Microsoft Excel application. I investigated Apache's POI project, which seemed fine at the first glance. The only problems with POI were that:

  1. you don't get any COM bridge between Java and Excel, and thus, you cannot stream data to Excel on the fly;
  2. you get OutOfMemoryErrors when the Excel document you want to build is too big because of the size of the POI object tree.
Another solution was to build a CSV file using string concatenation and then open it in Excel. I also rejected this option because of its lack of flexibility. Besides, I also wanted to generate charts on the fly using the data I was stuffing into that Excel file.

I found a cool and very powerful, yet commercial and somewhat costly, solution, called Intrinsyc's J-Integra for COM. You might wonder, "why the hell is he talking about a $200 product"? Well, $200 is not that much once you discover all the things you can do with the product. Another important thing: this is not an advertisement message, I don't have anything to do with Intrinsyc. I'm just reporting my experience. Anyway... Let's get to the real stuff...

With J-Integra's com2java utility, you can create a Java API from a COM type library that will allow you to access any COM components, such as Word, Excel and Powerpoint to cite a few. When running the com2java utility, you first select the COM type library you would like to pilot through Java and then you run the utility to generate Java proxies for the selected application. The result is a bunch of Java classes and interfaces that mimic the state, behavior and data structures that make up the chosen COM type library. For instance, when considering Excel, you get interfaces and proxy classes, such as Sheets, Charts, Workbook, Worksheet, Axis, etc... When you are done with that one-time proxy generation, you just put them on the classpath together with J-Integra's runtime and you are good to go.

Within your Java application, you can then use the generated proxies to pilot Excel and carry out any operation that can be performed using the Excel application itself since the proxies have been automatically generated from the Excel COM components, and thus, provide all functionalities available in Excel. Concretely, you can:

  • create, rename, delete workbooks;
  • create, rename, move, delete worksheets;
  • create charts;
  • handle data ranges;
  • change the font, the borders, the background color, the cell size, etc;
  • create sophisticated data tables;
  • create formulas and perform computations;
  • register event listeners to be informed of Excel events;
  • select regions and ranges;
  • etc.
You can read the whole documentation here.

Moreover, one big plus of J-Integra's COM bridge solution over Apache's POI API is that the user can interact with the Excel file while it is being generated, which means that you can get user input in real-time and handle it accordingly in your Java business logic.

For instance, initiating an interaction with Excel is as simple as the following code piece:

  excel.Application app = new excel.Application();
  excelApp.setVisible(true);

Then, you can get workbooks and create a new worksheet with the following code:
  Workbooks workbooks = app.getWorkbooks();
  Workbook workbook   = workbooks.add(null);
  Sheets worksheets   = workbook.getWorksheets();
  Worksheet sheet     = new Worksheet(worksheets.add(null, null, null, null));

Once you have a handle on the worksheet, you can easily populate values within a given range as denoted by the following code:
  Range range = sheet.getRange("B2:D4", null);
  Object[][] newValues = {
    { "Hello",           new Boolean(true),  new Double(Math.PI)},
    { new Date(),        new Long(1234567),  new Float(Math.E)},
    { new Boolean(false), "World",            new Date()}
  };
  range.setValue2(newValues);

Finally, once you are done populating your sheet, you just close the workbook and clean the environment:
  workbook.close(new Boolean(false), null, null);
  app.quit();
  com.linar.jintegra.Cleaner.releaseAll();

That's as easy as it gets, isn't it? The biggest negative point I can mention is that 80% of the method parameters in the generated Java proxy classes are of type java.lang.Object and the provided documentation doesn't say much as to what kind of object a given method is expecting as argument. To illustrate this, let's take the method we used above to add a new worksheet.
worksheets.add(null, null, null, null);
In the Worksheets class, the signature of this method is:
public Object add(Object arg1, Object arg2, Object arg3, Object arg4);
Not really self-explanatory as you can see...

If you stick with the most commonly used functionalities, you are fine as the examples provided in the documentation are good enough. But as soon as you delve into more complicated matters, such as charting, then you are in trouble. Personally, I had to browse through their knowledge base and look for articles and white papers. I also had to swim across the 9,000+ messages available in their Yahoo discussion group in order to dig out some basic information. Plus, icing on the cake, by decompiling the generated proxies I could finally infer what a given method was expecting... Not really developer-friendly, I admit, but in a matter of one day, I could create very nice and dynamic charts in Excel.

To conclude, J-Integra brings you the full power of COM right into the Java world. I would also like to mention that J-Integra not only enables Java-to-COM (i.e., C++, ATL, MFC, VB) communications but also COM-to-Java interactions, which means that your C++ and VB applications can talk to your Java programs, such as servlets, EJBs, JMS topics and queues, etc. As you can see, J-Integra allows one to join the best of both worlds into a single and homogeneous whole, which can thus benefit from COM performance and Java flexibility and elegance. Don't throw POI out of the window, though, that API is true gold as well and will probably fit many of your needs.

Once again, many big thanks to the nice folks at APress (especially you Janet) for sending me this review copy of Jeff Linwood's and David Minter's "Building Portals with the Java Portlet API". I definitely enjoyed what I saw in there. A must read for portal developers!

My 9-horseshoes review follows (also available at Javaranch.com):

Information is as vital to success-striving companies and individuals as blood is to living creatures. As far as productivity is concerned, it is critical that heterogeneous corporate information systems (such as, email systems, ERP, CMS, CRM, databases, etc.) be organized in a way that allows employees at any level of the organization to seamlessly exploit and manage the massive amount of stored and generated data. This book introduces the value proposition of corporate portals when it comes to dealing with the problematic of efficient information organization and management.

Building on their long experience of developing corporate portals, the authors demonstrate how to create JSR 168 (Java Portlet API) compliant enterprise portals. They first introduce basic portlets concepts and go on explaining how to create, package, deploy and configure portlets, how to let users personalize them, how to provide single sign-on security, and how to expose portlets to the outside world or to make use of remote web service portlets. A couple of other interesting topics are also touched upon, such as creating RSS, syndication and search portlets, using portlets with JSP and servlets and integrating portlets with JSR 170 (Java Content Repository API) compliant content management systems.

If you find yourself routinely switching among several different applications to carry out your daily activities and you are dreaming at night of a single entry point to all (or most of) your information systems, remember that this book is not to be considered as an expense, it’s an investment !

 
About this Blog