This patch adds "magic" methods to the
AbstractJacnConfigFile base class and the
corresponding bytecode parsing, so that Jacn config
classes can use field and method names in a typesafe,
refactoring-friendly way.
These are the methods:
1. beanName(someBean);
Returns id/name of the specified bean field, in this
case "someBean".
This is a special case of the following method, but is
more explicit
about its intent, and allows more readable
configuration.
2. fieldName(System.out);
Returns name of the referenced field, in this case
"out"
3. methodName(System.currentTimeMillis());
Only for non-void methods, returns name of the called
method, in this case "currentTimeMillis".
4. For void methods:
public void wire() throws Exception {
System.exit(1);
bean.setName(new String[] {lastMethodName()});
}
lastMethodName() returns the name of the last invoked
method, in this case "exit". It can also be used for
non-void methods, if you prefer.
The above examples use static fields and methods.
Instance members should work too.
Note that the semantics of these "magic" methods are
quite different from normal Java semantics, since the
fields and methods are not actually used/called.
These methods actually operate on the references, and
thus return the name of the reference used.
(NB: These methods are currently instance methods, but
might be changed to static methods.)
Field/method names patch
Logged In: YES
user_id=1316552
patch applied in HEAD