public static void unregisterInstantiatorsInThisVM() { // unregister all the instantiators InternalInstantiator.reinitialize(); assertEquals(0, InternalInstantiator.getInstantiators().length); } }
/** * Creates a new {@code Instantiator} with the given class and id and * {@linkplain #register(Instantiator, boolean) registers} it with the data serialization * framework. * * @throws IllegalArgumentException The instantiator cannot be created * @throws IllegalStateException The instantiator cannot be registered */ public static void register(Class instantiatorClass, Class instantiatedClass, int id, boolean distribute) { if (checkForThread()) { Instantiator inst = newInstance(instantiatorClass, instantiatedClass, id); _register(inst, distribute); } }
public static void allPoolsRegisterInstantiator(InstantiatorAttributesHolder holder) { InstantiatorAttributesHolder[] holders = new InstantiatorAttributesHolder[1]; holders[0] = holder; for (Iterator<Pool> itr = PoolManager.getAll().values().iterator(); itr.hasNext();) { PoolImpl next = (PoolImpl) itr.next(); try { EventID eventId = InternalInstantiator.generateEventId(); if (eventId == null) { // cache must not exist, do nothing } else { RegisterInstantiatorsOp.execute(next, holders, InternalInstantiator.generateEventId()); } } catch (RuntimeException e) { logger.warn("Error registering instantiator on pool:", e); } finally { next.releaseThreadLocalConnection(); } } }
/** * Registers an {@code Instantiator} with the data serialization framework. */ public static void register(Instantiator instantiator, boolean distribute) { // [sumedh] Skip the checkForThread() check if the instantiation has not // to be distributed. This allows instantiations from ServerConnection // thread in client security plugins, for example. This is particularly // useful for native clients that do not send a REGISTER_INSTANTIATORS // message rather rely on server side registration, so each server can // do the registration with distribute set to false. if (!distribute || checkForThread()) { _register(instantiator, distribute); } }
final String cName = c.getName(); int oldId = getClassId(c); if (oldId != 0 && oldId != classId) { throw new IllegalStateException( sendRegistrationMessage(instantiator); sendRegistrationMessageToServers(instantiator); sendRegistrationMessageToClients(instantiator);
/** * Registers a {@code DataSerializable} class with the data serialization framework. This method * is usually invoked from the static initializer of a class that implements * {@code DataSerializable}. * * @param instantiator An {@code Instantiator} whose {@link #newInstance} method is invoked when * an object is data deserialized. * * @throws IllegalStateException If class {@code c} is already registered with a different class * id, or another class has already been registered with id {@code classId} * @throws NullPointerException If {@code instantiator} is {@code null}. */ public static synchronized void register(Instantiator instantiator) { InternalInstantiator.register(instantiator, true); }
@Override protected void process(ClusterDistributionManager dm) { if (this.fromDataProblems != null) { if (logger.isDebugEnabled()) { logger.debug(this.fromDataProblems); } } if (this.instantiatorClass != null && this.instantiatedClass != null) { Instantiator s = newInstance(this.instantiatorClass, this.instantiatedClass, this.id); s.setEventId(eventId); InternalInstantiator.register(s, false); } else if (this.instantiatorClassName != null && this.instantiatedClassName != null) { InternalInstantiator.register(this.instantiatorClassName, this.instantiatedClassName, this.id, false, this.eventId, null); } }
/** * Persist this class's map to out */ public static void saveRegistrations(DataOutput out) throws IOException { for (Instantiator inst : InternalInstantiator.getInstantiators()) { out.writeInt(inst.getId()); DataSerializer.writeClass(inst.getClass(), out); DataSerializer.writeClass(inst.getInstantiatedClass(), out); } // We know that Instantiator id's must not be 0 so write a zero // to mark then end of the instantiators. out.writeInt(0); }
/** * Lazily creates a new {@code Instantiator} with the given class and id. * * @throws IllegalArgumentException The instantiator cannot be created * @throws IllegalStateException The instantiator cannot be registered */ public static void register(String instantiatorClass, String instantiatedClass, int id, boolean distribute) { if (checkForThread()) { register(instantiatorClass, new InstantiatorAttributesHolder(instantiatorClass, instantiatedClass, id), distribute); } }
/** * Creates a new {@code Instantiator} with the given class and id and * {@linkplain #register(Instantiator, boolean) registers} it with the data serialization * framework. * * This method is only called when server connection and CacheClientUpdaterThread * * @throws IllegalArgumentException The instantiator cannot be created * @throws IllegalStateException The instantiator cannot be registered */ public static void register(Class instantiatorClass, Class instantiatedClass, int id, boolean distribute, EventID eventId, ClientProxyMembershipID context) { Instantiator inst = newInstance(instantiatorClass, instantiatedClass, id); // This method is only called when server connection and CacheClientUpdaterThread inst.setEventId(eventId); inst.setContext(context); _register(inst, distribute); }
recoveryScheduled = false; Object[] objects = InternalInstantiator.getInstantiatorsForSerialization(); if (objects.length == 0) { return; EventID eventId = InternalInstantiator.generateEventId();
sendRegistrationMessageToServers(holder); Object inst2 = idsToInstantiators.get(holder.getId()); if (inst2 == inst) { register(instantiatorClass, instantiatedClass, holder.getId(), distribute, holder.getEventId(), holder.getContext()); } else { if (inst2 == null || inst2 instanceof Marker) { register(instantiatorClassName, holder, distribute); } else {
private void saveInstantiators() { Object[] objects = InternalInstantiator.getInstantiatorsForSerialization(); for (Object obj : objects) { if (obj instanceof Instantiator) { saveInstantiator((Instantiator) obj); } else { InstantiatorAttributesHolder iah = (InstantiatorAttributesHolder) obj; saveInstantiator(iah.getId(), iah.getInstantiatorClassName(), iah.getInstantiatedClassName()); } } }
private static Object readUserDataSerializable(final DataInput in, int classId) throws IOException { Instantiator instantiator = InternalInstantiator.getInstantiator(classId); if (instantiator == null) { logger.error(LogMarker.SERIALIZER_MARKER, "No Instantiator has been registered for class with id {}", classId); throw new IOException( String.format("No Instantiator has been registered for class with id %s", classId)); } else { try { DataSerializable ds; if (instantiator instanceof CanonicalInstantiator) { CanonicalInstantiator ci = (CanonicalInstantiator) instantiator; ds = ci.newInstance(in); } else { ds = instantiator.newInstance(); } ds.fromData(in); return ds; } catch (Exception ex) { throw new SerializationException( String.format("Could not deserialize an instance of %s", instantiator.getInstantiatedClass().getName()), ex); } } }
int classId = InternalInstantiator.getClassId(c); if (classId != 0) { writeUserDataSerializableHeader(classId, out);
InternalInstantiator.logInstantiators(); } catch (RuntimeException ex) { this.config.close();
/** * Registers a {@code DataSerializable} class with the data serialization framework. This method * is usually invoked from the static initializer of a class that implements * {@code DataSerializable}. * * @param instantiator An {@code Instantiator} whose {@link #newInstance} method is invoked when * an object is data deserialized. * * @param distribute True if the registered {@code Instantiator} has to be distributed to other * members of the distributed system. Note that if distribute is set to false it may still * be distributed in some cases. * * @throws IllegalArgumentException If class {@code c} is already registered with a different * class id, or another class has already been registered with id {@code classId} * @throws NullPointerException If {@code instantiator} is {@code null}. * @deprecated as of 9.0 use {@link Instantiator#register(Instantiator)} instead */ @Deprecated public static synchronized void register(Instantiator instantiator, boolean distribute) { InternalInstantiator.register(instantiator, distribute); }
@Override protected void process(ClusterDistributionManager dm) { if (fromDataProblems != null) { if (logger.isDebugEnabled()) { logger.debug(fromDataProblems); } } if (this.instantiatorClass != null && this.instantiatedClass != null) { Instantiator s = newInstance(this.instantiatorClass, this.instantiatedClass, this.id); s.setEventId(this.eventId); s.setContext(this.context); InternalInstantiator.register(s, false); } else if (this.instantiatorClassName != null && this.instantiatedClassName != null) { InternalInstantiator.register(this.instantiatorClassName, this.instantiatedClassName, this.id, false, this.eventId, this.context); } }
if (clientVersion != null && clientVersion.compareTo(Version.GFE_61) >= 0) { Instantiator[] instantiators = InternalInstantiator.getInstantiators(); HashMap instantiatorMap = new HashMap(); if (instantiators != null && instantiators.length > 0) {
Object[] insts = InternalInstantiator.getInstantiatorsForSerialization(); out.writeInt(insts.length); for (int i = 0; i < insts.length; i++) {