Implementatation of the Service locator pattern

This commit is contained in:
MSaifAsif
2014-12-06 02:39:54 +05:00
parent 3e42a10060
commit 1cb62f543b
10 changed files with 282 additions and 0 deletions
@@ -0,0 +1,37 @@
package com.iluwater;
/**
* This is a single service implementation of a sample service. This is the actual
* service that will process the request. The reference for this service is to
* be looked upon in the JNDI server that can be set in the web.xml deployment descriptor
* @author saifasif
*
*/
public class ServiceImpl implements Service {
private String serviceName;
private int id;
public ServiceImpl(String serviceName) {
// set the service name
this.serviceName = serviceName;
// Generate a random id to this service object
this.id = (int)Math.floor(Math.random()*1000)+1;
}
@Override
public String getName() {
return serviceName;
}
@Override
public int getId() {
return id;
}
@Override
public void execute() {
System.out.println("Service " + getName() + " is now executing with id " + getId());
}
}