IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & industry solutions      Support & downloads      My IBM     
developerWorks  >  Blogs  >   developerWorks

author Web 2.0 and Middleware

Roland Barcia is a Senior Technical Staff Member (STSM) and lead Web 2.0 architect for IBM Software Services for WebSphere.



Tuesday May 13, 2008

Persistence in the Enterprise

I have just finished 5 straight weeks of conferences starting with IBM Impact and finishing last week at the WebSphere Services Technical Conference which is an internal conference. I am glad it finished. Last week, my book, Persistence in the Enterprise was released.

Besides myself, my coauthors are Geoff Hambrick, Kyle Brown, Robert Peterson, and Kulvir Bhogal. The book focuses on the persistence layer of an application. The first half of the book is primarily focused on things like requirements (persistence focused), design, best practices, and criteria for selecting a persistence layer. The second half of the book focuses on implementing those using 5 different technologies: JDBC, IBatis, Hibernate, OpenJPA, and pureQuery.




May 13 2008, 09:40:57 AM EDT Permalink



Tuesday April 08, 2008

WebSphere sMash powered by Project Zero

Today, at IBM Impact, we announced a suite of Mashup Solutions, including WebSphere sMash. IBM WebSphere sMash is a development platform that supports dynamic scripting languages and aggregates data from various sources. It employs REST. The developer edition of sMash remains free, but a commercial platform will be licensed. WebSphere sMash is based on IBM's Project Zero. In addition to WebSphere sMash, we also announced the IBM Mashup Center.

IBM Mashup Center: The mashup center is a group of Web applications that account for IT requirements such as security and governance. Underpinning the Mashup Center is IBM’s Lotus Mashups and InfoSphere MashupHub. IBM has been experimenting with mashups internally. Among the components:

*

  • Lotus Mashups allows business types to drag and drop mashup components from Web, personal and enterprise sources to launch custom Web apps.
  • The InfoSphere MashupHub is “a lightweight environment for unlocking, transforming and mixing enterprise, departmental, Web and personal systems while enforcing enterprise-class security and governance.” In other words, it’s for folks that want to mess with a little or no code.




Apr 08 2008, 01:06:14 PM EDT Permalink



Wednesday April 02, 2008

IBM IMPACT and Web 2.0

Hi everyone. Next week is IBM Impact. I plan to be there, God willing. (I am recovering from a bronchitis infection that had me in the hospital on Sunday). I am excited at all the Web 2.0 content. There is going to be a lot of sessions on Project Zero, the WebSphere Web 2.0 Feature Pack, Ajax, and others. Below are the list of Sessions I will be speaking at or part of:

*

  • TSD-2203A Lab: Constructing mashups and integrating services with Project Zero MGM Grand: Studio 8 Tue, 8/Apr, 09:00 AM - 11:45 AM
  • ICR-1396A SOA foundation deployment: Summary of 92 case studies MGM Grand: Vista Room 210 Wed, 9/Apr, 03:15 PM - 04:30 PM
  • TSD-1238A Developing Web extended service-oriented architecture applications with Project Zero, Groovy, and REST MGM Grand: Room 119 Wed, 9/Apr, 04:45 PM - 06:00 PM
  • TSD-2201A Lab: Developing RESTful services with Project Zero and PHP or Groovy MGM Grand: Studio 6 Thu, 10/Apr, 09:00 AM - 11:45 AM
  • TSD-2203B Lab: Constructing mashups and integrating services with Project Zero MGM Grand: Studio 8 Fri, 11/Apr, 09:00 AM - 11:45 AM

I will also be participating in session: 1519: Showcase: Web 2.0 innovations: Mon, 7/Apr 03:45 PM - 05:00 PM MGM Grand: Room 118

There is also Web 2.0/App Dev Tech Zone. I will be host for the time slot below.

*

  • Date: Tuesday, April 8, 2008. 3:15–4:30pm
  • Topic: Best Practices for Web 2.0 Development
  • Location: Web 2.0/App Dev Tech Zone, 3rd Floor of Conference Center

I will also be there during Jason and Kyle's 'What is Project Zero and how does it help you?'

Hopefully, my bronchitis goes away and I will be good to go.

You can look over the Web 2.0 track here:




Apr 02 2008, 08:40:14 AM EDT Permalink



Wednesday March 26, 2008

Chat on Dojo Toolkit and WebSphere Web 2.0 FP

Several of my colleagues and I will be hosting a chat. We will be answering questions on new features in Dojo 1.1 as well as questions on the WAS Web 2.0 FP.




Mar 26 2008, 07:48:37 PM EDT Permalink



Thursday March 06, 2008

Coding Servlets is cool again

With the EJB 3 and Ajax Patterns, I am finding it much easier to code Service Endpoints in Servlets, rather than using frameworks sometimes. Traditionally, the use of MVC abstractions was favored because a lot of view logic was handled in the Container. But for Ajax apps coded in something like Dojo, I find myself just writing RESTful Services for Java EE apps in Servlets. The fact that I can inject Session Beans right into them makes it easy to hook up Ajax endpoints to business logic. Below is an example of a Servlet using the JSON4J API that is part of the WebSphere Web 2.0 Feature Pack.

public class Product extends javax.servlet.http.HttpServlet

@EJB

private ProductSearchService productSearchService;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setHeader(“Content-Type“, “application/json” );

if(request.getPathInfo() != null)

{

try

{

int productId = Integer.parseInt(request.getPathInfo().substring(1));

org.pwte.example.domain.Product product = productSearchService.loadProduct(productId);

JSONObject productJson = ProductToJsonHelper.serializeProductToJson(product);

productJson.serialize(response.getWriter()) ;

}

catch (ProductDoesNotExistException e)

{

response.sendError(response.SC_NOT_FOUND) ;

}

catch (Exception e)

{

response.sendError(response.SC_BAD_REQUEST) ;

}

}

else if (request.getParameter(“category” ) != null)

{

try

{

int categoryId = Integer.parseInt(request.getParameter(“category” )) ;

List products = productSearchService.loadProductsByCategory(categoryId);

JSONArray productArray = new JSONArray();

for (org.pwte.example.domain.Product product: products)

{

JSONObject jsonProduct = ProductToJsonHelper.serializeProductToJson(product);

productArray.add(jsonProduct);

}

productArray.serialize(response.getWriter()) ;

}

catch (Exception e)

{

response.sendError(response.SC_BAD_REQUEST) ;

}

}

else response.sendError(response.SC_BAD_REQUEST) ;

}

}

Of course, writing logic to move between POJO's and JSON is not as fun. Forwarding to a JSP template to do this could be easier. Or using a higher level API like that in the RPC package may be preferred as well.




Mar 06 2008, 08:41:08 AM EST Permalink



Monday February 18, 2008

Project Zero Milestone 4 Released

The Project Zero Development Team has just released Milestone 4. The Project Zero Developer's Blog contains some overall highlights of this Milestone.




Feb 18 2008, 09:54:20 AM EST Permalink



Wednesday January 30, 2008

Dojo MVC: Dojo Store(Model), Dojo Grid (View), DojoX Wires (Controller)

I have been using the Dojo Store, Dojo Grid> and Dojox Wires a lot recently to build RIA applications that consume RESTful Services that I create in Project Zero. Since REST focuses on exposing resources, it puts some burden on maintaining flow on the clients. Model View Controller in my mind is crucial in Ajax applications. To reduce some chattiness, Ajax applications deal with data locally, and certain UI events trigger saving local data to the server. In essence, the Ajax applications that deal with local data now need to manage 2 resources, a local one inside the browser and a set of remote resources, and has to do so without the benefit of a transaction manager.

Applications have to worry about keeping the state of the local data clean, as well as deal with server data. This makes the role of a Controller in Ajax applications very important. An Ajax controller needs to:

*

  • Respond to UI events
  • Synchronize Data between Local Model and Remote Model (RESTful Services represented as URL‘s)
  • Respond to Server events (Ajax responses or COMEt patterns)
  • Update View (or at least trigger the updating of a widget, or trigger a refresh of a smart widget).
  • Error Handling for all the scenarios above.

It seems that the Controller logic is where I use JavaScript the heaviest. Lately I have found the Dojox Wires really helps reduce the amount of JS that I write, so I am using it more and more inside my controller logic. It does not completely eliminate JS, but it gives my controller some structure. I previously blogged about Dojox Wires. I find myself repeating the same patterns again and again. The architecture looks like the figure below.

I may be looking to use JET Transformations to generate these type of clients from existing RESTful Resources.

I have had some interesting experiences with the Dojo Grid and the Dojo ItemWriteStore. A Dojo Grid can be populated from a Store. For a while, when I updated the data in the grid, the Dojo Store was not being updated. I had populated the Grid programmatically with code like this:

incentiveHandler.incentiveStore = new dojo.data.ItemFileWriteStore({data: this.result}); incentiveHandler.incentiveModel = new dojox.grid.data.DojoData(); incentiveHandler.incentiveModel.store = incentiveHandler.incentiveStore; incentiveHandler.incentiveModel.query = {incentiveid:‘*‘}; var grid = dijit.byId(‘grid‘ ) ; grid.setModel(incentiveHandler.incentiveModel);

I was doing it programmaticly because I had to first wrap the RESTful Data into Store format (I recently discovered wires helps here too). My friend and coworker Jared Jurkiewicz then told me that the DojoData Object for the Grid needed to receive the Store at construction time, or else it would think the Store was read only. So if you want changes to the Grid to propagate to the Dojo Store, you need to create the Grid Model by passing the Store in its constructor as shown below.


incentiveHandler.incentiveStore = new dojo.data.ItemFileWriteStore({data: this.result});

incentiveHandler.incentiveModel = new dojox.grid.data.DojoData(null,null,{store:incentiveHandler.incentiveStore,query:{incentiveid:‘*‘}});

var grid = dijit.byId(‘grid‘ ) ;

grid.setModel(incentiveHandler.incentiveModel);

I also realized that the Data in the DojoStore should not be manipulated as discussed in the Dojo Book here. Having a useful ItemToObject method like the one below is a useful idea (Thanks Jared).

itemToObject:function(store,item)

{

var jsItem = {};

if (store.isItem(item))

{

var attributes = store.getAttributes(item);

if (attributes)

{

var i;

for (i = 0; i < attributes.length; i++)

{

var value = store.getValue(item, attributes[i]);

if (store.isItem(value))

{

value = this.itemToObject(value);

}

jsItem[attributes[i]] = value;

}

}

}

return jsItem;

}




Jan 30 2008, 07:45:57 PM EST Permalink



Thursday January 17, 2008

RESTful Applications in an SOA

I just published part 2 of my article series that I am writing with Steve Ims. It is titled RESTful Applications in an SOA. In it, we show building a RESTful Application around Energy Incentives. We illustrate different concepts of the Project Zero Programming Model:

*Building RESTful Services with the Data Access API's

*Securing RESTful resources with Zero security

*Restful Documentation

*Zero Resource Model (ZRM)

*Zero client programming model.

*Dojo Grid Usage with Zero.


This is actually a scaled down example of the Incentive Finder component within the website called energycommons.com. Currently this site is in Beta and we are making many more enhancements to improve the usability and function.




Jan 17 2008, 08:03:51 PM EST Permalink



Wednesday January 16, 2008

Oracle and BEA: OpenJPA (Kodo) or TopLink JPA?

Many have commented on Oracle buying BEA out there in the blogging community. One thing I am very interested in seeing is which persistence mechanism is supported if they choose one. Most likely, we will see Oracle pushing BEA's App Server. TopLink has had a long history as a persistence provider and supports JPA. But BEA's App Server is based on OpenJPA (more specifically the Kodo product they purchased from SolarMetric.) IBM also built its JPA provider(available via the EJB 3 Feature Pack for WebSphere) on top of OpenJPA. It should be interesting to see which way Oracle/BEA goes with in persistence.

I recently released a tutorial on using the EJB 3 FP for WebSphere.




Jan 16 2008, 03:54:12 PM EST Permalink



Wednesday January 02, 2008

WebSphere Web 2.0 Feature Pack has been released

Happy New Year Everyone!! I hope everyone has a blessed new year.

The WebSphere Web 2.0 Feature Pack is now officially production ready.

Highlights include

*

  • API‘s for exposing Java EE applications using JSON , JSON-RPC , and ATOM .
  • An Ajax Proxy which allows you to deal with cross domain security issues.
  • Ajax Messaging Bridge for extending your Messaging based Bus to the browser. This can be used to support COMet patterns.
  • Ajax Development support, which includes the Dojo Toolkit and some more widgets for Dojo that we provide.

The FP can be used with WAS 6.1, WAS 6.0, or WAS CE 2.0.

A few weeks ago, I posted on how the EJB 3 FP and the Web 2.0 FP can be used together to provide a simplified Programming Model for the Enterprise.




Jan 02 2008, 09:30:51 AM EST Permalink



Wednesday December 26, 2007

RESTful patterns for partial lists

Merry Christmas and sorry for not posting in a few days. I was trying to meet the deadline for getting the updates for my book to the publisher and Geoff and I had to pull a couple of all nighters. The title of the book is Persistence in the Enterprise and it should be released soon. I also just published an article on using the EJB 3 FP for WebSphere.

I wanted to post on this a few days back. In the first installment of my Project Zero Series (Part 2 based on Milestone 3 will be released shortly) we discuss RESTful patterns. One of the things that we covered is RESful patterns for getting a list of all items and a single record.

* http://host/resources/customer will return a list of customers.

  • http://host/resources/customer/roland will return the record for Roland.

One thing I have been getting asked is how do I RESTfully interact with a partial list. Not pagination of a list, but specifically asking for a list based on a set of keys. This is equivalent to

select * from table where key in (a,b,c,d,e). The most typical use case for this feature I have seen is a "Compare" feature in a shopping application, where I may select 3 or 4 items to compare side by side. By selecting a checkbox and clicking compare, I need to generate a RESTful URI with 3-4 keys. One thing to note that REST allows the use of query parameters as an alternative.

http://host/resources/customer/roland and http://host/resources/customer&customerId=Roland are both perfectly RESTful. I know that some people prefer not to use query parameters this way to access a single record. The rule of thumb I have heard is use the URI namespace for primary keys or other mandatory fields, and query parameters for filter criteria or optional parameters. With that in mind, there are three options for this RESTful query

Option 1: Namespace Option.

http://host/resources/product/23/22/44/55

In this case, you add a set of keys after the product. This may require you to do some parsing of the URI, and it can be confusing if keys are Strings, because nested URI names can also imply relationships such as /category/3/product

Option 2: Multiple Query parameters for key

http://host/resources/product?productId=23@productId=24&productId=44

Most servers will give you an array back.

Option 3: Single comma separated key parameter.

http://host/resources/product?productId=23,24,44,33

This one seems more compact and straight forward, but again you have to parse yourself. However, if your service implementation is using a Select * from Product where productId IN(23,24,244,33), then you can pass this request parameter fairly simply into the In clause. Although with some implementations, building queries this way may by pass prepared statements.




Dec 26 2007, 02:00:32 AM EST Permalink



Friday December 14, 2007

Project Zero Milestone 3 released

Milestone 3 of Project Zero has been released. As posted on the Project Zero Developer's Blog, some major highlight's include:



  • Zero Resource Model enhancements


  • Zero Code Completion for Groovy (Eclipse)


  • Enhanced management features (CLI and RESTful interfaces)


  • OpenID support


  • Cross-Site Request Forgery prevention


  • Groovy 1.5


  • Dojo 1.0.1




You can download the latest Milestone from the download page of projectzero.org.

I will be presenting at AjaxWorld in NYC, in the month of March, about Project Zero.

Also, I recently released an article that shows you how to use the EJB 3 Feature Pack for WebSphere.



Categories : [   Ajax  |  AjaxWorld  |  EJB3  |  Zero  ]

Dec 14 2007, 10:14:19 PM EST Permalink



Monday December 10, 2007

Dojox Wire

Last March, I wrote an article about Ajax applications passing data versus html markup as content. As middleware becomes more Service Oriented, Ajax Applications are needing more and more sophisticated MVC models. Of course, this means more JavaScript. However, with the release of Dojo 1.0, I have been using the new Dojox Wire Technology. It allows me to declare composite actions based on JavaScript events. I really like this technology. Below is a snippet of code of an application I am writing



The logic in the figure defines a sequence of steps I want to happen when the application loads. The Action tag defines a composite where I can nest Invocations to JavaScript functions, as well as Transfer data. Writing such logic in JavaScript code requires a lot more explicit eventing.



Below is a summary of the supported actions:





  • dojox.wire.ml.Action

    The basic action container widget that supports filtering of actions. When some event/function is invoked on Object X and all filters match, do A,B,C.

    This widget can contain sub-widgets of type:

    • dojox.wire.ml.Transfer
    • dojox.wire.ml.Invocation
    • dojox.wire.ml.ActionFilter

  • dojox.wire.ml.Transfer

    The data wiring widget. On some event, copy property/value X from object A to property/value Y on object B. This widget can contain sub widgets of type:

    dojox.wire.ml.ChildWire (and all subclasses.)



  • dojox.wire.ml.Invocation

    The method invocation widget. When action X occurs, invoke Y on object B.



  • dojox.wire.ml.Data

    Declarative data variables. Think of this as a way to declare a new data object (JavaScript object, array, etc), completely in markup, no nested script tags.



  • dojox.wire.ml.Service

    Declarative service invocation. This widget allows you to define services to invoke when specific actions occur and where to route the results. It knows how to handle various services through mappings. Currently, it maps the following service types to dojo service classes:

    • “TEXT“: “dojox.wire.ml.RestHandler”,
    • “XML“: “dojox.wire.ml.XmlHandler”,
    • “JSON“: “dojox.wire.ml.JsonHandler”,
    • “JSON-RPC“: “dojo.rpc.JsonService”





    There is a good presentation on dojox wires attached to the Dojo 1.0 Book.




Dec 10 2007, 08:44:35 PM EST Permalink



Thursday December 06, 2007

Project Zero on You Tube and where can I learn more about Zero?

Jason McGee recently put out 3 videos on YouTube for Project Zero.

Installing Project Zero on Eclipse.

Project Zero - Hello World on Eclipse.

Installing Project Zero CLI (Command Line Interface)

In addition, if you would like to get a hands on tutorial, Steve Ims and I put out a tutorial back in October based on the M1 driver called Introduction to Project Zero: Part 1 - Building RESTful Services with Project Zero.

Part 2 of this series is going to be released in January, probably based on M3.

There are a few other articles out there as well:

Use Active Content Filtering for Project Zero application security

Preserve the security of your Project Zero applications, Part 1: Authentication and authorization

Get started with Project Zero and PHP

Optimize database configuration and dependencies of Project Zero applications

Create a photo album application with Project Zero and REST design principles

Add other scripting languages to your Project Zero applications

The Project Zero website itself has a few movies, samples, and tutorials worth checking out. There is a very comprehensive Developer's Guide as well.




Dec 06 2007, 09:09:50 AM EST Permalink



Monday December 03, 2007

Web 2.0 Programming Model for the Enterprise and their supporting departments

The WebSphere EJB 3 Feature Pack has GA'ed.

You can download it for free and install it on WAS 6.1.

You may also want to use the Web 2.0 FP as a way to expose your EJB 3 based solutions to Web 2.0 platforms like Project Zero. The Web 2.0 FP provides API's for exposing Enterprise Components via JSON, XML, or Atom. In addition, the Ajax Proxy component of the Feature Pack can help Dojo Applications invoke other services without worrying about the cross-domain issue.

The EJB 3 FP + the Web 2.0 FP I believe gives you a nice programming model for exposing some of your Enterprise Components via JSON based services. Below is an example of an Enterprise Application Model. I have seen more and more departmental apps (usually written in something like PHP or Ruby) need to access Enterprise Services. Project Zero makes it easy to invoke HTTP based services and build quick websites with REST Based Services, Dojo, Zero Resource Modeling, Rich client eventing and feed/rest assemblies. The main programming languages for Zero are Groovy and PHP.

Of course with Ajax Patterns, you may have to think about how chatty you want to be between the browser and the server. These are general concerns for most Ajax applications when exposing data.




Dec 03 2007, 11:10:57 AM EST Permalink

Previous month
  May 2008
S M T W T F S
    123
45678910
11121314
15
1617
18192021222324
25262728293031
       
Today

RSS for

RSS for

Favorites

Categories
Ajax (1)
AjaxWorld (1)
EJB3 (1)
Zero (1)

Recent Entries
Persistence in the Enterprise
WebSphere sMash powered by Proje...
IBM IMPACT and Web 2.0
Chat on Dojo Toolkit and WebSphe...
Coding Servlets is cool again
Project Zero Milestone 4 Release...
Dojo MVC: Dojo Store(Model), Do...
RESTful Applications in an SOA
Oracle and BEA: OpenJPA (Kodo) ...
WebSphere Web 2.0 Feature Pack h...
RESTful patterns for partial lis...
Project Zero Milestone 3 release...
Dojox Wire
Project Zero on You Tube and whe...
Web 2.0 Programming Model for th...

Blogs I read

Special offers
Save on Rational testing software
Download trial versions of popular IBM software
Register for the DB2 Information Management Technical Conference

More offers


 
    About IBM Privacy Contact