Enforce enhancement

58 views
Skip to first unread message

Daryl Stultz

unread,
Feb 10, 2012, 8:05:23 AM2/10/12
to Ebean ORM
Hello,

I've added a feature to Ebean that allows the requirement of entities
to be enhanced. This is useful if you want to use enhancement and you
want protection against a failure to enhance (something wrong with
your build process, for example). There are situations where Eclipse
will recompile but not run my Ant build task to enhance.

Simply set this in properties:

ebean.allowSubclassing=false

Here's the patch:


diff -r 84c44248aea2 src/main/java/com/avaje/ebean/config/
ServerConfig.java
--- a/src/main/java/com/avaje/ebean/config/ServerConfig.java Thu Feb
09 16:14:35 2012 -0500
+++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java Fri Feb
10 08:01:10 2012 -0500
@@ -254,6 +254,11 @@
*/

private boolean vanillaRefMode;



+ /**

+ * Set to false to require enhancement to be used. Defaults to
true.

+ */

+ private boolean allowSubclassing;

+

/**

* Construct a Server Configuration for programmatically creating
an

* EbeanServer.

@@ -1202,6 +1207,20 @@
}



/**

+ * Returns whether this config supports subclassed entities.

+ */

+ public boolean isAllowSubclassing() {

+ return allowSubclassing;

+ }

+

+ /**

+ * Set to false to require enhancement to be used. Defaults to
true.

+ */

+ public void setAllowSubclassing(boolean allowSubclassing) {

+ this.allowSubclassing = allowSubclassing;

+ }

+

+ /**

* Register a BeanQueryAdapter instance.

* <p>

* Note alternatively you can use {@link #setQueryAdapters(List)}
to set

@@ -1409,6 +1428,8 @@
packages = getSearchJarsPackages(packagesProp);

}



+ allowSubclassing = p.getBoolean("allowSubclassing", true);

+

validateOnSave = p.getBoolean("validateOnSave", true);

vanillaMode = p.getBoolean("vanillaMode", false);

vanillaRefMode = p.getBoolean("vanillaRefMode", false);

diff -r 84c44248aea2 src/main/java/com/avaje/ebeaninternal/server/
deploy/BeanDescriptorManager.java
--- a/src/main/java/com/avaje/ebeaninternal/server/deploy/
BeanDescriptorManager.java Thu Feb 09 16:14:35 2012 -0500
+++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/
BeanDescriptorManager.java Fri Feb 10 08:01:10 2012 -0500
@@ -180,6 +180,8 @@


private final LuceneIndexManager luceneManager;



+ private final boolean allowSubclassing;

+

/**

* Create for a given database dbConfig.

*/

@@ -219,6 +221,8 @@


this.reflectFactory = createReflectionFactory();

this.transientProperties = new TransientProperties();

+

+ this.allowSubclassing =
config.getServerConfig().isAllowSubclassing();

}



public BeanDescriptor<?> getBeanDescriptorById(String
descriptorId) {

@@ -1498,9 +1502,13 @@
if (desc.isAbstract()) {

if (hasEntityBeanInterface(beanClass)) {

checkEnhanced(desc, beanClass);

- } else {

- checkSubclass(desc, beanClass);

- }

+ } else {

+ if (allowSubclassing) {

+ checkSubclass(desc, beanClass);

+ } else {

+ throw new PersistenceException("This configuration does not
allow entity subclassing [" + beanClass + "]");

+ }

+ }

return;

}

try {

Rob Bygrave

unread,
Feb 13, 2012, 4:48:13 AM2/13/12
to eb...@googlegroups.com
Hi,

I have applied the patch to trunk.

Thanks, Rob.
Reply all
Reply to author
Forward
0 new messages