View Javadoc

1   package org.apache.commons.ognl;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * This class was previously intended to produce performance improvement.<br>
24   * This hand-made object pooling is now a bottleneck under high load.<br>
25   * We now rely on the new jvm garbage collection improvements to handle object allocation efficiently.
26   *
27   * @deprecated object-pooling now relies on the jvm garbage collection
28   */
29  public final class ObjectArrayPool
30  {
31      public ObjectArrayPool()
32      {
33          super();
34      }
35  
36      public Object[] create( int arraySize )
37      {
38          return new Object[arraySize];
39      }
40  
41      public Object[] create( Object singleton )
42      {
43          Object[] result = create( 1 );
44  
45          result[0] = singleton;
46          return result;
47      }
48  
49      public Object[] create( Object object1, Object object2 )
50      {
51          Object[] result = create( 2 );
52  
53          result[0] = object1;
54          result[1] = object2;
55          return result;
56      }
57  
58      public Object[] create( Object object1, Object object2, Object object3 )
59      {
60          Object[] result = create( 3 );
61  
62          result[0] = object1;
63          result[1] = object2;
64          result[2] = object3;
65          return result;
66      }
67  
68      public Object[] create( Object object1, Object object2, Object object3, Object object4 )
69      {
70          Object[] result = create( 4 );
71  
72          result[0] = object1;
73          result[1] = object2;
74          result[2] = object3;
75          result[3] = object4;
76          return result;
77      }
78  
79      public Object[] create( Object object1, Object object2, Object object3, Object object4, Object object5 )
80      {
81          Object[] result = create( 5 );
82  
83          result[0] = object1;
84          result[1] = object2;
85          result[2] = object3;
86          result[3] = object4;
87          result[4] = object5;
88          return result;
89      }
90  
91      /**
92       * @deprecated object-pooling now relies on the jvm garbage collection
93       */
94      public void recycle( Object[] value )
95      {
96          // no need of recycling, we rely on the garbage collection efficiency
97      }
98  }