/** * Registers the given {@link SpringPropertyProxy} with the BlazeDS {@link PropertyProxyRegistry}. * @param proxy the property proxy to register */ protected void registerPropertyProxy(SpringPropertyProxy proxy) { PropertyProxyRegistry.getRegistry().register(proxy.getBeanType(), proxy); }
/** * Returns a PropertyProxy suitable for the given instance and registers * the selected PropertyProxy for the Class of the instance. Note that * the PropertyProxy is not cloned so either the PropertyProxy should be * used as a template else you must first call clone() on the returned * PropertyProxy and then set the instance as the default on the resulting * clone. * * @param instance the type to search for a suitable PropertyProxy. * @return PropertyProxy suitable for the instance type. */ public static PropertyProxy getProxyAndRegister(Object instance) { if (instance instanceof PropertyProxy) return (PropertyProxy)instance; Class c = instance.getClass(); PropertyProxy proxy = getRegistry().getProxyAndRegister(c); if (proxy == null) { proxy = guessProxy(instance); getRegistry().register(c, proxy); } return proxy; }
private void initThreadLocals() { // allocate static thread local objects // If available, invoke the MessageBroker.createThreadLocalObjects() method: Method createThreadLocalObjMethod = ReflectionUtils.findMethod(MessageBroker.class, "createThreadLocalObjects"); if (createThreadLocalObjMethod != null) { ReflectionUtils.invokeMethod(createThreadLocalObjMethod, null); } FlexContext.createThreadLocalObjects(); SerializationContext.createThreadLocalObjects(); TypeMarshallingContext.createThreadLocalObjects(); PropertyProxyRegistry.getRegistry(); }
/** * Returns a PropertyProxy suitable for the given instance and registers * the selected PropertyProxy for the Class of the instance. Note that * the PropertyProxy is not cloned so either the PropertyProxy should be * used as a template else you must first call clone() on the returned * PropertyProxy and then set the instance as the default on the resulting * clone. * * @param instance the type to search for a suitable PropertyProxy. * @return PropertyProxy suitable for the instance type. */ public static PropertyProxy getProxyAndRegister(Object instance) { if (instance instanceof PropertyProxy) return (PropertyProxy)instance; Class c = instance.getClass(); PropertyProxy proxy = getRegistry().getProxyAndRegister(c); if (proxy == null) { proxy = guessProxy(instance); getRegistry().register(c, proxy); } return proxy; }
/** * Returns a PropertyProxy suitable for the given instance and registers * the selected PropertyProxy for the Class of the instance. Note that * the PropertyProxy is not cloned so either the PropertyProxy should be * used as a template else you must first call clone() on the returned * PropertyProxy and then set the instance as the default on the resulting * clone. * * @param instance the type to search for a suitable PropertyProxy. * @return PropertyProxy suitable for the instance type. */ public static PropertyProxy getProxyAndRegister(Object instance) { if (instance instanceof PropertyProxy) return (PropertyProxy)instance; Class c = instance.getClass(); PropertyProxy proxy = getRegistry().getProxyAndRegister(c); if (proxy == null) { proxy = guessProxy(instance); getRegistry().register(c, proxy); } return proxy; }
/** * Serialize the provided object to the output stream. * Convert enums to their string representation for Actionscript. */ public void writeObject(Object o) throws IOException { if (o != null && o instanceof Enum && PropertyProxyRegistry.getRegistry().getProxy(o.getClass()) == null) { Enum enumValue = (Enum)o; writeString(enumValue.name()); } else { super.writeObject(o); } }
/** * Serialize an object using AMF0. Handles Java 5 constructs such as enum. * @param o the object to serialize * @throws IOException if there is a problem writing to the output stream */ public void writeObject(Object o) throws IOException { if (o != null && o instanceof Enum && PropertyProxyRegistry.getRegistry().getProxy(o.getClass()) == null) { Enum enumValue = (Enum)o; writeAMFString(enumValue.name()); } else { super.writeObject(o); } } }
/** * Serialize an object using AMF3. Handles Java 5 constructs such as enum. * @param o the object to serialize * @throws IOException if there is a problem writing to the output stream */ public void writeObject(Object o) throws IOException { // If there is a proxy for this, we'll write it as a custom object so that folks can // override the default serialization behavior for enums. if (o != null && o instanceof Enum && PropertyProxyRegistry.getRegistry().getProxy(o.getClass()) == null) { Enum enumValue = (Enum)o; writeAMFString(enumValue.name()); } else { super.writeObject(o); } } }
/** * Returns a PropertyProxy suitable for the given instance but does not * register the selected PropertyProxy for the Class of the instance. Note * that the PropertyProxy is not cloned so either the PropertyProxy should * be used as a template else you must first call clone() on the returned * PropertyProxy and then set the instance as the default on the resulting * clone. * * @param instance the type to search for a suitable PropertyProxy. * @return PropertyProxy suitable for the instance type. */ public static PropertyProxy getProxy(Object instance) { if (instance instanceof PropertyProxy) return (PropertyProxy)instance; Class c = instance.getClass(); PropertyProxy proxy = getRegistry().getProxy(c); if (proxy == null) { proxy = guessProxy(instance); } proxy = (PropertyProxy)proxy.clone(); proxy.setDefaultInstance(instance); return proxy; }
/** * Returns a PropertyProxy suitable for the given instance but does not * register the selected PropertyProxy for the Class of the instance. Note * that the PropertyProxy is not cloned so either the PropertyProxy should * be used as a template else you must first call clone() on the returned * PropertyProxy and then set the instance as the default on the resulting * clone. * * @param instance the type to search for a suitable PropertyProxy. * @return PropertyProxy suitable for the instance type. */ public static PropertyProxy getProxy(Object instance) { if (instance instanceof PropertyProxy) return (PropertyProxy)instance; Class c = instance.getClass(); PropertyProxy proxy = getRegistry().getProxy(c); if (proxy == null) { proxy = guessProxy(instance); } proxy = (PropertyProxy)proxy.clone(); proxy.setDefaultInstance(instance); return proxy; }
/** * Returns a PropertyProxy suitable for the given instance but does not * register the selected PropertyProxy for the Class of the instance. Note * that the PropertyProxy is not cloned so either the PropertyProxy should * be used as a template else you must first call clone() on the returned * PropertyProxy and then set the instance as the default on the resulting * clone. * * @param instance the type to search for a suitable PropertyProxy. * @return PropertyProxy suitable for the instance type. */ public static PropertyProxy getProxy(Object instance) { if (instance instanceof PropertyProxy) return (PropertyProxy)instance; Class c = instance.getClass(); PropertyProxy proxy = getRegistry().getProxy(c); if (proxy == null) { proxy = guessProxy(instance); } proxy = (PropertyProxy)proxy.clone(); proxy.setDefaultInstance(instance); return proxy; }
proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass);
private Object getInstantiatedObject(String className, PropertyProxy proxy) { Class<?> desiredClass = null; try { desiredClass = AbstractProxy.getClassFromClassName(className); } catch (MessageException me) { // Type not found but don't mind using ASObject for the missing type. if (me.getCode().startsWith(MessageException.CODE_SERVER_RESOURCE_UNAVAILABLE) && context.createASObjectForMissingType) { ASObject object = (ASObject)ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/); object.setType(className); return object; } throw me; // Rethrow. } // Type exists. proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass); return proxy == null? ClassUtil.createDefaultInstance(desiredClass, null, true /*validate*/) : proxy.createInstance(className); // Validation is performed in the proxy. }
private Object getInstantiatedObject(String className, PropertyProxy proxy) { Class<?> desiredClass = null; try { desiredClass = AbstractProxy.getClassFromClassName(className); } catch (MessageException me) { // Type not found but don't mind using ASObject for the missing type. if (me.getCode().startsWith(MessageException.CODE_SERVER_RESOURCE_UNAVAILABLE) && context.createASObjectForMissingType) { ASObject object = (ASObject)ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/); object.setType(className); return object; } throw me; // Rethrow. } // Type exists. proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass); return proxy == null? ClassUtil.createDefaultInstance(desiredClass, null, true /*validate*/) : proxy.createInstance(className); // Validation is performed in the proxy. }
proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass); if (proxy == null)
proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass); if (proxy == null)
else if (o instanceof Enum && PropertyProxyRegistry.getRegistry().getProxy(o.getClass()) == null)
else if (o instanceof Enum && PropertyProxyRegistry.getRegistry().getProxy(o.getClass()) == null)
proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass);
proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass);