io.ebeaninternal.server.deploy.parse.ReadAnnotations Maven / Gradle / Ivy
package io.ebeaninternal.server.deploy.parse;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.server.deploy.BeanDescriptorManager;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory;
/**
* Read the deployment annotations for the bean.
*/
public final class ReadAnnotations {
private final ReadAnnotationConfig readConfig;
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder.Settings config) {
this.readConfig = new ReadAnnotationConfig(generatedPropFactory, asOfViewSuffix, versionsBetweenSuffix, config);
}
/**
* Read the initial non-relationship annotations included Id and EmbeddedId.
*
* We then have enough to create BeanTables which are used in readAssociations
* to resolve the relationships etc.
*
*/
public void readInitial(DeployBeanInfo> info) {
try {
new AnnotationClass(info, readConfig).parse();
new AnnotationFields(info, readConfig).parse();
} catch (RuntimeException e) {
throw new RuntimeException("Error reading annotations for " + info, e);
}
}
/**
* Read and process the associated relationship annotations.
*
* These can only be processed after the BeanTables have been created
*
*
* This uses the factory as a call back to get the BeanTable for a given
* associated bean.
*
*/
public void readAssociations(DeployBeanInfo> info, BeanDescriptorManager factory) {
try {
new AnnotationAssocOnes(info, readConfig, factory).parse();
new AnnotationAssocManys(info, readConfig, factory).parse();
// read the Sql annotations last because they may be
// dependent on field level annotations
new AnnotationSql(info, readConfig).parse();
new AnnotationClass(info, readConfig).parseAttributeOverride();
info.getDescriptor().postAnnotations();
} catch (RuntimeException e) {
throw new RuntimeException("Error reading annotations for " + info, e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy