Java Code Examples for org.apache.axis2.description.AxisService#getOperations()

The following examples show how to use org.apache.axis2.description.AxisService#getOperations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemStatisticsDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void serviceUpdate(AxisEvent axisEvent, AxisService axisService) {

        if (SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) || axisService.isClientSide()) {
            return;
        }
        if (axisEvent.getEventType() == AxisEvent.SERVICE_DEPLOY) {
            for (Iterator iter = axisService.getOperations(); iter.hasNext(); ) {
                AxisOperation op = (AxisOperation) iter.next();
                setCountersAndProcessors(op);
            }
            // see ESBJAVA-2327
            if (JavaUtils.isTrueExplicitly(axisService.getParameterValue("disableOperationValidation"))) {
                AxisOperation defaultOp = (AxisOperation) axisService.getParameterValue("_default_mediate_operation_");
                if (defaultOp != null) {
                    setCountersAndProcessors(defaultOp);
                }
            }
            // Service response time processor
            Parameter responseTimeProcessor = new Parameter();
            responseTimeProcessor.setName(StatisticsConstants.SERVICE_RESPONSE_TIME_PROCESSOR);
            responseTimeProcessor.setValue(new ResponseTimeProcessor());
            try {
                axisService.addParameter(responseTimeProcessor);
            } catch (AxisFault axisFault) {
                // will not occur
            }
        }
    }
 
Example 2
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public int getServiceRequestCount(AxisService axisService) throws AxisFault {
    int count = 0;
    for (Iterator opIter = axisService.getOperations(); opIter.hasNext();) {
        AxisOperation axisOp = (AxisOperation) opIter.next();
        Parameter parameter = axisOp.getParameter(StatisticsConstants.IN_OPERATION_COUNTER);
        if (parameter != null) {
            count += ((AtomicInteger) parameter.getValue()).get();
        }
    }
    return count;
}
 
Example 3
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public int getServiceFaultCount(AxisService axisService) throws AxisFault {
    int count = 0;
    for (Iterator opIter = axisService.getOperations(); opIter.hasNext();) {
        AxisOperation axisOp = (AxisOperation) opIter.next();
        Parameter parameter = axisOp.getParameter(StatisticsConstants.OPERATION_FAULT_COUNTER);
        if (parameter != null) {
            count += ((AtomicInteger) parameter.getValue()).get();
        }
    }
    return count;
}
 
Example 4
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public int getServiceResponseCount(AxisService axisService) throws AxisFault {
    int count = 0;
    for (Iterator opIter = axisService.getOperations(); opIter.hasNext();) {
        AxisOperation axisOp = (AxisOperation) opIter.next();
        Parameter parameter = axisOp.getParameter(StatisticsConstants.OUT_OPERATION_COUNTER);
        if (parameter != null) {
            count += ((AtomicInteger) parameter.getValue()).get();
        }
    }
    return count;
}
 
Example 5
Source File: WSDLToDataService.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Create a DataService from an AxisService.
 * @param axisService The AxisService used to create the DS
 * @return The newly created data service
 * @throws DataServiceFault
 */
@SuppressWarnings("unchecked")
private static DataService createDataServiceFromAxisService(
		AxisService axisService) throws DataServiceFault {
	DataService dataService = new DataService(
			extractServiceNameFromHeirachicalName(axisService.getName()), 
			null, null, null, DBConstants.ServiceStatusValues.INACTIVE, 
			false, false, null);
       /* setting default authorization provider */
       dataService.setAuthorizationProvider(new UserStoreAuthorizationProvider());
	
	/* add dummy config */
	String dummyConfigId = DBConstants.DEFAULT_CONFIG_ID;
	dataService.addConfig(getDummyConfig(dataService, dummyConfigId));
	
	/* compile schema */
	Map<QName, Document> modelMap;
	Map<QName, String> elementMap;
	try {
		CompilerOptions options = new CompilerOptions();
		SchemaCompiler schemaCompiler = new SchemaCompiler(options);
		schemaCompiler.compile(axisService.getSchema());
		modelMap = schemaCompiler.getProcessedModelMap();
		elementMap = schemaCompiler.getProcessedElementMap();
	} catch (SchemaCompilationException e) {
		throw new DataServiceFault(e, "Error in schema compile");
	}
	
	/* add queries/operations */
	AxisOperation axisOperation;
	String operationName;
	String queryId;
	List<QueryParam> queryParams;
	for (Iterator<AxisOperation> axisOperations = axisService.getOperations(); axisOperations.hasNext();) {
		axisOperation = axisOperations.next();
		operationName = axisOperation.getName().getLocalPart(); 
		queryId = operationName + DBConstants.CONTRACT_FIRST_QUERY_SUFFIX;
		queryParams = getQueryParamsFromAxisOperation(modelMap, elementMap, axisOperation);
		/* query */
		dataService.addQuery(new SQLQuery(dataService, queryId, dummyConfigId, false, false, null,
                                             DBConstants.CONTRACT_FIRST_DUMMY_SQL, queryParams,
                                             getResultFromAxisOperation(dataService, axisOperation), null, null,
                                             new HashMap<String, String>(), dataService.getServiceNamespace()));
		/* operation */
		dataService.addOperation(new Operation(dataService, operationName, null,
                                                  getOperationCallQueryFromQueryParams(dataService, queryId, queryParams),
                                                  false, null, false, false));
	}
	return dataService;
}
 
Example 6
Source File: PassThroughNHttpGetProcessor.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the HTML text for the list of services deployed.
 * This can be delegated to another Class as well
 * where it will handle more options of GET messages.
 *
 * @param prefix to be used for the Service names
 * @return the HTML to be displayed as a String
 */
protected String getServicesHTML(String prefix) {

    Map services = cfgCtx.getAxisConfiguration().getServices();
    Hashtable erroneousServices = cfgCtx.getAxisConfiguration().getFaultyServices();
    boolean servicesFound = false;

    StringBuffer resultBuf = new StringBuffer();
    resultBuf.append("<html><head><title>Axis2: Services</title></head>" + "<body>");

    if ((services != null) && !services.isEmpty()) {

        servicesFound = true;
        resultBuf.append("<h2>" + "Deployed services" + "</h2>");

        for (Object service : services.values()) {

            AxisService axisService = (AxisService) service;
            Parameter isHiddenService = axisService.getParameter(
                    NhttpConstants.HIDDEN_SERVICE_PARAM_NAME);
            Parameter isAdminService = axisService.getParameter("adminService");
            boolean isClientSide = axisService.isClientSide();

            boolean isSkippedService = (isHiddenService != null &&
                    JavaUtils.isTrueExplicitly(isHiddenService.getValue())) || (isAdminService != null &&
                    JavaUtils.isTrueExplicitly(isAdminService.getValue())) || isClientSide;
            if (axisService.getName().startsWith("__") || isSkippedService) {
                continue;    // skip private services
            }

            Iterator iterator = axisService.getOperations();
            resultBuf.append("<h3><a href=\"").append(prefix).append(axisService.getName()).append(
                    "?wsdl\">").append(axisService.getName()).append("</a></h3>");

            if (iterator.hasNext()) {
                resultBuf.append("Available operations <ul>");

                for (; iterator.hasNext();) {
                    AxisOperation axisOperation = (AxisOperation) iterator.next();
                    resultBuf.append("<li>").append(
                            axisOperation.getName().getLocalPart()).append("</li>");
                }
                resultBuf.append("</ul>");
            } else {
                resultBuf.append("No operations specified for this service");
            }
        }
    }

    if ((erroneousServices != null) && !erroneousServices.isEmpty()) {
        servicesFound = true;
        resultBuf.append("<hr><h2><font color=\"blue\">Faulty Services</font></h2>");
        Enumeration faultyservices = erroneousServices.keys();

        while (faultyservices.hasMoreElements()) {
            String faultyserviceName = (String) faultyservices.nextElement();
            resultBuf.append("<h3><font color=\"blue\">").append(
                    faultyserviceName).append("</font></h3>");
        }
    }

    if (!servicesFound) {
        resultBuf.append("<h2>There are no services deployed</h2>");
    }

    resultBuf.append("</body></html>");
    return resultBuf.toString();
}
 
Example 7
Source File: ServiceAdmin.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public ServiceMetaData getServiceData(String serviceName) throws Exception {

        AxisService service = axisConfiguration.getServiceForActivation(serviceName);

        if (service == null) {
            String msg = "Invalid service name, service not found : " + serviceName;
            throw new AxisFault(msg);
        }

        String serviceType = getServiceType(service);
        List<String> ops = new ArrayList<String>();
        for (Iterator<AxisOperation> opIter = service.getOperations(); opIter.hasNext(); ) {
            AxisOperation axisOperation = opIter.next();

            if (axisOperation.getName() != null) {
                ops.add(axisOperation.getName().getLocalPart());
            }
        }

        ServiceMetaData serviceMetaData = new ServiceMetaData();
        serviceMetaData.setOperations(ops.toArray(new String[ops.size()]));
        serviceMetaData.setName(serviceName);
        serviceMetaData.setServiceId(serviceName);
        serviceMetaData.setServiceVersion("");
        serviceMetaData.setActive(service.isActive());
        String[] eprs = this.getServiceEPRs(serviceName);
        serviceMetaData.setEprs(eprs);
        serviceMetaData.setServiceType(serviceType);

        serviceMetaData.setWsdlURLs(Utils.getWsdlInformation(serviceName, axisConfiguration));

        AxisServiceGroup serviceGroup = (AxisServiceGroup) service.getParent();
        serviceMetaData.setFoundWebResources(serviceGroup.isFoundWebResources());
        serviceMetaData.setScope(service.getScope());
        serviceMetaData.setWsdlPorts(service.getEndpoints());
        Parameter deploymentTime = service.getParameter("serviceDeploymentTime");
        if (deploymentTime != null) {
            serviceMetaData.setServiceDeployedTime((Long) deploymentTime.getValue());
        }

        serviceMetaData.setServiceGroupName(serviceGroup.getServiceGroupName());

        if (service.getDocumentation() != null) {
            serviceMetaData.setDescription(service.getDocumentation());
        } else {
            serviceMetaData.setDescription("No service description found");
        }

        Parameter parameter = service.getParameter("enableMTOM");
        if (parameter != null) {
            serviceMetaData.setMtomStatus((String) parameter.getValue());
        } else {
            serviceMetaData.setMtomStatus("false");
        }

        parameter = service.getParameter("disableTryIt");
        if (parameter != null && Boolean.TRUE.toString().equalsIgnoreCase((String) parameter.getValue())) {
            serviceMetaData.setDisableTryit(true);
        }

        return serviceMetaData;
    }