Search in sources :

Example 11 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class MetricsAggregatorModuleTest method testInit.

/**
 * Initializing metricsAggregationModule and assert for the returned counter obj
 * @throws AxisFault
 */
public void testInit() throws AxisFault {
    AxisConfiguration axisConfiguration = new AxisConfiguration();
    ConfigurationContext configurationContext = new ConfigurationContext(axisConfiguration);
    metricsAggregatorModule.init(configurationContext, null);
    Counter counter = (Counter) axisConfiguration.getParameter(MetricsConstants.GLOBAL_REQUEST_COUNTER).getValue();
    Assert.assertEquals("Counter should be 0", counter.getCount(), 0);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext)

Example 12 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class Axis2SynapseController method deployMediationLibraryArtifacts.

/**
 * The mediation library deployer will handling the process of deploying the
 * libararyArtifacts, this is required since the library specific artifacts
 * has to be initialized priorly for the cases like connectors
 */
private void deployMediationLibraryArtifacts() {
    if (configurationContext == null || synapseConfiguration == null) {
        return;
    }
    DeploymentEngine deploymentEngine = (DeploymentEngine) configurationContext.getAxisConfiguration().getConfigurator();
    String libsPath = deploymentEngine.getRepositoryDir().getPath() + File.separator + "synapse-libs";
    deploymentEngine.addDeployer(new LibraryArtifactDeployer(), libsPath, "zip");
}
Also used : LibraryArtifactDeployer(org.apache.synapse.deployers.LibraryArtifactDeployer) DeploymentEngine(org.apache.axis2.deployment.DeploymentEngine)

Example 13 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class HessianMessageBuilderTest method testProcessDocumentFaultWithSynEnv.

public void testProcessDocumentFaultWithSynEnv() throws IOException {
    SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), new SynapseConfiguration());
    testProcessDocumentFault(synEnv);
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 14 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class HessianMessageBuilderTest method testProcessDocumentWithSynEnv.

public void testProcessDocumentWithSynEnv() throws IOException {
    SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), new SynapseConfiguration());
    testProcessDocument(synEnv);
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 15 with ConfigurationContext

use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.

the class ThrottleHandler method loadThrottle.

/**
 * Loads a throttle metadata for a particular throttle type
 *
 * @param messageContext - The messageContext
 * @param throttleType   - The type of throttle
 * @return IPBaseThrottleConfiguration     - The IPBaseThrottleConfiguration - load from AxisConfiguration
 * @throws ThrottleException Throws if the throttle type is unsupported
 */
public Throttle loadThrottle(MessageContext messageContext, int throttleType) throws ThrottleException {
    Throttle throttle = null;
    ConfigurationContext configContext = messageContext.getConfigurationContext();
    // the Parameter which hold throttle ipbase object
    // to get throttles map from the configuration context
    Map throttles = (Map) configContext.getPropertyNonReplicable(ThrottleConstants.THROTTLES_MAP);
    if (throttles == null) {
        if (debugOn) {
            log.debug("Couldn't find throttles object map .. thottlling will not be occurred ");
        }
        return null;
    }
    switch(throttleType) {
        case ThrottleConstants.GLOBAL_THROTTLE:
            {
                throttle = (Throttle) throttles.get(ThrottleConstants.GLOBAL_THROTTLE_KEY);
                break;
            }
        case ThrottleConstants.OPERATION_BASED_THROTTLE:
            {
                AxisOperation axisOperation = messageContext.getAxisOperation();
                if (axisOperation != null) {
                    QName opName = axisOperation.getName();
                    if (opName != null) {
                        AxisService service = (AxisService) axisOperation.getParent();
                        if (service != null) {
                            String currentServiceName = service.getName();
                            if (currentServiceName != null) {
                                throttle = (Throttle) throttles.get(currentServiceName + opName.getLocalPart());
                            }
                        }
                    }
                } else {
                    if (debugOn) {
                        log.debug("Couldn't find axis operation ");
                    }
                    return null;
                }
                break;
            }
        case ThrottleConstants.SERVICE_BASED_THROTTLE:
            {
                AxisService axisService = messageContext.getAxisService();
                if (axisService != null) {
                    throttle = (Throttle) throttles.get(axisService.getName());
                } else {
                    if (debugOn) {
                        log.debug("Couldn't find axis service ");
                    }
                    return null;
                }
                break;
            }
        default:
            {
                throw new ThrottleException("Unsupported Throttle type");
            }
    }
    return throttle;
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) ThrottleException(org.apache.synapse.commons.throttle.core.ThrottleException) AxisService(org.apache.axis2.description.AxisService) Map(java.util.Map) Throttle(org.apache.synapse.commons.throttle.core.Throttle)

Aggregations

ConfigurationContext (org.apache.axis2.context.ConfigurationContext)184 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)119 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)70 Test (org.junit.Test)64 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)62 Parameter (org.apache.axis2.description.Parameter)56 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)48 OMElement (org.apache.axiom.om.OMElement)43 AxisFault (org.apache.axis2.AxisFault)34 MessageContext (org.apache.synapse.MessageContext)34 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)30 AxisService (org.apache.axis2.description.AxisService)26 EndpointReference (org.apache.axis2.addressing.EndpointReference)24 MessageContext (org.apache.axis2.context.MessageContext)23 Options (org.apache.axis2.client.Options)22 HashMap (java.util.HashMap)20 ServiceContext (org.apache.axis2.context.ServiceContext)19 Map (java.util.Map)18 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)16