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.server.annotations; 021 022 023import java.lang.annotation.Documented; 024import java.lang.annotation.ElementType; 025import java.lang.annotation.Inherited; 026import java.lang.annotation.Retention; 027import java.lang.annotation.RetentionPolicy; 028import java.lang.annotation.Target; 029 030import org.apache.commons.pool2.PooledObjectFactory; 031import org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory; 032import org.apache.directory.ldap.client.api.DefaultLdapConnectionValidator; 033import org.apache.directory.ldap.client.api.DefaultPoolableLdapConnectionFactory; 034import org.apache.directory.ldap.client.api.LdapConnection; 035import org.apache.directory.ldap.client.api.LdapConnectionFactory; 036import org.apache.directory.ldap.client.api.LdapConnectionValidator; 037 038 039/** 040 * A annotation used to define a LdapConnection configuration. 041 * Many elements can be configured : 042 * 043 * <ul> 044 * <li> The connection timeout</li> 045 * <li> A list of attributes to be interpreted as binary (in addition to the defaults)</li> 046 * </ul> 047 * 048 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 049 */ 050@Documented 051@Inherited 052@Retention(RetentionPolicy.RUNTIME) 053@Target( 054 { ElementType.METHOD, ElementType.TYPE }) 055public @interface CreateLdapConnectionPool 056{ 057 /** @return Attributes names to be added to the list of default binary attributes */ 058 String[] additionalBinaryAttributes() default {}; 059 060 061 /** @return LdapConnection factory implementation class */ 062 Class<? extends LdapConnectionFactory> connectionFactoryClass() default 063 DefaultLdapConnectionFactory.class; 064 065 066 /** @return LdapConnection pool factory implementation class */ 067 Class<? extends PooledObjectFactory<LdapConnection>> factoryClass() default 068 DefaultPoolableLdapConnectionFactory.class; 069 070 071 /** @return Connections borrowed in LIFO order, default true */ 072 boolean lifo() default true; 073 074 075 /** @return The maximum number of active connections, default 8 */ 076 int maxActive() default 8; 077 078 079 /** @return The maximum number of idle connections, default 8 */ 080 int maxIdle() default 8; 081 082 083 /** @return The maximum amount of time to wait for a connection to be returned in millis, default -1 */ 084 long maxWait() default -1L; 085 086 087 /** @return The minimum idle time before evicting a connection in millis, default 1000*60*30 */ 088 long minEvictableIdleTimeMillis() default 1000L * 60L * 30L; 089 090 091 /** @return The minumum number of idle instances before evictor spawns new object, default 0 */ 092 int minIdle() default 0; 093 094 095 /** @return The number of objects to test per eviction run, default 3 */ 096 int numTestsPerEvictionRun() default 3; 097 098 099 /** @return Same as minEvictableIdleTimeMillis with extra condition that minIdle objects remain in pool, default -1 */ 100 long softMinEvictableIdleTimeMillis() default -1L; 101 102 103 /** @return If true, connection will be tested on borrow, default false */ 104 boolean testOnBorrow() default false; 105 106 107 /** @return If true, connection will be tested on return, default false */ 108 boolean testOnReturn() default false; 109 110 111 /** @return If true, connection will be tested on while idle, default false */ 112 boolean testWhileIdle() default false; 113 114 115 /** @return The time, in millis, between eviction runs, default -1 (forever) */ 116 long timeBetweenEvictionRunsMillis() default -1L; 117 118 119 /** @return The connection timeout in millis, default 30000 */ 120 long timeout() default 30000L; 121 122 123 /** @return The class to use for validation */ 124 Class<? extends LdapConnectionValidator> validatorClass() default 125 DefaultLdapConnectionValidator.class; 126 127 128 /** @return The default action when connections are exhausted, default 1 (block) */ 129 byte whenExhaustedAction() default 1; 130}