}
@Override
protected void doOpen(final DatabaseCallback callback)
{
final IDBOpenDBRequest openDBRequest = IDBFactory.get().open(getName(), getVersion());
openDBRequest.onSuccess(new IDBOpenedEvent.Handler()
{
@Override
public void onSuccess(IDBOpenedEvent event)
{
db = event.getResult();
if (LogConfiguration.loggingIsEnabled())
{
logger.log(Level.INFO, messages.databaseOpened(getName()));
}
if (callback != null)
{
callback.onSuccess();
}
}
});
openDBRequest.onBlocked(new IDBBlockedEvent.Handler()
{
@Override
public void onBlocked(IDBBlockedEvent event)
{
String message = messages.databaseBlocked(getName());
if (LogConfiguration.loggingIsEnabled())
{
logger.log(Level.SEVERE, message);
}
if (callback != null)
{
callback.onError(message);
}
else if (errorHandler != null)
{
errorHandler.onError(message);
}
}
});
openDBRequest.onError(new IDBErrorEvent.Handler()
{
@Override
public void onError(IDBErrorEvent event)
{
String message = messages.databaseOpenError(getName(), event.getName());
if (LogConfiguration.loggingIsEnabled())
{
logger.log(Level.SEVERE, message);
}
if (callback != null)
{
callback.onError(message);
}
else if (errorHandler != null)
{
errorHandler.onError(message);
}
}
});
openDBRequest.onUpgradeNeeded(new IDBUpgradeNeededEvent.Handler()
{
@Override
public void onUpgradeNeeded(IDBUpgradeNeededEvent event)
{
db = event.getResult();