@Test public void testUserPropertiesLazyInit() { BaseContext context = new MockBaseContext(); assertNull(context.userProperties); Map<String, Object> properties = context.getUserProperties(); assertNotNull(properties); assertSame(properties, context.getUserProperties()); }
protected Map<String, Object> getUserProperties() { if (userProperties == null) { synchronized (this) { if (userProperties == null) { userProperties = new ConcurrentHashMap<>(); } } } return userProperties; }
BaseContext implements ObjectContext { protected Map<String, Object> getUserProperties() { if (userProperties == null) { synchronized (this) { if (userProperties == null) { userProperties = new ConcurrentHashMap<>(); } } } return userProperties; } }
BaseContext implements ObjectContext { protected Map<String, Object> getUserProperties() { if (userProperties == null) { synchronized (this) { if (userProperties == null) { userProperties = new ConcurrentHashMap<>(); } } } return userProperties; } protected  BaseContext(); }
BaseContext implements ObjectContext { protected Map<String, Object> getUserProperties() { if (userProperties == null) { synchronized (this) { if (userProperties == null) { userProperties = new ConcurrentHashMap<>(); } } } return userProperties; } protected  BaseContext(); static ObjectContext getThreadObjectContext(); static void bindThreadObjectContext(ObjectContext context); @Override abstract void commitChanges(); @Override abstract void commitChangesToParent(); @Override void deleteObject(Object object); @Override abstract Collection<?> deletedObjects(); @Override DataChannel getChannel(); void setChannel(DataChannel channel); @Override EntityResolver getEntityResolver(); void setEntityResolver(EntityResolver entityResolver); boolean isValidatingObjectsOnCommit(); void setValidatingObjectsOnCommit(boolean flag); @Override T localObject(T objectFromAnotherContext); @Override abstract GraphManager getGraphManager(); @Override abstract Collection<?> modifiedObjects(); @Override abstract T newObject(Class<T> persistentClass); @Override abstract void registerNewObject(Object object); @Override abstract Collection<?> newObjects(); @Override abstract QueryResponse performGenericQuery(Query query); @Override abstract List performQuery(Query query); @SuppressWarnings("unchecked") @Override List<T> select(Select<T> query); @Override T selectOne(Select<T> query); @Override T selectFirst(Select<T> query); @Override void iterate(Select<T> query, ResultIteratorCallback<T> callback); @Override abstract ResultIterator<T> iterator(Select<T> query); @Override ResultBatchIterator<T> batchIterator(Select<T> query, int size); @Override void prepareForAccess(Persistent object, String property, boolean lazyFaulting); @Override void propertyChanged(Persistent object, String property, Object oldValue, Object newValue); @Override abstract void rollbackChanges(); @Override abstract void rollbackChangesLocally(); @Override abstract Collection<?> uncommittedObjects(); QueryCache getQueryCache(); void setQueryCache(QueryCache queryCache); @Override EventManager getEventManager(); @Override GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType); @Override void invalidateObjects(Collection<?> objects); @Override void invalidateObjects(T... objects); @Override Object getUserProperty(String key); @Override void setUserProperty(String key, Object value); @Override void deleteObjects(T... objects); @Override void deleteObjects(Collection<?> objects); }
BaseContext implements ObjectContext { protected Map<String, Object> getUserProperties() { if (userProperties == null) { synchronized (this) { if (userProperties == null) { userProperties = new ConcurrentHashMap<>(); } } } return userProperties; } protected  BaseContext(); static ObjectContext getThreadObjectContext(); static void bindThreadObjectContext(ObjectContext context); @Override abstract void commitChanges(); @Override abstract void commitChangesToParent(); @Override void deleteObject(Object object); @Override abstract Collection<?> deletedObjects(); @Override DataChannel getChannel(); void setChannel(DataChannel channel); @Override EntityResolver getEntityResolver(); void setEntityResolver(EntityResolver entityResolver); boolean isValidatingObjectsOnCommit(); void setValidatingObjectsOnCommit(boolean flag); @Override T localObject(T objectFromAnotherContext); @Override abstract GraphManager getGraphManager(); @Override abstract Collection<?> modifiedObjects(); @Override abstract T newObject(Class<T> persistentClass); @Override abstract void registerNewObject(Object object); @Override abstract Collection<?> newObjects(); @Override abstract QueryResponse performGenericQuery(Query query); @Override abstract List performQuery(Query query); @SuppressWarnings("unchecked") @Override List<T> select(Select<T> query); @Override T selectOne(Select<T> query); @Override T selectFirst(Select<T> query); @Override void iterate(Select<T> query, ResultIteratorCallback<T> callback); @Override abstract ResultIterator<T> iterator(Select<T> query); @Override ResultBatchIterator<T> batchIterator(Select<T> query, int size); @Override void prepareForAccess(Persistent object, String property, boolean lazyFaulting); @Override void propertyChanged(Persistent object, String property, Object oldValue, Object newValue); @Override abstract void rollbackChanges(); @Override abstract void rollbackChangesLocally(); @Override abstract Collection<?> uncommittedObjects(); QueryCache getQueryCache(); void setQueryCache(QueryCache queryCache); @Override EventManager getEventManager(); @Override GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType); @Override void invalidateObjects(Collection<?> objects); @Override void invalidateObjects(T... objects); @Override Object getUserProperty(String key); @Override void setUserProperty(String key, Object value); @Override void deleteObjects(T... objects); @Override void deleteObjects(Collection<?> objects);  }