Java源码示例:org.apache.axis2.engine.AxisConfiguration

示例1
private void engagePoxSecurity() {
    try {
        AxisConfiguration axisConfig = DataHolder.getInstance().getConfigCtx().getAxisConfiguration();
        Parameter passwordCallbackParam = new Parameter();
        DefaultPasswordCallback passwordCallbackClass = new DefaultPasswordCallback();
        passwordCallbackParam.setName("passwordCallbackRef");
        passwordCallbackParam.setValue(passwordCallbackClass);
        axisConfig.addParameter(passwordCallbackParam);
        String enablePoxSecurity = CarbonServerConfigurationService.getInstance()
                .getFirstProperty("EnablePoxSecurity");
        if (enablePoxSecurity == null || "true".equals(enablePoxSecurity)) {
            AxisConfiguration mainAxisConfig = DataHolder.getInstance().getConfigCtx().getAxisConfiguration();
            // Check for the module availability
            if (mainAxisConfig.getModules().toString().contains(POX_SECURITY_MODULE)){
                mainAxisConfig.engageModule(POX_SECURITY_MODULE);
                log.debug("UT Security is activated");
            } else {
                log.error("UT Security is not activated UTsecurity.mar is not available");
            }
        } else {
            log.debug("POX Security Disabled");
        }
    } catch (Throwable e) {
        log.error("Failed to activate Micro Integrator UT security module ", e);
    }
}
 
示例2
/**
 * This method returns the available data services names.
 *
 * @param axisConfiguration Axis configuration
 * @return names of available data services
 * @throws AxisFault
 */
public static String[] getAvailableDS(AxisConfiguration axisConfiguration) throws AxisFault {
    List<String> serviceList = new ArrayList<>();
    Map<String, AxisService> map = axisConfiguration.getServices();
    Set<String> set = map.keySet();
    for (String serviceName : set) {
        AxisService axisService = axisConfiguration.getService(serviceName);
        Parameter parameter = axisService.getParameter(DBConstants.AXIS2_SERVICE_TYPE);
        if (parameter != null) {
            if (DBConstants.DB_SERVICE_TYPE.equals(parameter.getValue().toString())) {
                serviceList.add(serviceName);
            }
        }
    }
    return serviceList.toArray(new String[serviceList.size()]);
}
 
示例3
/**
 * Deploy the data service artifacts and add them to data services.
 *
 * @param carbonApp  find artifacts from this CarbonApplication instance.
 * @param axisConfig AxisConfiguration of the current tenant.
 */
@Override
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Deploying data services of carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> dependencies = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<>();
    for (Artifact.Dependency dependency : dependencies) {
        if (dependency.getArtifact() != null) {
            artifacts.add(dependency.getArtifact());
        }
    }
    deployDataSources(artifacts, axisConfig);
}
 
示例4
private AxisService getAxisService(String serviceName) {
    AxisConfiguration axisConfiguration = getAxisConfig();
    AxisService axisService = axisConfiguration.getServiceForActivation(serviceName);
    // Check if the service in in ghost list
    try {
        if (axisService == null && GhostDeployerUtils.
                getTransitGhostServicesMap(axisConfiguration).containsKey(serviceName)) {
            GhostDeployerUtils.waitForServiceToLeaveTransit(serviceName, getAxisConfig());
            axisService = axisConfiguration.getServiceForActivation(serviceName);
        }
    } catch (AxisFault axisFault) {
        log.error("Error occurred while service : " + serviceName + " is " +
                  "trying to leave transit", axisFault);
    }
    return axisService;
}
 
示例5
private void populateDataServiceList(MessageContext msgCtx) throws Exception {
    SynapseConfiguration configuration = msgCtx.getConfiguration();
    AxisConfiguration axisConfiguration = configuration.getAxisConfiguration();
    String[] dataServicesNames = DBUtils.getAvailableDS(axisConfiguration);

    // initiate list model
    DataServicesList dataServicesList = new DataServicesList(dataServicesNames.length);

    for (String dataServiceName : dataServicesNames) {
        DataService dataService = getDataServiceByName(msgCtx, dataServiceName);
        ServiceMetaData serviceMetaData = getServiceMetaData(dataService);
        // initiate summary model
        DataServiceSummary summary = null;
        if (serviceMetaData != null) {
            summary = new DataServiceSummary(serviceMetaData.getName(), serviceMetaData.getWsdlURLs());
        }
        dataServicesList.addServiceSummary(summary);
    }

    org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) msgCtx)
            .getAxis2MessageContext();

    String stringPayload = new Gson().toJson(dataServicesList);
    Utils.setJsonPayLoad(axis2MessageContext, new JSONObject(stringPayload));
}
 
示例6
/**
 * Deploy the data source artifacts and add them to datasources.
 *
 * @param carbonApp  - store info in this object after deploying
 * @param axisConfig - AxisConfiguration of the current tenant
 */
@Override
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(true, artifacts);
}
 
示例7
/**
 * Un-deploy the data sources and remove them from datasources.
 *
 * @param carbonApp  - all information about the existing artifacts are in this instance.
 * @param axisConfig - AxisConfiguration of the current tenant.
 */
@Override
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig)
        throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Un-Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(false, artifacts);
}
 
示例8
public static MessageContext createMessageContext(OMElement payload,
                                                  OMElement topic,
                                                  int tenantId) throws EventBrokerException {
    MessageContext mc = new MessageContext();
    mc.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
    SOAPFactory soapFactory = new SOAP12Factory();
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    envelope.getBody().addChild(payload);
    if (topic != null) {
        envelope.getHeader().addChild(topic);
    }
    try {
        mc.setEnvelope(envelope);
    } catch (Exception e) {

        throw new EventBrokerException("Unable to generate event.", e);
    }
    return mc;
}
 
示例9
private AutoscalerContext() {
    // Check clustering status
    AxisConfiguration axisConfiguration = ServiceReferenceHolder.getInstance().getAxisConfiguration();
    if ((axisConfiguration != null) && (axisConfiguration.getClusteringAgent() != null)) {
        clustered = true;
    }

    // Initialize distributed object provider
    distributedObjectProvider = ServiceReferenceHolder.getInstance().getDistributedObjectProvider();

    if (applicationContextMap == null) {
        applicationContextMap = distributedObjectProvider.getMap(AS_APPLICATION_ID_TO_APPLICATION_CTX_MAP);//new ConcurrentHashMap<String, ApplicationContext>();
    }
    setClusterMonitors(distributedObjectProvider.getMap(AS_CLUSTER_ID_TO_CLUSTER_MONITOR_MAP));
    setApplicationMonitors(distributedObjectProvider.getMap(AS_APPLICATION_ID_TO_APPLICATION_MONITOR_MAP));
    pendingApplicationMonitors = distributedObjectProvider.getList(AS_PENDING_APPLICATION_MONITOR_LIST);//new ArrayList<String>();
    applicationIdToNetworkPartitionAlgorithmContextMap =
            distributedObjectProvider.getMap(AS_APPLICATIOIN_ID_TO_NETWORK_PARTITION_ALGO_CTX_MAP);
}
 
示例10
protected void unsetConfigurationContextService(ConfigurationContextService contextService) {

        AxisConfiguration axisConf = configContext.getAxisConfiguration();
        if (axisConf != null) {
            AxisModule statModule = axisConf.getModule(StatisticsConstants.STATISTISTICS_MODULE_NAME);
            if (statModule != null) {
                try {
                    axisConf.disengageModule(statModule);
                } catch (AxisFault axisFault) {
                    log.error("Failed disengage module: " + StatisticsConstants.STATISTISTICS_MODULE_NAME);
                }
            }
            this.configContext = null;
        }

    }
 
示例11
protected Lock getLock(AxisConfiguration axisConfig) {
    Parameter p = axisConfig.getParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK);
    if (p != null) {
        return (Lock) p.getValue();
    } else {
        log.warn(ServiceBusConstants.SYNAPSE_CONFIG_LOCK + " is null, Recreating a new lock");
        Lock lock = new ReentrantLock();
        try {
            axisConfig.addParameter(ServiceBusConstants.SYNAPSE_CONFIG_LOCK, lock);
            return lock;
        } catch (AxisFault axisFault) {
            log.error("Error while setting " + ServiceBusConstants.SYNAPSE_CONFIG_LOCK);
        }
    }

    return null;
}
 
示例12
public static MessageContext getMessageContextWithOutAuthContext(String context, String version) {
    SynapseConfiguration synCfg = new SynapseConfiguration();
    org.apache.axis2.context.MessageContext axisMsgCtx = new org.apache.axis2.context.MessageContext();
    axisMsgCtx.setIncomingTransportName("http");
    axisMsgCtx.setProperty(Constants.Configuration.TRANSPORT_IN_URL, Path.SEPARATOR+context+Path.SEPARATOR+version
            + Path.SEPARATOR+"search.atom");
    AxisConfiguration axisConfig = new AxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
    MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg,
            new Axis2SynapseEnvironment(cfgCtx, synCfg));
    synCtx.setProperty(RESTConstants.REST_API_CONTEXT, context);
    synCtx.setProperty(RESTConstants.SYNAPSE_REST_API_VERSION, version);
    synCtx.setProperty(APIConstants.API_ELECTED_RESOURCE, "resource");
    Map map = new TreeMap();
    map.put("host","127.0.0.1");
    map.put("X-FORWARDED-FOR", "127.0.0.1");
    map.put("Authorization", "Bearer 123456789");
    synCtx.setProperty(RESTConstants.REST_API_CONTEXT, context);
    synCtx.setProperty(RESTConstants.SYNAPSE_REST_API_VERSION,version);
    ((Axis2MessageContext) synCtx).getAxis2MessageContext()
            .setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map);
    return synCtx;
}
 
示例13
public void createdConfigurationContext(ConfigurationContext configurationContext) {
    AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
    try {
        if (axisConfig.getModule(StatisticsConstants.STATISTISTICS_MODULE_NAME) != null) {
            axisConfig.engageModule(StatisticsConstants.STATISTISTICS_MODULE_NAME);
        }
    } catch (Throwable e) {
        PrivilegedCarbonContext carbonContext =
                PrivilegedCarbonContext.getThreadLocalCarbonContext();
        String msg;
        if (carbonContext.getTenantDomain() != null) {
            msg = "Could not globally engage " + StatisticsConstants.STATISTISTICS_MODULE_NAME +
                  " module to tenant " + carbonContext.getTenantDomain() +
                  "[" + carbonContext.getTenantId() + "]";
        } else {
            msg = "Could not globally engage " + StatisticsConstants.STATISTISTICS_MODULE_NAME +
                  " module to super tenant ";
        }
        log.error(msg, e);
    }
}
 
示例14
/**
 * Undeploy the provided carbon App by sending it through the registered undeployment handler chain.
 *
 * @param carbonApp  - CarbonApplication instance
 * @param axisConfig - AxisConfiguration of the current tenant
 */
private void undeployCarbonApp(CarbonApplication carbonApp,
                               AxisConfiguration axisConfig) {
    log.info("Undeploying Carbon Application : " + carbonApp.getAppNameWithVersion() + "...");
    // Call the undeployer handler chain
    try {
        for (AppDeploymentHandler handler : appDeploymentHandlers) {
            handler.undeployArtifacts(carbonApp, axisConfig);
        }
        // Remove the app from cAppMap list
        removeCarbonApp(carbonApp);

        // Remove the app from registry
        // removing the extracted CApp form tmp/carbonapps/
        FileManipulator.deleteDir(carbonApp.getExtractedPath());
        log.info("Successfully undeployed Carbon Application : " + carbonApp.getAppNameWithVersion()
                         + AppDeployerUtils.getTenantIdLogString(AppDeployerUtils.getTenantId()));
    } catch (Exception e) {
        log.error("Error occurred while trying to unDeploy  : " + carbonApp.getAppNameWithVersion(), e);
    }
}
 
示例15
/**
 * Deploy the data source artifacts and add them to datasources.
 *
 * @param carbonApp  - store info in this object after deploying
 * @param axisConfig - AxisConfiguration of the current tenant
 */
@Override
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(true, artifacts);
}
 
示例16
/**
 * Registers the Endpoint deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void registerDeployer(AxisConfiguration axisConfig,
                              SynapseEnvironment synapseEnvironment)
        throws TenantAwareLoadBalanceEndpointException {
    SynapseConfiguration synCfg = synapseEnvironment
            .getSynapseConfiguration();
    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig
            .getConfigurator();
    SynapseArtifactDeploymentStore deploymentStore = synCfg
            .getArtifactDeploymentStore();

    String synapseConfigPath = ServiceBusUtils
            .getSynapseConfigAbsPath(synapseEnvironment
                    .getServerContextInformation());
    String endpointDirPath = synapseConfigPath + File.separator
            + MultiXMLConfigurationBuilder.ENDPOINTS_DIR;

    for (Endpoint ep : synCfg.getDefinedEndpoints().values()) {
        if (ep.getFileName() != null) {
            deploymentStore.addRestoredArtifact(endpointDirPath
                    + File.separator + ep.getFileName());
        }
    }
    deploymentEngine.addDeployer(new EndpointDeployer(), endpointDirPath,
            ServiceBusConstants.ARTIFACT_EXTENSION);
}
 
示例17
/**
 * Performing the action of importing the given meidation library
 *
 * @param libName
 * @param packageName
 * @param axisConfig AxisConfiguration of the current tenant
 * @throws AxisFault
 */
public void addImport(String libName, String packageName, AxisConfiguration axisConfig) throws AxisFault {
    SynapseImport synImport = new SynapseImport();
    synImport.setLibName(libName);
    synImport.setLibPackage(packageName);
    OMElement impEl = SynapseImportSerializer.serializeImport(synImport);
    if (impEl != null) {
        try {
            addImport(impEl.toString(), axisConfig);
        } catch (AxisFault axisFault) {
            handleException(log, "Could not add Synapse Import", axisFault);
        }
    } else {
        handleException(log,
                "Could not add Synapse Import. Invalid import params for libName : " +
                        libName + " packageName : " + packageName, null);
    }
}
 
示例18
@Test(dataProvider = "getServerURLData")
public void testGetServerURL(String host, int port, String proxyCtx, String ctxRoot, String endpoint, boolean
        addProxyContextPath, boolean addWebContextRoot, String expected) throws Exception {

    when(CarbonUtils.getTransportPort(any(AxisConfiguration.class), anyString())).thenReturn(9443);
    when(CarbonUtils.getTransportProxyPort(any(AxisConfiguration.class), anyString())).thenReturn(port);
    when(CarbonUtils.getManagementTransport()).thenReturn("https");
    when(mockServerConfiguration.getFirstProperty(IdentityCoreConstants.HOST_NAME)).thenReturn(host);
    when(mockServerConfiguration.getFirstProperty(IdentityCoreConstants.WEB_CONTEXT_ROOT)).thenReturn(ctxRoot);
    when(mockServerConfiguration.getFirstProperty(IdentityCoreConstants.PROXY_CONTEXT_PATH)).thenReturn(proxyCtx);

    assertEquals(IdentityUtil.getServerURL(endpoint, addProxyContextPath, addWebContextRoot), expected, String
            .format("Generated server url doesn't match the expected for input: host = %s, " +
                            "port = %d, proxyCtx = %s, ctxRoot = %s, endpoint = %s, addProxyContextPath = %b, " +
                            "addWebContextRoot = %b", host, port, proxyCtx, ctxRoot, endpoint, addProxyContextPath,
                    addWebContextRoot));
}
 
示例19
@Activate
protected void activate(ComponentContext ctxt) {

    BundleContext bundleCtx = ctxt.getBundleContext();
    // Publish the OSGi service
    Dictionary props = new Hashtable();
    props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
    bundleCtx.registerService(AxisObserver.class.getName(), this, props);
    PreAxisConfigurationPopulationObserver preAxisConfigObserver = new PreAxisConfigurationPopulationObserver() {

        public void createdAxisConfiguration(AxisConfiguration axisConfiguration) {

            init(axisConfiguration);
            axisConfiguration.addObservers(UrlMappingDeploymentInterceptor.this);
        }
    };
    bundleCtx.registerService(PreAxisConfigurationPopulationObserver.class.getName(), preAxisConfigObserver, null);
    // Publish an OSGi service to listen tenant configuration context creation events
    Dictionary properties = new Hashtable();
    properties.put(CarbonConstants.AXIS2_CONFIG_SERVICE, Axis2ConfigurationContextObserver.class.getName());
    bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(), new UrlMappingServiceListener(),
            properties);
}
 
示例20
/**
 * This method verifies whether there's an existing data service group for the given name data service group.
 *
 * @param axisConfiguration Axis configuration
 * @param dataServiceGroup  Data service Group
 * @return Boolean (Is available)
 * @throws AxisFault
 */
public static boolean isAvailableDSServiceGroup(AxisConfiguration axisConfiguration, String dataServiceGroup)
        throws AxisFault {
    Iterator<AxisServiceGroup> map = axisConfiguration.getServiceGroups();
    while (map.hasNext()) {
        AxisServiceGroup serviceGroup = map.next();
        if (serviceGroup.getServiceGroupName().equals(dataServiceGroup)) {
            return true;
        }
    }
    return false;
}
 
示例21
public static void waitAndInitialize() {
    try {
        String mgtTransport = CarbonUtils.getManagementTransport();
        AxisConfiguration axisConfiguration = ServiceReferenceHolder
                .getContextService().getServerConfigContext().getAxisConfiguration();
        int mgtTransportPort = CarbonUtils.getTransportProxyPort(axisConfiguration, mgtTransport);
        if (mgtTransportPort <= 0) {
            mgtTransportPort = CarbonUtils.getTransportPort(axisConfiguration, mgtTransport);
        }
        // Using localhost as the hostname since this is always an internal admin service call.
        // Hostnames that can be retrieved using other approaches does not work in this context.
        url = mgtTransport + "://" + TenantInitializationConstants.LOCAL_HOST_NAME + ":" + mgtTransportPort
                + "/services/";
        adminName = ServiceDataHolder.getInstance().getRealmService()
                .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getRealmConfiguration()
                .getAdminUserName();
        adminPwd = ServiceDataHolder.getInstance().getRealmService()
                .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getRealmConfiguration()
                .getAdminPassword().toCharArray();
        executor = new ScheduledThreadPoolExecutor(1);
        executor.scheduleAtFixedRate(new ScheduledThreadPoolExecutorImpl(),
                TenantInitializationConstants.DEFAULT_WAIT_DURATION,
                TenantInitializationConstants.DEFAULT_WAIT_DURATION, TimeUnit.SECONDS);
    } catch (UserStoreException e) {
        log.error("An error occurred while retrieving admin credentials for initializing on-premise " +
                "gateway configuration.", e);
    }
}
 
示例22
public void createdConfigurationContext(ConfigurationContext configurationContext) {
    AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
    try {
        if (DiscoveryMgtUtils.isServiceDiscoveryEnabled(axisConfig)) {
            if (log.isDebugEnabled()) {
                String domain = PrivilegedCarbonContext.getThreadLocalCarbonContext().
                        getTenantDomain(true);
                log.debug("Registering the Axis observer for WS-Discovery in tenant: " + domain);
            }
            Util.registerServiceObserver(axisConfig);
        }
    } catch (RegistryException e) {
        log.error("Checking whether service discovery is enabled for a tenant", e);
    }
}
 
示例23
/**
 * @param flag; support ON or OFF.
 * @return The information about the Tracer service
 * @throws AxisFault If the tracer module is not found
 */
public TracerServiceInfo setMonitoring(String flag) throws AxisFault {
    if (!flag.equalsIgnoreCase("ON") && !flag.equalsIgnoreCase("OFF")) {
        throw new RuntimeException("IllegalArgument for monitoring status. Only 'ON' and 'OFF' is allowed");
    }
    TracerServiceInfo tracerServiceInfo = new TracerServiceInfo();
    ConfigurationContext configurationContext = getConfigContext();
    AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
    AxisModule axisModule = axisConfiguration.getModule(TracerConstants.WSO2_TRACER);

    if (axisModule == null) {
        throw new RuntimeException(TracerAdmin.class.getName() + " " +
                                   TracerConstants.WSO2_TRACER + " is not available");
    }

    if (flag.equalsIgnoreCase("ON")) {
        if (!axisConfiguration.isEngaged(axisModule.getName())) {
            try {
                axisConfiguration.engageModule(axisModule);
            } catch (AxisFault axisFault) {
                log.error(axisFault);
                throw new RuntimeException(axisFault);
            }
        }
    } else if (flag.equalsIgnoreCase("OFF")) {
        if (axisConfiguration.isEngaged(axisModule.getName())) {
            axisConfiguration.disengageModule(axisModule);
            configurationContext.removeProperty(TracerConstants.MSG_SEQ_BUFFER);
        }
    }
    TracePersister tracePersister = getTracePersister();
    tracePersister.saveTraceStatus(flag);
    tracerServiceInfo.setEmpty(true);
    tracerServiceInfo.setFlag(flag);
    tracerServiceInfo.setTracePersister(tracePersister.getClass().getName());

    return tracerServiceInfo;
}
 
示例24
@Test
public void testUnsetConfigurationContextService() {
    AxisConfiguration axisConfiguration = new AxisConfiguration();
    ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
    hostObjectComponent.unsetConfigurationContextService(configurationContextService);
    // Nothing to assert
}
 
示例25
protected void unsetSynapseRegistrationsService(SynapseRegistrationsService synapseRegistrationsService) {

        int tenantId = synapseRegistrationsService.getTenantId();
        if (synapseEnvironmentServices.containsKey(tenantId)) {
            SynapseEnvironment env = synapseEnvironmentServices.get(tenantId).getSynapseEnvironment();
            synapseEnvironmentServices.remove(synapseRegistrationsService.getTenantId());
            AxisConfiguration axisConfig = synapseRegistrationsService.getConfigurationContext().getAxisConfiguration();
            if (axisConfig != null) {
                unregistryDeployer(axisConfig, env);
            }
        }
    }
 
示例26
public void init(ConfigurationContext configContext,
                 AxisModule module) throws AxisFault {

    AxisConfiguration axisConfig = configContext.getAxisConfiguration();

    {
        AtomicInteger globalRequestCounter = new AtomicInteger(0);
        Parameter globalRequestCounterParam = new Parameter();
        globalRequestCounterParam.setName(StatisticsConstants.GLOBAL_REQUEST_COUNTER);
        globalRequestCounterParam.setValue(globalRequestCounter);
        axisConfig.addParameter(globalRequestCounterParam);
    }

    {
        AtomicInteger globalResponseCounter = new AtomicInteger(0);
        Parameter globalResponseCounterParam = new Parameter();
        globalResponseCounterParam.setName(StatisticsConstants.GLOBAL_RESPONSE_COUNTER);
        globalResponseCounterParam.setValue(globalResponseCounter);
        axisConfig.addParameter(globalResponseCounterParam);
    }

    {
        AtomicInteger globalFaultCounter = new AtomicInteger(0);
        Parameter globalFaultCounterParam = new Parameter();
        globalFaultCounterParam.setName(StatisticsConstants.GLOBAL_FAULT_COUNTER);
        globalFaultCounterParam.setValue(globalFaultCounter);
        axisConfig.addParameter(globalFaultCounterParam);
    }

    {
        ResponseTimeProcessor responseTimeProcessor = new ResponseTimeProcessor();
        Parameter responseTimeProcessorParam = new Parameter();
        responseTimeProcessorParam.setName(StatisticsConstants.RESPONSE_TIME_PROCESSOR);
        responseTimeProcessorParam.setValue(responseTimeProcessor);
        axisConfig.addParameter(responseTimeProcessorParam);
    }
}
 
示例27
private MessageContext createMessageContext() throws AxisFault {
    SynapseConfiguration synConfig = new SynapseConfiguration();
    AxisConfiguration axisConfig = new AxisConfiguration();
    synConfig.setAxisConfiguration(axisConfig);

    org.apache.axis2.context.MessageContext axis2Ctx = new org.apache.axis2.context.MessageContext();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
    axis2Ctx.setConfigurationContext(cfgCtx);

    MessageContextCreatorForAxis2.setSynConfig(synConfig);
    MessageContextCreatorForAxis2.setSynEnv(new Axis2SynapseEnvironment(synConfig));
    return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2Ctx);
}
 
示例28
public SecurityConfigAdmin(AxisConfiguration config, Registry reg, CallbackHandler cb) {
    this.axisConfig = config;
    this.registry = reg;
    this.callback = cb;

    try {
        this.govRegistry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry(
                ((UserRegistry) reg).getTenantId());
    } catch (Exception e) {
        // TODO : handle this exception properly.
        log.error("Error when obtaining the governance registry instance.", e);
    }
}
 
示例29
public void creatingConfigurationContext(org.apache.axis2.context.ConfigurationContext configCtx) {
    AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
    //Register UrlMappingDeploymentInterceptor as an AxisObserver in tenant's AxisConfig.
    UrlMappingDeploymentInterceptor secDeployInterceptor = new UrlMappingDeploymentInterceptor();
    secDeployInterceptor.init(axisConfig);
    axisConfig.addObservers(secDeployInterceptor);
}
 
示例30
@Test
public void testDestroy() {
    APIAuthenticationHandler apiAuthenticationHandler = new APIAuthenticationHandler();
    apiAuthenticationHandler.destroy();
    SynapseEnvironment synapseEnvironment = Mockito.mock(SynapseEnvironment.class);
    SynapseConfiguration synapseConfiguration = Mockito.mock(SynapseConfiguration.class);
    AxisConfiguration axisConfiguration = Mockito.mock(AxisConfiguration.class);
    Mockito.when(synapseEnvironment.getSynapseConfiguration()).thenReturn(synapseConfiguration);
    Mockito.when(synapseConfiguration.getAxisConfiguration()).thenReturn(axisConfiguration);
    PowerMockito.mockStatic(Util.class);
    PowerMockito.when(Util.getTenantDomain()).thenReturn("carbon.super");
    apiAuthenticationHandler.init(synapseEnvironment);
    apiAuthenticationHandler.destroy();
}