01: /**
02: * Copyright (C) 2001-2005 France Telecom R&D
03: */package org.objectweb.speedo.generation.enhancer.pc.jdo;
04:
05: import org.objectweb.asm.ClassVisitor;
06: import org.objectweb.asm.ClassWriter;
07: import org.objectweb.speedo.generation.enhancer.pc.PersistentClassEnhancer;
08: import org.objectweb.speedo.lib.Personality;
09: import org.objectweb.speedo.metadata.SpeedoClass;
10: import org.objectweb.util.monolog.api.Logger;
11:
12: import java.util.Map;
13:
14: public class JDOPersistentClassEnhancer extends PersistentClassEnhancer {
15:
16: public JDOPersistentClassEnhancer() {
17: super (Personality.JDO);
18: }
19:
20: protected ClassVisitor getFirstVisitors(ClassWriter cw, Logger log,
21: String classToWrite, Map ctx) {
22: ClassVisitor current = super .getFirstVisitors(cw, log,
23: classToWrite, ctx);
24: final JDOImplRegistrationAdder regAdder = new JDOImplRegistrationAdder(
25: current, classToWrite, log);
26: regAdder.setGenerationAllowed(false);
27: current = regAdder;
28: ctx.put("regAdder", regAdder);
29: return current;
30: }
31:
32: protected ClassVisitor getParentVisitors(ClassVisitor current,
33: Logger log, String classToWrite, SpeedoClass sc, Map ctx) {
34: return super .getParentVisitors(new JDOPersistenceCapableAdder(
35: current, log, sc, scp, Personality.JDO), log,
36: classToWrite, sc, ctx);
37: }
38:
39: protected ClassVisitor getVisitors(ClassVisitor current,
40: Logger log, String classToWrite, SpeedoClass sc, Map ctx) {
41: current = super
42: .getVisitors(current, log, classToWrite, sc, ctx);
43: ((JDOImplRegistrationAdder) ctx.get("regAdder"))
44: .setGenerationAllowed(true);
45: return current;
46: }
47:
48: }
|