mirror of https://github.com/apache/openjpa.git
Remove warning from enhancing impl generated classes and optimize
class / interface interaction git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@446904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d746a3fd7c
commit
05865aef89
|
@ -1904,7 +1904,7 @@ public class PCEnhancer {
|
||||||
method.makeProtected();
|
method.makeProtected();
|
||||||
access = "protected";
|
access = "protected";
|
||||||
}
|
}
|
||||||
if (_log.isWarnEnabled())
|
if (!_meta.getDescribedType().isInterface() && _log.isWarnEnabled())
|
||||||
_log.warn(_loc.get("enhance-adddefaultconst", type, access));
|
_log.warn(_loc.get("enhance-adddefaultconst", type, access));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ public class ClassMetaData
|
||||||
private Boolean _embedded = null;
|
private Boolean _embedded = null;
|
||||||
private Boolean _interface = null;
|
private Boolean _interface = null;
|
||||||
private Class _impl = null;
|
private Class _impl = null;
|
||||||
|
private List _interfaces = null;
|
||||||
private Map _ifaceMap = new HashMap();
|
private Map _ifaceMap = new HashMap();
|
||||||
private int _identity = ID_UNKNOWN;
|
private int _identity = ID_UNKNOWN;
|
||||||
private int _idStrategy = ValueStrategies.NONE;
|
private int _idStrategy = ValueStrategies.NONE;
|
||||||
|
@ -697,6 +698,38 @@ public class ClassMetaData
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all explicitly declared interfaces this class implements.
|
||||||
|
*/
|
||||||
|
public Class[] getDeclaredInterfaces() {
|
||||||
|
if (_interfaces == null)
|
||||||
|
return _repos.EMPTY_CLASSES;
|
||||||
|
|
||||||
|
return (Class[]) _interfaces.toArray(new Class[_interfaces.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly declare the given interface among the ones this
|
||||||
|
* class implements.
|
||||||
|
*/
|
||||||
|
public void addDeclaredInterface(Class iface) {
|
||||||
|
if (_interfaces == null)
|
||||||
|
_interfaces = new ArrayList();
|
||||||
|
if (!iface.isInterface())
|
||||||
|
throw new MetaDataException(_loc.get("declare-non-interface",
|
||||||
|
this, iface));
|
||||||
|
_interfaces.add(iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the given interface from the declared list.
|
||||||
|
*/
|
||||||
|
public boolean removeDeclaredInterface(Class iface) {
|
||||||
|
if (_interfaces == null)
|
||||||
|
return false;
|
||||||
|
return _interfaces.remove(iface);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias properties from the given interface during queries to
|
* Alias properties from the given interface during queries to
|
||||||
* the local field.
|
* the local field.
|
||||||
|
@ -728,6 +761,18 @@ public class ClassMetaData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all aliases property named for the given interface.
|
||||||
|
*/
|
||||||
|
public String[] getInterfaceAliasedProperties(Class iface) {
|
||||||
|
synchronized (_ifaceMap) {
|
||||||
|
Map fields = (Map) _ifaceMap.get(iface);
|
||||||
|
if (fields == null)
|
||||||
|
return new String[0];
|
||||||
|
return (String[]) fields.keySet().toArray(new String[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of fields that use impl or intermediate data, in
|
* Return the number of fields that use impl or intermediate data, in
|
||||||
* order to create a compacted array for storage of said data.
|
* order to create a compacted array for storage of said data.
|
||||||
|
@ -1610,6 +1655,13 @@ public class ClassMetaData
|
||||||
// resolve lifecycle metadata now to prevent lazy threading problems
|
// resolve lifecycle metadata now to prevent lazy threading problems
|
||||||
_lifeMeta.resolve();
|
_lifeMeta.resolve();
|
||||||
|
|
||||||
|
// record implements in the repository
|
||||||
|
if (_interfaces != null) {
|
||||||
|
for (Iterator it = _interfaces.iterator(); it.hasNext();) {
|
||||||
|
_repos.addDeclaredInterfaceImpl(this, (Class) it.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// resolve fetch groups
|
// resolve fetch groups
|
||||||
if (_fgMap != null)
|
if (_fgMap != null)
|
||||||
for (Iterator itr = _fgMap.values().iterator(); itr.hasNext();)
|
for (Iterator itr = _fgMap.values().iterator(); itr.hasNext();)
|
||||||
|
|
|
@ -865,9 +865,23 @@ public class MetaDataRepository
|
||||||
/**
|
/**
|
||||||
* Add the given metadata as declared interface implementation.
|
* Add the given metadata as declared interface implementation.
|
||||||
*/
|
*/
|
||||||
public void addDeclaredInterfaceImpl(ClassMetaData meta, Class iface) {
|
void addDeclaredInterfaceImpl(ClassMetaData meta, Class iface) {
|
||||||
synchronized (_impls) {
|
synchronized (_impls) {
|
||||||
addToCollection(_impls, iface, meta.getDescribedType(), false);
|
boolean supDec = false;
|
||||||
|
Collection vals = (Collection) _impls.get(iface);
|
||||||
|
|
||||||
|
// check to see if the superclass already declares to avoid dups
|
||||||
|
if (vals != null) {
|
||||||
|
ClassMetaData sup = meta.getPCSuperclassMetaData();
|
||||||
|
while (vals != null && sup != null && !supDec) {
|
||||||
|
supDec = vals.contains(sup.getDescribedType());
|
||||||
|
sup = sup.getPCSuperclassMetaData();
|
||||||
|
}
|
||||||
|
if (supDec)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addToCollection(_impls, iface, meta.getDescribedType(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue