Modularization

79 views
Skip to first unread message

Chas

unread,
Nov 12, 2012, 12:31:28 PM11/12/12
to xitrum-f...@googlegroups.com
I'm building a rather complex application using Xitrum, and I want to modularize it. Not only do I want to put certain features in modules (or plugins), but I want the user on the client side to be able to get a unique mix of modules. I don't want code that isn't needed to be downloaded.

Xitrum seems a perfect candidate for this with it's distributable routing. My app will use ember.js on the front end, and the back end will be purely a REST app.

Is there an example of the best practice for organizing code in this manner? Where would the modules go? How would they be integrated? Can I distribute the front end code, too?

So, for example, could I create a lib folder and a module in there (e.g., authorization) that included all the Scala, HTML, CSS, and Javascript needed for this particular module? How would this integrate with other modules?

Any and all suggestions, links to resources, code snippets, whatever greatly appreciated.

Chas.

Ngoc Dao

unread,
Nov 12, 2012, 2:16:53 PM11/12/12
to Xitrum web framework
I've just created this demo for you:
https://github.com/ngocdaothanh/xitrum-modularized-demo

Charles Munat

unread,
Nov 12, 2012, 3:39:21 PM11/12/12
to xitrum-f...@googlegroups.com
Holy crap. That was fast (and above and beyond the call of duty). Going
to have to put you on my Christmas list this year.

Thanks! I'll check it out.

Chas.

El Softwarerero

unread,
Nov 13, 2012, 10:48:46 AM11/13/12
to xitrum-f...@googlegroups.com
That is really cool. I dream of modules which changes are imediately reflected in the app while developing a module and the app at the same time. Something where no publish-local or restart is necessary. Play 1 had this but sacrificed it for the other benefits of SBT.

Another nice feature would be if files in the public folder of a module would be merged with the application. Probably in an optional subfolder with the module name to avoid name clashes.

I guess I have to learn SBT a bit more.

Ngoc Dao

unread,
Nov 13, 2012, 4:05:36 PM11/13/12
to Xitrum web framework
"sbt package" is faster than "sbt publish-local". One trick is using "sbt publish-local" only the first time. Then later, after updating module1 source code, use "sbt package". I usually use this trick when developing xitrum and xitrum-demos.

1. sbt publish-local only the first time
2. cd ~/ivy2/local/tv.cntt/xitrum-modularized-demo-module1_2.9.2/1.0-SNAPSHOT/jars/
3. rm xitrum-modularized-demo-module1_2.9.2.jar
4. Create symlink from the jar file in the source code directory to here: ln -s ~/src/xitrum-modularized-demo/module1/target/scala-2.9.2/xitrum-modularized-demo-module1_2.9.2-1.0-SNAPSHOT.jar xitrum-modularized-demo-module1_2.9.2.jar
5. When updating module1 source code, use "sbt package"


> Something where no publish-local or restart is necessary

Currently, you can use JRebel to reload things other than routes.


> public folder of a module would be merged with the application

Because module is packaged as a jar file, you should use "resources/<module name>/public" as demonstrated in xitrum-modularized-demo. I think the meaning of the word "module" itself is "encapsulation". Once packaged, it should not be changed.
Reply all
Reply to author
Forward
0 new messages