use of org.wildfly.swarm.container.runtime.cdi.DeploymentContextImpl in project wildfly-swarm by wildfly-swarm.
the class ConfigurableManagerTest method testDeploymentConfigurableUsingAlias.
@Test
public void testDeploymentConfigurableUsingAlias() throws Exception {
Properties props = new Properties();
Map<String, String> env = new HashMap<>();
ConfigViewFactory factory = new ConfigViewFactory(props, env);
factory.withProperty("swarm.http.context", "/myapp");
ConfigView configView = factory.get(true);
DeploymentContext context = new DeploymentContextImpl();
ConfigurableManager manager = new ConfigurableManager(configView, context);
Archive archive = ShrinkWrap.create(JavaArchive.class, "myapp.war");
try {
context.activate(archive, archive.getName(), false);
Component component = new Component();
manager.scan(component);
assertThat(component.context.get()).isEqualTo("/myapp");
} finally {
context.deactivate();
}
}
use of org.wildfly.swarm.container.runtime.cdi.DeploymentContextImpl in project wildfly-swarm by wildfly-swarm.
the class ConfigurableManagerTest method testDeploymentConfigurable.
@Test
public void testDeploymentConfigurable() throws Exception {
Properties props = new Properties();
Map<String, String> env = new HashMap<>();
ConfigViewFactory factory = new ConfigViewFactory(props, env);
factory.withProperty("swarm.deployment.[myapp.war].context", "/myapp");
ConfigView configView = factory.get(true);
DeploymentContext context = new DeploymentContextImpl();
ConfigurableManager manager = new ConfigurableManager(configView, context);
Archive archive = ShrinkWrap.create(JavaArchive.class, "myapp.war");
try {
context.activate(archive, archive.getName(), false);
Component component = new Component();
manager.scan(component);
assertThat(component.context.get()).isEqualTo("/myapp");
} finally {
context.deactivate();
}
}
use of org.wildfly.swarm.container.runtime.cdi.DeploymentContextImpl in project wildfly-swarm by wildfly-swarm.
the class ServerBootstrapImpl method bootstrap.
@Override
public Server bootstrap() throws Exception {
try (AutoCloseable bootstrap = Performance.time("Bootstrap")) {
Module module = Module.getBootModuleLoader().loadModule("swarm.container");
return ClassLoading.withTCCL(new ExtensionPreventionClassLoaderWrapper(module.getClassLoader()), () -> {
try (AutoCloseable logFractionHandle = Performance.time("Log fractions")) {
logFractions();
}
RuntimeServer outerServer = LogSilencer.silently("org.jboss.weld", "ServiceLoader").execute(() -> {
Weld weld = new Weld(WELD_INSTANCE_ID);
weld.setClassLoader(module.getClassLoader());
ConfigViewProducingExtension configViewProducingExtension = new ConfigViewProducingExtension(this.configView);
DeploymentContext deploymentContext = new DeploymentContextImpl();
ConfigurableManager configurableManager = new ConfigurableManager(this.configView, deploymentContext);
// Add Extension that adds User custom bits into configurator
weld.addExtension(new FractionProducingExtension(explicitlyInstalledFractions, configurableManager));
weld.addExtension(new ConfigurableExtension(configurableManager));
weld.addExtension(new CommandLineArgsExtension(args));
weld.addExtension(configViewProducingExtension);
weld.addExtension(new XMLConfigProducingExtension(this.xmlConfigURL));
weld.addExtension(new InterfaceExtension(this.configView));
weld.addExtension(new OutboundSocketBindingExtension(this.outboundSocketBindings));
weld.addExtension(new SocketBindingExtension(this.socketBindings));
weld.addExtension(new DeploymentScopedExtension(deploymentContext));
weld.addExtension(new ImplicitArchiveExtension());
for (Class<?> each : this.userComponents) {
weld.addBeanClass(each);
}
weld.property("org.jboss.weld.se.shutdownHook", false);
WeldContainer weldContainer = null;
RuntimeServer server = null;
try (AutoCloseable weldRelated = Performance.time("Weld-related")) {
try (AutoCloseable weldInitHandle = Performance.time("Weld initialize")) {
weldContainer = weld.initialize();
}
try (AutoCloseable serverSelectHandle = Performance.time("Server construction")) {
server = weldContainer.select(RuntimeServer.class).get();
}
}
return server;
});
try (AutoCloseable weldInitHandle = Performance.time("Server start")) {
outerServer.start(true);
}
return outerServer;
});
} finally {
SwarmMetricsMessages.MESSAGES.bootPerformance(Performance.dump());
}
}
use of org.wildfly.swarm.container.runtime.cdi.DeploymentContextImpl in project wildfly-swarm by wildfly-swarm.
the class ConfigurableManagerTest method testDeploymentConfigurableUsingBoth.
@Test
public void testDeploymentConfigurableUsingBoth() throws Exception {
Properties props = new Properties();
Map<String, String> env = new HashMap<>();
ConfigViewFactory factory = new ConfigViewFactory(props, env);
factory.withProperty("swarm.deployment.[myapp.war].context", "/my-specific-app");
factory.withProperty("swarm.http.context", "/my-alias-app");
ConfigView configView = factory.get(true);
DeploymentContext context = new DeploymentContextImpl();
ConfigurableManager manager = new ConfigurableManager(configView, context);
Archive archive = ShrinkWrap.create(JavaArchive.class, "myapp.war");
try {
context.activate(archive, archive.getName(), false);
Component component = new Component();
manager.scan(component);
assertThat(component.context.get()).isEqualTo("/my-specific-app");
} finally {
context.deactivate();
}
Archive archiveToo = ShrinkWrap.create(JavaArchive.class, "otherapp.war");
try {
context.activate(archiveToo, archiveToo.getName(), false);
Component component = new Component();
manager.scan(component);
assertThat(component.context.get()).isEqualTo("/my-alias-app");
} finally {
context.deactivate();
}
}
Aggregations