NEW: CustomDeployParser

This commit is contained in:
Jonas Pöhler committed 2021-10-22 15:04:46 +02:00
1 parent 60cf9fa078
commit 50824f1d7f
15 files changed
+287 -6

No files matched your search

@@ -16,6 +16,7 @@ import io.ebean.event.changelog.ChangeLogPrepare;
import io.ebean.event.changelog.ChangeLogRegister;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.plugin.CustomDeployParser;
import io.ebean.util.StringHelper;
import javax.persistence.EnumType;
@@ -389,6 +390,7 @@ public class DatabaseConfig {
private List<BeanQueryAdapter> queryAdapters = new ArrayList<>();
private final List<BulkTableEventListener> bulkTableEventListeners = new ArrayList<>();
private final List<ServerConfigStartup> configStartupListeners = new ArrayList<>();
private final List<CustomDeployParser> customDeployParsers = new ArrayList<>();
/**
* By default inserts are included in the change log.
@@ -2674,6 +2676,17 @@ public class DatabaseConfig {
return configStartupListeners;
}
/**
* Add a CustomDeployParser.
*/
public void addCustomDeployParser(CustomDeployParser customDeployParser) {
customDeployParsers.add(customDeployParser);
}
public List<CustomDeployParser> getCustomDeployParsers() {
return customDeployParsers;
}
/**
* Register all the BeanPersistListener instances.
* <p>
@@ -0,0 +1,15 @@
package io.ebean.plugin;
import io.ebean.config.dbplatform.DatabasePlatform;
/**
* Fired after all beans are parsed. You may implement own parsers to handle custom annotations.
* (See test case for example)
*
* @author Roland Praml, FOCONIS AG
*/
@FunctionalInterface
public interface CustomDeployParser {
void parse(DeployBeanDescriptorMeta descriptor, DatabasePlatform databasePlatform);
}
@@ -0,0 +1,37 @@
package io.ebean.plugin;
import java.util.Collection;
import java.util.List;
/**
* General deployment information. This is used in {@link CustomDeployParser}.
*
* @author Roland Praml, FOCONIS AG
*/
public interface DeployBeanDescriptorMeta {
/**
* Return a collection of all BeanProperty deployment information.
*/
public Collection<? extends DeployBeanPropertyMeta> propertiesAll();
/**
* Get a BeanProperty by its name.
*/
public DeployBeanPropertyMeta getBeanProperty(String secondaryBeanName);
/**
* Return the DeployBeanDescriptorMeta for the given bean class.
*/
public DeployBeanDescriptorMeta getDeployBeanDescriptorMeta(Class<?> propertyType);
/**
* Returns the discriminator column, if any.
* @return
*/
public String getDiscriminatorColumn();
public String getBaseTable();
DeployBeanPropertyMeta idProperty();
}
@@ -0,0 +1,23 @@
package io.ebean.plugin;
public interface DeployBeanPropertyAssocMeta extends DeployBeanPropertyMeta {
/**
* Return the mappedBy deployment attribute.
* <p>
* This is the name of the property in the 'detail' bean that maps back to
* this 'master' bean.
* </p>
*/
String getMappedBy();
/**
* Return the base table for this association.
* <p>
* This has the table name which is used to determine the relationship for
* this association.
* </p>
*/
String getBaseTable();
}
@@ -0,0 +1,38 @@
package io.ebean.plugin;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public interface DeployBeanPropertyMeta {
/**
* Return the name of the property.
*/
String getName();
/**
* The database column name this is mapped to.
*/
String getDbColumn();
/**
* Return the bean Field associated with this property.
*/
Field getField();
/**
* The property is based on a formula.
*/
void setSqlFormula(String sqlSelect, String sqlJoin);
/**
* Return the bean type.
*/
Class<?> getOwningType();
/**
* Return the property type.
*/
Class<?> getPropertyType();
}