Monday, June 4, 2007

BEA WebLogic + Microsoft Popfly = Enterprise Mashups

In my last blog entry, I showed how to build a data driven Mashup using Microsoft Popfly. That exercise was a stepping stone to this blog entry: I will show how WebLogic Portal can surface enterprise data into a Popfly Mashup. In particular, I will show how images located in a WebLogic Portal Content Management repository can be brought into a Popfly project. This demo shows how BEA products can be the key ingredient in your enterprise mashup projects.

NOTE: this blog entry was originally posted June 4th, 2007 on my previous blogging system (dev2dev.bea.com). Comments on the old blog were not transferred.

NOTE: as of 2009, Microsoft has announced that it is terminating support for Popfly.

Building a Mashup with Microsoft Popfly

My last blog entry covered Microsoft Popfly, which is a new mashup building tool from Microsoft. Instead of covering that topic again, I will simply point you to that blog entry if you need some more context.

Reference: previous blog entry

Enter BEA WebLogic Portal and Enterprise Mashups

We have been showing customers how WebLogic Portal can be a key component in your enterprise mashup project. You have hopefully seen how WLP can consume Google Gadgets and other external services to create portal based mashups. WLP can also work in reverse - WLP can produce its portlets onto other, non-portal web pages and mashups like iGoogle. For a quick recap of these capabilities please consult these resources:

  • Webinar: Enterprise Mashups with WebLogic Portal 9.2 - I presented an introduction to the Enterprise Mashup space
  • WebLogic Portlet Publishing - an article discussing how WLP portlets can be produced onto non-portal web pages
  • Add a WLP Portlet to iGoogle - WLP portlets can be exposed as Google Gadgets
  • WebLogic Portal Playground - home of the WLP engineering labs, showing some online demos of WLP+Google Gadgets

In this blog I will demo WLP participating in a Mashup in a different way: it will be a data feed producer for a mashup. Specifically, I will show you how you can surface images from the WLP Content Respository as a JSON data feed. That data feed will in turn be combined in a Popfly mashup using the technique I covered in the previous blog entry.

This helps to show how WebLogic Portal can be the gateway from the enterprise into the consumer mashup space. WLP provides not only a UI framework for producing portlets (as in the iGoogle case), but it is also a virtualization layer for enterprise data services. The diagram below shows this idea. Notice that WLP provides virtualization capabilities for User Profile and Content Management. Once virtualized, WLP can produce profile and content REST services with ease.

mashupwithpopfly

Before I show you how to build it, take a quick look at the WLP+Popfly live demo hosted here. You will be prompted to download the Microsoft Silverlight browser plugin - you must accept to see the demo. Notice how the Photosphere is animating with a set of pictures? Those pictures are being retrieved from the WLP instance at http://wlp.bea.com. Note: the Photosphere Block is computationally expensive, so your CPU usage will spike.

Curious to know how I built it? Follow the steps below to build your own enterprise mashup with WebLogic Portal and Microsoft Popfly!

Step 1: Provisioning the WLP Content Repository

The first thing to do is provision the WLP Content Repository with images. In an enterprise, this will be done by content authors who are using Content Management to store the artifacts that they create on a daily basis. In my case, I loaded a number of pictures I took at the Smithsonian Air and Space Museum in Washington DC into the content repository on wlp.bea.com. I made sure that anonymous users are entitled to see the content, and that all images are in 'Published' status.

popfly_cmtools

Next, I modified the default image content type by adding a multivalued text property called "tag". Then, with each picture, I added a few tag words that describe the picture, like "plane", "propeller", "jet", "warplane", etc. This allows us to quickly query the images by keyword.

Step 2: Building a REST-style service for the WLP Content Repository

In the first blog post, I showed how to build a Popfly Data Block to consume a data service that returns JSON. We are going to use that same pattern in this mashup. To implement this, we need to deploy a REST service for WLP CM.

I turned to dev2dev CodeShare to quickly get my service up and running. There is a download available (that includes sample code for working with the WLP CM repository). I lifted the code from the Search sample to build my service. Also, Tejas Joshi coincidently just blogged about how to create a CM service just a few hours ago. My REST service does the following:

  • Queries the WLP CM system for all images
  • Optionally, the service accepts a tag to search for to scope the result set, like "plane"
  • The result set is composed as a JSON response, including the URL for each image
  • The client can then deserialize the JSON and extract the URLS for the images

The servlet I created for the service is implemented with a .JSP, not a .java file, to allow for easier distribution for others who want to use it. For a quick demo of the service, try the hosted service:

I won't post the code for the JSP here. But I will see about submitting it to CodeShare. (as of 2009, CodeShare is no longer available)

Step 3: Building the Popfly Data Block for Consuming the JSON Service

Now that we have our JSON service, we need the associated data block in Popfly. Since I have already covered how to build a JSON data block in the previous blog entry, I will just show the code and move on. The code snippets below show how I defined the JSON consumer block. I have shared my block on Popfly with the title Air and Space Museum Images, so you should see it in your Block palette.

Block Descriptor

<?xml version="1.0" encoding="utf-8"?>
<block class="AirAndSpaceMuseum">
<providerName>AirAndSpaceMuseum</providerName>
<providerUrl>
http://ajaxmashup.googlepages.com/
</providerUrl>
<providerLogoUrl>
http://wlp.bea.com/images/bea_logo.gif
</providerLogoUrl>
<blockIconUrl>
http://wlp.bea.com/images/bea_logo.gif
</blockIconUrl>
<operations>
<operation name="getImages">
<description>
Images from the Smithsonian Air and Space Museum,
hosted on BEA WebLogic Portal.
</description>
<inputs />
<outputs>
<output isArray="true" type="custom" object="Photo" />
</outputs>
</operation>
</operations>
<objects>
<object name="Photo">
<field name="url" type="imageUrl"
isArray="false" />
<field name="thumbnailUrl" type="thumbnailImageUrl"
isArray="false" />
<field name="id" type="id"
isArray="false" />
<field name="owner" type="userName"
isArray="false" />
<field name="title" type="title"
isArray="false" />
<field name="longitude" type="longitude"
isArray="false" />
<field name="latitude" type="latitude"
isArray="false" />
</object>
</objects>
</block>








Block Code Implementation









// create our namespace for the Block
function AirAndSpaceMuseum() { }

AirAndSpaceMuseum.prototype.getImages = function () {
// set the URL to our JSON service
// hosted in CM on wlp.bea.com
// tagged with the word 'plane' to scope it
url = "http://wlp.bea.com/dvt/"+
"api/content/images.jsp?tag=plane";

// get the JSON list of locations
var resultJSON = environment.getText(url);
var responseObject = eval("(" + resultJSON + ")");

// convert to the Array type we want
var resultsArray = new Array();
for(i=0;i < responseObject.images.image.length; i++) {
resultsArray[i] = new Photo(
responseObject.images.image[i].id,
"Peter Laird",
responseObject.images.image[i].image_name,
responseObject.images.image[i].url,
responseObject.images.image[i].url,
0, 0);
}
return resultsArray;
};

// Define the output payload, must match the XML
function Photo(id, ownerName, title, url, mediumUrl,
lon, lat)
{
this.id = id;
this.owner = ownerName;
this.title = title;
this.url = mediumUrl;
this.thumbnailUrl = url;
this.longitude = lon;
this.latitude = lat;

this.toString = function()
{
return "<table><tr><td><a href='" +
environment.escapeQuotes( this.url ) +
"' target='_blank'><img src='" +
environment.escapeQuotes( this.thumbnailUrl ) +
"' title='" +
environment.escapeQuotes( this.title ) +
", ID: " +
environment.escapeQuotes( this.id ) +
"'/></a></td><tr><td>" +
this.latitude + ", " + this.longitude +
"</td></tr></table>";
}
}








Step 4: Assembling the Mashup








As we saw in the previous blog entry, assembling the mashup is easily done. In this case, we connect the output of our Data Block to the input of the Photosphere Block. Without any coding, the Mashup is complete. Click the following link to see it in action:









WebLogic Portal + Popfly Mashup









This image shows the linkage of the mashup in the Popfly workspace:









popfly_airspacemashup









Taking a Step Back









Now that you have invested yourself in reading this tutorial, I will state without hesitation that this specific mashup has absolutely no value to the enterprise. Are your customers or employees really going to be entertained by images from your enterprise rotating in a Photosphere? Is it going to improve their productivity? Doubtful. To be a true mashup, shouldn't two services (like JSON+Flickr) be combined like in my previous blog? Probably.









So what was the point of building this mashup?!?









My intent was to show how easily it is to surface data from the enterprise into Popfly using WebLogic Portal. Mashups crave easily consumable data - which is exactly what WLP can provide. Finding a useful purpose for that data once it is in the Popfly environment is entirely up to you.









BEA WebLogic Portal + Microsoft Popfly = Enterprise Mashups









Happy mashing!









The simple CM REST service used above was submitted as a code sample here:









Simple CM REST CodeShare Project (as of 2009, CodeShare is no longer available)











Friday, June 1, 2007

Building a Data Driven Mashup with Microsoft Popfly

Regular readers of my blog know that I have been looking at Enterprise Mashups for a while now. Because I am an engineer on the WebLogic Portal product, I have focused on solutions involving that product. However, in this blog I will cover a new product called Popfly from Microsoft that takes an interesting approach to Mashups. I will walk you through how to build a Mashup in Popfly step by step, including the programming of a data service. The Mashup will display a slideshow that contains picture from Flickr of each of the US cities that dev2dev Tech Days visited.

NOTE: this blog entry was originally posted June 1st, 2007 on my previous blogging system (dev2dev.bea.com). Comments on the old blog were not transferred.

The World of Enterprise Mashups

A common question people ask is: "what's a Mashup?". That question is usually followed by another question: "why would I want one in my enterprise?" We are covering this topic in detail with a traveling road show called dev2dev Tech Days. The topic of the seminar is "Mashup the Enterprise", and we answer these questions. In the last few days, you have seen others blogging about that event on dev2dev such as James Bayer and Sean Boiling.

For those unable to attend the seminar, I can offer a few pointers to help get you started.

  • AP News - my favorite sample mashup from the web; it uses an AP News wire feed, Yahoo Geocoding, and Google Maps
  • dev2dev Tech Days 2007 - Mashup the Enterprise - register for a FREE seminar from BEA, available in 45 cities
  • Webinar: Enterprise Mashups with WebLogic Portal 9.2 - I presented an introduction to the Enterprise Mashup space
  • Building a Simple Ajax Powered Google Maps Mashup - a tutorial to build a simple Hello World mashup example
  • Picasa and Google Maps Mashup - James Bayer shows how to use Workshop to build a Picasa Mashup

BEA and Enterprise Mashups

Before we head into Microsoft land, I need to quickly cover how BEA is addressing the Mashup space. BEA offers several approaches to building a Mashup. The first approach is to use a portal product like WebLogic Portal or AquaLogic Portal. A second approach is a new product that will launch soon called AquaLogic Ensemble that specifically targets the Mashup space.

Enter Microsoft Popfly

Popfly is a new offering from Microsoft, currently just out the door as an Alpha release. The best way to get a feel for Popfly is to watch their 15 minute screencast here. Interesting eh? Let me summarize:

  • Popfly is a web based composition engine for assembling components into workable Mashups
  • The tooling intends to allow non-programmers to accomplish this
  • A Popfly Mashup is composed of "Blocks" which can either be data driven or presentation driven

It may seem odd for a BEA employee to cover a Microsoft product. But it all makes sense - Mashups are similar to Service Oriented Architectures (SOA) in that they demand interop between heterogeneous systems. While this particular blog entry will not show BEA WebLogic Portal integrating with Popfly, you should expect that I am heading in that direction. I have been showing how WLP portlets can be surfaced in iGoogle for nearly a year now, and customers have loved to see how WLP interops with other Mashups. Next, in a follow up blog I will show artifacts from WLP Content Management being surfaced in Popfly. Cool! But before we can show WLP+Popfly, I need to first introduce you to Popfly development which is what this blog entry is all about.

Your First Glimpse at a Popfly Mashup

To give you a better idea, see the iframe below which contains the completed demo that I will explain in this blog. I know it doesn't look like much, but I will show how this widget was assembled using 3 Popfly Blocks, including one that I built myself.

PJL revision:
Readers complained that just viewing my blog page required installing the Silverlight plugin because of the iframe. I am therefore just linking it here now. dev2dev Tech Days Popfly Mashup
/PJL revision:

Warning: the Flickr Block is presenting a random picture associated with each city. All apologies if a picture turns up that is not office-friendly. I just saw a picture of a guy in underwear. Yikes.

Here is what it is doing:

  • There already exists a hosted data feed (returning JSON) listing some of the locations that dev2dev Tech Days will visit this year
  • I built a Popfly Data Block that consumes that JSON feed, bringing the list of cities into my Popfly project
  • The dev2dev Data Block is wired into a pre-built Flickr Data Block, so that for each city, a single picture is retrieved using the city name as the image query
  • Finally, the Flickr Data Block is wired into a pre-built Slideshow Presentation Block to display the pictures
popfly_demo_endState

Starting with Popfly

Currently, Popfly is in a managed Alpha release. You must apply for a Popfly account and then wait. I applied last week and just got mine today, so perhaps it will go quickly for you.

Once you get your account, you will be able to start building Mashups. A developers kit is available for download once you have a login. There are a few hundred Blocks already available for your use, with more being added daily. You will also need to download a new browser plugin called Silverlight to use the toolset (you will be prompted). For this demo, you will also need to configure a Flickr API Key, available here.

Step 1: Creating the Data Service Block

As I mentioned previously, I assembled an Ajax powered Google Maps Mashup for my dev2dev article. The demo is hosted at http://ajaxmashup.googlepages.com, and includes a data feed that returns a list of dev2dev Tech Days cities. That data feed returns a format called JSON. If JSON is unfamiliar to you, I will add a link to my article that explains it as soon as it is posted.

To consume the JSON feed in Popfly, I first had to create a new Block project. A Block once again is a Mashup component that either works with data or generates presentation (a single Block can do both, but it shouldn't). My Block will retrieve the JSON, translate it into the appropriate Javascript object, and pass the object to the next Block. From what I have seen, Blocks are written in Javascript, although the intro screencast shows some interesting Visual Basic use cases.

Once a the Block project has been created, you must supply two files:

  • Block descriptor: an XML file that describes your block; this information is used to power the visual wireup capabilities
  • Javascript file: a single Javascript file that includes your Block implementation

The Block descriptor is self explanatory, and well documented. It enumerates the inputs and outputs of your Block so that a non-programmer can wireup the Block into a Mashup. Popfly defines a set of standard data types, including url, userName, title, etc. so that the tool can make intelligent default guesses on how to wire two Blocks together. The following is our Block descriptor. Notice how we have defined a single operation (method) on this Block: getLocations. This operation has no inputs, and its output is an array of Dev2DevLocation objects.

<?xml version="1.0" encoding="utf-8"?>
<block class="Dev2DevDays">
<providerName>Dev2DevDays</providerName>
<providerUrl>
http://ajaxmashup.googlepages.com/
</providerUrl>
<providerLogoUrl>
http://wlp.bea.com/images/bea_logo.gif
</providerLogoUrl>
<blockIconUrl>
http://wlp.bea.com/images/bea_logo.gif
</blockIconUrl>
<operations>
<operation name="getLocations">
<description>
Get the locations of BEA dev2dev Tech Days
2007, "Mashup the Enterprise".
</description>
<inputs />
<outputs>
<output isArray="true" type="custom"
object="Dev2DevLocation" />
</outputs>
</operation>
</operations>
<objects>
<object name="Dev2DevLocation">
<field name="city" type="city" isArray="false"/>
<field name="venue" type="name" isArray="false" />
<field name="address" type="location"
isArray="false"/>
<field name="date" type="date" isArray="false"/>
</object>
</objects>
</block>








The second piece of our Block is the implementation itself. I implemented this in Javascript, and it is quite simple. It is essentially a function call that marshals the JSON feed into an object array that can be used in Popfly.









// create our namespace for the Block
function Dev2DevDays() { }

Dev2DevDays.prototype.getLocations = function () {

// set the URL to our JSON service, hosted on googlepages.com
url = "http://ajaxmashup.googlepages.com/getD2DSites.html";

// get the JSON list of locations
var resultJSON = environment.getText(url);
var responseObject = eval("(" + resultJSON + ")");

// convert to the Array type we want
var resultsArray = new Array();
for(i=0;i < responseObject.locations.location.length; i++) {
resultsArray[i] = new Dev2DevLocation(
responseObject.locations.location[i].city,
responseObject.locations.location[i].location,
responseObject.locations.location[i].address,
responseObject.locations.location[i].date);
}
return resultsArray;
};

// Define the output payload, must match the XML descriptor
function Dev2DevLocation(city, venue, address, date)
{
this.city = city;
this.venue = venue;
this.address = address;
this.date = date;
}
Dev2DevLocation.prototype.toString = function(){
return this.venue+", "+this.address;
};








For those that have implemented Mashups in a browser, you are aware that browser security would normally restrict access to the googlepages.com JSON feed. The Single Origin Policy prevents browsers from crossing multiple network domains. Popfly provides a workaround: it includes a server side proxy accessible via the getText() or getXml() Javascript calls.









Wiring the dev2dev Block to the Flickr Block








The next step is to take the output of the dev2dev Data Block, which is an array of locations, and wire it into the Flickr Block. The Flickr block is provided out of the box by Popfly, so you do not need to build it. The Flickr block needs a query string to retrieve a photo. In this case, I wire that using the "city" field from the JSON feed. This can be done using the visual UI.









popfly_demo_wireup









Wiring the Flickr Block to the Slideshow Block








The last step is to take the output of the Flickr Data Block, which is an array of Photo objects, and wire it into the Slideshow Block. This can be done visually by just connecting the two blocks, as the default wireup will work just fine. Now the Mashup is done, how is easy is that!









Workaround for Popfly Alpha








OK, so for now it's not quite as easy as I said. I found I need one workaround to make this all hang together. The Flickr Block and Slideshow Block have a slight mismatch for their data contract because of the way I built the Mashup. Ordinarily, the Flickr Block is given a single string (city, in our case) to query on. But in our case, we are handing it a list of strings.









In this case, the Flickr Block will output an array of arrays - the outer array having a cell for each city, and the contents of each cell being an array of Photo objects. The Slideshow Block unfortunately expects a single dimension array of Photo objects. Therefore, the visual wireup will not succeed in building a working Mashup. Fortunately, there is a way to manually intervene in the wireup by editing the Javascript code for the wireup.









This is done by selecting the "Advanced Settings" when configuring the source Block, which is the Flickr Block in this case. In this case, the code needs to be altered to create a single concatenated array instead of a multi-dimensional array.









popfly_demo_advancedWireup









The code below is the replacement code to use, which was derived from the default code provided by Popfly. Note the addition of the concat() function to assemble one contiguous array. Also, the call to call_slideshow() has been taken out of the loop and is now called just once using the single array.









data["flickr"] = new Array();
for (var i=0; i<data["d2d Demo Block"].length; i++)
{
try
{
data["flickr"] = data["flickr"].concat(
flickr.getPhotos(data["d2d Demo Block"][i].city, 1));

}
catch (ex)
{
environment.reportErrorInLoop(i, ex);
}
}
call_slideshow();








Testing and Deploying the Mashup









Now that the Mashup is complete, it is a simple matter to put it to the test. By clicking on the Preview button, you can immediately deploy the Mashup and make sure it works.









After, you can navigate to the Project Manager and "Share" your dev2dev Block and Mashup. This allows other users to see your work.









Another Look at this Demo









I have recorded a cheesy movie that shows how the UI works for assembling this Mashup. I made the movie very late at night, so please excuse the tired voiceover. You will need to download the free FLV player to view them.

















The Road Ahead









While cool, this demo may not have clear relevance to BEA customers. But hopefully you can see that we have established the basic working principles for building a data driven Mashup with Popfly. The next step: exposing enterprise data from a WebLogic Portal application into Popfly. Stay tuned!











Saturday, May 12, 2007

Optimized Development for WebLogic Portal Apps

If you would like to improve the speed at which you can develop a WebLogic Portal 9.2 application, this blog is for you. Actually, most of this advice applies to anyone developing medium to large Java web applications, but I will focus on WLP. Across BEA we have been investigating ways to improve what we call iterative development performance. I will share some discoveries that you can put to use today.

NOTE: this blog entry was originally posted May 12th, 2007 on my previous blogging system (dev2dev.bea.com).

The 5 Easy Ways to Improve Development Performance

I will explain the 5 tips we have found to be most useful in improving iterative development performance. Performance here is measured in the time it takes to republish your application. These tips have been measured with WebLogic Portal applications, but any medium to large JEE applications will likely see the same benefits. They are, in order of importance:

  1. Use JRockit as your server JVM!!! It's faster and won't fall over due to PermGen issues like Hotspot.
  2. Use Parallel Garbage Collection with JRockit - up to 40% improvement!
  3. Don't start Autonomy search services unless you need them. This saves 500MB of RAM.
  4. Prefer developing classes in web application scope. Workshop has nice optimizations if you do this.
  5. Avoid bloating your application with unnecesary files. Consider relocating static files to a web server.
Details for each follow below.

BEA JRockit is your Friend

This one is a no-brainer. We have found JRockit to be both faster and more stable than Hotspot for iterative development. When creating a new domain, always select JRockit as the JVM for the server (Hotspot is the default, so you will need to take action). If you have seen out of memory errors after republishing a number of times, switching to JRockit will solve that problem for you. Note: Workshop IDE is configured to run on Hotspot, and that's ok so don't try changing that. Only change the server JVM.

Not sure what you are using? Look at the server console at startup and it will log whether is using Hotspot or JRockit. To configure JRockit for a domain, set JAVA_VENDOR=BEA in the setDomainEnv.(sh,cmd) script in your generated domain.

JRockit is a good choice not only for performance reasons. Henrik Stahl blogged about other features that make JRockit a good choice for development.

Life is Better in a Parallel Universe

Another no-brainer. Do you want up to 40% improvement in the speed of a republish? The Parallel algorithm for garbage collection in JRockit just does a great job with this type of action. Parallel can increase pause times, but overall it maximizes throughput. Maximum throughput sounds like something you want!

To configure parallel GC for your server, you need to alter setDomainEnv.(sh,cmd). Change the line that says MEM_ARGS="-Xms256m -Xmx768m" so that it read MEM_ARGS="-Xgc:parallel -Xms256m -Xmx768m". Then light a cigar, kick your feet up, and call your wife to tell her you expect to finish work early today.

Save the Soul Searching for Production

This one is WLP specific. WLP is preconfigured to start the Autonomy search engine out of the box. This is so full-text search across the content repository will work for you. However, most developers don't need to be doing full-text search in their environments. Autonomy takes up quite a bit of RAM, so it's a good idea to disable it unless you need it.

You will need to edit your DOMAIN_HOME/bin/startWebLogic.cmd/sh. Edit the file so that the default search profile is set to "none", by updating this line:

if "%CONTENT_SEARCH_OPTION%"=="" (
@REM make the following assignment to none, so it won't start Autonomy
set CONTENT_SEARCH_OPTION=none


That's Why We Love Workshop



Workshop is smart, so let it be smart and help you out. When developing an application, you ultimately have 3 scopes in which to deploy your artifacts:




  • System classpath - please avoid this, for a variety of reasons.


  • Application scope - EJBs are deployed in here, and anything else that needs to be shared across multiple web applications.


  • Web Application scope - everything deployed in the web project is in this category.



If you change a class deployed on the system classpath, you need to restart your server. Not a good option at all. If you change a class deployed in the application, Workshop will need to redeploy the application and all web applications. This can be expensive. If you change something in the web application, Workshop can generally just redeploy the web application. That's the fastest way to republish. So if you can, prefer to deploy your development artifacts in a Web Project.



Workshop has more features to help speed you along, so visit this page for more info.



Put that 100MB Movie on YouTube



Size does matter when it comes to deployment. Especially in development, avoid bloating out your application with static files that could be located elsewhere. A modest amount of images, CSS, and Javascript in your application is inevitable, but consider using Content Management or a web server to host large collections of stuff.



Work Continues...



A special thanks goes out to the WLP engineers (Dave, Bret, thanks!) who provided the above information. They have been analyzing iterative development, and continue to look at ways to make WLP application development faster. Also, Josh Lannin blogged about more performance tips for WLP developers in this blog entry. Hopefully you can put these tips to work for you on your current projects!



Thursday, May 3, 2007

BEA dev2dev Tech Days 2007 Kick Off

Like a flashback to the 1933 movie classic, King Kong invaded New York City once again. This time King Kong was not a large ape, but the giant among developers that is Adam Fitzgerald, Director of dev2dev at BEA. He took center stage on the first of many performances of the dev2dev TechDays 2007 conference, coming soon to a city near you. I was a witness to this awe inspiring event, and I am here to report on what I saw.

kong.gif

The kick off sessions for dev2dev TechDays 2007 were held this week in Washington D.C and New York City. In both cities the room was packed for the half day seminar on the topic of Enterprise Mashups - confirming that there is a lot of interest in this space. With Adam Fitzgerald (aka Kong) as the primary presenter, I participated as well as Todd Ruhl from Adobe. Here is a recap of the action.

NOTE: this blog entry was originally posted May 3rd, 2007 on my previous blogging system (dev2dev.bea.com).

Just the Facts - the Agenda

dev2dev TechDays is a FREE half-day event explaining how the concept of a Mashup can be successfully applied to the enterprise. The agenda is as follows:

  • Defining and Explaining the Benefits of an Enterprise Mashup
  • Technologies and Buzzwords in the Mashup Space
  • BEA Mashup Enabled Products
  • Enterprise Mashups and Enterprise Portals
  • BEA Ensemble, the Next Word on Mashing up the Enterprise
  • BEA + Flex - a Killer Platform for Enterprise Mashups

Scaling the Empire State Building - the Demos

Always the daunting adventure that can cause vertigo, during the session we deliver a number of live demos. Fortunately, the demo gods looked favorably down upon us, and the demos went off mostly without a hitch.

The set of demos include:

Your Toolbox for Tackling Large Apes, and Enterprise Mashups

In addition to the demos, we discuss a variety of technologies you will need to understand to be successful in your Mashup implementation. Although we don't deep dive in any one technology, we look at code snippets and provide examples where we can.

  • Client Programming Stack #1: JavaScript, XmlHttpRequest, JSON/XML (aka Ajax)
  • Client Programming Stack #2: Adobe Flex
  • Microformats
  • REST APIs
  • RSS/ATOM
  • Google Gadgets and iGoogle

King Kong Captured on Film

To prove dev2dev TechDays is real and not imaginary, I was able to snap a few pictures of the event:

adam3_sml.jpg
King Kong captured on film, bewildering spectators.

todd2_sml.jpg
Todd Ruhl, defying the demo Gods with his Flex demo.

 

Technorati Tags: ,,,,

Tuesday, February 13, 2007

WebLogic Portal 10.0 Ajax FAQ

Chris Jolley and Bob Bergman did a webinar today on the Ajax capabilities of WebLogic Portal 10.0. We had an enormous audience - we are happy to see the amount of interest in this feature. The replay of the webinar will be up in about a week, and the slides are already posted. This blog entry will cover some of the many questions that were asked during the webinar.

NOTE: this blog entry was originally posted February 14th, 2007 on my previous blogging system (dev2dev.bea.com).

WebLogic Portal 10.0 Ajax Summary

A WebLogic Portal desktop is esssentially an instance of a portal. A desktop has these features:

  • Shell - define the overall layout of the portal, usually with a header and footer.
  • Look and Feel (LaF) - is a set of CSS/JS files that are applied to the portal, which can be dynamically changed at runtime
  • Books - a tabbed set of pages, each desktop has a top level book, and any number of nested books
  • Pages - a container of portlets and nested books
  • Portlets - application windows, built using a variety of technologies including JSP, JSR 168, JSF, JPF, WSRP, etc.

In WebLogic Portal 9.2, portlets can be declaratively specified (just enable a checkbox in Workshop) to render via an XmlHttpRequest (Ajax). What this means is that when a user interacts with the portlet, only that portlet needs to be refreshed. WLP handles all of the link rewriting to make this happen.

In WebLogic Portal 10.0, the entire desktop can be Ajax enabled. The way this works is the first request to the desktop brings back the entire desktop as before. However, whenever a user interacts with a portlet, or if there are events that change the page, only the pieces of the desktop that need updating are refreshed. This is done using an XmlHttpRequest.

For a more detailed explanation, I encourage you to:

  • Download the slides, available NOW on wlp.bea.com
  • Watch the webinar replay, which should be available in about a week on dev2dev Live!

WebLogic Portal 10.0 Ajax FAQ

While Chris was presenting the webinar, we got a massive number of questions typed in from meeting viewers. There were 3 of us from the WLP engineering team hammering away at the answers. It was hard to keep up! We saw a set of questions asked multiple times, so I wanted to blog about those and present the answers in a durable way.

What do these terms mean: XmlHttpRequest, XHR, JSON, Dojo, etc?
These are standard technologies in use today to implement Ajax applications. The XmlHttpRequest (XHR) is an out of band mechanism to issue HTTP requests from Javascript. JSON is an alternative data serialization format to XML. Dojo is a popular Ajax framework. There are plenty of resources on the web that can describe them in more detail.

How does WebLogic Portal 10.0 work with other Ajax frameworks, like Dojo, DWR, GWT, etc
We haven't formally certified WLP with any of these frameworks, but we have found through informal use that client side frameworks like Dojo work well. A hosted demo of WebLogic Portal 9.2 can be on wlp.bea.com, which uses Dojo to implement drag and drop.

What is the N+1 problem?
The WebLogic Portal 10.0 Ajax feature avoids the N+1 problem - but what is it? In this case, we are talking about scalability and the number of requests issued from the browser to the server. 'N' refers to the number of portlets on a page. What you don't want when the user first requests the desktop URL (or refreshes the page) is for the browser to issue a request for every portlet. If there are 10 portlets on the page, that would cause 11 requests to be issued - 1 for the page, and 10 for the portlets (N+1).

WLP 10.0 solves the N+1 problem by returning the entire rendered desktop page on the first request for the desktop (so that's 1, not N+1). Thereafter, when a user interacts with portlets on the page, they will be updated individually without a full page refresh (once again, 1 request per click).

What is IPC?
IPC is inter-portlet communication. This is most often seen in the master-detail use case - when a user clicks on a link in one portlet, it causes a detail view to appear in another portlet. WebLogic Portal has a rich eventing model for server-side IPC, that is fully supported by the Ajax feautre. When the Ajax desktop is enabled, a single XmlHttpRequest will be issued when the user clicks in the portlet. On the server side, the portlet runs through a lifecycle and publishes IPC events. If another portlet wishes to participate, it will also be re-rendered. Both updated portlets then return on the single response. One request, one response, multiple portlets are updated.

When should I use the WebLogic 10.0 Desktop Ajax vs. the 9.2 style portlet Ajax
It depends on what you want. The 9.2 solution is fine grained - it is enabled per portlet. It allows you to enable Ajax only for the portlets that need it. However, the 9.2 approach has a drawback in that it issues a request per Ajax portlet. So if all portlets on the page are individually Ajax enabled, the N+1 problem will appear. In that case, the 10.0 desktop Ajax is the recommended solution.

Do all WLP features (like WSRP, entitlements, threading, caching, IPC) work with WLP 10.0 desktop Ajax?
With only a few minor exceptions, yes. The webinar has a slide that covers a few cases, but overall the Ajax feature encompasses almost all WLP features.

What are the security issues to be aware of with the Ajax feature?
This is a difficult question to answer succinctly because there a number of considerations. But here is a quick list:

  • XmlHttpRequest: the browser will refuse to load an XmlHttpRequest if it is directed to a domain different to the parent page. WLP's feature abides by this rule.
  • HTTPS: the Ajax feature will use the protocol of the parent page, so HTTPS is supported.
  • Entitlements: WLP uses a role based system called entitlements to provide authorization of portlets. The Ajax feature honors entitlements, just like non-Ajax portlets.
  • Identity/cookies: XmlHttpRequests do pass cookies, and so the identity of the user is maintained with the Ajax feature.

What about iframes?
WebLogic Portal supports iframe portlets, and they are still a valid approach. They can consume content from any domain (unlike XHR), and seem similar to XHR in that they bring back content out of band of the primary page request. However, there a number of limitations with iframes, including an inability to participate in IPC.

How does the Back button work with the Ajax feature?
XmlHttpRequests are not hooked into the Back button on browsers. Therefore, the Back button will take the user to the last full page refresh, and will not unwind portlet/page refreshes that used the Ajax feature.

What is Adrenaline, and how does it work with the Ajax feature?
Adrenaline is a technology that allows WLP portlets to be consumed outside the the WLP portal framework. Consuming pages (like a legacy webapp, or your Vista desktop, or your Mac OS X desktop) can render the portlet without the encompassing page. When rendered from a web page, there are two major options for rendering an Adrenaline portlet, covered in this article:

  • iframe: the consuming page uses an iframe to bring the portlet onto the page
  • WLP 9.2 style Ajax: the consuming page can also include an Ajax snippet that in effect uses the WLP 9.2 portlet Ajax capability
Technorati Tags: ,

Tuesday, February 6, 2007

My Favorite Browser Based Development Tools for Internet Explorer

If you aren't using browser based development tools to help with your web application development, it is time to start. With Ajax enabled sites becoming common, View Source is no longer a reliable debugging approach. Also, when looking into issues like Cross Site Scripting (XSS), it is useful to have an embedded HTTP monitor. Firefox users seem to have universally adopted Firebug, but what about Internet Explorer? I personally use two IE tools, IE Developer Toolbar and IE HTTP Analyzer, and this blog explains why they are useful.

NOTE: this blog entry was originally posted February 7th, 2007 on my previous blogging system (dev2dev.bea.com).

My Toolbox

This blog discusses the browser based tools I use for troubleshooting and debugging in the web world. Every developer has their likes and dislikes when it comes to the tools they use. Discussions that compare and contrast different development tools like IDEs often degrade into religious tirades. I am not asserting that my toolbox is necessarily the best - it's simply what I use and what I like. Please add comments to this blog entry if you have found other tools useful. This blog will explain the capabilities that I use with these tools, but I will not cover all of the features.

Both of these tools are client side solutions, and install directly into Internet Explorer. I like the convenience of these features being one click away as I am working with a page. I personally use IE 7, but both of these tools work with IE 6 as well.

IE Developer Toolbar by Microsoft

The IE Developer Toolbar is a free download that snaps into your IE browser. By default, the tool pane is hidden from view. When you want to use the tool, you click on one of the options in the menu toolbar. This tool is great for debugging page content issues.

IE HTTP Analyzer by IEInspector Software LLC

The IE HTTP Analyzer is a modestly priced download that snaps into your IE browser. By default, the tool pane is hidden from view. When you want to use the tool, you click on the small icon to the right of your Page/Tools dropdown. This tool allows you to inspect all aspects of the HTTP protocol as your browser makes requests.

The rest of this blog will describe some use cases for which I have found these tools very helpful.

Use Case 1: Page Inspection - Viewing the Current DOM

Tool of Choice: IE Developer Toolbar

The View Source feature on browsers has no small place in the history of the web. How many people first learned HTML from a book? I, like most other developers, learned HTML using the View Source feature. The rapid expansion of the web back in the 90's was probably helped tremendously by this browser feature.

The View Source feature also used to be a great debugging tool while developing dynamic web projects. JSP not rendering correctly? View Source to the rescue. However, while View Source still has some use, it is no longer a reliable tool to help your development efforts.

Today's websites are far more interactive than the pages of just a few years ago. By way of DHTML and/or Ajax, the HTML that came back from the last page request may not be what the user is currently seeing. As you likely know, parts of the page DOM may get updated as you work within the page. View Source unfortunately is not tuned into this: it will only provide the HTML from the last page load.

Fortunately, the IE Developer Toolbar can help here. It has a View DOM capability that enables the developer to inspect the current state of the DOM for the page. When enabled, the tool will create a new window pane at the bottom of your browser that will show the DOM tree. For each node in the tree, you can inspect its style attributes and text children. As dynamic page capabilities change the DOM, the tree will be updated to reflect the changes. Also, a handy feature is the "Find by Click" capability. This enables you to navigate the tree by clicking anywhere on the page, and the DOM viewer tree will find the element you clicked on.

For example, WebLogic Portal 9.2 can make any portlet Ajax enabled. This prevents clicks within the portlet from causing page refreshes - it will update only the portlet instead. To capture the returned HTML from a portlet update, View Source will do no good. View DOM is the way to go.

Use Case 2: CSS Debug - Why is that text green?

Tool of Choice: IE Developer Toolbar

Cascading Style Sheets (CSS) allow for sophisticated page styles, but come at a price. At times it can be difficult to pinpoint why a style has been applied to an element on the page. Have you ever had trouble determining why a piece of text is a certain color? Or why the font is not what you expected?

WebLogic Portal has a sophisticated Look and Feel capability that allows developers to fine tune the appearance of a portal page. Styles can be associated with page tabs, portlet headers, portlet backgrounds, menus, and many other things. When I work on a Look and Feel, sometimes I need a little help to make things look right.

The tool that I find most useful is once again the IE Developer Toolbar. The DOM inspector allows me to click anywhere in the tree, and look at the applied styles. Then, I can walk the tree upwards until I discover which class the style is coming from. Because this is done in the browser on a rendered page, it is a very accurate and quick approach.

Use Case 3 - Monitoring Requests: Performance and Security Aids

Tool of Choice: IE HTTP Analyzer

Performance

While there are many useful server-side performance tools available, it is still helpful to have a client side tool. There are several scenarios that can be seen on the client:

  • Too many artifact requests - a single page may use hundreds of images/css/js files
  • Big artifacts - images/css files may be abnormally sized
  • Too many XmlHttpRequests - Ajax gone wild can overload the server

The IE HTTP Analyzer when enabled appears in a pane at the bottom of the browser. The top section of the tool shows the list of requests that the browser has issued. With each request, it shows the size in bytes of the response, the response time, and other attributes. With this feature, the above performance concerns can be quickly identified.

Security

Cross Site Scripting (XSS) testing has become an important part of the QA cycle when developing web applications. The typical behavior of a XSS attack is that it will send rogue requests to malicious systems from your browser. I recently wrote a blog entry about a specific XSS vulnerability with PDF files. While I was exploring that issue, it was useful to be able to see those rogue requests being emitted.

I found that the request monitoring feature of IE HTTP Analyzer to be useful in this case. It allowed me to easily see the problem, and validate that the solution that I implemented was sound. For security testers and for developers working on XSS issues, I think this tool is quite helpful.

Use Case 4: HTTP Headers - Viewing and Setting

Tool of Choice: IE HTTP Analyzer

Viewing

Request/response headers are a cornerstone of the HTTP protocol. Every request and response have them, and the information contained within is quite important. Cookies, caching, browser specific HTML, language detection - headers make these features possible. With any feature, sometimes things just don't work correctly.

IE HTTP Analyzer allows you to view the request and response headers for each request. This can be enormously useful when troubleshooting problems related to the headers. This week it helped me diagnose an issue with an incorrect mime type being returned for a resource.

Setting

There are cases when being able to view the headers is not enough. I recently did a blog post about implementing Single Sign On (SSO) with WebLogic Portal. The solution required a server side component to detect a special token in the request headers that contained the user identity. In a production environment, a proxy server would do the job of inserting the header. But while developing the solution, I wanted an easy way to test the implementation.

Once again, the IE HTTP Analyzer gave me a great solution. The tool provides an easy way to clone a request, and then muck with the request headers. In my case, I needed to clone a request to my WLP instance, and then add a test SSO token to the request header. The Request Builder can then rerun the request with the new header, providing a very easy way to test my implementation. See the image below on the tool in action - notice the new header I added (text selected).

Additional Resources

Browser Tools

Online Tools
These are convenient, but only work for testing internet accessible web servers.
Note: these are proxies hosted by 3rd parties, it probably isn't wise to login to your bank through them.

WebLogic Portal

Technorati Tags: ,,,

Thursday, February 1, 2007

Google Analytics informs me that I am fluent in Chinese

It is well known that Google Analytics is a nice technology, but I would have never guessed that it could reveal a useful skill that I didn't know I had - the ability to write fluent chinese. Well, that isn't exactly true, but in effect it has done that. Let me explain...

NOTE: this blog entry was originally posted February 2nd, 2007 on my previous blogging system (dev2dev.bea.com).

wlp.bea.com

In my various writings on dev2dev, I have provided links back to the demo site I work on - wlp.bea.com. That site contains a number of demos running on WebLogic Portal 9.2 related to Enterprise Mashups, Ajax, Drag and Drop, and Google Gadget technology. If you have read my stuff, you will see the code name Adrenaline, which is a part of the WLP Mashup story. The demos for Adrenaline are on wlp.bea.com. The site is a great way for WLP product engineers like myself to demonstrate new WLP features, or new uses of the existing WLP product.

Google Analytics

Many web admins know of Google Analytics - it is a free service provided by the mother ship. It provides a set of great features for answering questions like:

  • How many people have visited my website?
  • How many page views do I have per day?
  • What Google Search terms drive people to my site?
  • Where are my visitors from?

Not only is it useful, it is really easy to implement. You simply need to add a javascript snippet in every page on your site. Google does the rest. About a month ago, I implemented Google Analytics for wlp.bea.com so we can understand better how popular the demo site was, and what people liked looking at. Although we are all technical people who work on it, the business concept of ROI (investment being our time) is important to us.

dev2dev.bea.com.cn

I took a look at my Google Analytics console for wlp.bea.com today and saw something strange. See the image below.

The fact that Adrenaline is not a big hit in Africa and Greenland is not what I found strange. I would like to see more Canadians visiting, but that isn't entirely strange either. What was strange is that a new website became a significant referrer - see the pie chart on the right*. For the first time, dev2dev showed up twice as a top referrer. Why?

Although the UI cuts off the suffix, I could see that the second dev2dev is none other than dev2dev.bea.com.cn. OK, that must be the sister site for dev2dev in China. That made sense, but something didn't. Who is driving traffic to wlp.bea.com from the Chinese dev2dev?

The Skill I Never Knew I Had

Curious, I did a search on dev2dev.bea.com.cn for wlp.bea.com - and it is at this point that I discovered my latent skill. I can write in Chinese! My dev2dev.bea.com article on Adrenaline is also on dev2dev.bea.com.cn, but translated into Chinese. I had a native speaker take a look, and it is no babelfish hack job - it is a real translation. I didn't know I could do that! Well, ok, the real story is we must be employing chinese translators for dev2dev. I didn't know this, but I think it's a great idea.

But what I really like is how Google Analytics revealed an unexpected use of wlp.bea.com. That is what analytics is all about - finding illuminating patterns in the behavior of customers. In this case, Google delivered. Now we have data that can drive a business decision: do we hire a translator for wlp.bea.com?

And to my anonymous translator: thank you!

* the pie chart shows a blurred entry. It appears to be a mail server from Japan, but since I don't why it is showing up, I blurred it. It may somehow identify a BEA customer, and so I played it safe and obscured it.

Additional Resources
Technorati Tags: ,