-
Ruby on Rails + CDI? Why not! Enter TorqueBox + Weld
Posted on July 27th, 2010 1 commentI guess many people are often “unsatisfied” with how JSF works and how much time it sometimes takes to do a simple thing. That’s why we are trying out a new combination: RoR for the frontend and CDI for the backend. How?
Deploying RoR applications to JBoss AS is really easy thanks to the TorqueBox project. You just deploy a
.ymlfile using the providedraketasks and you can develop the application “live” – no redeploys, instant changes, and so on.Using RoR as a frontend to a CDI/Weld based application requries two more steps, so that RoR can see the business logic classes and share the same http session with CDI (so it’s possible to access
@SessionScopedbeans from RoR and CDI code).First you need to deploy your application in the
DefaultDomain(at least until TORQUE-85 is fixed). To do this, add ajboss-classloading.xmlfile to theMETA-INFdirectory with this content:<classloading xmlns="urn:jboss:classloading:1.0" domain="DefaultDomain" top-level-classloader="true" export-all="NON_EMPTY" import-all="true"> </classloading>Secondly, you need to add a filter to RoR’s web application, so that Weld and RoR share the same session. Just edit
config/web.xmlin your RoR application (the magic in the RoR deployer will add it to the virtual .war deployment it creates) and add the following:<web-app> <listener> <listener-class>org.jboss.weld.servlet.WeldListener</listener-class> </listener> </web-app>Now RoR and CDI share the same session (so you can use
@SessionScopedbeans etc, probably also@ConversationScoped, but I haven’t tried that). You can lookup CDI beans from RoR code using e.g. the BeanInject class from cdi-ext, or just by writing a very simple utility method which lookups theBeanManager.Adam
-
Initial valid-time support in Envers
Posted on July 2nd, 2010 No commentsI just commited initial support for valid-time auditing in Envers, a feature that a lot of users has been (directly or indirectly) asking for. It’s joint work, as Stephanie Pau contributed a patch with a large portion of those changes – thanks!
You can try it out by checking out Hibernate trunk source code.
What is valid-time about? So far Envers only stored the revision at which a change was made. This information is enough to retrieve historical data, however the queries are quite complicated and in advanced use cases can be time-consuming. This can be improved when we store both the start and end revisions, that is information on when data was “valid”. For historic entities, both column are filled, and for “current” data, the end revision column is
null.Using the valid-time audit strategy, it will be possible to:
- speed up and simplify the queries to retrieve historical data
- implement support for queries, which traverse relations
- implement other types of queries, like latest changes
To configure Envers to store the end-revision number, you have to specify a property in your configuration file:
<property name="org.hibernate.envers.audit_strategy"> org.hibernate.envers.strategy.ValidTimeAuditStrategy </property>
Envers will then generate and additional
REVENDcolumn (next to theREVcolumn) in every audit (_AUD) entity/table; however this column won’t be part of the primary key. You can change the name of the end-revision column by setting theorg.hibernate.envers.audit_strategy_valid_time_end_nameproperty value.The value of the end-revision column can be calculated basing only on the original revision-changed columns, so using a couple of queries it will be possible to easily migrate existing data to the new audit strategy.
Please note that this feature is experimental, and can be changed in the future. The associated JIRA issue is HHH-3763.
Adam
-
NEnvers
Posted on July 1st, 2010 No commentsIf you are a .NET and NHibernate user, soon you’ll be able to use Envers in your project!
Simon Duduica has been working on an Envers to .NET port. This is still work in progress, but you can check out the current source code here: https://nhcontrib.svn.sourceforge.net/svnroot/nhcontrib/trunk/sandbox/simondud/Envers.NET
A large portion was ported, but there’s also quite a lot left, so any help is appreciated. Big thanks to Simon and looking forward to a release :)
Adam

