uqbar-project / arena-pers Goto Github PK
View Code? Open in Web Editor NEWArena Persistence - módulo sencillo de persistencia a partir de un grafo de objetos Neo4J
Arena Persistence - módulo sencillo de persistencia a partir de un grafo de objetos Neo4J
If you don't follow JavaBean convention Arena-persistence complains with the following message:
Exception in thread "main" uqbar.arena.persistence.ConfigurationException: La annotation uqbar.arena.persistence.annotations.PersistentField solo es válida anotando un getter
New languages that don't use JavaBean convention (like Scala, or even in Groovy or Xtend when it's not mandatory to define getters and setters) you have to define unnecessary getters because of this.
If you define an AbstractPersistentHome extending PersistentHome, and try to define a method like this:
Override public Class<T> getEntityType() { T.class }
You get the following stack trace:
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available
ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available
ClassNotFoundException.<init>(String) line: not available URLClassLoader$1.run() line: not available
URLClassLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available
[native method] Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
And every call to allInstances
return an empty list. Perhaps we can add a consistency check in every home, so Arena-persistence can complain when there's no getEntityType
of a concrete class defined.
Maybe creating a maven site for the application
If you define an AbstractPersistentHome extending PersistentHome, and try to define a method like this:
@OverRide
public Class getEntityType() {
T.class
}
You get the following stack trace:
ClassNotFoundException(Throwable).(String, Throwable) line: 286
ClassNotFoundException(Exception).(String, Throwable) line: not available
ClassNotFoundException(ReflectiveOperationException).(String, Throwable) line: not available
ClassNotFoundException.(String) line: not available
URLClassLoader$1.run() line: not available
URLClassLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction, AccessControlContext) line: not available [native method]
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
And every call to allInstances return an empty list.
Perhaps we can add a consistency check in every home, so Arena-persistence can complain when there's no getEntityType of a concrete class defined.
Using Groovy with Arena-UI + Arena-Persistence, following stack trace is showed:
Exception in thread "main" java.lang.RuntimeException: javassist.CannotCompileException: [source error] syntax error near "$ = ([Lorg.codeh"
at uqbar.arena.persistence.reflection.ClasspathCrawler.getClasses(ClasspathCrawler.java:48)
at uqbar.arena.persistence.reflection.ClasspathCrawler.getClasses(ClasspathCrawler.java:34)
at uqbar.arena.persistence.Configuration$.configure(Configuration.scala:33)
at uqbar.arena.persistence.Configuration.configure(Configuration.scala)
at uqbar.arena.persistence.Configuration$configure.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at dds.grupo5.festival.modelo.UI.PuntoDeVentaApplication.main(PuntoDeVentaApplication.groovy:23) Caused by: javassist.CannotCompileException: [source error] syntax error near "$ = ([Lorg.codeh"
at javassist.expr.FieldAccess.replace(FieldAccess.java:216)
at com.uqbar.apo.Advice.edit(Advice.scala:42)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198)
at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
at javassist.CtClassType.instrument(CtClassType.java:1385)
at com.uqbar.apo.Advice.apply(Advice.scala:72)
at com.uqbar.apo.AdviceWeaver.applyAdviceToCtClass(AdviceWeaver.scala:42)
at com.uqbar.apo.AdviceWeaver$$anonfun$applyAdvice$1.apply(AdviceWeaver.scala:35)
at com.uqbar.apo.AdviceWeaver$$anonfun$applyAdvice$1.apply(AdviceWeaver.scala:33)
at scala.collection.immutable.List.foreach(List.scala:318)
at com.uqbar.apo.AdviceWeaver.applyAdvice(AdviceWeaver.scala:33)
at com.uqbar.apo.APOClassLoader.applyAPO(APOClassLoader.scala:106)
at com.uqbar.apo.APOClassLoader.findClass(APOClassLoader.scala:83)
at com.uqbar.apo.APOClassLoader.loadClass(APOClassLoader.scala:58)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.uqbar.apo.APOClassLoader.loadClass(APOClassLoader.scala:69)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:70)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawl(ClasspathCrawler.java:59)
at uqbar.arena.persistence.reflection.ClasspathCrawler.getClasses(ClasspathCrawler.java:46) ... 8 more Caused by: compile error: syntax error near "$_ = ([Lorg.codeh"
at javassist.compiler.Parser.parsePrimaryExpr(Parser.java:1256)
at javassist.compiler.Parser.parsePostfix(Parser.java:1030)
at javassist.compiler.Parser.parseUnaryExpr(Parser.java:888)
at javassist.compiler.Parser.parseBinaryExpr(Parser.java:775)
at javassist.compiler.Parser.parseConditionalExpr(Parser.java:719)
at javassist.compiler.Parser.parseExpression(Parser.java:699)
at javassist.compiler.Parser.parsePrimaryExpr(Parser.java:1244)
at javassist.compiler.Parser.parsePostfix(Parser.java:1030)
at javassist.compiler.Parser.parseCast(Parser.java:921)
at javassist.compiler.Parser.parseUnaryExpr(Parser.java:886)
at javassist.compiler.Parser.parseBinaryExpr(Parser.java:775)
at javassist.compiler.Parser.parseConditionalExpr(Parser.java:719)
at javassist.compiler.Parser.parseExpression(Parser.java:699)
at javassist.compiler.Parser.parseExpression(Parser.java:704)
at javassist.compiler.Parser.parseDeclarationOrExpression(Parser.java:591)
at javassist.compiler.Parser.parseStatement(Parser.java:277)
at javassist.compiler.Javac.compileStmnt(Javac.java:567)
at javassist.expr.FieldAccess.replace(FieldAccess.java:210) ... 34 more
We would like to:
*IMPORTANT: This enhancement is useless if issue 5 is solved. ("Allow @PersistentField and @relation annotations in attributes rather than getters")
*
But just in case it's a heavy work to annotate attributes, maybe there's a chance to add a consistency check between getter/setter/attribute, so you can avoid problems like:
case 1- there's an attribute called nomYApe, and getter getNomYape()
case 2- there's an attribute int cantidad, and getter is defined Integer getCantidad()
case 3- there's an attribute int cantidad, and getter is defined def getCantidad(), with type inference o dynamic typing like Groovy.
For now on, there's a good error message: "Exception in thread "main" java.lang.RuntimeException: Se ha producido un error invocando setXXXXX" for case 1, and not so good message for cases 2 and 3: "Excepción: org.eclipse.core.runtime.AssertionFailedException: assertion failed: Could not read collection values"
The framework doesn´t have a Testmode, so If you want to make unit testing, you will need to add dependencies Neo4J to your project
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>1.7.2</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
This is used for manually initializing the Neo4J database and manage the transaction. For example, this is the definitions in the Test Class:
def GraphDatabaseService graphDb
def Transaction transaction
The followin code is used in te @before method to set up the fixture:
graphDb = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase()
SessionManager.testMode(graphDb)
Configuration.configure()
transaction = graphDb.beginTx()
And do this in the @after method
transaction.finish()
graphDb.shutdown()
Configuration.clear()
Perhaps in the uqbar.arena.persistence.Configuration class can be forced a TestMode.
If you don't follow JavaBean convention Arena-persistence complains with the following message:
Exception in thread "main" uqbar.arena.persistence.ConfigurationException: La annotation uqbar.arena.persistence.annotations.PersistentField solo es válida anotando un getter
New languages that don't use JavaBean convention (like Scala, or even in Groovy or Xtend when it's not mandatory to define getters and setters) you have to define unnecessary getters because of this.
Using Groovy with Arena-UI + Arena-persistence, following stack trace is showed:
Exception in thread "main" java.lang.RuntimeException: javassist.CannotCompileException: [source error] syntax error near "$_ = ([Lorg.codeh"
at uqbar.arena.persistence.reflection.ClasspathCrawler.getClasses(ClasspathCrawler.java:48)
at uqbar.arena.persistence.reflection.ClasspathCrawler.getClasses(ClasspathCrawler.java:34)
at uqbar.arena.persistence.Configuration$.configure(Configuration.scala:33)
at uqbar.arena.persistence.Configuration.configure(Configuration.scala)
at uqbar.arena.persistence.Configuration$configure.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at dds.grupo5.festival.modelo.UI.PuntoDeVentaApplication.main(PuntoDeVentaApplication.groovy:23)
Caused by: javassist.CannotCompileException: [source error] syntax error near "$_ = ([Lorg.codeh"
at javassist.expr.FieldAccess.replace(FieldAccess.java:216)
at com.uqbar.apo.Advice.edit(Advice.scala:42)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198)
at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
at javassist.CtClassType.instrument(CtClassType.java:1385)
at com.uqbar.apo.Advice.apply(Advice.scala:72)
at com.uqbar.apo.AdviceWeaver.applyAdviceToCtClass(AdviceWeaver.scala:42)
at com.uqbar.apo.AdviceWeaver$$anonfun$applyAdvice$1.apply(AdviceWeaver.scala:35)
at com.uqbar.apo.AdviceWeaver$$anonfun$applyAdvice$1.apply(AdviceWeaver.scala:33)
at scala.collection.immutable.List.foreach(List.scala:318)
at com.uqbar.apo.AdviceWeaver.applyAdvice(AdviceWeaver.scala:33)
at com.uqbar.apo.APOClassLoader.applyAPO(APOClassLoader.scala:106)
at com.uqbar.apo.APOClassLoader.findClass(APOClassLoader.scala:83)
at com.uqbar.apo.APOClassLoader.loadClass(APOClassLoader.scala:58)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.uqbar.apo.APOClassLoader.loadClass(APOClassLoader.scala:69)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:70)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawlFiles(ClasspathCrawler.java:73)
at uqbar.arena.persistence.reflection.ClasspathCrawler.crawl(ClasspathCrawler.java:59)
at uqbar.arena.persistence.reflection.ClasspathCrawler.getClasses(ClasspathCrawler.java:46)
... 8 more
Caused by: compile error: syntax error near "$_ = ([Lorg.codeh"
at javassist.compiler.Parser.parsePrimaryExpr(Parser.java:1256)
at javassist.compiler.Parser.parsePostfix(Parser.java:1030)
at javassist.compiler.Parser.parseUnaryExpr(Parser.java:888)
at javassist.compiler.Parser.parseBinaryExpr(Parser.java:775)
at javassist.compiler.Parser.parseConditionalExpr(Parser.java:719)
at javassist.compiler.Parser.parseExpression(Parser.java:699)
at javassist.compiler.Parser.parsePrimaryExpr(Parser.java:1244)
at javassist.compiler.Parser.parsePostfix(Parser.java:1030)
at javassist.compiler.Parser.parseCast(Parser.java:921)
at javassist.compiler.Parser.parseUnaryExpr(Parser.java:886)
at javassist.compiler.Parser.parseBinaryExpr(Parser.java:775)
at javassist.compiler.Parser.parseConditionalExpr(Parser.java:719)
at javassist.compiler.Parser.parseExpression(Parser.java:699)
at javassist.compiler.Parser.parseExpression(Parser.java:704)
at javassist.compiler.Parser.parseDeclarationOrExpression(Parser.java:591)
at javassist.compiler.Parser.parseStatement(Parser.java:277)
at javassist.compiler.Javac.compileStmnt(Javac.java:567)
at javassist.expr.FieldAccess.replace(FieldAccess.java:210)
... 34 more
We would like to
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.