@Test public void testClone() throws IOException, ClassNotFoundException { Context context = new Context(); context.put ("A", "ABC", true); context.put ("B", "BCD"); Context cloned = context.clone(); assertEquals(cloned.get("A"), "ABC"); assertEquals(cloned.get("B"), "BCD"); assertEquals(context, cloned); context = Serializer.serializeDeserialize(cloned); assertEquals(context.get("A"), "ABC"); assertNull(context.get("B"), "A should be null"); }
@Override public Context clone() { try { Context context = (Context) super.clone(); if (map != null) { context.map = Collections.synchronizedMap (new LinkedHashMap<>()); context.map.putAll(map); } if (pmap != null) { context.pmap = Collections.synchronizedMap (new LinkedHashMap<>()); context.pmap.putAll(pmap); } return context; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }
Context implements Externalizable, Loggeable, Pausable, Cloneable { @Override public Context clone() { try { Context context = (Context) super.clone(); if (map != null) { context.map = Collections.synchronizedMap (new LinkedHashMap<>()); context.map.putAll(map); } if (pmap != null) { context.pmap = Collections.synchronizedMap (new LinkedHashMap<>()); context.pmap.putAll(pmap); } return context; } catch (CloneNotSupportedException e) { throw new AssertionError(); } } }
Context implements Externalizable, Loggeable, Pausable, Cloneable { @Override public Context clone() { try { Context context = (Context) super.clone(); if (map != null) { context.map = Collections.synchronizedMap (new LinkedHashMap<>()); context.map.putAll(map); } if (pmap != null) { context.pmap = Collections.synchronizedMap (new LinkedHashMap<>()); context.pmap.putAll(pmap); } return context; } catch (CloneNotSupportedException e) { throw new AssertionError(); } } Context(); }
Context implements Externalizable, Loggeable, Pausable, Cloneable { @Override public Context clone() { try { Context context = (Context) super.clone(); if (map != null) { context.map = Collections.synchronizedMap (new LinkedHashMap<>()); context.map.putAll(map); } if (pmap != null) { context.pmap = Collections.synchronizedMap (new LinkedHashMap<>()); context.pmap.putAll(pmap); } return context; } catch (CloneNotSupportedException e) { throw new AssertionError(); } } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace); }
Context implements Externalizable, Loggeable, Pausable, Cloneable { @Override public Context clone() { try { Context context = (Context) super.clone(); if (map != null) { context.map = Collections.synchronizedMap (new LinkedHashMap<>()); context.map.putAll(map); } if (pmap != null) { context.pmap = Collections.synchronizedMap (new LinkedHashMap<>()); context.pmap.putAll(pmap); } return context; } catch (CloneNotSupportedException e) { throw new AssertionError(); } } Context(); void put(Object key, Object value); void put(Object key, Object value, boolean persist); void persist(Object key); void evict(Object key); T get(Object key); T get(Object key, T defValue); synchronized T remove(Object key); String getString(Object key); String getString(Object key, String defValue); void dump(PrintStream p, String indent); @SuppressWarnings("unchecked") synchronized T get(Object key, long timeout); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override Context clone(); @Override boolean equals(Object o); @Override int hashCode(); synchronized Map<Object,Object> getMap(); synchronized LogEvent getLogEvent(); synchronized Profiler getProfiler(); synchronized Result getResult(); void log(Object msg); void checkPoint(String detail); void setPausedTransaction(PausedTransaction p); PausedTransaction getPausedTransaction(); PausedTransaction getPausedTransaction(long timeout); void setTimeout(long timeout); long getTimeout(); synchronized void resume(); boolean isTrace(); void setTrace(boolean trace);  }