All,
I am
trying to upgrade from 1.0.6 of aspectj to 1.1 and I ran into some compile
problems with an inter-type aspect that we created. The aspect code is as
follows:
public
aspect DomainPropertiesAspect { //
define a point cut in the set account method of
IncidentProperties pointcut
IncidentPropertiesPointcut(AccountProperties ap) :
call(public void IncidentProperties.setAccount(AccountProperties))
&& args(ap);
// define a point cut in the set
account method of ContactPartyModel pointcut
contactPartyPointcut(ContactPartyModel cpm) : target(cpm) && call(void
setAccount(AccountProperties)); //
apply the advise to remove all the listeners from an account when the next
account // is retrieved.
before(AccountProperties ap) : IncidentPropertiesPointcut(ap) &&
args(ap) {
ap.removeAllListeners(); }
before(ContactPartyModel cpm) : contactPartyPointcut(cpm)
&& args(cpm) {
cpm.getAccount().removeAllListeners();
} // Add a boolean field to all
instances of DomainProperties public boolean
DomainProperties+.listenersZapped = false;
// Add a method to recursively
remove DomainProperty listeners from any // instance of
DomainProperties
public void
DomainProperties+.removeAllListeners(){ // to
prevent the same object from being called
twice.
if(listenersZapped){
return;
}
try{
this.getAllChangeListeners().clear();
this.listenersZapped = true;
// get all fields defined in
this class. For each field that is an //
instance of DomainProperties call the remove all listeners
method.
Field[] allFields =
this.getClass().getDeclaredFields();
if(allFields.length == 0)
{
return; }
// if
for(int i=0;i<allFields.length;i++)
{
Object theObject =
allFields[i].get(this);
if(theObject ==
null){
return;
}
if(theObject.getClass().isArray()){
for(int a =
0;a<Array.getLength(theObject);a++){
Object arrayObject =
Array.get(theObject,a);
if(theObject instanceof
DomainProperties){
callRemove(theObject);
} else
{
break;
} //
if
} //
for
} else if(theObject instanceof
DomainProperties){
callRemove(theObject);
} else if(theObject instanceof
Collection){
Collection aCollection = (Collection)
theObject;
Iterator iter =
aCollection.iterator();
while(iter.hasNext()){
Object collectionObject =
iter.next();
if(collectionObject instanceof
DomainProperties){
callRemove(collectionObject);
} else
{
break;
} //
if
} //
while
} // if/else
if } //
for } catch(Exception
e){ } //
try } //
method
// utility method to cast from
Object to DomainProperties and call removeAllListeners
private void DomainProperties+.callRemove(Object
theObject){ DomainProperties value
= (DomainProperties) theObject;
value.removeAllListeners(); }
}
The
error I get is the following:
[echo] Compiling all java
classes. [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:26
ap cannot be resolved [iajc]
ap.removeAllListeners(); [iajc]
^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:30
cpm cannot be resolved [iajc]
cpm.getAccount().removeAllListeners(); [iajc]
^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:34
Duplicate field
DomainPropertiesAspec .DomainProperties [iajc]
public boolean DomainProperties+.listenersZapped =
false;
[iajc]
^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:34
Syntax error on token "+", ";", "," e pected
[iajc] public boolean DomainProperties+.listenersZapped =
false;
[iajc]
^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:39
Duplicate field
DomainPropertiesAspec .DomainProperties [iajc]
public void DomainProperties+.removeAllListeners(){
[iajc]
^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:39
Return type for the method is missing [iajc] public
void DomainProperties+.removeAllListeners(){
[iajc]
^^^^^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:41
listenersZapped cannot be resolved [iajc]
if(listenersZapped){ [iajc]
^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:45
The method getAllChangeListeners() is undefined for the type
DomainPropertiesAspect [iajc]
this.getAllChangeListeners().clear();
[iajc]
^^^^^^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:46
listenersZapped cannot be resolved or is not a
field [iajc] this.listenersZapped =
true; [iajc]
^^^^^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:63
The method callRemove(Object) is unde ined for the type
DomainPropertiesAspect [iajc]
callRemove(theObject); [iajc]
^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:69
The method callRemove(Object) is unde ined for the type
DomainPropertiesAspect [iajc]
callRemove(theObject); [iajc]
^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:76
The method callRemove(Object) is unde ined for the type
DomainPropertiesAspect [iajc]
callRemove(collectionObject); [iajc]
^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:89
Duplicate field
DomainPropertiesAspec .DomainProperties [iajc]
private void DomainProperties+.callRemove(Object
theObject){
[iajc]
^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:89
Return type for the method is missing [iajc] private
void DomainProperties+.callRemove(Object theObject){
[iajc]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [iajc]
C:\view$\rdifrang_aspectjUpgrade_NT\discovery\dev\src\com\capitalon \risk\domain\DomainPropertiesAspect.aj:91
The method removeAllListeners() is un efined for the type
DomainProperties [iajc]
value.removeAllListeners();
[iajc]
^^^^^^^^^^^^^^^^^^
Thanks,
Ron
DiFrango
************************************************************************** The information transmitted herewith is sensitive information intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
|