Search in sources :

Example 6 with WebMethod

use of javax.jws.WebMethod in project ats-framework by Axway.

the class AgentWsImpl method getActionExecutionResults.

/**
     * Queue has already finished and the Test Executor is asking for the
     * queue execution results.
     *
     * There is theoretical chance to be called by more than one thread on Test Executor side,
     * when more than one queue is started in non-blocking mode. That's why it is synchronized
     *
     * @param queueName
     * @return
     * @throws AgentException
     */
@WebMethod
public synchronized byte[] getActionExecutionResults(@WebParam(name = "name") String queueName) throws AgentException {
    try {
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
        objectOutStream.writeObject(QueueExecutionStatistics.getInstance().getActionExecutionResults(queueName));
        return byteOutStream.toByteArray();
    } catch (Exception e) {
        handleExceptions(e);
        // always throw but the compiler is not aware of this
        return null;
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) InternalComponentException(com.axway.ats.agent.core.exceptions.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) NoSuchActionException(com.axway.ats.agent.core.exceptions.NoSuchActionException) NoCompatibleMethodFoundException(com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException) NoSuchComponentException(com.axway.ats.agent.core.exceptions.NoSuchComponentException) IOException(java.io.IOException) ActionExecutionException(com.axway.ats.agent.core.exceptions.ActionExecutionException) WebMethod(javax.jws.WebMethod)

Example 7 with WebMethod

use of javax.jws.WebMethod in project ats-framework by Axway.

the class AgentWsImpl method getNumberPendingLogEvents.

@WebMethod
public synchronized int getNumberPendingLogEvents() throws AgentException {
    final String caller = getCaller();
    ThreadsPerCaller.registerThread(caller);
    try {
        PassiveDbAppender appender = PassiveDbAppender.getCurrentInstance(caller);
        if (appender != null) {
            return appender.getNumberPendingLogEvents();
        }
    } finally {
        ThreadsPerCaller.unregisterThread();
    }
    return -1;
}
Also used : PassiveDbAppender(com.axway.ats.log.appenders.PassiveDbAppender) WebMethod(javax.jws.WebMethod)

Example 8 with WebMethod

use of javax.jws.WebMethod in project wildfly by wildfly.

the class JwsWebServiceEndpointVerifier method verifyWebMethod.

void verifyWebMethod(final Method endpointInterfaceDefinedWebMethod) {
    final Method endpointImplementationMethod = findEndpointImplMethodMatching(endpointInterfaceDefinedWebMethod);
    if (endpointImplementationMethod != null) {
        final int methodModifiers = endpointImplementationMethod.getModifiers();
        final WebMethod possibleWebMethodAnnotation = endpointImplementationMethod.getAnnotation(WebMethod.class);
        if (possibleWebMethodAnnotation == null || !possibleWebMethodAnnotation.exclude()) {
            if (Modifier.isPublic(methodModifiers)) {
                if (Modifier.isStatic(methodModifiers) || Modifier.isFinal(methodModifiers)) {
                    verificationFailures.add(new WebMethodIsStaticOrFinal(endpointImplementationMethod));
                }
            } else {
                verificationFailures.add(new WebMethodIsNotPublic(endpointImplementationMethod));
            }
        }
    }
}
Also used : WebMethod(javax.jws.WebMethod) WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method)

Example 9 with WebMethod

use of javax.jws.WebMethod in project bamboobsc by billchen198318.

the class ManualJobServiceImpl method execute.

@WebMethod
@POST
@Path("/executeJob/{uploadOid}")
@Override
public String execute(@WebParam(name = "uploadOid") @PathParam("uploadOid") String uploadOid) throws Exception {
    SysExprJobLogVO result = null;
    Subject subject = null;
    ObjectMapper objectMapper = new ObjectMapper();
    String exceptionMessage = "";
    try {
        Map<String, Object> dataMap = SystemExpressionJobUtils.getDecUploadOid(uploadOid);
        if (dataMap == null || StringUtils.isBlank((String) dataMap.get("accountId")) || StringUtils.isBlank((String) dataMap.get("sysExprJobOid"))) {
            log.error("no data accountId / sysExprJobOid");
            result = new SysExprJobLogVO();
            result.setFaultMsg("no data accountId / sysExprJobOid");
            return objectMapper.writeValueAsString(result);
        }
        String accountId = (String) dataMap.get("accountId");
        String sysExprJobOid = (String) dataMap.get("sysExprJobOid");
        ShiroLoginSupport loginSupport = new ShiroLoginSupport();
        subject = loginSupport.forceCreateLoginSubject(accountId);
        result = SystemExpressionJobUtils.executeJobForManual(sysExprJobOid);
    } catch (ServiceException se) {
        se.printStackTrace();
        exceptionMessage = se.getMessage().toString();
    } catch (Exception e) {
        e.printStackTrace();
        if (e.getMessage() == null) {
            exceptionMessage = e.toString();
        } else {
            exceptionMessage = e.getMessage().toString();
        }
    } finally {
        if (result == null) {
            result = new SysExprJobLogVO();
        }
        if (subject != null) {
            subject.logout();
        }
        if (!StringUtils.isBlank(exceptionMessage) && StringUtils.isBlank(result.getFaultMsg())) {
            result.setFaultMsg(exceptionMessage);
        }
    }
    return objectMapper.writeValueAsString(result);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysExprJobLogVO(com.netsteadfast.greenstep.vo.SysExprJobLogVO) Subject(org.apache.shiro.subject.Subject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ShiroLoginSupport(com.netsteadfast.greenstep.sys.ShiroLoginSupport) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 10 with WebMethod

use of javax.jws.WebMethod in project bamboobsc by billchen198318.

the class KpiLogicServiceImpl method findKpis.

/**
	 * for TEST
	 * 這是測試 WS REST 用的  metod , 暴露 KPIs 主檔資料
	 * 
	 * rest address: http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/
	 * 
	 * json:
	 * http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/json
	 * 
	 * xml:
	 * http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/xml
	 * 
	 * @param format			example:	xml / json
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@WebMethod
@GET
@Path("/kpis/{format}")
@Override
public String findKpis(@WebParam(name = "format") @PathParam("format") String format) throws ServiceException, Exception {
    List<KpiVO> kpis = null;
    try {
        kpis = this.kpiService.findListVOByParams(null);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (null == kpis) {
            kpis = new ArrayList<KpiVO>();
        }
    }
    if ("json".equals(format)) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("KPIS", kpis);
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(paramMap);
    }
    XStream xstream = new XStream();
    //xstream.registerConverter( new DateConverter() );
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias("KPIS", List.class);
    xstream.alias("KPI", KpiVO.class);
    return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xstream.toXML(kpis);
}
Also used : HashMap(java.util.HashMap) XStream(com.thoughtworks.xstream.XStream) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

WebMethod (javax.jws.WebMethod)20 IOException (java.io.IOException)6 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)5 AgentException (com.axway.ats.agent.core.exceptions.AgentException)5 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)5 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)5 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)5 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)5 Path (javax.ws.rs.Path)5 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 WebResult (javax.jws.WebResult)3 GET (javax.ws.rs.GET)3 Subject (org.apache.shiro.subject.Subject)3 TestCaseState (com.axway.ats.log.autodb.TestCaseState)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 BscApiServiceResponse (com.netsteadfast.greenstep.bsc.vo.BscApiServiceResponse)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ObjectInputStream (java.io.ObjectInputStream)2