Returns the default Provider for the protocol specified. Checks mail.<protocol>.class property first and if it exists, returns the Provider associated with this implementation. If it doesn't exist, returns the Provider that appeared first in the configuration files. If an implementation for th
(String protocol)
| 483 | * protocol is not found. |
| 484 | */ |
| 485 | public synchronized Provider getProvider(String protocol) |
| 486 | throws NoSuchProviderException { |
| 487 | |
| 488 | if (protocol == null || protocol.length() <= 0) { |
| 489 | throw new NoSuchProviderException("Invalid protocol: null"); |
| 490 | } |
| 491 | |
| 492 | Provider _provider = null; |
| 493 | |
| 494 | // check if the mail.<protocol>.class property exists |
| 495 | String _className = props.getProperty("mail."+protocol+".class"); |
| 496 | if (_className != null) { |
| 497 | if (logger.isLoggable(Level.FINE)) { |
| 498 | logger.fine("mail."+protocol+ |
| 499 | ".class property exists and points to " + |
| 500 | _className); |
| 501 | } |
| 502 | _provider = providersByClassName.get(_className); |
| 503 | } |
| 504 | |
| 505 | if (_provider != null) { |
| 506 | return _provider; |
| 507 | } else { |
| 508 | // returning currently default protocol in providersByProtocol |
| 509 | _provider = providersByProtocol.get(protocol); |
| 510 | } |
| 511 | |
| 512 | if (_provider == null) { |
| 513 | throw new NoSuchProviderException("No provider for " + protocol); |
| 514 | } else { |
| 515 | if (logger.isLoggable(Level.FINE)) { |
| 516 | logger.fine("getProvider() returning " + _provider.toString()); |
| 517 | } |
| 518 | return _provider; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Set the passed Provider to be the default implementation |
no test coverage detected