public static void logInstantiators() { for (Iterator itr = dsMap.values().iterator(); itr.hasNext();) { Instantiator instantiator = (Instantiator) itr.next(); logger .info("Instantiator registered with id {} class {}", Integer.valueOf(instantiator.getId()), instantiator.getInstantiatedClass().getName()); } for (Iterator itr = idsToHolders.values().iterator(); itr.hasNext();) { InstantiatorAttributesHolder holder = (InstantiatorAttributesHolder) itr.next(); logger.info("Instantiator registered with holder id {} class {}", Integer.valueOf(holder.getId()), holder.getInstantiatedClassName()); } } }
/** * Returns the class id for the given class. * * @return {@code 0} if the class has not be registered * * @see DataSerializer#writeObject(Object, DataOutput) */ public static int getClassId(Class c) { int result = 0; final Instantiator i = (Instantiator) dsMap.get(c.getName()); if (i != null) { result = i.getId(); } else { InstantiatorAttributesHolder iah = classNamesToHolders.get(c.getName()); if (iah != null) { result = iah.getId(); } } return result; }
InternalDataSerializer.getCachedClass(holder.getInstantiatedClassName()); synchronized (InternalInstantiator.class) { if (!idsToInstantiators.containsKey(holder.getId())) { register(instantiatorClass, instantiatedClass, holder.getId(), false, holder.getEventId(), holder.getContext()); idsToHolders.remove(holder.getId());
inst = idsToInstantiators.get(holder.getId()); if (inst == null) { if (instantiatorClassName == null || instantiatorClassName.trim().equals("")) { throw new IllegalArgumentException("Instantiator class name cannot be null or empty."); if (holder.getId() == 0) { throw new IllegalArgumentException( "Instantiator id cannot be zero"); classNamesToHolders.putIfAbsent(holder.getInstantiatedClassName(), holder); if (iah != null && iah.getId() != holder.getId()) { throw new IllegalStateException( String.format( "Class %s is already registered with id %s so it can not be registered with id %s", new Object[] {instantiatorClassName, iah.getId(), holder.getId()})); idsToHolders.putIfAbsent(holder.getId(), holder); Integer.valueOf(holder.getId()), holder.getInstantiatedClassName()); Object inst2 = idsToInstantiators.get(holder.getId()); if (inst2 == inst) { register(instantiatorClass, instantiatedClass, holder.getId(), distribute, holder.getEventId(), holder.getContext()); } else {
register(instantiatorClass, instantiatedClass, holder.getId(), false, holder.getEventId(), holder.getContext()); classNamesToHolders.remove(holder.getInstantiatedClassName());
instantiatedClassName = ((InstantiatorAttributesHolder) insts[i]).getInstantiatedClassName(); id = ((InstantiatorAttributesHolder) insts[i]).getId();
this.instantiatorClasseNames[i] = inst.getInstantiatorClassName(); this.instantiatedClasseNames[i] = inst.getInstantiatedClassName(); this.instantiatorIds[i] = inst.getId();
instantiatorClassName = ((InstantiatorAttributesHolder) obj).getInstantiatorClassName(); instantiatedClassName = ((InstantiatorAttributesHolder) obj).getInstantiatedClassName(); id = ((InstantiatorAttributesHolder) obj).getId();
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()); } } }