Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
@WebService(name="StockQuote",
serviceName="StockQuoteService")
public class StockQuoteImpl {
@WebMethod(operationName="getQuote")
public double getQuote(String ticker) {
double result = 0.0;
if (ticker.equals("MHP")) {
result = 50.0;
} else if (ticker.equals("IBM")) {
result = 83.0;
}
return result;
}
}
Server Ant Target :
<?xml version="1.0"
encoding="UTF-8"?>
<target depends="setup"
name="build-server-java">
<apt debug="${debug}"
destdir="${build.classes.home}"
fork="true"
sourcedestdir="${build.classes.home}"
sourcepath="${basedir}/src"
verbose="${verbose}">
<classpath>
<path
refid="jaxws.classpath"/>
<pathelement
location="${basedir}/src"/>
</classpath>
<option
key="r"
value="${build.home}"/>
<source
dir="${basedir}/src">
<include
name="**/server/*.java"/>
</source>
</apt>
</target>
Client Async Target :
<?xml version="1.0"
encoding="UTF-8"?>
<target depends="setup"
name="generate-client-async">
<wsimport debug="${debug}"
destdir="${build.classes.home}"
extension="${extension}"
keep="${keep}"
verbose="${verbose}"
wsdl="${client.wsdl}">
<binding
dir="${basedir}/etc"
includes="${schema.binding}"/>
<binding
dir="${basedir}/etc"
includes="${client.binding.async}"/>
</wsimport>
</target>
----- Client with Call back
Class
private class GetQuoteCallbackHandler
implements AsyncHandler<GetQuoteResponse>{
private GetQuoteResponse output;
public void handleResponse
(Response<GetQuoteResponse>response)
{
try
{ output =
response.get ();
} catch (ExecutionException
e)
{ e.printStackTrace (); }
catch (InterruptedException e)
{
e.printStackTrace (); }
}
GetQuoteResponse getResponse
(){
return output;
}
}
Client :
StockQuote port
= new StockQuoteService().getStockQuotePort();
GetQuoteCallbackHandler callbackHandler = new
GetQuoteCallbackHandler ();
responseCallback = port.getQuoteAsync
("MHP", callbackHandler);
while( ! responseCallback.isDone()){
//some client side processes
}
result = callbackHandler.getResponse().getReturn();
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.