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);
}
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");
}
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);
}
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);
}
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;
}
Aggregations