11 Replies Latest reply on Mar 30, 2010 11:37 PM by Glenn Silverman

    Web Beans and Scala integration?

    Arbi Sookazian Master

      any plans for Scala and Web Beans integration (Web Beans 1.1 or 2.0 - if it's possible)? 


      I see lots of posts/article on artima.com regarding Scala and Ted Neward is a big fan of Scala as well.

        • 1. Re: Web Beans and Scala integration?
          John Ament Master

          is there reason to believe that scala does not work within webbeans at the moment? i would assume in a scripting environment you would load webbeans like a Java SE app, and embedding scala in EE code would make the beans available to scala classes...

          • 2. Re: Web Beans and Scala integration?
            Arbi Sookazian Master

            I don't have much experience with Scala but I know it compiles to bytecode and thus runs in a JVM.



            First, Scala compiles to Java bytecode, meaning it runs on the JVM. In addition to enabling you to continue leveraging the rich Java open-source ecosystem, Scala can be integrated into an existing IT environment with zero migration effort.





            Second, Scala is based on the functional principles of Haskell and ML, yet still borrows heavily from the familiar object-oriented concepts Java programmers love. As a result, it can blend the best of both worlds into a whole that offers significant benefit without sacrificing the familiarity we've come to depend on.

            source: http://www.ibm.com/developerworks/java/library/j-scala01228.html


            So I guess the question is not so much what is the integration plan for Web Beans and functional programming languages like Scala? but more like will there be a Scala example in the WB RI like there is a groovybooking in Seam distro?


            And the answer is..........


            Submit the source/example!


            So is it possible to write an entire Web Beans JEE 6 web app in Scala??  Or Groovy?


            probably not b/c most (if not all) SE and EE libraries are written in Java, so is it possible to access these APIs from Groovy or Scala in a Web Beans or Seam 3 app?

            • 3. Re: Web Beans and Scala integration?
              John Ament Master

              Again, you're assuming there's an issue/problem when there's no clear identification of one.  Groovy/Scala/JRuby and others have full access to the java libraries, including the built in and extended libraries (e.g. hibernate, struts, and spring).  WebBeans/Seam are simply libraries.


              As for will there be examples in EE, probably not, but I can only speculate.  Scala's not a JSR.  The closest thing is JSR 223 which scala's not 100% compliant with.  I don't see any reason why webbeans would need to provide any additional functionality to work w/ 223 compliant apps.

              • 4. Re: Web Beans and Scala integration?
                Arbi Sookazian Master

                I get your point.  It's like asking about Spring and Scala integration.  It's a language that compiles to Java bytecode, not another EE framework that you can integrate with an existing EE framework (e.g. JSF / Seam / EJB)


                • 5. Re: Web Beans and Scala integration?
                  Dan Allen Master

                  Right, but the question I have is whether it's possible to load a Scala resource dynamically (not compiled to bytecode). We currently have this integration in Seam for Groovy. You can put Groovy resources in WEB-INF/dev and Seam picks them up using a special classloader. Would it be reasonable (or possible) to provide the same thing for Scala? Or is it assumed that when you use Scala, you will always be compiling. If you have to compile, then yeah, there is no need for a special integration. Rather, just have the scala compiler weaved into the Ant or Maven 2 build.

                  • 6. Re: Web Beans and Scala integration?
                    Dan Allen Master

                    I just gave Scala a quick test and since it supports annotations and all, if you compile the classes, you can use them in Seam (and therefore WB too). One thing to look out for is that you cannot create final classes since Seam needs to proxy them.

                    • 7. Re: Web Beans and Scala integration?
                      Pete Muir Master

                      No longer true in 299 - as long as you use the dependent scope, with no interceptors or decorators (i.e. the default), no proxy will be applied :-)

                      • 8. Re: Web Beans and Scala integration?
                        Dan Allen Master

                        I figured I was going to get corrected on that after I posted it. It's Seam that requires the classes to not be final. As Pete mentioned, Web Beans has been designed to remove this limitation in cases when you are not using an explicit scope on the class.

                        • 9. Re: Web Beans and Scala integration?
                          Siarhei Dudzin Apprentice

                          Pete Muir wrote on Jun 12, 2009 22:33:


                          No longer true in 299 - as long as you use the dependent scope, with no interceptors or decorators (i.e. the default), no proxy will be applied :-)


                          Pete, I have concerns about this one... the spec says: Client proxies are never required for a bean whose scope is a pseudo-scope such as @Dependent. But it doesn't actually forbid a CDI implementation to actually implement proxies for dependent scope?

                          • 10. Re: Web Beans and Scala integration?
                            Pete Muir Master

                            Siarhei Dudzin wrote on Jul 10, 2009 14:21:



                            Pete Muir wrote on Jun 12, 2009 22:33:


                            No longer true in 299 - as long as you use the dependent scope, with no interceptors or decorators (i.e. the default), no proxy will be applied :-)


                            Pete, I have concerns about this one... the spec says: Client proxies are never required for a bean whose scope is a pseudo-scope such as @Dependent. But it doesn't actually forbid a CDI implementation to actually implement proxies for dependent scope?


                            Correct - so choose a impl which doesn't (like Web Beans :-)

                            • 11. Re: Web Beans and Scala integration?
                              Glenn Silverman Newbie

                              A discussion of my problems with a similar issue is posted an this forum at:


                              http://www.seamframework.org/Community/ScalaJSF20OnJboss6DeploymentError


                              I'd be interested in any insight you might have.


                              Glenn