@Override public String getNodeName() { return this.environment.get().getNodeName(); }
public void start(final StartContext context) throws StartException { JBossLocalTransactionProvider.Builder builder = JBossLocalTransactionProvider.builder(); builder.setExtendedJBossXATerminator(extendedJBossXATerminatorInjector.getValue()); builder.setTransactionManager(transactionManagerInjector.getValue().getTransactionManager()); builder.setTransactionSynchronizationRegistry(transactionManagerInjector.getValue().getTransactionSynchronizationRegistry()); builder.setXATerminator(transactionManagerInjector.getValue().getJbossXATerminator()); builder.setXAResourceRecoveryRegistry(xaResourceRecoveryRegistryInjector.getValue()); builder.setXARecoveryLogDirRelativeToPath(serverEnvironmentInjector.getValue().getServerDataDir().toPath()); final LocalTransactionContext transactionContext = this.context = new LocalTransactionContext(builder.build()); // TODO: replace this with per-CL settings for embedded use and to support remote UserTransaction doPrivileged((PrivilegedAction<Void>) () -> { LocalTransactionContext.getContextManager().setGlobalDefault(transactionContext); return null; }); // Install the void service required by capability org.wildfly.transactions.global-default-local-provider // so other capabilities that require it can start their services after this capability // has completed its work. context.getChildTarget().addService(LOCAL_PROVIDER_CAPABILITY.getCapabilityServiceName()) .setInstance(Service.NULL) .install(); }
/** * Collect a JDR report. */ public JdrReport collect() throws OperationFailedException { JdrRunner runner = new JdrRunner(true); serverEnvironment = serverEnvironmentValue.getValue(); runner.setJbossHomeDir(serverEnvironment.getHomeDir().getAbsolutePath()); runner.setReportLocationDir(serverEnvironment.getServerTempDir().getAbsolutePath()); runner.setControllerClient(controllerClient); runner.setHostControllerName(serverEnvironment.getHostControllerName()); runner.setServerName(serverEnvironment.getServerName()); return runner.collect(); }
ServerEnvironment getServerEnvironment() { Properties props = new Properties(); File home = new File("target/jbossas"); delete(home); home.mkdir(); props.put(ServerEnvironment.HOME_DIR, home.getAbsolutePath()); File standalone = new File(home, "standalone"); standalone.mkdir(); props.put(ServerEnvironment.SERVER_BASE_DIR, standalone.getAbsolutePath()); File configuration = new File(standalone, "configuration"); configuration.mkdir(); props.put(ServerEnvironment.SERVER_CONFIG_DIR, configuration.getAbsolutePath()); File xml = new File(configuration, "standalone.xml"); try { xml.createNewFile(); } catch (IOException e) { throw new RuntimeException(e); } props.put(ServerEnvironment.JBOSS_SERVER_DEFAULT_CONFIG, "standalone.xml"); return new ServerEnvironment(null, props, new HashMap<String, String>(), "standalone.xml", null, LaunchType.STANDALONE, runningModeControl.getRunningMode(), null); }
private ServerEnvironment createStandaloneServerEnvironment() { Properties props = new Properties(); File home = new File("target/jbossas"); delete(home); home.mkdir(); delay(10); props.put(ServerEnvironment.HOME_DIR, home.getAbsolutePath()); File standalone = new File(home, "standalone"); standalone.mkdir(); props.put(ServerEnvironment.SERVER_BASE_DIR, standalone.getAbsolutePath()); File configuration = new File(standalone, "configuration"); configuration.mkdir(); props.put(ServerEnvironment.SERVER_CONFIG_DIR, configuration.getAbsolutePath()); File xml = new File(configuration, "standalone.xml"); try { xml.createNewFile(); } catch (IOException e) { throw new RuntimeException(e); } props.put(ServerEnvironment.JBOSS_SERVER_DEFAULT_CONFIG, "standalone.xml"); ProductConfig pc = new ProductConfig("Test", Version.AS_VERSION, "main"); return new ServerEnvironment(null, props, new HashMap<String, String>(), "standalone.xml", null, LaunchType.STANDALONE, runningModeControl.getRunningMode(), pc, false); }
private OSGiMetaData getModuleMetadata(Module module) throws Exception { ModuleIdentifier identifier = module.getIdentifier(); ModuleClassLoader moduleClassLoader = module.getClassLoader(); Iterator<Resource> itres = moduleClassLoader.iterateResources("/META-INF", false); while (itres.hasNext()) { File homeDir = injectedServerEnvironment.getValue().getHomeDir(); Path modulesPath = fileSystem.getPath(homeDir.getAbsolutePath(), "modules", "system", "layers", "base"); FileInputStream input = new FileInputStream(entryFile); try { Properties props = new Properties(); props.load(input); return OSGiMetaDataBuilder.load(props); } finally {
private OSGiMetaData getModuleMetadata(Module module) throws IOException { URL manifestURL = module.getExportedResource(JarFile.MANIFEST_NAME); if (manifestURL != null) { InputStream input = manifestURL.openStream(); File homeDir = injectedServerEnvironment.getValue().getHomeDir(); final File modulesDir = new File(homeDir + File.separator + "modules"); final ModuleIdentifier identifier = module.getIdentifier(); FileInputStream input = new FileInputStream(entryFile); try { Properties props = new Properties(); props.load(input); return OSGiMetaDataBuilder.load(props); } finally {
final ProductConfig config = serverEnvironment.getProductConfig(); final String prettyVersion = config.getPrettyVersionString(); ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion); if (System.getSecurityManager() != null) { final StringBuilder b = new StringBuilder(8192); b.append(ServerLogger.ROOT_LOGGER.configuredSystemPropertiesLabel()); for (String property : new TreeSet<String>(properties.stringPropertyNames())) { String propVal = property.toLowerCase(Locale.getDefault()).contains("password") ? "<redacted>" : properties.getProperty(property, "<undefined>"); b.append("\n\t").append(property).append(" = ").append(propVal); final BootstrapListener bootstrapListener = new BootstrapListener(container, startTime, serviceTarget, futureContainer, prettyVersion, serverEnvironment.getServerTempDir()); bootstrapListener.getStabilityMonitor().addController(myController); if(serverEnvironment.useGit()) { GitContentRepository.addService(serviceTarget, serverEnvironment.getGitRepository(), serverEnvironment.getServerContentDir(), serverEnvironment.getServerTempDir()); } else { ContentRepository.Factory.addService(serviceTarget, serverEnvironment.getServerContentDir(), serverEnvironment.getServerTempDir()); RemoteFileRepositoryService.addService(serviceTarget, serverEnvironment.getServerContentDir(), serverEnvironment.getServerTempDir()); serviceTarget.addService(Services.JBOSS_PRODUCT_CONFIG_SERVICE, new ValueService<ProductConfig>(productConfigValue)) .setInitialMode(ServiceController.Mode.ACTIVE) .install();
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment(); final ProductConfig config = serverEnvironment.getProductConfig(); final String prettyVersion = config.getPrettyVersionString(); AS_ROOT_LOGGER.serverStarting(prettyVersion); if (CONFIG_LOGGER.isDebugEnabled()) { final StringBuilder b = new StringBuilder(8192); b.append(ServerMessages.MESSAGES.configuredSystemPropertiesLabel()); for (String property : new TreeSet<String>(properties.stringPropertyNames())) { b.append("\n\t").append(property).append(" = ").append(properties.getProperty(property, "<undefined>")); ContentRepository.Factory.addService(serviceTarget, serverEnvironment.getServerContentDir()); } else { RemoteFileRepositoryService.addService(serviceTarget, serverEnvironment.getServerContentDir()); serviceTarget.addService(Services.JBOSS_PRODUCT_CONFIG_SERVICE, new ValueService<ProductConfig>(productConfigValue)) .setInitialMode(ServiceController.Mode.ACTIVE) .install();
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment(); String prettyVersion = serverEnvironment.getProductConfig().getPrettyVersionString(); AS_ROOT_LOGGER.serverStarting(prettyVersion); if (CONFIG_LOGGER.isDebugEnabled()) { final StringBuilder b = new StringBuilder(8192); b.append(ServerMessages.MESSAGES.configuredSystemPropertiesLabel()); for (String property : new TreeSet<String>(properties.stringPropertyNames())) { b.append("\n\t").append(property).append(" = ").append(properties.getProperty(property, "<undefined>")); serviceTarget.addListener(ServiceListener.Inheritance.ALL, bootstrapListener); myController.addListener(bootstrapListener); ContentRepository.Factory.addService(serviceTarget, serverEnvironment.getServerContentDir()); } else { RemoteFileRepositoryService.addService(serviceTarget, serverEnvironment.getServerContentDir());
if (CommandLineConstants.VERSION.equals(arg) || CommandLineConstants.SHORT_VERSION.equals(arg) || CommandLineConstants.OLD_VERSION.equals(arg) || CommandLineConstants.OLD_SHORT_VERSION.equals(arg)) { productConfig = new ProductConfig(Module.getBootModuleLoader(), SecurityActions.getSystemProperty(ServerEnvironment.HOME_DIR), null); System.out.println(productConfig.getPrettyVersionString()); return null; } else if (CommandLineConstants.HELP.equals(arg) || CommandLineConstants.SHORT_HELP.equals(arg) || CommandLineConstants.OLD_HELP.equals(arg)) { value = arg.substring(idx + 1, arg.length()); systemProperties.setProperty(name, value); } else if (arg.startsWith(CommandLineConstants.PUBLIC_BIND_ADDRESS)) { systemProperties.setProperty(propertyName, value); } else if (arg.startsWith(CommandLineConstants.DEFAULT_MULTICAST_ADDRESS)) { systemProperties.setProperty(ServerEnvironment.JBOSS_DEFAULT_MULTICAST_ADDRESS, value); } else if (CommandLineConstants.ADMIN_ONLY.equals(arg)) { runningMode = RunningMode.ADMIN_ONLY; productConfig = new ProductConfig(Module.getBootModuleLoader(), SecurityActions.getSystemProperty(ServerEnvironment.HOME_DIR), systemProperties); return new ServerEnvironment(hostControllerName, systemProperties, systemEnvironment, serverConfig, initialServerConfig, launchType, runningMode, productConfig);
public ServerEnvironment determineEnvironment(Properties systemProperties, Map<String, String> systemEnvironment, ServerEnvironment.LaunchType launchType, long startTime) { ProductConfig productConfig = ProductConfig.fromKnownSlot(PRODUCT_SLOT, Module.getBootModuleLoader(), systemProperties); systemProperties.put(ServerEnvironment.SERVER_TEMP_DIR, tmpDir.getAbsolutePath()); ServerEnvironment serverEnvironment = new ServerEnvironment(null, systemProperties, systemEnvironment, null, null, launchType, RunningMode.NORMAL, productConfig, startTime, false, null, null, null); return serverEnvironment; }
if (CommandLineConstants.VERSION.equals(arg) || CommandLineConstants.SHORT_VERSION.equals(arg) || CommandLineConstants.OLD_VERSION.equals(arg) || CommandLineConstants.OLD_SHORT_VERSION.equals(arg)) { productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), null); STDOUT.println(productConfig.getPrettyVersionString()); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.NORMAL); } else if (CommandLineConstants.HELP.equals(arg) || CommandLineConstants.SHORT_HELP.equals(arg) || CommandLineConstants.OLD_HELP.equals(arg)) { value = arg.substring(idx + 1, arg.length()); systemProperties.setProperty(name, value); } else if (arg.startsWith(CommandLineConstants.PUBLIC_BIND_ADDRESS)) { systemProperties.setProperty(propertyName, value); } else if (arg.startsWith(CommandLineConstants.DEFAULT_MULTICAST_ADDRESS)) { value = fixPossibleIPv6URL(value); systemProperties.setProperty(ServerEnvironment.JBOSS_DEFAULT_MULTICAST_ADDRESS, value); } else if (CommandLineConstants.ADMIN_ONLY.equals(arg)) { if(startModeSet) { productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), systemProperties); return new ServerEnvironmentWrapper(new ServerEnvironment(hostControllerName, systemProperties, systemEnvironment, serverConfig, configInteractionPolicy, launchType, runningMode, productConfig, startTime, startSuspended, gitRepository, gitBranch, gitAuthConfiguration));
public static ServiceController<?> addService(ServiceTarget serviceTarget, ServerPathManagerService service, ServerEnvironment serverEnvironment) { ServiceBuilder<?> serviceBuilder = serviceTarget.addService(SERVICE_NAME, service); // Add environment paths service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.HOME_DIR, serverEnvironment.getHomeDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.SERVER_BASE_DIR, serverEnvironment.getServerBaseDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.SERVER_CONFIG_DIR, serverEnvironment.getServerConfigurationDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.SERVER_DATA_DIR, serverEnvironment.getServerDataDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.SERVER_LOG_DIR, serverEnvironment.getServerLogDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.SERVER_TEMP_DIR, serverEnvironment.getServerTempDir().getAbsolutePath()); service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.CONTROLLER_TEMP_DIR, serverEnvironment.getControllerTempDir().getAbsolutePath()); // Add system paths service.addHardcodedAbsolutePath(serviceTarget, "user.dir", System.getProperty("user.dir")); service.addHardcodedAbsolutePath(serviceTarget, "user.home", System.getProperty("user.home")); service.addHardcodedAbsolutePath(serviceTarget, "java.home", System.getProperty("java.home")); // In the domain mode add a few more paths if(serverEnvironment.getLaunchType() == ServerEnvironment.LaunchType.DOMAIN) { if(serverEnvironment.getDomainBaseDir() != null) { service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.DOMAIN_BASE_DIR, serverEnvironment.getDomainBaseDir().getAbsolutePath()); } if(serverEnvironment.getDomainConfigurationDir() != null) { service.addHardcodedAbsolutePath(serviceTarget, ServerEnvironment.DOMAIN_CONFIG_DIR, serverEnvironment.getDomainConfigurationDir().getAbsolutePath()); } } return serviceBuilder.install(); }
final HttpManagementService service = new HttpManagementService(consoleMode, environment.getProductConfig().getConsoleSlot()); ServiceBuilder<HttpManagement> builder = serviceTarget.addService(HttpManagementService.SERVICE_NAME, service) .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector()) .addDependency(SocketBindingManagerImpl.SOCKET_BINDING_MANAGER, SocketBindingManager.class, service.getSocketBindingManagerInjector()) .addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, service.getControlledProcessStateServiceInjector()) .addInjection(service.getExecutorServiceInjector(), Executors.newCachedThreadPool(new JBossThreadFactory(new ThreadGroup("HttpManagementService-threads"), Boolean.FALSE, null, "%G - %t", null, null, AccessController.getContext())));
final UndertowHttpManagementService undertowService = new UndertowHttpManagementService(consoleMode, environment.getProductConfig().getConsoleSlot()); undertowService.getAllowedOriginsInjector().inject(commonPolicy.getAllowedOrigins()); CapabilityServiceBuilder<HttpManagement> undertowBuilder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY, undertowService).addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, undertowService.getModelControllerInjector()) final ServiceName shutdownName = UndertowHttpManagementService.SERVICE_NAME.append("shutdown"); final ServiceBuilder sb = serviceTarget.addService(shutdownName, shutdownService); sb.addDependency(requestProcessorName, ManagementHttpRequestProcessor.class, shutdownService.getProcessorValue()); sb.addDependency(Services.JBOSS_SERVER_EXECUTOR, Executor.class, shutdownService.getExecutorValue()); sb.addDependency(ManagementChannelRegistryService.SERVICE_NAME, ManagementChannelRegistryService.class, shutdownService.getMgmtChannelRegistry()); sb.requires(UndertowHttpManagementService.SERVICE_NAME); sb.install();
ClassLoader oldTccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(module.getClassLoader()); DeploymentInfo deploymentInfo = createServletConfig(); deploymentInfo.setServerName(serverEnvironmentInjectedValue.getValue().getProductConfig().getPrettyVersionString()); if (undertowService.getValue().isStatisticsEnabled()) { deploymentInfo.setMetricsCollector(new UndertowMetricsCollector());
@Override public AsyncFuture<ServiceContainer> run(final List<ServiceActivator> runServices) { final Bootstrap bootstrap = Bootstrap.Factory.newInstance(); final ProductConfig productConfig = new ProductConfig(Module.getBootModuleLoader(), home, properties); final ServerEnvironment providedEnvironment = new ServerEnvironment(hostControllerName, properties,
@Override public AsyncFuture<ServiceContainer> run(final List<ServiceActivator> runServices) { final Bootstrap bootstrap = Bootstrap.Factory.newInstance(); final ProductConfig productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), home, properties); final ServerEnvironment providedEnvironment = new ServerEnvironment(hostControllerName, properties, WildFlySecurityManager.getSystemEnvironmentPrivileged(), null, null, ServerEnvironment.LaunchType.DOMAIN, RunningMode.NORMAL, productConfig, Module.getStartTime(), suspend, null, null, null); DomainServerCommunicationServices.updateOperationID(initialOperationID);
@Override public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvironment serverEnvironment, ExecutorService executorService) { ConfigurationFile configurationFile = serverEnvironment.getServerConfigurationFile(); if (runningModeControl.isReloaded()) { configurationFile.resetBootFile(runningModeControl.isUseCurrentConfig(), runningModeControl.getAndClearNewBootFileName()); } QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server"); StandaloneXml parser = new StandaloneXml(Module.getBootModuleLoader(), executorService, extensionRegistry); XmlConfigurationPersister persister; if (configurationFile.useGit()) { persister = new GitConfigurationPersister(serverEnvironment.getGitRepository(), configurationFile, rootElement, parser, parser, runningModeControl.isReloaded()); } else { persister = new BackupXmlConfigurationPersister(configurationFile, rootElement, parser, parser, runningModeControl.isReloaded(), serverEnvironment.getLaunchType() == ServerEnvironment.LaunchType.EMBEDDED); } for (Namespace namespace : Namespace.domainValues()) { if (!namespace.equals(Namespace.CURRENT)) { persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "server"), parser); } } extensionRegistry.setWriterRegistry(persister); return persister; } };