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 2018/02/23 09:53:37 UTC

[isis] branch master updated (a505032 -> f89ec39)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from a505032  ISIS-1870: fixes compile issue
     new 63a45ae  ISIS-1871 just warn if db connection not configured for schema creation
     new 6e06e73  ISIS-1871 ISIS-1756 ISIS-1775 proper life-cycling + context-path support
     new 7e409ca  ISIS-1871 ISIS-1755 let CDI ignore beans as specified
     new f89ec39  ISIS-1871 minor cleanup and refactoring

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../value/vsp/ValueSemanticsProviderUtil.java      |   2 -
 .../services/swagger/SwaggerServiceDefault.java    |  15 ++-
 .../WebAppContextSupport.java}                     |  45 +++++----
 .../core/runtime/services/ServiceInstantiator.java |  10 +-
 .../core/runtime/system/context/IsisContext.java   |  18 +++-
 .../DataNucleusApplicationComponents.java          |  21 ++++-
 .../persistence/PersistenceSessionFactory.java     |  31 ++-----
 .../PersistenceSessionFactoryMetamodelRefiner.java |   1 -
 .../system/session/IsisSessionFactoryBuilder.java  |  25 +++--
 .../IsisComponentProvider.java                     |  18 ++--
 .../PersistenceCapableTypeFinder.java              |  65 +++++++++++++
 .../webapp/jee/IsisCDIBeanScanInterceptor.java     | 102 +++++++++++++++++++++
 .../CreateSchemaObjectFromClassMetadata.java       |   5 +
 .../datanucleus/DataNucleusLifeCycleHelper.java    |  57 ++++++++++++
 .../objectstore/jdo/service/RegisterEntities.java  |  83 +++--------------
 .../services/javax.enterprise.inject.spi.Extension |   1 +
 .../wicket/viewer/IsisWicketApplication.java       |  99 ++++++++++----------
 17 files changed, 401 insertions(+), 197 deletions(-)
 copy core/metamodel/src/main/java/org/apache/isis/core/{runtime/fixtures/authentication/AuthenticationRequestLogonFixture.java => webapp/WebAppContextSupport.java} (52%)
 create mode 100644 core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java
 create mode 100644 core/runtime/src/main/java/org/apache/isis/core/webapp/jee/IsisCDIBeanScanInterceptor.java
 create mode 100644 core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusLifeCycleHelper.java
 create mode 100644 core/runtime/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.

[isis] 01/04: ISIS-1871 just warn if db connection not configured for schema creation

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 63a45aeed001f5ca4a5e176bc38901e989276615
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Feb 23 10:29:42 2018 +0100

    ISIS-1871 just warn if db connection not configured for schema creation
---
 .../jdo/datanucleus/CreateSchemaObjectFromClassMetadata.java         | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/CreateSchemaObjectFromClassMetadata.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/CreateSchemaObjectFromClassMetadata.java
index 6b2d536..465f19b 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/CreateSchemaObjectFromClassMetadata.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/CreateSchemaObjectFromClassMetadata.java
@@ -67,6 +67,11 @@ public class CreateSchemaObjectFromClassMetadata implements MetaDataListener, Da
         final String url = properties.get("javax.jdo.option.ConnectionURL");
         final String userName = properties.get("javax.jdo.option.ConnectionUserName");
         final String password = getConnectionPassword();
+        
+        if(Strings.isNullOrEmpty(driverName) || Strings.isNullOrEmpty(url)) {
+        	LOG.warn("Unable to create schema due to missing configuration javax.jdo.option.Connection*");
+        	return;
+        }
 
         try {
 

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.

[isis] 02/04: ISIS-1871 ISIS-1756 ISIS-1775 proper life-cycling + context-path support

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 6e06e73c81b76fdb6db2a6850c74996d2def6e6b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Feb 23 10:40:31 2018 +0100

    ISIS-1871 ISIS-1756 ISIS-1775 proper life-cycling + context-path support
    
    this works for DN 4 or 5 >= 5.1.5
---
 .../services/swagger/SwaggerServiceDefault.java    | 15 +++-
 .../isis/core/webapp/WebAppContextSupport.java     | 50 +++++++++++
 .../core/runtime/system/context/IsisContext.java   | 18 +++-
 .../DataNucleusApplicationComponents.java          | 21 ++++-
 .../persistence/PersistenceSessionFactory.java     | 31 ++-----
 .../datanucleus/DataNucleusLifeCycleHelper.java    | 57 +++++++++++++
 .../wicket/viewer/IsisWicketApplication.java       | 99 ++++++++++++----------
 7 files changed, 215 insertions(+), 76 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/swagger/SwaggerServiceDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/swagger/SwaggerServiceDefault.java
index 968a93c..192b5f6 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/swagger/SwaggerServiceDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/swagger/SwaggerServiceDefault.java
@@ -22,15 +22,15 @@ import java.util.Map;
 
 import javax.annotation.PostConstruct;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.NatureOfService;
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.swagger.SwaggerService;
 import org.apache.isis.core.metamodel.services.swagger.internal.SwaggerSpecGenerator;
 import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
+import org.apache.isis.core.webapp.WebAppContextSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @DomainService(
         nature = NatureOfService.DOMAIN,
@@ -48,7 +48,14 @@ public class SwaggerServiceDefault implements SwaggerService {
 
     @PostConstruct
     public void init(final Map<String,String> properties) {
-        this.basePath = getPropertyElse(properties, KEY_RESTFUL_BASE_PATH, KEY_RESTFUL_BASE_PATH_DEFAULT);
+    	
+    	final String webappContextPath = 
+    			getPropertyElse(properties, WebAppContextSupport.WEB_APP_CONTEXT_PATH, "/");
+    	
+    	final String basePath = 
+    			getPropertyElse(properties, KEY_RESTFUL_BASE_PATH, KEY_RESTFUL_BASE_PATH_DEFAULT);
+    	
+    	this.basePath = WebAppContextSupport.prependContextPathIfPresent(webappContextPath, basePath);
     }
 
     static String getPropertyElse(final Map<String, String> properties, final String key, final String dflt) {
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/webapp/WebAppContextSupport.java b/core/metamodel/src/main/java/org/apache/isis/core/webapp/WebAppContextSupport.java
new file mode 100644
index 0000000..10aa314
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/webapp/WebAppContextSupport.java
@@ -0,0 +1,50 @@
+/*
+ *  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.webapp;
+
+import javax.servlet.ServletContext;
+
+import com.google.common.base.Strings;
+
+public class WebAppContextSupport {
+
+    /**
+     * Property name given to the context path of the web application as returned by 
+     * {@link ServletContext#getContextPath()}.
+     */
+	public static final String WEB_APP_CONTEXT_PATH = "application.webapp.context-path";
+	
+	
+	public static String prependContextPathIfPresent(String contextPath, String path) {
+		if(Strings.isNullOrEmpty(contextPath) || contextPath.equals("/"))
+			return path;
+		
+		if(!contextPath.startsWith("/"))
+			throw new IllegalArgumentException(
+					"contextPath must start with a slash '/' character, got '"+contextPath+"'");
+
+		if(!path.startsWith("/"))
+			throw new IllegalArgumentException(
+					"path must start with a slash '/' character, got '"+path+"'");
+		
+		return contextPath + path;
+	}
+	
+}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
index ee1cc1c..9763ff5 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
@@ -48,7 +48,7 @@ public interface IsisContext {
 				()->new IllegalStateException(
 						"internal error: should have been populated by IsisSessionFactoryBuilder") );
 	}
-	
+
 	/**
 	 * 
 	 * @return Isis's default class loader
@@ -65,6 +65,7 @@ public interface IsisContext {
      */
     public static void clear() {
     	_Context.clear();
+    	resetLogging();
     }
     
     // -- DEPRECATIONS
@@ -79,4 +80,19 @@ public interface IsisContext {
     	clear();
     }
 
+	// -- HELPER
+
+	/**
+	 * TODO [andi-huber] not sure if required, initial idea was to force log4j
+	 * re-configuration on an undeploy/deploy cycle
+	 */
+	static void resetLogging() {
+		try {
+			org.apache.log4j.BasicConfigurator.resetConfiguration();
+			org.apache.log4j.Logger.getRootLogger().removeAllAppenders();
+		} catch (Exception e) {
+			// at least we tried
+		}
+	}
+
 }
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/DataNucleusApplicationComponents.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/DataNucleusApplicationComponents.java
index 52ac35b..4e8d9fa 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/DataNucleusApplicationComponents.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/DataNucleusApplicationComponents.java
@@ -41,7 +41,9 @@ import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.factory.InstanceUtil;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
+import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.objectstore.jdo.datanucleus.CreateSchemaObjectFromClassMetadata;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusLifeCycleHelper;
 import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPropertiesAware;
 import org.apache.isis.objectstore.jdo.metamodel.facets.object.query.JdoNamedQuery;
 import org.apache.isis.objectstore.jdo.metamodel.facets.object.query.JdoQueryFacet;
@@ -109,6 +111,20 @@ public class DataNucleusApplicationComponents implements ApplicationScopedCompon
 
         namedQueryByName = catalogNamedQueries(persistableClassNameSet);
     }
+    
+    /** 
+     * Marks the end of DataNucleus' life-cycle. Purges any state associated with DN. 
+     * Subsequent calls have no effect.  
+     * 
+     * @since 2.0.0
+     */
+    public void shutdown() {
+    	instance = null;
+    	if(persistenceManagerFactory != null) {
+    		DataNucleusLifeCycleHelper.cleanUp(persistenceManagerFactory);
+    		persistenceManagerFactory = null;
+    	}
+    }
 
     private static boolean isSchemaAwareStoreManager(Map<String,String> datanucleusProps) {
 
@@ -148,8 +164,9 @@ public class DataNucleusApplicationComponents implements ApplicationScopedCompon
                 datanucleusProps.put(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_TABLES, "true"); // but have DN do everything else...
                 datanucleusProps.put(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_COLUMNS, "true");
                 datanucleusProps.put(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_CONSTRAINTS, "true");
-
-                persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory(datanucleusProps);
+                
+                persistenceManagerFactory = JDOHelper
+                		.getPersistenceManagerFactory(datanucleusProps,	IsisContext.getClassLoader() );
                 createSchema(persistenceManagerFactory, persistableClassNameSet, datanucleusProps);
 
             } else {
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
index 8a32edb..ad72168 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
@@ -53,18 +53,12 @@ public class PersistenceSessionFactory implements ApplicationScopedComponent, Fi
 
     private static final Logger LOG = LoggerFactory.getLogger(PersistenceSessionFactory.class);
 
-    //region > constructor
-
     private final IsisConfigurationDefault configuration;
 
     public PersistenceSessionFactory(final IsisConfigurationDefault isisConfiguration) {
         this.configuration = isisConfiguration;
     }
 
-    //endregion
-
-    //region > init, createDataNucleusApplicationComponents
-
     public static final String JDO_OBJECTSTORE_CONFIG_PREFIX = "isis.persistor.datanucleus";  // specific to the JDO objectstore
     public static final String DATANUCLEUS_CONFIG_PREFIX = "isis.persistor.datanucleus.impl"; // reserved for datanucleus' own config props
 
@@ -93,7 +87,7 @@ public class PersistenceSessionFactory implements ApplicationScopedComponent, Fi
             final Map<String, String> datanucleusProps = dataNucleusConfig.asMap();
             addDataNucleusPropertiesIfRequired(datanucleusProps);
 
-            final RegisterEntities registerEntities = new RegisterEntities(configuration.asMap(), specificationLoader);
+            final RegisterEntities registerEntities = new RegisterEntities(specificationLoader);
             final Set<String> classesToBePersisted = registerEntities.getEntityTypes();
 
             applicationComponents = new DataNucleusApplicationComponents(jdoObjectstoreConfig, specificationLoader,
@@ -159,19 +153,18 @@ public class PersistenceSessionFactory implements ApplicationScopedComponent, Fi
             props.put(key, value);
         }
     }
-    //endregion
 
-    //region > shutdown
     @Programmatic
     public final void shutdown() {
-        // no-op
+        if(!isInitialized()) {
+            return;
+        }
+    	if(applicationComponents != null) {
+    		applicationComponents.shutdown();
+            applicationComponents = null;
+    	}
     }
 
-    //endregion
-
-
-    //region > createPersistenceSession
-
     /**
      * Called by {@link org.apache.isis.core.runtime.system.session.IsisSessionFactory#openSession(AuthenticationSession)}.
      */
@@ -190,12 +183,6 @@ public class PersistenceSessionFactory implements ApplicationScopedComponent, Fi
                 fixturesInstalledFlag);
     }
 
-
-
-    //endregion
-
-    //region > FixturesInstalledFlag impl
-
     private Boolean fixturesInstalled;
 
     @Programmatic
@@ -210,7 +197,5 @@ public class PersistenceSessionFactory implements ApplicationScopedComponent, Fi
         this.fixturesInstalled = fixturesInstalled;
     }
 
-    //endregion
-
 
 }
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusLifeCycleHelper.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusLifeCycleHelper.java
new file mode 100644
index 0000000..bc19b81
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusLifeCycleHelper.java
@@ -0,0 +1,57 @@
+/*
+ *  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.objectstore.jdo.datanucleus;
+
+import javax.jdo.PersistenceManagerFactory;
+
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.datanucleus.enhancer.EnhancementHelper;
+
+/**
+ * 
+ * Purges any state associated with DataNucleus.
+ * <br/><br/>
+ * (requires datanucleus-core 4 or 5 >= 5.1.5)
+ * 
+ * @since 2.0.0
+ *
+ */
+public class DataNucleusLifeCycleHelper {
+	
+    //private static final Logger LOG = LoggerFactory.getLogger(DataNucleusLifeCycleHelper.class);
+
+	public static void cleanUp(PersistenceManagerFactory persistenceManagerFactory) {
+		
+		try {
+			
+			final ClassLoader cl = IsisContext.getClassLoader();
+			
+			persistenceManagerFactory.close();
+			
+			// for info, on why we do this see
+			// https://github.com/datanucleus/datanucleus-core/issues/272
+			EnhancementHelper.getInstance().unregisterClasses(cl);
+			
+		} catch (Exception e) {
+			// ignore, since it only affects re-deploy-ability, which is nice to have but not critical
+		}
+
+	}
+
+}
diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
index 03426ac..ecf8d4c 100644
--- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
+++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
@@ -30,52 +30,7 @@ import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Resources;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.Component;
-import org.apache.wicket.ConverterLocator;
-import org.apache.wicket.IConverterLocator;
-import org.apache.wicket.Page;
-import org.apache.wicket.RuntimeConfigurationType;
-import org.apache.wicket.SharedResources;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.authentication.IAuthenticationStrategy;
-import org.apache.wicket.authentication.strategy.DefaultAuthenticationStrategy;
-import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
-import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
-import org.apache.wicket.core.request.mapper.MountedMapper;
-import org.apache.wicket.devutils.debugbar.DebugBar;
-import org.apache.wicket.devutils.debugbar.InspectorDebugPanel;
-import org.apache.wicket.devutils.debugbar.PageSizeDebugPanel;
-import org.apache.wicket.devutils.debugbar.SessionSizeDebugPanel;
-import org.apache.wicket.devutils.debugbar.VersionDebugContributor;
-import org.apache.wicket.devutils.diskstore.DebugDiskDataStore;
-import org.apache.wicket.guice.GuiceComponentInjector;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.filter.JavaScriptFilteredIntoFooterHeaderResponse;
-import org.apache.wicket.markup.html.IHeaderContributor;
-import org.apache.wicket.markup.html.IHeaderResponseDecorator;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.cycle.IRequestCycleListener;
-import org.apache.wicket.request.cycle.PageRequestHandlerTracker;
-import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
-import org.apache.wicket.request.resource.CssResourceReference;
-import org.apache.wicket.settings.DebugSettings;
-import org.apache.wicket.settings.RequestCycleSettings;
-import org.apache.wicket.util.IContextProvider;
-import org.apache.wicket.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wicketstuff.select2.ApplicationSettings;
-
+import org.apache.isis.applib.internal.context._Context;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.config.IsisConfigurationDefault;
@@ -91,6 +46,7 @@ import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
 import org.apache.isis.core.runtime.threadpool.ThreadPoolSupport;
 import org.apache.isis.core.webapp.IsisWebAppBootstrapper;
 import org.apache.isis.core.webapp.WebAppConstants;
+import org.apache.isis.core.webapp.WebAppContextSupport;
 import org.apache.isis.schema.utils.ChangesDtoUtils;
 import org.apache.isis.schema.utils.CommandDtoUtils;
 import org.apache.isis.schema.utils.InteractionDtoUtils;
@@ -119,6 +75,51 @@ import org.apache.isis.viewer.wicket.viewer.integration.wicket.ConverterForObjec
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.ConverterForObjectAdapterMemento;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.WebRequestCycleForIsis;
 import org.apache.isis.viewer.wicket.viewer.settings.IsisResourceSettings;
+import org.apache.wicket.Application;
+import org.apache.wicket.Component;
+import org.apache.wicket.ConverterLocator;
+import org.apache.wicket.IConverterLocator;
+import org.apache.wicket.Page;
+import org.apache.wicket.RuntimeConfigurationType;
+import org.apache.wicket.SharedResources;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.authentication.IAuthenticationStrategy;
+import org.apache.wicket.authentication.strategy.DefaultAuthenticationStrategy;
+import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
+import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
+import org.apache.wicket.core.request.mapper.MountedMapper;
+import org.apache.wicket.devutils.debugbar.DebugBar;
+import org.apache.wicket.devutils.debugbar.InspectorDebugPanel;
+import org.apache.wicket.devutils.debugbar.PageSizeDebugPanel;
+import org.apache.wicket.devutils.debugbar.SessionSizeDebugPanel;
+import org.apache.wicket.devutils.debugbar.VersionDebugContributor;
+import org.apache.wicket.devutils.diskstore.DebugDiskDataStore;
+import org.apache.wicket.guice.GuiceComponentInjector;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.filter.JavaScriptFilteredIntoFooterHeaderResponse;
+import org.apache.wicket.markup.html.IHeaderContributor;
+import org.apache.wicket.markup.html.IHeaderResponseDecorator;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.cycle.IRequestCycleListener;
+import org.apache.wicket.request.cycle.PageRequestHandlerTracker;
+import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
+import org.apache.wicket.request.resource.CssResourceReference;
+import org.apache.wicket.settings.DebugSettings;
+import org.apache.wicket.settings.RequestCycleSettings;
+import org.apache.wicket.util.IContextProvider;
+import org.apache.wicket.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.wicketstuff.select2.ApplicationSettings;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.io.Resources;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
 
 import de.agilecoders.wicket.core.Bootstrap;
 import de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapBaseBehavior;
@@ -333,6 +334,8 @@ public class IsisWicketApplication
         List<Future<Object>> futures = null;
         try {
             super.init();
+            
+            _Context.putSingleton(ClassLoader.class, this.getClass().getClassLoader());
 
             futures = startBackgroundInitializationThreads();
 
@@ -346,6 +349,9 @@ public class IsisWicketApplication
 
             final IsisConfigurationBuilder isisConfigurationBuilder = obtainConfigBuilder();
             isisConfigurationBuilder.addDefaultConfigurationResourcesAndPrimers();
+            
+            final String webappContextPath = getServletContext().getContextPath();
+            isisConfigurationBuilder.add(WebAppContextSupport.WEB_APP_CONTEXT_PATH, webappContextPath);
 
             final IsisConfigurationDefault configuration = isisConfigurationBuilder.getConfiguration();
 
@@ -859,6 +865,7 @@ public class IsisWicketApplication
             }
             getServletContext().setAttribute(WebAppConstants.ISIS_SESSION_FACTORY, null);
             super.onDestroy();
+            IsisContext.clear();
         } catch(final RuntimeException ex) {
             // symmetry with #init()
             LOG.error("Failed to destroy", ex);

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.

[isis] 04/04: ISIS-1871 minor cleanup and refactoring

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit f89ec3915e51cb74b5187bbbd561c82759c3d91c
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Feb 23 10:49:09 2018 +0100

    ISIS-1871 minor cleanup and refactoring
---
 .../value/vsp/ValueSemanticsProviderUtil.java      |  2 -
 .../core/runtime/services/ServiceInstantiator.java | 10 +--
 .../PersistenceSessionFactoryMetamodelRefiner.java |  1 -
 .../system/session/IsisSessionFactoryBuilder.java  | 25 +++----
 .../IsisComponentProvider.java                     | 18 +++--
 .../PersistenceCapableTypeFinder.java              | 65 +++++++++++++++++
 .../objectstore/jdo/service/RegisterEntities.java  | 83 ++++------------------
 7 files changed, 103 insertions(+), 101 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/vsp/ValueSemanticsProviderUtil.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/vsp/ValueSemanticsProviderUtil.java
index 03658a5..b34d5fe 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/vsp/ValueSemanticsProviderUtil.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/vsp/ValueSemanticsProviderUtil.java
@@ -24,7 +24,6 @@ import com.google.common.base.Strings;
 import org.apache.isis.applib.adapters.ValueSemanticsProvider;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.lang.ClassUtil;
-import org.apache.isis.core.commons.lang.StringExtensions;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 
 public final class ValueSemanticsProviderUtil {
@@ -46,7 +45,6 @@ public final class ValueSemanticsProviderUtil {
         @SuppressWarnings("rawtypes")
         final Class clazz = candidateClass != null ? ClassUtil.implementingClassOrNull(candidateClass.getName(), ValueSemanticsProvider.class, FacetHolder.class) : null;
         return clazz != null ? clazz : (Class)ClassUtil.implementingClassOrNull(classCandidateName, ValueSemanticsProvider.class, FacetHolder.class);
-
     }
 
 }
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServiceInstantiator.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServiceInstantiator.java
index 02e229e..199e3b3 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServiceInstantiator.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServiceInstantiator.java
@@ -28,11 +28,6 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.enterprise.context.RequestScoped;
 
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.isis.applib.internal.context._Context;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.exceptions.IsisException;
@@ -42,6 +37,11 @@ import org.apache.isis.core.commons.lang.ArrayExtensions;
 import org.apache.isis.core.commons.lang.MethodExtensions;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
 import org.apache.isis.core.metamodel.specloader.classsubstitutor.JavassistEnhanced;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 import javassist.util.proxy.MethodFilter;
 import javassist.util.proxy.MethodHandler;
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactoryMetamodelRefiner.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactoryMetamodelRefiner.java
index 8f5352d..7c6108e 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactoryMetamodelRefiner.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactoryMetamodelRefiner.java
@@ -57,7 +57,6 @@ public class PersistenceSessionFactoryMetamodelRefiner implements MetaModelRefin
         // and also MandatoryFacetOnPropertyMandatoryAnnotationFactory
         // and also PropertyAnnotationFactory
         programmingModel.addFactory(new MandatoryFromJdoColumnAnnotationFacetFactory());
-
     }
 
     @Override
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactoryBuilder.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactoryBuilder.java
index 7a56c93..52df40e 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactoryBuilder.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSessionFactoryBuilder.java
@@ -207,21 +207,18 @@ public class IsisSessionFactoryBuilder {
 
 
             isisSessionFactory.doInSession(
-                    new Runnable() {
-                        @Override
-                        public void run() {
-                            specificationLoader.postProcess();
-                            try {
-                                specificationLoader.validateAndAssert();
-
-                            } catch (final MetaModelInvalidException ex) {
-                                // no need to use a higher level, such as error(...); the calling code will expose any metamodel
-                                // validation errors in their own particular way.
-                                if(LOG.isDebugEnabled()) {
-                                    LOG.debug("Meta model invalid", ex);
-                                }
-                                _Context.putSingleton(MetaModelInvalidException.class, ex);
+                    () -> {
+                        specificationLoader.postProcess();
+                        try {
+                            specificationLoader.validateAndAssert();
+
+                        } catch (final MetaModelInvalidException ex) {
+                            // no need to use a higher level, such as error(...); the calling code will expose any metamodel
+                            // validation errors in their own particular way.
+                            if(LOG.isDebugEnabled()) {
+                                LOG.debug("Meta model invalid", ex);
                             }
+                            _Context.putSingleton(MetaModelInvalidException.class, ex);
                         }
                     }
             );
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
index 70c0acb..9b2936a 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
@@ -23,10 +23,8 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import javax.annotation.Nullable;
-import javax.jdo.annotations.PersistenceCapable;
 
 import org.apache.isis.applib.AppManifest;
 import org.apache.isis.applib.annotation.DomainObject;
@@ -138,19 +136,19 @@ public abstract class IsisComponentProvider {
         final Discovery discovery = _Reflect.discover(moduleAndFrameworkPackages);
 
         final Set<Class<?>> domainServiceTypes = discovery.getTypesAnnotatedWith(DomainService.class);
-        final Set<Class<?>> persistenceCapableTypes = discovery.getTypesAnnotatedWith(PersistenceCapable.class);
+        final Set<Class<?>> persistenceCapableTypes = PersistenceCapableTypeFinder.find(discovery);
         final Set<Class<? extends FixtureScript>> fixtureScriptTypes = discovery.getSubTypesOf(FixtureScript.class);
 
         final Set<Class<?>> mixinTypes = Sets.newHashSet();
         mixinTypes.addAll(discovery.getTypesAnnotatedWith(Mixin.class));
 
         final Set<Class<?>> domainObjectTypes = discovery.getTypesAnnotatedWith(DomainObject.class);
-        mixinTypes.addAll(
-                domainObjectTypes.stream()
-                        .filter(input -> input.getAnnotation(DomainObject.class).nature() == Nature.MIXIN)
-                        .collect(Collectors.toList())
-        );
-        
+        domainObjectTypes.stream()
+        .filter(input -> {
+            final DomainObject annotation = input.getAnnotation(DomainObject.class);
+            return annotation.nature() == Nature.MIXIN;
+        })
+        .forEach(mixinTypes::add);
         
         // add in any explicitly registered services...
         domainServiceTypes.addAll(appManifest.getAdditionalServices());
@@ -190,7 +188,7 @@ public abstract class IsisComponentProvider {
     }
     static private boolean containedWithin(final List<String> packagesWithDotSuffix, final String className) {
         for (String packageWithDotSuffix : packagesWithDotSuffix) {
-            if(className.startsWith(packageWithDotSuffix)) {
+            if (className.startsWith(packageWithDotSuffix)) {
                 return true;
             }
         }
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java
new file mode 100644
index 0000000..1fbf533
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java
@@ -0,0 +1,65 @@
+/*
+ *  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.runtime.systemusinginstallers;
+
+import java.lang.annotation.Annotation;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.jdo.annotations.PersistenceCapable;
+
+import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
+
+/**
+ * 
+ * Package private helper class. Finds PersistenceCapable types.
+ *
+ */
+class PersistenceCapableTypeFinder {
+
+	@SuppressWarnings("unchecked")
+	static Set<Class<?>> find(Discovery discovery) {
+
+		final Set<Class<?>> types = new LinkedHashSet<>();
+
+		discovery.getTypesAnnotatedWith(PersistenceCapable.class).stream()
+		.forEach(type->{
+
+			if(type.isAnnotation()) {
+
+				// We have an annotation, that is annotated with @PersistenceCapable,
+				// this requires special treatment: 
+				// Search for any classes annotated with this (meta-)annotation.
+				
+				discovery.getTypesAnnotatedWith((Class<? extends Annotation>) type).stream()
+				.filter(x->!x.isAnnotation())
+				.forEach(types::add);
+
+			} else {
+
+				types.add(type);
+
+			}	
+		});
+
+		return types;
+	}
+
+}
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
index 7cbb48b..1908dfe 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
@@ -18,33 +18,30 @@
  */
 package org.apache.isis.objectstore.jdo.service;
 
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import javax.jdo.annotations.PersistenceCapable;
 
-import org.apache.isis.applib.AppManifest;
-import org.apache.isis.applib.internal.reflection._Reflect;
-import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
-import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
 import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.applib.AppManifest;
+import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
+
 public class RegisterEntities {
 
     @SuppressWarnings("unused")
     private final static Logger LOG = LoggerFactory.getLogger(RegisterEntities.class);
-    
+
+    /**
+     * @deprecated - no longer used; instead an AppManifest must be specified.
+     */
+    @Deprecated
     public final static String PACKAGE_PREFIX_KEY = "isis.persistor.datanucleus.RegisterEntities.packagePrefix";
 
     // //////////////////////////////////////
@@ -59,13 +56,13 @@ public class RegisterEntities {
     }
     //endregion
 
-    public RegisterEntities(final Map<String, String> configuration, final SpecificationLoader specificationLoader) {
+    public RegisterEntities(final SpecificationLoader specificationLoader) {
         this.specificationLoader = specificationLoader;
 
         Set<Class<?>> persistenceCapableTypes = AppManifest.Registry.instance().getPersistenceCapableTypes();
 
         if(persistenceCapableTypes == null) {
-            persistenceCapableTypes = searchForPersistenceCapables(configuration);
+            throw new IllegalStateException("AppManifest is required");
         }
 
         final List<String> classNamesNotEnhanced = Lists.newArrayList();
@@ -85,52 +82,11 @@ public class RegisterEntities {
         }
     }
 
-    /**
-     * only called if no appManifest
-     */
-    Set<Class<?>> searchForPersistenceCapables(final Map<String, String> configuration) {
-
-        final String packagePrefixes = lookupPackagePrefixes(configuration);
-
-        final Set<Class<?>> persistenceCapableTypes = Sets.newLinkedHashSet();
-        final List<String> domPackages = parseDomPackages(packagePrefixes);
-        for (final String packageName : domPackages) {
-        	
-        	final Discovery dicovery = _Reflect.discover(packageName);
-        	
-            final Set<Class<?>> entityTypesInPackage =
-            		dicovery.getTypesAnnotatedWith(PersistenceCapable.class);
-
-            if(entityTypesInPackage.isEmpty()) {
-                throw new IllegalArgumentException(String.format(
-                        "Bad configuration.\n\nCould not locate any @PersistenceCapable entities in package '%s'\n" +
-                                "Check value of '%s' key in WEB-INF/*.properties\n",
-                        packageName,
-                        PACKAGE_PREFIX_KEY));
-            }
-            persistenceCapableTypes.addAll(entityTypesInPackage);
-        }
-        return persistenceCapableTypes;
-    }
-
-    private String lookupPackagePrefixes(final Map<String, String> configuration) {
-        final String packagePrefixes = configuration.get(PACKAGE_PREFIX_KEY);
-        if(Strings.isNullOrEmpty(packagePrefixes)) {
-            throw new IllegalArgumentException(String.format(
-                    "Could not locate '%s' key in property files - aborting",
-                    PACKAGE_PREFIX_KEY));
-        }
-        return packagePrefixes;
-    }
-
-    private static List<String> parseDomPackages(String packagePrefixes) {
-        return Collections.unmodifiableList(Lists.newArrayList(Iterables.transform(Splitter.on(",").split(packagePrefixes), trim())));
-    }
 
     private static boolean ignore(final Class<?> entityType) {
         try {
             if(entityType.isAnonymousClass() || entityType.isLocalClass() || entityType.isMemberClass() ||
-               entityType.isInterface()) {
+               entityType.isInterface() || entityType.isAnnotation()) {
                 return true;
             }
             final PersistenceCapable persistenceCapable = entityType.getAnnotation(PersistenceCapable.class);
@@ -140,20 +96,9 @@ public class RegisterEntities {
         }
     }
 
-    private static Function<String,String> trim() {
-        return new Function<String,String>(){
-            @Override
-            public String apply(String input) {
-                return input.trim();
-            }
-        };
-    }
-
-    // //////////////////////////////////////
 
     SpecificationLoader getSpecificationLoader() {
         return specificationLoader;
     }
 
-
 }

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.

[isis] 03/04: ISIS-1871 ISIS-1755 let CDI ignore beans as specified

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 7e409ca00e07c632f645035bc1e160d2fb79cd07
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Feb 23 10:47:39 2018 +0100

    ISIS-1871 ISIS-1755 let CDI ignore beans as specified
---
 .../webapp/jee/IsisCDIBeanScanInterceptor.java     | 102 +++++++++++++++++++++
 .../services/javax.enterprise.inject.spi.Extension |   1 +
 2 files changed, 103 insertions(+)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/webapp/jee/IsisCDIBeanScanInterceptor.java b/core/runtime/src/main/java/org/apache/isis/core/webapp/jee/IsisCDIBeanScanInterceptor.java
new file mode 100644
index 0000000..06fe4bf
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/webapp/jee/IsisCDIBeanScanInterceptor.java
@@ -0,0 +1,102 @@
+/*
+ * 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.webapp.jee;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Predicate;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
+import org.apache.isis.applib.services.metrics.MetricsService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * A CDI inject extension @see <a href="https://docs.jboss.org/weld/reference/latest/en-US/html/extend.html">weld</a>,
+ * that lets CDI ignore certain Beans we declare tabu. 
+ * <p>
+ * This extension is registered as a service provider by creating a file named 
+ * {@code META-INF/services/javax.enterprise.inject.spi.Extension}, 
+ * which contains the name of this extension class.
+ * </p>
+ * 
+ * <p>
+ * Beans declared tabu are managed (meaning instantiation and dependency injection) 
+ * by Isis itself. All other Beans are allowed to be managed by CDI.
+ * </p>
+ * 
+ * @author ahuber@apache.org
+ *
+ */
+public final class IsisCDIBeanScanInterceptor implements Extension {
+	
+	private static final Logger log = LoggerFactory.getLogger(IsisCDIBeanScanInterceptor.class);
+
+	/**
+	 * Declaration of Beans that are managed by Isis and should be ignored by CDI. 
+	 * (in addition to those that have the @DomainService annotation)
+	 */
+	private static final List<Predicate<Class<?>>> tabu = new ArrayList<>();
+	{
+		tabu.add(MetricsService.class::equals);
+		tabu.add(ExceptionRecognizer.class::isAssignableFrom);
+	}
+	
+	void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
+		log.info("beginning the scanning process");
+	}
+
+	<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> event) {
+
+		final Class<?> clazz = event.getAnnotatedType().getJavaClass();
+		final String className = clazz.getName();
+		
+		if(isTabu(clazz, event)) {
+			log.debug("veto type: " + className);
+			event.veto();
+		} else {
+			log.debug("allowing type: " + className);
+		}
+	}
+
+	void afterBeanDiscovery(@Observes AfterBeanDiscovery event) {
+		log.info("finished the scanning process");
+	}
+	
+	// -- HELPER
+	
+	private boolean isTabu(Class<?> clazz, ProcessAnnotatedType<?> event) {
+		if(event.getAnnotatedType().isAnnotationPresent(DomainService.class))
+			return true;
+		for(Predicate<Class<?>> isTabu : tabu) {
+			if(isTabu.test(clazz))
+				return true;
+		}
+		return false;
+	}
+
+}
diff --git a/core/runtime/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/core/runtime/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
new file mode 100644
index 0000000..1be69b2
--- /dev/null
+++ b/core/runtime/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1 @@
+org.apache.isis.core.webapp.jee.IsisCDIBeanScanInterceptor
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.