本文整理汇总了Java中org.jboss.as.server.ServerEnvironment类的典型用法代码示例。如果您正苦于以下问题:Java ServerEnvironment类的具体用法?Java ServerEnvironment怎么用?Java ServerEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerEnvironment类属于org.jboss.as.server包,在下文中一共展示了ServerEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
ServiceTarget target = serviceActivatorContext.getServiceTarget();
MetricsService service = new MetricsService();
ServiceBuilder<MetricsService> metricsServiceBuilder = target.addService(MetricsService.SERVICE_NAME, service);
RegistryFactory factory = new RegistryFactoryImpl();
ServiceBuilder<MetricsService> serviceBuilder = metricsServiceBuilder
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector())
.addDependency(ServiceName.parse("jboss.eclipse.microprofile.config.config-provider"))
.addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector());
serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
BinderService binderService = new BinderService(SWARM_MP_METRICS, null, true);
target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, SWARM_MP_METRICS), binderService)
.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(factory))
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}
示例2: getServerEnvironment
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
public 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<>(), "standalone.xml", null, LaunchType.STANDALONE, runningModeControl.getRunningMode(), null);
}
示例3: createStandaloneServerEnvironment
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
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");
return new ServerEnvironment(null, props, new HashMap<String, String>(), "standalone.xml", null, LaunchType.STANDALONE, runningModeControl.getRunningMode(), null);
}
示例4: testDataAndConfigOverride
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Test
public void testDataAndConfigOverride() throws Exception {
Properties props = new Properties();
props.setProperty(EmbeddedStandaloneServerFactory.JBOSS_EMBEDDED_ROOT, embeddedRoot.toAbsolutePath().toString());
props.setProperty(ServerEnvironment.SERVER_DATA_DIR, alternativeDataDir.toAbsolutePath().toString());
props.setProperty(ServerEnvironment.SERVER_CONFIG_DIR, alternativeConfigDir.toAbsolutePath().toString());
EmbeddedStandaloneServerFactory.setupCleanDirectories(standardJBossHome, props);
Assert.assertEquals(4, props.size());
Assert.assertEquals(embeddedRoot.toAbsolutePath().toString(), props.getProperty(EmbeddedStandaloneServerFactory.JBOSS_EMBEDDED_ROOT));
assertPropertyAndEmbeddedRootFile(props, ServerEnvironment.SERVER_BASE_DIR, -1);
assertPropertyAndEmbeddedRootFile(props, ServerEnvironment.SERVER_DATA_DIR, 3);
assertPropertyAndEmbeddedRootFile(props, ServerEnvironment.SERVER_CONFIG_DIR, 4);
}
示例5: execute
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath();
List<File> logFiles;
try {
logFiles = findFiles(logDir, model);
} catch (IOException e) {
logFiles = Collections.emptyList();
LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir);
}
final SimpleDateFormat dateFormat = new SimpleDateFormat(LogFileResourceDefinition.ISO_8601_FORMAT);
final ModelNode result = context.getResult().setEmptyList();
for (File logFile : logFiles) {
final ModelNode fileInfo = new ModelNode();
fileInfo.get(FILE_NAME.getName()).set(logFile.getName());
fileInfo.get(FILE_SIZE.getName()).set(logFile.length());
fileInfo.get(LAST_MODIFIED_DATE.getName()).set(dateFormat.format(new Date(logFile.lastModified())));
result.add(fileInfo);
}
context.completeStep(ResultHandler.NOOP_RESULT_HANDLER);
}
示例6: execute
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
final ModelNode model = context.getResult();
final String name = LoggingOperations.getAddressName(operation);
final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath();
validateFile(context, logDir, name);
final Path path = Paths.get(logDir, name);
if (Files.notExists(path)) {
throw LoggingLogger.ROOT_LOGGER.logFileNotFound(name, logDir);
}
try {
updateModel(path, model);
} catch (IOException e) {
throw new RuntimeException(e);
}
context.completeStep(ResultHandler.NOOP_RESULT_HANDLER);
}
示例7: getChildrenNames
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Override
public Set<String> getChildrenNames(final String childType) {
if (LOG_FILE.equals(childType)) {
final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath();
try {
final Set<Path> validPaths = findFiles(logDir, getFileHandlersModel(), true);
final Set<String> result = new LinkedHashSet<>();
for (Path p : validPaths) {
result.add(p.toString());
}
return result;
} catch (IOException e) {
LoggingLogger.ROOT_LOGGER.errorProcessingLogDirectory(logDir);
}
}
return delegate.getChildrenNames(childType);
}
示例8: registerAttributes
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.LAUNCH_TYPE, (context,operation) -> {
readResourceServerConfig(context, operation);
context.getResult().set(ServerEnvironment.LaunchType.DOMAIN.toString());
});
resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.SERVER_STATE, (context, operation) -> {
readResourceServerConfig(context, operation);
// note this is inconsistent with the other values, should be lower case, preserved for now.
context.getResult().set("STOPPED");
});
resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.RUNTIME_CONFIGURATION_STATE,
(context, operation) -> {
readResourceServerConfig(context, operation);
context.getResult().set(ClientConstants.CONTROLLER_PROCESS_STATE_STOPPED);
}
);
}
示例9: registerCapabilities
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
@Override
public void registerCapabilities(ManagementResourceRegistration resourceRegistration) {
super.registerCapabilities(resourceRegistration);
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(HostControllerEnvironment.HOME_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(HostControllerEnvironment.DOMAIN_CONFIG_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(HostControllerEnvironment.DOMAIN_DATA_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(HostControllerEnvironment.DOMAIN_LOG_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(HostControllerEnvironment.DOMAIN_TEMP_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(HostControllerEnvironment.CONTROLLER_TEMP_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(ServerEnvironment.SERVER_BASE_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(ServerEnvironment.SERVER_CONFIG_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(ServerEnvironment.SERVER_DATA_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(ServerEnvironment.SERVER_LOG_DIR));
resourceRegistration.registerCapability(PATH_CAPABILITY.fromBaseCapability(ServerEnvironment.SERVER_TEMP_DIR));
}
示例10: addService
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
public static ServiceController<?> addService(ServiceTarget serviceTarget, HostPathManagerService service, HostControllerEnvironment hostEnvironment) {
ServiceBuilder<?> serviceBuilder = serviceTarget.addService(AbstractControllerService.PATH_MANAGER_CAPABILITY.getCapabilityServiceName(), service).addAliases(SERVICE_NAME);
// Add resources and capabilities for the always-present paths
service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.HOME_DIR, hostEnvironment.getHomeDir().getAbsolutePath());
service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_CONFIG_DIR, hostEnvironment.getDomainConfigurationDir().getAbsolutePath());
service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_DATA_DIR, hostEnvironment.getDomainDataDir().getAbsolutePath());
service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_LOG_DIR, hostEnvironment.getDomainLogDir().getAbsolutePath());
service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.DOMAIN_TEMP_DIR, hostEnvironment.getDomainTempDir().getAbsolutePath());
service.addHardcodedAbsolutePath(serviceTarget, HostControllerEnvironment.CONTROLLER_TEMP_DIR, hostEnvironment.getDomainTempDir().getAbsolutePath());
// Registering the actual standard server path capabilities so server config resources can reference them
//TODO look if those registrations could be moved to ServerService/DomainModelControllerService.initModel
registerServerPathCapability(service.localCapRegRef, ServerEnvironment.SERVER_BASE_DIR);
registerServerPathCapability(service.localCapRegRef, ServerEnvironment.SERVER_CONFIG_DIR);
registerServerPathCapability(service.localCapRegRef, ServerEnvironment.SERVER_DATA_DIR);
registerServerPathCapability(service.localCapRegRef, ServerEnvironment.SERVER_LOG_DIR);
registerServerPathCapability(service.localCapRegRef, ServerEnvironment.SERVER_TEMP_DIR);
return serviceBuilder.install();
}
示例11: ModelControllerService
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
ModelControllerService(final ControlledProcessState processState, final StringConfigurationPersister persister, final ServerDelegatingResourceDefinition rootResourceDefinition) {
super(ProcessType.EMBEDDED_SERVER, new RunningModeControl(RunningMode.ADMIN_ONLY), persister, processState, rootResourceDefinition, null, ExpressionResolver.TEST_RESOLVER,
AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), new CapabilityRegistry(true));
this.persister = persister;
this.processState = processState;
this.rootResourceDefinition = rootResourceDefinition;
Properties properties = new Properties();
properties.put("jboss.home.dir", System.getProperty("basedir", ".") + File.separatorChar + "target");
final String hostControllerName = "hostControllerName"; // Host Controller name may not be null when in a managed domain
environment = new ServerEnvironment(hostControllerName, properties, new HashMap<String, String>(), null, null,
ServerEnvironment.LaunchType.DOMAIN, null, ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), ".", properties), false);
extensionRegistry =
new ExtensionRegistry(ProcessType.STANDALONE_SERVER, new RunningModeControl(RunningMode.NORMAL), null, null, null, RuntimeHostControllerInfoAccessor.SERVER);
capabilityRegistry = new CapabilityRegistry(processType.isServer());
}
示例12: createStandaloneServerEnvironment
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
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);
}
示例13: getServerEnvironment
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
public 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, false);
}
示例14: createService
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
public static ServiceController<RhqMetricsService> createService(final ServiceTarget target,
final ServiceVerificationHandler verificationHandler,
ModelNode config) {
RhqMetricsService service = new RhqMetricsService(config);
return target.addService(SERVICE_NAME, service)
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class,
service.serverEnvironmentValue)
.addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class,
service.modelControllerValue)
.addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class,
service.processStateValue)
.addListener(verificationHandler)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}
示例15: installWildFlySingleton
import org.jboss.as.server.ServerEnvironment; //导入依赖的package包/类
private static void installWildFlySingleton(final ServiceRegistry registry,
final ServiceTarget target,
final Service service,
final ServiceName name) {
SingletonServiceBuilderFactory factory = null;
for(ServiceName each : SINGLETON_FACTORY_NAMES) {
ServiceController factoryService = registry.getService(each);
if (factoryService != null) {
factory = (SingletonServiceBuilderFactory)factoryService.getValue();
}
}
if (factory == null) {
throw new RuntimeException("Failed to locate singleton builder");
}
final InjectedValue<ServerEnvironment> env = new InjectedValue<>();
factory.createSingletonServiceBuilder(name, service)
.electionPolicy((SingletonElectionPolicy)electionPolicy())
.requireQuorum(1)
.build(target)
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, env)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}