Java Code Examples for org.apache.axis2.engine.AxisConfiguration#addParameter()

The following examples show how to use org.apache.axis2.engine.AxisConfiguration#addParameter() . 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: ServiceComponent.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Acquires the lock
 *
 * @param axisConfig AxisConfiguration instance
 * @return Lock instance
 */
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;
}
 
Example 3
Source File: MediationPersistenceManager.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: StatisticsModule.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 5
Source File: DiscoveryAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Enable publishing services using WS-Discovery to the specified Discovery proxy
 *
 * @param proxyURL URL of the target discovery proxy
 * @throws Exception on error
 */
public void enableServiceDiscovery(String proxyURL) throws Exception {
    AxisConfiguration axisConfig = getAxisConfig();
    if (axisConfig.getParameter(DiscoveryConstants.DISCOVERY_PROXY) != null) {
        return;
    }

    Parameter param = new Parameter(DiscoveryConstants.DISCOVERY_PROXY, proxyURL);
    param.setParameterElement(AXIOMUtil.stringToOM("<parameter name=\"" +
            DiscoveryConstants.DISCOVERY_PROXY + "\">" + proxyURL + "</parameter>"));
    axisConfig.addParameter(param);
    Util.registerServiceObserver(axisConfig);
    DiscoveryMgtUtils.persistPublisherConfiguration(proxyURL, true, getConfigSystemRegistry());
}
 
Example 6
Source File: DiscoveryMgtUtils.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether service discovery is enabled in the configuration. This method first checks
 * whether the DiscoveryConstants.DISCOVERY_PROXY parameter is set in the given AxisConfiguration.
 * If not it checks whether service discovery status is set to 'true' in the configuration
 * registry. If discovery is enabled in the registry configuration, this method will also
 * add the corresponding parameter to AxisConfiguration.
 *
 * @param axisConfig AxisConfiguration
 * @return service discovery status
 * @throws RegistryException if an error occurs while accessing the registry
 */
public static boolean isServiceDiscoveryEnabled(AxisConfiguration axisConfig) throws RegistryException {
    Parameter parameter = getDiscoveryParam(axisConfig);
    if (parameter != null) {
        return true;
    }

    String path = DISCOVERY_CONFIG_ROOT + DISCOVERY_PUBLISHER_CONFIG;

    Registry registry = PrivilegedCarbonContext.getThreadLocalCarbonContext().
            getRegistry(RegistryType.SYSTEM_CONFIGURATION);
    if (registry.resourceExists(path)) {
        Resource publisherConfig = registry.get(path);
        String status = publisherConfig.getProperty(DISCOVERY_PUBLISHER_STATUS);
        publisherConfig.discard();
        boolean enabled = JavaUtils.isTrueExplicitly(status);

        if (enabled) {
            String discoveryProxyURL = getDiscoveryProxyURL(registry);
            try {
                Parameter discoveryProxyParam =
                        ParameterUtil.createParameter(DiscoveryConstants.DISCOVERY_PROXY,
                                                      discoveryProxyURL);
                axisConfig.addParameter(discoveryProxyParam);
            } catch (AxisFault axisFault) {
                axisFault.printStackTrace();  //TODO
            }
        }
        return enabled;
    }

    return false;
}
 
Example 7
Source File: ServiceBusInitializer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private ServerContextInformation initESB(String name) throws AxisFault {

        if (configCtxSvc != null) {
            ConfigurationContext configContext = configCtxSvc.getServerConfigContext();
            log.debug("Initializing Apache Synapse...");
            configurationInformation = ServerConfigurationInformationFactory.createServerConfigurationInformation
                    (configContext.getAxisConfiguration());
            // ability to specify the SynapseServerName as a system property
            if (System.getProperty("SynapseServerName") != null) {
                configurationInformation.setServerName(System.getProperty("SynapseServerName"));
            }
            // for now we override the default configuration location with the value in registry
            String synapseConfigsLocation = configurationInformation.getSynapseXMLLocation();
            if (synapseConfigsLocation != null) {
                configurationInformation.setSynapseXMLLocation(synapseConfigsLocation + File.separator + name);
            } else {
                configurationInformation.setSynapseXMLLocation(ServiceBusConstants.DEFAULT_SYNAPSE_CONFIGS_LOCATION +
                        name);
            }
            configurationInformation.setCreateNewInstance(false);
            configurationInformation.setServerControllerProvider(CarbonSynapseController.class.getName());
            if (isRunningSamplesMode()) {
                if (System.getProperty(ServiceBusConstants.ESB_SAMPLE_SYSTEM_PROPERTY) != null) {
                    configurationInformation.setSynapseXMLLocation("repository" + File.separator + "samples" + File
                            .separator + "synapse_sample_" + System.getProperty(ServiceBusConstants
                            .ESB_SAMPLE_SYSTEM_PROPERTY) + ".xml");
                } else {
                    configurationInformation.setSynapseXMLLocation("samples" + File.separator + "service-bus" + File
                            .separator + "synapse_sample_" + System.getProperty(ServiceBusConstants
                            .EI_SAMPLE_SYSTEM_PROPERTY) + ".xml");
                }
            }
            serverManager = new ServerManager();
            ServerContextInformation contextInfo = new ServerContextInformation(configContext,
                    configurationInformation);

            if (secretCallbackHandlerService != null) {
                contextInfo.addProperty(SecurityConstants.PROP_SECRET_CALLBACK_HANDLER, secretCallbackHandlerService
                        .getSecretCallbackHandler());
            }
            AxisConfiguration axisConf = configContext.getAxisConfiguration();
            axisConf.addParameter(new Parameter(ServiceBusConstants.SYNAPSE_CURRENT_CONFIGURATION, name));
            if (isRunningDebugMode()) {
                log.debug("Micro Integrator started in Debug mode for super tenant");
                createSynapseDebugEnvironment(contextInfo);
            }
            boolean initConnectors = !Boolean.valueOf(System.getProperty(ServiceBusConstants
                    .DISABLE_CONNECTOR_INIT_SYSTEM_PROPERTY));
            if (initConnectors) {
                // Enable connectors
                SynapseArtifactInitUtils.initializeConnectors(axisConf);
            }
            serverManager.init(configurationInformation, contextInfo);
            serverManager.start();
            AxisServiceGroup serviceGroup = axisConf.getServiceGroup(SynapseConstants.SYNAPSE_SERVICE_NAME);
            serviceGroup.addParameter("hiddenService", "true");
            return contextInfo;
        } else {
            handleFatal("Couldn't initialize Synapse, " + "ConfigurationContext service or SynapseRegistryService is " +
                    "not available");
        }
        // never executes, but keeps the compiler happy
        return null;
    }
 
Example 8
Source File: WSDL2FormGenerator.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
private synchronized void updateMockProxyServiceGroup(AxisService axisService, ConfigurationContext configCtx,
                                                      AxisConfiguration axisConfig)
        throws AxisFault {
    /*axisService.addParameter("supportSingleOperation", Boolean.TRUE);
    AxisOperation singleOP = new InOutAxisOperation(new QName("invokeTryItProxyService"));
    singleOP.setDocumentation("This operation is a 'passthrough' for all operations in " +
                              " TryIt proxy service.");
    axisService.addOperation(singleOP);*/
    ProxyMessageReceiver receiver = new ProxyMessageReceiver(configCtx);
    PhasesInfo phaseInfo = axisConfig.getPhasesInfo();
    for (Iterator i = axisService.getOperations(); i.hasNext();) {
        AxisOperation op = (AxisOperation) i.next();
        op.setMessageReceiver(receiver);
        phaseInfo.setOperationPhases(op);
    }
    AxisServiceGroup serviceGroup;
    synchronized (axisConfig) {
        serviceGroup = axisConfig.getServiceGroup(TRYIT_SG_NAME);
        if (serviceGroup == null) {
            serviceGroup = new AxisServiceGroup();
            serviceGroup.setServiceGroupName(TRYIT_SG_NAME);
            serviceGroup.addParameter("DoAuthentication", "false");
            serviceGroup.addParameter("adminService", "true");
        }

        // resolving Axis service name conflicts.
        AxisService testService = axisConfig.getService(axisService.getName());
        if (testService != null) {
            for (int loop = 1; ; loop++) {
                String testName = axisService.getName() + "_" + loop;
                if (axisConfig.getService(testName) == null) {
                    axisService.setName(testName);
                    break;
                }
            }
        }
        serviceGroup.addService(axisService);
        axisConfig.addServiceGroup(serviceGroup);
        axisService.addParameter(LAST_TOUCH_TIME, System.currentTimeMillis());
        axisService.addParameter("modifyUserWSDLPortAddress", "false");
        // Set the timer.
        Parameter parameter = axisConfig.getParameter(PROXY_TIMER);
        if (parameter == null) {
            Timer timer = new Timer();
            timer.scheduleAtFixedRate(new ProxyTimerTask(axisConfig), PERIOD, PERIOD);
            parameter = new Parameter(PROXY_TIMER, timer);
            axisConfig.addParameter(parameter);
        }
    }
}