use of org.jboss.msc.service.StopContext in project wildfly-camel by wildfly-extras.
the class CamelContextRegistryBindingService method addService.
public static ServiceController<?> addService(ServiceTarget serviceTarget) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_REGISTRY_BINDING_NAME);
BinderService binderService = new BinderService(bindInfo.getBindName()) {
@Override
public synchronized void start(StartContext context) throws StartException {
super.start(context);
LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName());
}
@Override
public synchronized void stop(StopContext context) {
LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName());
super.stop(context);
}
};
Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector();
ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService);
builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
builder.addDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelContextRegistry.class, new ManagedReferenceInjector<CamelContextRegistry>(injector));
return builder.install();
}
use of org.jboss.msc.service.StopContext in project wildfly-camel by wildfly-extras.
the class CamelContextBindingService method addService.
public static ServiceController<?> addService(ServiceTarget serviceTarget, final CamelContext camelctx) {
final BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_BINDING_NAME + "/" + camelctx.getName());
BinderService binderService = new BinderService(bindInfo.getBindName()) {
@Override
public synchronized void start(StartContext context) throws StartException {
super.start(context);
LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName());
}
@Override
public synchronized void stop(StopContext context) {
LOGGER.info("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName());
super.stop(context);
}
};
binderService.getManagedObjectInjector().inject(new ImmediateManagedReferenceFactory(camelctx));
ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService);
builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
return builder.install();
}
use of org.jboss.msc.service.StopContext in project fakereplace by fakereplace.
the class WildflyHibernate5ClassChangeAware method doServiceStop.
private void doServiceStop(Service puService) throws InterruptedException {
final CountDownLatch stopLatch = new CountDownLatch(1);
final AtomicBoolean async = new AtomicBoolean(false);
puService.stop(new StopContext() {
@Override
public void asynchronous() throws IllegalStateException {
async.set(true);
}
@Override
public void complete() throws IllegalStateException {
stopLatch.countDown();
}
@Override
public long getElapsedTime() {
return 0;
}
@Override
public ServiceController<?> getController() {
return null;
}
@Override
public void execute(Runnable command) {
command.run();
}
});
if (async.get()) {
stopLatch.await();
}
}
use of org.jboss.msc.service.StopContext in project wildfly by wildfly.
the class JaxrsSpringProcessor method getResteasySpringVirtualFile.
/**
* Lookup Seam integration resource loader.
*
* @return the Seam integration resource loader
* @throws DeploymentUnitProcessingException
* for any error
*/
protected synchronized VirtualFile getResteasySpringVirtualFile() throws DeploymentUnitProcessingException {
if (resourceRoot != null) {
return resourceRoot;
}
try {
Module module = Module.getBootModuleLoader().loadModule(MODULE);
URL fileUrl = module.getClassLoader().getResource(JAR_LOCATION);
if (fileUrl == null) {
throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
}
File dir = new File(fileUrl.toURI());
File file = null;
for (String jar : dir.list()) {
if (jar.endsWith(".jar")) {
file = new File(dir, jar);
break;
}
}
if (file == null) {
throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
}
VirtualFile vf = VFS.getChild(file.toURI());
final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
Service<Closeable> mountHandleService = new Service<Closeable>() {
public void start(StartContext startContext) throws StartException {
}
public void stop(StopContext stopContext) {
VFSUtils.safeClose(mountHandle);
}
public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
return mountHandle;
}
};
ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SERVICE_NAME), mountHandleService);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
resourceRoot = vf;
return resourceRoot;
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
}
use of org.jboss.msc.service.StopContext in project wildfly by wildfly.
the class JaegerTracerConfigurationAddHandler method performRuntime.
@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
super.performRuntime(context, operation, model);
CapabilityServiceBuilder builder = context.getCapabilityServiceTarget().addCapability(TRACER_CAPABILITY);
String outboundSocketBindingName = TracerAttributes.SENDER_BINDING.resolveModelAttribute(context, model).asStringOrNull();
Supplier<OutboundSocketBinding> outboundSocketBindingSupplier;
if (outboundSocketBindingName != null) {
outboundSocketBindingSupplier = builder.requiresCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, OutboundSocketBinding.class, outboundSocketBindingName);
} else {
outboundSocketBindingSupplier = () -> null;
}
TracerConfiguration config = new JaegerTracerConfiguration(context, context.getCurrentAddressValue(), operation, outboundSocketBindingSupplier);
Consumer<TracerConfiguration> injector = builder.provides(TRACER_CAPABILITY);
builder.setInstance(new Service() {
@Override
public void start(StartContext context) {
injector.accept(config);
WildFlyTracerFactory.registerTracer(config.getName()).accept(config);
}
@Override
public void stop(StopContext context) {
WildFlyTracerFactory.registerTracer(config.getName()).accept(null);
}
});
builder.setInitialMode(ON_DEMAND).install();
}
Aggregations