Search in sources :

Example 6 with SimpleKey

use of org.wildfly.swarm.spi.api.config.SimpleKey in project wildfly-swarm by wildfly-swarm.

the class NetworkConfigurer method fixOutboundSocketBindings.

protected void fixOutboundSocketBindings(SocketBindingGroup group) {
    ConfigKey key = ROOT.append(group.name()).append("outbound-socket-bindings");
    List<SimpleKey> names = this.configView.simpleSubkeys(key);
    names.stream().map(e -> e.name()).map(name -> group.outboundSocketBindings().stream().filter(e -> e.name().equals(name)).findFirst().orElseGet(() -> {
        OutboundSocketBinding binding = new OutboundSocketBinding(name);
        group.outboundSocketBinding(binding);
        return binding;
    })).forEach(e -> {
        applyConfiguration(key, e);
    });
}
Also used : SocketBinding(org.wildfly.swarm.spi.api.SocketBinding) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) Consumer(java.util.function.Consumer) Inject(javax.inject.Inject) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) List(java.util.List) Interface(org.wildfly.swarm.container.Interface) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Any(javax.enterprise.inject.Any) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Instance(javax.enterprise.inject.Instance) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey)

Example 7 with SimpleKey

use of org.wildfly.swarm.spi.api.config.SimpleKey in project wildfly-swarm by wildfly-swarm.

the class InterfaceExtension method afterBeanDiscovery.

@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
    List<SimpleKey> configuredInterfaces = this.configView.simpleSubkeys(ROOT);
    for (SimpleKey interfaceName : configuredInterfaces) {
        Set<Bean<?>> ifaces = beanManager.getBeans(Interface.class, AnyLiteral.INSTANCE);
        if (ifaces.stream().noneMatch(e -> e.getQualifiers().stream().anyMatch(anno -> anno instanceof Named && ((Named) anno).value().equals(interfaceName + "-interface")))) {
            Interface iface = new Interface(interfaceName.name(), "0.0.0.0");
            applyConfiguration(iface);
            CommonBean<Interface> interfaceBean = CommonBeanBuilder.newBuilder(Interface.class).beanClass(InterfaceExtension.class).scope(ApplicationScoped.class).addQualifier(AnyLiteral.INSTANCE).addQualifier(new NamedLiteral(interfaceName.name() + "-interface")).createSupplier(() -> iface).addType(Interface.class).addType(Object.class).build();
            abd.addBean(interfaceBean);
        }
    }
}
Also used : AfterBeanDiscovery(javax.enterprise.inject.spi.AfterBeanDiscovery) Set(java.util.Set) AnyLiteral(org.jboss.weld.literal.AnyLiteral) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) List(java.util.List) Interface(org.wildfly.swarm.container.Interface) CommonBean(org.wildfly.swarm.spi.api.cdi.CommonBean) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) Observes(javax.enterprise.event.Observes) NamedLiteral(org.jboss.weld.literal.NamedLiteral) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Named(javax.inject.Named) ConfigView(org.wildfly.swarm.spi.api.config.ConfigView) Bean(javax.enterprise.inject.spi.Bean) BeanManager(javax.enterprise.inject.spi.BeanManager) CommonBeanBuilder(org.wildfly.swarm.spi.api.cdi.CommonBeanBuilder) Named(javax.inject.Named) NamedLiteral(org.jboss.weld.literal.NamedLiteral) Interface(org.wildfly.swarm.container.Interface) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey) CommonBean(org.wildfly.swarm.spi.api.cdi.CommonBean) Bean(javax.enterprise.inject.spi.Bean)

Example 8 with SimpleKey

use of org.wildfly.swarm.spi.api.config.SimpleKey in project wildfly-swarm by wildfly-swarm.

the class ArtifactDeployer method deploy.

public void deploy() throws Exception {
    List<SimpleKey> subkeys = configView.simpleSubkeys(ConfigKey.of("swarm", "deployment"));
    for (SimpleKey subkey : subkeys) {
        String spec = subkey.name();
        if (spec.contains(":")) {
            String[] parts = spec.split(":");
            String groupId = parts[0];
            parts = parts[1].split("\\.");
            String artifactId = parts[0];
            String packaging = parts[1];
            JavaArchive artifact = Swarm.artifact(groupId + ":" + artifactId + ":" + packaging + ":*", artifactId + "." + packaging);
            deployer.get().deploy(artifact, spec);
        }
    }
}
Also used : JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey)

Example 9 with SimpleKey

use of org.wildfly.swarm.spi.api.config.SimpleKey in project wildfly-swarm by wildfly-swarm.

the class ConfigNode method recursiveChild.

/**
 * Set the value of a descendant.
 *
 * <p>Any intermediate leafs will be created as-needed.</p>
 *
 * @param key   The possibly-complex key to a descendant.
 * @param value The value to set.
 */
public void recursiveChild(ConfigKey key, Object value) {
    SimpleKey head = key.head();
    if (head == ConfigKey.EMPTY) {
        value(value);
    }
    ConfigKey rest = key.subkey(1);
    if (rest == ConfigKey.EMPTY) {
        child(head, value);
    } else {
        ConfigNode child = child(head);
        if (child == null) {
            child = new ConfigNode();
            child(head, child);
        }
        child.recursiveChild(rest, value);
    }
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey)

Example 10 with SimpleKey

use of org.wildfly.swarm.spi.api.config.SimpleKey in project wildfly-swarm by wildfly-swarm.

the class ConfigNode method descendant.

ConfigNode descendant(ConfigKey key) {
    SimpleKey head = key.head();
    if (head == ConfigKey.EMPTY) {
        return this;
    }
    ConfigKey rest = key.subkey(1);
    ConfigNode child = child(head);
    if (child == null) {
        return null;
    }
    return child.descendant(rest);
}
Also used : ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) SimpleKey(org.wildfly.swarm.spi.api.config.SimpleKey)

Aggregations

SimpleKey (org.wildfly.swarm.spi.api.config.SimpleKey)18 ConfigKey (org.wildfly.swarm.spi.api.config.ConfigKey)10 List (java.util.List)6 Test (org.junit.Test)6 ConfigView (org.wildfly.swarm.spi.api.config.ConfigView)5 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 AfterBeanDiscovery (javax.enterprise.inject.spi.AfterBeanDiscovery)3 BeanManager (javax.enterprise.inject.spi.BeanManager)3 Interface (org.wildfly.swarm.container.Interface)3 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)3 CommonBean (org.wildfly.swarm.spi.api.cdi.CommonBean)3 Field (java.lang.reflect.Field)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 Consumer (java.util.function.Consumer)2 Observes (javax.enterprise.event.Observes)2 Any (javax.enterprise.inject.Any)2 Instance (javax.enterprise.inject.Instance)2 Bean (javax.enterprise.inject.spi.Bean)2