Java Code Examples for org.apache.axis2.context.ConfigurationContext#getProperty()

The following examples show how to use org.apache.axis2.context.ConfigurationContext#getProperty() . 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: AbstractTracingHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Appends SOAP message metadata to a message buffer
 *
 * @param configCtx  The server ConfigurationContext
 * @param serviceName  The service name
 * @param operationName  The operation name
 * @param msgSeq The message sequence. Use -1 if unknown.
 */
protected void appendMessage(ConfigurationContext configCtx,
                             String serviceName,
                             String operationName,
                             Long msgSeq) {
    CircularBuffer<MessageInfo> buffer =
        (CircularBuffer<MessageInfo>) configCtx.getProperty(TracerConstants.MSG_SEQ_BUFFER);
    if (buffer == null){
        buffer = new CircularBuffer<MessageInfo>(TracerConstants.MSG_BUFFER_SZ);
        configCtx.setProperty(TracerConstants.MSG_SEQ_BUFFER, buffer);
    }
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(new Date());
    MessageInfo messageInfo = new MessageInfo();
    messageInfo.setMessageSequence(msgSeq);
    messageInfo.setOperationName(operationName);
    messageInfo.setServiceId(serviceName);
    messageInfo.setTimestamp(cal);
    buffer.append(messageInfo);
}
 
Example 2
Source File: ServerStatus.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Get the current server status
 *
 * @return The current server status
 * @throws AxisFault If an error occurs while getting the ConfigurationContext
 */
public static String getCurrentStatus() {
    ConfigurationContext configCtx =
            CarbonConfigurationContextFactory.getConfigurationContext();
    String currentStatus = (String) configCtx.getProperty(CURRENT_SERVER_STATUS);
    if (currentStatus == null) {
        configCtx.setProperty(CURRENT_SERVER_STATUS, STATUS_STARTING);
        return STATUS_STARTING;
    }
    return currentStatus;
}
 
Example 3
Source File: APIThrottleHandler.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
private boolean doThrottle(MessageContext messageContext) {
    boolean isResponse = messageContext.isResponse();
    org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext).
            getAxis2MessageContext();
    ConfigurationContext cc = axis2MC.getConfigurationContext();

    ThrottleDataHolder dataHolder = null;
    if (cc == null) {
        handleException("Error while retrieving ConfigurationContext from messageContext");
    }

    synchronized (cc) {
        dataHolder = (ThrottleDataHolder) cc.getProperty(ThrottleConstants.THROTTLE_INFO_KEY);
        if (dataHolder == null) {
            dataHolder = new ThrottleDataHolder();
            cc.setNonReplicableProperty(ThrottleConstants.THROTTLE_INFO_KEY, dataHolder);
        }
    }

    if ((throttle == null && !isResponse) || (isResponse && concurrentAccessController == null)) {
        isClusteringEnable = isClusteringEnabled();
    }

    if (!isResponse) {
        //check the availability of the ConcurrentAccessController
        //if this is a clustered environment
        if (isClusteringEnable) {
            concurrentAccessController = (ConcurrentAccessController) cc.getProperty(key);
        }
        initThrottle(messageContext, cc);
    } else {
        // if the message flow path is OUT , then must lookup from ConfigurationContext -
        // never create ,just get the existing one
        concurrentAccessController = (ConcurrentAccessController) cc.getProperty(key);
    }


    // perform concurrency throttling
    boolean canAccess = doThrottleByConcurrency(isResponse);
    // if the access is success through concurrency throttle and if this is a request message
    // then do access rate based throttling
    if (canAccess && !isResponse && throttle != null) {
        canAccess = throttleByAccessRate(axis2MC, cc) &&
                doRoleBasedAccessThrottling(messageContext, cc);
    }

    // All the replication functionality of the access rate based throttling handled by itself
    // Just replicate the current state of ConcurrentAccessController
    if (isClusteringEnable && concurrentAccessController != null) {

        try {
            Replicator.replicate(cc);
        } catch (ClusteringFault clusteringFault) {
            handleException("Error during the replicating  states ", clusteringFault);
        }

    }

    if (!canAccess) {
        handleThrottleOut(messageContext);
        return false;
    }
    return true;
}
 
Example 4
Source File: WSDL2Code.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
/**
 * Generates code for CXF
 *
 * @param options
 * @return
 * @throws AxisFault
 */
public CodegenDownloadData codegenForCXF(String[] options) throws AxisFault {
    boolean isJaxWs = true; //Otherwise JaxRS
    String uuid = String.valueOf(System.currentTimeMillis() + Math.random());
    ConfigurationContext configContext = getConfigContext();
    String codegenOutputDir = configContext.getProperty(ServerConstants.WORK_DIR) + File.separator
            + "tools_codegen" + File.separator + uuid + File.separator;
    System.getProperties().remove("project.base.dir");
    System.getProperties().remove("name");
    System.setProperty("project.base.dir", codegenOutputDir);

    ArrayList<String> optionsList = new ArrayList<String>();
    HashMap<String, String> projOptionsList = new HashMap<String, String>();
    // adding default configurations

    projOptionsList.put("-gid", "WSO2");
    projOptionsList.put("-vn", "0.0.1-SNAPSHOT");
    projOptionsList.put("-aid", "WSO2-Axis2-Client");

                int i = 0;
    for (String s : options) {

           if (s.equalsIgnoreCase("-jaxws") || s.equalsIgnoreCase("-jaxrs")) {
            if (s.equals("-jaxrs")) {
                isJaxWs = false;
                //This is only to distinguish jaxws and jaxrs. Therefore no need of adding this to options list
                i++;
                continue;
            }
        }
        if (s.equalsIgnoreCase("-gid") || s.equalsIgnoreCase("-vn") || s.equalsIgnoreCase("-aid")) {
            projOptionsList.put(s, options[i + 1]);
        } else {
            optionsList.add(s);
        }
        i++;
    }

    if (isJaxWs) {
        return getJaxWSCodegenDownloadData(configContext, codegenOutputDir, optionsList, projOptionsList);
    } else {
        return getJaxRSCodegenDownloadData(configContext, codegenOutputDir, optionsList, projOptionsList);
    }
}