001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.transport.auto; 018 019import java.util.Arrays; 020import java.util.HashMap; 021import java.util.HashSet; 022import java.util.Map; 023import java.util.Set; 024 025import org.apache.activemq.util.IntrospectionSupport; 026 027/** 028 * 029 * 030 */ 031public class AutoTransportUtils { 032 033 //wireformats 034 public static String ALL = "all"; 035 public static String OPENWIRE = "default"; 036 public static String STOMP = "stomp"; 037 public static String AMQP = "amqp"; 038 public static String MQTT = "mqtt"; 039 040 //transports 041 public static String AUTO = "auto"; 042 043 public static Map<String, Map<String, Object>> extractWireFormatOptions(Map<String, String> options ) { 044 Map<String, Map<String, Object>> wireFormatOptions = new HashMap<>(); 045 if (options != null) { 046 wireFormatOptions.put(OPENWIRE, IntrospectionSupport.extractProperties(options, "wireFormat.default.")); 047 wireFormatOptions.put(STOMP, IntrospectionSupport.extractProperties(options, "wireFormat.stomp.")); 048 wireFormatOptions.put(AMQP, IntrospectionSupport.extractProperties(options, "wireFormat.amqp.")); 049 wireFormatOptions.put(MQTT, IntrospectionSupport.extractProperties(options, "wireFormat.mqtt.")); 050 wireFormatOptions.put(ALL, IntrospectionSupport.extractProperties(options, "wireFormat.")); 051 } 052 return wireFormatOptions; 053 } 054 055 public static Set<String> parseProtocols(String protocolString) { 056 Set<String> protocolSet = new HashSet<>();; 057 if (protocolString != null && !protocolString.isEmpty()) { 058 protocolSet.addAll(Arrays.asList(protocolString.split(","))); 059 } 060 return protocolSet; 061 } 062}