/** Start the backup service. This involves opening the backup workspace. */ private void startImpl() { logger.logInfo("Starting backup service."); try { environment = readBackupEnvironment(); workspace = readBackupWorkspace(); Assert.assertNotNull(environment, "Backup environment not yet initialized."); Assert.assertNotNull(workspace, "Backup workspace not yet initialized."); final WorkspaceModel workspaceModel = WorkspaceModel.getInstance(); if (!workspaceModel.isInitialized(workspace)) { workspaceModel.initialize( new ProcessAdapter() { @Override public void beginProcess() {} @Override public void beginStep(final Step step, final Object data) {} @Override public void determineSteps(final Integer steps) {} @Override public void endProcess() {} @Override public void endStep(final Step step) {} }, new InitializeMediator() { public Boolean confirmRestorePremium() { return null; } public Boolean confirmRestoreStandard() { return null; } }, workspace, null); } eventHandler.start(getModelFactory()); logger.logInfo("Backup service started."); } catch (final Throwable t) { throw new BackupException(t, "Failed to start backup service."); } }
/** * Obtain the annotated transaction type for the method. If the transaction type is not defined on * the method; attempt to retreive it from the class. If no transaction annotation is found * assert. * * @param method A <code>Method</code>. * @return A <code>TransactionType</code>. */ private TransactionType extractXAType(final Method method) { ThinkParityTransaction transaction = method.getAnnotation(ThinkParityTransaction.class); if (null == transaction) { transaction = method.getDeclaringClass().getAnnotation(ThinkParityTransaction.class); } if (null == transaction) { LOGGER.logFatal( "Method {0} of class {1} does not define transactional behaviour.", method.getName(), method.getDeclaringClass().toString()); XA_LOGGER.logFatal( "Method {0} of class {1} does not define transactional behaviour.", method.getName(), method.getDeclaringClass().toString()); } Assert.assertNotNull( transaction, "Method {0} of class {1} does not define transactional behaviour.", method.getName(), method.getDeclaringClass().toString()); return transaction.value(); }
/** * Assert that the object references provided are not null. If they are, throw a {@link * NullPointerAssertion}. * * @param message An assertion message. * @param objectReferences <code>java.lang.Object</code> */ public static void assertNotNull(final Object message, final Object[] objectReferences) { Assert.assertNotNull(message, (Object) objectReferences); for (int i = 0; i < objectReferences.length; i++) Assert.assertNotNull(message, objectReferences[i]); }
/** * Read the backup workspace. * * @return The backup <code>Workspace</code>. */ private Workspace readBackupWorkspace() { Assert.assertNotNull(environment, "Backup environment not yet initialized."); Assert.assertNotNull(fileSystem, "Backup file system not yet initialized."); final WorkspaceModel workspaceModel = WorkspaceModel.getInstance(); return workspaceModel.getWorkspace(fileSystem.getRoot()); }