Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessConsumer.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessConsumer.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessConsumer.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessConsumer.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.device; + +import java.util.Map; + +import org.osgi.service.log.LogService; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class DeviceAccessConsumer { + volatile LogService log; + + void add(DeviceAccess deviceAccess, Map<String, Object> props) { + log.log(LogService.LOG_INFO, "DeviceAccessConsumer: Handling device access: id=" + props.get("device.access.id") + + "\n\t device=" + deviceAccess.getDevice() + + "\n\t device parameter=" + deviceAccess.getDeviceParameter() + + "\n\t device access properties=" + props); + } +}
Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessImpl.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessImpl.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessImpl.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceAccessImpl.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.device; + +import static org.apache.felix.dm.builder.java.DependencyActivatorBase.component; + +import org.apache.felix.dm.Component; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class DeviceAccessImpl implements DeviceAccess { + volatile Device device; + volatile DeviceParameter deviceParameter; + + void init(Component c) { + // Dynamically add an extra dependency on a DeviceParameter (using java8 builder). + // Notice that we also add a "device.access.id" service property dynamically. + component(c, builder -> builder + .properties("device.access.id", device.getDeviceId()) + .withService(DeviceParameter.class, srv -> srv.filter("(device.id=" + device.getDeviceId() + ")"))); + } + + @Override + public Device getDevice() { + return device; + } + + @Override + public DeviceParameter getDeviceParameter() { + return deviceParameter; + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceImpl.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceImpl.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceImpl.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceImpl.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.device; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class DeviceImpl implements Device { + final int id; + + public DeviceImpl(int id) { + this.id = id; + } + + @Override + public int getDeviceId() { + return id; + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameter.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameter.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameter.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameter.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.device; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public interface DeviceParameter { + int getDeviceId(); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameterImpl.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameterImpl.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameterImpl.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/DeviceParameterImpl.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.device; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class DeviceParameterImpl implements DeviceParameter { + final int id; + + public DeviceParameterImpl(int id) { + this.id = id; + } + + @Override + public int getDeviceId() { + return id; + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/README URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/README?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/README (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/device/README Thu Nov 12 22:26:29 2015 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +This is an example showing a Dependency Manager "Adapter" in action. Two kinds of services are +registered in the registry: some Device, and some DeviceParameter services. For each Device (having +a given id), there is also a corresponding "DeviceParameter" service, having the same id. + +Then a "DeviceAccessImpl" adapter service is defined: it is used to "adapt" the "Device" service to +a "DeviceAccess" service, which provides the union of each pair of Device/DeviceParameter having the +same device.id . The adapter also dynamically propagate the service properties of the adapted Device +service. + +So see logs, just type this command under gogo shell: + +g! log info|grep device.api + Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/Activator.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/Activator.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/Activator.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/Activator.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +import static org.apache.felix.service.command.CommandProcessor.COMMAND_FUNCTION; +import static org.apache.felix.service.command.CommandProcessor.COMMAND_SCOPE; + +import org.apache.felix.dm.builder.java.DependencyActivatorBase; +import org.osgi.service.log.LogService; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class Activator extends DependencyActivatorBase { + @Override + public void init() throws Exception { + // Create the factory configuration for our DictionaryImpl service. + factoryPidAdapter(comp -> comp + .factoryPid(DictionaryConfiguration.class).onUpdate(DictionaryImpl::updated).propagate() + .provides(DictionaryService.class) + .impl(DictionaryImpl.class) + .withService(LogService.class, dep -> dep.required(false))); + + // Create the Dictionary Aspect + aspect(DictionaryService.class, asp -> asp + .filter("(lang=en)").rank(10).impl(DictionaryAspect.class) + .withConfiguration(conf -> conf.pid(DictionaryAspectConfiguration.class).onUpdate(DictionaryAspect::addWords)) + .withService(LogService.class, srv -> srv.required(false))); + + // Create the SpellChecker component + component(comp -> comp + .provides(SpellChecker.class) + .properties(COMMAND_SCOPE, "dictionary", COMMAND_FUNCTION, new String[] {"spellcheck"}) + .impl(SpellChecker.class) + .withService(DictionaryService.class, srv -> srv.required()) + .withService(LogService.class, srv -> srv.required(false))); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspect.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspect.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspect.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspect.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless + * required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +import java.util.Dictionary; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.osgi.service.log.LogService; + +import aQute.bnd.annotation.metatype.Configurable; + +/** + * This aspect applies to the English DictionaryService, and allows to decorate it with some + * custom English words, which are configurable from WebConsole. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class DictionaryAspect implements DictionaryService { + /** + * This is the service this aspect is applying to. + */ + private volatile DictionaryService m_originalDictionary; + + /** + * We store all configured words in a thread-safe data structure, because ConfigAdmin may + * invoke our updated method at any time. + */ + private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>(); + + /** + * We'll use the OSGi log service for logging. If no log service is available, then we'll + * use a NullObject. + */ + private LogService m_log; + + /** + * Defines a configuration dependency for retrieving our english custom words (by default, + * our PID is our full class name). + */ + protected void addWords(Dictionary<String, ?> config) { + if (config != null) { + // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface. + DictionaryConfiguration cnf = Configurable.createConfigurable(DictionaryConfiguration.class, config); + m_words.clear(); + for (String word : cnf.words()) { + m_words.add(word); + } + } + } + + /** + * Our Aspect Service is starting and is about to be registered in the OSGi regsitry. + */ + protected void start() { + m_log.log(LogService.LOG_INFO, "Starting aspect Dictionary with words: " + m_words + + "; original dictionary service=" + m_originalDictionary); + } + + /** + * Checks if a word is found from our custom word list. if not, delegate to the decorated + * dictionary. + */ + public boolean checkWord(String word) { + m_log.log(LogService.LOG_INFO, "DictionaryAspect: checking word " + word + " (original dictionary=" + + m_originalDictionary + ")"); + if (m_words.contains(word)) { + return true; + } + return m_originalDictionary.checkWord(word); + } + + public String toString() { + return "DictionaryAspect: words=" + m_words + "; original dictionary=" + m_originalDictionary; + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspectConfiguration.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspectConfiguration.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspectConfiguration.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryAspectConfiguration.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +import java.util.List; + +import aQute.bnd.annotation.metatype.Meta.AD; +import aQute.bnd.annotation.metatype.Meta.OCD; + +/** + * This interface describes the configuration for our DictionaryAspect component. We are using the bnd metatype + * annotations, allowing to configure our Dictionary Services from web console. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +@OCD(name="Spell Checker Aspect Dictionary (api)", + description = "Declare here the list of english words to be added into the default english dictionary") +public interface DictionaryAspectConfiguration { + @AD(description = "Dictionary aspect words") + List<String> words(); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryConfiguration.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryConfiguration.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryConfiguration.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryConfiguration.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +import java.util.List; + +import aQute.bnd.annotation.metatype.Meta.AD; +import aQute.bnd.annotation.metatype.Meta.OCD; + +/** + * This interface describes the configuration for our DictionaryImpl component. We are using the bnd metatype + * annotations, allowing to configure our Dictionary Services from web console. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +@OCD(name="Spell Checker Dictionary (api)", + factory = true, + description = "Declare here some Dictionary instances, allowing to instantiates some DictionaryService services for a given dictionary language") +public interface DictionaryConfiguration { + @AD(description = "Describes the dictionary language", deflt = "en") + String lang(); + + @AD(description = "Declare here the list of words supported by this dictionary.") + List<String> words(); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryImpl.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryImpl.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryImpl.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryImpl.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +import java.util.Dictionary; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.osgi.service.log.LogService; + +import aQute.bnd.annotation.metatype.Configurable; + +/** + * A Dictionary Service, instantiated from webconsole, when you add some configurations instances to the + * DictionaryConfiguration factory pid. The Configuration metatype informations is described using the + * bnd metatype information (see the DictionaryConfiguration interface). + * + * You must configure at least one Dictionary from web console, since the SpellCheck won't start if no Dictionary + * Service is available. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class DictionaryImpl implements DictionaryService { + /** + * The key of our config admin dictionary values. + */ + final static String WORDS = "words"; + + /** + * We store all configured words in a thread-safe data structure, because ConfigAdmin + * may invoke our updated method at any time. + */ + private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>(); + + /** + * We'll use the OSGi log service for logging. If no log service is available, then we'll use a NullObject. + */ + private LogService m_log; + + /** + * Our Dictionary language. + */ + private String m_lang; + + /** + * Our service will be initialized from ConfigAdmin. + * @param config The configuration where we'll lookup our words list (key=".words"). + */ + protected void updated(Dictionary<String, ?> config) { + if (config != null) { + // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface. + DictionaryConfiguration cnf = Configurable.createConfigurable(DictionaryConfiguration.class, config); + + m_lang = cnf.lang(); + m_words.clear(); + for (String word : cnf.words()) { + m_words.add(word); + } + } + } + + /** + * A new Dictionary Service is starting (because a new factory configuration has been created + * from webconsole). + */ + protected void start() { + m_log.log(LogService.LOG_INFO, "Starting Dictionary Service with language: " + m_lang); + } + + /** + * Check if a word exists if the list of words we have been configured from ConfigAdmin/WebConsole. + */ + public boolean checkWord(String word) { + return m_words.contains(word); + } + + @Override + public String toString() { + return "Dictionary: language=" + m_lang + ", words=" + m_words; + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryService.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryService.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryService.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/DictionaryService.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +/** + * A simple service interface that defines a dictionary service. A dictionary + * service simply verifies the existence of a word. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public interface DictionaryService { + /** + * Check for the existence of a word. + * + * @param word the word to be checked. + * @return true if the word is in the dictionary, false otherwise. + */ + public boolean checkWord(String word); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/README URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/README?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/README (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/README Thu Nov 12 22:26:29 2015 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +This sample shows a "SpellChecker" application (using DM API) which provides a +"dictionary:spellcheck" GOGO shell command. The GOGO "dictionary:spellcheck" command accepts a +string as parameter, which is checked for proper existence. The SpellChecker class has a +required/multiple (1..N) dependency over every available "DictionaryService" services, which are +internally used by the SpellChecker command, when checking word existence. + +A DictionaryService is defined using a FactoryConfigurationAdapterService , allowing to instantiate +many "DictionaryService" instances when some configurations are added to the +"Spell Checker Configuration (api)" factory pid from web +console. The factory pid configuration metatypes are defined using the bnd "metatype" annotations +(see DictionaryConfiguration.java). + +The DictionaryService is decorated with a DictionaryAspect, which you can instantiate by adding a +configuration to the "Spell Checker Aspect Dictionary (api)" pid from web console. The +aspect configuration metatype is also declared using the bnd metatype annotations (see +DictionaryAspectConfiguration.java). + +Before running this sample, go to webconsole, and add some words in the Spell Checker Configuration (api) factory PID, and +in the Spell Checker Aspect Dictionary (api) PID. + +Then go to gogo shell, and type dm help. You will normally see the dictionary:spellcheck command. +Type dictionary:spellcheck <some words configured either in the spell checker configuration, or in the spell checker aspect configuration, +and the dictionary will check for proper word existance in the configuration. + Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/SpellChecker.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/SpellChecker.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/SpellChecker.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/dictionary/SpellChecker.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.dictionary; + +import java.util.concurrent.ConcurrentLinkedQueue; + +import org.apache.felix.service.command.Descriptor; +import org.osgi.service.log.LogService; + +/** + * Felix "spellcheck" Gogo Shell Command. This command allows to check if some given words are valid or not. + * This command will be activated only if (at least) one DictionaryService has been injected. + * To create a Dictionary Service, you have to go the the web console and add a configuration in the + * "Dictionary Configuration" factory pid. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class SpellChecker { + /** + * We'll use the OSGi log service for logging. If no log service is available, then we'll use a NullObject. + */ + private volatile LogService m_log; + + /** + * We'll store all Dictionaries in a concurrent list, in order to avoid method synchronization. + * (Auto-Injected from Activator, at any time). + */ + private final Iterable<DictionaryService> m_dictionaries = new ConcurrentLinkedQueue<>(); + + /** + * Lifecycle method callback, used to check if our service has been activated. + */ + protected void start() { + m_log.log(LogService.LOG_WARNING, "Spell Checker started"); + } + + /** + * Lifecycle method callback, used to check if our service has been activated. + */ + protected void stop() { + m_log.log(LogService.LOG_WARNING, "Spell Checker stopped"); + } + + // --- Gogo Shell command + + @Descriptor("checks if word is found from an available dictionary") + public void spellcheck(@Descriptor("the word to check") String word) { + m_log.log(LogService.LOG_INFO, "Checking spelling of word \"" + word + "\" using the following dictionaries: " + + m_dictionaries); + + for (DictionaryService dictionary : m_dictionaries) { + if (dictionary.checkWord(word)) { + System.out.println("word " + word + " is correct"); + return; + } + } + System.err.println("word " + word + " is incorrect"); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Activator.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Activator.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Activator.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Activator.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.factory; + +import org.apache.felix.dm.builder.java.DependencyActivatorBase; +import org.osgi.service.log.LogService; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class Activator extends DependencyActivatorBase { + @Override + public void init() throws Exception { + component(comp -> comp + .provides(Provider.class) + .factory(ProviderFactory::new, ProviderFactory::create) + .withService(LogService.class, srv -> srv.required().onAdd(ProviderImpl::set)) + .onStart(ProviderImpl::start)); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Provider.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Provider.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Provider.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/Provider.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.factory; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public interface Provider { +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderFactory.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderFactory.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderFactory.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderFactory.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,7 @@ +package org.apache.felix.dependencymanager.samples.factory; + +public class ProviderFactory { + public Object create() { + return new ProviderImpl(); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderImpl.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderImpl.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderImpl.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/ProviderImpl.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.factory; + +import org.osgi.service.log.LogService; + +/** + * This is the main implementation for our "Provider" service. + * This service is using a composition of two participants, which are used to provide the service + * (ProviderParticipant1, and ProviderParticipant2). + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class ProviderImpl implements Provider { + private volatile LogService m_log; + + void set(LogService log) { m_log = log; } + + void start() { + m_log.log(LogService.LOG_INFO, "ProviderImpl.start()"); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/README URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/README?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/README (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/factory/README Thu Nov 12 22:26:29 2015 @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +This sample is an example usage of DM composite components. A composite component is implemented +using a composition of multiple object instances, which are used to implement a given complex +service. Here, we define a "Provider" service, which is implemented by three object instances: +ProviderImpl, ProviderParticipant1, ProviderParticipant2. + +Dependencies are injected in all objects being part of the composition. + +To see logs, type this command under the gogo shell: + +g! log info|grep compositefactory Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Activator.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Activator.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Activator.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Activator.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.hello; + +import org.apache.felix.dm.builder.java.DependencyActivatorBase; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.log.LogService; + +/** + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class Activator extends DependencyActivatorBase { + void bind(ServiceProvider provider) { + System.out.println("Activator.bind(" + provider + ")"); + } + + @Override + public void init() throws Exception { + component(comp -> comp + .provides(ServiceProvider.class) + .onStart(ServiceProviderImpl::activate) + .properties("foo", "bar", "gabu", "zo") // foo=bar, gabu=zo + .impl(ServiceProviderImpl.class) + .withService(LogService.class, srv -> srv.onAdd(ServiceProviderImpl::bind))); + + component(comp -> comp + .impl(ServiceConsumer.class) + .withService(LogService.class) + .withService(ServiceProvider.class, srv -> srv.filter("(foo=bar)").onAdd(this::bind)) + .withConfiguration(conf -> conf.pid(ServiceConsumer.class).onUpdate(ServiceConsumer::updated))); + + component(comp -> comp.impl(Configurator.class).withService(ConfigurationAdmin.class)); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Configurator.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Configurator.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Configurator.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/Configurator.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,20 @@ +package org.apache.felix.dependencymanager.samples.hello; + +import java.io.IOException; +import java.util.Dictionary; +import java.util.Hashtable; + +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +public class Configurator { + volatile ConfigurationAdmin m_cm; // injected by reflection. + + void start() throws IOException { + // Configure the ServiceConsumer component + Configuration c = m_cm.getConfiguration(ServiceConsumer.class.getName(), null); + Dictionary<String, Object> props = new Hashtable<>(); + props.put("foo", "bar"); + c.update(props); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/README URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/README?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/README (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/README Thu Nov 12 22:26:29 2015 @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +This sample provides a DM Activator declaring one service consumer and a service provider. The +ServiceConsumer is also depending on a configuration pid (see org.apache.felix.dependencymanager.samples.conf.Configurator). +To see logs, just type this under gogo shell: + +g! log info|grep hello.annot + Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceConsumer.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceConsumer.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceConsumer.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceConsumer.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.hello; + +import java.util.Dictionary; + +import org.osgi.service.log.LogService; + +/** + * Our service consumer. We depend on a ServiceProvider, and on a configuration. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class ServiceConsumer { + volatile ServiceProvider service; + volatile LogService log; + Dictionary<?, ?> conf; + + public void updated(Dictionary<String, Object> conf) { + this.conf = conf; + } + + public void start() { + log.log(LogService.LOG_INFO, "ServiceConsumer.start: calling service.hello()"); + this.service.hello(); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProvider.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProvider.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProvider.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProvider.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.hello; + +/** + * The interface for our service provider. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public interface ServiceProvider { + public void hello(); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProviderImpl.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProviderImpl.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProviderImpl.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/src/org/apache/felix/dependencymanager/samples/hello/ServiceProviderImpl.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.felix.dependencymanager.samples.hello; + +import org.osgi.service.log.LogService; + +/** + * The implementation for our service provider. + * + * @author <a href="mailto:[email protected]">Felix Project Team</a> + */ +public class ServiceProviderImpl implements ServiceProvider { + volatile LogService log; + + void bind(LogService log) { this.log = log; } + + void activate() { + log.log(LogService.LOG_INFO, "ServiceProviderImpl.start"); + } + + @Override + public void hello() { + log.log(LogService.LOG_INFO, "ServiceProviderImpl.hello"); + } +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/test/.gitignore URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java.samples/test/.gitignore?rev=1714132&view=auto ============================================================================== (empty) Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.classpath URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.classpath?rev=1714132&view=auto ============================================================================== Binary file - no diff available. Propchange: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.classpath ------------------------------------------------------------------------------ svn:mime-type = application/xml Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.gitignore URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.gitignore?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.gitignore (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.gitignore Thu Nov 12 22:26:29 2015 @@ -0,0 +1,3 @@ +/bin/ +/bin_test/ +/generated/ Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.project URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.project?rev=1714132&view=auto ============================================================================== Binary file - no diff available. Propchange: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/.project ------------------------------------------------------------------------------ svn:mime-type = application/xml Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/bnd.bnd URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/bnd.bnd?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/bnd.bnd (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/bnd.bnd Thu Nov 12 22:26:29 2015 @@ -0,0 +1,14 @@ +javac.source: 1.8 +javac.target: 1.8 +Bundle-Version: 1.0.0 +-buildpath: \ + org.apache.felix.dependencymanager;version=latest,\ + net.jodah.typetools;version=0.4.5,\ + osgi.core;version=6.0,\ + osgi.cmpn;version=6.0 +Private-Package: \ + org.apache.felix.dm.builder.java.impl +Export-Package: \ + org.apache.felix.dm.builder.java +-runfw: org.apache.felix.framework;version='[4.4.1,4.4.1]' +-runee: JavaSE-1.8 Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/.gitignore URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/.gitignore?rev=1714132&view=auto ============================================================================== (empty) Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AdapterBuilder.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AdapterBuilder.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AdapterBuilder.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AdapterBuilder.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,24 @@ +package org.apache.felix.dm.builder.java; + +/** + * Defines the interface for a DependencyManager adapter builder. + * + * Code example that adapts a "Device" service to an HttpServlet service. the adapter accepts a lambda that is provided with an AdapterBuilder + * + * <pre> {@code + * public class Activator extends DependencyActivatorBase { + * public void init() throws Exception { + * adapter(Device.class, builder -> builder + * .provides(HttpServlet.class).properties("alias", "/device").impl(DeviceServlet.class).onStart(DeviceServlet::activate); + * } + * }}</pre> + * + * @param <T> the adaptee service + * TODO: add javadoc + */ +public interface AdapterBuilder<T> extends ComponentBuilder<AdapterBuilder<T>>, ServiceCallbacksBuilder<T, AdapterBuilder<T>> { + AdapterBuilder<T> filter(String adapteeFilter); + AdapterBuilder<T> propagate(); + AdapterBuilder<T> propagate(boolean propagate); + AdapterBuilder<T> inject(String field); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AspectBuilder.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AspectBuilder.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AspectBuilder.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/AspectBuilder.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,26 @@ +package org.apache.felix.dm.builder.java; + +/** + * Defines the interface for a DependencyManager aspect builder. + * + * Code example that provides an aspect service for an English dictionary service: + * + * <pre> {@code + * public class Activator extends DependencyActivatorBase { + * public void init() throws Exception { + * aspect(DictionaryService.class, builder -> builder + * .filter("(lang=en)") + * .rank(10) + * .impl(DictionaryAspect.class) + * .withService(LogService.class, srv -> srv.required(false))); + * } + * }}</pre> + * + * @param <T> the aspect service + * + * TODO: javadoc + */ +public interface AspectBuilder<T> extends ComponentBuilder<AspectBuilder<T>>, ServiceCallbacksBuilder<T, AspectBuilder<T>> { + AspectBuilder<T> filter(String filter); + AspectBuilder<T> rank(int ranking); +} Added: felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/Callbacks.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/Callbacks.java?rev=1714132&view=auto ============================================================================== --- felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/Callbacks.java (added) +++ felix/sandbox/pderop/dependencymanager.builder.java/org.apache.felix.dependencymanager.builder.java/src/org/apache/felix/dm/builder/java/Callbacks.java Thu Nov 12 22:26:29 2015 @@ -0,0 +1,265 @@ +package org.apache.felix.dm.builder.java; + +import java.util.Dictionary; +import java.util.Map; + +import org.osgi.framework.ServiceReference; + +/** + * This class contains the definition of all possible method references that a component may define for dependency injections and + * lifecycle callbacks. + */ +public class Callbacks { + /** + * Defines a reference on a bind method from an object instance. The bind method takes a service parameter. + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface Service<T> { + /** + * Signature of the callback method + * @param service the service injected using the callback method + */ + void call(T service); + } + + /** + * Defines a reference on a bind method from an object instance. The bind method takes a service parameter, as well as a Map + * (for service properties). + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface ServiceMap<T> { + /** + * Signature of the callback method + * @param service the service injected using the callback method + * @param properties the service properties + */ + void call(T service, Map<String, Object> properties); + } + + /** + * Defines a method reference on a bind method from an object instance. The bind method takes a service parameter, as well as a Dictionary + * (for service properties). + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface ServiceDict<T> { + /** + * Signature of the callback method + * @param service the service injected using the callback method + * @param properties the service properties + */ + void call(T service, Dictionary<String, Object> properties); + } + + /** + * Defines a method reference on a bind method from an object instance. The bind method takes an OSGi service reference parameter. + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface Ref<T> { + /** + * Signature of the callback method + * @param service the service injected using the callback method + */ + void call(ServiceReference<T> service); + } + + /** + * Defines a method reference on a bind method from an object instance. The bind method takes a service, and the corresponding OSGi service reference. + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface ServiceRef<T> { + /** + * Signature of the callback method + * @param service the service injected using the callback method + * @param ref the corresponding OSGi service reference + */ + void call(T service, ServiceReference<T> ref); + } + + /** + * Defines a method reference on a DependencManager swap callback, using ServiceReference for service properties. + * @param <T> the type of the swapped service. + */ + @FunctionalInterface + public interface RefServiceRefService<T> { + /** + * Signature of the callback method + * @param oldRef the replaced service reference + * @param old the replaced service + * @param replaceRef the reference to the new service that replaces the old service + * @param replace the new service that replaces the old service + */ + void call(ServiceReference<T> oldRef, T old, ServiceReference<T> replaceRef, T replace); + } + + /** + * Defines a method reference on a DependencManager swap callback, using Map for service properties. + * @param <T> the type of the swapped service. + */ + @FunctionalInterface + public interface MapServiceMapService<T> { + /** + * Signature of the callback method + * @param oldProps the replaced service properties + * @param old the replaced service + * @param replaceProps the new service properties that replaces the old service + * @param replace the new service that replaces the old service + */ + void call(Map<String, Object> oldProps, T old, Map<String, Object> replaceProps, T replace); + } + + /** + * Defines a method reference on a DependencManager swap callback, using Dictionary for service properties. + * @param <T> the type of the swapped service. + */ + @FunctionalInterface + public interface DictServiceDictService<T> { + /** + * Signature of the callback method + * @param oldProps the replaced service properties + * @param old the replaced service + * @param replaceProps the new service properties that replaces the old service + * @param replace the new service that replaces the old service + */ + void call(Dictionary<String, Object> oldProps, T old, Dictionary<String, Object> replaceProps, T replace); + } + + /** + * Defines a method reference on a class method, without the instance. The bind method takes an OSGi service as parameter. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface InstanceService<I, T> { + /** + * Signature of the callback method. + * @param instance the instance on which the callback has to be called + * @param service the service to inject in the instance method using this method reference + */ + void call(I instance, T service); + } + + /** + * Defines a method reference on a class method, without the instance. the bind method takes an OSGi service as parameter, and a Map + * for service properties. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the method parameter. + */ + @FunctionalInterface + public interface InstanceServiceMap<I, T> { + /** + * Signature of the callback method. + * @param instance the instance on which the callback has to be called + * @param service the service to inject in the instance method using this method reference + * @param properties the service properties + */ + void call(I instance, T service, Map<String, Object> properties); + } + + /** + * Defines a method reference on a class method, without the instance. the bind method takes an OSGi service as parameter, and a Dictionary + * for service properties. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the method parameter. + */ + @FunctionalInterface + public interface InstanceServiceDict<I, T> { + /** + * Signature of the callback method. + * @param instance the instance on which the callback has to be called + * @param service the service to inject in the instance method using this method reference + * @param properties the service properties + */ + void call(I instance, T service, Dictionary<String, Object> properties); + } + + /** + * Defines a method reference on a class method, without the instance. The bind method takes an OSGi service reference as parameter. + * for service properties. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface InstanceRef<I, T> { + /** + * Signature of the callback method. + * @param instance the instance on which the callback has to be called + * @param service the service to inject in the instance method using this method reference + */ + void call(I instance, ServiceReference<T> service); + } + + /** + * Defines a method reference on a class method, without the instance. The bind method takes a Service, and the corresponding service reference. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface InstanceServiceRef<I, T> { + /** + * Signature of the callback method. + * @param instance the instance on which the callback has to be called + * @param service the service to inject in the instance method using this method reference + * @param ref the service reference + */ + void call(I instance, T service, ServiceReference<T> ref); + } + + /** + * Defines a method reference on a DependencyManager swap callback, without the instance. The bind method takes a ServiceReference, a Service, a ServiceReference, and a Service. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface InstanceRefServiceRefService<I, T> { + /** + * Signature of the callback method + * @param instance the instance on which the callback has to be called + * @param oldRef the replaced service reference + * @param old the replaced service + * @param replaceRef the reference to the new service that replaces the old service + * @param replace the new service that replaces the old service + */ + void call(I instance, ServiceReference<T> oldRef, T old, ServiceReference<T> replaceRef, T replace); + } + + /** + * Defines a method reference on a DependencyManager swap callback, without the instance. The bind method takes a Map, a Service, a Map, and a Service. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface InstanceMapServiceMapService<I, T> { + /** + * Signature of the callback method + * @param instance the instance on which the callback has to be called + * @param oldProps the replaced service properties + * @param old the replaced service + * @param replaceProps the new service properties that replaces the old service + * @param replace the new service that replaces the old service + */ + void call(I instance, Map<String, Object> oldProps, T old, Map<String, Object> replaceProps, T replace); + } + + /** + * Defines a method reference on a DependencyManager swap callback, without the instance. The bind method takes a Dictionary, a Service, a Dictionary, and a Service. + * @param <I> the type of the instance on which this method reference is applied + * @param <T> the type of the parameter passed to the callback method. + */ + @FunctionalInterface + public interface InstanceDictServiceDictService<I, T> { + /** + * Signature of the callback method + * @param instance the instance on which the callback has to be called + * @param oldProps the replaced service properties + * @param old the replaced service + * @param replaceProps the new service properties that replaces the old service + * @param replace the new service that replaces the old service + */ + void call(I instance, Dictionary<String, Object> oldProps, T old, Dictionary<String, Object> replaceProps, T replace); + } +}
