use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationFactoryServiceImplTest method findActiveApplication.
@Test
void findActiveApplication() throws Exception {
final BundleContext bundleContext = getBundleContext();
final ApplicationFactoryServiceImpl service = new ApplicationFactoryServiceImpl(bundleContext);
service.activate();
final String appName = "app1";
final ApplicationKey applicationKey = ApplicationKey.from(appName);
final Bundle bundle = deploy(appName, newBundle(appName, true));
assertThat(service.findActiveApplication(applicationKey)).isEmpty();
bundle.start();
assertThat(service.findActiveApplication(applicationKey)).isNotEmpty();
bundle.stop();
assertThat(service.findActiveApplication(applicationKey)).isEmpty();
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImpl method doInstallGlobalApplication.
private Application doInstallGlobalApplication(final ByteSource byteSource) {
final ApplicationKey applicationKey = getApplicationKey(byteSource);
if (!appFilterService.accept(applicationKey)) {
throw new ApplicationInstallException(String.format("Application %s is not permitted on this instance", applicationKey));
}
final Application application = installOrUpdateApplication(byteSource, applicationKey, false, true);
LOG.info("Global Application [{}] installed successfully", applicationKey);
doPublishInstalledEvent(applicationKey);
doStartApplication(applicationKey, true, false);
return application;
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImpl method doInstallStoredApplication.
private Application doInstallStoredApplication(final NodeId nodeId) {
final ByteSource byteSource = this.repoService.getApplicationSource(nodeId);
if (byteSource == null) {
throw new ApplicationInstallException("Cannot install application with id [" + nodeId + "], source not found");
}
final ApplicationKey applicationKey = getApplicationKey(byteSource);
if (!appFilterService.accept(applicationKey)) {
LOG.info("Application {} is not permitted on this instance", applicationKey);
return null;
}
return installOrUpdateApplication(byteSource, applicationKey, false, false);
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImpl method doInstallStoredApplications.
private void doInstallStoredApplications(final ApplicationInstallationParams params) {
LOG.info("Searching for installed applications");
final Nodes applicationNodes = repoService.getApplications();
LOG.info("Found [" + applicationNodes.getSize() + "] installed applications");
for (final Node applicationNode : applicationNodes) {
try {
final Application application = doInstallStoredApplication(applicationNode.id());
if (application == null) {
continue;
}
final ApplicationKey applicationKey = application.getKey();
LOG.info("Stored application [{}] installed successfully", applicationKey);
if (params.isTriggerEvent()) {
doPublishInstalledEvent(applicationNode);
}
if (params.isStart() && storedApplicationIsStarted(applicationNode)) {
doStartApplication(applicationKey, params.isTriggerEvent(), false);
}
} catch (Exception e) {
LOG.error("Cannot install application [{}]", applicationNode.name(), e);
}
}
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImpl method doInstallStoredApplication.
private Application doInstallStoredApplication(final NodeId nodeId, final ApplicationInstallationParams params) {
final Application application = doInstallStoredApplication(nodeId);
if (application == null) {
return null;
}
final ApplicationKey applicationKey = application.getKey();
LOG.info("Stored application [{}] installed successfully", applicationKey);
if (params.isTriggerEvent()) {
doPublishInstalledEvent(applicationKey);
}
if (params.isStart()) {
doStartApplication(applicationKey, params.isTriggerEvent(), false);
}
return application;
}
Aggregations