Andrew Powell

Into The Mind of A Solutions Architect

Andrew Powell

Entries Tagged as LiveCycle ES

ColdFusion: The Original ESB

December 10, 2009 · 1 Comment

A few months ago, I started a project to make a framework for ColdFusion to enable its functionality as an Enterprise Service Bus (ESB).  I kept running into roadblocks in my mind as how to structure things, but I realized something.  Everything I was trying to do to make ColdFusion an ESB was simply hindering tasks that were already easy to do.  ColdFusion, out of the box, can function as an ESB.  

It wasn't always this way, but over the years, with the addition of things like JMS gateways, .NET integration, HTTP, and FTP integration; it's easy to create workflows that receive data from an input, processes it, and sends it to another destination.  ColdFusion 9 enables this even more so with the addition of Sharepoint integration. 

Why worry about installing something like Mule?  ColdFusion already does everything you need it to do out of the box.  ESBs are the next generation in integration.  ColdFusion just makes it easier and faster than traditional Java or .NET based solutions. 

1 CommentTags: Adobe · ColdFusion · Flex · FlexServerLib · Java · LiveCycle ES · MOM · Universal Mind · WebNext · XML

Flash Camp Atlanta Is Next Week

August 17, 2009 · No Comments

 

We're just over a week away from Flash Camp Atlanta and tickets are almost sold out.  If you're interested in going, but have been on the fence, all the sessions are posted here.  There are cheap flights and hotels available still.   Sign up today at www.flashcampatlanta.com and ensure your seat before they're all gone!

No CommentsTags: LiveCycle ES · Java · FlexCamp · ColdFusion · Flex · Conferences · BlazeDS · Adobe · Universal Mind

Flash Camp Atlanta 2009 Early Bird Ending

July 29, 2009 · No Comments

The early bird pricing for Flash Camp Atlanta ends in less than 24 hours!  Tickets are on pace to sell out soon, so if you don't want to pay more later, go sign up now.  The early bird pricing is dirt cheap, only $40 for the main session and $15 for the introductory session ( an intro to Flash, Flex, and AIR ). 

No CommentsTags: Adobe · AIR · BlazeDS · ColdFusion · Conferences · Flex · FlexCamp · FlexServerLib · Java · LiveCycle ES · Universal Mind · User Experience · XML

Flash Camp Atlanta 2009

July 09, 2009 · No Comments

Flash Camp is coming to the ATL! 

Flash Camp Atlanta is a full-day event featuring some top industry experts on the Adobe Flash Platform from both inside and outside Adobe. Come advance your Flex and Flash skills, meet members of the Adobe team and network with local companies and fellow developers. Sessions will be geared towards developers and designers with little to advanced level of experience with Flex and/or ActionScript. There will be plenty of giveaways, raffles and swag (and lunch).

In addition to a great Main Session (9am-5pm) there will also be a special Introductory Session (8-9am) for developers who are new to the Adobe Flash Platform.  This special session only costs an additional $15 (until July 30th and $25 thereafter).  This session will get these developers up to speed aspects of the Flash Platform like Adobe Flex, AIR, and Flash Builder.

Register Today

When:  August 28th 2009, 8:00AM - 5:00PM

Where:  Georgia World Congress Center - Room B405

Confirmed Speakers:

Greg Wilson

David Tucker

Christian Saylor

Carl Smith

Douglas Knudsen

Ben Stucki

Jesse Warden

It's going to be a day of great content and fun!  Go and sign up today so you don't miss out on your seat!

Register Today

Events

No CommentsTags: Adobe · AIR · BlazeDS · ColdFusion · Flex · FlexCamp · LiveCycle ES · Speaking · Universal Mind

What Is BlazeDS?

May 05, 2009 · 2 Comments

A lot of people think that BlazeDS (and LCDS, for that matter) is a server.  They think it's something that you can deploy, like ColdFusion, and write apps on it.  Not quite, the case, but not too far off either.

BlazeDS is not a server.

Let's say that again, so you understand it.  BlazeDS is not a server.

BlazeDS is a set of servlets and listeners that you can add to your J2EE web application to access your service layer via the AMF protocol.  You don't deploy BlazeDS on its own unless you want to do purely messaging.  90% of deployments are done as part of a larger web project.  BlazeDS is simply another tool that you can use to expose your services to AMF clients (not just Flex).  

Further proof that BlazeDS exists as part of the J2EE ecosystem came late last year when SpringSource announced Spring/BlazeDS Integration.  This virtually removed the MessageBrokerServlet from the equation, routing messages through Spring's MVC architecture instead.  BlazeDS, the guts of it at least, was still responsible for the leg work in processing the AMF requests, but the easy integration into the Spring Framework really made it apparent that BlazeDS is not a server.

Lastly, BlazeDS is easy to incorporate into ColdFusion.  ColdFusion is, at it's roots, a J2EE web app.  BlazeDS is just another piece you can integrate into the web app to enable access to Java and CFC services via AMF.

Any questions?

2 CommentsTags: Adobe · AIR · BlazeDS · ColdFusion · Flex · Hibernate · Java · JMS · JSP · LiveCycle ES · MOM · Silverlight · Spring · Universal Mind

Bypassing Hibernate's Lazy Loading in BlazeDS with Spring

December 09, 2008 · 10 Comments

The Problem:

When using Hibernate as your persistence layer, it allows you to create lazy collections. This is nice because lazy collections can speed up your application, and in theory, you only access the data you want to access. Simple enough. The problem lies however in talking to Flex applications, specifically via BlazeDS or LiveCycle DS. What happens is the fault of the serializers. When you make a request, via mx:RemoteObject, to the server, and you are accessing a lazy collection, when the serializer attempts to turn the data from Java to AMF, it touches everything. This "unwelcome touching" by the serializer, in turn, triggers all of your lazy loading to fire, therefore rendering your lazy collections and the effort to set them up, useless. So, with that in mind, how do we pass back only the data we want to pass back?

The Solution

Let's consider the following value objects:

package com.universalmind.samples.lazyloadIssue;
   import org.hibernate.annotations.Entity;
   import java.util.UUID;
   /**
    * Copyright (c) 2008 Universal Mind Inc.
    * Created by IntelliJ IDEA.
    * Created By: Andrew Powell
    * Date: Dec 9, 2008
    * Time: 11:44:37 AM
    */
   @Entity
   public class Item implements AMFSerializable {
    private UUID id;
    private String sku;
    private String name;
    private String description;
    public Item() {
    }
    public UUID getId() {
    return id;
    }
    public void setId(UUID id) {
    this.id = id;
    }
    public String getSku() {
    return sku;
    }
    public void setSku(String sku) {
    this.sku = sku;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getDescription() {
    return description;
    }
    public void setDescription(String description) {
    this.description = description;
    }
    public Item cloneForAMF() {
    Item item = new Item();
    item.setDescription(description);
    item.setId(id);
    item.setName(name);
    item.setSku(sku);
    return item;
    }
   }

package com.universalmind.samples.lazyloadIssue;
   import org.hibernate.annotations.Table;
   import javax.persistence.Entity;
   import javax.persistence.ManyToMany;
   import javax.persistence.FetchType;
   import java.util.UUID;
   import java.util.Date;
   import java.util.ArrayList;
   /**
    * Copyright (c) 2008 Universal Mind Inc.
    * Created by IntelliJ IDEA.
    * Created By: Andrew Powell
    * Date: Dec 9, 2008
    * Time: 11:43:09 AM
    */
   @Entity
   public class Order implements AMFSerializable {
    private UUID id;
    private Date date;
    private ArrayList items;
    public Order() {
    }
    public UUID getId() {
    return id;
    }
    public void setId(UUID id) {
    this.id = id;
    }
    public Date getDate() {
    return date;
    }
    public void setDate(Date date) {
    this.date = date;
    }
    @ManyToMany(targetEntity=Item.class,fetch= FetchType.LAZY)
    public ArrayList getItems() {
    return items;
    }
    public void setItems(ArrayList items) {
    this.items = items;
    }
    public Order cloneForAMF() {
    Order clone = new Order();
    clone.setDate(date);
    clone.setId(id);
    return clone;
    }
   }

These two value objects are related in the sense that there is a many-to-many relationship between Order and Item. An Order can have many Item instances and a Item can belong to many Order instances. There is another piece in there as well. Both of these implement the AMFSerializable interface, listed below:

package com.universalmind.samples.lazyloadIssue;
   import java.io.Serializable;
   /**
    * Copyright (c) 2008 Universal Mind Inc.
    * Created by IntelliJ IDEA.
    * Created By: Andrew Powell
    * Date: Dec 9, 2008
    * Time: 12:16:37 PM
    */
   public interface AMFSerializable extends Serializable {
    public Object cloneForAMF();
   }

This interface extends java.io.Serializable which is needed for AMF serialization. It also adds one method: cloneForAMF(). This method allows you to create a copy of the object that is free from Hibernate proxies and only contains the data that you want to send back to Flex. The next trick, however, is invoking that method once your business logic completes.

Let's say we have a simple, Hibernate and Spring enabled, data access object:

package com.universalmind.samples.lazyloadIssue;
   import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
   import org.hibernate.criterion.DetachedCriteria;
   import org.hibernate.criterion.Restrictions;
   import java.util.*;
   /**
    * Copyright (c) 2008 Universal Mind Inc.
    * Created by IntelliJ IDEA.
    * Created By: Andrew Powell
    * Date: Dec 9, 2008
    * Time: 11:42:55 AM
    */
   public class OrderDAO extends HibernateDaoSupport {

    @SuppressWarnings("unchecked")
    public ArrayList getTodaysOrders(Date yesterday, Date tomorrow){
    DetachedCriteria criteria = DetachedCriteria.forClass(Order.class);
    criteria.add(Restrictions.gt("date",yesterday));
    criteria.add(Restrictions.lt("date",tomorrow));
    return (ArrayList) this.getHibernateTemplate().findByCriteria(criteria);
    }
   }

The method we're going to call, getTodaysOrders is going to return an ArrayList, given a set of criteria. Pretty simple. Between the time this method executes and the time it hits the serializer, within the RemoteObject call, we want to prep our data with the cloneForAMF() method that we created on our value objects. Since we're using Spring, we can leverage the power of Aspect-Oriented Programming to accomplish this task. In order to accomplish this with AOP, we need to implement advice both before and after the method in question. Implementing this "around advice" is easy using the MethodInterceptor class, as shown below:

package com.universalmind.samples.lazyloadIssue;
   import org.aopalliance.intercept.MethodInterceptor;
   import org.aopalliance.intercept.MethodInvocation;
   import java.util.ArrayList;
   /**
    * Copyright (c) 2008 Universal Mind Inc.
    * Created by IntelliJ IDEA.
    * Created By: Andrew Powell
    * Date: Dec 9, 2008
    * Time: 12:12:37 PM
    */
   public class PreSerializationInterceptor implements MethodInterceptor {
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    if(methodInvocation.getMethod().getName() == "getTodaysOrders"){
    ArrayList persistentCollection = (ArrayList) methodInvocation.proceed();
    ArrayList serializedCollection = new ArrayList();
    for(Order order : persistentCollection){
    if(order instanceof AMFSerializable) serializedCollection.add(order.cloneForAMF()); }
    return serializedCollection;
    }
    else{
    return methodInvocation.proceed();
    }
    }
   }

This code will first make sure we're executing the method we want to clean the results of, execute the method using methodInvocation.proceed(), and then we will do some "post-processing" of the method results to only return what we want to be serialized to Flex. We must also create a new collection, as the collection that is returned is aware that it's a Hibernate lazy-collection (via proxy). After we create the new collection, if the members of the persistent collection implement the AMFSerializable interface, we will call the cloneForAMF() method and add the resulting object to our new non-persistent collection. This collection then gets returned and serialized by the AMF serializer. There are now lazy-loaded collections triggered because the collection we are passing back to the serializer is blissfully unaware of Hibernate or any lazy-collection.

The drawback to this method is that every time you want to get an object's collection, you must make another round-trip to the server. These trips can be less data passed across, but be aware that this must happen if you want to retrieve the lazy collections. Those calls must also be via another method you create, you cannot just load the same objects up and expect the collections to come back by themselves. That defeats the purpose.

I must admit that this does feel like a bit of a hack instead of a more elegant solution like dpHibernate, but sometimes you don't want to mess around with custom adapters on the Java side and special configs on the Flex side. This allows you to implement Hibernate and bypass lazy loading with minimal impact to your value objects and retrieval methods on the AS side. So, in that sense, I think this solution has its place and can be valuable to you on your Flex / Java projects.

10 CommentsTags: BlazeDS · Flex · Hibernate · Java · LiveCycle ES · Spring · Universal Mind

My 360|Flex Session Is Online

October 23, 2008 · 1 Comment

Thanks to Ted for getting these posted up.  I had almost forgotten about these:

1 CommentTags: Adobe · BlazeDS · Conferences · Flex · Hibernate · Java · LiveCycle ES · MOM · Speaking · Spring · Universal Mind · WebNext

360|Flex San Jose 2008: My Speaker Reviews For You To Read

September 17, 2008 · 7 Comments

I did this last time around, so here it is again, my session survey results.  Did people love me?  Did they hate me?  Did they care?  Well, the ones who cared enough to fill out the session survey did enough to fill out the survey.  Either way, enough rambling, here's the link:

Survey Results

7 CommentsTags: Adobe · AIR · BlazeDS · Conferences · Flex · Hibernate · Java · JMS · LiveCycle ES · MOM · Spring · Universal Mind · WebNext · XML

360|Flex Session Preview: Implementing BlazeDS

August 17, 2008 · 2 Comments

Excited about BlazeDS, but not really sure what it means for you?  Are you a Java developer coming to Flex who wants to learn how to connect your services to Flex?  Want to see a new spin on the ubiquitous chat application?  Come to my 360|Flex session, Implementing BlazeDS, and you'll get all that and more.  This session is the first of a three-part "Flex/Java Track" that you will get at 360|Flex.  Major topics covered will be:  Remote Objects, Messaging, Integrating Spring & Hibernate, & Binary Remoting without BlazeDS.  Stop on by Monday at 4:00PM if you're interested in learning more.

2 CommentsTags: Adobe · BlazeDS · Conferences · Flex · General · Hessian · Hibernate · JMS · LiveCycle ES · Speaking · Spring · Universal Mind

IntelliJ IDEA 7.0.4 Available

August 12, 2008 · 1 Comment

IntelliJ IDEA, the most kick-ass Java IDE available, is now out and better than ever.  The main thing about 7.0.4 is that it now has great support for Ruby/JRuby.  This means that, essentially, IntelliJ is a viable Ruby IDE now, as well as a Java IDE.  It's also got some support for Flex, but it's not quite ready for prime time yet, IMO.

 

What's new in 7.0.4

1 CommentTags: Adobe · ANT · BlazeDS · Flex · General · Hibernate · LiveCycle ES · Ruby on Rails · Spring · Universal Mind