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