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

The following examples show how to use org.apache.axis2.engine.AxisConfiguration#getParameter() . 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: 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 2
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 3
Source File: DiscoveryShutdownHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void invoke() {

        ConfigurationContext mainCfgCtx =
                ConfigHolder.getInstance().getServerConfigurationContext();
        if (mainCfgCtx != null) {
            AxisConfiguration mainAxisConfig = mainCfgCtx.getAxisConfiguration();
            if (mainAxisConfig.getParameter(DiscoveryConstants.DISCOVERY_PROXY) != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Sending BYE messages for services deployed in the super tenant");
                }
                Util.unregisterServiceObserver(mainAxisConfig, true);
            }
        } else {
            log.warn("Unable to notify service undeployment. ConfigurationContext is " +
                    "unavailable.");
        }
    }
 
Example 4
Source File: ServiceBusUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static MediationPersistenceManager getMediationPersistenceManager(
        AxisConfiguration axisCfg) {
    
    Parameter p = axisCfg.getParameter(
            ServiceBusConstants.PERSISTENCE_MANAGER);
    if (p != null) {
        return (MediationPersistenceManager) p.getValue();
    }

    return null;
}
 
Example 5
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public double getAvgSystemResponseTime(AxisConfiguration axisConfig) {
    Parameter processor =
            axisConfig.getParameter(StatisticsConstants.RESPONSE_TIME_PROCESSOR);
    if (processor != null) {
        Object value = processor.getValue();
        if (value instanceof ResponseTimeProcessor) {
            return ((ResponseTimeProcessor) value).getAvgResponseTime();
        }
    }
    return 0;
}
 
Example 6
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public long getMaxSystemResponseTime(AxisConfiguration axisConfig) {
    Parameter processor =
            axisConfig.getParameter(StatisticsConstants.RESPONSE_TIME_PROCESSOR);
    if (processor != null) {
        Object value = processor.getValue();
        if (value instanceof ResponseTimeProcessor) {
            return ((ResponseTimeProcessor) value).getMaxResponseTime();
        }
    }
    return 0;
}
 
Example 7
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public long getMinSystemResponseTime(AxisConfiguration axisConfig) {
    Parameter processor =
            axisConfig.getParameter(StatisticsConstants.RESPONSE_TIME_PROCESSOR);
    if (processor != null) {
        Object value = processor.getValue();
        if (value instanceof ResponseTimeProcessor) {
            return ((ResponseTimeProcessor) value).getMinResponseTime();
        }
    }
    return 0;
}
 
Example 8
Source File: DiscoveryAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get the current service discovery configuration
 *
 * @return a ServiceDiscoveryConfig instance
 * @throws Exception on error
 */
public ServiceDiscoveryConfig getServiceDiscoveryConfig() throws Exception {
    ServiceDiscoveryConfig config = new ServiceDiscoveryConfig();
    AxisConfiguration axisConfig = getAxisConfig();
    Parameter param = axisConfig.getParameter(DiscoveryConstants.DISCOVERY_PROXY);
    config.setEnabled(param != null);
    config.setProxyURL(DiscoveryMgtUtils.getDiscoveryProxyURL(axisConfig));
    return config;
}
 
Example 9
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 10
Source File: DiscoveryAdmin.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Disable publishing services using WS-Discovery
 *
 * @param sendBye true is BYE messages should be sent before disabling WS-Discovery
 * @throws Exception on error
 */
public void disableServiceDiscovery(boolean sendBye) throws Exception {
    AxisConfiguration axisConfig = getAxisConfig();
    Parameter param = axisConfig.getParameter(DiscoveryConstants.DISCOVERY_PROXY);
    if (param == null) {
        return;
    }

    DiscoveryMgtUtils.persistPublisherConfiguration(param.getValue().toString(), false,
            getConfigSystemRegistry());
    Util.unregisterServiceObserver(axisConfig, sendBye);
    axisConfig.removeParameter(param);
}
 
Example 11
Source File: Util.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Disengage the TargetServiceObserver from the given AxisConfiguration. This will
 * disable service discovery. If sendBye is set to 'true' this method will also send BYE
 * messages to the discovery proxy before disabling the TargetServiceObserver. This method
 * expects the discovery proxy parameter is available in the AxisConfiguration. Without
 * that it will not send BYE messages even if sendBye is set to 'true'.
 *
 * @param axisConf AxisConfiguration instance
 * @param sendBye true if BYE messages should be sent for all the deployed services
 */
public static void unregisterServiceObserver(AxisConfiguration axisConf, boolean sendBye) {
    if (sendBye) {
        Parameter discoveryProxyParam = axisConf.getParameter(DiscoveryConstants.DISCOVERY_PROXY);
        if (discoveryProxyParam != null) {
            MessageSender messageSender = new MessageSender();
            try {
                for (AxisService axisService : axisConf.getServices().values()) {
                    messageSender.sendBye(axisService, (String) discoveryProxyParam.getValue());
                }
            } catch (DiscoveryException e) {
                log.error("Cannot send the bye message", e);
            }
        }
    }

    List<AxisObserver> observers = axisConf.getObserversList();
    AxisObserver serviceObserver = null;
    // Locate the TargetServiceObserver instance registered earlier
    for (AxisObserver o : observers) {
        if (o instanceof TargetServiceObserver) {
            serviceObserver = o;
            break;
        }
    }

    if (serviceObserver != null) {            
        observers.remove(serviceObserver);
    }
}
 
Example 12
Source File: SystemStatistics.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public void update(AxisConfiguration axisConfig) throws AxisFault {

        int tenantId =  PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        Parameter systemStartTime =
                axisConfig.getParameter(CarbonConstants.SERVER_START_TIME);
        long startTime = 0;
        if (systemStartTime != null) {
            startTime = Long.parseLong((String) systemStartTime.getValue());
        }
        Date stTime = new Date(startTime);

        // only super admin can view serverStartTime and systemUpTime
        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            serverStartTime = dateFormatter.format(stTime);
            systemUpTime = (getTime((System.currentTimeMillis() - startTime) / 1000));
        }
        try {
            totalRequestCount = statService.getTotalSystemRequestCount(axisConfig);
            totalResponseCount = statService.getSystemResponseCount(axisConfig);
            totalFaultCount = statService.getSystemFaultCount(axisConfig);
            avgResponseTime = statService.getAvgSystemResponseTime(axisConfig);
            maxResponseTime = statService.getMaxSystemResponseTime(axisConfig);
            minResponseTime = statService.getMinSystemResponseTime(axisConfig);

        } catch (Exception e) {
            throw AxisFault.makeFault(e);
        }

        Runtime runtime = Runtime.getRuntime();

        // only super admin can view usedMemory and totalMemory
        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            usedMemory = formatMemoryValue(runtime.totalMemory() - runtime.freeMemory());
            totalMemory = formatMemoryValue(runtime.totalMemory());
        }
        wso2wsasVersion = ServerConfiguration.getInstance().getFirstProperty("Version");

        int activeServices = 0;
        for (Iterator services = axisConfig.getServices().values().iterator();
             services.hasNext(); ) {
            AxisService axisService = (AxisService) services.next();
            AxisServiceGroup asGroup = (AxisServiceGroup) axisService.getParent();
            if (axisService.isActive() &&
                !axisService.isClientSide() &&
                !SystemFilter.isFilteredOutService(asGroup)) {
                activeServices++;
            }
        }

        this.services = activeServices;
        try {
            // only susper admin is allow to view serverName.
            if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
                serverName = NetworkUtils.getLocalHostname();
            }
        } catch (SocketException ignored) {
        }
    }
 
Example 13
Source File: SystemStatisticsUtil.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
private int getSystemStatisticsCount(AxisConfiguration axisConfig,
                                     String parameterName) {
    Parameter globalCounter =
            axisConfig.getParameter(parameterName);
    return ((AtomicInteger) globalCounter.getValue()).get();
}
 
Example 14
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);
        }
    }
}
 
Example 15
Source File: DiscoveryMgtUtils.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public static Parameter getDiscoveryParam(AxisConfiguration axisConfig) {
    return axisConfig.getParameter(DiscoveryConstants.DISCOVERY_PROXY);
}