[jboss-dev-forums] [Design of POJO Server] - Re: ProfileServiceUnitTestCase value/type misuse

alesj do-not-reply at jboss.com
Fri Dec 21 05:50:41 EST 2007


"scott.stark at jboss.org" wrote : There was the question of primative types vs SimpleMetaType and whether the ManagedProperty should be accepting primatives and autoboxing these into SimpleValues. I think we should look into doing this.
  | 
  | The question also came up of enforcing a check against the ManagedProperty.getMetaType().isValue(Object) for the values passed into ManagedProperty.setValue(Object). Could be done with aop, but I don't think we can assume jboss aop is available/used in the admin client. It could also be done via a wrapping proxy that imposed this behavior, as well as the autoboxing.
  | 

Looking at this piece of horrible code - which I added :-( - we really must clear up the confusion about this values/types.

  |          // TODO - decide what is the type of value when we set it
  |          // since currently get always returns MetaValue, but we see some cases
  |          // where plain Serializable is enough
  |          Serializable serializable;
  |          MetaValue metaValue;
  |          Object value = prop.getValue();
  |          if (value instanceof MetaValue)
  |          {
  |             metaValue = (MetaValue)value;
  |             MetaType metaType = metaValue.getMetaType();
  |             if (metaType.isSimple())
  |                serializable = ((SimpleValue)metaValue).getValue();
  |             else if (metaType.isGeneric())
  |                serializable = ((GenericValue)metaValue).getValue();
  |             else
  |                serializable = null;
  |          }
  |          else
  |          {
  |             serializable = (Serializable)value;
  |             metaValue = MetaValueFactory.getInstance().create(value);
  |          }
  | 
  |          if(serializable != null)
  |             ctxProp.setValue(serializable);
  |          // todo - should this also dispatch to runtime component?
  |          Object componentName = getComponentName(ctxProp);
  |          if (componentName != null)
  |             dispatcher.set(componentName, ctxProp.getName(), metaValue);
  | 

I would expect a ManagedProperty to take MetaValue (so that it can also take non-serializable 'composite' values) and a runtime dispatcher to take plain object value.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114940#4114940

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114940



More information about the jboss-dev-forums mailing list