001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2013 ForgeRock AS.
025 */
026
027package org.forgerock.opendj.ldap;
028
029import org.forgerock.opendj.ldap.spi.Provider;
030
031/**
032 * Exception thrown when a provider of a service can't be found.
033 */
034@SuppressWarnings("serial")
035public class ProviderNotFoundException extends RuntimeException {
036
037    private final Class<? extends Provider> providerType;
038    private final String providerName;
039
040    /**
041     * Creates the exception with a provider type, provider name and a message.
042     *
043     * @param providerClass
044     *            the provider class
045     * @param providerName
046     *            the name of the provider implementation that was requested
047     * @param message
048     *            the detail message
049     */
050    public ProviderNotFoundException(final Class<? extends Provider> providerClass, final String providerName,
051            final String message) {
052        super(message);
053        this.providerType = providerClass;
054        this.providerName = providerName;
055    }
056
057    /**
058     * Returns the type of provider.
059     *
060     * @return the provider class
061     */
062    public Class<?> getProviderType() {
063        return providerType;
064    }
065
066    /**
067     * Returns the name of provider.
068     *
069     * @return the name of the provider implementation that was requested, or
070     *         null if the default provider was requested.
071     */
072    public String getProviderName() {
073        return providerName;
074    }
075
076}