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/05/16 13:18:26 UTC
[isis] branch 2112_SpringBoot updated: ISIS-2112: fixes some
provisioning issues
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch 2112_SpringBoot
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/2112_SpringBoot by this push:
new 44ee6d6 ISIS-2112: fixes some provisioning issues
44ee6d6 is described below
commit 44ee6d6f4cf45e67c11b3537b35c9af60fa73c31
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu May 16 15:18:19 2019 +0200
ISIS-2112: fixes some provisioning issues
- also let ServiceRegistry wait on Spring's context to become available
Task-Url: https://issues.apache.org/jira/browse/ISIS-2112
---
.../core/metamodel/facetapi/MetaModelRefiner.java | 7 +--
.../metamodel/MetaModelServiceDefault.java | 18 +++++--
.../services/registry/ServiceRegistryDefault.java | 5 ++
.../services/registry/SpringContextProvider.java | 23 ++++++++
.../MetaModelValidatorServiceDefault.java | 4 +-
.../org/apache/isis/runtime/spring/IsisBoot.java | 33 ++++++++++++
.../java/domainapp/application/HelloWorldApp.java | 38 ++++++++++++++
.../application/HelloWorldAppManifest.java | 61 +++++++++++++++++++++-
8 files changed, 177 insertions(+), 12 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/MetaModelRefiner.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/MetaModelRefiner.java
index c30d6db..f8f6661 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/MetaModelRefiner.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facetapi/MetaModelRefiner.java
@@ -22,7 +22,7 @@ package org.apache.isis.core.metamodel.facetapi;
import java.util.List;
import java.util.stream.Collectors;
-import org.apache.isis.core.metamodel.MetaModelContext;
+import org.apache.isis.applib.services.registry.ServiceRegistry;
import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
@@ -41,10 +41,7 @@ public interface MetaModelRefiner extends MetaModelValidatorRefiner {
// -- LOOKUP ALL REFINERS
- static List<MetaModelRefiner> getAll() {
-
- val context = MetaModelContext.current();
- val serviceRegistry = context.getServiceRegistry();
+ static List<MetaModelRefiner> getAll(ServiceRegistry serviceRegistry) {
val refiners = serviceRegistry.select(MetaModelRefiner.class)
.stream()
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/MetaModelServiceDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/MetaModelServiceDefault.java
index 7fe4eec..d5165ce 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/MetaModelServiceDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/metamodel/MetaModelServiceDefault.java
@@ -85,9 +85,7 @@ public class MetaModelServiceDefault implements MetaModelService {
@Override
public void rebuild(final Class<?> domainType) {
- GridService gridService = serviceRegistry.lookupServiceElseFail(GridService.class);
gridService.remove(domainType);
-
specificationLoader.reloadSpecification(domainType);
}
@@ -259,8 +257,20 @@ public class MetaModelServiceDefault implements MetaModelService {
}
@Inject ServiceRegistry serviceRegistry;
+
+ //-------------
+ //TODO[2112] workaround circular dependency issues when bootstrapping ...
@Inject SpecificationLoader specificationLoader;
- //@Inject GridService gridService; // to break circular dependency
-
+ @Inject GridService gridService;
+ //
+// private _Lazy<SpecificationLoader> specificationLoader = _Lazy.threadSafe(()->
+// serviceRegistry.lookupServiceElseFail(SpecificationLoader.class));
+// //
+// private _Lazy<GridService> gridService = _Lazy.threadSafe(()->
+// serviceRegistry.lookupServiceElseFail(GridService.class));
+// //
+// private _Lazy<MetaModelExporter> metaModelExporter = _Lazy.threadSafe(()->
+// new MetaModelExporter(specificationLoader.get()));
+ //-------------
}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/ServiceRegistryDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/ServiceRegistryDefault.java
index 62d9f9c..04a7971 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/ServiceRegistryDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/ServiceRegistryDefault.java
@@ -24,6 +24,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.isis.applib.annotation.DomainService;
@@ -54,6 +55,10 @@ public final class ServiceRegistryDefault implements ServiceRegistry {
return registeredBeans.get().stream();
}
+ // -- DEPS
+
+ // ensure we have Spring's context
+ @Inject SpringContextProvider springContextProvider;
// -- HELPER
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/SpringContextProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/SpringContextProvider.java
new file mode 100644
index 0000000..90caad4
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/registry/SpringContextProvider.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.core.metamodel.services.registry;
+
+public interface SpringContextProvider {
+
+}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/MetaModelValidatorServiceDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/MetaModelValidatorServiceDefault.java
index 6f44cfc..fc56775 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/MetaModelValidatorServiceDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/MetaModelValidatorServiceDefault.java
@@ -21,6 +21,7 @@ package org.apache.isis.core.metamodel.specloader;
import javax.inject.Inject;
import javax.inject.Singleton;
+import org.apache.isis.applib.services.registry.ServiceRegistry;
import org.apache.isis.commons.internal.base._Lazy;
import org.apache.isis.config.IsisConfiguration;
import org.apache.isis.core.commons.factory.InstanceUtil;
@@ -47,6 +48,7 @@ public class MetaModelValidatorServiceDefault implements MetaModelValidatorServi
@Inject private IsisConfiguration configuration;
@Inject private ProgrammingModelService programmingModelService;
+ @Inject private ServiceRegistry serviceRegistry;
private _Lazy<MetaModelValidator> metaModelValidator =
_Lazy.threadSafe(this::createMetaModelValidator);
@@ -61,7 +63,7 @@ public class MetaModelValidatorServiceDefault implements MetaModelValidatorServi
val mmValidatorComposite = MetaModelValidatorComposite.asComposite(mmValidator);
val programmingModel = programmingModelService.get();
- val metaModelRefiners = MetaModelRefiner.getAll();
+ val metaModelRefiners = MetaModelRefiner.getAll(serviceRegistry);
for (MetaModelRefiner metaModelRefiner : metaModelRefiners) {
metaModelRefiner.refineProgrammingModel(programmingModel);
diff --git a/core/runtime-extensions/src/main/java/org/apache/isis/runtime/spring/IsisBoot.java b/core/runtime-extensions/src/main/java/org/apache/isis/runtime/spring/IsisBoot.java
index 15ec99b..d530449 100644
--- a/core/runtime-extensions/src/main/java/org/apache/isis/runtime/spring/IsisBoot.java
+++ b/core/runtime-extensions/src/main/java/org/apache/isis/runtime/spring/IsisBoot.java
@@ -1,9 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.isis.runtime.spring;
+import javax.inject.Singleton;
+
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
@@ -15,6 +36,8 @@ import org.apache.isis.commons.internal.context._Context;
import org.apache.isis.commons.internal.spring._Spring;
import org.apache.isis.config.internal._Config;
import org.apache.isis.core.metamodel.IsisMetamodelModule;
+import org.apache.isis.core.metamodel.services.registry.ServiceRegistryDefault;
+import org.apache.isis.core.metamodel.services.registry.SpringContextProvider;
import org.apache.isis.core.runtime.IsisRuntimeModule;
import org.apache.isis.core.runtime.services.IsisRuntimeServicesModule;
import org.apache.isis.core.runtime.threadpool.ThreadPoolExecutionMode;
@@ -63,6 +86,16 @@ public class IsisBoot implements ApplicationContextAware {
}
}
+
+ /**
+ * With this producer we create a dependency from {@link ServiceRegistryDefault} to here.
+ * Lets {@link ServiceRegistryDefault} wait on Spring's context to become available.
+ * @return just a dummy
+ */
+ @Bean @Singleton
+ public SpringContextProvider springContextProvider() {
+ return new SpringContextProvider() {};
+ }
}
diff --git a/example/application/helloworld/src/main/java/domainapp/application/HelloWorldApp.java b/example/application/helloworld/src/main/java/domainapp/application/HelloWorldApp.java
new file mode 100644
index 0000000..e99b77c
--- /dev/null
+++ b/example/application/helloworld/src/main/java/domainapp/application/HelloWorldApp.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package domainapp.application;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.annotation.Import;
+
+import org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession5;
+import org.apache.isis.runtime.spring.IsisBoot;
+
+@SpringBootApplication
+@Import({
+ PersistenceSession5.class,
+ IsisBoot.class,
+ FixtureScriptsDefault.class,
+ HelloWorldAppManifest.class
+})
+public class HelloWorldApp extends SpringBootServletInitializer {
+
+}
diff --git a/example/application/helloworld/src/main/java/domainapp/application/HelloWorldAppManifest.java b/example/application/helloworld/src/main/java/domainapp/application/HelloWorldAppManifest.java
index bd66434..38dfb66 100644
--- a/example/application/helloworld/src/main/java/domainapp/application/HelloWorldAppManifest.java
+++ b/example/application/helloworld/src/main/java/domainapp/application/HelloWorldAppManifest.java
@@ -18,15 +18,72 @@
*/
package domainapp.application;
+import javax.inject.Singleton;
+
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.io.ClassPathResource;
+
+import org.apache.isis.config.IsisConfiguration;
+import org.apache.isis.config.beans.WebAppConfigBean;
+import org.apache.isis.config.internal._Config;
+import org.apache.isis.core.runtime.authorization.standard.AuthorizationManagerStandard;
+import org.apache.isis.core.security.authentication.bypass.AuthenticatorBypass;
+import org.apache.isis.core.security.authentication.manager.AuthenticationManager;
+import org.apache.isis.core.security.authentication.standard.AuthenticationManagerStandard;
+import org.apache.isis.core.security.authorization.bypass.AuthorizorBypass;
+import org.apache.isis.core.security.authorization.manager.AuthorizationManager;
+import org.apache.isis.core.security.authorization.standard.Authorizor;
/**
* Bootstrap the application.
*/
@Configuration
-@PropertySource("isis-non-changing.properties")
-public class HelloWorldAppManifest {
+@PropertySource("classpath:/domainapp/application/isis-non-changing.properties")
+public class HelloWorldAppManifest {
+
+ @Bean @Singleton
+ public IsisConfiguration getConfig() {
+ return _Config.getConfiguration();
+ }
+
+ /**
+ * The standard authentication manager, configured with the 'bypass' authenticator
+ * (allows all requests through).
+ * <p>
+ * integration tests ignore appManifest for authentication and authorization.
+ */
+ @Bean @Singleton
+ public AuthenticationManager authenticationManagerWithBypass() {
+ final AuthenticationManagerStandard authenticationManager = new AuthenticationManagerStandard();
+ authenticationManager.addAuthenticator(new AuthenticatorBypass());
+ return authenticationManager;
+ }
+
+ @Bean @Singleton
+ public AuthorizationManager authorizationManagerWithBypass() {
+ final AuthorizationManagerStandard authorizationManager = new AuthorizationManagerStandard() {
+ {
+ authorizor = new AuthorizorBypass();
+ }
+ };
+ return authorizationManager;
+ }
+
+ @Bean @Singleton
+ public Authorizor autorizor() {
+ return new AuthorizorBypass();
+ }
+
+
+ @Bean @Singleton
+ public WebAppConfigBean webAppConfigBean() {
+ return WebAppConfigBean.builder()
+ .menubarsLayoutXml(new ClassPathResource("menubars.layout.xml", this.getClass()))
+ .build();
+ }
+
//TODO[2112] add missing producers