Thursday, June 16, 2011

More Scala

Ok, so now that a basic bean is up and running, let's get rid of the Java ServletContextListener and prove we can successfully do EJB injection in Scala.

Here's the Scala version:

package co.bookleaf.servlet

import javax.servlet.{ServletContextListener,ServletContextEvent}
import javax.ejb._
import com.scalaejb.ScalaEjbLocal

class StartupShutdown extends javax.servlet.ServletContextListener {

@EJB private var localEJB:ScalaEjbLocal = _

override def contextInitialized( sce: ServletContextEvent ) = { println("Here Scala: "+localEJB); localEJB.sayHi("Fred") }
override def contextDestroyed( sce: ServletContextEvent ) = {}
}
And... it works too! Getting there.

No comments:

Post a Comment