javawaveblogs-20

Friday, November 30, 2007

Comparing two Value Objects in Java

In Java comparing two value object is not straight forward. Here we will see how we can compare two value objects in Java.

For that first we will create a value object called "MyValueObject". This value object contains two properties. 1) firstName 2) lastName. Both the properties are of type string.

In the same class we also have a overridden method which does the comparison for us. This method "public boolean equals(Object obj)" takes the properties and compare them individually. if the properties values are all equal then it returns true or it will return false. By doing this our test class will just call the equals method on the object to make sure if the objects are equal or not.

Code is listed below.

/*
*/
package com.blogspot.javawave;

/**
*
* @author dhanago
*/
public class MyValueObject
{

private String firstName;
private String lastName;

/**
* This constructor is used to set the two properties values in the class.
*
* @param firstName
* @param lastName
*/
public MyValueObject(String firstName,
String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}

@Override
public boolean equals(Object obj)
{
boolean isEqual = false;
if (this.getClass() == obj.getClass())
{
MyValueObject myValueObject = (MyValueObject) obj;
if ((myValueObject.firstName).equals(this.firstName) &&
(myValueObject.lastName).equals(this.lastName))
{
isEqual = true;
}
}

return isEqual;
}
}

Test class is given below:

/*
*/
package com.blogspot.javawave;

/**
*This class is used to test compare the value object.
*
* @author dhanago
*/
public class TestCompareValueObject
{

/**
* This is the main method used to test compare the value object.
* @param arg
*/
public static void main(String[] arg)
{
MyValueObject obj1 = new MyValueObject("Muthu", "Kumar");
MyValueObject obj2 = new MyValueObject("Muthu", "Kumar");

if (obj1.equals(obj2))
{
System.out.println("Both the objects are equal");
}
else
{
System.out.println("Both the objects are not equal");
}
}
}

This one of the way we can easily compare the value objects in Java

Tuesday, November 13, 2007

SOA principles

SOA principles

The following guiding principles define the ground rules for development, maintenance, and usage of the SOA[8]

  • Reuse, granularity, modularity, composability, componentization, and interoperability
  • Compliance to standards (both common and industry-specific)
  • Services identification and categorization, provisioning and delivery, and monitoring and tracking

The following specific architectural principles for design and service definition focus on specific themes that influence the intrinsic behaviour of a system and the style of its design:

  • Service Encapsulation - A lot of existing web-services are consolidated to be used under the SOA Architecture. Many a times, such services have not been planned to be under SOA.
  • Service Loose coupling - Services maintain a relationship that minimizes dependencies and only requires that they maintain an awareness of each other
  • Service contract - Services adhere to a communications agreement, as defined collectively by one or more service description documents
  • Service abstraction - Beyond what is described in the service contract, services hide logic from the outside world
  • Service reusability - Logic is divided into services with the intention of promoting reuse
  • Service composability - Collections of services can be coordinated and assembled to form composite services
  • Service autonomy – Services have control over the logic they encapsulate
  • Service optimization – All else equal, high-quality services are generally considered preferable to low-quality ones
  • Service discoverability – Services are designed to be outwardly descriptive so that they can be found and assessed via available discovery mechanisms[9]

In addition, the following factors should also be taken into account when defining a SOA implementation:

  • SOA Reference Architecture covers the SOA Reference Architecture, which provides a worked design of an enterprise-wide SOA implementation with detailed architecture diagrams, component descriptions, detailed requirements, design patterns, opinions about standards, patterns on regulation compliance, standards templates etc.[10]
  • Life cycle management SOA Practitioners Guide Part 3: Introduction to Services Lifecycle introduces the Services Lifecycle and provides a detailed process for services management though the service lifecycle, from inception through to retirement or repurposing of the services. It also contains an appendix that includes organization and governance best practices, templates, comments on key SOA standards, and recommended links for more information.
  • Efficient use of system resources
  • Service maturity and performance
  • EAI Enterprise Application Integration

Friday, November 2, 2007

What is WSDL?

diggthis