/** * Unregisters the user types descriptors. **/ public void unregisterUserTypeDescriptors() { Iterator<Map.Entry<Class<?>, BinaryClassDescriptor>> it = descByCls.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Class<?>, BinaryClassDescriptor> e = it.next(); if (e.getValue().userType()) it.remove(); } }
/** * Register user types schemas. */ public void registerUserTypesSchema() { for (BinaryClassDescriptor desc : predefinedTypes.values()) { if (desc.userType()) desc.registerStableSchema(); } }
/** * Undeployment callback invoked when class loader is being undeployed. * * Some marshallers may want to clean their internal state that uses the undeployed class loader somehow. * * @param ldr Class loader being undeployed. */ public void onUndeploy(ClassLoader ldr) { for (Iterator<Map.Entry<Class<?>, BinaryClassDescriptor>> it = descByCls.entrySet().iterator(); it.hasNext();) { Map.Entry<Class<?>, BinaryClassDescriptor> e = it.next(); // Never undeploy system types. if (e.getValue().userType()) { if (ldr.equals(e.getKey().getClassLoader())) it.remove(); } } U.clearClassCache(ldr); }
/** * @throws Exception If failed. */ @Test public void testCustomTypeRegistration() throws Exception { BinaryTypeConfiguration customType = new BinaryTypeConfiguration(Value.class.getName()); BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(customType)); BinaryContext ctx = binaryContext(marsh); int typeId = ctx.typeId(Value.class.getName()); BinaryClassDescriptor descriptor = ctx.descriptorForTypeId(true, typeId, null, false); assertEquals(Value.class, descriptor.describedClass()); assertEquals(true, descriptor.registered()); assertEquals(true, descriptor.userType()); // Custom explicit types must be registered in 'predefinedTypes' in order not to break the interoperability. Field field = ctx.getClass().getDeclaredField("predefinedTypes"); field.setAccessible(true); Map<Integer, BinaryClassDescriptor> map = (Map<Integer, BinaryClassDescriptor>)field.get(ctx); assertTrue(!map.isEmpty()); assertNotNull(map.get(typeId)); // Custom explicit types must NOT be registered in 'predefinedTypeNames'. field = ctx.getClass().getDeclaredField("predefinedTypeNames"); field.setAccessible(true); Map<String, Integer> map2 = (Map<String, Integer>)field.get(ctx); assertTrue(!map2.isEmpty()); assertNull(map2.get(ctx.userTypeName(Value.class.getName()))); }
if (!desc.userType()) { BinaryClassDescriptor desc0 = new BinaryClassDescriptor( this,
/** * Unregisters the user types descriptors. **/ public void unregisterUserTypeDescriptors() { Iterator<Map.Entry<Class<?>, BinaryClassDescriptor>> it = descByCls.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Class<?>, BinaryClassDescriptor> e = it.next(); if (e.getValue().userType()) it.remove(); } }
/** * Register user types schemas. */ public void registerUserTypesSchema() { for (BinaryClassDescriptor desc : predefinedTypes.values()) { if (desc.userType()) desc.registerStableSchema(); } }
/** * Undeployment callback invoked when class loader is being undeployed. * * Some marshallers may want to clean their internal state that uses the undeployed class loader somehow. * * @param ldr Class loader being undeployed. */ public void onUndeploy(ClassLoader ldr) { for (Iterator<Map.Entry<Class<?>, BinaryClassDescriptor>> it = descByCls.entrySet().iterator(); it.hasNext();) { Map.Entry<Class<?>, BinaryClassDescriptor> e = it.next(); // Never undeploy system types. if (e.getValue().userType()) { if (ldr.equals(e.getKey().getClassLoader())) it.remove(); } } U.clearClassCache(ldr); }
if (!desc.userType()) { BinaryClassDescriptor desc0 = new BinaryClassDescriptor( this,