Example usage for org.springframework.context.support FileSystemXmlApplicationContext getType

List of usage examples for org.springframework.context.support FileSystemXmlApplicationContext getType

Introduction

In this page you can find the example usage for org.springframework.context.support FileSystemXmlApplicationContext getType.

Prototype

@Override
    @Nullable
    public Class<?> getType(String name) throws NoSuchBeanDefinitionException 

Source Link

Usage

From source file:org.age.services.worker.internal.DefaultWorkerService.java

private void setupTaskFromConfig(final @NonNull String configPath) {
    assert nonNull(configPath);
    assert !isTaskRunning() : "Task is already running.";

    taskLock.writeLock().lock();//  w  w  w  .  j a va  2s  .c  o  m
    try {
        log.debug("Setting up task from config {}.", configPath);

        log.debug("Creating internal Spring context.");
        final FileSystemXmlApplicationContext taskContext = new FileSystemXmlApplicationContext(configPath);
        prepareContext(taskContext);

        currentClassName = taskContext.getType("runnable").getCanonicalName();

        log.debug("Task setup finished.");
    } catch (final BeanCreationException e) {
        log.error("Cannot create the task.", e);
        cleanUpAfterTask();
    } finally {
        taskLock.writeLock().unlock();
    }
}