Showing posts with label IBM tools. Show all posts
Showing posts with label IBM tools. Show all posts

Friday, January 29, 2010

WebSphere + GWT + Comet

IBM supports Reverse AJAX (AKA Comet) in a form of WebSphere Feature Pack for Web 2.0 for WebSphere Application Server 6.0+. It is shipped by default with the latest fix packs for WAS 6.1 and in all 7.0 versions. Actually this Feature Pack has a lot of nice Web 2.0 features, but at the moment we are interested in Web Messaging Service only.

To install and enable FP you need to follow the documentation, it won't take long. As the result you will get the ability to push data to your client's web browser by publishing it to the special JMS topics. As an alternative, you may also use a more specialized API for doing this, but the Publisher object is stored in the Servlet context, therefore it can be somewhat tricky to access it from an arbitrary part of your application, which is not true with JMS.

I assume that you have successfully installed and tested your Web Messaging, and now want to upgrade your QuoteStreamer sample application to GWT. For example, you have a widget and want its methods to be called when some data arrives from the backend.

It is possible to use JSNI to achieve exactly this goal. The idea is simple: when you need to push some object to the client (for example, out of your Message Driven Bean), you first serialize it using GWT RPC mechanism, then put the resulting string to the appropriate JMS Topic. This string is wrapped to JSON envelope, sent to the client via WFP and unwrapped there via Dojo. Your JavaScript listener should be triggered at this moment. But as we use GWT for all our JavaScript programming, we should implement that listener as JSNI snippet:
private native void initCallbackAndSubscribe (String someParam) /*-{
if ($wnd.dojox) {
$wnd.dojox.cometd.subscribe("/test/" + someParam, this,
function (comet) {
module.@com.test.MyCoolWidget::onReverseAjax(Ljava/lang/String;)(comet.data)
});
}
}-*/;

// This is a normal Java code
public void
onReverseAjax(String msg) throws SerializationException {
SerializationStreamReader r = ((SerializationStreamFactory) svc).createStreamReader(msg);
Object data = r.readObject();
// Do something with that data arrived
}
As you see, the data is deserialized later in your normal Java code called by this listener. That's it. If you have initialized everything right (in your index.jsp or some similar place), this scheme should work fine. Now I will show you how to send data using GWT RPC. It should be simple via RPC.encodeResponseForSuccess method, but there is one problem - it requires SerializationPolicy object for the security reasons. This mechanism restricts serialized objects to the limited set described in *.gwt.rpc files, generated during compilation. Another problem is that there can be several such files. I haven't found a good way to get the SerializationPolicy other than by concatenating these files altogether:
public SerializationPolicy getSerializationPolicy() throws Exception {
String result = "";
for (File file : new File(PATH_TO_YOUR_GENERATED_STUFF).listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".rpc");
}
})) {
result += (FileUtils.readFileToString(file));
}
return SerializationPolicyLoader
.loadFromStream(new ByteArrayInputStream(result
.getBytes("UTF-8")), null);
}

public void publishObject(String topic, Object obj, Method method) throws Exception {
String r = RPC.encodeResponseForSuccess(method, obj, getSerializationPolicy());
publishStringViaJms(topic, r.toString());
}
I forgot to mention that RPC.encodeResponseForSuccess requires a Method instance, but it is used only to extract the return value type, so any method returning the object of the obj.getClass() type will do.

In general, there are some good things about such WebSphere + GWT + Comet integration, the major one is that it uses WFP, which is a pretty powerful Comet server, compared to some custom-built solutions. For example (at least on WAS 7.0), it uses connection multiplexing, nio and all that cool stuff you expect from the modern web server. Also, it naturally integrates into your ESB, so you can use it in your Process Server applications with ease. Some limitations are obvious too, for example it won't work in GWT Hosted Mode with Tomcat. Also it seems to me that this should be implemented somehow simpler, but I was unable to find it. So if you have any other ideas, please give me a clue.

P.S.: Actually, there are some alternatives to this approach. For example you can use gwt-comet-streamhub to enable Reverse AJAX for your GWT applications. But it provides its own Comet server called StreamHub which is definitely not a part of the IBM WebSphere product line :)

P.P.S.: The described method should work with other Comet-enabled J2EE servers like Jetty with minor modifications.

P.P.P.S.: There is left one more issue with security. As for now, it is not really clear for me how to implement role-based security for Comet... I can think of using several update servlets at the same time, and it should allow me to use webapp security. But this issue definitely needs further investigation.

Monday, July 13, 2009

A way to stress-test GUI

What to do if you need to test the performance of your client-server application, which is not on the Web? For example, some kind of Lotus Notes one. The problem is - you can't even execute several Lotus instances on a single machine, so it's quite a tricky task to simulate multiple simultaneous users.

Virtualization is what you can use in this case. There's an example of working stress testing system consisting of Citrix XenApp terminal server running 10 Lotus Notes instances (eating 50 Mb of RAM each), and a load generator running IBM Rational Performance Tester (which is just a very advanced point-and-click thing), which can safely simulate 20 - 40 concurrent users.

Major bottlenecks of this setup are:
  1. RAM on Terminal Server (it's better to use 64 bit solution)
  2. Network bandwidth (at least 1 Gbit Ethernet)
  3. It takes much longer (up to 4 times) to implement and debug such test cases, compared to usual web testing scenarios

Friday, June 5, 2009

Nice short article about IBM Rational Team Concert

Here it is. Seems that RTC is even better than I thought... Among cool things mentioned, there are:
  • Support for Agile methodology out of the box
  • Original approach to SCM, based on the concept of "streams" (which are essentially branches)
  • Advanced build system, automatically collecting all supporting artifacts, such as change sets, fixed defects, etc.
  • A lot of great documentation (like Getting Started with Jazz Source Control)
What I can add from my personal experience, is that the Major Huge Advantage of RTC is that you get all these features integrated altogether out of the box. Installed it today on Windows 2003 Server - it took just 15 minutes (!) to install and configure a complete team collaboration solution. It normally takes few days to configure something like Trac + Subversion + Hudson, and even longer if you'd like to replace Trac with Redmine or Bugzilla on Linux, etc.

Wednesday, February 11, 2009

Tools for XSD-LDM-DDL roundrip development

There are some articles suggesting to use Rational Data Architect for XSD-DDL-LDM roundtrip development. It doesn't work. None of four RDA 7.0.0.5 installations I found in my department is able to import XSD into LDM, as this article suggests. It shows all the necessary dialog boxes, but in the end it does nothing. Just sielently does nothing.

Ok, maybe my schema is all wrong (maybe because it was not created by Business Modeler), still it's very simple and I see no reason why it shouldn't work. Also, it doesn't permit to transform LDM to Physical Data Model, so no DDL generation too... Ok, I guess it should work, but only after reading some Redbook about it.

I decided to give a short try to other ER modeling tools. PowerDesigner allowed me to easily create an LDM (it's called "Conceptual Data Model" there) and transform it to Physical Data Model AKA DDL in few clicks. Altova XML Spy was able to move between XML Schema and DDL seamlessly...

Both tools also provide a lot of useful additional functionality, which I'm going to explore and describe a bit later.

Friday, February 6, 2009

IBM Rational products I didn't know about

Finally I managed to find some time and go through the complete list of IBM Rational products. Here is a list of tools I found interesting and new to me:
  • Rational Host Integration Solution. It looks like an advanced screen-scrambler for existing [ugly] mainframe user interfaces, powered by Rational Host Access Transformation Services. They say it's done "without changing the existing applications". Kinda telnet2ws.
  • Rational Software Analyzer. This static software analyzer looks promising, it supports C++, Java and something else. What I'm interested in is 500+ code review rules for Java. I tried to run it against one of our projects, and it produces some quite impressive results. I mean, something I wouldn't notice in an everyday life. The major drawback is that the installation is >600 Mb, which is just too much for such a simple thing (I would prefer to have it just as a downloadable plugin for my RSA). Furthermore, Rational Software Architect which I use as a main tool already have limited support for such analysis (providing just 200+ rules).
  • Rational Business Developer. After reading this: "EGL (Enterprise Generation Language) compliments the breadth and depth of Java and COBOL technology with a simplified, more abstract development paradigm", I imagined an EGL editor with a radiobutton allowing to choose one of these: "Generate COBOL code", "Generate Java code". No COBOL please. Also they compare it with .NET for a task of retreiving data from IBM mainframe (!). In the end they claim something like "yep, we knew it would happen. Dotnet sucks, it doesn't work with mainframes". In fact, that PDF is the most exciting thing about RBD, and reading it somehow resembles watching Belarussian political news on government TV channel (that's exaclty the situation when one look is worth a hundered words).
Wheeew! To be continued.

JSF in RAD links

Here are just few good links found about how to easily implement JSF in Rational Application Developer. Haven't managed to read it yet, so posting it here just in order not to lose it:

Thursday, January 22, 2009

HTTPUnit in DB2 stored procedure

That was nightmare - running HttpUnit as a stored procedure (don't ask me why) on 8.2 was crashing db2fmp to heap dump. After two days tossing xercesImpl.jar here and there, I decided that was enough and upgraded DB2 to 9.5 Viper-2! Pretty cool XML support and a lot of other large-scale-supporting stuff, but all I need is stable interpretation of my precious stored procedure.

And guess what? It works! More or less... Xerces still unable to find something important inside HttpUnit, but at least no crashes. I guess it's because Xerces uses something internal as a classloader, that's why they have so many problems with shared libraries, etc. So, I've just put that nasty JARs here and there and everywhere (yes, that's not any kind of production system, just a learning application) and now it seems working fine. Well, I'm not sure yet, because it's quite a long-running procedure, but I will know for sure in about ten minutes.

Keeping my fingers crossed + +

UPD: Yes, it works finally. Also, I've found a nice article about HtmlUnit vs HttpUnit. Damn.