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 */ 020package org.apache.directory.api.ldap.codec.protocol.mina; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory; 025import org.apache.mina.core.session.IoSession; 026import org.apache.mina.filter.codec.ProtocolCodecFactory; 027import org.apache.mina.filter.codec.ProtocolDecoder; 028import org.apache.mina.filter.codec.ProtocolEncoder; 029 030 031/** 032 * The factory used to create the LDAP encoder and decoder. 033 * 034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 035 */ 036public class LdapProtocolCodecFactory implements ProtocolCodecFactory 037{ 038 /** The tag stored into the session if we want to set a max PDU size */ 039 public static final String MAX_PDU_SIZE = "MAX_PDU_SIZE"; 040 041 /** The LdapDecoder key */ 042 public static final String LDAP_DECODER = "LDAP_DECODER"; 043 044 /** The LdapEncoder key */ 045 public static final String LDAP_ENCODER = "LDAP_ENCODER"; 046 047 private LdapApiService ldapApiService; 048 049 public LdapProtocolCodecFactory() 050 { 051 this( LdapApiServiceFactory.getSingleton() ); 052 } 053 054 public LdapProtocolCodecFactory( LdapApiService ldapApiService ) 055 { 056 this.ldapApiService = ldapApiService; 057 } 058 059 /** 060 * Get the LDAP decoder. 061 * 062 * @param session the IO session 063 * @return the decoder 064 */ 065 public ProtocolDecoder getDecoder( IoSession session ) 066 { 067 return new LdapProtocolDecoder(); 068 } 069 070 071 /** 072 * Get the LDAP encoder. 073 * 074 * @param session the IO session 075 * @return the encoder 076 */ 077 public ProtocolEncoder getEncoder( IoSession session ) 078 { 079 return new LdapProtocolEncoder( ldapApiService ); 080 } 081}