 |
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
|
 |
| S | M | T | W | T | F | S | | | | | | 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 | 31 | | | | | | | | | | Today |
|