Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weld feature disconnected from runtime. #2906

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<Object> {
// 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<Type> types;

ProxyBean(Class<?> beanClass, Set<Type> types) {
this.beanClass = beanClass;

this.types = types;
}

@Override
public Class<?> getBeanClass() {
return beanClass;
}

@Override
public Set<InjectionPoint> getInjectionPoints() {
return Collections.emptySet();
}

@Override
public boolean isNullable() {
return false;
}

@Override
public Object create(CreationalContext<Object> creationalContext) {
throw new IllegalStateException("This bean should not be created");
}

@Override
public void destroy(Object instance, CreationalContext<Object> creationalContext) {
}

@Override
public Set<Type> getTypes() {
return types;
}

@Override
public Set<Annotation> getQualifiers() {
return Set.of(Any.Literal.INSTANCE, Default.Literal.INSTANCE);
}

@Override
public Class<? extends Annotation> getScope() {
return ApplicationScoped.class;
}

@Override
public String getName() {
return beanClass.getName();
}

@Override
public Set<Class<? extends Annotation>> getStereotypes() {
return Collections.emptySet();
}

@Override
public boolean isAlternative() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -227,76 +221,6 @@ static List<WeldProxyConfig> weldProxyConfigurations(DuringSetupAccess access) {
}
}

/**
* Proxy used to initialize Weld.
*/
static final class ProxyBean implements Bean<Object> {
// 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<Type> types;

ProxyBean(Class<?> beanClass, Set<Type> types) {
this.beanClass = beanClass;

this.types = types;
}

@Override
public Class<?> getBeanClass() {
return beanClass;
}

@Override
public Set<InjectionPoint> getInjectionPoints() {
return Collections.emptySet();
}

@Override
public boolean isNullable() {
return false;
}

@Override
public Object create(CreationalContext<Object> creationalContext) {
throw new IllegalStateException("This bean should not be created");
}

@Override
public void destroy(Object instance, CreationalContext<Object> creationalContext) {
}

@Override
public Set<Type> getTypes() {
return types;
}

@Override
public Set<Annotation> getQualifiers() {
return Set.of(Any.Literal.INSTANCE, Default.Literal.INSTANCE);
}

@Override
public Class<? extends Annotation> getScope() {
return ApplicationScoped.class;
}

@Override
public String getName() {
return beanClass.getName();
}

@Override
public Set<Class<? extends Annotation>> getStereotypes() {
return Collections.emptySet();
}

@Override
public boolean isAlternative() {
return false;
}
}

private static class WeldProxyConfig {
// bean class
private final String beanClass;
Expand Down