@Override public String instantiateComponent(String componentName) { ComponentFactory factory = componentFactories.get(componentName); if (factory != null) { ComponentInstance instance = factory.newInstance(null); int hashCode = instance.hashCode(); String code = componentName + "#" + hashCode; componentInstances.put(code, instance); return code; } return null; }
@SuppressWarnings("unchecked") protected void createRefactorEngineComponent(ComponentFactory factory) { // both create*** methods sync on the searcherAndDereferencerLock to avoid // multiple component instances because of concurrent calls synchronized (this.lock) { if (refactorEngineComponentInstance == null) { this.refactorEngineComponentInstance = factory.newInstance(OsgiUtils.copyConfig(context .getProperties())); } } }
/** * Called when all of the SCR Components required dependencies have been satisfied. */ @Activate public void activate() { LOG.info("Activating the {}", COMPONENT_LABEL); try { lock.readLock().lock(); if (factory != null) { final Properties props = new Properties(); props.setProperty("salutation", "Hello"); props.setProperty("name", "User"); instance = factory.newInstance((Dictionary) props); greeterService = (GreeterServiceComponentFactory) instance.getInstance(); greeterService.startGreeter(); } } finally { lock.readLock().unlock(); } }
/** * Creates the entity dereferencer component used by this {@link Site}. The implementation used as the * dereferencer is configured by the {@link SiteConfiguration#ENTITY_DEREFERENCER_TYPE} property. * * @param factory * the component factory used to create the {@link #dereferencer} */ @SuppressWarnings("unchecked") protected void createDereferencerComponent(ComponentFactory factory) { // both create*** methods sync on searcherAndDereferencerLock to avoid // multiple component instances because of concurrent calls synchronized (searcherAndDereferencerLock) { if (dereferencerComponentInstance == null) { dereferencerComponentInstance = factory.newInstance(OsgiUtils.copyConfig(cc.getProperties())); updateServiceRegistration(bc, siteConfiguration, dereferencerComponentInstance, entitySearcherComponentInstance, cache, nsPrefixService, offlineMode); } } }
/** * Creates the entity dereferencer component used by this {@link Site}. The implementation used as the * dereferencer is configured by the {@link SiteConfiguration#ENTITY_DEREFERENCER_TYPE} property. * * @param factory * the component factory used to create the {@link #dereferencer} */ @SuppressWarnings("unchecked") protected void createDereferencerComponent(ComponentFactory factory) { // both create*** methods sync on searcherAndDereferencerLock to avoid // multiple component instances because of concurrent calls synchronized (searcherAndDereferencerLock) { if (dereferencerComponentInstance == null) { dereferencerComponentInstance = factory.newInstance(OsgiUtils.copyConfig(cc.getProperties())); updateServiceRegistration(bc, siteConfiguration, dereferencerComponentInstance, entitySearcherComponentInstance, cache, nsPrefixService, offlineMode); } } }
/** * Creates the entity searcher component used by this {@link Site} (and configured via the * {@link SiteConfiguration#ENTITY_SEARCHER_TYPE} property). * <p> * If the {@link SiteConfiguration#ENTITY_DEREFERENCER_TYPE} is set to the same vale and the * {@link #accessUri} also equals the {@link #queryUri}, than the component created for the entity * searcher is also used as dereferencer. * * @param factory * The component factory used to create the {@link #entitySearcherComponentInstance} */ @SuppressWarnings("unchecked") protected void createEntitySearcherComponent(ComponentFactory factory) { // both create*** methods sync on the searcherAndDereferencerLock to // avoid // multiple component instances because of concurrent calls synchronized (searcherAndDereferencerLock) { if (entitySearcherComponentInstance == null) { entitySearcherComponentInstance = factory.newInstance(OsgiUtils.copyConfig(cc.getProperties())); if(dereferencerEqualsEntitySearcherComponent){ //use the same instance for dereferencer and entity searcher dereferencerComponentInstance = entitySearcherComponentInstance; } updateServiceRegistration(bc, siteConfiguration, dereferencerComponentInstance, entitySearcherComponentInstance, cache, nsPrefixService, offlineMode); } } }
/** * Creates the entity searcher component used by this {@link Site} (and configured via the * {@link SiteConfiguration#ENTITY_SEARCHER_TYPE} property). * <p> * If the {@link SiteConfiguration#ENTITY_DEREFERENCER_TYPE} is set to the same vale and the * {@link #accessUri} also equals the {@link #queryUri}, than the component created for the entity * searcher is also used as dereferencer. * * @param factory * The component factory used to create the {@link #entitySearcherComponentInstance} */ @SuppressWarnings("unchecked") protected void createEntitySearcherComponent(ComponentFactory factory) { // both create*** methods sync on the searcherAndDereferencerLock to // avoid // multiple component instances because of concurrent calls synchronized (searcherAndDereferencerLock) { if (entitySearcherComponentInstance == null) { entitySearcherComponentInstance = factory.newInstance(OsgiUtils.copyConfig(cc.getProperties())); if(dereferencerEqualsEntitySearcherComponent){ //use the same instance for dereferencer and entity searcher dereferencerComponentInstance = entitySearcherComponentInstance; } updateServiceRegistration(bc, siteConfiguration, dereferencerComponentInstance, entitySearcherComponentInstance, cache, nsPrefixService, offlineMode); } } }