Popular Posts

Thursday, December 13, 2007

Top replies by programmers to testers when their program doesn't work

Found a set of funny replies from Quality Assurance and Testing blog

1. "It works on my machine"
2. "Why do you want to do it that way?"
3. "You can't use that version in your system"
4. "Even though it doesn't work, how does it feel?"
5. "Somebody must have changed my code"
6. "You must have the wrong version"
7. "I haven't touched that module in weeks!!"
8. "There is something funky in your data"
9. "What did you type in wrong to get it to crash?"
10."It worked yesterday"
11."That is not a bug, that was a requirement"

Wednesday, December 12, 2007

Deploying an axis2 service in application scope

If you deploy a service without specifying a scope, it will be considered as sessionless and will be deployed in request session scope. In other words, request scope is the default session scope of an axis2 web service.
When a service is deployed in request session scope, an instance of the service implementation class is created for every invocation. Suppose you want to get rid of that and maintain a single instance of service class throughout the server life time.
Then you should deploy the service in application session scope. Lets see how it can be achieved and tested the service invocation using WSO2 WSAS.

First, create a simple java bean as follows.

public class Employee {

private int Age;
private String name;
private String emp_id;
public int getAge() {
return Age;
}
public void setAge(int age) {
Age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmp_id() {
return emp_id;
}
public void setEmp_id(String emp_id) {
this.emp_id = emp_id;
}
}

Now create the service descriptor (services.xml) for the above class.

<service name="EmployeeService" scope="application">
<messagereceivers>
<messagereceiver mep="http://www.w3.org/2006/01/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver">
<messagereceiver mep="http://www.w3.org/2006/01/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver">
</messagereceiver>
<parameter name="ServiceClass" locked="false">
org.wso2test.Employee
</parameter>
</messagereceiver>

Here, we define the session scope of the service as 'application', which will create a single instance when server is started.

Now, include these in a deployable service archive. (Create a META-INF directory and add the services.xml in there and save the archive as an aar)

Next, deploy the service archive using WSO2 WSAS management console. In the WSAS management console, go to "Services and Service Group Management' page and select 'EmployeeService'. Then click on 'Tryit' to test the service invocation.
The all getter and setter methods of the service class are displayed there. Click on setName and enter a string value in the given text box. You will get a NuLL response since it is an request only invocation. Next, select getName and click on getName button. You will get the name you have set in the previous step.

The above scenario demonstrates the creation of a single service class instance using application scope.