[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] @DeclareMixin and access to mixxed in object properties
|
Hallo,
I'm using annotations to create aspects and I would like to make same thing as :
public aspect Item2Xml {
public void Item.preXmlMarschalCheck() {
if (this.getXmlDescription() == null)
throw new DARequiredException(DAExceptionType.REQUIRED_ERROR, new ObjectProperties(Item.class.getName(), "xmlDescription"));
}
}
So I add method to the class Item where I access the local method getXmlDescription() ......
But using the @DeclareMixin the only way how to make this is (as I know):
@Aspect
public class Item2Xml {
public interface WithProperties2Xml {
void preXmlMarschalCheck();
}
public static class WithProperties2XmlImpl implements WithProperties2Xml {
private Item item;
protected WithProperties2XmlImpl(Item item) {
super();
this.item = item;
}
public void preXmlMarschalCheck() {
if (item.getXmlDescription() == null) throw new DARequiredException(REQUIRED_ERROR, new ObjectProperties(Item.class.getName(), "xmlDescription"));
}
}
@DeclareMixin("cz.svt.dao.hibernate.Item")
public static WithProperties2Xml createWithProperties2Xml(Item item) {
return new WithProperties2XmlImpl(item);
}
}
This looks more complicated than it should be ... is there a better way (eg. make WithProperties2XmlImpl extending the Item)?
Thanks for help
Jirka