2 * Copyright 2016 ZTE, Inc. and others.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package org.openo.msb.wrapper.util;
\r
19 import org.apache.commons.lang3.StringUtils;
\r
20 import org.openo.msb.api.DiscoverInfo;
\r
23 public class RouteUtil {
\r
25 public static String IUI_ROOT_PATH="iui";
\r
27 public static String API_ROOT_PATH="api";
\r
29 public static final String ROUTE_PATH="msb:routing";
\r
31 public static final String APIROUTE="api";
\r
33 public static final String IUIROUTE="iui";
\r
35 public static final String CUSTOMROUTE="custom";
\r
37 public static final String P2PROUTE="p2p";
\r
40 public static final String ROUTE_PATH_INFO="info";
\r
42 public static final String ROUTE_PATH_LOADBALANCE="lb";
\r
44 public static final String APIROUTE_PATH_LIFE="life";
\r
47 public static final String REQUEST_SUCCESS = "SUCCESS";
\r
49 public static final String REQUEST_FAIL = "FAIL";
\r
51 public static String PROTOCOL_LIST="REST,UI,MQ,FTP,SNMP,TCP,UDP";
\r
53 public static DiscoverInfo discoverInfo=new DiscoverInfo();
\r
56 public static String[] visualRangeRange={"0","1"};
\r
58 public static String[] controlRangeMatches={"0","1","2"};
\r
60 public static String[] statusRangeMatches={"0","1"};
\r
62 public static String[] useOwnUpstreamRangeMatches={"0","1"};
\r
64 public static String[] visualRangeMatches={"1"};
\r
67 * @Title: getPrefixedKey
\r
68 * @Description: TODO(Add base path prefix radis assembly path)
\r
69 * @param: @param serviceName
\r
70 * @param: @param version
\r
71 * @param: @param type
\r
76 public static String getPrefixedKey(String...paths){
\r
77 StringBuffer sb= new StringBuffer();
\r
79 if(paths[0].trim().equals("") || paths[0].equals(String.valueOf(JedisUtil.serverPort))){
\r
80 sb.append(ROUTE_PATH);
\r
83 sb.append(paths[0]);
\r
86 for (int i = 1; i < paths.length; i++) {
\r
88 sb.append(paths[i]);
\r
90 return sb.toString();
\r
94 public static Object[] concat(Object[] a, Object[] b) {
\r
95 Object[] c= new Object[a.length+b.length];
\r
96 System.arraycopy(a, 0, c, 0, a.length);
\r
97 System.arraycopy(b, 0, c, a.length, b.length);
\r
101 public static boolean contain(String[] array,String str){
\r
102 for(int i=0;i<array.length;i++){
\r
103 if(array[i].equals(str)){
\r
111 public static boolean contain(String[] array,String value[]){
\r
112 for(int i=0;i<array.length;i++){
\r
113 for(int n=0;n<value.length;n++){
\r
114 if(array[i].equals(value[n])){
\r
123 public static String show(String[] array){
\r
125 return StringUtils.join(array, "|");
\r
129 public static void main(String[] args) {
\r
130 String array[]={"1","2"};
\r
131 System.out.println(StringUtils.join(array, "|"));
\r