Since my last post I've received some requests about a working sample for Liferay 6. Ok then...here it goes!
First there are some things I have to tell you....
Since some libraries and packages have changed from Liferay 5.2.3 to Liferay 6, I had to do some refactoring, so, taking advantage of this, I've made some modifications to the Zeep o'Tron version for Liferay 5.2.3.
As I told in some other posts, one of the features of Zeep o'Tron was the possibility to override/add your own Spring beans to Liferay core. Since Liferay already provides the possibility to add your own services through the service tag in hook's definition files, I've eliminated this feature from Zeep o'Tron. Maybe I missed something when taking that decision, so, if you think of any situation where adding your own Spring beans could be an advantage, just let me know, and I'll put it back.
Another thing that has been changed is the way Struts and Tiles configurations are loaded. In previous version, Zeep o'Tron just scanned any deployed hook for classes and libs and added them to Liferay's classloader, then, looked for a "struts-config.xml" file under hook's WEB-INF directory, scanned it, and added those configs to Liferay's struts configs. Finally, searched for a "tiles-defs.xml" file, under the same directory, and added those Tiles configurations to Liferay's Tiles configurations.
Thinking about it, I find it too much aggressive, I mean Zeep o'Tron was applied to each and every deployed hook, and, sometimes, it makes no sense. That's why I've decided to modify the version for Liferay 6 to make it work different, so that not only you can choose which hooks will be parsed by Zeep o'Tron, but which kind of configurations you want to be loaded, and which files contain those configs.
How does it work now? From now on, when a hook is deployed, Zeep o'Tron will look for a file called zeep-o-tron.properties under hook's WEB-INF directory. If it is found, it will check for two properties: 'struts.file.path' and 'tiles.file.path'. If there is a filled 'struts.file.path' property, Struts configurations found in that file (the one represented in the property value) will be loaded into Liferay's Struts configurations, overriding and adding whatever is needed. Besides, all classes and libs found in the hook will be added to Liferay's classloader, so that we can make sure that all classes needed by those configurations are available to Liferay.
At last, something similar is done for Tiles configurations: if a value is found for the property 'tiles.file.path', that file is parsed and all Tiles configurations found in there, added to Liferay's Tiles definitions.
You can take a look at the same hook for the details.
So, the sample hook you'll find in this entry, will work exactly as that shown in Liferay Portal Server: avoiding use of extension. JAR and sample for Liferay 5.2.3, except by the Spring part:
- Install Zeep o'Tron for Liferay 6 the same way as explained for Liferay 5.2.3
- Start Liferay, and deploy the sample hook provided later on in this entry
- Create an event in the Calendar portlet and have a look at the logs (remember the sample hook outputs to the logs just by using System.out) to check Zeep o'Tron's Struts functionality
- Try to see the details of an event, to check Zeep o'Tron's Tiles functionallity
For more details about the testing the sample hook, check out the blog entry related to Zeep o'Tron for Liferay 5.2.3 (and remember to avoid the Spring part, of course!).
Finally, here you can download Zeep o'Tron for Liferay 6, and a sample hook. Sorry for uploading the artifacts in such a place, but found nothing better..
Enjoy!!
Have any idea on how to improve it? Just let me know!