Preparation
The following components were gathered in this phase:
- JPA - the current standard of doing ORM in Java.
- EclipseLink is the reference implementation. It should serve the purpose well.
- SQL Server 2008 Express - As ASP.NET is being used anyway, why don't we work in the whole Microsoft ecosystem?
- SQL Server JDBC Driver - Yes, I need a JDBC Driver in .Net...
- AdventureWorksLT - Microsoft used to provide sample databases that works with SQL Server. AdventureWorksLT is the simplified version.
META-INF/persistence.xml
One of the challenges encountered was loading the persistence.xml. Luckily, IKVM can load the resource files with by specifying -classloader:ikvm.runtime.ClassPathAssemblyClassLoader when the compiling the class files and JAR files into .Net assembly. However, since all files were compiled into a single DLL. Only the first persistence.xml IKVM read can managed to be the resource.
META-INF/orm.xml
The problem of compiling everything into .Net assembly is losing all annotations in the classes. In the other words, you must use META-INF/orm.xml and initialize it in an IHttpModule.
Rework
The limitation of loading the two XML files is quite nasty. It would not feasible for medium size application that might have a few JAR files containing persistence.xml. Creating orm.xml manually is quite a pain as you know the information is in the classes already. To increase the flexbility, ClassPathAssemblyClassLoader is is wrapped by an URLClassLoader with the following classpaths:
- WEB-INF\classes
- All JAR files in WEB-INF\lib directory
Dual Mode
Now, Jeans support two ways to run a Java webapp:
- Native mode - With everything compiled into a single DLL
- WAR mode - Run a standard Java webapp directory whose structure is the same as in WAR file given:
- JSP are precompiled into servlet and put into WEB-INF/classes folder.
- JSP Servlet mappings are stored in jspweb.xml to complement the original web.xml.
No comments:
Post a Comment