Search in sources :

Example 96 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project carbon-business-process by wso2.

the class BPELClusterNotifier method sendClusterNotification.

public static void sendClusterNotification(StateClusteringCommand command, Object processStore) throws AxisFault {
    if (log.isDebugEnabled()) {
        log.debug("Sending clustering command.");
    }
    AxisConfiguration axisConfig = BPELClusterNotifierServiceComponent.getAxisConfiguration();
    axisConfig.addParameter(PARAM_PARENT_PROCESS_STORE, processStore);
    Replicator.replicateState(command, axisConfig);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration)

Example 97 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project carbon-business-process by wso2.

the class AnonymousServiceFactory method createAnonymousService.

private static AxisService createAnonymousService(AxisConfiguration axisCfg, String serviceKey) {
    try {
        OutOnlyAxisOperation outOnlyOperation = new OutOnlyAxisOperation(ServiceClient.ANON_OUT_ONLY_OP);
        OutInAxisOperation outInOperation = new OutInAxisOperation(ServiceClient.ANON_OUT_IN_OP);
        AxisService axisAnonymousService = new AxisService(serviceKey);
        axisAnonymousService.addOperation(outOnlyOperation);
        axisAnonymousService.addOperation(outInOperation);
        // set a right default action *after* operations have been added to the service.
        outOnlyOperation.setSoapAction("");
        outInOperation.setSoapAction("");
        if (log.isDebugEnabled()) {
            log.debug("Creating Client Service: " + serviceKey);
        }
        axisAnonymousService.setClientSide(true);
        axisCfg.addService(axisAnonymousService);
        return axisAnonymousService;
    } catch (AxisFault axisFault) {
        handleException("Adding service to axis configuration failed.", axisFault);
    }
    return null;
}
Also used : AxisFault(org.apache.axis2.AxisFault) OutOnlyAxisOperation(org.apache.axis2.description.OutOnlyAxisOperation) AxisService(org.apache.axis2.description.AxisService) OutInAxisOperation(org.apache.axis2.description.OutInAxisOperation)

Example 98 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project carbon-business-process by wso2.

the class AnonymousServiceFactory method getAnonymousService.

/**
 * Create AxisService for the requested endpoint config to sending out messages to external services.
 *
 * @param serviceName    External service QName
 * @param servicePort    service port
 * @param axisConfig     AxisConfiguration object
 * @param caller Identifier for the service caller
 * @return AxisService
 */
public static AxisService getAnonymousService(QName serviceName, String servicePort, AxisConfiguration axisConfig, String caller) {
    String serviceKey = "axis_service_for_" + caller + "#" + serviceName.getLocalPart() + "#" + servicePort;
    try {
        AxisService service = axisConfig.getService(serviceKey);
        if (service == null) {
            synchronized (AnonymousServiceFactory.class) {
                /* Fix for bugs due to high concurrency. If there are number of service calls to same service from
                     * different process instances, two process instances will try to add same service to axis config.
                     */
                service = axisConfig.getService(serviceKey);
                if (service != null) {
                    return service;
                }
                service = createAnonymousService(axisConfig, serviceKey);
            }
        }
        return service;
    } catch (AxisFault axisFault) {
        handleException("Error retrieving service for key " + serviceKey, axisFault);
    }
    return null;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisService(org.apache.axis2.description.AxisService)

Example 99 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method fillPartnerLinks.

// private java.lang.String[] getServiceLocationForProcess(QName processId)
// throws ProcessManagementException {
// AxisConfiguration axisConf = getConfigContext().getAxisConfiguration();
// Map<String, AxisService> services = axisConf.getServices();
// ArrayList<String> serviceEPRs = new ArrayList<String>();
// 
// for (AxisService service : services.values()) {
// Parameter pIdParam = service.getParameter(BPELConstants.PROCESS_ID);
// if (pIdParam != null) {
// if (pIdParam.getValue().equals(processId)) {
// serviceEPRs.addAll(Arrays.asList(service.getEPRs()));
// }
// }
// }
// 
// if (serviceEPRs.size() > 0) {
// return serviceEPRs.toArray(new String[serviceEPRs.size()]);
// }
// 
// String errMsg = "Cannot find service for process: " + processId;
// log.error(errMsg);
// throw new ProcessManagementException(errMsg);
// }
private void fillPartnerLinks(ProcessInfoType pInfo, TDeployment.Process processInfo) throws ProcessManagementException {
    if (processInfo.getProvideList() != null) {
        EndpointReferencesType eprsType = new EndpointReferencesType();
        for (TProvide provide : processInfo.getProvideList()) {
            String plinkName = provide.getPartnerLink();
            TService service = provide.getService();
            /* NOTE:Service cannot be null for provider partner link*/
            if (service == null) {
                String errorMsg = "Error in <provide> element for process " + processInfo.getName() + " partnerlink" + plinkName + " did not identify an endpoint";
                log.error(errorMsg);
                throw new ProcessManagementException(errorMsg);
            }
            if (log.isDebugEnabled()) {
                log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
            }
            QName serviceName = service.getName();
            EndpointRef_type0 eprType = new EndpointRef_type0();
            eprType.setPartnerLink(plinkName);
            eprType.setService(serviceName);
            ServiceLocation sLocation = new ServiceLocation();
            try {
                String url = getTryitURL(serviceName.getLocalPart(), getConfigContext());
                sLocation.addServiceLocation(url);
                String[] wsdls = getWsdlInformation(serviceName.getLocalPart(), getConfigContext().getAxisConfiguration());
                if (wsdls.length == 2) {
                    if (wsdls[0].endsWith("?wsdl")) {
                        sLocation.addServiceLocation(wsdls[0]);
                    } else {
                        sLocation.addServiceLocation(wsdls[1]);
                    }
                }
            } catch (AxisFault axisFault) {
                String errMsg = "Error while getting try-it url for the service: " + serviceName;
                log.error(errMsg, axisFault);
                throw new ProcessManagementException(errMsg, axisFault);
            }
            eprType.setServiceLocations(sLocation);
            eprsType.addEndpointRef(eprType);
        }
        pInfo.setEndpoints(eprsType);
    }
// if (processInfo.getInvokeList() != null) {
// for (TInvoke invoke : processInfo.getInvokeList()) {
// String plinkName = invoke.getPartnerLink();
// TService service = invoke.getService();
// /* NOTE:Service can be null for partner links*/
// if (service == null) {
// continue;
// }
// if (log.isDebugEnabled()) {
// log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" +
// plinkName + " -->" + service);
// }
// 
// QName serviceName = service.getName();
// }
// }
}
Also used : AxisFault(org.apache.axis2.AxisFault) QName(javax.xml.namespace.QName) ServiceLocation(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ServiceLocation) EndpointReferencesType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EndpointReferencesType) EndpointRef_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EndpointRef_type0) TProvide(org.apache.ode.bpel.dd.TProvide) TService(org.apache.ode.bpel.dd.TService) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)

Example 100 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getTryitURL.

private static String getTryitURL(String serviceName, ConfigurationContext configurationContext) throws AxisFault {
    AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
    // If axis2 uses the servlet transport then we could use the prefix of its endpoint URL to
    // determine the tryit url
    String wsdlURL = getWsdlInformation(serviceName, axisConfig)[0];
    String tryitPrefix = wsdlURL.substring(0, wsdlURL.length() - serviceName.length() - 5);
    if (!isServletTransport(axisConfig)) {
        int tenantIndex = tryitPrefix.indexOf("/t/");
        if (tenantIndex != -1) {
            String tmpTryitPrefix = tryitPrefix.substring(tryitPrefix.substring(0, tryitPrefix.indexOf("/t/")).lastIndexOf("/"));
            // Check if the  Webapp context root of WSO2 Carbon is set.
            tryitPrefix = tryitPrefix.replaceFirst("//", "");
            if (tryitPrefix.substring(0, tryitPrefix.indexOf("/services/")).lastIndexOf("/") > -1) {
                tryitPrefix = tryitPrefix.substring(tryitPrefix.substring(0, tryitPrefix.indexOf("/services/")).lastIndexOf("/"));
            } else {
                tryitPrefix = tmpTryitPrefix;
            }
        } else {
            tryitPrefix = configurationContext.getServiceContextPath() + "/";
        }
    }
    return CarbonUtils.getProxyContextPath(false) + tryitPrefix + serviceName + "?tryit";
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)211 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)122 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)95 Test (org.junit.Test)68 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)65 Parameter (org.apache.axis2.description.Parameter)62 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)62 OMElement (org.apache.axiom.om.OMElement)40 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 AxisService (org.apache.axis2.description.AxisService)33 DeploymentEngine (org.apache.axis2.deployment.DeploymentEngine)32 MessageContext (org.apache.synapse.MessageContext)32 AxisFault (org.apache.axis2.AxisFault)31 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)28 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)21 DeploymentException (org.apache.axis2.deployment.DeploymentException)20 SynapseException (org.apache.synapse.SynapseException)20 IOException (java.io.IOException)19 XMLStreamException (javax.xml.stream.XMLStreamException)16 File (java.io.File)15