Browse DevX
Sign up for e-mail newsletters from DevX


Extend your Java Application with Embedded Languages

A scripting engine, built in the language of your choice, and embedded into your application can make a huge difference to your customers, who have concerns about extensibility. Even better, creating a scripting engine is easy and fun. See three versions of a spam filter engine built in Groovy, Jython, and BeanShell.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

hat happens when a potential customer goes through the feature list for your application and finds just one or two missing items? Do you have a mechanism for them to extend your application to handle those features? Or will you lose the sale to an application that can be extended? Embedded scripting languages can turn a static vertical application into a dynamic application platform that will adapt rapidly to changing customer requirements.

And lucky for you Java is an extremely popular platform for embedded scripting languages. Why? Because the garbage collection and reflection capabilities of the Java language and framework make it easy to build parsers, compilers, and interpreters that work on any platform and can make use of the Java framework.

In this article I will discuss how you can use these embedded languages to add real customer value to your application, and then demonstrate the use of three different embedded languages in an example email application.

Let's start with the basics. A scripting language engine parses, compiles, and executes scripts at runtime. The host application then feeds the scripting engine chunks of script code to compile and execute. This script code can make method calls back to the host application through objects that have been injected into the script context.

One of the most popular examples of built-in scripting language support is Microsoft's support for custom macros in Office. These macro scripts access injected objects that represent the active document to add words or make changes to spreadsheets with arbitrarily complex logic. Whole business applications have been built entirely in the scripting framework. Which proves the benefit of a dynamic scriptable application framework in a business environment.

All of the scripting engines discussed in this article are capable of providing the same level of facility.

The Customer Perspective
The customer advantages of scripting support are clear:

  • The application can be extended and customized to add missing features or to achieve a higher level of integration with the business environment.
  • Business logic or flow can be customized without returning to the vendor for modifications.
  • Repetitive tasks can be automated to increase productivity.
Support for a scripting language in an application can also aid us as developers:
  • We can rapidly prototype new features in the scripting language and then roll them back into the Java when it makes sense for efficiency reasons.
  • It's simple to implement a shell—operating within the context of a running application—that allows you to inspect and modify the application's object model.
  • It's much easier to provide an application facility for what-if scenarios with run-time evaluated formulae.

That's just a taste of the power that embedded scripting languages can supply us as developers as well as our customers and end users.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date