001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.core.replication;
021
022 /**
023 * Describe the type of replication :
024 * <li>refreshOnly : replication is done only when requested. This is a
025 * <b>Pull</b> mode</li>
026 * <li>refreshAndPersist: replication is done and a listener is created to be
027 * informed whenever some modification occurs on the provider. This is a
028 * <b>Push</b> mode</li>
029 *
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 * @version $Rev: $, $Date: $
032 */
033 public enum ReplicationType
034 {
035 REFRESH_ONLY( "refreshOnly" ),
036 REFRESH_AND_PERSIST( "refreshAndPersist" ),
037 UNKNOWN( "" );
038
039 /** The inner String associated with the types */
040 private String type;
041
042
043 /**
044 * private constructor to create the instances.
045 */
046 private ReplicationType( String type )
047 {
048 this.type = type;
049 }
050
051
052 /**
053 * Get the ReplicationType associated with the given String.
054 * @param type The ReplicationType as a String
055 * @return The associated enum instance
056 */
057 public static ReplicationType getInstance( String type )
058 {
059 if ( REFRESH_ONLY.type.equalsIgnoreCase( type ) )
060 {
061 return REFRESH_ONLY;
062 }
063 else if ( REFRESH_AND_PERSIST.type.equalsIgnoreCase( type ) )
064 {
065 return REFRESH_AND_PERSIST;
066 }
067 else
068 {
069 return UNKNOWN;
070 }
071 }
072 }