本文整理汇总了Java中org.jboss.msc.service.ServiceController类的典型用法代码示例。如果您正苦于以下问题:Java ServiceController类的具体用法?Java ServiceController怎么用?Java ServiceController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceController类属于org.jboss.msc.service包,在下文中一共展示了ServiceController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performRuntime
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model,
ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
final String moduleId = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
_componentNames.add(moduleId);
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(SwitchYardExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, _priority++, new SwitchYardModuleDependencyProcessor(moduleId));
}
}, OperationContext.Stage.RUNTIME);
final SwitchYardComponentService componentService = new SwitchYardComponentService(moduleId, model);
final ServiceBuilder<Component> componentServiceBuilder = context.getServiceTarget().addService(SwitchYardComponentService.SERVICE_NAME.append(moduleId), componentService);
componentServiceBuilder.addDependency(SwitchYardInjectorService.SERVICE_NAME, Map.class, componentService.getInjectedValues())
.addDependency(RA_REPOSITORY_SERVICE_NAME, ResourceAdapterRepository.class, componentService.getResourceAdapterRepository());
componentServiceBuilder.addDependency(WebSubsystemServices.JBOSS_WEB);
componentServiceBuilder.setInitialMode(Mode.ACTIVE);
newControllers.add(componentServiceBuilder.install());
}
示例2: applyUpdateToRuntime
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode resolvedValue, ModelNode currentValue,
HandbackHolder<Boolean> handbackHolder) throws OperationFailedException {
final String bindingName = context.getCurrentAddressValue();
final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
final ServiceName serviceName = OUTBOUND_SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, OutboundSocketBinding.class);
final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(serviceName);
final OutboundSocketBinding binding = controller.getState() == ServiceController.State.UP ? OutboundSocketBinding.class.cast(controller.getValue()) : null;
final boolean bound = binding != null && binding.isConnected(); // FIXME see if this can be used, or remove
if (binding == null) {
// existing is not started, so can't "update" it. Instead reinstall the service
handleBindingReinstall(context, bindingModel, serviceName);
handbackHolder.setHandback(Boolean.TRUE);
} else {
// We don't allow runtime changes without a context reload for outbound socket bindings
// since any services which might have already injected/depended on the outbound
// socket binding service would have use the (now stale) attributes.
context.reloadRequired();
}
return false; // we handle the reloadRequired stuff ourselves; it's clearer
}
示例3: doGet
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String serviceName = getRequiredParameter(req, SERVICE);
String expected = req.getParameter(EXPECTED);
this.log(format("Received request for %s, expecting %s", serviceName, expected));
@SuppressWarnings("unchecked")
ServiceController<Environment> service = (ServiceController<Environment>) getServiceContainer()
.getService(parse(serviceName));
try {
Environment env = service.getValue();
if (expected != null) {
for (int i = 0; i < RETRIES; ++i) {
if ((env != null) && expected.equals(env.getNodeName()))
break;
Thread.yield();
env = service.getValue();
}
}
if (env != null) {
resp.setHeader("node", env.getNodeName());
}
} catch (IllegalStateException e) {
// Service was not started
}
resp.getWriter().write("Success");
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:27,代码来源:HAServiceServlet.java
示例4: startNeo4jDriverService
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
private void startNeo4jDriverService(OperationContext context, ConfigurationBuilder builder, final Set<String> outboundSocketBindings) throws OperationFailedException {
if (builder.getJNDIName() != null && builder.getJNDIName().length() > 0) {
final Neo4jClientConnectionService neo4jClientConnectionService = new Neo4jClientConnectionService(builder);
final ServiceName serviceName = ConnectionServiceAccess.serviceName(builder.getDescription());
final ContextNames.BindInfo bindingInfo = ContextNames.bindInfoFor(builder.getJNDIName());
final BinderService binderService = new BinderService(bindingInfo.getBindName());
context.getServiceTarget().addService(bindingInfo.getBinderServiceName(), binderService)
.addDependency(Neo4jSubsystemService.serviceName())
.addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addDependency(serviceName, Neo4jClientConnectionService.class, new Injector<Neo4jClientConnectionService>() {
@Override
public void inject(final Neo4jClientConnectionService value) throws
InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<>(value.getDriver())));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
final ServiceBuilder<Neo4jClientConnectionService> serviceBuilder = context.getServiceTarget().addService(serviceName, neo4jClientConnectionService);
serviceBuilder.addDependency(Neo4jSubsystemService.serviceName(), new CastingInjector<>(neo4jClientConnectionService.getNeo4jSubsystemServiceInjectedValue(), Neo4jSubsystemService.class));
// add service dependency on each separate hostname/port reference in standalone*.xml referenced from this driver profile definition.
for (final String outboundSocketBinding : outboundSocketBindings) {
final ServiceName outboundSocketBindingDependency = context.getCapabilityServiceName(Neo4jDriverDefinition.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding, OutboundSocketBinding.class);
serviceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingDependency, OutboundSocketBinding.class, neo4jClientConnectionService.getOutboundSocketBindingInjector(outboundSocketBinding));
}
if (builder.getSecurityDomain() != null) {
serviceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
neo4jClientConnectionService.getSubjectFactoryInjector());
}
serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
}
示例5: startServices
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
private void startServices(OperationContext context, Configuration configuration, String outboundSocketBinding) {
ServiceName connectionsServiceName = ConnectionServiceAccess.serviceName(configuration.getProfileName());
OrientInteraction orientInteraction = new OrientInteraction(configuration);
OrientClientConnectionsService connectionsService = new OrientClientConnectionsService(configuration, orientInteraction);
ServiceBuilder<OrientClientConnectionsService> connectionsServiceBuilder = context.getServiceTarget()
.addService(connectionsServiceName, connectionsService);
connectionsServiceBuilder.addDependency(OrientSubsystemService.SERVICE_NAME, new CastingInjector<>(
connectionsService.getOrientSubsystemServiceInjectedValue(), OrientSubsystemService.class));
ServiceName outboundSocketBindingServiceName = context.getCapabilityServiceName(
OrientDriverDefinition.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding,
OutboundSocketBinding.class);
connectionsServiceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingServiceName,
new CastingInjector<>(connectionsService.getOutboundSocketBindingInjectedValue(),
OutboundSocketBinding.class));
if (configuration.getSecurityDomain() != null) {
connectionsServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
connectionsService.getSubjectFactoryInjector());
}
connectionsServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
bindJndi(context, connectionsServiceName, configuration.getJndiName(), orientInteraction.getDatabasePoolClass());
}
示例6: activate
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
ServiceTarget target = context.getServiceTarget();
target.addService(TopologyManager.SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE)))
.install();
BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true);
target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService)
.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE))
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}
示例7: performBoottime
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void performBoottime(OperationContext context, ModelNode operation, ModelNode model,
ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers)
throws OperationFailedException {
ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
SmppService service = SmppService.INSTANCE;
service.setModel(fullModel);
ServiceName name = SmppService.getServiceName();
ServiceController<SmppServiceInterface> controller = context.getServiceTarget()
.addService(name, service)
.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManagerInjector())
.addDependency(MBeanServerService.SERVICE_NAME, MBeanServer.class, service.getMbeanServer())
.addListener(verificationHandler)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
newControllers.add(controller);
}
示例8: install
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
public static ServiceController<Void> install(ServiceTarget target,
String serviceName,
String socketBindingName,
Collection<String> userDefinedTags) {
List<String> tags = new ArrayList<>(userDefinedTags);
tags.add(socketBindingName);
ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName);
RegistrationAdvertiser advertiser = new RegistrationAdvertiser(serviceName, tags.toArray(new String[tags.size()]));
return target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser)
.addDependency(CONNECTOR_SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector())
.addDependency(socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector())
.setInitialMode(ServiceController.Mode.PASSIVE)
.install();
}
示例9: activate
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
ServiceTarget target = context.getServiceTarget();
TopologyManager.INSTANCE.setServiceTarget(target);
target.addService(SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE)))
.install();
BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true);
target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService)
.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE))
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}
示例10: activate
import org.jboss.msc.service.ServiceController; //导入依赖的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();
}
示例11: doGet
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
ServiceContainer sc = CurrentServiceContainer.getServiceContainer();
// for(ServiceName sn: sc.getServiceNames()) {
// log.info("" + sn);
// }
ServiceName sn = ServiceName.of("jboss", "infinispan", "web", "repl");
ServiceController scon = sc.getService(sn);
Cache cache = (Cache)scon.getValue();
log.info("" + cache);
String path = req.getPathInfo();
Object o = null;
if ("/put".equals(path)) {
cache.put("test", "blah");
}
else if ("/get".equals(path)) {
o = cache.get("test");
}
res.setContentType("text/html");
PrintWriter out = res.getWriter();
if (o != null) {
out.println(o);
}
}
示例12: performRuntime
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
final ModelNode address = operation.require(OP_ADDR);
final PathAddress pathAddress = PathAddress.pathAddress(address);
String transportName = pathAddress.getLastElement().getValue();
final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
ServiceName serviceName = TeiidServiceNames.transportServiceName(transportName);
final ServiceController<?> controller = serviceRegistry.getService(serviceName);
if (controller != null) {
TransportService transport = TransportService.class.cast(controller.getValue());
if (transport.isEmbedded()) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(LocalServerConnection.jndiNameForRuntime(transportName));
context.removeService(bindInfo.getBinderServiceName());
context.removeService(TeiidServiceNames.embeddedTransportServiceName(transportName).append("reference-factory")); //$NON-NLS-1$
}
context.removeService(serviceName);
}
}
示例13: getService
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
protected SessionAwareCache getService(OperationContext context, PathAddress pathAddress, ModelNode operation) throws OperationFailedException {
String cacheType = Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.name();
if (operation.hasDefined(OperationsConstants.CACHE_TYPE.getName())) {
cacheType = operation.get(OperationsConstants.CACHE_TYPE.getName()).asString();
}
ServiceController<?> sc;
if (SessionAwareCache.isResultsetCache(cacheType)) {
sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.CACHE_RESULTSET);
}
else {
sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.CACHE_PREPAREDPLAN);
}
if (sc != null) {
return SessionAwareCache.class.cast(sc.getValue());
}
return null;
}
示例14: updateServices
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
static void updateServices(OperationContext context, RuntimeVDB vdb,
String dsName, ReplaceResult rr) {
if (rr.isNew) {
VDBDeployer.addDataSourceListener(context.getServiceTarget(), new VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName);
}
if (rr.removedDs != null) {
final ServiceRegistry registry = context.getServiceRegistry(true);
ServiceName serviceName;
try {
serviceName = TeiidServiceNames.dsListenerServiceName(vdb.getVdb().getName(), vdb.getVdb().getVersion(), rr.removedDs);
} catch (InvalidServiceNameException e) {
return; //the old isn't valid
}
final ServiceController<?> controller = registry.getService(serviceName);
if (controller != null) {
context.removeService(serviceName);
}
}
}
示例15: performRuntime
import org.jboss.msc.service.ServiceController; //导入依赖的package包/类
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try {
try {
classloader = Module.getCallerModule().getClassLoader();
} catch(Throwable t) {
//ignore..
}
Thread.currentThread().setContextClassLoader(classloader);
initilaizeTeiidEngine(context, operation, newControllers);
} finally {
Thread.currentThread().setContextClassLoader(classloader);
}
}