AspectJ and workflow control

J

jacksu

I am handling a big chunk of old code, its methods only return status
code, (0-ok, 1 - user failure, 2 - system error). then the caller must
check the return code, if no ok, just return to the next caller. I'd
like to use aspectj to simplify it, but not sure how to break the
workflow when method return code is not 0.
This is old code:
int getValue() {
m_Value = somevalue; // m_Value is instance variable
return 0; // 0 == ok, 1== user error; 2 == sys error
}

mainMethod() {
int rc = getValue();
if (rc != 0) { // the following three lines repeat million times,
and ugly.
return rc;
}
rc = getValue2() ;
if (rc != 0) {
return rc;
}
}


I'd like to change it so that in mainMethod:

mainMethod {
getValue();
getValue2();
}

and in aspectj, I check the return value, if it is not 0, return out
of mainMethod..


I know we are suppose to use throw exception to handle this kind of
issue, but our existing code and method just too much, ....

Thanks in advance.

-- Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top