Search in sources :

Example 1 with ApplicationNotFoundException

use of com.enonic.xp.app.ApplicationNotFoundException in project xp by enonic.

the class ScriptExecutorFactory method create.

public ScriptExecutor create(final ApplicationKey applicationKey) {
    LOG.debug("Create Script Executor for {}", applicationKey);
    final Application application = applicationService.getInstalledApplication(applicationKey);
    if (application == null || !application.isStarted() || application.getConfig() == null) {
        throw new ApplicationNotFoundException(applicationKey);
    }
    final ClassLoader classLoader = application.getClassLoader();
    final Bundle bundle = application.getBundle();
    final BundleContext bundleContext = Objects.requireNonNull(bundle.getBundleContext(), String.format("application bundle %s context must not be null", bundle.getBundleId()));
    return new ScriptExecutorImpl(scriptAsyncService.getAsyncExecutor(application.getKey()), scriptSettings, classLoader, new ServiceRegistryImpl(bundleContext), resourceService, application, RunMode.get());
}
Also used : ServiceRegistryImpl(com.enonic.xp.script.impl.service.ServiceRegistryImpl) ApplicationNotFoundException(com.enonic.xp.app.ApplicationNotFoundException) Bundle(org.osgi.framework.Bundle) Application(com.enonic.xp.app.Application) BundleContext(org.osgi.framework.BundleContext)

Aggregations

Application (com.enonic.xp.app.Application)1 ApplicationNotFoundException (com.enonic.xp.app.ApplicationNotFoundException)1 ServiceRegistryImpl (com.enonic.xp.script.impl.service.ServiceRegistryImpl)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1