-
1. Re: Seam Project with Scala
asookazian Jan 19, 2010 9:56 PM (in response to gzoller.greg.zoller.aviall.com)I don't have any hands-on experience (yet) with Scala but it sounds like you may be missing a Scala library in your classpath unless a Scala-Seam integration library is required? I'm pretty sure Scala is like Groovy in that they just require a JVM to exec... Is there a Groovy-Seam integration library, maybe you can check that first??
-
2. Re: Seam Project with Scala
gzoller.greg.zoller.aviall.com Jan 21, 2010 10:22 PM (in response to gzoller.greg.zoller.aviall.com)Ok... got it. Here's the HOWTO in order to use Seam w/Scala.
1) Download/install the nightly Scala Eclipse plug-in. This gives you Scala 2.8 (beta). May work w/2.7.x but frankly the community buzz confirms the older Eclipse plugin is bumpy. Take your best shot here.
2) Import a seam-gen'ed project like normal
3) In your Eclipse left-hand-side project view (Seam perspective), right click your project and go down to the Scala menu and select Add Scala Nature.
4) In your project's lib directory import the scala-library.jar (from the normal Scala distribution) for Scala 2.8 (or whatever, to match your Eclipse plugin's Scala version
5) Edit deployed-jars-ear.list and add scala-library.jar so that the library will deploy to your app server as part of the ear.
You can now use Scala in your project with the normal Java/Scala limitations. Here's a sample of a Seam component that injects a trivial Scala class (also a component):
import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.AutoCreate; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; @Name("message") @Scope(ScopeType.CONVERSATION) @AutoCreate public class Message { @In(create=true) MsgText msgText; // Scala object injected public String getSay() { return "Hey! "+msgText.say(); } }
and the Scala component:
import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; @Name("msgText") @Scope(ScopeType.CONVERSATION) class MsgText { val msg = "Some message text" def say() = { msg } }
I'm sure there'll be a gotcha here or there, but this is a wonderful prospect for those, like me, who love the potential of Scala but want the features Seam provides.