From 2353049c6fe6c824f2ebf344ce5e07bad96e6c4b Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 29 Feb 2016 09:19:44 +1300 Subject: [PATCH] #574 - Refactor - rename .plugin objects; SpiBeanType -> BeanType and SpiServerPlugin -> Plugin --- .../plugin/{SpiBeanType.java => BeanType.java} | 2 +- .../{SpiServerPlugin.java => Plugin.java} | 2 +- .../java/com/avaje/ebean/plugin/SpiServer.java | 6 +++--- .../api/SpiExpressionValidation.java | 6 +++--- .../com/avaje/ebeaninternal/api/SpiQuery.java | 5 ++--- .../changelog/DefaultChangeLogListener.java | 4 ++-- .../server/core/DefaultServer.java | 18 +++++++++--------- .../server/core/InternalConfiguration.java | 12 ++++++------ .../server/deploy/BeanDescriptor.java | 4 ++-- .../server/deploy/BeanDescriptorManager.java | 4 ++-- .../server/querydefn/DefaultOrmQuery.java | 4 ++-- .../com/avaje/ebean/plugin/SpiServerTest.java | 6 +++--- 12 files changed, 36 insertions(+), 37 deletions(-) rename src/main/java/com/avaje/ebean/plugin/{SpiBeanType.java => BeanType.java} (97%) rename src/main/java/com/avaje/ebean/plugin/{SpiServerPlugin.java => Plugin.java} (93%) diff --git a/src/main/java/com/avaje/ebean/plugin/SpiBeanType.java b/src/main/java/com/avaje/ebean/plugin/BeanType.java similarity index 97% rename from src/main/java/com/avaje/ebean/plugin/SpiBeanType.java rename to src/main/java/com/avaje/ebean/plugin/BeanType.java index ac97d7237..ce44337e5 100644 --- a/src/main/java/com/avaje/ebean/plugin/SpiBeanType.java +++ b/src/main/java/com/avaje/ebean/plugin/BeanType.java @@ -9,7 +9,7 @@ import com.avaje.ebean.event.BeanQueryAdapter; /** * Information and methods on BeanDescriptors made available to plugins. */ -public interface SpiBeanType { +public interface BeanType { /** * Return the class type this BeanDescriptor describes. diff --git a/src/main/java/com/avaje/ebean/plugin/SpiServerPlugin.java b/src/main/java/com/avaje/ebean/plugin/Plugin.java similarity index 93% rename from src/main/java/com/avaje/ebean/plugin/SpiServerPlugin.java rename to src/main/java/com/avaje/ebean/plugin/Plugin.java index 8c874f1c6..4fa8fe49d 100644 --- a/src/main/java/com/avaje/ebean/plugin/SpiServerPlugin.java +++ b/src/main/java/com/avaje/ebean/plugin/Plugin.java @@ -3,7 +3,7 @@ package com.avaje.ebean.plugin; /** * A 'plugin' that wants to be configured on startup so it can use features of the EbeanServer itself. */ -public interface SpiServerPlugin { +public interface Plugin { /** * Configure the plugin. diff --git a/src/main/java/com/avaje/ebean/plugin/SpiServer.java b/src/main/java/com/avaje/ebean/plugin/SpiServer.java index 6dd1cd07b..854e96817 100644 --- a/src/main/java/com/avaje/ebean/plugin/SpiServer.java +++ b/src/main/java/com/avaje/ebean/plugin/SpiServer.java @@ -24,16 +24,16 @@ public interface SpiServer extends EbeanServer { /** * Return all the bean types registered on this server instance. */ - List> getBeanTypes(); + List> getBeanTypes(); /** * Return the bean type for a given entity bean class. */ - SpiBeanType getBeanType(Class beanClass); + BeanType getBeanType(Class beanClass); /** * Return the bean types mapped to the given base table. */ - List> getBeanTypes(String baseTableName); + List> getBeanTypes(String baseTableName); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java index fdc1e93cc..3e0b4e0da 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java @@ -1,6 +1,6 @@ package com.avaje.ebeaninternal.api; -import com.avaje.ebean.plugin.SpiBeanType; +import com.avaje.ebean.plugin.BeanType; import java.util.LinkedHashSet; import java.util.Set; @@ -10,11 +10,11 @@ import java.util.Set; */ public class SpiExpressionValidation { - private final SpiBeanType desc; + private final BeanType desc; private final LinkedHashSet unknown = new LinkedHashSet(); - public SpiExpressionValidation(SpiBeanType desc) { + public SpiExpressionValidation(BeanType desc) { this.desc = desc; } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java index 69831f8f3..11067a139 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java @@ -11,7 +11,7 @@ import com.avaje.ebean.bean.ObjectGraphNode; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebean.event.BeanQueryRequest; import com.avaje.ebean.event.readaudit.ReadEvent; -import com.avaje.ebean.plugin.SpiBeanType; +import com.avaje.ebean.plugin.BeanType; import com.avaje.ebeaninternal.server.autotune.ProfilingListener; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; @@ -19,7 +19,6 @@ import com.avaje.ebeaninternal.server.deploy.TableJoin; import com.avaje.ebeaninternal.server.query.CancelableQuery; import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail; -import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties; import java.sql.Timestamp; import java.util.List; @@ -679,6 +678,6 @@ public interface SpiQuery extends Query { /** * Validate the query returning the set of properties with unknown paths. */ - Set validate(SpiBeanType desc); + Set validate(BeanType desc); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java index 1271c5f6c..1e00c9564 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java @@ -5,7 +5,7 @@ import com.avaje.ebean.event.changelog.ChangeLogListener; import com.avaje.ebean.event.changelog.ChangeSet; import com.avaje.ebean.event.changelog.ChangeType; import com.avaje.ebean.plugin.SpiServer; -import com.avaje.ebean.plugin.SpiServerPlugin; +import com.avaje.ebean.plugin.Plugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +20,7 @@ import java.util.Properties; * is fully contained with the transaction information. *

*/ -public class DefaultChangeLogListener implements ChangeLogListener, SpiServerPlugin { +public class DefaultChangeLogListener implements ChangeLogListener, Plugin { /** * The usual application specific logger. diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index eba6fd89d..7b4e9c44c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -18,9 +18,9 @@ import com.avaje.ebean.event.BeanPersistController; import com.avaje.ebean.event.readaudit.ReadAuditLogger; import com.avaje.ebean.event.readaudit.ReadAuditPrepare; import com.avaje.ebean.meta.MetaInfoManager; -import com.avaje.ebean.plugin.SpiBeanType; +import com.avaje.ebean.plugin.BeanType; import com.avaje.ebean.plugin.SpiServer; -import com.avaje.ebean.plugin.SpiServerPlugin; +import com.avaje.ebean.plugin.Plugin; import com.avaje.ebean.text.csv.CsvReader; import com.avaje.ebean.text.json.JsonContext; import com.avaje.ebeaninternal.api.LoadBeanRequest; @@ -138,7 +138,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private final CQueryEngine cqueryEngine; - private final List serverPlugins; + private final List serverPlugins; private final DdlGenerator ddlGenerator; @@ -248,7 +248,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { autoTuneService.startup(); - for (SpiServerPlugin plugin : serverPlugins) { + for (Plugin plugin : serverPlugins) { plugin.configure(this); } } @@ -282,7 +282,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { for (SpiEbeanPlugin plugin : ebeanPlugins) { plugin.execute(online); } - for (SpiServerPlugin plugin : serverPlugins) { + for (Plugin plugin : serverPlugins) { plugin.online(online); } } @@ -408,7 +408,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private void shutdownPlugins() { - for (SpiServerPlugin plugin : serverPlugins) { + for (Plugin plugin : serverPlugins) { try { plugin.shutdown(); } catch (Throwable e) { @@ -2000,14 +2000,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { /** * Return all the SPI BeanTypes. */ - public List> getBeanTypes() { + public List> getBeanTypes() { return getBeanDescriptors(); } /** * Return the SPI bean types mapped to the given table. */ - public List> getBeanTypes(String tableName) { + public List> getBeanTypes(String tableName) { return beanDescriptorManager.getBeanTypes(tableName); } @@ -2015,7 +2015,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * Return the SPI bean types for the given bean class. */ @Override - public SpiBeanType getBeanType(Class beanType) { + public BeanType getBeanType(Class beanType) { return getBeanDescriptor(beanType); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java b/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java index 87dd3109d..8dab12bd1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java @@ -11,7 +11,7 @@ import com.avaje.ebean.event.changelog.ChangeLogPrepare; import com.avaje.ebean.event.changelog.ChangeLogRegister; import com.avaje.ebean.event.readaudit.ReadAuditLogger; import com.avaje.ebean.event.readaudit.ReadAuditPrepare; -import com.avaje.ebean.plugin.SpiServerPlugin; +import com.avaje.ebean.plugin.Plugin; import com.avaje.ebean.text.json.JsonContext; import com.avaje.ebeaninternal.api.SpiBackgroundExecutor; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -103,7 +103,7 @@ public class InternalConfiguration { /** * List of plugins (that ultimately the DefaultServer configures late in construction). */ - private final List plugins = new ArrayList(); + private final List plugins = new ArrayList(); public InternalConfiguration(XmlConfig xmlConfig, ClusterManager clusterManager, ServerCacheManager cacheManager, SpiBackgroundExecutor backgroundExecutor, @@ -156,8 +156,8 @@ public class InternalConfiguration { * later on the DefaultServer for late call to configure(). */ public T plugin(T maybePlugin) { - if (maybePlugin instanceof SpiServerPlugin) { - plugins.add((SpiServerPlugin) maybePlugin); + if (maybePlugin instanceof Plugin) { + plugins.add((Plugin) maybePlugin); } return maybePlugin; } @@ -165,10 +165,10 @@ public class InternalConfiguration { /** * Return the list of plugins we collected during construction. */ - public List getPlugins() { + public List getPlugins() { // find additional plugins via ServiceLoader ... - for (SpiServerPlugin plugin : ServiceLoader.load(SpiServerPlugin.class)) { + for (Plugin plugin : ServiceLoader.load(Plugin.class)) { if (!plugins.contains(plugin)) { plugins.add(plugin); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java index 2e14bd300..27bcc3266 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java @@ -28,7 +28,7 @@ import com.avaje.ebean.event.readaudit.ReadAuditPrepare; import com.avaje.ebean.event.readaudit.ReadEvent; import com.avaje.ebean.meta.MetaBeanInfo; import com.avaje.ebean.meta.MetaQueryPlanStatistic; -import com.avaje.ebean.plugin.SpiBeanType; +import com.avaje.ebean.plugin.BeanType; import com.avaje.ebeaninternal.api.CQueryPlanKey; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; @@ -81,7 +81,7 @@ import java.util.concurrent.ConcurrentHashMap; /** * Describes Beans including their deployment information. */ -public class BeanDescriptor implements MetaBeanInfo, SpiBeanType { +public class BeanDescriptor implements MetaBeanInfo, BeanType { private static final Logger logger = LoggerFactory.getLogger(BeanDescriptor.class); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java index 1ab76e75d..d5722c0ab 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -21,7 +21,7 @@ import com.avaje.ebean.event.changelog.ChangeLogFilter; import com.avaje.ebean.event.changelog.ChangeLogListener; import com.avaje.ebean.event.changelog.ChangeLogPrepare; import com.avaje.ebean.event.changelog.ChangeLogRegister; -import com.avaje.ebean.plugin.SpiBeanType; +import com.avaje.ebean.plugin.BeanType; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.TransactionEventTable; import com.avaje.ebeaninternal.server.core.BootupClasses; @@ -359,7 +359,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { /** * Return the BeanDescriptors mapped to the table. */ - public List> getBeanTypes(String tableName) { + public List> getBeanTypes(String tableName) { return tableToDescMap.get(tableName.toLowerCase()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 258c404c4..45b6f0324 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -9,7 +9,7 @@ import com.avaje.ebean.bean.ObjectGraphOrigin; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebean.event.BeanQueryRequest; import com.avaje.ebean.event.readaudit.ReadEvent; -import com.avaje.ebean.plugin.SpiBeanType; +import com.avaje.ebean.plugin.BeanType; import com.avaje.ebean.text.PathProperties; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.HashQuery; @@ -1438,7 +1438,7 @@ public class DefaultOrmQuery implements SpiQuery { /** * Validate all the expression properties/paths given the bean descriptor. */ - public Set validate(SpiBeanType desc) { + public Set validate(BeanType desc) { SpiExpressionValidation validation = new SpiExpressionValidation(desc); if (whereExpressions != null) { diff --git a/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java b/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java index 21fddfdb8..750d29e57 100644 --- a/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java +++ b/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java @@ -18,7 +18,7 @@ public class SpiServerTest { EbeanServer defaultServer = Ebean.getDefaultServer(); SpiServer pluginApi = defaultServer.getPluginApi(); - SpiBeanType beanType = pluginApi.getBeanType(Customer.class); + BeanType beanType = pluginApi.getBeanType(Customer.class); assertEquals("o_customer", beanType.getBaseTable()); assertNotNull(pluginApi.getDatabasePlatform()); assertNull(beanType.getFindController()); @@ -38,11 +38,11 @@ public class SpiServerTest { assertEquals(42, beanType.getBeanId(customer)); - List> beanTypes = pluginApi.getBeanTypes("o_customer"); + List> beanTypes = pluginApi.getBeanTypes("o_customer"); assertEquals(1, beanTypes.size()); assertSame(beanType, beanTypes.get(0)); - List> allTypes = pluginApi.getBeanTypes(); + List> allTypes = pluginApi.getBeanTypes(); assertTrue(!allTypes.isEmpty()); }