>( 101 );
30 |
31 | PrimitiveTypes() {
32 | map.put( "boolean", Boolean.TYPE );
33 | map.put( "byte", Byte.TYPE );
34 | map.put( "short", Short.TYPE );
35 | map.put( "char", Character.TYPE );
36 | map.put( "int", Integer.TYPE );
37 | map.put( "long", Long.TYPE );
38 | map.put( "float", Float.TYPE );
39 | map.put( "double", Double.TYPE );
40 | }
41 |
42 | Class> get(String className) {
43 | return map.get(className);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/enhance/EnhancedClassLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.commons.ognl.enhance;
21 |
22 | public class EnhancedClassLoader
23 | extends ClassLoader
24 | {
25 | /*
26 | * =================================================================== Constructors
27 | * ===================================================================
28 | */
29 | public EnhancedClassLoader( ClassLoader parentClassLoader )
30 | {
31 | super( parentClassLoader );
32 | }
33 |
34 | /*
35 | * =================================================================== Overridden methods
36 | * ===================================================================
37 | */
38 | public Class> defineClass( String enhancedClassName, byte[] byteCode )
39 | {
40 | return defineClass( enhancedClassName, byteCode, 0, byteCode.length );
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/enhance/LocalReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.commons.ognl.enhance;
21 |
22 | /**
23 | * Container class for {@link OgnlExpressionCompiler} generated local method block references.
24 | */
25 | public interface LocalReference
26 | {
27 |
28 | /**
29 | * The name of the assigned variable reference.
30 | *
31 | * @return The name of the reference as it will be when compiled.
32 | */
33 | String getName();
34 |
35 | /**
36 | * The expression that sets the value, ie the part after refName =
.
37 | *
38 | * @return The setting expression.
39 | */
40 | String getExpression();
41 |
42 | /**
43 | * The type of reference.
44 | *
45 | * @return The type.
46 | */
47 | Class> getType();
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/enhance/OrderedReturn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.commons.ognl.enhance;
21 |
22 | /**
23 | * Marks an ognl expression {@link org.apache.commons.ognl.Node} as needing to have the return portion of a getter
24 | * method happen in a specific
25 | * part of the generated expression vs just having the whole expression returned in one chunk.
26 | */
27 | public interface OrderedReturn
28 | {
29 |
30 | /**
31 | * Gets the core expression to execute first before any return foo logic is started.
32 | *
33 | * @return The core standalone expression that shouldn't be pre-pended with a return keyword.
34 | */
35 | String getCoreExpression();
36 |
37 | /**
38 | * Gets the last expression to be pre-pended with a return <expression> block.
39 | *
40 | * @return The expression representing the return portion of a statement;
41 | */
42 | String getLastExpression();
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/enhance/UnsupportedCompilationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.commons.ognl.enhance;
21 |
22 | /**
23 | * Thrown during bytecode enhancement conversions of ognl expressions to indicate that a certain expression isn't
24 | * currently supported as a pure Java bytecode enhanced version.
25 | *
26 | * If this exception is thrown it is expected that ognl will fall back to default ognl evaluation of the expression.
27 | *
28 | */
29 | public class UnsupportedCompilationException
30 | extends RuntimeException
31 | {
32 |
33 | /**
34 | */
35 | private static final long serialVersionUID = 4961625077128174947L;
36 |
37 | public UnsupportedCompilationException( String message )
38 | {
39 | super( message );
40 | }
41 |
42 | public UnsupportedCompilationException( String message, Throwable cause )
43 | {
44 | super( message, cause );
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/enhance/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.commons.ognl.enhance;
21 |
22 | /*
23 | * Enhanced basic Java components.
24 | */
25 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/Cache.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 | public interface Cache
25 | {
26 | void clear();
27 |
28 | int getSize();
29 |
30 | V get( K key )
31 | throws CacheException;
32 |
33 | V put( K key, V value );
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/CacheException.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 | public class CacheException
25 | extends RuntimeException
26 | {
27 | public CacheException( Throwable e )
28 | {
29 | super( e.getMessage(), e );
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/CacheFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
23 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
24 |
25 | /**
26 | * User: Maurizio Cucchiara
27 | * Date: 10/22/11
28 | * Time: 1:35 AM
29 | */
30 | public interface CacheFactory
31 | {
32 | Cache createCache( CacheEntryFactory entryFactory );
33 |
34 | ClassCache createClassCache();
35 |
36 | ClassCache createClassCache( ClassCacheEntryFactory entryFactory );
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/ClassCache.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 | import org.apache.commons.ognl.ClassCacheInspector;
25 |
26 | /**
27 | * This is a highly specialized map for storing values keyed by Class objects.
28 | */
29 | public interface ClassCache
30 | extends Cache, V>
31 | {
32 | void setClassInspector( ClassCacheInspector inspector );
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapCacheFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 |
25 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
26 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
27 |
28 | public class ConcurrentHashMapCacheFactory
29 | implements CacheFactory
30 | {
31 |
32 | public Cache createCache( CacheEntryFactory entryFactory )
33 | {
34 | return new ConcurrentHashMapCache( entryFactory );
35 | }
36 |
37 | public ClassCache createClassCache()
38 | {
39 | return createClassCache( null );
40 | }
41 |
42 | public ClassCache createClassCache( ClassCacheEntryFactory entryFactory )
43 | {
44 | return new ConcurrentHashMapClassCache( entryFactory );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/ConcurrentHashMapClassCache.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | import org.apache.commons.ognl.ClassCacheInspector;
23 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
24 |
25 | /*
26 | */
27 |
28 | public class ConcurrentHashMapClassCache
29 | extends ConcurrentHashMapCache, T>
30 | implements ClassCache
31 | {
32 | private ClassCacheInspector inspector;
33 |
34 | public ConcurrentHashMapClassCache( CacheEntryFactory, T> entryFactory )
35 | {
36 | super( entryFactory );
37 | }
38 |
39 | public void setClassInspector( ClassCacheInspector inspector )
40 | {
41 | this.inspector = inspector;
42 | }
43 |
44 | @Override
45 | public T put( Class> key, T value )
46 | {
47 | if ( inspector != null && !inspector.shouldCache( key ) )
48 | {
49 | return value;
50 | }
51 | return super.put( key, value );
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/HashMapCacheFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 |
25 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
26 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
27 |
28 | public class HashMapCacheFactory
29 | implements CacheFactory
30 | {
31 | public Cache createCache( CacheEntryFactory entryFactory )
32 | {
33 | return new HashMapCache( entryFactory );
34 | }
35 |
36 | public ClassCache createClassCache()
37 | {
38 | return createClassCache( null );
39 | }
40 |
41 | public ClassCache createClassCache( ClassCacheEntryFactory entryFactory )
42 | {
43 | return new HashMapClassCache( entryFactory );
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/HashMapClassCache.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 |
25 | import org.apache.commons.ognl.ClassCacheInspector;
26 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
27 |
28 | public class HashMapClassCache
29 | extends HashMapCache,T>
30 | implements ClassCache
31 | {
32 | private ClassCacheInspector inspector;
33 |
34 | public HashMapClassCache( CacheEntryFactory, T> entryFactory )
35 | {
36 | super( entryFactory );
37 | }
38 |
39 | public void setClassInspector( ClassCacheInspector inspector )
40 | {
41 | this.inspector = inspector;
42 | }
43 |
44 | public T put( Class> key, T value )
45 | {
46 | if ( inspector != null && !inspector.shouldCache( key ) )
47 | {
48 | return value;
49 | }
50 | return super.put( key, value );
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockCacheFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 |
25 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
26 | import org.apache.commons.ognl.internal.entry.ClassCacheEntryFactory;
27 |
28 | public class ReentrantReadWriteLockCacheFactory
29 | implements CacheFactory
30 | {
31 | public Cache createCache( CacheEntryFactory entryFactory )
32 | {
33 | return new ReentrantReadWriteLockCache( entryFactory );
34 | }
35 |
36 | public ClassCache createClassCache()
37 | {
38 | return createClassCache( null );
39 | }
40 |
41 | public ClassCache createClassCache( ClassCacheEntryFactory entryFactory )
42 | {
43 | return new ReentrantReadWriteLockClassCache( entryFactory );
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/ReentrantReadWriteLockClassCache.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal;
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 | */
24 |
25 | import org.apache.commons.ognl.ClassCacheInspector;
26 | import org.apache.commons.ognl.internal.entry.CacheEntryFactory;
27 |
28 | public class ReentrantReadWriteLockClassCache
29 | extends HashMapCache, T>
30 | implements ClassCache
31 | {
32 | private ClassCacheInspector inspector;
33 |
34 | public ReentrantReadWriteLockClassCache( CacheEntryFactory, T> entryFactory )
35 | {
36 | super( entryFactory );
37 | }
38 |
39 | public void setClassInspector( ClassCacheInspector inspector )
40 | {
41 | this.inspector = inspector;
42 | }
43 |
44 | public T put( Class> key, T value )
45 | {
46 | if ( inspector != null && !inspector.shouldCache( key ) )
47 | {
48 | return value;
49 | }
50 | return super.put( key, value );
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntry.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal.entry;
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 | */
24 |
25 | public interface CacheEntry
26 | {
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/entry/CacheEntryFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal.entry;
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 | */
24 |
25 | import org.apache.commons.ognl.internal.CacheException;
26 |
27 | public interface CacheEntryFactory
28 | {
29 | V create( K key )
30 | throws CacheException;
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/entry/ClassCacheEntryFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal.entry;
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 | */
24 |
25 | public interface ClassCacheEntryFactory
26 | extends CacheEntryFactory, T>
27 | {
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/entry/DeclaredMethodCacheEntryFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal.entry;
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 | */
24 |
25 | import java.lang.reflect.Method;
26 | import java.lang.reflect.Modifier;
27 |
28 | /**
29 | * User: mcucchiara
30 | * Date: 13/10/11
31 | * Time: 13.00
32 | */
33 | public class DeclaredMethodCacheEntryFactory
34 | extends MethodCacheEntryFactory
35 | {
36 | @Override
37 | protected boolean shouldCache( DeclaredMethodCacheEntry key, Method method )
38 | {
39 | if ( key.type == null )
40 | {
41 | return true;
42 | }
43 | boolean isStatic = Modifier.isStatic( method.getModifiers() );
44 | if ( key.type == DeclaredMethodCacheEntry.MethodType.STATIC )
45 | {
46 | return isStatic;
47 | }
48 | return !isStatic;
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/commons/ognl/internal/entry/FieldCacheEntryFactory.java:
--------------------------------------------------------------------------------
1 | package org.apache.commons.ognl.internal.entry;
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 | * $Id: FiedlCacheEntryFactory.java 1194954 2011-10-29 18:00:27Z mcucchiara $
24 | */
25 |
26 | import org.apache.commons.ognl.internal.CacheException;
27 |
28 | import java.lang.reflect.Field;
29 | import java.util.HashMap;
30 | import java.util.Map;
31 |
32 | public class FieldCacheEntryFactory
33 | implements ClassCacheEntryFactory