You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ak...@apache.org on 2006/03/07 06:18:59 UTC
svn commit: r383788 - in /incubator/felix/trunk: ./
org.apache.felix.examples.dictionaryservice/
org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/
org.apache.felix.examples.dictionaryservice/src/main...
Author: akarasulu
Date: Mon Mar 6 21:18:57 2006
New Revision: 383788
URL: http://svn.apache.org/viewcvs?rev=383788&view=rev
Log:
checking in second example in tutorial using the maven-osgi-plugin
Added:
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/
- copied from r383778, incubator/felix/trunk/org.apache.felix.examples.eventlistener/
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/DictionaryService.java
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/impl/
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/impl/Activator.java
Removed:
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/eventlistener/
Modified:
incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/pom.xml
incubator/felix/trunk/pom.xml
Modified: incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/pom.xml?rev=383788&r1=383778&r2=383788&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/pom.xml (original)
+++ incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/pom.xml Mon Mar 6 21:18:57 2006
@@ -6,8 +6,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>osgi-bundle</packaging>
- <name>Apache Felix Examples: Service Event Listener</name>
- <artifactId>org.apache.felix.examples.eventlistener</artifactId>
+ <name>Apache Felix Examples: English Dictionary Service</name>
+ <artifactId>org.apache.felix.examples.dictionaryservice</artifactId>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
@@ -25,16 +25,17 @@
<extensions>true</extensions>
<configuration>
<osgiManifest>
- <bundleName>Service listener example</bundleName>
+ <bundleName>English Dictionary Example</bundleName>
+ <bundleVendor>Apache Software Foundation</bundleVendor>
<bundleDescription>
- Bundle listening for service events: displays a message on startup and when service events occur.
+ A bundle that registersan English dictionary service.
</bundleDescription>
<bundleActivator>
- org.apache.felix.examples.eventlistener.Activator
+ org.apache.felix.examples.dictionaryservice.impl.Activator
</bundleActivator>
- <bundleSymbolicName>
- org.apache.felix.examples.eventlistener
- </bundleSymbolicName>
+ <exportPackage>
+ org.apache.felix.examples.dictionaryservice
+ </exportPackage>
</osgiManifest>
</configuration>
</plugin>
Added: incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/DictionaryService.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/DictionaryService.java?rev=383788&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/DictionaryService.java (added)
+++ incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/DictionaryService.java Mon Mar 6 21:18:57 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.felix.examples.dictionaryservice;
+
+
+/**
+ * A simple service interface that defines a dictionary service. A dictionary
+ * service simply verifies the existence of a word.
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">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: incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/impl/Activator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/impl/Activator.java?rev=383788&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/impl/Activator.java (added)
+++ incubator/felix/trunk/org.apache.felix.examples.dictionaryservice/src/main/java/org/apache/felix/examples/dictionaryservice/impl/Activator.java Mon Mar 6 21:18:57 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.felix.examples.dictionaryservice.impl;
+
+
+import java.util.Properties;
+
+import org.apache.felix.examples.dictionaryservice.DictionaryService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * This class implements a simple bundle that uses the bundle context to
+ * register an English language dictionary service with the OSGi framework. The
+ * dictionary service interface is defined in a separate class file and is
+ * implemented by an inner class.
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class Activator implements BundleActivator
+{
+ /**
+ * Implements BundleActivator.start(). Registers an instance of a dictionary
+ * service using the bundle context; attaches properties to the service that
+ * can be queried when performing a service look-up.
+ *
+ * @param context the framework context for the bundle.
+ */
+ public void start( BundleContext context )
+ {
+ Properties props = new Properties();
+ props.put( "Language", "English" );
+ context.registerService( DictionaryService.class.getName(), new DictionaryImpl(), props );
+ }
+
+
+ /**
+ * Implements BundleActivator.stop(). Does nothing since the framework will
+ * automatically unregister any registered services.
+ *
+ * @param context the framework context for the bundle.
+ */
+ public void stop( BundleContext context )
+ {
+ // NOTE: The service is automatically unregistered.
+ }
+
+
+ /**
+ * A private inner class that implements a dictionary service; see
+ * DictionaryService for details of the service.
+ */
+ private static class DictionaryImpl implements DictionaryService
+ {
+ // The set of words contained in the dictionary.
+ String[] m_dictionary = { "welcome", "to", "the", "osgi", "tutorial" };
+
+ /**
+ * Implements DictionaryService.checkWord(). Determines if the passed in
+ * word is contained in the dictionary.
+ *
+ * @param word the word to be checked.
+ * @return true if the word is in the dictionary, false otherwise.
+ */
+ public boolean checkWord( String word )
+ {
+ word = word.toLowerCase();
+
+ // This is very inefficient
+ for ( int i = 0; i < m_dictionary.length; i++ )
+ {
+ if ( m_dictionary[i].equals( word ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
Modified: incubator/felix/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/pom.xml?rev=383788&r1=383787&r2=383788&view=diff
==============================================================================
--- incubator/felix/trunk/pom.xml (original)
+++ incubator/felix/trunk/pom.xml Mon Mar 6 21:18:57 2006
@@ -15,6 +15,7 @@
<module>org.apache.felix.daemon</module>
<module>org.apache.felix.main</module>
<module>org.apache.felix.examples.eventlistener</module>
+ <module>org.apache.felix.examples.dictionaryservice</module>
</modules>
<repositories>