vlc.j2c-service-implementation.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of legstar-jaxws-generator Show documentation
Show all versions of legstar-jaxws-generator Show documentation
Generates adapters and proxies for inbound and outbound mainframe integration with Web Services.
##/////////////////////////////////////////////////////////////////////
##Jaxws Service Adapter implementation Template.
##@author Fady
##/////////////////////////////////////////////////////////////////////
#parse("vlc/j2c-service-common-imports.vm")
## ==================================================================
## Create unique Lists of imports and Types
##
#set($importTypes = [])
#set($jaxbTypes = [])
#foreach ($cixsOperation in $model.cixsOperations)
#getImportTypes(${cixsOperation.getInput()})
#getImportTypes(${cixsOperation.getOutput()})
##
## if operations are in a different package than the service, we
## need to import the operation classes as well
##
#if($cixsOperation.packageName && $cixsOperation.packageName != $model.packageName)
#set($programInvokerType = ${cixsOperation.className} + "ProgramInvoker")
#set($newType = ${helper.getQualClassName(${cixsOperation.packageName}, $programInvokerType)})
#addUnique($importTypes $newType)
#set($newType = ${helper.getQualClassName(${cixsOperation.packageName}, ${cixsOperation.faultType})})
#addUnique($importTypes $newType)
#set($newType = ${helper.getQualClassName(${cixsOperation.packageName}, ${cixsOperation.faultInfoType})})
#addUnique($importTypes $newType)
#end
#end
## ==================================================================
#parse("vlc/j2c-service-common-package.vm")
import java.rmi.server.UID;
import javax.jws.WebService;
import com.legstar.coxb.transform.HostTransformException;
import com.legstar.host.invoke.AbstractServiceAdapter;
import com.legstar.host.invoke.HostInvokerException;
import com.legstar.messaging.LegStarAddress;
#foreach($importType in $importTypes)
import ${importType};
#end
/**
* JAX-WS Service Adapter implementation.
* Each method maps to a CICS program.
*
* This class was generated by ${generatorName}.
*/
@WebService(endpointInterface = "${helper.getQualClassName(${model.packageName}, ${model.interfaceClassName})}",
serviceName = "${wsdlServiceName}",
portName = "${wsdlPortName}",
targetNamespace = "${model.namespace}")
public class ${model.implementationClassName} extends AbstractServiceAdapter implements ${model.interfaceClassName} {
/** Name of this service adapter implementation. */
private static final String SERVICE_ADAPTER_NAME = "${model.name}";
#foreach ($cixsOperation in $model.cixsOperations)
/** Invoker implementation for operation ${cixsOperation.name}. */
private ${cixsOperation.className}ProgramInvoker m${cixsOperation.className}ProgramInvoker;
#end
/** Contructor creates a set of operation invokers. */
public ${model.implementationClassName}() {
super(SERVICE_ADAPTER_NAME);
#foreach ($cixsOperation in $model.cixsOperations)
m${cixsOperation.className}ProgramInvoker = new ${cixsOperation.className}ProgramInvoker(getConfigFileName());
#end
}
#foreach ($cixsOperation in $model.cixsOperations)
/** {@inheritDoc} */
#if($cixsOperation.getOutput().size() > 0)
public $cixsOperation.responseHolderType ${cixsOperation.name}(
#else
public void ${cixsOperation.name}(
#end
#if($cixsOperation.getInput().size() > 0)
final $cixsOperation.requestHolderType request,
#end
final ${model.headerClassName} hostHeader)
throws ${cixsOperation.faultType} {
try {
#if($cixsOperation.getOutput().size() > 0)return#end get${cixsOperation.className}ProgramInvoker().${cixsOperation.name}(
getAddress(hostHeader), getRequestID(hostHeader)#if($cixsOperation.getInput().size() > 0), request#end);
} catch (HostInvokerException e) {
throw get${cixsOperation.faultType}(e, "Failed to invoke host program:");
} catch (HostTransformException e) {
throw get${cixsOperation.faultType}(e, "Failed to transform data:");
}
}
/**
* Formats a fault element to notify client of an exception.
*
* @param e the exception which occurred
* @param text short message describing the context
* @return the fault exception
*/
public ${cixsOperation.faultType} get${cixsOperation.faultType}(
final Exception e, final String text) {
${cixsOperation.faultInfoType} faultInfo = new ${cixsOperation.faultInfoType}();
faultInfo.setMessage(e.getMessage());
faultInfo.setDetail(get${cixsOperation.className}ProgramInvoker().toString());
return new ${cixsOperation.faultType}(text + ' '
+ faultInfo.getMessage(), faultInfo, e);
}
#end
/**
* Extracts header data from SOAP header and create a host address.
* @param hostHeader the java object mapping the SOAP header element
* @return the new host address
*/
public LegStarAddress getAddress(
final ${model.headerClassName} hostHeader) {
if (hostHeader == null) {
return null;
}
LegStarAddress address = new LegStarAddress(hostHeader.getHostEndPoint());
address.setHostCharset(hostHeader.getHostCharset());
address.setHostUserID(hostHeader.getHostUserID());
address.setHostPassword(hostHeader.getHostPassword());
address.setHostTraceMode(hostHeader.getHostTraceMode());
return address;
}
/**
* Generates a unique ID for a request. This can be passed from the client
* using the host header.
* @param hostHeader the java object mapping the SOAP header element
* @return a unique request ID
*/
public String getRequestID(final ${model.headerClassName} hostHeader) {
if (hostHeader != null && hostHeader.getHostRequestID() != null) {
return hostHeader.getHostRequestID();
} else {
return getServiceAdapterName() + ":" + new UID().toString();
}
}
#foreach ($cixsOperation in $model.cixsOperations)
/**
* @return the invoker implementation for operation ${cixsOperation.name}
*/
public ${cixsOperation.className}ProgramInvoker get${cixsOperation.className}ProgramInvoker() {
return m${cixsOperation.className}ProgramInvoker;
}
/**
* @param programInvoker the invoker implementation for operation ${cixsOperation.name} to set
*/
public void set${cixsOperation.className}ProgramInvoker(
final ${cixsOperation.className}ProgramInvoker programInvoker) {
m${cixsOperation.className}ProgramInvoker = programInvoker;
}
#end
}