64 lines
1.5 KiB
Java
64 lines
1.5 KiB
Java
package org.gcube.data.access.storagehub;
|
|
|
|
|
|
import org.gcube.data.access.storagehub.services.RepositoryInitializer;
|
|
import org.gcube.smartgears.ApplicationManager;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
public class StorageHubAppllicationManager implements ApplicationManager {
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(StorageHubAppllicationManager.class);
|
|
|
|
private boolean alreadyShutDown = false;
|
|
private boolean alreadyInit = false;
|
|
|
|
private static RepositoryInitializer repository = RepositoryInitializerImpl.get();
|
|
|
|
//private static NotificationClient notificationClient;
|
|
|
|
public static RepositoryInitializer getRepository() {
|
|
return repository;
|
|
}
|
|
|
|
/*
|
|
public static NotificationClient getNotificationClient() {
|
|
return notificationClient;
|
|
}*/
|
|
|
|
@Override
|
|
public synchronized void onInit() {
|
|
|
|
|
|
logger.info("initializing storagehub");
|
|
try {
|
|
if (!alreadyInit) {
|
|
logger.info("jackrabbit initialization started");
|
|
|
|
repository.initContainerAtFirstStart(Constants.JCR_CREDENTIALS);
|
|
|
|
//notificationClient = new NotificationClient();
|
|
|
|
alreadyInit = true;
|
|
}
|
|
} catch (Throwable e) {
|
|
logger.error("unexpected error initiliazing storagehub",e);
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public synchronized void onShutdown() {
|
|
if (!alreadyShutDown)
|
|
try {
|
|
logger.info("jackrabbit is shutting down");
|
|
repository.shutdown();
|
|
alreadyShutDown= true;
|
|
} catch (Exception e) {
|
|
logger.warn("the database was not shutdown properly",e);
|
|
}
|
|
}
|
|
|
|
|
|
}
|