use of javax.jws.WebMethod in project ats-framework by Axway.
the class AgentWsImpl method scheduleActionsInMultipleThreads.
/**
* Schedule a set of actions (queue) in multiple threads. The actions
* will not be executed until a call to startQueue is made
*
* @param queueName the name of the action queue
* @param actions the actions in that queue
* @param serializedThreadingPattern the serialized threading pattern to be used
* @param testCaseState the test case state
* @throws AgentException on error
* @throws InternalComponentException if an exception is thrown while the actions are executed
*/
@WebMethod
public void scheduleActionsInMultipleThreads(@WebParam(name = "name") String queueName, @WebParam(name = "queueId") int queueId, @WebParam(name = "actions") ActionWrapper[] actions, @WebParam(name = "serializedThreadingPattern") byte[] serializedThreadingPattern, @WebParam(name = "serializedLoaderDataConfig") byte[] serializedLoaderDataConfig, boolean isUseSynchronizedIterations) throws AgentException, InternalComponentException {
final String caller = getCaller();
ThreadsPerCaller.registerThread(caller);
try {
ArrayList<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
for (ActionWrapper actionWrapper : actions) {
List<ArgumentWrapper> args = actionWrapper.getArgs();
int numArguments = args.size();
Object[] arguments = new Object[numArguments];
// unwrap the action arguments
for (int i = 0; i < numArguments; i++) {
ArgumentWrapper argWrapper = args.get(i);
ByteArrayInputStream byteInStream = new ByteArrayInputStream(argWrapper.getArgumentValue());
ObjectInputStream objectInStream = new ObjectInputStream(byteInStream);
arguments[i] = objectInStream.readObject();
}
// construct the action request
ActionRequest actionRequest = new ActionRequest(actionWrapper.getComponentName(), actionWrapper.getActionName(), arguments);
actionRequests.add(actionRequest);
}
ByteArrayInputStream byteInStream;
ObjectInputStream objectInStream;
// de-serialize the threading configuration
byteInStream = new ByteArrayInputStream(serializedThreadingPattern);
objectInStream = new ObjectInputStream(byteInStream);
ThreadingPattern threadingPattern = (ThreadingPattern) objectInStream.readObject();
// de-serialize the loader data configuration
byteInStream = new ByteArrayInputStream(serializedLoaderDataConfig);
objectInStream = new ObjectInputStream(byteInStream);
LoaderDataConfig loaderDataConfig = (LoaderDataConfig) objectInStream.readObject();
MultiThreadedActionHandler.getInstance(caller).scheduleActions(caller, queueName, queueId, actionRequests, threadingPattern, loaderDataConfig, isUseSynchronizedIterations);
} catch (Exception e) {
handleExceptions(e);
} finally {
ThreadsPerCaller.unregisterThread();
}
}
use of javax.jws.WebMethod in project ats-framework by Axway.
the class AgentWsImpl method getMonitoringResults.
/**
* @return the latest info about the Agent users activity
*
* @throws AgentException
* @throws InternalComponentException
*/
@WebMethod
public synchronized byte[] getMonitoringResults() throws AgentException, InternalComponentException {
try {
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
objectOutStream.writeObject(UserActionsMonitoringAgent.getInstance(getCaller()).getMonitoringResults());
return byteOutStream.toByteArray();
} catch (Exception e) {
handleExceptions(e);
// always throw but the compiler is not aware of this
return null;
}
}
use of javax.jws.WebMethod in project ats-framework by Axway.
the class AgentWsImpl method pushConfiguration.
/**
* Apply client configuration to the server
*
* @param configurators the serialized configurators to be applied
* @throws AgentException on error
*/
@SuppressWarnings("unchecked")
@WebMethod
public void pushConfiguration(@WebParam(name = "configurators") byte[] serializedConfigurators) throws AgentException {
final String caller = getCaller();
ThreadsPerCaller.registerThread(caller);
ByteArrayInputStream byteInStream = new ByteArrayInputStream(serializedConfigurators);
ObjectInputStream objectInStream;
try {
objectInStream = new ObjectInputStream(byteInStream);
List<Configurator> configurators = (List<Configurator>) objectInStream.readObject();
// Check if AgentConfigurator is set. In such case we will need to reload the
// Agent components as this configuration defines the way Agent components are loaded.
boolean needToReloadComponents = false;
for (Configurator configurator : configurators) {
if (configurator instanceof AgentConfigurator) {
needToReloadComponents = true;
break;
}
}
if (needToReloadComponents) {
// the already loaded Agent components are first unloaded
MainComponentLoader.getInstance().destroy();
// the initialization procedure will implicitly apply the new configurations
// and then will load up again the Agent components
MainComponentLoader.getInstance().initialize(configurators);
} else {
// just apply the configurations
ConfigurationManager.getInstance().apply(configurators);
}
} catch (IOException ioe) {
final String msg = "IO error while serializing configurators";
// log on the monitored machine
log.error(msg, ioe);
throw new AgentException(msg, ioe);
} catch (ClassNotFoundException cnfe) {
final String msg = "Could not deserialize configurators";
// log on the monitored machine
log.error(msg, cnfe);
throw new AgentException(msg, cnfe);
} catch (Exception e) {
final String msg = "Error applying configurators";
// log on the monitored machine
log.error(msg, e);
throw new AgentException(msg, e);
} finally {
ThreadsPerCaller.unregisterThread();
}
}
use of javax.jws.WebMethod in project ats-framework by Axway.
the class AgentWsImpl method executeAction.
/**
* Web method for execution of Agent actions.
*
* @param componentName name of the Agent component
* @param actionName name of the action to perform
* @param args arguments - array of ArgumentWrapper
* @return serialized returned result
* @throws AgentException if any error occurs
* @throws InternalComponentException if an exception occurs in the Agent action
*/
@WebMethod
public byte[] executeAction(@WebParam(name = "componentName") String componentName, @WebParam(name = "actionName") String actionName, @WebParam(name = "args") ArgumentWrapper[] args) throws AgentException, InternalComponentException {
final String caller = getCaller();
ThreadsPerCaller.registerThread(caller);
try {
Object result = executeAction(caller, componentName, actionName, args);
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
objectOutStream.writeObject(result);
return byteOutStream.toByteArray();
} catch (Exception e) {
handleExceptions(e);
// but the compiler is not aware of this
return null;
} finally {
ThreadsPerCaller.unregisterThread();
}
}
use of javax.jws.WebMethod in project bamboobsc by billchen198318.
the class ApiWebServiceImpl method getScorecard2.
@WebMethod
@GET
@Path("/scorecard2/")
@Override
public BscApiServiceResponse getScorecard2(@WebParam(name = "visionId") @QueryParam("visionId") String visionId, @WebParam(name = "startDate") @QueryParam("startDate") String startDate, @WebParam(name = "endDate") @QueryParam("endDate") String endDate, @WebParam(name = "startYearDate") @QueryParam("startYearDate") String startYearDate, @WebParam(name = "endYearDate") @QueryParam("endYearDate") String endYearDate, @WebParam(name = "frequency") @QueryParam("frequency") String frequency, @WebParam(name = "dataFor") @QueryParam("dataFor") String dataFor, @WebParam(name = "measureDataOrganizationId") @QueryParam("measureDataOrganizationId") String measureDataOrganizationId, @WebParam(name = "measureDataEmployeeId") @QueryParam("measureDataEmployeeId") String measureDataEmployeeId, @WebParam(name = "contentFlag") @QueryParam("contentFlag") String contentFlag) throws Exception {
HttpServletRequest request = null;
if (this.getWebServiceContext() != null && this.getWebServiceContext().getMessageContext() != null) {
request = (HttpServletRequest) this.getWebServiceContext().getMessageContext().get(MessageContext.SERVLET_REQUEST);
}
Subject subject = null;
BscApiServiceResponse responseObj = new BscApiServiceResponse();
responseObj.setSuccess(YesNo.NO);
try {
subject = WsAuthenticateUtils.login();
@SuppressWarnings("unchecked") IVisionService<VisionVO, BbVision, String> visionService = (IVisionService<VisionVO, BbVision, String>) AppContext.getBean("bsc.service.VisionService");
@SuppressWarnings("unchecked") IEmployeeService<EmployeeVO, BbEmployee, String> employeeService = (IEmployeeService<EmployeeVO, BbEmployee, String>) AppContext.getBean("bsc.service.EmployeeService");
@SuppressWarnings("unchecked") IOrganizationService<OrganizationVO, BbOrganization, String> organizationService = (IOrganizationService<OrganizationVO, BbOrganization, String>) AppContext.getBean("bsc.service.OrganizationService");
String visionOid = "";
String measureDataOrganizationOid = "";
String measureDataEmployeeOid = "";
DefaultResult<VisionVO> visionResult = visionService.findForSimpleByVisId(visionId);
if (visionResult.getValue() == null) {
throw new Exception(visionResult.getSystemMessage().getValue());
}
visionOid = visionResult.getValue().getOid();
if (StringUtils.isBlank(measureDataOrganizationId)) {
measureDataOrganizationOid = BscBaseLogicServiceCommonSupport.findEmployeeDataByEmpId(employeeService, measureDataOrganizationId).getOid();
}
if (StringUtils.isBlank(measureDataEmployeeId)) {
measureDataEmployeeOid = BscBaseLogicServiceCommonSupport.findOrganizationDataByUK(organizationService, measureDataEmployeeId).getOid();
}
this.processForScorecard(responseObj, request, visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid, contentFlag);
} catch (Exception e) {
responseObj.setMessage(e.getMessage());
} finally {
if (!YesNo.YES.equals(responseObj.getSuccess())) {
responseObj.setMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
}
WsAuthenticateUtils.logout(subject);
}
subject = null;
return responseObj;
}
Aggregations