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
private final void processInjectionPoint(@Observes final ProcessInjectionPoint<?, ?> event) { | |
if (event != null) { | |
final InjectionPoint ip = event.getInjectionPoint(); | |
assert ip != null; | |
final Set<Annotation> existingQualifiers = ip.getQualifiers(); | |
if (existingQualifiers != null && !existingQualifiers.isEmpty()) { | |
final Set<Annotation> newQualifiers = new HashSet<>(); | |
existingQualifiers.stream().forEach((qualifier) -> { | |
assert qualifier != null; | |
if (qualifier instanceof Key) { |
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
private static final class PropertyLiteral extends AnnotationLiteral<Property> implements Property { | |
private static final long serialVersionUID = 1L; | |
private final String value; | |
private PropertyLiteral() { | |
this(""); | |
} | |
private PropertyLiteral(final String value) { | |
super(); |
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
@Produces | |
@Dependent | |
@Property | |
private static final Object produceProperty(final InjectionPoint injectionPoint, final BigCoConfigurationEngine config) { | |
Objects.requireNonNull(config); | |
Object returnValue = null; | |
if (injectionPoint == null) { | |
// This is a case that really shouldn't happen. | |
return null; // ok to do with Dependent scope | |
} else { |
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
private final void installConfigurationValueProducerMethods(@Observes final AfterBeanDiscovery event, final BeanManager beanManager) { | |
if (event != null && beanManager != null) { | |
final Instance<Object> i = beanManager.createInstance(); | |
assert i != null; | |
final Instance<Configurations> configurationsInstance = i.select(Configurations.class); | |
assert configurationsInstance != null; | |
if (configurationsInstance.isResolvable()) { | |
final Configurations configurations = configurationsInstance.get(); | |
assert configurations != null; | |
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
// Note: no @Produces! | |
@ConfigurationValue | |
@Dependent | |
private static final Object produceConfigurationValue(final InjectionPoint injectionPoint, final Configurations configurations) { | |
Objects.requireNonNull(injectionPoint); | |
Objects.requireNonNull(configurations); | |
final String name = getConfigurationPropertyName(injectionPoint); | |
assert name != null; | |
return configurations.getValue(name, injectionPoint.getType()); // let's say this causes conversion | |
} |
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
// ConfigurationsExtension is our Extension class within which all this activity is taking place. | |
final AnnotatedType<ConfigurationsExtension> thisType = beanManager.createAnnotatedType(ConfigurationsExtension.class); | |
final AnnotatedMethod<? super ConfigurationsExtension> producerMethod = thisType.getMethods().stream() | |
.filter(m -> m.getJavaMember().getName().equals("produceConfigurationValue")) | |
.findFirst() | |
.get(); | |
final BeanAttributes<?> producerAttributes = beanManager.createBeanAttributes(producerMethod); |
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
public class DelegatingBeanAttributes<T> implements BeanAttributes<T> { | |
private final BeanAttributes<?> delegate; | |
public DelegatingBeanAttributes(final BeanAttributes<?> delegate) { | |
super(); | |
Objects.requireNonNull(delegate); | |
this.delegate = delegate; | |
} |
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
private final void installConfigurationValueProducerMethods(@Observes final AfterBeanDiscovery event, final BeanManager beanManager) { | |
if (event != null && beanManager != null) { | |
// Get a Configurations object. | |
final Instance<Object> i = beanManager.createInstance(); | |
assert i != null; | |
final Instance<Configurations> configurationsInstance = i.select(Configurations.class); | |
assert configurationsInstance != null; | |
if (configurationsInstance.isResolvable()) { | |
final Configurations configurations = configurationsInstance.get(); |
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
private final CountDownLatch latch; | |
private final Collection<HttpServer> startedHttpServers; | |
public HttpServerStartingExtension() { | |
super(); | |
this.startedHttpServers = new LinkedList<>(); | |
this.latch = new CountDownLatch(1); | |
Runtime.getRuntime().addShutdownHook(new Thread(() -> { | |
latch.countDown(); |
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
private final void startHttpServers(@Observes @Initialized(ApplicationScoped.class) @Priority(LIBRARY_AFTER) final Object event, final BeanManager beanManager) throws IOException, InterruptedException { | |
if (beanManager != null) { | |
final Instance<Object> beans = beanManager.createInstance(); | |
assert beans != null; | |
final Instance<HttpServer> httpServers = beans.select(HttpServer.class); | |
assert httpServers != null; | |
if (!httpServers.isUnsatisfied()) { | |
synchronized (this.startedHttpServers) { | |
for (final HttpServer httpServer : httpServers) { | |
if (httpServer != null) { |