001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2017 ForgeRock AS.
016 */
017package org.opends.server.replication.plugin;
018
019import static org.opends.server.schema.SchemaConstants.*;
020
021import java.util.Collection;
022import java.util.Collections;
023
024import org.opends.server.api.MatchingRuleFactory;
025import org.forgerock.opendj.server.config.server.MatchingRuleCfg;
026import org.forgerock.opendj.config.server.ConfigException;
027import org.forgerock.opendj.ldap.schema.CoreSchema;
028import org.forgerock.opendj.ldap.schema.MatchingRule;
029import org.forgerock.opendj.ldap.schema.SchemaBuilder;
030import org.opends.server.types.InitializationException;
031
032 /**
033 * This class is a factory class for
034  * {@link HistoricalCsnOrderingMatchingRule}.
035 */
036public final class HistoricalCsnOrderingMatchingRuleFactory
037        extends MatchingRuleFactory<MatchingRuleCfg>
038{
039
040  /** Associated Matching Rule. */
041  private MatchingRule matchingRule;
042
043 /** {@inheritDoc} */
044 @Override
045 public final void initializeMatchingRule(MatchingRuleCfg configuration)
046         throws ConfigException, InitializationException
047 {
048   matchingRule = new SchemaBuilder(CoreSchema.getInstance())
049       .buildMatchingRule(OMR_HISTORICAL_CSN_OID)
050       .names(OMR_HISTORICAL_CSN_NAME)
051       .syntaxOID(SYNTAX_OCTET_STRING_OID)
052       .implementation(new HistoricalCsnOrderingMatchingRuleImpl())
053       .addToSchema()
054       .toSchema().getMatchingRule(OMR_HISTORICAL_CSN_OID);
055 }
056
057 /** {@inheritDoc} */
058 @Override
059 public final Collection<MatchingRule> getMatchingRules()
060 {
061    return Collections.singleton(matchingRule);
062 }
063}