672329 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

News News News Messages: 10 Messages: 10 Messages: 10 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Rhino in Spring 1.1 released

Posted by: Attila Szegedi on February 27, 2007 DIGG
The Rhino in Spring has now reached its next evolutionary release, 1.1.

Rhino in Spring aims to integrate the Mozilla Foundation's Rhino JavaScript interpreter for Java with the Spring Framework.

The current release includes a controller component for the Spring Web MVC that allows you to express complex multipage flows in your web applications as server-side JavaScript programs.

You can use all the amenities of a full-blown imperative programming language while designing flows. You can write libraries of reusable code encapsulated into functions (i.e. validators), you can use the familiar for(), if(), while(), switch/case etc. statements to express the control flow, and so on.

Other features and functionalities include;
  • Use of Rhino’s continuations to support high scalability
  • support for back and forward button semantics
  • Support for “new window” split flow semantics
  • client side, in-memory or RDB storage of server state
  • compression, encryption and digital signing of state
  • Support for generic Spring bean factories

The 1.1 release includes numerous improvements driven by requirements of the project being used in real-world enterprise systems, mostly aimed at adding numerous customization and extension points. Among these are;
  • interceptors for customizing flow pre and postprocessing
  • pluggable script selection strategies
  • support for Rhino's integration with Java security policies
  • support for custom Rhino context factories

For further detail please visit the Rino in Spring project page.

Threaded replies

·  Rhino in Spring 1.1 released by Attila Szegedi on Tue Feb 27 04:44:30 EST 2007
  ·  Re: Rhino in Spring 1.1 released by Dennis Bekkering on Tue Feb 27 09:09:52 EST 2007
    ·  Advantage? by Jacob Briscoe on Tue Feb 27 09:37:43 EST 2007
      ·  Re: Advantage? by Adam Flynn on Tue Feb 27 10:59:39 EST 2007
        ·  Re: Advantage? by Attila Szegedi on Tue Feb 27 12:50:14 EST 2007
      ·  Re: Advantage? by Mark Davidson on Tue Feb 27 15:25:30 EST 2007
      ·  Re: Advantage? by Luca Garulli on Wed Feb 28 03:50:38 EST 2007
      ·  Re: Advantage? by Amir Sedighi on Sun Sep 14 02:47:37 EDT 2008
  ·  reinventing the problem... by Ivan Lazarte on Tue Feb 27 12:04:22 EST 2007
    ·  Re: reinventing the problem... by Attila Szegedi on Tue Feb 27 12:29:09 EST 2007
    ·  Re: reinventing the problem... by Adam Flynn on Tue Feb 27 12:34:50 EST 2007
  Message #228154 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Rhino in Spring 1.1 released

Posted by: Dennis Bekkering on February 27, 2007 in response to Message #228063
Spring Web? MVC? thats so yesterday

  Message #228157 Post reply Post reply Post reply Go to top Go to top Go to top

Advantage?

Posted by: Jacob Briscoe on February 27, 2007 in response to Message #228154
What would be some advantages to having server-side JavaScript ?

  Message #228160 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Advantage?

Posted by: Adam Flynn on February 27, 2007 in response to Message #228157
I think the main reason here is that it will allow you to construct your web app using the continuation support provided with Rhino. Of course, whether that's a good idea or not is debatable. This guy certainly doesn't think so.

The notion of defining the application flow with a script of some kind is an idea with some merit though, I think. This project seems similar to the concept of flowscripting in Cocoon. It's more intuitive (to me, anyway) than declaring the flow in an xml file as you do with Spring Webflow (although, I believe the xml format is not mandatory). It is immediately obvious from the script how the application is supposed to progress; I'm not sure you can say the same about the xml format.

  Message #228168 Post reply Post reply Post reply Go to top Go to top Go to top

reinventing the problem...

Posted by: Ivan Lazarte on February 27, 2007 in response to Message #228063
workflows are definition, not processing, and requires "programming in the large". javascript is a processing language, not a definition language. xml is a more natural choice despite scripting languages enjoying more attention lately.

there's also a zillion other reasons why i would never use a highly dynamic language like javascript as a definition language. i guess some people have to learn this the hard way!

  Message #228171 Post reply Post reply Post reply Go to top Go to top Go to top

Re: reinventing the problem...

Posted by: Attila Szegedi on February 27, 2007 in response to Message #228168
there's also a zillion other reasons why i would never use a highly dynamic language like javascript as a definition language.


I'd really be interested in hearing about concrete examples.

  Message #228174 Post reply Post reply Post reply Go to top Go to top Go to top

Re: reinventing the problem...

Posted by: Adam Flynn on February 27, 2007 in response to Message #228168
Maybe, but tell me there isn't a clearer, less verbose way of defining this (which is just about the simplest flow imaginable):

<webflow id="orderFlow" start-state="setupForm">
<!-- The initial state -->
<action-state id="setupForm">
<action bean="formAction"/>
<transition on="success" to="personalDetailsView"/> <!-- Continue the initial state -->
</action-state>

<!-- The initial or error state, depending on where we're coming from -->
<view-state id="personalDetailsView" view="enterPersonalDetails">
<transition on="submit" to="bindAndValidatePersonalDetails"/> <!-- To the bat mobile! -->
</view-state>

<!-- The submission state -->

<action-state id="bindAndValidatePersonalDetails">
<action bean="formAction" method="bindAndValidate"/>
<transition on="success" to="submissionSuccessful"/> <!-- To the success state -->
<transition on="error" to="personalDetailsView"/> <!-- To the error state -->
</action-state>

<!-- The success state -->
<end-state id="submissionSuccessful" view="orderComplete"/>
</webflow>

If that's "natural", then it's lost on me.

  Message #228178 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Advantage?

Posted by: Attila Szegedi on February 27, 2007 in response to Message #228160
I think the main reason here is that it will allow you to construct your web app using the continuation support provided with Rhino. Of course, whether that's a good idea or not is debatable. This guy certainly doesn't think so


Indeed he doesn't. His reasons are:

Abandoned sessions: he claims that a flowscript in an abandoned session simply "hangs" in its last continuation, not being able to clean up the resources it holds. This can be true, but it's a bad idea to cling onto resources between requests anyway. External resources are best managed using request-scoped servlet filters and/or interceptors, so the continuations don't hold on to any external resource (i.e. a Hibernate session) between requests but have it managed for them with a session interceptor around the request. This problem is in no way limited to continuation-based state management systems.

Thread affinity: true, you lose thread affinity. This is not worse than either COM+ object model or EJB model where you never could assume logical threads of execution have 1-1 mapping to any other (VM or OS) threads. Just don't assume it.

Web farm: (aka distributing the HTTP session over several machines for failover and load balancing). Right, your script might end up running different stages of itself on different machines. But the framework must make this transparent, and Rhino-in-Spring makes lots of efforts to deliver on this promise. It uses by-name serialization stubs to mark beans from WebApplicationContext and ServletContext reachable from the continuation, and resolves them to actual beans with by-name lookup on deserialization, thus correctly rebinds the continuation to its global context no matter which physical JVM it is resurrected in. I use a similar approach in a distributed enterprise script execution system I work on for living, and the execution site transparency does wonders for scalability (we can just add another script executor JVM as we need, connecting it to our messaging middleware, and it sucks up load consisting of already running scripts immediately).

The Back Button and Branching: in my eyes, it's the best feature of all. You write a single procedural flow script, and it can handle user going back and forth and branching multiple browser tabs. His misconception is that old continuations share local variables and thus you just introduced free-range gotos into your code that operates on a single set of local variables. This is fortunately (for me) and unfortunately (for him) not true. When multiple continuations per session are allowed, then each continuation has a deep copy of its local variables, acquired by serializing/deserializing in memory, so two continuations can't interfere any way with one another. Of course, you must take care to check the validity of the non-local variables between continuations, i.e. not cache results of database queries across requests etc. But you can rest assured that your local variables are safe. They're deeply copied when execution forks.

  Message #228194 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Advantage?

Posted by: Mark Davidson on February 27, 2007 in response to Message #228157
Alfresco features support for Rhino. You'll find examples of usage here - http://wiki.alfresco.com/wiki/JavaScript_API. It looks pretty cool.

  Message #228238 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Advantage?

Posted by: Luca Garulli on February 28, 2007 in response to Message #228157
The sense of Server Side Javascript is to use a scripting language instead of Java.

Benchmarks show Rhino is the fastest Java Scripting engine.

Ciao,
Luca Garulli

  Message #268386 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Advantage?

Posted by: Amir Sedighi on September 14, 2008 in response to Message #228157
I am using Rhino and Python to support online dynamic requirements in run time to support J2EE/Spring biz applications. Some thing like Rule engine or Work flow systems.
Both of them are platform independent and easy to use. I believe JavaScript is most popular programming language. It is interesting to let the business using of some powerfull logic and programming engine as Rhino.

New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com

Dependency Injection in Java EE 6 - Part 2

Reza Rahman continues to explore the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (January 21, Article)

Ted Neward Q&A: What you must know about JavaScript, Scala and more

Ted Neward is an independent consultant specializing in high-scale enterprise systems, and an authority in Java and .NET technologies. He is the author and co-author of several books, including Effective Enterprise Java. At TheServerSide Java Symposium in March, he will be presenting sessions on pragmatic architecture, ECMAScript and Scala. (January 15, Article)

Developers split on open sourcing Java

Now that Oracle is absorbing Sun Microsystems, there mixed views on what should come of the Java Community Process (JCP). While some say Oracle should become the new steward of Java and keep the JCP much as it was, others argue that it may be time to open-source this widespread language. (November 24, Article)

Dependency Injection in Java EE 6 - Part 1

Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (November 2, Article)

SAML: It's Not just for Web services

SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options. (September 28, Article)

Programming is Also Teaching Your Team

Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team. (September 22, Article)

Can Java EE Deliver The Asynchronous Web?

Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies. (July 14, Article)

JSF Flex

JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags. (June 29, Article)

The Rules of SOA - A Road to a Successful SOA Implementation

In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project. (June 23, Tech Talk)

Ari Zilka Talks About Terracotta 3.1

Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now. (June 15, Tech Talk)

Enterprise Application Integration, and Spring

In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements. (June 15, Tech Talk)

Google Web Toolkit: An Introduction

In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls. (June 4, Tech Talk)

Just Enough Early Architecture to Guide Development

Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable. (May 28, Tech Talk)

Productive Programmer: On the Lam from the Furniture Police

This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work. (May 26, Tech Talk)

Auto-Scaling Your Existing Web Application

Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers. (May 21, Tech Talk)

Automating Hibernate Mapping and Queries For Java Web Development

Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application. (May 19, Article)

Free Book PDF Download: Mastering EJB Third Edition

Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)

Application Server Matrix

The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map