Exemplo n.º 1
0
 @Override
 public int hashCode() {
   int result = id;
   result =
       31 * result + (externalizer.getClass() != null ? externalizer.getClass().hashCode() : 0);
   return result;
 }
Exemplo n.º 2
0
 @Override
 public boolean equals(Object o) {
   if (this == o) return true;
   if (o == null || getClass() != o.getClass()) return false;
   ExternalizerAdapter that = (ExternalizerAdapter) o;
   if (id != that.id) return false;
   if (externalizer != null
       ? !externalizer.getClass().equals(that.externalizer.getClass())
       : that.externalizer != null) return false;
   return true;
 }
Exemplo n.º 3
0
  private void loadForeignMarshallables(GlobalConfiguration globalCfg) {
    log.trace("Loading user defined externalizers");
    for (Map.Entry<Integer, AdvancedExternalizer<?>> config :
        globalCfg.serialization().advancedExternalizers().entrySet()) {
      AdvancedExternalizer<?> ext = config.getValue();

      // If no XML or programmatic config, id in annotation is used
      // as long as it's not default one (meaning, user did not set it).
      // If XML or programmatic config in use ignore @Marshalls annotation and use value in config.
      Integer id = ext.getId();
      if (config.getKey() == null && id == null)
        throw new CacheConfigurationException(
            String.format(
                "No advanced externalizer identifier set for externalizer %s",
                ext.getClass().getName()));
      else if (config.getKey() != null) id = config.getKey();

      id = checkForeignIdLimit(id, ext);
      updateExtReadersWritersWithTypes(
          new ForeignExternalizerAdapter(id, ext), generateForeignReaderIndex(id));
    }
  }
Exemplo n.º 4
0
 @Override
 public String toString() {
   // Each adapter is represented by the externalizer it delegates to, so just return the class
   // name
   return externalizer.getClass().getName();
 }
Exemplo n.º 5
0
 @Override
 public void writeObject(Marshaller output, Object object) throws IOException {
   output.write(id);
   externalizer.writeObject(output, object);
 }
Exemplo n.º 6
0
 public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
   return externalizer.readObject(input);
 }
Exemplo n.º 7
0
 void addInternalExternalizer(AdvancedExternalizer<?> ext) {
   int id = checkInternalIdLimit(ext.getId(), ext);
   updateExtReadersWritersWithTypes(new ExternalizerAdapter(id, ext));
 }