You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/09/30 18:18:22 UTC
[isis] branch v2 updated: ISIS-2158: fixes concurrent spec-loading
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new 26468ff ISIS-2158: fixes concurrent spec-loading
26468ff is described below
commit 26468ff7531285c4839c92f1e62ac14caa52fb1e
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Sep 30 20:18:09 2019 +0200
ISIS-2158: fixes concurrent spec-loading
- previously did dead-lock, because was running during post-construct
phase, which was too early
---
...assFacetOnActionFromConfiguredRegexFactory.java | 5 --
.../DomainObjectLayoutFacetFactory.java | 6 +-
.../facets/object/grid/GridFacetFactory.java | 16 +++--
.../metamodel/MetaModelServiceDefault.java | 1 -
.../specloader/SpecificationCacheDefault.java | 62 +++++++++-------
.../metamodel/specloader/SpecificationLoader.java | 2 -
.../specloader/SpecificationLoaderDefault.java | 82 +++++++++-------------
.../specloader/SpecificationCacheDefaultTest.java | 15 ++--
.../system/session/IsisSessionFactoryDefault.java | 8 ++-
9 files changed, 95 insertions(+), 102 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnActionFromConfiguredRegexFactory.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnActionFromConfiguredRegexFactory.java
index 302831b..86acbc1 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnActionFromConfiguredRegexFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/members/cssclass/annotprop/CssClassFacetOnActionFromConfiguredRegexFactory.java
@@ -21,13 +21,8 @@ package org.apache.isis.metamodel.facets.members.cssclass.annotprop;
import java.lang.reflect.Method;
import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.isis.commons.internal.base._Strings;
-import org.apache.isis.commons.internal.collections._Maps;
-import org.apache.isis.config.ConfigurationConstants;
import org.apache.isis.metamodel.facetapi.FacetHolder;
import org.apache.isis.metamodel.facetapi.FacetUtil;
import org.apache.isis.metamodel.facetapi.FeatureType;
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/domainobjectlayout/DomainObjectLayoutFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/domainobjectlayout/DomainObjectLayoutFacetFactory.java
index aff11c7..b765142 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/domainobjectlayout/DomainObjectLayoutFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/domainobjectlayout/DomainObjectLayoutFacetFactory.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.apache.isis.applib.annotation.DomainObjectLayout;
import org.apache.isis.applib.annotation.ViewModelLayout;
+import org.apache.isis.commons.internal.base._Lazy;
import org.apache.isis.metamodel.facetapi.FacetHolder;
import org.apache.isis.metamodel.facetapi.FacetUtil;
import org.apache.isis.metamodel.facetapi.FeatureType;
@@ -45,7 +46,7 @@ public class DomainObjectLayoutFacetFactory extends FacetFactoryAbstract {
final List<DomainObjectLayout> domainObjectLayouts = Annotations.getAnnotations(cls, DomainObjectLayout.class);
final List<ViewModelLayout> viewModelLayouts = Annotations.getAnnotations(cls, ViewModelLayout.class);
- val metamodelEventService = getServiceRegistry().lookupServiceElseFail(MetamodelEventService.class);
+ val metamodelEventService = this.metamodelEventService.get();
FacetUtil.addFacet(
TitleFacetViaDomainObjectLayoutAnnotationUsingTitleUiEvent.create(
@@ -113,7 +114,8 @@ public class DomainObjectLayoutFacetFactory extends FacetFactoryAbstract {
return;
}
-
+ private final _Lazy<MetamodelEventService> metamodelEventService = _Lazy.threadSafe(()->
+ getServiceRegistry().lookupServiceElseFail(MetamodelEventService.class));
}
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/grid/GridFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/grid/GridFacetFactory.java
index ee82d82..2a92ded 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/grid/GridFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/facets/object/grid/GridFacetFactory.java
@@ -17,25 +17,29 @@
package org.apache.isis.metamodel.facets.object.grid;
import org.apache.isis.applib.services.grid.GridService;
-import org.apache.isis.metamodel.facetapi.FacetHolder;
+import org.apache.isis.commons.internal.base._Lazy;
import org.apache.isis.metamodel.facetapi.FacetUtil;
import org.apache.isis.metamodel.facetapi.FeatureType;
import org.apache.isis.metamodel.facets.FacetFactoryAbstract;
-public class GridFacetFactory extends FacetFactoryAbstract {
+import lombok.val;
+public class GridFacetFactory extends FacetFactoryAbstract {
+
public GridFacetFactory() {
super(FeatureType.OBJECTS_ONLY);
}
@Override
public void process(final ProcessClassContext processClassContext) {
- final FacetHolder facetHolder = processClassContext.getFacetHolder();
-
- final GridService gridService = getServiceRegistry().lookupServiceElseFail(GridService.class);
+ val facetHolder = processClassContext.getFacetHolder();
- FacetUtil.addFacet(GridFacetDefault.create(facetHolder, gridService));
+ FacetUtil.addFacet(GridFacetDefault.create(facetHolder, gridService.get()));
}
+
+ private final _Lazy<GridService> gridService = _Lazy.threadSafe(()->
+ getServiceRegistry().lookupServiceElseFail(GridService.class));
+
}
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/services/metamodel/MetaModelServiceDefault.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/services/metamodel/MetaModelServiceDefault.java
index 681c4a9..87b0705 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/services/metamodel/MetaModelServiceDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/services/metamodel/MetaModelServiceDefault.java
@@ -25,7 +25,6 @@ import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import javax.inject.Singleton;
import org.springframework.stereotype.Service;
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefault.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefault.java
index 7661db0..df19632 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefault.java
@@ -19,10 +19,10 @@
package org.apache.isis.metamodel.specloader;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
import java.util.Map;
+import java.util.function.Function;
import org.apache.isis.commons.internal.collections._Lists;
import org.apache.isis.commons.internal.collections._Maps;
@@ -30,11 +30,13 @@ import org.apache.isis.metamodel.facets.object.objectspecid.ObjectSpecIdFacet;
import org.apache.isis.metamodel.spec.ObjectSpecId;
import org.apache.isis.metamodel.spec.ObjectSpecification;
+import lombok.val;
+
/**
* This is populated in two parts.
*
- * Initially the <tt>specByClassName</tt> map is populated using {@link #cache(String, ObjectSpecification)}.
+ * Initially the <tt>specByClassName</tt> map is populated using {@link #put(String, ObjectSpecification)}.
* This allows {@link #allSpecifications()} to return a list of specs.
* Later on, {@link #init()} called which populates #classNameBySpecId.
*
@@ -43,16 +45,22 @@ import org.apache.isis.metamodel.spec.ObjectSpecification;
* {@link IllegalStateException}.
*
*/
-class SpecificationCacheDefault {
+class SpecificationCacheDefault<T extends ObjectSpecification> {
- private final Map<String, ObjectSpecification> specByClassName = _Maps.newHashMap();
+ private final Map<String, T> specByClassName = _Maps.newHashMap();
private Map<ObjectSpecId, String> classNameBySpecId;
- public ObjectSpecification get(final String className) {
+ public T get(final String className) {
return specByClassName.get(className);
}
+
+ public T computeIfAbsent(
+ final String className,
+ final Function<? super String, T> mappingFunction) {
+ return specByClassName.computeIfAbsent(className, mappingFunction);
+ }
- public void cache(final String className, final ObjectSpecification spec) {
+ public void put(final String className, final T spec) {
specByClassName.put(className, spec);
recache(spec);
}
@@ -62,11 +70,14 @@ class SpecificationCacheDefault {
specByClassName.clear();
}
- public Collection<ObjectSpecification> allSpecifications() {
- return Collections.unmodifiableCollection(specByClassName.values());
+ /** @returns thread-safe defensive copy */
+ public Collection<T> snapshotSpecs() {
+ synchronized(this) {
+ return new ArrayList<T>(specByClassName.values());
+ }
}
- public ObjectSpecification getByObjectType(final ObjectSpecId objectSpecID) {
+ public T getByObjectType(final ObjectSpecId objectSpecID) {
if (!isInitialized()) {
throw new IllegalStateException("SpecificationCache by object type has not yet been initialized");
}
@@ -75,17 +86,16 @@ class SpecificationCacheDefault {
}
synchronized void init() {
- final Map<ObjectSpecId, ObjectSpecification> specById = _Maps.newHashMap();
-
- final List<ObjectSpecification> cachedSpecifications = _Lists.newArrayList();
- while(true) {
- final Collection<ObjectSpecification> newSpecifications = _Lists.newArrayList(allSpecifications());
+ val specById = _Maps.<ObjectSpecId, T>newHashMap();
+ val cachedSpecifications = _Lists.<T>newArrayList();
+ for(;;) {
+ val newSpecifications = snapshotSpecs();
newSpecifications.removeAll(cachedSpecifications);
if(newSpecifications.isEmpty()) {
break;
}
- for (final ObjectSpecification objSpec : newSpecifications) {
- final ObjectSpecId objectSpecId = objSpec.getSpecId();
+ for (val objSpec : newSpecifications) {
+ val objectSpecId = objSpec.getSpecId();
if (objectSpecId == null) {
continue;
}
@@ -97,13 +107,13 @@ class SpecificationCacheDefault {
internalInit(specById);
}
- void internalInit(final Map<ObjectSpecId, ObjectSpecification> specById) {
- final Map<ObjectSpecId, String> classNameBySpecId = _Maps.newHashMap();
- final Map<String, ObjectSpecification> specByClassName = _Maps.newHashMap();
+ void internalInit(final Map<ObjectSpecId, T> specById) {
+ val classNameBySpecId = _Maps.<ObjectSpecId, String>newHashMap();
+ val specByClassName = _Maps.<String, T>newHashMap();
- for (ObjectSpecId objectSpecId : specById.keySet()) {
- final ObjectSpecification objectSpec = specById.get(objectSpecId);
- final String className = objectSpec.getCorrespondingClass().getName();
+ for (val objectSpecId : specById.keySet()) {
+ val objectSpec = specById.get(objectSpecId);
+ val className = objectSpec.getCorrespondingClass().getName();
classNameBySpecId.put(objectSpecId, className);
specByClassName.put(className, objectSpec);
}
@@ -112,8 +122,8 @@ class SpecificationCacheDefault {
this.specByClassName.putAll(specByClassName);
}
- public ObjectSpecification remove(String typeName) {
- ObjectSpecification removed = specByClassName.remove(typeName);
+ public T remove(String typeName) {
+ T removed = specByClassName.remove(typeName);
if(removed != null) {
if(removed.containsDoOpFacet(ObjectSpecIdFacet.class)) {
// umm. It turns out that anonymous inner classes (eg org.estatio.dom.WithTitleGetter$ToString$1)
@@ -128,7 +138,7 @@ class SpecificationCacheDefault {
/**
* @param spec
*/
- public void recache(ObjectSpecification spec) {
+ public void recache(T spec) {
if(!isInitialized()) {
// JRebel plugin might call this before we are actually up and running;
// just ignore.
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoader.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoader.java
index 9d0d96d..0a99de1 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoader.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoader.java
@@ -23,8 +23,6 @@ import java.util.List;
import javax.annotation.Nullable;
import org.apache.isis.commons.internal.base._Strings;
-import org.apache.isis.config.property.ConfigPropertyBoolean;
-import org.apache.isis.config.property.ConfigPropertyEnum;
import org.apache.isis.metamodel.commons.ClassUtil;
import org.apache.isis.metamodel.spec.ObjectSpecId;
import org.apache.isis.metamodel.spec.ObjectSpecification;
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java
index aea88bc..579d484 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java
@@ -28,6 +28,7 @@ import javax.inject.Inject;
import org.springframework.stereotype.Service;
+import org.apache.isis.commons.internal.base._Casts;
import org.apache.isis.commons.internal.collections._Lists;
import org.apache.isis.config.IsisConfiguration;
import org.apache.isis.config.registry.IsisBeanTypeRegistry;
@@ -75,7 +76,7 @@ import lombok.extern.log4j.Log4j2;
@Service
@Log4j2
public class SpecificationLoaderDefault implements SpecificationLoader {
-
+
private final ClassSubstitutor classSubstitutor = new ClassSubstitutor();
private ProgrammingModel programmingModel;
@@ -83,7 +84,8 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
private MetaModelValidator metaModelValidator;
- private final SpecificationCacheDefault cache = new SpecificationCacheDefault();
+ private final SpecificationCacheDefault<ObjectSpecificationAbstract> cache =
+ new SpecificationCacheDefault<>();
private PostProcessor postProcessor;
@PostConstruct
@@ -144,9 +146,9 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
val typeRegistry = IsisBeanTypeRegistry.current();
- val specificationsFromRegistry = _Lists.<ObjectSpecification>newArrayList();
- val domainServiceSpecs = _Lists.<ObjectSpecification>newArrayList();
- val mixinSpecs = _Lists.<ObjectSpecification>newArrayList();
+ val specificationsFromRegistry = _Lists.<ObjectSpecificationAbstract>newArrayList();
+ val domainServiceSpecs = _Lists.<ObjectSpecificationAbstract>newArrayList();
+ val mixinSpecs = _Lists.<ObjectSpecificationAbstract>newArrayList();
CommonDtoUtils.VALUE_TYPES.forEach(type->{
val spec = internalLoadSpecificationOrNull(type, IntrospectionState.NOT_INTROSPECTED);
@@ -187,7 +189,7 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
cache.init();
- final Collection<ObjectSpecification> cachedSpecifications = allCachedSpecifications();
+ val cachedSpecifications = cache.snapshotSpecs();
logBefore(specificationsFromRegistry, cachedSpecifications);
@@ -284,51 +286,34 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
return spec;
}
- private ObjectSpecification internalLoadSpecificationOrNull(
+ private ObjectSpecificationAbstract internalLoadSpecificationOrNull(
final Class<?> type,
final IntrospectionState upTo) {
- final Class<?> substitutedType = classSubstitutor.getClass(type);
+ val substitutedType = classSubstitutor.getClass(type);
if (substitutedType == null) {
return null;
}
val typeName = substitutedType.getName();
- //TODO[2033] don't block on long running code ... 'specSpi.introspectUpTo(upTo);'
+ final ObjectSpecificationAbstract cachedSpec;
+
+ //XXX don't block on long running code ... 'spec.introspectUpTo(upTo);'
synchronized (cache) {
-
- val spec = cache.get(typeName);
- if (spec != null) {
- if(spec instanceof ObjectSpecificationAbstract) {
- ((ObjectSpecificationAbstract)spec).introspectUpTo(upTo);
- }
- return spec;
- }
-
- val specification = createSpecification(substitutedType);
-
- // put into the cache prior to introspecting, to prevent
- // infinite loops
- cache.cache(typeName, specification);
- specification.introspectUpTo(upTo);
-
- return specification;
+ cachedSpec = cache.computeIfAbsent(typeName, __->createSpecification(substitutedType));
}
+
+ cachedSpec.introspectUpTo(upTo);
+ return cachedSpec;
+
}
// -- LOOKUP
@Override
public List<ObjectSpecification> currentSpecifications() {
-
- final List<ObjectSpecification> defensiveCopy;
-
- synchronized (cache) {
- defensiveCopy = _Lists.newArrayList(allCachedSpecifications());
- }
-
- return defensiveCopy;
+ return _Casts.uncheckedCast(cache.snapshotSpecs());
}
@Override
@@ -348,10 +333,6 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
// -- HELPER
- private Collection<ObjectSpecification> allCachedSpecifications() {
- return cache.allSpecifications();
- }
-
/**
* Creates the appropriate type of {@link ObjectSpecification}.
*/
@@ -385,8 +366,8 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
//private final static _Probe probe = _Probe.unlimited().label("SpecificationLoader");
private void logBefore(
- final List<ObjectSpecification> specificationsFromRegistry,
- final Collection<ObjectSpecification> cachedSpecifications) {
+ final List<? extends ObjectSpecification> specificationsFromRegistry,
+ final Collection<? extends ObjectSpecification> cachedSpecifications) {
if(!log.isDebugEnabled()) {
return;
}
@@ -406,12 +387,12 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
registryNotCached.size(), cachedNotRegistry.size()));
}
- private void logAfter(final Collection<ObjectSpecification> cachedSpecifications) {
+ private void logAfter(final Collection<? extends ObjectSpecification> cachedSpecifications) {
if(!log.isDebugEnabled()) {
return;
}
- final Collection<ObjectSpecification> cachedSpecificationsAfter = cache.allSpecifications();
+ val cachedSpecificationsAfter = cache.snapshotSpecs();
List<ObjectSpecification> cachedAfterNotBefore = cachedSpecificationsAfter.stream()
.filter(spec -> !cachedSpecifications.contains(spec))
.collect(Collectors.toList());
@@ -419,25 +400,26 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
cachedSpecificationsAfter.size(), cachedAfterNotBefore.size()));
}
- private void introspect(final Collection<ObjectSpecification> specs, final IntrospectionState upTo) {
+ private void introspect(
+ final Collection<ObjectSpecificationAbstract> specs,
+ final IntrospectionState upTo) {
val isConcurrentFromConfig = configuration.getReflector().getIntrospector().isParallelize();
- val runSequential = !isConcurrentFromConfig || true; //FIXME concurrent specloading disabled, it deadlocks
+ val runSequential = !isConcurrentFromConfig;
if(runSequential) {
- for (final ObjectSpecification specification : specs) {
- val specSpi = (ObjectSpecificationAbstract) specification;
- specSpi.introspectUpTo(upTo);
+ for (val spec : specs) {
+ spec.introspectUpTo(upTo);
}
- return;
+ return; // sequential run done
}
specs.parallelStream()
- .map(spec -> (ObjectSpecificationAbstract) spec)
.forEach(spec -> spec.introspectUpTo(upTo));
+
}
@@ -469,7 +451,7 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
private void recache(final ObjectSpecification newSpec) {
- cache.recache(newSpec);
+ cache.recache((ObjectSpecificationAbstract)newSpec);
}
// -- DEPS
diff --git a/core/metamodel/src/test/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefaultTest.java b/core/metamodel/src/test/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefaultTest.java
index ed2f2cd..9996ebb 100644
--- a/core/metamodel/src/test/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefaultTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/metamodel/specloader/SpecificationCacheDefaultTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.isis.metamodel.specloader;
-import java.util.Collection;
import java.util.Map;
import org.jmock.Expectations;
@@ -39,6 +38,8 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
+import lombok.val;
+
public class SpecificationCacheDefaultTest {
@Rule
@@ -49,11 +50,11 @@ public class SpecificationCacheDefaultTest {
@Mock
private ObjectSpecification orderSpec;
- private SpecificationCacheDefault specificationCache;
+ private SpecificationCacheDefault<ObjectSpecification> specificationCache;
@Before
public void setUp() throws Exception {
- specificationCache = new SpecificationCacheDefault();
+ specificationCache = new SpecificationCacheDefault<>();
context.checking(new Expectations() {{
allowing(customerSpec).getCorrespondingClass();
@@ -80,7 +81,7 @@ public class SpecificationCacheDefaultTest {
@Test
public void get_whenCached() {
final String customerClassName = Customer.class.getName();
- specificationCache.cache(customerClassName, customerSpec);
+ specificationCache.put(customerClassName, customerSpec);
final ObjectSpecification objectSpecification = specificationCache.get(customerClassName);
@@ -90,10 +91,10 @@ public class SpecificationCacheDefaultTest {
@Test
public void allSpecs_whenCached() {
- specificationCache.cache(Customer.class.getName(), customerSpec);
- specificationCache.cache(Order.class.getName(), orderSpec);
+ specificationCache.put(Customer.class.getName(), customerSpec);
+ specificationCache.put(Order.class.getName(), orderSpec);
- final Collection<ObjectSpecification> allSpecs = specificationCache.allSpecifications();
+ val allSpecs = specificationCache.snapshotSpecs();
assertThat(allSpecs.size(), is(2));
}
diff --git a/core/runtime/src/main/java/org/apache/isis/runtime/system/session/IsisSessionFactoryDefault.java b/core/runtime/src/main/java/org/apache/isis/runtime/system/session/IsisSessionFactoryDefault.java
index 737b46e..aa34cae 100644
--- a/core/runtime/src/main/java/org/apache/isis/runtime/system/session/IsisSessionFactoryDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/runtime/system/session/IsisSessionFactoryDefault.java
@@ -26,10 +26,11 @@ import java.util.Set;
import java.util.concurrent.Callable;
import java.util.stream.Stream;
-import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import org.apache.isis.applib.services.i18n.TranslationService;
@@ -83,8 +84,9 @@ public class IsisSessionFactoryDefault implements IsisSessionFactory {
private IsisLocaleInitializer localeInitializer;
private IsisTimeZoneInitializer timeZoneInitializer;
- @PostConstruct
- public void init() {
+ //@PostConstruct .. too early, needs services to be provisioned first
+ @EventListener
+ public void init(ContextRefreshedEvent event) {
this.localeInitializer = new IsisLocaleInitializer();
this.timeZoneInitializer = new IsisTimeZoneInitializer();