org.apache.ibatis.ognl.OgnlCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.servicemix.bundles.mybatis
Show all versions of org.apache.servicemix.bundles.mybatis
This OSGi bundle wraps ${pkgArtifactId} ${pkgVersion} jar file.
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.ibatis.ognl;
import org.apache.ibatis.ognl.internal.Cache;
import org.apache.ibatis.ognl.internal.CacheException;
import org.apache.ibatis.ognl.internal.CacheFactory;
import org.apache.ibatis.ognl.internal.ClassCache;
import org.apache.ibatis.ognl.internal.ClassCacheHandler;
import org.apache.ibatis.ognl.internal.HashMapCacheFactory;
import org.apache.ibatis.ognl.internal.entry.DeclaredMethodCacheEntry;
import org.apache.ibatis.ognl.internal.entry.DeclaredMethodCacheEntryFactory;
import org.apache.ibatis.ognl.internal.entry.FieldCacheEntryFactory;
import org.apache.ibatis.ognl.internal.entry.GenericMethodParameterTypeCacheEntry;
import org.apache.ibatis.ognl.internal.entry.GenericMethodParameterTypeFactory;
import org.apache.ibatis.ognl.internal.entry.MethodAccessCacheEntryFactory;
import org.apache.ibatis.ognl.internal.entry.MethodAccessEntryValue;
import org.apache.ibatis.ognl.internal.entry.MethodPermCacheEntryFactory;
import org.apache.ibatis.ognl.internal.entry.PermissionCacheEntry;
import org.apache.ibatis.ognl.internal.entry.PermissionCacheEntryFactory;
import org.apache.ibatis.ognl.internal.entry.PropertyDescriptorCacheEntryFactory;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.Permission;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* This class takes care of all the internal caching for OGNL.
*/
public class OgnlCache {
private final CacheFactory cacheFactory = new HashMapCacheFactory();
private final ClassCache methodAccessors = cacheFactory.createClassCache();
{
MethodAccessor methodAccessor = new ObjectMethodAccessor();
setMethodAccessor(Object.class, methodAccessor);
setMethodAccessor(byte[].class, methodAccessor);
setMethodAccessor(short[].class, methodAccessor);
setMethodAccessor(char[].class, methodAccessor);
setMethodAccessor(int[].class, methodAccessor);
setMethodAccessor(long[].class, methodAccessor);
setMethodAccessor(float[].class, methodAccessor);
setMethodAccessor(double[].class, methodAccessor);
setMethodAccessor(Object[].class, methodAccessor);
}
private final ClassCache propertyAccessors = cacheFactory.createClassCache();
{
PropertyAccessor propertyAccessor = new ArrayPropertyAccessor();
setPropertyAccessor(Object.class, new ObjectPropertyAccessor());
setPropertyAccessor(byte[].class, propertyAccessor);
setPropertyAccessor(short[].class, propertyAccessor);
setPropertyAccessor(char[].class, propertyAccessor);
setPropertyAccessor(int[].class, propertyAccessor);
setPropertyAccessor(long[].class, propertyAccessor);
setPropertyAccessor(float[].class, propertyAccessor);
setPropertyAccessor(double[].class, propertyAccessor);
setPropertyAccessor(Object[].class, propertyAccessor);
setPropertyAccessor(List.class, new ListPropertyAccessor());
setPropertyAccessor(Map.class, new MapPropertyAccessor());
setPropertyAccessor(Set.class, new SetPropertyAccessor());
setPropertyAccessor(Iterator.class, new IteratorPropertyAccessor());
setPropertyAccessor(Enumeration.class, new EnumerationPropertyAccessor());
}
private final ClassCache elementsAccessors = cacheFactory.createClassCache();
{
ElementsAccessor elementsAccessor = new ArrayElementsAccessor();
setElementsAccessor(Object.class, new ObjectElementsAccessor());
setElementsAccessor(byte[].class, elementsAccessor);
setElementsAccessor(short[].class, elementsAccessor);
setElementsAccessor(char[].class, elementsAccessor);
setElementsAccessor(int[].class, elementsAccessor);
setElementsAccessor(long[].class, elementsAccessor);
setElementsAccessor(float[].class, elementsAccessor);
setElementsAccessor(double[].class, elementsAccessor);
setElementsAccessor(Object[].class, elementsAccessor);
setElementsAccessor(Collection.class, new CollectionElementsAccessor());
setElementsAccessor(Map.class, new MapElementsAccessor());
setElementsAccessor(Iterator.class, new IteratorElementsAccessor());
setElementsAccessor(Enumeration.class, new EnumerationElementsAccessor());
setElementsAccessor(Number.class, new NumberElementsAccessor());
}
private final ClassCache nullHandlers = cacheFactory.createClassCache();
{
NullHandler nullHandler = new ObjectNullHandler();
setNullHandler(Object.class, nullHandler);
setNullHandler(byte[].class, nullHandler);
setNullHandler(short[].class, nullHandler);
setNullHandler(char[].class, nullHandler);
setNullHandler(int[].class, nullHandler);
setNullHandler(long[].class, nullHandler);
setNullHandler(float[].class, nullHandler);
setNullHandler(double[].class, nullHandler);
setNullHandler(Object[].class, nullHandler);
}
final ClassCache