This document discusses managing change and achieving regression isolation using dynamic Groovy edges. It describes how Groovy can be used to build edge components, such as web service clients, in a way that makes it easier to update them and reduce the need for full regression testing when changes occur. Groovy allows direct access to XML payloads using techniques like the Markup Builder and XML Slurper. The document provides examples of using Groovy to detect web service changes and consume web services. It also discusses strategies for configuring Groovy scripts in Spring applications.
Gradle is a flexible general purpose build system with a build-by-convention framework a la Maven on top. It uses Apache Ivy under the hood for its dependency management. Its build scripts are written in Groovy.
Lab session given at OSCON Java 2011:
Visage is the successor to the JavaFX Script Language, a domain-specific language for writing UIs. It excels at rapid application design and can be used on any platform that supports Java. In this lab you will have an opportunity to write Visage applications that deploy to and run on Android mobile devices. No prior experience with Android or Visage development is required.
Node.js Development with Apache NetBeansRyan Cuprak
This session covers the basics of developing Node.js applications with NetBeans. NetBeans includes fully integrated support for both JavaScript and Node.js. You’ll get a tour of the features and learn how NetBeans can accelerate your projects. The presentation looks at basic code editing capabilities provided by the IDE, tool integration (npm/Grunt/Bower/Webpack), frameworks such as Express, and debugging capabilities. You’ll see why NetBeans is the best free JavaScript/Node.js IDE.
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
For the long time, we have used various build tools to package applications for new software releases or applying patches to existing applications etc. dependency management, version controlling, scalability, flexibility, single-multiple projects sup portability are some of the key areas that drove the selection of a build tool, This session focuses on Gradle as a successful build tool and looks into all the above areas and uses Groovy as a DSL. We will also look into how easy it is to use Gradle as compared to other open source build tools.
Photos: https://plus.google.com/u/0/photos/105295086916869617504/albums/5739617166453582993
Gradle build tool that rocks with DSL By Rajmahendra Hegde at JavaOne Hyderabad, India on 4th May 2012
Gradle is a flexible general purpose build system with a build-by-convention framework a la Maven on top. It uses Apache Ivy under the hood for its dependency management. Its build scripts are written in Groovy.
Lab session given at OSCON Java 2011:
Visage is the successor to the JavaFX Script Language, a domain-specific language for writing UIs. It excels at rapid application design and can be used on any platform that supports Java. In this lab you will have an opportunity to write Visage applications that deploy to and run on Android mobile devices. No prior experience with Android or Visage development is required.
Node.js Development with Apache NetBeansRyan Cuprak
This session covers the basics of developing Node.js applications with NetBeans. NetBeans includes fully integrated support for both JavaScript and Node.js. You’ll get a tour of the features and learn how NetBeans can accelerate your projects. The presentation looks at basic code editing capabilities provided by the IDE, tool integration (npm/Grunt/Bower/Webpack), frameworks such as Express, and debugging capabilities. You’ll see why NetBeans is the best free JavaScript/Node.js IDE.
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
For the long time, we have used various build tools to package applications for new software releases or applying patches to existing applications etc. dependency management, version controlling, scalability, flexibility, single-multiple projects sup portability are some of the key areas that drove the selection of a build tool, This session focuses on Gradle as a successful build tool and looks into all the above areas and uses Groovy as a DSL. We will also look into how easy it is to use Gradle as compared to other open source build tools.
Photos: https://plus.google.com/u/0/photos/105295086916869617504/albums/5739617166453582993
Gradle build tool that rocks with DSL By Rajmahendra Hegde at JavaOne Hyderabad, India on 4th May 2012
JavaScript Interview Questions and Answers | Full Stack Web Development Train...Edureka!
( ** Full Stack Web Developer Masters Program: https://www.edureka.co/masters-program/full-stack-developer-training ** )
This Edureka PPT on "JavaScript Interview Questions" will help you to prepare yourself for JavaScript Interviews (JavaScript Interview Questions Blog: https://www.edureka.co/blog/interview-questions/javascript-interview-questions/ ). Learn about the most important JavaScript interview questions and answers and know what will set you apart in the interview process.
Instagram: https://www.instagram.com/edureka_lea...
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
This presentation provides a brief overview of the history of JavaScript and its ecosystem and highlights the excellent JS support provided by the latest NetBeans IDE. You can find the examples on github: https://github.com/saikos/NetBeansES6Support
Here are slides from basic training for Gradle.
This training is aimed to help Java Developers to get hands-on experience to use Gradle as a primary build tool for Java source code starting from simple compilation continuing with different kinds of tests and finishing with code quality analysis and artefacts publishing.
JavaScript Interview Questions and Answers | Full Stack Web Development Train...Edureka!
( ** Full Stack Web Developer Masters Program: https://www.edureka.co/masters-program/full-stack-developer-training ** )
This Edureka PPT on "JavaScript Interview Questions" will help you to prepare yourself for JavaScript Interviews (JavaScript Interview Questions Blog: https://www.edureka.co/blog/interview-questions/javascript-interview-questions/ ). Learn about the most important JavaScript interview questions and answers and know what will set you apart in the interview process.
Instagram: https://www.instagram.com/edureka_lea...
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
This presentation provides a brief overview of the history of JavaScript and its ecosystem and highlights the excellent JS support provided by the latest NetBeans IDE. You can find the examples on github: https://github.com/saikos/NetBeansES6Support
Here are slides from basic training for Gradle.
This training is aimed to help Java Developers to get hands-on experience to use Gradle as a primary build tool for Java source code starting from simple compilation continuing with different kinds of tests and finishing with code quality analysis and artefacts publishing.
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)Daniel Bryant
A guest lecture I presented to MSc Level Enterprise Systems Development students within the Department of Computing at the University of Surrey. This was a very similar presentation to the L2 lecture delivered the week earlier, but also included more advanced material.
The next release of the Java Standard Edition is scheduled for the beginning of 2010. In this session we'll review the latest feature list of what's in and what's out of the next version of the JDK.
An update on the latest news around JavaFX including the 1.2 release and the general availability of JavaFX Mobile for Windows Mobile devices.
JSFest 2019: Technology agnostic microservices at SPA frontendVlad Fedosov
We'll go through the possible ways to bring technology agnostic microservice architecture to the frontend, review pros/cons of each of them. We also will check the "ultimate solution" that handles microservices with SSR in SPA manner.
This talk will be interesting for ones who have multiple teams working on the same frontend application.
We'll go through the possible ways to bring technology agnostic microservice architecture to the frontend, review pros/cons of each of them. We also will check the "ultimate solution" that handles microservices with SSR in SPA manner.
This talk will be interesting for ones who have multiple teams working on the same frontend application.
original (better quality) on https://docs.google.com/presentation/d/1bnwj8CrFGo5KekONYSeIHySdkoXZiewJxkHcZjXnzkQ/
slides from OpenDaylight Summit Oct 2016 Seattle
Agenda
Setting up an angular app.
Introduction to tools - Babel, Webpack
Alternative to Gulp, Grunt & Bower.
Writing Controllers, Services, Directives etc..
Testing Javascript with Jasmine.
Setting up Karma with Webpack.
Let’s understand code coverage.
An alternative: JEST
Writing NodeJS applications is an easy task for JavaScript developers. However, getting what is happening under the hood in NodeJS may be intimidating, but understanding it is vital for web developers.
Indeed, when you try to learn NodeJS, most tutorials are about the NodeJS ecosystem like Express, Socket.IO, PassportJS. It is really rare to see some tutorials about the NodeJS runtime itself.
By this meetup, I want to spot the light on some advanced NodeJS topics so as to help developers answering questions an experienced NodeJS developer is expected to answer. Understanding these topics is essential to make you a much more desirable developer. I want to explore several topics including the famous event-loop along with NodeJS Module Patterns and how dependencies actually work in NodeJS.
I hope that this meetup would help you to be more comfortable understanding advanced code written in NodeJS.
What we can expect from Java 9 by Ivan KrylovJ On The Beach
Java 9 is currently scheduled to become generally available in less then 1 year. Perhaps now is a good time to have a closer look at language proposals and API changes in Java 9. There are over 70 proposals targeted to Java 9, we will have a looks at some key ones, starting with java modularity. We will look at some breaking changes and ways to develop both short and long term solutions for adoption of new upcoming version of Java.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Mind map of terminologies used in context of Generative AI
Dynamic Groovy Edges
1. 1
Managing Change and Achieving
Regression Isolation
Dynamic Groovy Edges
May 21st, 2012
Prepared for:
Triangle Java User’s Group (TriJUG)
2. 2
Who Am I? Well…
Java Architect with ICF Ironworks
Adjunct Professor
Started with HTML and Lotus Notes in 1992
• In the interim there was C, C++, VB, Lotus Script, PERL, LabVIEW,
etc.
Not so much an Early Adopter as much as a Fast Follower of Java
Technologies
• Learned Java 1.1 in 1997, J2EE in 1999
Alphabet Soup (MCSE, ICAAD, ICASA, SCJP, SCJD, PMP, CSM)
LinkedIn: http://www.linkedin.com/in/iamjimmyray
Blog: http://jimmyraywv.blogspot.com/ Avoiding Tech-sand
4. 4
JEE Application Architecture
Arranged into layers
When there are N layers:
• There are N-1 layer junctions
• There are (N-1) X 2 layer edges
In this diagram there are three
layers, two layer junctions, and four
layer edges.
We
control
edges
5. 5
The Issue with Layers
Often written by someone else
• You often have little control or influence over the implementation of the
layer to which you must integrate
• You control your side (edge) of the interface junction
Notorious change zones
• Changes occur at different paces
6. 6
Keeping Up the Pace
Pace Layering Approach to Application Design
• http://www.doozer.com/developer-exchange/entry/accelerating-innovation-
by-adopting-a-pace-layered-application-strategy
Complex systems can be decomposed into multiple layers, where the layers change at different
rates. The “fast layers” learn, absorb shocks and get attention; the “slow layers” remember,
constrain and have power. One of the implications of this model is that information architects can
do what they have always done–slow, deep, rich work; while tagging can spin madly on the
surface. If it is worth keeping, it will seep down into the lower layers. – Donna Maurer
7. 7
When Layers Change
In Java web applications, regression analysis and testing are
usually tied to the boundaries of the application or deployment
artifacts: JARs, WARs, EARS etc.
• Upstream and downstream dependencies also come into play
• Not to be confused with functional testing of changed components
If you redeploy the entire WAR or EAR, you could find yourself
testing that entire application boundary.
• As well as its integration junctions (critical patches not withstanding)
8. 8
Detecting Changes
How do we detect changes to web services as soon as possible?
• XMLUnit/JUnit Tests
• Easily written in Groovy
• Hudson scheduled Ant tasks
DIFFERENCE CODE:19:CHILD_NODELIST_LENGTH_ID:Comparing 2 nodes with different
numbers of children
Control(prod) Node: <xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element minOccurs="0" name="address" type="tns:address"/>
<xs:element minOccurs="0" name="employeeId" type="xs:string"/>
<xs:element minOccurs="0" name="hireDate" type="xs:dateTime"/>
</xs:sequence>
Target(dev) Node: <xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element minOccurs="0" name="address" type="tns:address"/>
<xs:element minOccurs="0" name="department" type="tns:department"/>
<xs:element minOccurs="0" name="employeeId" type="xs:string"/>
<xs:element minOccurs="0" name="hireDate" type="xs:dateTime"/>
</xs:sequence>
10. 10
CI Using Groovy XmlUnit Tests
Wrap Groovy script with Ant
Execute in Hudson build
Use Gradle with the Groovy Plugin
• Run your Groovy test within Gradle build
11. 11
Managing Change
How do we better manage the change between the layers?
• Understand that we cannot stop change
• Reduce regression testing needs by shrinking regression boundaries
• Prepare our teams for the changes with more dynamic reaction
techniques
• Start with Groovy beans
• Or…Start with Java beans and move to Groovy as needed
• Detect changes as early as possible, and before they impact
downstream systems
12. 12
Groovy Edges
Build your edges with Groovy (or other dynamic
JVM language) objects
• Groovy can be written as a script and parsed at run-
time and compiled into Java byte-code and then
loaded by the Groovy class loader.
• Groovy scripts can contain Groovy and Java syntax
in the script file (*.groovy).
• Groovy can use the same Java APIs that are used
by traditional Java code.
• Groovy adds features that make it easier to work
with XML (primary language of choice for most
integrations)
• Markup Builder
• XML Slurper
13. 13
Groovy Markup Builder
Allows developers to use “builder patterns” to construct XML
def writer = new StringWriter();
def xml = new MarkupBuilder(writer);
xml.'ser:writeEmployee'('xmlns:ser':"http://service.rjug.ironworks.com/"){
employee{
dateOfBirth(emsRequest.getEmployee().getDateOfBirth())
firstName(emsRequest.getEmployee().getFirstName())
lastName(emsRequest.getEmployee().getLastName())
middleName(emsRequest.getEmployee().getMiddleName())
employeeId(emsRequest.getEmployee().getEmployeeId())
hireDate(emsRequest.getEmployee().getHireDate())
address{
addressLine1(emsRequest.getEmployee().getAddress().getAddressLine1())
…
14. 14
A Word About Hard-Coding (or not)
When is hard-coding not really?
• Our internal beliefs have shifted slightly.
How about when it is in Groovy?
• Especially when that Groovy is treated as content and not part of a
rigid deployment architecture?
• Still have to work within the boundaries (constraints) of the JVM
15. 15
Groovy XML Slurper
Groovy construct for efficient partial XML processing.
EmployeeManagerServiceResponse emsResponse = new EmployeeManagerServiceResponse();
GPathResult response;
try{
response = new XmlSlurper().parseText(rawResponse.getWriter().toString());
emsResponse.getEmployee().setFirstName(response.'return'.firstName.text());
emsResponse.getEmployee().setLastName(response.'return'.lastName.text());
…
17. 17
A Word About Groovy Slurping XML Payloads
No longer tied to JAXB
• This is uncomfortable for some traditional Java developers
Can use Groovy closures on collections (even nested collections)
Easy to enable/disable getter calls, especially if Groovy is stored
outside of rigid deployment structure (CMS, Apache, etc.)
• This is scary to some
• Still requires Configuration Management rigor
• It’s about risk tolerance
• It could be that this approach is better suited for non-production
environments within certain organizations
18. 18
Groovy XML Slurper Trade-offs
Use the Groovy XML Slurper when you do not have to parse the
entire XML
• Slurper uses paths expressions as apposed to constructing a DOM
• Path expression might be executed multiple times
• Could be slower in larger, more complex XML
There are also differences when editing XML
• The XML Parser allows for edits inline
• The XML Slurper would require another “slurp” after changes are
applied.
The XML Slurper is well suited for simple web service clients
• Allows direct access via getters to “return” object graph
19. 19
Groovy Edge Component – Web Service Client
For SOA interfaces implemented with web services, web service
clients are primarily the target edge component for dynamic
updating.
Using Groovy to write these web services clients makes it easier to
update clients.
• Features can be added or removed and quickly “redeployed” via
content changes, and not necessarily Java deployments
Spring will reload the Groovy web service client when it changes
This provides a great solution for prototyping in an Agile
environment.
For MVC containers, the controller is the edge component that is
up for “Groovy-enizing”, “Groovy-ization”, etc.
22. 22
Loading Properties
<!-- Read service related properties from the classpath -->
<bean id="services.propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlacehold
erConfigurer">
<property name="location">
<value>http://localhost/properties/service.properties</value>
</property>
</bean>
23. 23
Demo – Web Services Provider
Simple JAX-WS Bottom-up web service
Environment:
• Apache2.2
• Tomcat 6.0.35
• Java 1.6 JRE
• JAX-WS RI 2.2
• JAXB 2.2.3
• SoapUI 4.0.0
• Spring Data Layer – MongoDB Data Repository
• MongoDB NoSQL Database (Upcoming TriJUG Event: 07/16/12 Deep
Mistry Mongo DB)
24. 24
Demo – Web Services Consumer
Simple Spring WS Client
Environment:
• Apache2.2
• Tomcat 6.0.35
• Java 1.6 JRE
• Spring Framework 3.0.x
• Spring WS
• Groovy Web Services Framework
25. 25
This Is Not Bleeding Edge
Yet, it is still new to a lot of Spring users
January 2009: http://www.ibm.com/developerworks/java/library/j-
groovierspring2/index.html
At the NVSS NFJS conference in Reston in April 2012, there were
still sessions on Spring and Groovy integration with dynamic beans
• NFJS Due in Raleigh, NC – August 24-26
• http://www.nofluffjuststuff.com/home/main
26. 26
Spring Bean Configuration Issues
Spring needs to be able to locate Groovy script content in order to
load configurations.
ERROR - ContextLoader.initWebApplicationContext(220) | Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'employeeManagerService' defined in file
[C:Toolsapache-tomcat-6.0.16w
ebappsDynamicGroovyTutorialWEB-INFclassescontextservice_ws.xml]:
Cannot resolve reference to bean 'employeeManagerServiceImpl' while
setting bean property
'groovyImpl';
27. 27
Spring Bean Config With Content Proxy
Use a Content Proxy
• The Content Proxy is deployed into a separate WAR and addressable
via a URL (perhaps a RESTful web service) that would retrieve the
dynamic Spring Bean configuration scripts
• If the scripts are not found in script repository, the Content Proxy can load
the scripts from a backup site or even from inside the application boundaries
– Default Location.
• The Content Proxy is a layer of indirection to better manage the link
between your Spring application and the content management system that
you may be using.
• Content Proxies are also very helpful when scripts (or other content) are
loaded from a CMS through an API that would not link directly to the Spring
Bean configurator.
• Provides a layer of indirection and intelligence for Cache Forward
Architectures.
28. 28
Avoiding the Race Condition
Using a ServletContextListener allows you to specify how long the
application will try to seek the ContentProxy (or other URLs) in
other WARs that still may be spinning-up, before it lets the rest of
the application load.
• Reduces the “race-condition” introduced by URLs across multiple
WARs
30. 30
Inline Groovy – You can, but why would you?
package com.ironworks.framework.scripting;
import org.springframework.core.io.ResourceLoader;
import org.springframework.scripting.ScriptSource;
import org.springframework.scripting.support.*;
public class URLScriptFactoryPostProcessor extends ScriptFactoryPostProcessor{
@Override
protected ScriptSource convertToScriptSource(String beanName,
String scriptSourceLocator, ResourceLoader resourceLoader) {
if (scriptSourceLocator.startsWith(INLINE_SCRIPT_PREFIX)) {
return new StaticScriptSource(
scriptSourceLocator.substring(INLINE_SCRIPT_PREFIX.length()), beanName);
}
else if (scriptSourceLocator.startsWith("classpath")) {
return new
ResourceScriptSource(resourceLoader.getResource(scriptSourceLocator));
}
else{
return new URLScriptSource(resourceLoader.getResource(scriptSourceLocator));
}
}
}
31. 31
Spring Bean Delegating Construct
Use a Spring Bean Delegate construct as an alternative to
ServletContextListener and ContentProxy for handling potentially
unreliable or dynamic URLs during application startup
Deploy JAXB version of services, but leave them open to
replacement by Groovy, without needing another deployment
• Still able to use Dynamic Groovy Edges, if JAXB version of service
client requires updating
<bean id="iw_service.getData" class="com.ironworks.vdc.framework.service.DelegatingService">
<property name="delegates">
<list>
<ref bean="iw_service.getDataGroovy" />
<ref bean="iw_service.getDataJaxb" />
</list>
</property>
</bean>
32. 32
Spring Bean Delegate Construct Code
public final class DelegatingService<REQUEST extends ServiceRequest, RESPONSE extends
ServiceResponse>
implements Service<REQUEST, RESPONSE> {
private List<Service<REQUEST, RESPONSE>> delegates =
new ArrayList<Service<REQUEST, RESPONSE>>();
@Override
public RESPONSE execute(final REQUEST request) {
for (Service<REQUEST, RESPONSE> service : delegates) {
if (!(service instanceof AvailabilityStatus)
|| ((AvailabilityStatus) service).isAvailable()) {
return service.execute(request);
}
} throw new UnsupportedOperationException(
"No service implementation available to execute request");
}
public void setDelegates(final List<Service<REQUEST, RESPONSE>> delegates) {
this.delegates = delegates;
}
}
33. 33
AvailabilityStatus Interface
public interface AvailabilityStatus {
/**
* Indicate whether this service instance is available.
*
* @return true if the service is available, false otherwise.
*/
boolean isAvailable();
}
34. 34
Spring Delegate Construct Code Explanation
DelegatingService is substituted into the class attribute of the bean
definition
Possible “delegates” are added to the property list as objects
DelegatingService looks for viable services in the list of “delegates”
• Could be services that implement the AvailabilityStatus interface, and
are available (isAvailable())
• Beans that implement AvailabilityStatus, but are not available our by-passed
– This allows Groovy substitutes to be enabled/disabled quickly
• Could be services that do not implement AvailabilityStatus
35. 35
Some Tradeoffs for Groovy Approach
Groovy Web Clients
• Pros
• Easier to program with Getters and Setters approach to accessing and
mutating XML objects for request and response
• Markup Builder
• XML Slurper
• Cons
• Lose auto-generation of object graphs via JAXB
• Lose tighter integration to WSDL/XSD and makes it harder to track down
changes.
• It’s not for every change…more complex WSDLs, possibly with nested
object architectures, would not be good candidates for Groovy re-write
36. 36
What About All Those Classes?
Almost every technical decision comes with a trade off…
When using dynamic Groovy with the approach we have outlined,
obviously we are generating more “non-setup”, Groovy classes in
the JVM.
• Every time Spring detects a changed script, Groovy will parse it and
load another class.
• Depending on your JVM, GC settings and JVM memory settings, you
could experience OOM issues with PermGen
37. 37
Does Your JVM Have a PermGen?
IBM: No PermGen, classes exist in the native C-Heap
Oracle/WebLogic JRockit: No PermGen, classes exist in the
native C-Heap
Oracle/Sun Hotspot: Yes, PermGen in Java Heap
• Prior to Java 5, the Hotspot JVM assumed that classes were forever
• Then came CMS (Concurrent Mark Sweep) class unloading settings
38. 38
What Can We Do With PermGen?
Use GC settings for the CMS Collector
• Java 1.6: -XX:+CMSClassUnloadingEnabled
• Java 1.5: -XX:+CMSPermGenSweepingEnabled
Both require CMS GC enabled
• This may not be suitable for all applications
Increase size (not really desirable)
• Switch to 64 bit, if you have not already
Increase JVM bounce frequency (not really desirable)
• Not really a good long term strategy
39. 39
Don’t Use PermGen.
Some of our projects use JRockit
• While we do not see the same sensitivity to PermGen in our dynamic
environment, occasionally we still see issues with class memory areas
• Mostly in non-production environments where we tend to be more
dynamic
Problem: JRockit does not exist beyond Java 7
• Oracle has announced that it is being merged with Hotspot in Java 7
40. 40
Use Java 7?
In Java 7, PermGen is supposed to go away over time.
• This implies better class unloading and memory management
• JRockit merges with Hotspot
• When?
• http://javaeesupportpatterns.blogspot.com/2011/10/java-7-features-
permgen-removal.html
• http://blogs.oracle.com/java/entry/java_7_questions_answers
41. 41
Groovy Spring MVC Controllers
Spring MVC controllers are another example of edge components
that could benefit from more dynamic deployment and less rigid
deployment structures
• Remember: Just because it is marked as Groovy (*.groovy) does not
preclude you from writing some Java
<lang:groovy id="claimsController" script-source="${groovyClaimsController}" refresh-check-
delay="1000" >
<lang:property name="view" value="claim_summary"/>
<lang:property name="detailView" value="claim_detail"/>
<lang:property name="unsolicitedView" value="claim_unsolicited"/>
<lang:property name="errorView" value="claim_error"/>
<lang:property name="serviceDownView" value="claim_service_down"/>
</lang:groovy>>
43. 43
Summary
We cannot control changes in layers beyond our influence or
control
We can better prepare for change by using dynamic technologies
in the edges of interface junctions.
• Groovy blurs the once clear line between hard coding and properties
configurations.
• By using Spring to dynamically load Groovy scripts, stored outside of
web applications, web applications can narrow regression boundaries
by reducing the need to deploy EARs and WARs.
• The Content Proxy provides a layer of indirection that smoothes the
process for locating dynamic scripts an providing digestible data for the
Spring Bean Configuration process.
• Testing WSDL and XSD artifacts with XMLUnit provides early warning
of web service changes and failures
44. 44
Special Thanks To:
Laith Al-Samir – ICF Ironworks
• Spring WS application and Groovy WS Client
Mike Killeen – ICF Ironworks
• Groovy/XMLUnit/JUnit WSDL/XSD tests
Vince Jorrand – ICF Ironworks
• Spring Bean Delegates Construct