25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14 ■ Using Dynamic Languages<br />

<br />

<br />

String username;<br />

String password;<br />

void setUsername(String _username){<br />

username = _username;<br />

}<br />

void setPassword(String _password){<br />

password = _password;<br />

}<br />

boolean isAuthorized(String email,String pass){<br />

if(username.equals(email) &amp;&amp; password.equals(pass))<br />

return true;<br />

return false;<br />

}<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Listing 14-9 shows the inline Bean Shell script. If you run the same unit test one time for each XML configuration,<br />

you will have the same results:<br />

2014-05-19 00:12:59,835 DEBUG [Test worker] Testing Security...<br />

2014-05-19 00:12:59,844 DEBUG [Test worker] Validating Credentials > email:john@email.com, pass:doe<br />

com.apress.isf.spring.test.MyDocumentsTest > testBeanShell PASSED<br />

Summary<br />

In this chapter, you saw how to use dynamic languages and how they can help you do quick and easy tasks, like<br />

creating a Groovy script to validate the URL or to validate the location of your documents in a filesystem (something<br />

similar to what you did in Chapter 13). If you want, you can extend this and take advantage of the Groovy or JRuby<br />

programming languages by using their own features such as metaprogramming.<br />

In the next chapter, you will use a new persistent mechanism. Instead of using a JDBC with SQL, now you are<br />

going to use a new paradigm that has been getting stronger over the past few years: a NoSQL databases. You will use<br />

MongoDB.<br />

202

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!