#2355 - Rename methods in SpiServer with deprecation

This commit is contained in:
rbygrave
2021-09-03 20:17:12 +12:00
parent 25b9b37ac0
commit d072dd52cf
22 changed files with 86 additions and 38 deletions
@@ -16,32 +16,80 @@ public interface SpiServer extends Database {
/**
* Return the DatabaseConfig.
*/
DatabaseConfig getServerConfig();
DatabaseConfig config();
/**
* Migrate to config().
*/
@Deprecated
default DatabaseConfig getServerConfig() {
return config();
}
/**
* Return the DatabasePlatform for this database.
*/
DatabasePlatform getDatabasePlatform();
DatabasePlatform databasePlatform();
/**
* Migrate to config().
*/
@Deprecated
default DatabasePlatform getDatabasePlatform() {
return databasePlatform();
}
/**
* Return all the bean types registered on this server instance.
*/
List<? extends BeanType<?>> getBeanTypes();
List<? extends BeanType<?>> beanTypes();
/**
* Migrate to beanTypes().
*/
@Deprecated
default List<? extends BeanType<?>> getBeanTypes() {
return beanTypes();
}
/**
* Return the bean type for a given entity bean class.
*/
<T> BeanType<T> getBeanType(Class<T> beanClass);
<T> BeanType<T> beanType(Class<T> beanClass);
/**
* Migrate to beanType().
*/
@Deprecated
default <T> BeanType<T> getBeanType(Class<T> beanClass) {
return beanType(beanClass);
}
/**
* Return the bean types mapped to the given base table.
*/
List<? extends BeanType<?>> getBeanTypes(String baseTableName);
List<? extends BeanType<?>> beanTypes(String baseTableName);
/**
* Migrate to beanTypes().
*/
@Deprecated
default List<? extends BeanType<?>> getBeanTypes(String baseTableName) {
return beanTypes(baseTableName);
}
/**
* Return the bean type for a given doc store queueId.
*/
BeanType<?> getBeanTypeForQueueId(String queueId);
BeanType<?> beanTypeForQueueId(String queueId);
/**
* Migrate to beanTypes().
*/
@Deprecated
default BeanType<?> getBeanTypeForQueueId(String queueId) {
return beanTypeForQueueId(queueId);
}
/**
* Return a BeanLoader.
@@ -46,7 +46,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
@Override
public void configure(SpiServer server) {
jsonBuilder = new ChangeJsonBuilder();
Properties properties = server.getServerConfig().getProperties();
Properties properties = server.config().getProperties();
if (properties != null) {
String bufferSize = properties.getProperty("ebean.changeLog.bufferSize");
if (bufferSize != null) {
@@ -35,7 +35,7 @@ final class DefaultBeanLoader {
DefaultBeanLoader(DefaultServer server) {
this.server = server;
this.onIterateUseExtraTxn = server.getDatabasePlatform().useExtraTransactionOnIterateSecondaryQueries();
this.onIterateUseExtraTxn = server.databasePlatform().useExtraTransactionOnIterateSecondaryQueries();
}
void loadMany(LoadManyRequest loadRequest) {
@@ -305,12 +305,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public DatabaseConfig getServerConfig() {
public DatabaseConfig config() {
return config;
}
@Override
public DatabasePlatform getDatabasePlatform() {
public DatabasePlatform databasePlatform() {
return databasePlatform;
}
@@ -2118,7 +2118,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return all the SPI BeanTypes.
*/
@Override
public List<? extends BeanType<?>> getBeanTypes() {
public List<? extends BeanType<?>> beanTypes() {
return getBeanDescriptors();
}
@@ -2126,12 +2126,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return the SPI bean types mapped to the given table.
*/
@Override
public List<? extends BeanType<?>> getBeanTypes(String tableName) {
public List<? extends BeanType<?>> beanTypes(String tableName) {
return beanDescriptorManager.getBeanTypes(tableName);
}
@Override
public BeanType<?> getBeanTypeForQueueId(String queueId) {
public BeanType<?> beanTypeForQueueId(String queueId) {
return getBeanDescriptorByQueueId(queueId);
}
@@ -2144,7 +2144,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return the SPI bean types for the given bean class.
*/
@Override
public <T> BeanType<T> getBeanType(Class<T> beanType) {
public <T> BeanType<T> beanType(Class<T> beanType) {
return getBeanDescriptor(beanType);
}
@@ -28,7 +28,7 @@ public class BeanTypeTest {
private static Database db = DB.getDefault();
private <T> BeanType<T> beanType(Class<T> cls) {
return db.pluginApi().getBeanType(cls);
return db.pluginApi().beanType(cls);
}
@Test
@@ -15,7 +15,7 @@ public class ExpressionPathTest {
static EbeanServer server = Ebean.getDefaultServer();
<T> BeanType<T> beanType(Class<T> cls) {
return server.pluginApi().getBeanType(cls);
return server.pluginApi().beanType(cls);
}
@Test
@@ -15,7 +15,7 @@ public class PropertyTest {
static EbeanServer server = Ebean.getDefaultServer();
<T> BeanType<T> beanType(Class<T> cls) {
return server.pluginApi().getBeanType(cls);
return server.pluginApi().beanType(cls);
}
@Test
@@ -25,9 +25,9 @@ public class SpiServerTest extends BaseTestCase {
EbeanServer defaultServer = Ebean.getDefaultServer();
SpiServer pluginApi = defaultServer.pluginApi();
BeanType<Customer> beanType = pluginApi.getBeanType(Customer.class);
BeanType<Customer> beanType = pluginApi.beanType(Customer.class);
assertEquals("o_customer", beanType.getBaseTable());
assertNotNull(pluginApi.getDatabasePlatform());
assertNotNull(pluginApi.databasePlatform());
assertNull(beanType.getFindController());
assertNotNull(beanType.getPersistController());
assertNull(beanType.getPersistListener());
@@ -45,15 +45,15 @@ public class SpiServerTest extends BaseTestCase {
assertEquals(42, beanType.getBeanId(customer));
List<? extends BeanType<?>> beanTypes = pluginApi.getBeanTypes("o_customer");
List<? extends BeanType<?>> beanTypes = pluginApi.beanTypes("o_customer");
assertEquals(2, beanTypes.size());
BeanType<VwCustomer> vwBeanType = pluginApi.getBeanType(VwCustomer.class);
BeanType<VwCustomer> vwBeanType = pluginApi.beanType(VwCustomer.class);
assertThat(beanTypes.contains(beanType)).isTrue();
assertThat(beanTypes.contains(vwBeanType)).isTrue();
List<? extends BeanType<?>> allTypes = pluginApi.getBeanTypes();
List<? extends BeanType<?>> allTypes = pluginApi.beanTypes();
assertFalse(allTypes.isEmpty());
}
@@ -302,7 +302,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
final String sql = "select description from ebasic_clob where id = ?";
List<SqlRow> rows = new ArrayList<>();
final DataSourceConfig config = ((DefaultServer) DB.getDefault()).getServerConfig().getDataSourceConfig();
final DataSourceConfig config = ((DefaultServer) DB.getDefault()).config().getDataSourceConfig();
try (Connection connection = DriverManager.getConnection(config.getUrl(), config.getUsername(), config.getPassword());
PreparedStatement stmt = connection.prepareStatement(sql)) {
@@ -327,7 +327,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
DB.save(pfc);
List<SqlRow> rows = new ArrayList<>();
final DataSourceConfig config = ((DefaultServer) DB.getDefault()).getServerConfig().getDataSourceConfig();
final DataSourceConfig config = ((DefaultServer) DB.getDefault()).config().getDataSourceConfig();
final String sql = "select content from persistent_file_content where id = ?";
try (Connection connection = DriverManager.getConnection(config.getUrl(), config.getUsername(), config.getPassword());
@@ -22,7 +22,7 @@ public class DocStoreDeleteEventTest {
static EbeanServer server = Ebean.getDefaultServer();
<T> BeanType<T> beanType(Class<T> cls) {
return server.pluginApi().getBeanType(cls);
return server.pluginApi().beanType(cls);
}
BeanType<Order> orderType() {
@@ -20,7 +20,7 @@ public class DocStoreIndexEventTest {
static EbeanServer server = Ebean.getDefaultServer();
<T> BeanType<T> beanType(Class<T> cls) {
return server.pluginApi().getBeanType(cls);
return server.pluginApi().beanType(cls);
}
BeanType<Order> orderType() {
@@ -33,7 +33,7 @@ public class TestDPersonEl {
SpiServer server = Ebean.getDefaultServer().pluginApi();
BeanType<DPerson> descriptor = server.getBeanType(DPerson.class);
BeanType<DPerson> descriptor = server.beanType(DPerson.class);
JsonContext jsonContext = server.json();
@@ -21,7 +21,7 @@ public class TestPathExpression {
public TestPathExpression() {
SpiServer server = Ebean.getDefaultServer().pluginApi();
beanType = server.getBeanType(Customer.class);
beanType = server.beanType(Customer.class);
billingId = beanType.getExpressionPath("billingAddress.id");
line1 = beanType.getExpressionPath("billingAddress.line1");
city = beanType.getExpressionPath("billingAddress.city");
@@ -37,7 +37,7 @@ public class TestDbJson_Jackson extends BaseTestCase {
bean.getValueMap().put(1, "one");
bean.getValueMap().put(2, "two");
ObjectMapper mapper = (ObjectMapper) Ebean.getDefaultServer().pluginApi().getServerConfig().getObjectMapper();
ObjectMapper mapper = (ObjectMapper) Ebean.getDefaultServer().pluginApi().config().getObjectMapper();
String json = mapper.writeValueAsString(bean);
EBasicJsonJackson found = mapper.readValue(json, EBasicJsonJackson.class);
@@ -83,7 +83,7 @@ public class TestDbJson_Jackson extends BaseTestCase {
bean.getValueMap().put(1, new StringJacksonType("A"));
bean.getValueMap().put(2, new LongJacksonType(7l));
ObjectMapper mapper = (ObjectMapper) Ebean.getDefaultServer().pluginApi().getServerConfig().getObjectMapper();
ObjectMapper mapper = (ObjectMapper) Ebean.getDefaultServer().pluginApi().config().getObjectMapper();
String json = mapper.writeValueAsString(bean);
assertThat(json)
@@ -34,7 +34,7 @@ public class TestDbJson_Jackson2 extends BaseTestCase {
bean.getValueMap().put(1, new StringJacksonType("A"));
bean.getValueMap().put(2, new LongJacksonType(7l));
ObjectMapper mapper = (ObjectMapper) Ebean.getDefaultServer().pluginApi().getServerConfig().getObjectMapper();
ObjectMapper mapper = (ObjectMapper) Ebean.getDefaultServer().pluginApi().config().getObjectMapper();
String json = mapper.writeValueAsString(bean);
found = mapper.readValue(json, EBasicJsonJackson2.class);
@@ -20,7 +20,7 @@ public class TestEmbeddedManyToOne extends BaseTestCase {
ResetBasicData.reset();
BeanType<EAddr> embType = Ebean.getDefaultServer().pluginApi().getBeanType(EAddr.class);
BeanType<EAddr> embType = Ebean.getDefaultServer().pluginApi().beanType(EAddr.class);
Ebean.getDefaultServer().cacheManager().clearAll();
@@ -233,7 +233,7 @@ public class TestQueryFindIterate extends BaseTestCase {
ResetBasicData.reset();
SpiServer pluginApi = server().pluginApi();
DataSourcePool dsPool = (DataSourcePool) pluginApi.getServerConfig().getReadOnlyDataSource();
DataSourcePool dsPool = (DataSourcePool) pluginApi.config().getReadOnlyDataSource();
if (dsPool == null) {
dsPool = (DataSourcePool) server().dataSource();
}
@@ -37,7 +37,7 @@ public class TestNativeILikeExpression extends BaseTestCase {
private boolean isExpectNative() {
SpiServer pluginApi = server().pluginApi();
boolean expressionNativeIlike = pluginApi.getServerConfig().isExpressionNativeIlike();
boolean expressionNativeIlike = pluginApi.config().isExpressionNativeIlike();
Platform platform = pluginApi.platform().base();
return expressionNativeIlike && platform == Platform.POSTGRES;
@@ -16,7 +16,7 @@ public class TestTextJsonInvokeLazy extends BaseTestCase {
@Before
public void clearBeanCache() {
server().pluginApi().getBeanType(Customer.class).clearBeanCache();
server().pluginApi().beanType(Customer.class).clearBeanCache();
}
@Test
@@ -216,7 +216,7 @@ public class TestNewTypes extends BaseTestCase {
private void testSetGetPath(SomeNewTypesBean refBean) {
SomeNewTypesBean testBean = new SomeNewTypesBean();
BeanType<SomeNewTypesBean> beanType = DB.getDefault().pluginApi().getBeanType(SomeNewTypesBean.class);
BeanType<SomeNewTypesBean> beanType = DB.getDefault().pluginApi().beanType(SomeNewTypesBean.class);
ExpressionPath localDate = beanType.getExpressionPath("localDate");
ExpressionPath localDateTime = beanType.getExpressionPath("localDateTime");
ExpressionPath offsetDateTime = beanType.getExpressionPath("offsetDateTime");
@@ -33,7 +33,7 @@ public class PlatformDdl_AlterColumnTest {
private final PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform());
{
DatabaseConfig serverConfig = DB.getDefault().pluginApi().getServerConfig();
DatabaseConfig serverConfig = DB.getDefault().pluginApi().config();
sqlServerDdl.configure(serverConfig);
}
@@ -25,7 +25,7 @@ public class PlatformDdl_CreateIndexTest {
private final PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform());
{
DatabaseConfig config = DB.getDefault().pluginApi().getServerConfig();
DatabaseConfig config = DB.getDefault().pluginApi().config();
h2Ddl.configure(config);
pgDdl.configure(config);
mysqlDdl.configure(config);