Hello Dan, A plugin mechanism would be very useful for Hibernate, OpenJPA, EclipseLink and Spring support, that represent a non neglictable part of our current server technologies ;-)
The point is : how to allow third party libraries to add their own data serializer ? Is in your mind a GWT contribution the only way to do it ? I do not want to "hack" GWT source anymore (I have to do it since 2 years because of the damned "invokeAndEncodeResponse" method, for every GWT release, and it is a pain...), so just add a "addCustomDataSerializer" method looks to me a minimal effort. Regards Bruno PS : sorry for my english, I am not sure to be clear this morning... On 8 juil, 23:29, Daniel Rice (דניאל רייס) <r...@google.com> wrote: > Hi Bruno - > My though was that you could modify the code you except below as part of > whatever patch you have that adds Hibernate support. GWT is open-source, > after all. It seems like overkill at this point to have a whole runtime > plug-in mechanism just to deal with a 3 or four persistence APIs that > require serializer support. Does that make sense? > > Dan > > On Wed, Jul 8, 2009 at 3:18 PM, bruno <bruno.marches...@gmail.com> wrote: > > > Hi > > > Is it possible to modify the above code to allow third parties > > libraries to developer their own serializer ? I would adore to port > > Gilead as HibernateClientSerializer for regular GWT applications... > > > But the following code does not allow it : > > > static { > > // Load and register a JdoDetachedStateSerializer > > ClientDataSerializer serializer = > > JdoDetachedStateClientDataSerializer.getInstance(); > > serializers.put(serializer.getName(), serializer); > > } > > > Regards > > Bruno > > > On 6 juil, 21:58, codesite-nore...@google.com wrote: > > > Author: r...@google.com > > > Date: Mon Jul 6 12:56:52 2009 > > > New Revision: 5672 > > > > Added: > > > trunk/user/src/com/google/gwt/core/client/impl/WeakMapping.java > > > (contents, props changed) > > > > trunk/user/src/com/google/gwt/user/rebind/rpc/ClientDataSerializer.java > > > > (contents, props changed) > > > trunk/user/src/com/google/gwt/user/rebind/rpc/JdoDetachedStateClientDataSerializer.java > > > > (contents, props changed) > > > trunk/user/src/com/google/gwt/user/server/Base64Utils.java > > (contents, > > > props changed) > > > trunk/user/src/com/google/gwt/user/server/rpc/impl/JdoDetachedStateServerDataSerializer.java > > > > (contents, props changed) > > > trunk/user/src/com/google/gwt/user/server/rpc/impl/ServerDataSerializer.java > > > > (contents, props changed) > > > trunk/user/super/com/google/gwt/user/translatable/com/google/gwt/core/ > > > trunk/user/super/com/google/gwt/user/translatable/com/google/gwt/core/client/ > > > trunk/user/super/com/google/gwt/user/translatable/com/google/gwt/core/client/impl/ > > > trunk/user/super/com/google/gwt/user/translatable/com/google/gwt/core/client/impl/WeakMapping.java > > > trunk/user/test/com/google/gwt/user/server/Base64Test.java > > (contents, > > > props changed) > > > Modified: > > > trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java > > > trunk/tools/api-checker/config/gwt16_20userApi.conf > > > trunk/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java > > > trunk/user/src/com/google/gwt/user/server/rpc/impl/SerializabilityUtil.java > > > trunk/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java > > > trunk/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamWriter.java > > > trunk/user/super/com/google/gwt/emul/java/lang/Object.java > > > trunk/user/test/com/google/gwt/user/RPCSuite.java > > > > Log: > > > Implement RPC for JDO persistent objects. > > > The JDO object must contain the annotation: > > > > @PersistenceCapable(identityType = IdentityType.APPLICATION, detatchable > > > > = "true") > > > > and be detached at the time it is sent to the client as part of an RPC > > > request. > > > > For now, the WeakMapping API is in an impl/ package and excluded from API > > > > checking. > > > > Review by: bobv > > > > Modified: > > > trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java > > > ============================================================================== > > > --- > > > trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java > > > > (original) > > > +++ > > > trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java > > > > Mon Jul 6 12:56:52 2009 > > > @@ -1949,6 +1949,7 @@ > > > specialObfuscatedIdents.put("finalize", "fZ"); > > > > // Object fields > > > + specialObfuscatedIdents.put("expando", "eX"); > > > specialObfuscatedIdents.put("typeId", "tI"); > > > specialObfuscatedIdents.put("typeMarker", "tM"); > > > > Modified: trunk/tools/api-checker/config/gwt16_20userApi.conf > > > ============================================================================== > > > --- trunk/tools/api-checker/config/gwt16_20userApi.conf (original) > > > +++ trunk/tools/api-checker/config/gwt16_20userApi.conf Mon Jul 6 > > 12:56:52 > > > 2009 > > > @@ -54,6 +54,7 @@ > > > :**/rebind/**\ > > > :**/server/**\ > > > :**/tools/**\ > > > +:user/src/com/google/gwt/core/client/impl/WeakMapping.java\ > > > :user/src/com/google/gwt/junit/*.java\ > > > :user/src/com/google/gwt/junit/client/GWTTestCase.java\ > > > :user/src/com/google/gwt/junit/client/impl/GWTRunner.java\ > > > > Added: trunk/user/src/com/google/gwt/core/client/impl/WeakMapping.java > > > ============================================================================== > > > --- (empty file) > > > +++ trunk/user/src/com/google/gwt/core/client/impl/WeakMapping.java > > Mon > > > Jul 6 12:56:52 2009 > > > @@ -0,0 +1,169 @@ > > > +/* > > > + * Copyright 2009 Google Inc. > > > + * > > > + * Licensed under the Apache License, Version 2.0 (the "License"); you > > may > > > not > > > + * use this file except in compliance with the License. You may obtain a > > > > copy of > > > + * the License at > > > + * > > > + *http://www.apache.org/licenses/LICENSE-2.0 > > > + * > > > + * Unless required by applicable law or agreed to in writing, software > > > + * distributed under the License is distributed on an "AS IS" BASIS, > > > WITHOUT > > > + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See > > the > > > + * License for the specific language governing permissions and > > limitations > > > under > > > + * the License. > > > + */ > > > +package com.google.gwt.core.client.impl; > > > + > > > +import java.lang.ref.Reference; > > > +import java.lang.ref.ReferenceQueue; > > > +import java.lang.ref.WeakReference; > > > +import java.util.HashMap; > > > +import java.util.Map; > > > + > > > +/** > > > + * A class associating a (String, Object) map with arbitrary source > > objects > > > + * (except for Strings). This implementation is used in hosted mode. > > > + */ > > > +public class WeakMapping { > > > + > > > + /* > > > + * This implementation is used in hosted mode only. It uses a HashMap > > to > > > + * associate the (key, value) maps with source object instances. The > > > object > > > + * instances are wrapped in IdentityWeakReference objects in order to > > > > both > > > + * allow the underlying objects to be garbage-collected and to apply > > > + * IdentityHashMap semantics so that distinct objects that happen to > > > compare > > > + * as equals() still get to have distinct maps associated with them. > > > + */ > > > + > > > + /** > > > + * A WeakReference implementing equals() and hashCode(). The hash code > > > > of the > > > + * reference is permanently set to the identity hash code of the > > > referent at > > > + * construction time. > > > + */ > > > + static class IdentityWeakReference extends WeakReference { > > > + > > > + /** > > > + * The identity hash code of the referent, cached during > > construction. > > > + */ > > > + private int hashCode; > > > + > > > + public IdentityWeakReference(Object referent, ReferenceQueue queue) > > { > > > + super(referent, queue); > > > + hashCode = System.identityHashCode(referent); > > > + } > > > + > > > + �...@override > > > + public boolean equals(Object other) { > > > + /* > > > + * Identical objects are always equal. > > > + */ > > > + if (this == other) { > > > + return true; > > > + } > > > + > > > + /* > > > + * We can only be equal to another IdentityWeakReference. > > > + */ > > > + if (!(other instanceof IdentityWeakReference)) { > > > + return false; > > > + } > > > + > > > + /* > > > + * Check equality of the underlying referents. If either referent > > is > > > no > > > + * longer present, equals() will return false (note that the case > > of > > > + * identical IdentityWeakReference objects has already been > > defined > > > to > > > + * return true above). > > > + */ > > > + Object referent = get(); > > > + if (referent == null) { > > > + return false; > > > + } > > > + return referent == ((IdentityWeakReference) other).get(); > > > + } > > > + > > > + �...@override > > > + public int hashCode() { > > > + return hashCode; > > > + } > > > + } > > > + > > > + /** > > > + * A Map from Objects to <String,Object> maps. Hashing is based on > > object > > > + * identity. Weak references are used to allow otherwise unreferenced > > > > Objects > > > + * to be garbage collected. > > > + */ > > > + private static Map<IdentityWeakReference, HashMap<String, Object>> map > > = > > > new HashMap<IdentityWeakReference, HashMap<String, Object>>(); > > > + > > > + /** > > > + * A ReferenceQueue used to clean up the map as its keys are > > > + * garbage-collected. > > > + */ > > > + private static ReferenceQueue queue = new ReferenceQueue(); > > > + > > > + /** > > > + * Returns the Object associated with the given key in the (key, > > value) > > > + * mapping associated with the given Object instance. > > > + * > > > + * @param instance the source Object. > > > + * @param key a String key. > > > + * @return an Object associated with that key on the given instance, > > or > > > null. > > > + */ > > > + public static Object get(Object instance, String key) { > > > + cleanup(); > > > + > > > + Object ref = new IdentityWeakReference(instance, queue); > > > + HashMap<String, Object> m = map.get(ref); > > > + if (m == null) { > > > + return null; > > > + } > > > + return m.get(key); > > > + } > > > + > > > + /** > > > + * Associates a value with a given key in the (key, value) mapping > > > associated > > > + * with the given Object instance. Note that the > > ... > > plus de détails » --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---