Scala Integration

Search Solutions & Best Practices
Searching Solutions and Best Practices
Browse Solutions & Best Practices

                                                              

Summary: This article presents common Scala integration scenarios on top of XAP.
Author: Shravan (Sean) Kumar, Solutions Architect, GigaSpaces
Recently tested with GigaSpaces version: XAP 8.0.3

Overview

Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive.

Scala programs run on the Java VM, are byte code compatible with Java so you can make full use of existing Java libraries or existing application code. You can call Scala from Java and you can call Java from Scala, the integration is seamless. Because of this, Scala applications can use of GigaSpaces libraries and API like any other Java library or API.

Scala Helloworld examples

There are many possible permutations for integrating Java and Scala applications, you may have mixture of Java and Scala code or pure Scala code that you want to run on top of GigaSpaces. Hello World in Scala OpenSpaces project ports the GigaSpaces XAP standard helloworld example application for common Scala integration scenarios. Use this as a reference for how to integrate your Scala applications with GigaSpaces.

When building your application in Scala, the configuration and packaging will still be like Java application.

Find below code and configuration for the Helloworld application written completely in Scala.

Using Scala Interpreter

Scala also comes with an interpreter (REPL) which can be handy for development and testing. It is an interactive "shell" for writing Scala expressions and programs.

Interestingly, REPL can also be embedded in your application which is discussed in detail by Josh Suereth here and by Vassil Dichev here. Running REPL in your application is a useful trick which is theoretically possible but the ramifications of doing this on top of GigaSpaces are unknown. It is not recommended to run Scala on top of GigaSpaces using this approach.

Rate this page:
Your Rating: Results: PatheticBadOKGoodOutstanding! 15 rates

Additional resources: XAP Application Server | XAP Data Grid | XAP for Cloud Computing | XAP J2EE Support

Labels

 
(None)