Correction...
public void set(T aNewValue) {
if (isImmutable()) {
throw new IllegalStateException("Property [" +
qualifiedName()
+ "] is immutable");
}
if (constraints != null) {
constraints.checkConstraints(aNewValue);
}
value = aNewValue;
// Change property
if (Proxy.isProxyClass(aNewValue.getClass())) {
InvocationHandler handler =
getInvocationHandler(aNewValue);
if (handler instanceof ProxyReferenceInvocationHandler)
{
entityState
.setProperty(propertyInfo.qualifiedName(),
(T)
((ProxyReferenceInvocationHandler) handler)
.proxy());
return;
}
}
entityState.setProperty(propertyInfo.qualifiedName(),
aNewValue);
}
Le 28 août 2009 à 15:30, philippe van dyck a écrit :
Rickard,
IMHO, this kind od rare occasions will have a deep impact on the
Qi4j learning curve.
I really favor a change in EntityPropertyInstance :
public void set(T aNewValue) {
if (isImmutable()) {
throw new IllegalStateException("Property [" +
qualifiedName()
+ "] is immutable");
}
if (constraints != null) {
constraints.checkConstraints(aNewValue);
}
// Change property
if (Proxy.isProxyClass(aNewValue.getClass())) {
InvocationHandler handler =
getInvocationHandler(aNewValue);
if (handler instanceof ProxyReferenceInvocationHandler)
{
value = (T) ((ProxyReferenceInvocationHandler)
handler).proxy();
}
} else {
value = aNewValue;
}
entityState.setProperty(propertyInfo.qualifiedName(), value);
}
This not perfect but it solves the problem (and I would really like
to see it in V1 ;-).
Phil
Le 28 août 2009 à 03:58, Rickard Öberg a écrit :
philippe van dyck wrote:
And I cannot JSonize a proxy a null ValueComposite... Is this an
isolated problem ?
What did I miss ?
This is one of the rare occasions where you need to use a
workaround to convert the modifier proxy to a real proxy. We have
not been able to figure out a way to do this automatically.
Basically you need to do:
@Structure Qi4j api;
@This MyValue value;
...
// Convert proxy to real reference
MyValue realValue = api.dereference(value);
realValue is then the real reference, which you can send to other
code.
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev