*/
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (! roundEnv.processingOver() && ! roundEnv.errorRaised()) {
try {
MetadataMirrorFactory factory;
if (Boolean.valueOf(CanonicalModelProperties.getOption(CANONICAL_MODEL_USE_STATIC_FACTORY, CANONICAL_MODEL_USE_STATIC_FACTORY_DEFAULT, processingEnv.getOptions()))) {
if (staticFactory == null) {
// We must remember some state from one round to another.
// In some rounds, the user may only change one class
// meaning we only have one root element from the round.
// If it is a child class to an existing already generated
// parent class we need to know about this class, so the
// factory will also hang onto static projects for each
// persistence unit. Doing this is going to need careful
// cleanup thoughts though. Adding classes ok, but what
// about removing some?
MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
staticFactory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
processingEnv.getMessager().printMessage(Kind.NOTE, "Creating static metadata factory ...");
}
factory = staticFactory;
} else {
if (nonStaticFactory == null) {
MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
nonStaticFactory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
processingEnv.getMessager().printMessage(Kind.NOTE, "Creating non-static metadata factory ...");
}
factory = nonStaticFactory;
}
// Step 1 - The factory is passed around so those who want the
// processing or round env can get it off the factory. This
// saves us from having to pass around multiple objects.
factory.setEnvironments(processingEnv, roundEnv);
// Step 2 - read the persistence xml classes (gives us extra
// classes and mapping files. From them we get transients and
// access). Metadata read from XML causes new accessors to be
// created and override existing ones (causing them to be un-