Our code is in Java and Javascript (AJAX libraries). We have wrappers/reusable code around the existing libraries to perform mundane tasks like, db connections, session management, logging, hibernate settings, base structure, some reusable multitenancy code etc.. From the javascript end, we have page initializers, UI layout components, custom js objects, and some of our own logic.
We have multiple projects where this code can be reused, but at the same time, this code is evolving along with the application. So if we find a common way to do it, we can move it to the framework code and let other projects also benefit out of it. If/when we find a bug in the base code, we can fix it in one place and commit and all the other projects will pick up the change (rather than everyone making the changes locally).
If it's just java files, we can keep it as a separate project, and include it as a dependent module in eclipse/maven and have it included as a jar, as and when needed. This part is easy to handle, but now we also have reusable javascript in the code, which cannot exactly be jar(ed). We want some suggestions on how the code should be laid out, so we can reuse it via maven (deployment time) and via eclipse (development time), without going thru too many hoops.
Before writing this, I did come across some articles on stackoverflow, which do talk about reusable code and methodologies which are great, but not exactly how to manage them using svn, maven, eclipse etc..
Linking them, for reference.
- Architecture of some reusable code
- How do you make code reusable? -> This is a great article from a theory stand point, but no tips on management.
- How do I index and make available reusable code?
In some of our old projects, we maintained ant files, which would copy files from base locations to the final war, so everything is available. But over the period of time as the project grew, even for a simple check, we had to rebuild the whole war and deploy to test on the developers machine. Which took away 5 minutes every time.
So the question is, are there any repository patterns, eclipse project layout ideas, packaging styles, whic开发者_StackOverflowh can help us resolve this issue ?
I would suggest using a Component oriented java web framework for such tasks. Wicket immediately comes to mind. (But JSF, Tapestry etc will work equally well)
In wicket, everything is a component and components can be packaged with behaviors (which may include javascript, css etc)
So you'd have a commons - project where you maintain reuseable java and javascript code.
The benefits are obvious, it's pretty much exactly what you have been asking for. The drawbacks, on the other hand are mainly that javascript and css content is inside your jars and will be served by the app server rather than a static web server or CDN.
Sean
精彩评论