public static Protocol getMessageProtocol()

in modules/core/src/main/java/org/apache/savan/util/ProtocolManager.java [33:55]


    public static Protocol getMessageProtocol(SavanMessageContext smc) throws SavanException {
        //TODO to this depending on Protocol rules. //TODO make this algorithm efficient

        ConfigurationManager configurationManager = (ConfigurationManager)smc
                .getConfigurationContext().getProperty(SavanConstants.CONFIGURATION_MANAGER);
        if (configurationManager == null)
            throw new SavanException("Cant find the Configuration Manager");

        String action = smc.getMessageContext().getOptions().getAction();
        if (action != null) {
            HashMap map = configurationManager.getProtocolMap();
            Iterator iter = map.values().iterator();
            while (iter.hasNext()) {
                Protocol protocol = (Protocol)iter.next();
                MappingRules mappingRules = protocol.getMappingRules();
                if (mappingRules.ruleMatched(MappingRules.MAPPING_TYPE_ACTION, action)) {
                    return protocol;
                }
            }
        }

        return null;
    }