Version 4, last updated by Rich Dougherty at April 02, 2008 04:53 UTC

Prerequisites

Mercurial

Mercurial is used for version control. The main scala-mina repository includes two branches: trunk, a clone of MINA's Subversion trunk; and fork, the patched version of MINA that maintained on this website.

You can get Mercurial from http://www.selenic.com/mercurial/.

Maven

Maven is used to automate the build process. Maven manages all other dependencies for us automatically, making life much easier.

You can get Maven from http://maven.apache.org/.

Scala

Due to a bug parsing MINA's classfiles, you will need Scala 2.7.0.r14143 or later to run MINA with Scala. The Scala site hosts nightly builds of the distribution which can be used rather than building from source. Note that Maven will automatically download the right version of Scala for the build process; you will only need to worry about versions when running MINA outside of Maven.

Building

$ hg clone http://hg.assembla.com/scala-mina
destination directory: scala-mina
requesting all changes
adding changesets
adding manifests
adding file changes
added 12 changesets with 620 changes to 605 files (+1 heads)
580 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd scala-mina
$ hg update -C fork
38 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ mvn install
[INFO] Scanning for projects...
[INFO] Reactor build order: 
[INFO]   Apache MINA Parent POM
[INFO]   Apache MINA Core
[INFO]   Apache MINA Serial Communication support
[INFO]   Apache MINA APR Communication Support
[INFO]   Apache MINA Compression Filter
[INFO]   Apache MINA Netty Codec
[INFO]   Apache MINA HTTP Codec
[INFO]   Apache MINA State Machine
[INFO]   Apache MINA HTTP Client
[INFO]   Apache MINA !JavaBeans Integration
[INFO]   Apache MINA OGNL Integration
[INFO]   Apache MINA JMX Integration
[INFO]   Apache MINA Scala Integration
[INFO]   Apache MINA Examples
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...

A snapshot of the project should now be built and available in your local Maven repository.

Testing

Run the example Hello World server.

$ cd example
$ mvn exec:java -Dexec.mainClass=org.apache.mina.example.scala.helloworld.HelloWorld
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Apache MINA Examples
[INFO]    task-segment: [exec:java]
[INFO] ----------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
[INFO] [exec:java]
Listening on port 12345.

Connect to the server from another terminal.

$ telnet localhost 12345
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Hello world
Connection closed by foreign host.