Simplistic view of Spring

What is Spring?

TO bare minimum Spring is
Lightweight - Non-intrusive to your applications
Dependency Injection
Aspect-Oriented
Container - configuration and Management of lifecycle of Application objects
Framework - compose complex applications from simple components

What are spring modules? and why its there?

On top of these 6features, spring provides ready made modules to easy development. Otherwise if this is not something you are after you can plug-in/configure your own modules. Also Spring provides integration points to plugin other modules e.g. Hibernate

 Spring framework is made up of six modules
  1. Core Spring cotainer
  2. DataAccess & integration
  3. AOP
  4. Testing
  5. Web and Remoting
  6. Instrumentation

(Image take from Spring in Action Ed 3MEAP, first chapter available on Manning website)

What is Spring Core?

- Spring Core is made up of BeanFactory and ApplicationContext

- BeanFactory provides configures and manages bean instances using DI

- Application Context provides a way to configure Spring.

- Spring supports several implementations,

What is Data Access and Integration?

Spring doesnt have any ORM on its own, it just has Spring JDBC (core class JDBCTemplate)
It provides integration points with tools like Hibernate

What is web and remoting module?

Spring provides Spring MVC and Spring Portlet for web

Also supports Struts like frameworks...

Remoting has support for RMI and JAX-WS (contract first approach)

Jax-ws and Jboss


Jboss supports JAX-WS in 3 flavours.

# native - which is jboss proprietary implementation for jax-ws. It comes default with jboss5.0.0GA.

# apache CXF - this supports Jax-ws implementation which apache provides. This isnt Axis, Axis is something parallel to JAX-WS itself.

# metro stack - Jboss supports this as well, its a dedicated Metro only implementation. You get separate download for it, change JBOSS-HOME and other properties. Run a build script, and thats it. It adds stuff in Jboss directory and ready for work.

Thats it for now, its friday afternoon
Jai Ho

REST is not rest.


REST Services RS is just another way of representing web services, and its not just rest other than SOAP-WS.

What is it?
Its a full fledged service no less than any other computational system or to that matter its sister SOAP-WS. RS represnts a state of some resource at service side and upon request it changes the state and transfers that state to client, but resource remains.

So whats resource?
It can be anything and evrything you think of in the business context, e.g. You access Sydney's weather on weatherzone.com.au or it may be list from yahoo shoping.

Whats request? And how can i change state of the resource on service side?
A request should have 2 parts; HTTP method / VERB and actual parameters that can be a query string or a raw XML.
# if you want list it 'll be GET and query string with ? Followed by name-val pair.
# if want to change/add something POST and raw XML in HTTP request
Likewise there can be PUT for update, DELETE for delete function.

And response?
- Response is raw xml

What is JAX-RS?
- its java api for RS, nothing greek here. To implement few things are diff
# @WebServiceProvider
# @BindingType - HTTP
# @ServiceMode for just payload or whole message.
# Also to send and receive xml, you can use XmlEncode and XmlDecode.
# one more caution about exceptional handling it emits Http status code.

more on RS later...Till then..

Jai Ho

Refactoring code - big deal !

what is it really?
Just to simplify code so that its easy to understand and maintain.

But why its required any way?
I think, i am writing code which is easy to maintain and understand. So is it a myth? Ans is NO...
you write a code as per well designed abstractions and objects, but change to existing code makes software design to decay. Once that starts happening, you need to start to refactor code in small bursts. that way you will save code, design and most importantly time of any coder who will work on it.

Whats most visible difference that makes?
You would become more efficient developer as you would do things quickly over period of time and Your code will be less buggy. But that sounds counterproductive, since you have to devote time to refactor other than dev time. Yes, All good things take sometime to work, so it is.

When should i do it?
when i am
# add/changing new method
# fixing a defect
# dont understand some code

Are there any troubles?
# watch while changing interfaces methods, if its public or published its not easy to refactor
# watch for thrown exceptions

how can i quickly locate places in code that needs refactoring?
Those pointers will be in next post...

Until then...Jai ho..

Design pearls

Head first design pattern is a must must READ. Some of the principles are
# Encapsulate that varies.
# Every class has single responsibility to change.
# Keep interacting objects loosely coupled.
# Favour composition over inheritance. If required, inheritance should be used for type hierarchy and not behaviour.
# Use abstractions instead of concrete classes.
# Classes should be open for extension and closed for modification. This minimizes any changes to existing code / class hierarchy and new classes designed for changes. Decorator Pattern uses this principle, for example famous java IO API's.
More principles next time. Until then...
Jai ho.

SoapUI vs junit

Junit is a good option to quickly have unit tests ready, simply by adding custom 'test' target and add <junit> task inside, put whatever classes you want to test, thats it. For java, or pojo's this works best.

However for WebServices soapUI is a simpler option with ui based tests that can be done very quickly. It many features including invalid payloads etc, but you cant configure your real client like situation in soapUI, e.g. Jax-ws based client. It targets to have more interoperable env to test for your service.
In any case, you can always use soapUI to quickly devise and run tests. Later you can create jaxws client from WSDL and write junit for your service.

Jai ho

Google io keynote

Today i watched google IO keynote. I think its history by now, but it was a worth watch. About whats happening in web and google/browser world.
few highlights
1. HTML5 is much powerful with tags like canvas and video for 2D and 3D rendering using browser ONLY.
2. Tried these APIs with eclipse plugin.
Google webtool kit
Google appengine
App engine has got amazing features to manage webapps from your own ISP or from appspot.com. These services are almost free.
3. Google web elements
Jai ho

First blog via mobile

Check this...

Vista SP2 update

Tried to install SP2 on vista business. No surprise, its failed, and failing. Searched the net, found advise that hold on, hold on until MS pushes it for autoupdate. Hopefully somebody finds this blog useful and should avoid to waste few hours of their lives.

Step 1: After first failure, tried to do this with various combinations and painstakingly (re)starting numerous times. It was failing for "error code 490" when i try to install sp,

Step 2: Also tried this,
I've registered to post a potential solution: (At least that worked for me)
1.Make sure that your Windows clock's time is correct.
2.Go to the Start menu, Type Cmd in the search box, Right-click the CMD shortcut & select Run as administrator
Type the following command and press enter:
slmgr.vbs -rearm
Please wait about 1 minute and don't re enter the command. You should receive a message dialog.
Then, Just restart the computer and run the SP2 setup once again. Should work.

Finally found this advice
Susan Bradley recommended that you hold off on installing Vista SP2. Microsoft hasn't yet begun to push out the service pack via its Automatic Updates service.

so just hold yourself..


Eclipse 3.5 command line startup

Recently installed latest Eclipse Galileo and found my old eclipse 3.2 startup script is no more working. There are changes jar file and Main class
  1. C:\JavaDev\eclipse\plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
  2. org.eclipse.equinox.launcher.Main
In post eclipse3.2, they have started using equinox launcher.

start C:\JavaDev\jdk1.6.0_13\bin\javaw.exe -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -cp C:\JavaDev\eclipse\plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar org.eclipse.equinox.launcher.Main -os win32 -ws win32 -arch x86 -exitdata "C:\JavaDev\eclipse\eclipse.exe -exitdata c8_2c" -showlocation -data "%1" -clean -vm C:\JavaDev\jdk1.6.0_13\bin\java.exe -vmargs -Xmx1024M -cp C:\JavaDev\eclipse\plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar org.eclipse.equinox.launcher.Main


Edit [11Jun2012]

For eclipse Indigo
These are my latest arguments, which I save as startupEclipse.bat and run from work-space directory


start c:\JavaDev\java7\bin\javaw.exe -Xms32m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -cp C:\JavaDev\eclipse\plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -os win32 -ws win32 -arch x86 -exitdata "C:\JavaDev\eclipse\eclipse.exe -exitdata c8_2c" -showlocation -data "%1" -clean -vm C:\JavaDev\java7\bin\java.exe -vmargs -Xmx1024M -cp C:\JavaDev\eclipse\plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main

My Notes - SOA for Dummies Part 10

PART III Sustenance
All about other aspects of SOA like governance, security

Chapter 11: SOA Governance
-          SOA governance has clear impact on IT governance of the organisation.  IT governance is about managing IT of an individual department and managing IT across departments.
-          From implementation perspective SOA governance is a combination of policy, process and metadata of the component
-          SOA governance is more about how business units interacts involving SOA services, people in order to achieve business goals.
-          IT governance is about building business services where rules and process are correctly implemented; this is more targeted towards the reuse of services organization wide.
-          It is hard to convert or codify business requirements into services, and that’s about IT governance is.  These requirements are implemented by SOA services.  This is a how IT and SOA are related. 
-          As requirements keep changing, business processes and rules keep on updating, and so the IT governance is.  As SOA is an implementation of this IT governance, it has to accommodate all such change i.e. to remain dynamic.
-          SOA governance steps – organisation wide
o   Setup a board – to verify the business processes are followed correctly
o   Setup implementation standards across the board e.g. common technologies
o   Setup IT SOA governance Best practices – towards reuse of services across organisation, like service names, impact analysis, remedy action standards
o   Monitor the life-cycle services – bread-butter services for organisation, make it fail-safe and performance improvement
-          IT of an organisation expects from SOA
o   Modular design, standardization of webservice interfaces
o   Dependent webservices, reliable access, verification of quality and integrity of service and security
o   Track and report on results and service improvement
o   Well documented process on how regulations followed by services
-          Focus and object of SOA governance is:  to identify the services business needs and to conduct predictable and accurate those services. Also to maintain quality of service. 
-          Without SOA governance, SOA will not be trusted as a business computing model.

My Notes - SOA for Dummies Part 9

Chapter 10: The SOA supervisor
-           SOA is all about plumbing legacy applications and IT (Connecting business and IT).
-          Plumbing service:
o   Availability for life and death services for an organization
o   Response times and customer satisfaction
o   Business service mgmt
§  Monitoring service level
§  Identify faults and failures
§  Fault mgmt
§  Automate provisioning / remedial action
§  Performance modelling and optimization
§  Reporting
      
               The SOA Supervisor
o   SOA supervisor can also have Service Level Agreement Monitoring, which just monitors all good and happening as per deal.   SLA monitoring connected to adapters in order to monitor. If any bad is reported SLA monitoring informs SOA supervisor to take care by remedial action.
o   However this is solution is still not implemented all SOA and it’s ideal to have in your SOA implementation.

My Notes - SOA for Dummies Part 8

Chapter 9: The Enterprise Service Bus
As  evolved from Enterprise Application Integration (EAI), ESB ensures the different components / applications work together dynamically.
-          Broad level functions
o   Messaging service – transporting messages, reliable communications
o   Management services – apply and monitor service level and own performance rules, handling messages priorities, apply global business rules.
o   Interface service – validates messages against the schema
o   Mediation service – sends and converts messages between 2 connecting apps.  This can be part of SOA Service Broker.
o   Metadata Service – transforms data as per source and destinations apps. E.g. definition of Customer can be different for each connecting app.  ESB handles it either by storing that definition locally using light-weight registry or external registry.
o   Security, encryption for communication.  Authentication, authorization, privacy, data integrity, audit are goals of security.  ESB doesn’t implement any security, however facilitates pluggable security.  It is a type of mediation service. SOA Service Broker has this responsibility.

-          Core services ESB offers is messaging and management service, all other service can be duplicated, like interface service, which can be offered by other SOA layers.  As ESB is more generic and needs to stand on its own, so the duplication.

Types of messaging
-         
            Point-to-point – No response expected, message just sent
-          Point-to-point request/response – Transaction not complete until response is received by sender
-          Broadcast – Broadcasts messages to multiple receivers, no response expected
-          Broadcast request/response – only difference from above is that, transaction isn’t complete until all responses received for requests sent.
-          Publish/subscribe – Messages received by those who subscribe to receive the messages published at agreed place.               
-          Store/forward – if recipient doesn’t get sent messages, this type will store messages and forwards once receiver becomes online.

-          Runtime ESB - ESB doesn’t run as an island. It keeps things loose and increases reliability and predictability for connection services.




My Notes - SOA for Dummies Part 7



Chapter 8: The Registry and the Broker
-          SOA Registry key functionality
o   Publish webservices and enable their discovery
o   Collect and maintain metadata about webservices
o   Govern webservice usage
-          What is metadata
o   Data to describe the webservices
o   Business rules
o   Rules used to access those WS.
-          Brokering Services
o   It’s about finding services and connecting consumer service and producer service as per the rules specified policy engine (visualize as a component of the registry) to invoke target service.
o   In order to achieve this, services must be published to registry.
-          Registry – what’s inside?
o   Webservices component description – Rules about the service itself, follows UDDI standard
o   Legacy component description – if webservice is a legacy service, rules that govern to invoke such service
o   Business process definition – Holds a map of complete business process in order to orchestrate the services invocation in a given business process.   It’s broader than just webservices.
o   Business process rules – Rules that applies business process wide, like security it is another webservice component in itself.
o   Performance rules – what are the performance requirements in order to invoke the service at the outset.  ( SOA supervisor does same at runtime)
o   Governance rules – to handle change management of contents of registry like webservices rules



-          Service Broker – What it does? – It works with Service Registry and connects all services needed and uses information stored in registry to invoke the business process.    So how it does this?

  • When application is requested, broker gets notification.
  •    Consults registry, what needs to be done and whether it can be invoked at this time.
  • Broker checks
  • All components are working and if not it starts them.
  • Interfaces between components and what information those interfaces need to know, as all adapters get connected to execute requested business process.
  • If any rules associated with the connection between components (or adapters).  So components get them from Rules Engine associated with registry.
  • Based on rules if required, broker checks and gets the connection with other components.



        

My Notes - SOA for Dummies Part 6


Chapter 7: Dealing with Adapters
-          Why they are important?  How they came into existence? 
-          But you should have one if you have an application or business process that gets called by webservice.  It’s done in registry and the changes to actual implementation are transparent to adapters.  

-          These days many vendor softwares like SAP or BPM softwares comes with ready adapters or can build while you are constructing your business process.  At a technical level to write an adapter you need a source code of actual implementation which executes the resultant functionality, so that you are customize how adapter communicates with outer world.

My Notes - SOA for Dummies Part 5

Wednesday, 18 February 2009

Chapter 6: Xplicating XML

Here author talks about XML and how different forms of XML used in the SOA.   These forms include XML for actual data, XSD for metadata, WSDL for webservice description, SOAP for message transport.  

My Notes - SOA for Dummies Part 4

Chapter 5: Loose coupling and Federation

Loose Coupling

-          Old applications were tightly coupled and were executed and maintained as huge chunk of code, which is hard to maintain and change.

-          Loosely coupled applications are independent of each other in terms of execution, so can be replaced without affecting others.

-          Such loosely coupled applications can be tightly coupled by themselves, that tight coupling is among the subcomponents it has.

-          Other advantages can be

o   Create new applications easily by assembling such discrete services/applications

o   Create secured business applications quickly, as security can be another independent service itself which can be hooked with other services.

o   Isolate problems easily, to locate failures, easy to test.

o   Such services can be reused and can be sold separately to other applications

Licensing

-          Licensing has been changed to one perpetual license to subscription based, for services used.  SOA services can be licensed in similar fashion.  Different applications/domains have different ways to do it.

-          How licensing and charging such services be different? Like some financial services can be charged per transaction.

Federation

-          It’s about governing policies,

-          Services has some set of policies which are used application / companywide (imagine federal government) and these policies can have local flavour per each department, which is more domain specific for the environment in which those services will operate (imagine state government). 

-          So Federation is used to solve integration issues.  In other words changing global policies to suit local needs, so that integration can be easy.

SOA and Federation

-          Federation is implemented using SOA registries, where application-wide or global policies are in SOA registry, which is treated as parent registry by other domain specific registries.

-          Every domain (or department) will have its individual registry which inherits from global policies and also includes domain specific policy.

-          Security can be one of the global policies.

-          Domain is defined by SOA registry and SOA broker.  And other SOA components can be shared across domains.

My Notes - SOA for Dummies Part 3

PART II - Nitty – Gritty SOA

Chapter 4: SOA Sophistication – Pieces of SOA

-          ESB – Enterprise Service Bus is a communication channel for all SOA services.  One SOA Service sends messages and receives messages to and from other SOA services.  All this is done using ESB.  It’s an end-to-end communication. 

-          SOA Registry – It is an electronic catalogue for all services.  It maintains operational information about services to call each other and metadata information, what that service is all about input/output messages, which can be used programmers.  Important function of registry is to publish services, to make it available for its consumers.

-          BPM – Business process modelling is an end-to-end solution.  This is a more like configuration, where we can specify to carry out specific business functions which different business processes will interact.  End-to-end business processes a.k.a. workflow.

-          Service Broker – This is a runtime component, for BPM, which can actually find services and connect for a business process.

-          SOA Supervisor – Just monitors all processes by using reports generated by monitor agents (these are initialized by service brokers), this enables SOA supervisor to know current state of processes.  This is just like traffic police to make sure everything flowing smoothly.

-          SOA Plumbing – These are adapters which sit in between existing legacy code and bus

BPM Tool

-          Important functions

o   Creates Business functions

o   Links in Individual functions to Business applications.  Also links Business apps together

o   (publishes) adds and refers services registered in SOA Registry

o   Programs for workflow engine.

- Availability of services at all levels should be 99.999%

My Notes - SOA for Dummies Part 2

Chapter 3

-          This is generic information so far

-          Starting with Components, and code reusability, how it can be done, how it was restricted to individual developers, customers, applications.  When such components tried to interact had issues of interoperability

-          When internet started it was just static pages, as it evolved specifications and protocol developed around technological aspect HTML, XML, Browsers.  This further extended to use such component based systems to interact over Internet. 

-          This gave birth to webservices which posed challenges over connectivity and sharing data, where XML, WSDL and SOAP protocols were developed as standards

-          As webservices are used more by business, all such business process confined in one boundary earlier, there was need of making such processes accessible online thru internet.  Such that it can be accessed by other businesses.

-          Business Processes:

o   For any business there are set of processes and sub-processes are required to carry out to carry out day to day business functions.   Generally it may need manual intervention and application systems.  Stringing together such function of a business function is called business process. And SOA can do such stringing activity of manual functions and application functions and the process management to carry out business process.

o   From SOA perspective, business processes includes people, those business process itself, implemented as software applications, adapters, and process management.

-          Siloed Applications

o   Existing applications when added with some more components are called as composite applications.

o   Such composite applications (e.g. for one business department) interact with other composite applications interacts directly.  But this interaction can be costly in terms of resources; SOA facilitates such integration with some process management.  However integration is most difficult and crucial part for successful SOA implementation.

o   Application silos are applications which are constrained for individual business departments or functions.  Are not built for use by other business functions.  Such systems have two issues inconsistent data definitions and process duplication.

-          How SOA helps?

o   SOA just work with these application silos as it is, avoiding manual work required to talk to different silos. 

o   SOA can be done in steps, no need to do all at once and hence no wastage in earlier investments.