From 1e13c75d5e366a71fffe3c67de53b5db2e7043f0 Mon Sep 17 00:00:00 2001 From: Scott England-Sullivan Date: Thu, 28 Mar 2013 13:36:05 -0500 Subject: [PATCH 4/4] KARAF-2257 Improvements: Delete example code. --- .../scr/examples/component/ManagedComponent.java | 84 ------------------- .../component/MetaTypeManagedComponent.java | 86 -------------------- .../component/MetaTypeManagedComponentConfig.java | 27 ------ .../scr/examples/component/SimpleComponent.java | 77 ----------------- .../karaf/scr/examples/service/ExampleService.java | 24 ------ .../service/provider/ExampleServiceProvider.java | 62 -------------- 6 files changed, 0 insertions(+), 360 deletions(-) delete mode 100644 scr/examples/src/main/java/org/apache/karaf/scr/examples/component/ManagedComponent.java delete mode 100644 scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponent.java delete mode 100644 scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponentConfig.java delete mode 100644 scr/examples/src/main/java/org/apache/karaf/scr/examples/component/SimpleComponent.java delete mode 100644 scr/examples/src/main/java/org/apache/karaf/scr/examples/service/ExampleService.java delete mode 100644 scr/examples/src/main/java/org/apache/karaf/scr/examples/service/provider/ExampleServiceProvider.java diff --git a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/ManagedComponent.java b/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/ManagedComponent.java deleted file mode 100644 index f70b076..0000000 --- a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/ManagedComponent.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.karaf.scr.examples.component; - -import java.util.Map; - -import org.apache.karaf.scr.examples.service.ExampleService; -import org.osgi.service.log.LogService; - -import aQute.bnd.annotation.component.Activate; -import aQute.bnd.annotation.component.Component; -import aQute.bnd.annotation.component.ConfigurationPolicy; -import aQute.bnd.annotation.component.Deactivate; -import aQute.bnd.annotation.component.Reference; - -@Component(name = ManagedComponent.COMPONENT_NAME, configurationPolicy = ConfigurationPolicy.require) -public class ManagedComponent { - - public static final String COMPONENT_NAME = "ManagedComponent"; - - public static final String COMPONENT_LABEL = "Example Managed Component"; - - private static final String COMPONENT_PROP_NAME = "name"; - - private static final String COMPONENT_PROP_SALUTATION = "salutation"; - - private LogService logService; - - private ExampleService exampleService; - - /** - * Called when all of the SCR Components required dependencies have been - * satisfied. - */ - @Activate - public void activate(final Map properties) { - logService.log(LogService.LOG_INFO, "Activating the " + COMPONENT_LABEL); - exampleService.setName((String) properties.get(COMPONENT_PROP_NAME)); - exampleService.setSalutation((String) properties.get(COMPONENT_PROP_SALUTATION)); - exampleService.printGreetings(); - } - - /** - * Called when any of the SCR Components required dependencies become - * unsatisfied. - */ - @Deactivate - public void deactivate() { - logService.log(LogService.LOG_INFO, "Deactivating the " + COMPONENT_LABEL); - } - - @Reference - public void setExampleService(final ExampleService exampleService) { - this.exampleService = exampleService; - } - - public void unsetExampleService(final ExampleService exampleService) { - this.exampleService = null; - } - - @Reference - protected void setLogService(LogService logService) { - this.logService = logService; - } - - protected void unsetLogService(LogService logService) { - this.logService = logService; - } - -} diff --git a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponent.java b/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponent.java deleted file mode 100644 index 6396b43..0000000 --- a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponent.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.karaf.scr.examples.component; - -import java.util.Map; - -import org.apache.karaf.scr.examples.service.ExampleService; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.log.LogService; - -import aQute.bnd.annotation.component.Activate; -import aQute.bnd.annotation.component.Component; -import aQute.bnd.annotation.component.Deactivate; -import aQute.bnd.annotation.component.Reference; -import aQute.bnd.annotation.metatype.Configurable; - -@Component(name = MetaTypeManagedComponent.COMPONENT_NAME, designateFactory = MetaTypeManagedComponentConfig.class) -public class MetaTypeManagedComponent { - - public static final String COMPONENT_NAME = "MetaTypeManagedComponent"; - - public static final String COMPONENT_LABEL = "Example Managed Component with MetaType"; - - private LogService logService; - - private ExampleService exampleService; - - /** - * Called when all of the SCR Components required dependencies have been - * satisfied. - */ - @Activate - public void activate(final Map properties, ComponentContext componentContext) { - logService.log(LogService.LOG_INFO, "Activating the " + COMPONENT_LABEL); - - MetaTypeManagedComponentConfig config = Configurable.createConfigurable(MetaTypeManagedComponentConfig.class, properties); - - exampleService.setName(config.name()); - exampleService.setSalutation(config.salutation()); - for (int i = 0; i < config.numberOfGreetings(); i++) { - exampleService.printGreetings(); - } - } - - /** - * Called when any of the SCR Components required dependencies become - * unsatisfied. - */ - @Deactivate - public void deactivate() { - logService.log(LogService.LOG_INFO, "Deactivating the " + COMPONENT_LABEL); - } - - @Reference - public void setExampleService(final ExampleService exampleService) { - this.exampleService = exampleService; - } - - public void unsetExampleService(final ExampleService exampleService) { - this.exampleService = null; - } - - @Reference - protected void setLogService(LogService logService) { - this.logService = logService; - } - - protected void unsetLogService(LogService logService) { - this.logService = null; - } - -} diff --git a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponentConfig.java b/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponentConfig.java deleted file mode 100644 index aa9b37b..0000000 --- a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/MetaTypeManagedComponentConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.karaf.scr.examples.component; - -public interface MetaTypeManagedComponentConfig { - - String name(); - - String salutation(); - - Integer numberOfGreetings(); - -} diff --git a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/SimpleComponent.java b/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/SimpleComponent.java deleted file mode 100644 index e974bea..0000000 --- a/scr/examples/src/main/java/org/apache/karaf/scr/examples/component/SimpleComponent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.karaf.scr.examples.component; - -import org.apache.karaf.scr.examples.service.ExampleService; -import org.osgi.service.log.LogService; - -import aQute.bnd.annotation.component.Activate; -import aQute.bnd.annotation.component.Component; -import aQute.bnd.annotation.component.Deactivate; -import aQute.bnd.annotation.component.Reference; - -@Component(name = SimpleComponent.COMPONENT_NAME) -public class SimpleComponent { - - public static final String COMPONENT_NAME = "SimpleComponent"; - - public static final String COMPONENT_LABEL = "Example Component"; - - private LogService logService; - - private ExampleService exampleService; - - /** - * Called when all of the SCR Components required dependencies have been - * satisfied. - */ - @Activate - public void activate() { - logService.log(LogService.LOG_INFO, "Activating the " + COMPONENT_LABEL); - exampleService.setName("Scott"); - exampleService.setSalutation("Hello"); - exampleService.printGreetings(); - } - - /** - * Called when any of the SCR Components required dependencies become - * unsatisfied. - */ - @Deactivate - public void deactivate() { - logService.log(LogService.LOG_INFO, "Deactivating the " + COMPONENT_LABEL); - } - - @Reference - public void setExampleService(final ExampleService exampleService) { - this.exampleService = exampleService; - } - - public void unsetExampleService(final ExampleService exampleService) { - this.exampleService = null; - } - - @Reference - protected void setLogService(LogService logService) { - this.logService = logService; - } - - protected void unsetLogService(LogService logService) { - this.logService = null; - } - -} diff --git a/scr/examples/src/main/java/org/apache/karaf/scr/examples/service/ExampleService.java b/scr/examples/src/main/java/org/apache/karaf/scr/examples/service/ExampleService.java deleted file mode 100644 index 9ed46af..0000000 --- a/scr/examples/src/main/java/org/apache/karaf/scr/examples/service/ExampleService.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed 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.karaf.scr.examples.service; - -public interface ExampleService { - - void printGreetings(); - - void setSalutation(String salutation); - - void setName(String name); - -} diff --git a/scr/examples/src/main/java/org/apache/karaf/scr/examples/service/provider/ExampleServiceProvider.java b/scr/examples/src/main/java/org/apache/karaf/scr/examples/service/provider/ExampleServiceProvider.java deleted file mode 100644 index b9c0251..0000000 --- a/scr/examples/src/main/java/org/apache/karaf/scr/examples/service/provider/ExampleServiceProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed 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.karaf.scr.examples.service.provider; - -import org.apache.karaf.scr.examples.service.ExampleService; -import org.osgi.service.log.LogService; - -import aQute.bnd.annotation.component.Component; -import aQute.bnd.annotation.component.Reference; - -@Component -public class ExampleServiceProvider implements ExampleService { - - public static final String COMPONENT_NAME = "ExampleServiceProvider"; - - public static final String COMPONENT_LABEL = "Example Service Consumer Component"; - - private LogService logService; - - private String name = "To whom it may concern"; - - private String salutation = "Hello"; - - public void printGreetings() { - logService.log(LogService.LOG_INFO, salutation + " " + name); - } - - /** - * @param salutation the salutation to set - */ - public void setSalutation(String salutation) { - this.salutation = salutation; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - @Reference - protected void setLogService(LogService logService) { - this.logService = logService; - } - - protected void unsetLogService(LogService logService) { - this.logService = logService; - } - -} -- 1.7.7.3