-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved proxy bean to top level class, so it does not drag WeldFeature …
…to native image. (#2906)
- Loading branch information
1 parent
9b67ec7
commit 6bda22b
Showing
2 changed files
with
100 additions
and
77 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
...nsion/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/ProxyBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters