Skip to content

Commit 7ab6e94

Browse files
author
Andrew Swan
authored
Fix service-based and extender-based sample projects (apache#114)
* Made inner Circle class static in service-based demo project * Fixed Javadoc errors in sample project * Removed redundant modifiers from SimpleShape interfaces in sample project * Added license comment to source file to fix build failure about unlicensed files * Fixed typos in comment and private method name * Updated version numbers and parent coordinates in demo project to fix build errors
1 parent e92f67c commit 7ab6e94

File tree

8 files changed

+42
-21
lines changed

8 files changed

+42
-21
lines changed

examples/extenderbased.host/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
<dependency>
3737
<groupId>org.apache.felix</groupId>
3838
<artifactId>org.apache.felix.framework</artifactId>
39-
<version>4.0.2</version>
39+
<version>7.0.1</version>
4040
</dependency>
4141
</dependencies>
4242
<build>
4343
<plugins>
4444
<plugin>
4545
<groupId>org.apache.felix</groupId>
4646
<artifactId>maven-bundle-plugin</artifactId>
47-
<version>1.4.0</version>
47+
<version>5.1.2</version>
4848
<extensions>true</extensions>
4949
<configuration>
5050
<instructions>
@@ -63,8 +63,8 @@
6363
<groupId>org.apache.maven.plugins</groupId>
6464
<artifactId>maven-compiler-plugin</artifactId>
6565
<configuration>
66-
<source>1.6</source>
67-
<target>1.6</target>
66+
<source>1.8</source>
67+
<target>1.8</target>
6868
</configuration>
6969
</plugin>
7070
</plugins>

examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/ShapeBundleTracker.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.apache.felix.example.extenderbased.host;
220

321
import java.util.Dictionary;
@@ -59,7 +77,7 @@ public SimpleShape addingBundle(Bundle bundle, BundleEvent event)
5977
return shape;
6078
}
6179

62-
// bundle is no ShapeBundle, ingore it
80+
// bundle is no ShapeBundle, ignore it
6381
return null;
6482
}
6583

@@ -107,7 +125,7 @@ public void removedBundle(Bundle bundle, BundleEvent event, SimpleShape object)
107125
// if the name is not null, bundle is a ShapeBundle
108126
if (name != null)
109127
{
110-
prcoessRemove(name);
128+
processRemove(name);
111129
}
112130
}
113131

@@ -116,7 +134,7 @@ public void removedBundle(Bundle bundle, BundleEvent event, SimpleShape object)
116134
*
117135
* @param name the name of the shape that is about to be removed.
118136
*/
119-
private void prcoessRemove(final String name)
137+
private void processRemove(final String name)
120138
{
121139
try
122140
{

examples/extenderbased.host/src/main/java/org/apache/felix/example/extenderbased/host/extension/SimpleShape.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,22 @@ public interface SimpleShape
3838
/**
3939
* A property for the name of the shape.
4040
**/
41-
public static final String NAME_PROPERTY = "Extension-Name";
41+
String NAME_PROPERTY = "Extension-Name";
42+
4243
/**
4344
* A property for the icon of the shape.
4445
**/
45-
public static final String ICON_PROPERTY = "Extension-Icon";
46+
String ICON_PROPERTY = "Extension-Icon";
47+
4648
/**
4749
* A property for the class of the shape.
4850
**/
49-
public static final String CLASS_PROPERTY = "Extension-Class";
51+
String CLASS_PROPERTY = "Extension-Class";
5052

5153
/**
5254
* Method to draw the shape of the extension.
5355
* @param g2 The graphics object used for painting.
5456
* @param p The position to paint the triangle.
5557
**/
56-
public void draw(Graphics2D g2, Point p);
58+
void draw(Graphics2D g2, Point p);
5759
}

examples/extenderbased.square/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
<parent>
2222
<groupId>org.apache.felix</groupId>
23-
<artifactId>felix</artifactId>
24-
<version>1.0.4</version>
23+
<artifactId>felix-parent</artifactId>
24+
<version>7</version>
2525
<relativePath>../../pom/pom.xml</relativePath>
2626
</parent>
2727

examples/servicebased.circle/src/main/java/org/apache/felix/example/servicebased/circle/Activator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void stop(BundleContext context)
7070
* This inner class implements the circle <tt>SimpleShape</tt> service.
7171
* It simply provides a <tt>draw()</tt> that paints a circle.
7272
**/
73-
public class Circle implements SimpleShape
73+
public static class Circle implements SimpleShape
7474
{
7575
/**
7676
* Implements the <tt>SimpleShape.draw()</tt> method for painting

examples/servicebased.host/src/main/java/org/apache/felix/example/servicebased/host/DefaultShape.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
* objects in an effort to improve performance; this level of
3737
* indirection could be removed if eager creation of objects is not
3838
* a concern. Since this application uses the service-based extension
39-
* appraoch, lazy shape creation will only come into effect if
39+
* approach, lazy shape creation will only come into effect if
4040
* service providers register service factories instead of directly
4141
* registering <tt>SimpleShape</tt> or if they use a technology like
4242
* Declarative Services or iPOJO to register services. Since the
43-
* example providers register services instances directly there is
43+
* example providers register service instances directly there is
4444
* no laziness in the example, but the proxy approach is still used
4545
* to demonstrate how to make laziness possible and to keep it
4646
* similar to the extender-based approach.

examples/servicebased.host/src/main/java/org/apache/felix/example/servicebased/host/ShapeTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/**
2929
* Extends the <tt>ServiceTracker</tt> to create a tracker for
3030
* <tt>SimpleShape</tt> services. The tracker is responsible for
31-
* listener for the arrival/departure of <tt>SimpleShape</tt>
31+
* listening for the arrival/departure of <tt>SimpleShape</tt>
3232
* services and informing the application about the availability
3333
* of shapes. This tracker forces all notifications to be processed
3434
* on the Swing event thread to avoid synchronization and redraw

examples/servicebased.host/src/main/java/org/apache/felix/example/servicebased/host/service/SimpleShape.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ public interface SimpleShape
3636
/**
3737
* A service property for the name of the shape.
3838
**/
39-
public static final String NAME_PROPERTY = "simple.shape.name";
39+
String NAME_PROPERTY = "simple.shape.name";
40+
4041
/**
4142
* A service property for the icon of the shape.
4243
**/
43-
public static final String ICON_PROPERTY = "simple.shape.icon";
44+
String ICON_PROPERTY = "simple.shape.icon";
4445

4546
/**
4647
* Method to draw the shape of the service.
4748
* @param g2 The graphics object used for painting.
48-
* @param p The position to paint the triangle.
49+
* @param p The position to paint the shape.
4950
**/
50-
public void draw(Graphics2D g2, Point p);
51+
void draw(Graphics2D g2, Point p);
5152
}

0 commit comments

Comments
 (0)