You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/04/25 23:06:52 UTC

svn commit: r164650 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapPoolEnum.java

Author: elecharny
Date: Mon Apr 25 14:06:52 2005
New Revision: 164650

URL: http://svn.apache.org/viewcvs?rev=164650&view=rev
Log:
Added this class to ease the pool managment

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapPoolEnum.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapPoolEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapPoolEnum.java?rev=164650&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapPoolEnum.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapPoolEnum.java Mon Apr 25 14:06:52 2005
@@ -0,0 +1,99 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1.ldap.codec;
+
+import org.apache.asn1.ldap.codec.LdapMessageContainer;
+import org.apache.asn1.ldap.pojo.BindRequestPOJO;
+import org.apache.asn1.ldap.pojo.BindResponsePOJO;
+import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
+import org.apache.asn1.ldap.pojo.LdapResultPOJO;
+import org.apache.asn1.ldap.pojo.SaslAuthenticationPOJO;
+import org.apache.asn1.ldap.pojo.SimpleAuthenticationPOJO;
+import org.apache.asn1.util.pools.PoolObject;
+
+/**
+ * This is where all the different Ldap pools are named. To add a new pool, we have to
+ * add an entry to the list, and to modify the getType method.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class LdapPoolEnum {
+
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** Pool of SimpleAuthPOJO objects */
+    public static final int SIMPLE_AUTH_POJO_POOL = 40;
+
+    /** Pool of SaslAuthPOJO objects */
+    public static final int SASL_AUTH_POJO_POOL = 41;
+
+    /** Pool of BindResponsePOJO objects */
+    public static final int BIND_RESPONSE_POJO_POOL = 42;
+
+    /** Pool of BindRequestPOJO objects */
+    public static final int BIND_REQUEST_POJO_POOL = 43;
+
+    /** Pool of LdapMessageContainer objects */
+    public static final int LDAP_MESSAGE_CONTAINER_POOL = 44;
+
+    /** Pool of LdapMessagePOJO objects */
+    public static final int LDAP_MESSAGE_POJO_POOL = 45;
+
+    /** Pool of Ldap Result POJO */
+    public static final int LDAP_RESULT_POJO_POOL = 46;
+
+    /**
+     * Get the name of the object stored in this pool 
+     *
+     * @return The object name
+     */
+    public static String getType(int poolId)
+    {
+        switch (poolId)
+        {
+        	case SIMPLE_AUTH_POJO_POOL       : return "SimpleAuthPOJO";
+        	case SASL_AUTH_POJO_POOL         : return "SaslAuthPOJO";
+        	case BIND_RESPONSE_POJO_POOL     : return "BindResponsePOJO";
+        	case BIND_REQUEST_POJO_POOL      : return "BindRequestPOJO";
+        	case LDAP_MESSAGE_CONTAINER_POOL : return "LdapMessageContainer";
+        	case LDAP_MESSAGE_POJO_POOL      : return "LdapMessagePOJO";
+        	case LDAP_RESULT_POJO_POOL       : return "LdapResultPOJO";
+        	default                          : return "UNKNOWN POOL";
+        }
+    }
+    
+    /**
+     * Allocate a new object the classic way.
+     * @param poolId The object pool Id
+     * @return An object
+     */
+    public static PoolObject allocate(int poolId)
+    {
+    	switch (poolId)
+		{
+    		case SIMPLE_AUTH_POJO_POOL : return new SimpleAuthenticationPOJO();
+    		case SASL_AUTH_POJO_POOL : return new SaslAuthenticationPOJO();
+    		case BIND_RESPONSE_POJO_POOL : return new BindResponsePOJO();
+    		case BIND_REQUEST_POJO_POOL : return new BindRequestPOJO();
+    		case LDAP_MESSAGE_CONTAINER_POOL : return new LdapMessageContainer();
+    		case LDAP_MESSAGE_POJO_POOL : return new LdapMessagePOJO();
+    		case LDAP_RESULT_POJO_POOL : return new LdapResultPOJO();
+    		
+    		default : return null;
+		}
+    }
+}