| Re: [aspectj-users] instrumenting JAXB-generated classes |
Hi,
I am using JAXB to generate Java classes based on the given XML schema. I then try to weave aspects in the generated classes, but I can't seem to capture when fields of JAXB-generated classes get set at runtime.
Below are the two advices which I am trying to weave in the TXmlEntity JAXB-generated class. Note that the first advice fires up just fine and prints out correct XmlIds. However, the second aspect never gets fired. I don't understand how xmlId field in TXmlEntity class gets set if the second (setter) advice never fires up and the first (getter) one prints out correct xmlId values?
after (TXmlEntity var) : get (* TXmlEntity.*) && this(var) && !cflowbelow(adviceexecution())
{
logger.error("Reading: " + var.getXmlId());
}
after (TXmlEntity var) : set (* TXmlEntity.*) && this(var) && !cflowbelow(adviceexecution())
{
logger.error("Setting: " + var.getXmlId());
}
TXmlEntity is just a POJO class shown below.
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0-hudson-3037-ea3
// See <a href="" href="http://java.sun.com/xml/jaxb" target="_blank" >http://java.sun.com/xml/jaxb"> http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2006.05.31 at 10:19:36 AM MDT
//
package com.nextpage.tester.domain.xml.entities;
import javax.xml.bind.annotation.AccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.nextpage.tester.domain.xml.entities.Adapter1;
import com.nextpage.tester.domain.xml.entities.TXmlEntity;
/**
* <p>Java class for TXmlEntity complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="TXmlEntity">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="dbId" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" minOccurs="0"/>
* </sequence>
* <attribute name="client-entity" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* <attribute name="server-entity" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* <attribute name="xmlId" use="required" type="{http://www.w3.org/2001/XMLSchema}ID" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(AccessType.FIELD)
@XmlType(name = "TXmlEntity", propOrder = {
"dbId"
})
public class TXmlEntity {
@XmlElement(namespace = "http://nextpage.com/tester/domain", type = String.class)
@XmlJavaTypeAdapter(Adapter1 .class)
protected Object dbId;
@XmlAttribute(name = "client-entity")
protected Boolean clientEntity;
@XmlAttribute(name = "server-entity")
protected Boolean serverEntity;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlID
protected String xmlId;
/**
* Gets the value of the dbId property.
*
* @return
* possible object is
* {@link String }
*
*/
public Object getDbId() {
return dbId;
}
/**
* Sets the value of the dbId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDbId(Object value) {
this.dbId = value;
}
/**
* Gets the value of the clientEntity property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isClientEntity() {
return clientEntity;
}
/**
* Sets the value of the clientEntity property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setClientEntity(Boolean value) {
this.clientEntity = value;
}
/**
* Gets the value of the serverEntity property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isServerEntity() {
return serverEntity;
}
/**
* Sets the value of the serverEntity property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setServerEntity(Boolean value) {
this.serverEntity = value;
}
/**
* Gets the value of the xmlId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getXmlId() {
return xmlId;
}
/**
* Sets the value of the xmlId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setXmlId(String value) {
this.xmlId = value;
}
}
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users