blob: a6e18623a2a26aa338dd911c14dabbf4f8d96570 [file] [log] [blame]
<?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>NotifierFactory.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> &gt; <a href="index.source.html" class="el_package">org.apache.juddi.subscription.notify</a> &gt; <span class="el_source">NotifierFactory.java</span></div><h1>NotifierFactory.java</h1><pre class="source lang-java linenums">/*
* Copyright 2001-2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* 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 &quot;AS IS&quot; 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.subscription.notify;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.juddi.ClassUtil;
import org.apache.juddi.model.BindingTemplate;
import org.apache.juddi.model.TmodelInstanceInfo;
/**
* The factory figures out which Notifier class to instantiate.
*
* @author kstam
*
*/
<span class="fc" id="L33">public class NotifierFactory {</span>
<span class="fc" id="L35"> Log log = LogFactory.getLog(this.getClass());</span>
public static final String UDDI_TRANSPORT_KEY = &quot;uddi:uddi.org:transport:&quot;;
public Notifier getNotifier(BindingTemplate bindingTemplate)
throws URISyntaxException, IllegalArgumentException, SecurityException,
InstantiationException, IllegalAccessException, InvocationTargetException,
NoSuchMethodException, ClassNotFoundException
{
<span class="fc" id="L43"> String notifierClassName = null;</span>
<span class="pc bpc" id="L44" title="1 of 2 branches missed."> for (TmodelInstanceInfo tModelInstanceInfo : bindingTemplate.getTmodelInstanceInfos()) {</span>
<span class="pc bpc" id="L45" title="1 of 2 branches missed."> if (tModelInstanceInfo.getTmodelKey().startsWith(UDDI_TRANSPORT_KEY)) {</span>
<span class="fc" id="L46"> log.debug(&quot;Found transport tModelKey &quot; + tModelInstanceInfo.getTmodelKey());</span>
<span class="fc" id="L47"> String transport = tModelInstanceInfo.getTmodelKey().substring(UDDI_TRANSPORT_KEY.length(),tModelInstanceInfo.getTmodelKey().length());</span>
<span class="fc" id="L48"> transport = transport.replaceAll(&quot;-&quot;, &quot;_&quot;);</span>
<span class="fc" id="L49"> notifierClassName = &quot;org.apache.juddi.subscription.notify.&quot; + transport.toUpperCase() + &quot;Notifier&quot;;</span>
<span class="fc" id="L50"> break;</span>
}
<span class="nc" id="L52"> }</span>
<span class="pc bpc" id="L53" title="1 of 2 branches missed."> if (notifierClassName == null) {</span>
//JUDDI-496 TODO make sure the tModel is loaded
<span class="nc" id="L55"> log.warn(&quot;The bindingTemplate &quot; + bindingTemplate.getEntityKey() + &quot; does not contain a tModel to define its type of transport. Defaulting &quot; </span>
+ &quot;to http.&quot;);
//JUDDI-596, attempt http transport, even if a transport isn't specified
<span class="nc" id="L58"> notifierClassName = &quot;org.apache.juddi.subscription.notify.HTTPNotifier&quot;;</span>
}
<span class="pc bpc" id="L60" title="1 of 2 branches missed."> if (log.isDebugEnabled()) log.debug(&quot;Going find and instantiate notifier class: &quot; + notifierClassName);</span>
@SuppressWarnings(&quot;unchecked&quot;)
<span class="fc" id="L63"> Class&lt;Notifier&gt; notifierClass = (Class&lt;Notifier&gt;) ClassUtil.forName(notifierClassName,this.getClass());</span>
<span class="fc" id="L64"> Notifier notifier = notifierClass.getConstructor(BindingTemplate.class).newInstance(bindingTemplate);</span>
<span class="fc" id="L65"> return notifier;</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>