Thursday, October 26, 2006

Aspect, oh Aspect...

Not all is peachy at aspectj land.

If you are using hibernate, you are in for a nasty circular dependency surprise once you inject an object/service/dao to your domain object which has a hibernate session factory injected via spring. The session factory object tries to load your entity/domain, which will be intercepted with aspectj and try to configure using your spring configuration, which will again call on session factory....

The solution is including an unsaved-value="null" into your primary class (use xdoclet to make your life easy).

Am currently using load time weaving using the AJDT tool. And its a bit slow on bookah wookah. A much nicer/lightweight approach is to mock your objects for unit testing and use ajc on the final jar build.

Is it domain dependency injection worth the trouble? It depends, but it truly helps make your model more object oriented. Makes mapping meatspace problems easier. You could treat your domain object just like a real object.


devnox
- binding aspects to the jar output...

Tuesday, October 24, 2006

Allergic to annotations?

If you are like me, still allergic to annotations, but would like to inject stuff to your domain objects to keep them from becoming anemic, you cant rely on the spring docs (ATM) to give you a more simple explanation on using AspectJ for domain injection. The problem is magnified if your only use of aspects is for domain injection and nothing else (K.I.S.S. philosophy).

There is another way. You still need to download the usual AspectJ installer and the eclipse AJDT. Then create an aspectj project with a class like the code below.


package com.mobileindie.spring.utils;

import org.springframework.beans.factory.aspectj.AbstractBeanConfigurerAspect;
import org.springframework.beans.factory.wiring.ClassNameBeanWiringInfoResolver;

public aspect DomainObjectConfiguration extends AbstractBeanConfigurerAspect {

public DomainObjectConfiguration() {
setBeanWiringInfoResolver(new ClassNameBeanWiringInfoResolver());
}

// the creation of a new bean (any object in the domain model)
protected pointcut beanCreation(Object beanInstance) :
initialization(com.mobileindie.domains..new(..)) &&
this(beanInstance);

}


Take note of the initialization line, this is where you define which objects you would like to inject your dependencies whenever a new instance is called. This also assumes wire by prototype mode. But the beans are configured just like a normal bean in your spring application context xml.

devnox
- ano nga ba ang aspect kung meron kang aspect?

Apple - MacBook Pro

Core 2 Duo based MacBook Pro just out!

The time has come to drool again. Imagine the boost in productivity with that machine. A core 2 duo compiling my java apps! If the current crop macbook can cut my compile time in half, imagine the speed on this sweet bugger.

Back to G4 reality.

macnox
- dreaming ang drooling...

The Aspects Blog: Tips for using Eclipse effectively

Aha!

I had been using eclipse for quite a while and didn't know that there is such an option such as Fast Views, which really helps reclaim much needed screen state on my 1024x768 resolution challenged bookah wookah.

Just right click on the title bar of the view and select the Fast View. It minimizes your view to a single icon on the bottom (default). But you can place it either on the left or right portion depending on your preference.

dev nox
- hopping around...

Sunday, October 22, 2006

Alapaap

Alapaap

iPhoto Diet 3.1 - VersionTracker

Woot! Just what I need!

Need to swap the larger drive soon tho. With barely 1 gig free disk space, things are slowin. Can't give up both my music and photo collection either. Wonder if those shops are oven on tuesday...