本文整理汇总了Java中org.apache.deltaspike.core.util.ServiceUtils类的典型用法代码示例。如果您正苦于以下问题:Java ServiceUtils类的具体用法?Java ServiceUtils怎么用?Java ServiceUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceUtils类属于org.apache.deltaspike.core.util包,在下文中一共展示了ServiceUtils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookup
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
/**
* Looks up a unique service implementation.
*
* @return ProxyClassGenerator service
*/
public static DeltaSpikeProxyClassGenerator lookup()
{
if (generator == null)
{
List<DeltaSpikeProxyClassGenerator> proxyClassGeneratorList =
ServiceUtils.loadServiceImplementations(DeltaSpikeProxyClassGenerator.class);
if (proxyClassGeneratorList.size() != 1)
{
throw new IllegalStateException(proxyClassGeneratorList.size()
+ " implementations of " + DeltaSpikeProxyClassGenerator.class.getName()
+ " found. Expected exactly one implementation.");
}
generator = proxyClassGeneratorList.get(0);
}
return generator;
}
示例2: initScheduler
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
private void initScheduler(AfterBeanDiscovery afterBeanDiscovery)
{
List<Scheduler> availableSchedulers = ServiceUtils.loadServiceImplementations(Scheduler.class, true);
this.scheduler = findScheduler(availableSchedulers, this.jobClass);
if (this.scheduler != null)
{
try
{
this.scheduler.start();
}
catch (Throwable t)
{
afterBeanDiscovery.addDefinitionError(t);
}
}
else if (!this.foundManagedJobClasses.isEmpty())
{
LOG.warning(
this.foundManagedJobClasses.size() + " scheduling-jobs found, but there is no configured scheduler");
}
}
示例3: resolveConfigSources
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
private static List<ConfigSource> resolveConfigSources()
{
List<ConfigSource> appConfigSources = ServiceUtils.loadServiceImplementations(ConfigSource.class);
List<ConfigSourceProvider> configSourceProviderServiceLoader =
ServiceUtils.loadServiceImplementations(ConfigSourceProvider.class);
for (ConfigSourceProvider configSourceProvider : configSourceProviderServiceLoader)
{
appConfigSources.addAll(configSourceProvider.getConfigSources());
}
List<? extends ConfigFilter> configFilters = ServiceUtils.loadServiceImplementations(ConfigFilter.class);
for (ConfigFilter configFilter : configFilters)
{
addConfigFilter(configFilter);
}
return appConfigSources;
}
示例4: processConfigurationValidation
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
protected void processConfigurationValidation(AfterDeploymentValidation adv)
{
for (ConfigValidator configValidator : ServiceUtils.loadServiceImplementations(ConfigValidator.class))
{
Set<String> violations = configValidator.processValidation();
if (violations == null)
{
continue;
}
for (String violation : violations)
{
adv.addDeploymentProblem(new IllegalStateException(violation));
}
}
}
示例5: lookupOfSpiImplementations
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
@Test
public void lookupOfSpiImplementations()
{
//exclude it due to an issue with the arquillian-adapter for owb 1.1.x and 1.2.0
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_OWB_1_1_x) &&
!CdiContainerUnderTest.is(CONTAINER_OWB_1_2_0));
Assert.assertTrue(ServiceUtils.loadServiceImplementations(MyInterface.class).iterator().hasNext());
Assert.assertNotNull(ServiceUtils.loadServiceImplementations(MyInterface.class));
Assert.assertFalse(ServiceUtils.loadServiceImplementations(MyInterface.class).isEmpty());
Assert.assertEquals(1, ServiceUtils.loadServiceImplementations(MyInterface.class).size());
Assert.assertEquals(
"test", ServiceUtils.loadServiceImplementations(MyInterface.class).iterator().next().getValue());
}
示例6: registerPropertyFileConfigs
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
/**
* Load all {@link PropertyFileConfig}s which are registered via
* {@code java.util.ServiceLoader}.
*/
private void registerPropertyFileConfigs() {
List<? extends PropertyFileConfig> propertyFileConfigs = ServiceUtils
.loadServiceImplementations(PropertyFileConfig.class);
for (PropertyFileConfig propertyFileConfig : propertyFileConfigs) {
EnvironmentPropertyConfigSourceProvider environmentPropertyConfigSourceProvider = new EnvironmentPropertyConfigSourceProvider(
propertyFileConfig.getPropertyFileName(), propertyFileConfig.isOptional());
configSources.addAll(environmentPropertyConfigSourceProvider.getConfigSources());
}
}
示例7: CdiTestRunner
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
public CdiTestRunner(Class<?> testClass) throws InitializationError
{
super(testClass);
TestControl testControl = testClass.getAnnotation(TestControl.class);
this.testContext = new ContainerAwareTestContext(testControl, null);
//benefits from the fallback-handling in ContainerAwareTestContext
Class<? extends Handler> logHandlerClass = this.testContext.getLogHandlerClass();
if (!Handler.class.equals(logHandlerClass))
{
try
{
LOGGER.addHandler(logHandlerClass.newInstance());
}
catch (Exception e)
{
throw ExceptionUtils.throwAsRuntimeException(e);
}
}
this.statementDecoratorFactories = ServiceUtils.loadServiceImplementations(TestStatementDecoratorFactory.class);
Collections.sort(this.statementDecoratorFactories, new Comparator<TestStatementDecoratorFactory>()
{
@Override
public int compare(TestStatementDecoratorFactory f1, TestStatementDecoratorFactory f2)
{
return f1.getOrdinal() > f2.getOrdinal() ? 1 : -1;
}
});
}
示例8: registerPropertyFileConfigs
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
/**
* Load all {@link PropertyFileConfig}s which are registered via
* {@code java.util.ServiceLoader}.
*/
private void registerPropertyFileConfigs()
{
List<? extends PropertyFileConfig> propertyFileConfigs =
ServiceUtils.loadServiceImplementations(PropertyFileConfig.class);
for (PropertyFileConfig propertyFileConfig : propertyFileConfigs)
{
EnvironmentPropertyConfigSourceProvider environmentPropertyConfigSourceProvider
= new EnvironmentPropertyConfigSourceProvider(propertyFileConfig.getPropertyFileName(),
propertyFileConfig.isOptional());
configSources.addAll(environmentPropertyConfigSourceProvider.getConfigSources());
}
}
示例9: startScopes
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
private void startScopes(CdiContainer container,
Class testClass,
Method testMethod,
Class<? extends Annotation>... restrictedScopes) {
ContextControl contextControl = container.getContextControl();
List<Class<? extends Annotation>> scopeClasses = new ArrayList<Class<? extends Annotation>>();
Collections.addAll(scopeClasses, this.testControl.startScopes());
if (scopeClasses.isEmpty()) {
addScopesForDefaultBehavior(scopeClasses);
} else {
List<TestControlValidator> testControlValidatorList =
ServiceUtils.loadServiceImplementations(TestControlValidator.class);
for (TestControlValidator testControlValidator : testControlValidatorList) {
if (testControlValidator instanceof TestAware) {
if (testMethod != null) {
((TestAware) testControlValidator).setTestMethod(testMethod);
}
((TestAware) testControlValidator).setTestClass(testClass);
}
try {
testControlValidator.validate(this.testControl);
} finally {
if (testControlValidator instanceof TestAware) {
((TestAware) testControlValidator).setTestClass(null);
((TestAware) testControlValidator).setTestMethod(null);
}
}
}
}
for (Class<? extends Annotation> scopeAnnotation : scopeClasses) {
if (this.parent != null && this.parent.isScopeStarted(scopeAnnotation)) {
continue;
}
if (isRestrictedScope(scopeAnnotation, restrictedScopes)) {
continue;
}
try {
//force a clean context - TODO discuss onScopeStopped call
contextControl.stopContext(scopeAnnotation);
contextControl.startContext(scopeAnnotation);
this.startedScopes.add(scopeAnnotation);
onScopeStarted(scopeAnnotation);
} catch (RuntimeException e) {
Logger logger = Logger.getLogger(CdiCucumberTestRunner.class.getName());
logger.setLevel(Level.SEVERE);
logger.log(Level.SEVERE, "failed to start scope @" + scopeAnnotation.getName(), e);
}
}
}
示例10: init
import org.apache.deltaspike.core.util.ServiceUtils; //导入依赖的package包/类
protected void init(@Observes BeforeBeanDiscovery beforeBeanDiscovery)
{
isActivated = ClassDeactivationUtils.isActivated(getClass());
mockFilters = ServiceUtils.loadServiceImplementations(MockFilter.class);
}