use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class AtomicCounterEditorProvider method activate.
@Activate
public void activate(BundleContext context) {
whiteboard.set(new OsgiWhiteboard(context));
ThreadFactory tf = new ThreadFactoryBuilder().setNameFormat("atomic-counter-%d").build();
scheduler.set(Executors.newScheduledThreadPool(10, tf));
}
use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class DataStoreTextProviderService method activate.
@Activate
private void activate(BundleContext context, Configuration config) throws IOException {
String dirPath = config.dir();
checkNotNull(dirPath, "Directory path not configured via 'dir'");
File dir = new File(dirPath);
checkArgument(dir.exists(), "Directory %s does not exist", dir.getAbsolutePath());
textWriter = new DataStoreTextWriter(dir, true);
reg = context.registerService(PreExtractedTextProvider.class.getName(), textWriter, null);
}
use of org.osgi.service.component.annotations.Activate in project liferay-blade-samples by liferay.
the class AddTestData method addTestData.
@Activate
public void addTestData() {
int entries = 2;
while (entries > 0) {
Foo foo = _fooLocalService.createFoo(0);
foo.setField1("new field1 entry" + entries);
foo.setField2(true);
foo.setField3(10);
foo.setField4(new Date());
foo.setField5("new field5 entry" + entries);
foo.isNew();
_fooLocalService.addFooWithoutId(foo);
entries--;
}
}
use of org.osgi.service.component.annotations.Activate in project liferay-blade-samples by liferay.
the class BladeCustomJspBag method activate.
/**
* Adds the URL paths for all custom core JSPs to a list when the module is
* activated.
*
* @param bundleContext the bundle context from which to get the custom
* JSP's bundle
*/
@Activate
protected void activate(BundleContext bundleContext) {
_bundle = bundleContext.getBundle();
_customJsps = new ArrayList<>();
Enumeration<URL> entries = _bundle.findEntries(getCustomJspDir(), "*.jsp", true);
while (entries.hasMoreElements()) {
URL url = entries.nextElement();
_customJsps.add(url.getPath());
}
}
use of org.osgi.service.component.annotations.Activate in project adeptj-modules by AdeptJ.
the class EntityManagerFactoryProvider method start.
// ---------------- INTERNAL ----------------
@Activate
protected void start(BundleContext context, EntityManagerFactoryConfig config) {
this.lock.lock();
try {
String unitName = config.unitName();
Validate.isTrue(isNotEmpty(unitName), "unitName can't be null or empty!!");
LOGGER.info("Creating EntityManagerFactory for PersistenceUnit: [{}]", unitName);
DataSource ds = Validate.notNull(this.dataSourceProvider.getDataSource(config.dataSourceName()), DS_NOT_NULL_MSG);
this.emf = new PersistenceProvider().createEntityManagerFactory(unitName, JpaProperties.create(config, ds, this.validatorService.getValidatorFactory()));
if (this.emf == null) {
throw new IllegalStateException(EMF_NULL_MSG);
} else {
LOGGER.info("EntityManagerFactory [{}] created for PersistenceUnit: [{}]", this.emf, unitName);
this.jpaCrudRepository = JpaCrudRepositories.create(unitName, this.emf, context);
}
} catch (Exception ex) {
// NOSONAR
LOGGER.error("Exception occurred while creating EntityManagerFactory!!", ex);
// Close the EntityManagerFactory if it was created earlier but exception occurred later.
Optional.ofNullable(this.emf).ifPresent(EntityManagerFactory::close);
// Throw exception so that SCR won't create the component instance.
throw new JpaBootstrapException(ex);
} finally {
this.lock.unlock();
}
}
Aggregations