GERONIMO-6756 ensure no actual beans are in the extension to support more environments
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigBean.java b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigBean.java
new file mode 100644
index 0000000..341025e
--- /dev/null
+++ b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigBean.java
@@ -0,0 +1,111 @@
+/*
+ * 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.geronimo.config.cdi;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptySet;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import org.eclipse.microprofile.config.Config;
+
+public class ConfigBean implements Bean<Config>, PassivationCapable {
+    private final Set<Type> types;
+    private final Set<Annotation> qualifiers;
+    private final String id;
+    private Config config;
+
+    ConfigBean() {
+        this.qualifiers = new HashSet<>(asList(DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE));
+        this.types = new HashSet<>(asList(Config.class, Serializable.class));
+        this.id = ConfigBean.class.getName() + "[" + Config.class.getName() + "]";
+    }
+
+    void init(final Config config) {
+        this.config = config;
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return emptySet();
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return Config.class;
+    }
+
+    @Override
+    public boolean isNullable() {
+        return false;
+    }
+
+    @Override
+    public Config create(final CreationalContext<Config> context) {
+        return config;
+    }
+
+    @Override
+    public void destroy(final Config instance, final CreationalContext<Config> context) {
+        // no-op
+    }
+
+    @Override
+    public Set<Type> getTypes() {
+        return types;
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return ApplicationScoped.class;
+    }
+
+    @Override
+    public String getName() {
+        return null;
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes() {
+        return emptySet();
+    }
+
+    @Override
+    public boolean isAlternative() {
+        return false;
+    }
+
+    @Override
+    public String getId() {
+        return id;
+    }
+}
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
index 8870ff0..7f06f17 100644
--- a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
+++ b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
@@ -71,7 +71,12 @@
     private Set<Class<?>> proxies = new HashSet<>();
     private List<Class<?>> validProxies;
     private List<ProxyBean<?>> proxyBeans;
+    private boolean hasConfigProxy;
+    private ConfigBean configBean;
 
+    public ConfigExtension() {
+        config = ConfigProvider.getConfig(); // ensure to store the ref the whole lifecycle, java gc is aggressive now
+    }
 
     public void findProxies(@Observes ProcessAnnotatedType<?> pat) {
         final Class<?> javaClass = pat.getAnnotatedType().getJavaClass();
@@ -103,6 +108,11 @@
         types.addAll(providerTypes);
 
         types.stream()
+                .peek(type -> {
+                    if (type == Config.class) {
+                        hasConfigProxy = true;
+                    }
+                })
                 .map(type -> new ConfigInjectionBean(bm, type))
                 .forEach(abd::addBean);
 
@@ -115,18 +125,24 @@
                                      .collect(toList());
             proxyBeans.forEach(abd::addBean);
         } // else there are errors
+
+        if (!hasConfigProxy) {
+            configBean = new ConfigBean();
+            abd.addBean(configBean);
+        }
     }
 
     public void validate(@Observes AfterDeploymentValidation add) {
         List<String> deploymentProblems = new ArrayList<>();
 
-        config = ConfigProvider.getConfig();
-
         StreamSupport.stream(config.getConfigSources().spliterator(), false)
                      .filter(Reloadable.class::isInstance)
                      .map(Reloadable.class::cast)
                      .forEach(Reloadable::reload);
 
+        if (!hasConfigProxy) {
+            configBean.init(config);
+        }
         proxyBeans.forEach(b -> b.init(config));
         proxyBeans.clear();
 
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionProducer.java b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionProducer.java
deleted file mode 100644
index ce16e8e..0000000
--- a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionProducer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.geronimo.config.cdi;
-
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-
-import org.eclipse.microprofile.config.Config;
-import org.eclipse.microprofile.config.ConfigProvider;
-
-/**
- * @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
- */
-@ApplicationScoped
-public class ConfigInjectionProducer {
-
-    private Config config;
-
-    @PostConstruct
-    void init() {
-        config = ConfigProvider.getConfig();
-    }
-
-    @Produces
-    @ApplicationScoped
-    public Config createConfig() {
-        return config;
-    }
-
-
-}
diff --git a/impl/src/test/java/org/apache/geronimo/config/test/GeronimoConfigArchiveProcessor.java b/impl/src/test/java/org/apache/geronimo/config/test/GeronimoConfigArchiveProcessor.java
index 7316c01..dd18b15 100644
--- a/impl/src/test/java/org/apache/geronimo/config/test/GeronimoConfigArchiveProcessor.java
+++ b/impl/src/test/java/org/apache/geronimo/config/test/GeronimoConfigArchiveProcessor.java
@@ -18,7 +18,7 @@
 
 import org.apache.geronimo.config.ConfigImpl;
 import org.apache.geronimo.config.DefaultConfigProvider;
-import org.apache.geronimo.config.cdi.ConfigInjectionProducer;
+import org.apache.geronimo.config.cdi.ConfigExtension;
 import org.apache.geronimo.config.configsource.BaseConfigSource;
 import org.apache.geronimo.config.converters.BooleanConverter;
 import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
@@ -47,7 +47,7 @@
                     .addPackage(ConfigImpl.class.getPackage())
                     .addPackage(BooleanConverter.class.getPackage())
                     .addPackage(BaseConfigSource.class.getPackage())
-                    .addPackage(ConfigInjectionProducer.class.getPackage())
+                    .addPackage(ConfigExtension.class.getPackage())
                     .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
                     .addAsServiceProvider(ConfigProviderResolver.class, DefaultConfigProvider.class);
             ((WebArchive) applicationArchive).addAsLibraries(configJar);