|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectJ2OSynchroniser
public class J2OSynchroniser
This is the program which manipulates the annotated compiled class files to insert the code for synchronising Java and OWL.
An example is: The class
@J2OWLClass(name = "Person", OWLSuperClasses = "LivingThing") class Person { boolean male; public TestPerson(boolean male) {this.male = male;} @J2OWLProperty(setter = "setGender", required=true) public boolean isMale(){return male;} public void setGender(boolean male){ this.male = male;}}would be changed to
@J2OWLClass(name = "Person", OWLSuperClasses = "LivingThing") class Person { boolean male; public static J2OIndividualManager j2OWLIndividualManager; public boolean j2OWLNoSynchronizationByObject; private static Method J2OWL_getter_isMale = J2OSynchroniser.getMethod(TestPackage/TestPerson, "isMale"); J2OIndividualManager J2OSynchronisationActive() { Java2OWLFlags |= 6; return (Java2OWLFlags & 1) == 0 ? null : j2OWLIndividualManager;} public TestPerson(boolean male) {this.male = male;} @J2OWLProperty(setter = "setGender", required=true) public boolean isMale(){return male;} public void setGender(boolean male){ if(J2OSynchronisationActive() != null) J2OSynchronisationActive().exchangePropertyValue(this, J2OWL_getter_isMale, Boolean.valueOf(isMale()), Boolean.valueOf(male)); this.male = male;}}
The variables j2OWLIndividualManager and Java2OWLFlags are injected in each class even in subclasses. This means, if A is a subclass of B then A has these two variables twice, its own pair and the inherited pair. The method J2OSynchronisationActive() accesses the pair belonging to the object's actual class. Therefore one can, for example, activate synchronisation for a superclass and deactivate it for a subclass.
Field Summary | |
---|---|
String |
dump
For test purposes: a filename where the transformed class is to be dumped. |
Constructor Summary | |
---|---|
J2OSynchroniser()
creates a new J2OSynchroniser |
Method Summary | |
---|---|
static Method |
getMethod(Class jcl,
String name)
returns jcl's method with the given name. |
static void |
main(String[] args)
|
byte[] |
transform(ClassLoader loader,
String className,
Class redefiningClass,
ProtectionDomain domain,
byte[] bytes)
This method is called by the class loader. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public String dump
Constructor Detail |
---|
public J2OSynchroniser()
Method Detail |
---|
public byte[] transform(ClassLoader loader, String className, Class redefiningClass, ProtectionDomain domain, byte[] bytes) throws IllegalClassFormatException
transform
in interface ClassFileTransformer
IllegalClassFormatException
public static Method getMethod(Class jcl, String name)
public static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |