mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#394 - ENH: Add plugin API SpiServer, SpiBeanType ... migrate plugins towards using this API, migrate away from direct use of BeanDescriptor etc.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.avaje.ebean.plugin;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class SpiServerTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
EbeanServer defaultServer = Ebean.getDefaultServer();
|
||||
SpiServer pluginApi = defaultServer.getPluginApi();
|
||||
|
||||
SpiBeanType<Customer> beanType = pluginApi.getBeanType(Customer.class);
|
||||
assertEquals("o_customer", beanType.getBaseTable());
|
||||
assertNotNull(pluginApi.getDatabasePlatform());
|
||||
assertNull(beanType.getFindController());
|
||||
assertNotNull(beanType.getPersistController());
|
||||
assertNull(beanType.getPersistListener());
|
||||
assertNull(beanType.getQueryAdapter());
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setId(42);
|
||||
|
||||
assertEquals(42, beanType.getBeanId(customer));
|
||||
|
||||
List<? extends SpiBeanType<?>> beanTypes = pluginApi.getBeanTypes("o_customer");
|
||||
assertEquals(1, beanTypes.size());
|
||||
assertSame(beanType, beanTypes.get(0));
|
||||
|
||||
List<? extends SpiBeanType<?>> allTypes = pluginApi.getBeanTypes();
|
||||
assertTrue(!allTypes.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.avaje.ebean.cache.ServerCacheManager;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.meta.MetaInfoManager;
|
||||
import com.avaje.ebean.plugin.SpiServer;
|
||||
import com.avaje.ebean.text.csv.CsvReader;
|
||||
import com.avaje.ebean.text.json.JsonContext;
|
||||
import com.avaje.ebeaninternal.server.autofetch.AutoFetchManager;
|
||||
@@ -42,6 +43,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiServer getPluginApi() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectQueryOrigins() {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user