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 2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014 ForgeRock AS 026 */ 027package org.opends.server.api; 028 029 030import java.util.Collection; 031import java.util.List; 032 033import org.opends.server.admin.std.server.MatchingRuleCfg; 034import org.forgerock.opendj.config.server.ConfigException; 035import org.forgerock.opendj.ldap.schema.MatchingRule; 036import org.forgerock.i18n.LocalizableMessage; 037import org.opends.server.types.InitializationException; 038 039/** 040 * This class defines the set of methods and structures that must be 041 * implemented by a Directory Server module that implements a matching 042 * rule factory. 043 * 044 * @param <T> The type of configuration handled by this matching 045 * rule. 046 */ 047@org.opends.server.types.PublicAPI( 048 stability=org.opends.server.types.StabilityLevel.VOLATILE, 049 mayInstantiate=false, 050 mayExtend=true, 051 mayInvoke=false) 052public abstract class MatchingRuleFactory<T extends MatchingRuleCfg> 053{ 054 055 /** 056 * Initializes the matching rule(s) based on the information in the 057 * provided configuration entry. 058 * 059 * @param configuration The configuration to use to intialize this 060 * matching rule. 061 * 062 * @throws ConfigException If an unrecoverable problem arises in 063 * the process of performing the 064 * initialization. 065 * 066 * @throws InitializationException If a problem that is not 067 * configuration-related occurs 068 * during initialization. 069 */ 070 public abstract void initializeMatchingRule(T configuration) 071 throws ConfigException, InitializationException; 072 073 074 075 /** 076 * Performs any finalization that may be needed whenever this 077 * matching rule factory is taken out of service. 078 */ 079 public void finalizeMatchingRule() 080 { 081 //No implementation is required by default. 082 } 083 084 085 086 /** 087 * Indicates whether the provided configuration is acceptable for 088 * this matching rule. It should be possible to call this method on 089 * an uninitialized matching rule instance in order to determine 090 * whether the matching rule would be able to use the provided 091 * configuration. 092 * <BR><BR> 093 * Note that implementations which use a subclass of the provided 094 * configuration class will likely need to cast the configuration 095 * to the appropriate subclass type. 096 * 097 * @param configuration The matching rule configuration for 098 * which to make the determination. 099 * @param unacceptableReasons A list that may be used to hold the 100 * reasons that the provided 101 * configuration is not acceptable. 102 * 103 * @return {@code true} if the provided configuration is acceptable 104 * for this matching rule, or {@code false} if not. 105 */ 106 public boolean isConfigurationAcceptable( 107 T configuration, 108 List<LocalizableMessage> unacceptableReasons) 109 { 110 // This default implementation does not perform any special 111 // validation. It should be overridden by matching rule 112 // implementations that wish to perform more detailed validation. 113 return true; 114 } 115 116 117 118 /** 119 * Returns an umodifiable view of Collection of associated 120 * MatchingRules. 121 * 122 * @return An unmodifiable view of Collection of 123 * MatchingRule instances. 124 */ 125 public abstract Collection<MatchingRule> getMatchingRules(); 126}