001 package org.apache.commons.ognl;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 /**
023 * This class was previously intended to produce performance improvement.<br>
024 * This hand-made object pooling is now a bottleneck under high load.<br>
025 * We now rely on the new jvm garbage collection improvements to handle object allocation efficiently.
026 *
027 * @deprecated object-pooling now relies on the jvm garbage collection
028 */
029 public final class ObjectArrayPool
030 {
031 public ObjectArrayPool()
032 {
033 super();
034 }
035
036 public Object[] create( int arraySize )
037 {
038 return new Object[arraySize];
039 }
040
041 public Object[] create( Object singleton )
042 {
043 Object[] result = create( 1 );
044
045 result[0] = singleton;
046 return result;
047 }
048
049 public Object[] create( Object object1, Object object2 )
050 {
051 Object[] result = create( 2 );
052
053 result[0] = object1;
054 result[1] = object2;
055 return result;
056 }
057
058 public Object[] create( Object object1, Object object2, Object object3 )
059 {
060 Object[] result = create( 3 );
061
062 result[0] = object1;
063 result[1] = object2;
064 result[2] = object3;
065 return result;
066 }
067
068 public Object[] create( Object object1, Object object2, Object object3, Object object4 )
069 {
070 Object[] result = create( 4 );
071
072 result[0] = object1;
073 result[1] = object2;
074 result[2] = object3;
075 result[3] = object4;
076 return result;
077 }
078
079 public Object[] create( Object object1, Object object2, Object object3, Object object4, Object object5 )
080 {
081 Object[] result = create( 5 );
082
083 result[0] = object1;
084 result[1] = object2;
085 result[2] = object3;
086 result[3] = object4;
087 result[4] = object5;
088 return result;
089 }
090
091 /**
092 * @deprecated object-pooling now relies on the jvm garbage collection
093 */
094 public void recycle( Object[] value )
095 {
096 // no need of recycling, we rely on the garbage collection efficiency
097 }
098 }