use of net.sf.cglib.proxy.Factory in project cloudstack by apache.
the class SearchBase method finalize.
/**
* Marks the SearchBuilder as completed in building the search conditions.
*/
@Override
protected synchronized void finalize() {
if (_entity != null) {
final Factory factory = (Factory) _entity;
factory.setCallback(0, null);
_entity = null;
}
if (_joins != null) {
for (final JoinBuilder<SearchBase<?, ?, ?>> join : _joins.values()) {
join.getT().finalize();
}
}
if (_selects == null || _selects.size() == 0) {
_selectType = SelectType.Entity;
assert _entityBeanType.equals(_resultType) : "Expecting " + _entityBeanType + " because you didn't specify any selects but instead got " + _resultType;
return;
}
for (final Select select : _selects) {
if (select.field == null) {
assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?";
_selectType = SelectType.Single;
return;
}
if (select.func != null) {
_selectType = SelectType.Result;
return;
}
}
_selectType = SelectType.Fields;
}
use of net.sf.cglib.proxy.Factory in project cloudstack by apache.
the class AsyncCallbackDispatcher method getTarget.
@SuppressWarnings("unchecked")
public T getTarget() {
Class<?> clz = _targetObject.getClass();
String clzName = clz.getName();
if (clzName.contains("EnhancerByCloudStack"))
clz = clz.getSuperclass();
Enhancer en = null;
synchronized (enMap) {
en = enMap.get(clz);
if (en == null) {
en = new Enhancer();
en.setSuperclass(clz);
en.setCallback(new MethodInterceptor() {
@Override
public Object intercept(Object arg0, Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
return null;
}
});
enMap.put(clz, en);
}
}
try {
T t = (T) en.create();
Factory factory = (Factory) t;
factory.setCallback(0, new MethodInterceptor() {
@Override
public Object intercept(Object arg0, Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
if (arg1.getParameterTypes().length == 0 && arg1.getName().equals("finalize")) {
return null;
} else {
_callbackMethod = arg1;
_callbackMethod.setAccessible(true);
return null;
}
}
});
return t;
} catch (Throwable e) {
s_logger.error("Unexpected exception", e);
}
return null;
}
Aggregations