use of org.b3log.solo.repository.OptionRepository in project solo by b3log.
the class SoloServletListener method contextInitialized.
@Override
public void contextInitialized(final ServletContextEvent servletContextEvent) {
// For Latke IoC
Latkes.setScanPath("org.b3log.solo");
super.contextInitialized(servletContextEvent);
Stopwatchs.start("Context Initialized");
beanManager = Lifecycle.getBeanManager();
// Upgrade check (https://github.com/b3log/solo/issues/12040)
final UpgradeService upgradeService = beanManager.getReference(UpgradeService.class);
upgradeService.upgrade();
JdbcRepository.dispose();
// Set default skin, loads from preference later
Skins.setDirectoryForTemplateLoading(Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
final OptionRepository optionRepository = beanManager.getReference(OptionRepositoryImpl.class);
final Transaction transaction = optionRepository.beginTransaction();
try {
loadPreference();
if (transaction.isActive()) {
transaction.commit();
}
} catch (final Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
}
registerEventProcessor();
final PluginManager pluginManager = beanManager.getReference(PluginManager.class);
pluginManager.load();
LOGGER.info("Solo is running [" + Latkes.getServePath() + "]");
Stopwatchs.end();
LOGGER.log(Level.DEBUG, "Stopwatch: {0}{1}", Strings.LINE_SEPARATOR, Stopwatchs.getTimingStat());
}
use of org.b3log.solo.repository.OptionRepository in project solo by b3log.
the class OptionRepositoryImplTestCase method test.
/**
* Tests.
*
* @throws Exception exception
*/
@Test
public void test() throws Exception {
final OptionRepository optionRepository = getOptionRepository();
final JSONObject option = new JSONObject();
option.put(Keys.OBJECT_ID, Option.ID_C_BROADCAST_CHANCE_EXPIRATION_TIME);
option.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_BROADCAST);
option.put(Option.OPTION_VALUE, 0L);
Transaction transaction = optionRepository.beginTransaction();
optionRepository.add(option);
transaction.commit();
Assert.assertEquals(optionRepository.count(), 1);
Assert.assertNotNull(optionRepository.get(Option.ID_C_BROADCAST_CHANCE_EXPIRATION_TIME));
}
Aggregations