bd77493f3515c6dd0b2afbeeb452bb89dcd8fce0
[vfc/nfvo/driver/ems.git] /
1 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MessageChannelFactory.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">vfc-nfvo-driver-ems-ems-boco</a> &gt; <a href="index.source.html" class="el_package">org.onap.vfc.nfvo.emsdriver.messagemgr</a> &gt; <span class="el_source">MessageChannelFactory.java</span></div><h1>MessageChannelFactory.java</h1><pre class="source lang-java linenums">/**
2  * Copyright 2017 BOCO Corporation.  CMCC Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.emsdriver.messagemgr;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 <span class="nc" id="L21">public class MessageChannelFactory {</span>
22         
23 <span class="fc" id="L23">      public static Map&lt;String, MessageChannel&gt; map = new HashMap&lt;String, MessageChannel&gt;();</span>
24
25         public synchronized static MessageChannel getMessageChannel(String key,Integer size){
26 <span class="pc bpc" id="L26" title="1 of 2 branches missed.">          if(map.get(key) != null){</span>
27 <span class="nc" id="L27">                      return map.get(key);</span>
28                 }
29 <span class="fc" id="L29">              MessageChannel mc = null;</span>
30 <span class="pc bpc" id="L30" title="2 of 4 branches missed.">          if(size != null &amp;&amp; size &gt; 0){</span>
31 <span class="fc" id="L31">                      mc = new MessageChannel(size);</span>
32                 }else{
33 <span class="nc" id="L33">                      mc = new MessageChannel();</span>
34                 }
35                 
36 <span class="fc" id="L36">              map.put(key, mc);</span>
37 <span class="fc" id="L37">              return mc;</span>
38         }
39         
40         public synchronized static MessageChannel getMessageChannel(String key){
41 <span class="fc bfc" id="L41" title="All 2 branches covered.">          if(map.get(key) != null){</span>
42 <span class="fc" id="L42">                      return map.get(key);</span>
43                 }
44 <span class="fc" id="L44">              MessageChannel mc = new MessageChannel();</span>
45                 
46 <span class="fc" id="L46">              map.put(key, mc);</span>
47 <span class="fc" id="L47">              return mc;</span>
48         }
49         
50         public synchronized static boolean destroyMessageChannel(String key){
51 <span class="pc bpc" id="L51" title="1 of 2 branches missed.">          if(map.get(key) != null){</span>
52 <span class="nc" id="L52">                      map.remove(key);</span>
53 <span class="nc" id="L53">                      return true;</span>
54                 }
55 <span class="fc" id="L55">              return false;</span>
56         }
57         
58         public synchronized static void clean(){
59 <span class="fc" id="L59">              map.clear();</span>
60 <span class="fc" id="L60">      }</span>
61 }
62 </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html>