/** Component activator method. */ @Activate public void activate(final ComponentContext<MemBlobstoreComponent> componentContext) { MemBlobstore memBlobstore = new MemBlobstore(transactionManager); Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>(componentContext.getProperties()); serviceRegistration = componentContext.registerService(Blobstore.class, memBlobstore, serviceProperties); }
/** * Configures an {@link SQLTemplates} instance based on {@code componentProperties} and registers * it as an OSGi service using {@code context}. * * @throws IllegalStateException if problem with to create service register. */ @Activate public void activate(final ComponentContext<SQLTemplatesComponent> componentContext) { try { Map<String, Object> componentProperties = componentContext.getProperties(); Object dbTypeObject = componentProperties.get(SQLTemplatesConstants.ATTR_DB_TYPE); Builder sqlTemplateBuilder = instantiateBuilder((String) dbTypeObject); new SQLTemplateConfigurator(sqlTemplateBuilder, componentProperties).configure(); sqlTemplate = sqlTemplateBuilder.build(); } catch (UnknownDatabaseTypeException e) { throw new IllegalStateException(e); } catch (NullPointerException | ClassCastException e) { throw new IllegalStateException( SQLTemplatesConstants.ATTR_DB_TYPE + " property must be set and must be a String", e); } registerService(componentContext); }