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.shared.ldap.codec;
021
022 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
023 import org.apache.directory.shared.ldap.message.spi.Provider;
024 import org.apache.directory.shared.ldap.message.spi.ProviderDecoder;
025 import org.apache.directory.shared.ldap.message.spi.ProviderEncoder;
026 import org.apache.directory.shared.ldap.message.spi.ProviderException;
027
028
029
030
031 /**
032 * The Twix specific BER provider for LDAP.
033 *
034 * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
035 * $Rev: 725712 $
036 */
037 public class TwixProvider extends Provider
038 {
039 /**
040 * Creates an instance of a Twix based LDAP BER Provider.
041 */
042 private TwixProvider()
043 {
044 super( "Twix LDAP BER Provider", "Apache Directory Project" );
045 }
046
047 /** the singleton TwixProvider instance */
048 private static TwixProvider singleton;
049
050
051 /**
052 * Gets a handle on the singleton TwixProvider. Only one instance should
053 * have to be instantiated for the entire jvm.
054 *
055 * @return the singleton SnaccProvider instance
056 */
057 public static synchronized Provider getProvider()
058 {
059 if ( singleton == null )
060 {
061 singleton = new TwixProvider();
062 }
063
064 return singleton;
065 }
066
067
068 /**
069 * Gets the encoder associated with this provider.
070 *
071 * @return the provider's encoder.
072 * @throws org.apache.directory.shared.ldap.message.spi.ProviderException
073 * if the provider or its encoder cannot be found
074 */
075 public ProviderEncoder getEncoder() throws ProviderException
076 {
077 return new TwixEncoder( this );
078 }
079
080
081 /**
082 * Gets the decoder associated with this provider.
083 *
084 * @return the provider's decoder.
085 * @throws org.apache.directory.shared.ldap.message.spi.ProviderException
086 * if the provider or its decoder cannot be found
087 */
088 public ProviderDecoder getDecoder( BinaryAttributeDetector binaryAttributeDetector, int maxPDUSize ) throws ProviderException
089 {
090 return new TwixDecoder( this, binaryAttributeDetector, maxPDUSize );
091 }
092 }