use of jakarta.inject.Singleton in project micronaut-camunda-bpm by camunda-community-hub.
the class ProcessEngineFactory method processEngine.
@Singleton
@Bean(preDestroy = "close")
public ProcessEngine processEngine(ProcessEngineConfiguration processEngineConfiguration, CamundaVersion camundaVersion, SynchronousTransactionManager<Connection> transactionManager, BasicJdbcConfiguration basicJdbcConfiguration, ParallelInitializationService parallelInitializationService) {
if (camundaVersion.getVersion().isPresent()) {
log.info("Camunda version: {}", camundaVersion.getVersion().get());
} else {
log.warn("The Camunda version cannot be determined. If you created a Fat/Uber/Shadow JAR then please consider using the Micronaut Application Plugin's 'dockerBuild' task to create a Docker image.");
}
log.info("Building process engine connected to {}", basicJdbcConfiguration.getUrl());
Instant start = Instant.now();
ProcessEngine processEngine = transactionManager.executeWrite(transactionStatus -> processEngineConfiguration.buildProcessEngine());
log.info("Started process engine in {}ms", ChronoUnit.MILLIS.between(start, Instant.now()));
log.debug("Starting Camunda related services...");
parallelInitializationService.process(processEngine);
log.debug("Camunda related services started in {}ms", ChronoUnit.MILLIS.between(start, Instant.now()));
return processEngine;
}
use of jakarta.inject.Singleton in project glassfish-hk2 by eclipse-ee4j.
the class ServiceLocatorUtilitiesTest method testGetSingleton.
/**
* Tests getSingleton
*/
@Test
public void testGetSingleton() {
Singleton fromClass = HasScopes.class.getAnnotation(Singleton.class);
Assert.assertNotNull(fromClass);
Singleton fromUtility = ServiceLocatorUtilities.getSingletonAnnotation();
Assert.assertNotNull(fromUtility);
Assert.assertTrue(fromClass.equals(fromUtility));
Assert.assertTrue(fromUtility.equals(fromClass));
}
use of jakarta.inject.Singleton in project glassfish-hk2 by eclipse-ee4j.
the class Populator method populate.
/**
* TODO: This should be removed once we have @Service all hooked up
*
* @param locator The locator to populate
*/
public static void populate(ServiceLocator locator) {
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();
// The InjectionResolver we are showcasing
config.bind(BuilderHelper.link(AlternateInjectResolver.class).to(InjectionResolver.class).in(Singleton.class.getName()).build());
// The HttpEventReciever is in the default scope @PerLookup
config.bind(BuilderHelper.link(HttpEventReceiver.class).build());
// The HttpRequest is in the RequestScope
config.bind(BuilderHelper.link(HttpRequest.class).in(RequestScope.class.getName()).build());
// The HttpServer is a singleton
config.bind(BuilderHelper.link(HttpServer.class).in(Singleton.class.getName()).build());
// The RequestContext is the context implementation for RequestScope
config.bind(BuilderHelper.link(RequestContext.class).to(Context.class).in(Singleton.class.getName()).build());
// RequestProcessor processes a request from an HttpServer
config.bind(BuilderHelper.link(RequestProcessor.class).build());
// The logger is just another service to be injected
config.bind(BuilderHelper.link(Logger.class).in(Singleton.class.getName()).build());
// And commit
config.commit();
}
use of jakarta.inject.Singleton in project micronaut-views by micronaut-projects.
the class PebbleEngineFactory method create.
/**
* @return The Pebble Engine
*/
@Singleton
public PebbleEngine create() {
Builder builder = new PebbleEngine.Builder().cacheActive(configuration.isCacheActive()).newLineTrimming(configuration.isNewLineTrimming()).autoEscaping(configuration.isAutoEscaping()).defaultEscapingStrategy(configuration.getDefaultEscapingStrategy()).strictVariables(configuration.isStrictVariables()).greedyMatchMethod(configuration.isGreedyMatchMethod()).allowOverrideCoreOperators(configuration.isAllowOverrideCoreOperators()).literalDecimalTreatedAsInteger(configuration.isLiteralDecimalsAsIntegers()).literalNumbersAsBigDecimals(configuration.isLiteralNumbersAsBigDecimals());
if (executorService != null) {
builder.executorService(executorService);
}
builder.loader(loader.orElseGet(() -> new PebbleLoader(viewsConfiguration, configuration)));
syntax.ifPresent(bean -> builder.syntax(bean));
methodAccessValidator.ifPresent(bean -> builder.methodAccessValidator(bean));
extensions.forEach(bean -> builder.extension(bean));
return builder.build();
}
use of jakarta.inject.Singleton in project micronaut-views by micronaut-projects.
the class ThymeleafFactory method templateResolver.
/**
* Constructs the template resolver bean.
*
* @param viewsConfiguration The views configuration
* @param rendererConfiguration The renderer configuration
* @return The template resolver
*/
@Singleton
public AbstractConfigurableTemplateResolver templateResolver(ViewsConfiguration viewsConfiguration, ThymeleafViewsRendererConfiguration rendererConfiguration) {
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix(viewsConfiguration.getFolder());
templateResolver.setCharacterEncoding(rendererConfiguration.getCharacterEncoding());
templateResolver.setTemplateMode(rendererConfiguration.getTemplateMode());
templateResolver.setSuffix(rendererConfiguration.getSuffix());
templateResolver.setForceSuffix(rendererConfiguration.getForceSuffix());
templateResolver.setForceTemplateMode(rendererConfiguration.getForceTemplateMode());
templateResolver.setCacheTTLMs(rendererConfiguration.getCacheTTLMs());
templateResolver.setCheckExistence(rendererConfiguration.getCheckExistence());
templateResolver.setCacheable(rendererConfiguration.getCacheable());
return templateResolver;
}
Aggregations