| <?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>ServiceCounterLifecycleResource.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">jUDDI Core Services</a> > <a href="index.source.html" class="el_package">org.apache.juddi.api.impl</a> > <span class="el_source">ServiceCounterLifecycleResource.java</span></div><h1>ServiceCounterLifecycleResource.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2001-2008 The Apache Software Foundation. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| */ |
| package org.apache.juddi.api.impl; |
| |
| import java.util.HashMap; |
| import java.util.List; |
| import java.util.Map; |
| |
| import org.apache.juddi.api.util.CustodyTransferQuery; |
| import org.apache.juddi.api.util.InquiryQuery; |
| import org.apache.juddi.api.util.JUDDIQuery; |
| import org.apache.juddi.api.util.PublicationQuery; |
| import org.apache.juddi.api.util.ReplicationQuery; |
| import org.apache.juddi.api.util.SecurityQuery; |
| import org.apache.juddi.api.util.SubscriptionListenerQuery; |
| import org.apache.juddi.api.util.SubscriptionQuery; |
| import org.apache.juddi.api.util.ValueSetCachingQuery; |
| import org.apache.juddi.api.util.ValueSetValidationQuery; |
| |
| <span class="nc" id="L34">public class ServiceCounterLifecycleResource {</span> |
| <span class="fc" id="L35"> static Map<String, UDDIServiceCounter> serviceCounters = </span> |
| new HashMap<String, UDDIServiceCounter>(); |
| |
| <span class="fc" id="L38"> static Map<String, List<String>> implForQuery = new HashMap<String, List<String>>();</span> |
| |
| public static String getObjectName(Class<?> klass) { |
| <span class="fc" id="L41"> StringBuffer objectName = new StringBuffer("portType=" + klass.toString());</span> |
| <span class="fc" id="L42"> return objectName.toString();</span> |
| } |
| |
| public static synchronized void initQuery() { |
| <span class="fc" id="L46"> synchronized (implForQuery) {</span> |
| <span class="pc bpc" id="L47" title="1 of 2 branches missed."> if (implForQuery.isEmpty()) {</span> |
| <span class="fc" id="L48"> implForQuery = new HashMap<String, List<String>>();</span> |
| <span class="fc" id="L49"> implForQuery.put(UDDICustodyTransferImpl.class.getName(), CustodyTransferQuery.getQueries());</span> |
| <span class="fc" id="L50"> implForQuery.put(UDDIInquiryImpl.class.getName(), InquiryQuery.getQueries());</span> |
| <span class="fc" id="L51"> implForQuery.put(UDDIPublicationImpl.class.getName(), PublicationQuery.getQueries());</span> |
| <span class="fc" id="L52"> implForQuery.put(UDDIReplicationImpl.class.getName(), ReplicationQuery.getQueries());</span> |
| <span class="fc" id="L53"> implForQuery.put(UDDISecurityImpl.class.getName(), SecurityQuery.getQueries());</span> |
| <span class="fc" id="L54"> implForQuery.put(UDDISubscriptionImpl.class.getName(), SubscriptionQuery.getQueries());</span> |
| <span class="fc" id="L55"> implForQuery.put(UDDISubscriptionListenerImpl.class.getName(), SubscriptionListenerQuery.getQueries());</span> |
| <span class="fc" id="L56"> implForQuery.put(UDDIValueSetCachingImpl.class.getName(), ValueSetCachingQuery.getQueries());</span> |
| <span class="fc" id="L57"> implForQuery.put(UDDIValueSetValidationImpl.class.getName(), ValueSetValidationQuery.getQueries());</span> |
| <span class="fc" id="L58"> implForQuery.put(JUDDIApiImpl.class.getName(), JUDDIQuery.getQueries());</span> |
| } |
| <span class="pc" id="L60"> }</span> |
| <span class="fc" id="L61"> }</span> |
| |
| public static UDDIServiceCounter getServiceCounter(Class<?> klass) { |
| <span class="fc bfc" id="L64" title="All 2 branches covered."> if (implForQuery.isEmpty()) {</span> |
| <span class="fc" id="L65"> initQuery();</span> |
| } |
| |
| <span class="fc" id="L68"> String objectName = getObjectName(klass);</span> |
| <span class="fc" id="L69"> synchronized (serviceCounters) {</span> |
| <span class="fc" id="L70"> UDDIServiceCounter serviceCounter = serviceCounters.get(objectName);</span> |
| <span class="fc bfc" id="L71" title="All 2 branches covered."> if (serviceCounter == null) {</span> |
| <span class="fc" id="L72"> UDDIServiceCounter uddiServiceCounter = new UDDIServiceCounter();</span> |
| <span class="fc" id="L73"> uddiServiceCounter.initList(klass, (List<String>)implForQuery.get(klass.getName()));</span> |
| <span class="fc" id="L74"> uddiServiceCounter.registerMBean(); </span> |
| <span class="fc" id="L75"> serviceCounters.put(objectName, uddiServiceCounter);</span> |
| <span class="fc" id="L76"> return uddiServiceCounter;</span> |
| } else { |
| <span class="fc" id="L78"> return serviceCounter;</span> |
| } |
| <span class="nc" id="L80"> }</span> |
| } |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html> |