mirror of
https://github.com/apache/openjpa.git
synced 2025-03-06 16:39:11 +00:00
OPENJPA-2909 rough implementation with ASM is ready
Still needs a few tweaks to iron out failures.
This commit is contained in:
parent
12f780eb76
commit
8f9547b643
@ -109,7 +109,6 @@
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!--
|
||||
<execution>
|
||||
<id>generate-standard-sco-proxies</id>
|
||||
<phase>process-classes</phase>
|
||||
@ -124,7 +123,6 @@
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
-->
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* 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.openjpa.util.proxy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.openjpa.util.MapChangeTracker;
|
||||
import org.apache.openjpa.util.Proxies;
|
||||
|
||||
/**
|
||||
* Utility methods used by concurrent map proxies.
|
||||
*
|
||||
*/
|
||||
public class ProxyConcurrentMaps extends ProxyMaps {
|
||||
/**
|
||||
* Call before invoking {@link Map#remove(key, value) } on super.
|
||||
*/
|
||||
public static boolean beforeRemove(ProxyMap map, Object key, Object value) {
|
||||
Proxies.dirty(map, false);
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call after invoking {@link Map#remove(key, value) } on super.
|
||||
*
|
||||
* @param ret the return value from the super's method
|
||||
* @param before the return value from {@link #beforeRemove}
|
||||
* @return the value to return from {@link Map#remove}
|
||||
*/
|
||||
public static boolean afterRemove(ProxyMap map, Object key, Object value, boolean ret,
|
||||
boolean before) {
|
||||
if (before) {
|
||||
if (map.getChangeTracker() != null) {
|
||||
((MapChangeTracker) map.getChangeTracker()).removed(key, ret);
|
||||
}
|
||||
Proxies.removed(map, key, true);
|
||||
Proxies.removed(map, ret, false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -206,6 +206,35 @@ public class ProxyMaps
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* See OPENJPA-2442.
|
||||
* Call before invoking {@link Map#remove(key, value) } on super.
|
||||
*/
|
||||
public static boolean beforeRemove(ProxyMap map, Object key, Object value) {
|
||||
Proxies.dirty(map, false);
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* See OPENJPA-2442.
|
||||
* Call after invoking {@link Map#remove(key, value) } on super.
|
||||
*
|
||||
* @param ret the return value from the super's method
|
||||
* @param before the return value from {@link #beforeRemove}
|
||||
* @return the value to return from {@link Map#remove}
|
||||
*/
|
||||
public static boolean afterRemove(ProxyMap map, Object key, Object value, boolean ret,
|
||||
boolean before) {
|
||||
if (before) {
|
||||
if (map.getChangeTracker() != null) {
|
||||
((MapChangeTracker) map.getChangeTracker()).removed(key, ret);
|
||||
}
|
||||
Proxies.removed(map, key, true);
|
||||
Proxies.removed(map, ret, false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marker interface for a proxy entry set.
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.openjpa.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Time;
|
||||
@ -47,6 +48,7 @@ import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.openjpa.lib.util.Files;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -769,6 +771,20 @@ public class TestProxyManager {
|
||||
assertBeansEqual(orig, (CustomBean) _mgr.copyCustom(orig));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeanClassProxy() throws Exception {
|
||||
Class cls = CustomComparatorSortedSet.class;
|
||||
final String proxyClassName = ProxyManagerImpl.getProxyClassName(cls, false);
|
||||
final byte[] bytes = _mgr.generateProxyCollectionBytecode(cls, true, proxyClassName);
|
||||
File dir = Files.getClassFile(TestProxyManager.class).getParentFile();
|
||||
|
||||
final String fileName = cls.getName().replace('.', '$') + "$proxy" + ".class";
|
||||
java.nio.file.Files.write(new File(dir, fileName).toPath(), bytes);
|
||||
|
||||
_mgr.loadBuildTimeProxy(cls, this.getClass().getClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the given bean with arbitrary data.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user