diff --git a/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/ProxyBean.java b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/ProxyBean.java new file mode 100644 index 00000000000..ab90d2256a8 --- /dev/null +++ b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/ProxyBean.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * Licensed 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 io.helidon.integrations.graal.mp.nativeimage.extension; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.util.Collections; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.Any; +import javax.enterprise.inject.Default; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.InjectionPoint; + +/** + * Proxy used to initialize Weld. + * This class is a top level class so it does not add WeldFeature to the image. + */ +final class ProxyBean implements Bean { + // this is the bean class (producer class, or the type itself for managed beans) + private final Class beanClass; + // the types of the produced bean (or + private final Set types; + + ProxyBean(Class beanClass, Set types) { + this.beanClass = beanClass; + + this.types = types; + } + + @Override + public Class getBeanClass() { + return beanClass; + } + + @Override + public Set getInjectionPoints() { + return Collections.emptySet(); + } + + @Override + public boolean isNullable() { + return false; + } + + @Override + public Object create(CreationalContext creationalContext) { + throw new IllegalStateException("This bean should not be created"); + } + + @Override + public void destroy(Object instance, CreationalContext creationalContext) { + } + + @Override + public Set getTypes() { + return types; + } + + @Override + public Set getQualifiers() { + return Set.of(Any.Literal.INSTANCE, Default.Literal.INSTANCE); + } + + @Override + public Class getScope() { + return ApplicationScoped.class; + } + + @Override + public String getName() { + return beanClass.getName(); + } + + @Override + public Set> getStereotypes() { + return Collections.emptySet(); + } + + @Override + public boolean isAlternative() { + return false; + } +} diff --git a/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java index 98fe6f35508..96afed6bab2 100644 --- a/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java +++ b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. + * Copyright (c) 2019, 2021 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package io.helidon.integrations.graal.mp.nativeimage.extension; import java.io.IOException; -import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.net.URL; import java.util.ArrayList; @@ -32,12 +31,7 @@ import java.util.Set; import java.util.function.Supplier; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.inject.Any; -import javax.enterprise.inject.Default; import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.InjectionPoint; import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonObject; @@ -227,76 +221,6 @@ static List weldProxyConfigurations(DuringSetupAccess access) { } } - /** - * Proxy used to initialize Weld. - */ - static final class ProxyBean implements Bean { - // this is the bean class (producer class, or the type itself for managed beans) - private final Class beanClass; - // the types of the produced bean (or - private final Set types; - - ProxyBean(Class beanClass, Set types) { - this.beanClass = beanClass; - - this.types = types; - } - - @Override - public Class getBeanClass() { - return beanClass; - } - - @Override - public Set getInjectionPoints() { - return Collections.emptySet(); - } - - @Override - public boolean isNullable() { - return false; - } - - @Override - public Object create(CreationalContext creationalContext) { - throw new IllegalStateException("This bean should not be created"); - } - - @Override - public void destroy(Object instance, CreationalContext creationalContext) { - } - - @Override - public Set getTypes() { - return types; - } - - @Override - public Set getQualifiers() { - return Set.of(Any.Literal.INSTANCE, Default.Literal.INSTANCE); - } - - @Override - public Class getScope() { - return ApplicationScoped.class; - } - - @Override - public String getName() { - return beanClass.getName(); - } - - @Override - public Set> getStereotypes() { - return Collections.emptySet(); - } - - @Override - public boolean isAlternative() { - return false; - } - } - private static class WeldProxyConfig { // bean class private final String beanClass;