From 61ecf16978e1279e9dc4eb3a3ac98df92664b48f Mon Sep 17 00:00:00 2001 From: rbygrave Date: Mon, 11 May 2015 23:59:41 +1200 Subject: [PATCH] No effective change - reformat --- .../server/core/BootupClasses.java | 576 +++++++++--------- 1 file changed, 288 insertions(+), 288 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/BootupClasses.java b/src/main/java/com/avaje/ebeaninternal/server/core/BootupClasses.java index 0f03a4679..3b4af8ed9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/BootupClasses.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/BootupClasses.java @@ -30,339 +30,339 @@ import com.avaje.ebeaninternal.server.util.ClassPathSearchMatcher; */ public class BootupClasses implements ClassPathSearchMatcher { - private static final Logger logger = LoggerFactory.getLogger(BootupClasses.class); + private static final Logger logger = LoggerFactory.getLogger(BootupClasses.class); - private ArrayList> embeddableList = new ArrayList>(); + private ArrayList> embeddableList = new ArrayList>(); - private ArrayList> entityList = new ArrayList>(); + private ArrayList> entityList = new ArrayList>(); - private ArrayList> scalarTypeList = new ArrayList>(); + private ArrayList> scalarTypeList = new ArrayList>(); - private ArrayList> scalarConverterList = new ArrayList>(); + private ArrayList> scalarConverterList = new ArrayList>(); - private ArrayList> compoundTypeList = new ArrayList>(); - - private ArrayList> beanControllerList = new ArrayList>(); + private ArrayList> compoundTypeList = new ArrayList>(); - private ArrayList> transactionEventListenerList = new ArrayList>(); + private ArrayList> beanControllerList = new ArrayList>(); - private ArrayList> beanFinderList = new ArrayList>(); + private ArrayList> transactionEventListenerList = new ArrayList>(); - private ArrayList> beanListenerList = new ArrayList>(); + private ArrayList> beanFinderList = new ArrayList>(); - private ArrayList> beanQueryAdapterList = new ArrayList>(); + private ArrayList> beanListenerList = new ArrayList>(); + + private ArrayList> beanQueryAdapterList = new ArrayList>(); - private ArrayList> serverConfigStartupList = new ArrayList>(); - private ArrayList serverConfigStartupInstances = new ArrayList(); + private ArrayList> serverConfigStartupList = new ArrayList>(); + private ArrayList serverConfigStartupInstances = new ArrayList(); - private List persistControllerInstances = new ArrayList(); - private List persistListenerInstances = new ArrayList(); - private List queryAdapterInstances = new ArrayList(); - private List transactionEventListenerInstances = new ArrayList(); + private List persistControllerInstances = new ArrayList(); + private List persistListenerInstances = new ArrayList(); + private List queryAdapterInstances = new ArrayList(); + private List transactionEventListenerInstances = new ArrayList(); - public BootupClasses() { + public BootupClasses() { + } + + public BootupClasses(List> list) { + if (list != null) { + for (Class cls : list) { + isMatch(cls); + } + } + } + + /** + * Run any ServerConfigStartup listeners. + */ + public void runServerConfigStartup(ServerConfig serverConfig) { + + for (Class cls : serverConfigStartupList) { + try { + ServerConfigStartup newInstance = (ServerConfigStartup) cls.newInstance(); + newInstance.onStart(serverConfig); + + } catch (Exception e) { + String msg = "Error creating BeanQueryAdapter " + cls; + logger.error(msg, e); + } + } + } + + public void addQueryAdapters(List queryAdapterInstances) { + if (queryAdapterInstances != null) { + for (BeanQueryAdapter a : queryAdapterInstances) { + this.queryAdapterInstances.add(a); + // don't automatically instantiate + this.beanQueryAdapterList.remove(a.getClass()); + } + } + } + + /** + * Add BeanPersistController instances. + */ + public void addPersistControllers(List beanControllerInstances) { + if (beanControllerInstances != null) { + for (BeanPersistController c : beanControllerInstances) { + this.persistControllerInstances.add(c); + // don't automatically instantiate + this.beanControllerList.remove(c.getClass()); + } + } + } + + /** + * Add TransactionEventListeners instances. + */ + public void addTransactionEventListeners(List transactionEventListeners) { + if (transactionEventListeners != null) { + for (TransactionEventListener c : transactionEventListeners) { + this.transactionEventListenerInstances.add(c); + // don't automatically instantiate + this.transactionEventListenerList.remove(c.getClass()); + } + } + } + + public void addPersistListeners(List listenerInstances) { + if (listenerInstances != null) { + for (BeanPersistListener l : listenerInstances) { + this.persistListenerInstances.add(l); + // don't automatically instantiate + this.beanListenerList.remove(l.getClass()); + } + } + } + + public void addServerConfigStartup(List startupInstances) { + if (startupInstances != null) { + for (ServerConfigStartup l : startupInstances) { + this.serverConfigStartupInstances.add(l); + // don't automatically instantiate + this.serverConfigStartupList.remove(l.getClass()); + } + } + } + + public List getBeanQueryAdapters() { + // add class registered BeanQueryAdapter to the + // already created instances + for (Class cls : beanQueryAdapterList) { + try { + BeanQueryAdapter newInstance = (BeanQueryAdapter) cls.newInstance(); + queryAdapterInstances.add(newInstance); + } catch (Exception e) { + String msg = "Error creating BeanQueryAdapter " + cls; + logger.error(msg, e); + } } - public BootupClasses(List> list) { - if (list != null) { - for (Class cls : list) { - isMatch(cls); - } - } + return queryAdapterInstances; + } + + public List getBeanPersistListeners() { + // add class registered BeanPersistController to the + // already created instances + for (Class cls : beanListenerList) { + try { + BeanPersistListener newInstance = (BeanPersistListener) cls.newInstance(); + persistListenerInstances.add(newInstance); + } catch (Exception e) { + String msg = "Error creating BeanPersistController " + cls; + logger.error(msg, e); + } } - /** - * Run any ServerConfigStartup listeners. - */ - public void runServerConfigStartup(ServerConfig serverConfig) { - - for (Class cls : serverConfigStartupList) { - try { - ServerConfigStartup newInstance = (ServerConfigStartup) cls.newInstance(); - newInstance.onStart(serverConfig); - - } catch (Exception e) { - String msg = "Error creating BeanQueryAdapter " + cls; - logger.error(msg, e); - } - } - } - - public void addQueryAdapters(List queryAdapterInstances) { - if (queryAdapterInstances != null) { - for (BeanQueryAdapter a : queryAdapterInstances) { - this.queryAdapterInstances.add(a); - // don't automatically instantiate - this.beanQueryAdapterList.remove(a.getClass()); - } - } + return persistListenerInstances; + } + + public List getBeanPersistControllers() { + // add class registered BeanPersistController to the + // already created instances + for (Class cls : beanControllerList) { + try { + BeanPersistController newInstance = (BeanPersistController) cls.newInstance(); + persistControllerInstances.add(newInstance); + } catch (Exception e) { + String msg = "Error creating BeanPersistController " + cls; + logger.error(msg, e); + } } - /** - * Add BeanPersistController instances. - */ - public void addPersistControllers(List beanControllerInstances) { - if (beanControllerInstances != null) { - for (BeanPersistController c : beanControllerInstances) { - this.persistControllerInstances.add(c); - // don't automatically instantiate - this.beanControllerList.remove(c.getClass()); - } - } + return persistControllerInstances; + } + + public List getTransactionEventListeners() { + // add class registered TransactionEventListener to the + // already created instances + for (Class cls : transactionEventListenerList) { + try { + TransactionEventListener newInstance = (TransactionEventListener) cls.newInstance(); + transactionEventListenerInstances.add(newInstance); + } catch (Exception e) { + String msg = "Error creating TransactionEventListener " + cls; + logger.error(msg, e); + } } - /** - * Add TransactionEventListeners instances. - */ - public void addTransactionEventListeners(List transactionEventListeners) { - if (transactionEventListeners != null) { - for (TransactionEventListener c : transactionEventListeners) { - this.transactionEventListenerInstances.add(c); - // don't automatically instantiate - this.transactionEventListenerList.remove(c.getClass()); - } - } + return transactionEventListenerInstances; + } + + /** + * Return the list of Embeddable classes. + */ + public ArrayList> getEmbeddables() { + return embeddableList; + } + + /** + * Return the list of entity classes. + */ + public ArrayList> getEntities() { + return entityList; + } + + /** + * Return the list of ScalarTypes found. + */ + public ArrayList> getScalarTypes() { + return scalarTypeList; + } + + /** + * Return the list of ScalarConverters found. + */ + public ArrayList> getScalarConverters() { + return scalarConverterList; + } + + /** + * Return the list of ScalarConverters found. + */ + public ArrayList> getCompoundTypes() { + return compoundTypeList; + } + + /** + * Return the list of BeanControllers found. + */ + public ArrayList> getBeanControllers() { + return beanControllerList; + } + + /** + * Return the list of TransactionEventListeners found + */ + public ArrayList> getTransactionEventListenerList() { + return transactionEventListenerList; + } + + /** + * Return the list of BeanFinders found. + */ + public ArrayList> getBeanFinders() { + return beanFinderList; + } + + /** + * Return the list of BeanListeners found. + */ + public ArrayList> getBeanListeners() { + return beanListenerList; + } + + public boolean isMatch(Class cls) { + + if (isEmbeddable(cls)) { + embeddableList.add(cls); + + } else if (isEntity(cls)) { + entityList.add(cls); + + } else { + return isInterestingInterface(cls); } - public void addPersistListeners(List listenerInstances) { - if (listenerInstances != null) { - for (BeanPersistListener l : listenerInstances) { - this.persistListenerInstances.add(l); - // don't automatically instantiate - this.beanListenerList.remove(l.getClass()); - } - } - } + return true; + } - public void addServerConfigStartup(List startupInstances) { - if (startupInstances != null) { - for (ServerConfigStartup l : startupInstances) { - this.serverConfigStartupInstances.add(l); - // don't automatically instantiate - this.serverConfigStartupList.remove(l.getClass()); - } - } + /** + * Look for interesting interfaces. + *

+ * This includes ScalarType, BeanController, BeanFinder and BeanListener. + *

+ */ + private boolean isInterestingInterface(Class cls) { + + if (Modifier.isAbstract(cls.getModifiers())) { + // do not include abstract classes as we can + // not instantiate them + return false; } - - public List getBeanQueryAdapters() { - // add class registered BeanQueryAdapter to the - // already created instances - for (Class cls : beanQueryAdapterList) { - try { - BeanQueryAdapter newInstance = (BeanQueryAdapter) cls.newInstance(); - queryAdapterInstances.add(newInstance); - } catch (Exception e) { - String msg = "Error creating BeanQueryAdapter " + cls; - logger.error(msg, e); - } - } + boolean interesting = false; - return queryAdapterInstances; + if (BeanPersistController.class.isAssignableFrom(cls)) { + beanControllerList.add(cls); + interesting = true; } - public List getBeanPersistListeners() { - // add class registered BeanPersistController to the - // already created instances - for (Class cls : beanListenerList) { - try { - BeanPersistListener newInstance = (BeanPersistListener) cls.newInstance(); - persistListenerInstances.add(newInstance); - } catch (Exception e) { - String msg = "Error creating BeanPersistController " + cls; - logger.error(msg, e); - } - } - - return persistListenerInstances; + if (TransactionEventListener.class.isAssignableFrom(cls)) { + transactionEventListenerList.add(cls); + interesting = true; } - public List getBeanPersistControllers() { - // add class registered BeanPersistController to the - // already created instances - for (Class cls : beanControllerList) { - try { - BeanPersistController newInstance = (BeanPersistController) cls.newInstance(); - persistControllerInstances.add(newInstance); - } catch (Exception e) { - String msg = "Error creating BeanPersistController " + cls; - logger.error(msg, e); - } - } - - return persistControllerInstances; + if (ScalarType.class.isAssignableFrom(cls)) { + scalarTypeList.add(cls); + interesting = true; } - public List getTransactionEventListeners() { - // add class registered TransactionEventListener to the - // already created instances - for (Class cls : transactionEventListenerList) { - try { - TransactionEventListener newInstance = (TransactionEventListener) cls.newInstance(); - transactionEventListenerInstances.add(newInstance); - } catch (Exception e) { - String msg = "Error creating TransactionEventListener " + cls; - logger.error(msg, e); - } - } - - return transactionEventListenerInstances; - } - - /** - * Return the list of Embeddable classes. - */ - public ArrayList> getEmbeddables() { - return embeddableList; + if (ScalarTypeConverter.class.isAssignableFrom(cls)) { + scalarConverterList.add(cls); + interesting = true; } - /** - * Return the list of entity classes. - */ - public ArrayList> getEntities() { - return entityList; + if (CompoundType.class.isAssignableFrom(cls)) { + compoundTypeList.add(cls); + interesting = true; } - /** - * Return the list of ScalarTypes found. - */ - public ArrayList> getScalarTypes() { - return scalarTypeList; + if (BeanFinder.class.isAssignableFrom(cls)) { + beanFinderList.add(cls); + interesting = true; } - /** - * Return the list of ScalarConverters found. - */ - public ArrayList> getScalarConverters() { - return scalarConverterList; + if (BeanPersistListener.class.isAssignableFrom(cls)) { + beanListenerList.add(cls); + interesting = true; } - /** - * Return the list of ScalarConverters found. - */ - public ArrayList> getCompoundTypes() { - return compoundTypeList; - } - - /** - * Return the list of BeanControllers found. - */ - public ArrayList> getBeanControllers() { - return beanControllerList; + if (BeanQueryAdapter.class.isAssignableFrom(cls)) { + beanQueryAdapterList.add(cls); + interesting = true; } - /** - * Return the list of TransactionEventListeners found - */ - public ArrayList> getTransactionEventListenerList() { - return transactionEventListenerList; + if (ServerConfigStartup.class.isAssignableFrom(cls)) { + serverConfigStartupList.add(cls); + interesting = true; } - /** - * Return the list of BeanFinders found. - */ - public ArrayList> getBeanFinders() { - return beanFinderList; + return interesting; + } + + private boolean isEntity(Class cls) { + + Annotation ann = cls.getAnnotation(Entity.class); + if (ann != null) { + return true; } + ann = cls.getAnnotation(Table.class); + return ann != null; + } - /** - * Return the list of BeanListeners found. - */ - public ArrayList> getBeanListeners() { - return beanListenerList; - } + private boolean isEmbeddable(Class cls) { - public boolean isMatch(Class cls) { - - if (isEmbeddable(cls)) { - embeddableList.add(cls); - - } else if (isEntity(cls)) { - entityList.add(cls); - - } else { - return isInterestingInterface(cls); - } - - return true; - } - - /** - * Look for interesting interfaces. - *

- * This includes ScalarType, BeanController, BeanFinder and BeanListener. - *

- */ - private boolean isInterestingInterface(Class cls) { - - if (Modifier.isAbstract(cls.getModifiers())) { - // do not include abstract classes as we can - // not instantiate them - return false; - } - boolean interesting = false; - - if (BeanPersistController.class.isAssignableFrom(cls)) { - beanControllerList.add(cls); - interesting = true; - } - - if (TransactionEventListener.class.isAssignableFrom(cls)) { - transactionEventListenerList.add(cls); - interesting = true; - } - - if (ScalarType.class.isAssignableFrom(cls)) { - scalarTypeList.add(cls); - interesting = true; - } - - if (ScalarTypeConverter.class.isAssignableFrom(cls)) { - scalarConverterList.add(cls); - interesting = true; - } - - if (CompoundType.class.isAssignableFrom(cls)) { - compoundTypeList.add(cls); - interesting = true; - } - - if (BeanFinder.class.isAssignableFrom(cls)) { - beanFinderList.add(cls); - interesting = true; - } - - if (BeanPersistListener.class.isAssignableFrom(cls)) { - beanListenerList.add(cls); - interesting = true; - } - - if (BeanQueryAdapter.class.isAssignableFrom(cls)) { - beanQueryAdapterList.add(cls); - interesting = true; - } - - if (ServerConfigStartup.class.isAssignableFrom(cls)){ - serverConfigStartupList.add(cls); - interesting = true; - } - - return interesting; - } - - private boolean isEntity(Class cls) { - - Annotation ann = cls.getAnnotation(Entity.class); - if (ann != null) { - return true; - } - ann = cls.getAnnotation(Table.class); - return ann != null; - } - - private boolean isEmbeddable(Class cls) { - - Annotation ann = cls.getAnnotation(Embeddable.class); - return ann != null; - } + Annotation ann = cls.getAnnotation(Embeddable.class); + return ann != null; + } }