четверг, 30 января 2014 г.

Deploy artifacts from Ivy to Artifactory

After some time struggling with deploying jar files to Apache Archiva I decided to throw it out and replace with Artifactory oss version.
The installation of Artifactory is simple - just drop the war file into Tomcat webapp.

What is important for me is that Artifactory supports deployment of artifacts with Ivy.

Use IBM JRE 7 with Tomcat 7 on Windows 7

If you have running Apache Tomcat on Windows you'll most likely run it on Oracle JVM.
What if you need to run Tomcat on IBM JRE?
You can use Apache Service Manager application to change the settings of JRE.
Open Apache Service Manager, goto Java tab.
There you see "Java Virtual Machine" field. My current value for Oracle JRE is  "C:\jre6\bin\client\jvm.dll".
Change it to file jre\bin\j9vm\jvm.dll.
Press apply.
Start Tomcat.
In your server status you can check that Tomcat is running on IBM JRE.

вторник, 28 января 2014 г.

WebSphere Portal. Run XmlAccess on remote hosts.

If you want to automate the configuration and deployment task on WebSphere Portal, eventually, you will use XmlAccess.

IBM provides ant task called XmlAccess. My goal is to achieve the invokation of configuration tasks on remote machine from my machine. I use Windows 7 and ant 1.8.4 . Remote installations of WebSphere Portal use Linux.

четверг, 16 января 2014 г.

Learning jQuery Deferreds

Started to learn Learning jQuery Deferreds.

The aim of the book is to give the high level overview of the deferreds and their implementation in jQuery particularly.
Here are the benefits of this book:
1) Introduction to promises and deferreds (through nice informal analogies). No special skills are necessary.
2) A lot of practical ready recipes. You can apply them immediately.
3) Exercises and answers.
4) The size of the book is rather small. You can read it fast.

After reading this book you will have another tool in your belt. Deffereds  are not the silver bullet, but sometimes is will allow you to write maintainable javascript code.

Some examples on deferreds application can be found on http://learn.jquery.com/code-organization/deferreds/examples/.

Update 08.07.2014: jQuery contains useful method $.when. Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. In practice you can pass it multiple deffereds and the method will resolve as soon as all the Deferreds resolve, or reject as soon as one of the Deferreds is rejected.

So, if you pass some ajax requests and want to wait when ALL of them will be finished with success or failed you can't use $.when.

I have find out the following solution to this in the net:

$(function(){
 $.whenAll = function( firstParam ) {
     var args = arguments,
         sliceDeferred = [].slice,
         i = 0,
         length = args.length,
         count = length,
         rejected,
         deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise )
             ? firstParam
             : jQuery.Deferred();

     function resolveFunc( i, reject ) {
         return function( value ) {
             rejected = true;
             args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
             if ( !( --count ) ) {
                 // Strange bug in FF4:
                 // Values changed onto the arguments object sometimes end up as undefined values
                 // outside the $.when method. Cloning the object into a fresh array solves the issue
                 var fn = rejected ? deferred.rejectWith : deferred.resolveWith;
                 fn.call(deferred, deferred, sliceDeferred.call( args, 0 ));
             }
         };
     }

     if ( length > 1 ) {
         for( ; i < length; i++ ) {
             if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
                 args[ i ].promise().then( resolveFunc(i), resolveFunc(i, true) );
             } else {
                 --count;
             }
         }
         if ( !count ) {
             deferred.resolveWith( deferred, args );
         }
     } else if ( deferred !== firstParam ) {
         deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
     }
     return deferred.promise();
 };
});

This function allows you to pass multiple deffereds and wait until all of them will be resolved or rejected.

среда, 8 января 2014 г.

Thoughts about AspectJ in Action: Enterprise AOP with Spring Applications

Have finished reading book AspectJ in Action.
This is a rather lengthy book, but it covers AOP in depth. First, AOP theory and AspectJ as a reference implementation. Second, Spring AOP and the use of AspectJ and Spring altogether.

The author writes that AOP is not the silver bullet. As always choose the right tool for the right job.

I would also recommend read Spring documentation on AOP together with this book. Also, the book contains the path to gradually adoption of AOP in your projects.