-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> | ||
<classpathentry kind="src" path="resources"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> | ||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>hello.client</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.maven.ide.eclipse.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.maven.ide.eclipse.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Mon May 28 18:40:50 CST 2012 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Mon May 28 18:40:50 CST 2012 | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
fullBuildGoals=process-test-resources | ||
resolveWorkspaceProjects=true | ||
resourceFilterGoals=process-resources resources\:testResources | ||
skipCompilerPlugin=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>iPOJOTutorial</groupId> | ||
<artifactId>hello.client</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>bundle</packaging> | ||
|
||
<name>hello.client</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> <!-- Compilation (i.e. class) dependency on the service interface --> | ||
<groupId>iPOJOTutorial</groupId> | ||
<artifactId>hello.service</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>1.4.3</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> | ||
<Private-Package>ipojo.example.hello.client</Private-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-ipojo-plugin</artifactId> | ||
<version>1.2.0</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>ipojo-bundle</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
72 changes: 72 additions & 0 deletions
72
hello.client/src/main/java/ipojo/example/hello/client/HelloClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package ipojo.example.hello.client; | ||
|
||
import ipojo.example.hello.Hello; | ||
|
||
/** | ||
* Hello Service simple client. | ||
* | ||
* @author <a href="mailto:[email protected]">Felix Project Team</a> | ||
*/ | ||
public class HelloClient implements Runnable { | ||
|
||
/** | ||
* Delay between two invocations. | ||
*/ | ||
private static final int DELAY = 10000; | ||
|
||
/** | ||
* Hello services. Injected by the container. | ||
* */ | ||
private Hello[] m_hello; // Service Requirement | ||
|
||
/** | ||
* End flag. | ||
* */ | ||
private boolean m_end; | ||
|
||
/** | ||
* Name property. Injected by the container. | ||
* */ | ||
private String m_name; | ||
|
||
/** | ||
* Run method. | ||
* | ||
* @see java.lang.Runnable#run() | ||
*/ | ||
public void run() { | ||
while (!m_end) { | ||
try { | ||
invokeHelloServices(); | ||
Thread.sleep(DELAY); | ||
} catch (InterruptedException ie) { | ||
/* will recheck end */ | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Invoke hello services. | ||
*/ | ||
public void invokeHelloServices() { | ||
for (int i = 0; i < m_hello.length; i++) { | ||
System.out.println(m_hello[i].sayHello(m_name)); | ||
} | ||
} | ||
|
||
/** | ||
* Starting. | ||
*/ | ||
public void starting() { | ||
Thread thread = new Thread(this); | ||
m_end = false; | ||
thread.start(); | ||
} | ||
|
||
/** | ||
* Stopping. | ||
*/ | ||
public void stopping() { | ||
m_end = true; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
hello.client/src/main/java/ipojo/example/hello/client/SpellCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ipojo.example.hello.client; | ||
|
||
import ipojo.example.hello.DictionaryService; | ||
import ipojo.example.hello.SpellChecker; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.StringTokenizer; | ||
|
||
public class SpellCheck implements SpellChecker { | ||
private DictionaryService m_dictionary; | ||
|
||
/** | ||
* Implements SpellChecker.check(). Checks the given passage for misspelled | ||
* words. | ||
* | ||
* @param passage | ||
* the passage to spell check. | ||
* @return An array of misspelled words or null if no words are misspelled. | ||
*/ | ||
public String[] check(String passage) { | ||
// No misspelled words for an empty string. | ||
if ((passage == null) || (passage.length() == 0)) { | ||
return null; | ||
} | ||
List errorList = new ArrayList(); | ||
// Tokenize the passage using spaces and punctuation. | ||
StringTokenizer st = new StringTokenizer(passage, " ,.!?;:"); | ||
// Loop through each word in the passage. | ||
while (st.hasMoreTokens()) { | ||
String word = st.nextToken(); | ||
// Check the current word. | ||
if (!m_dictionary.checkWord(word)) { | ||
// If the word is not correct, then add it | ||
// to the incorrect word list. | ||
errorList.add(word); | ||
} | ||
} | ||
// Return null if no words are incorrect. | ||
if (errorList.size() == 0) { | ||
return null; | ||
} | ||
// Return the array of incorrect words. | ||
return (String[]) errorList.toArray(new String[errorList.size()]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd" | ||
xmlns="org.apache.felix.ipojo"> | ||
<component classname="ipojo.example.hello.client.SpellCheck"> | ||
<requires field="m_dictionary" /> | ||
<provides /> | ||
</component> | ||
<instance component="ipojo.example.hello.client.SpellCheck" /> | ||
</ipojo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
java -jar bin\felix.jar | ||
start file:D:/may/sDrive/hello.service/target/hello.service-1.0.0.jar | ||
start file:D:/may/sDrive/hello.impl/target/hello.impl-1.0.0.jar | ||
start file:D:/may/sDrive/hello.client/target/hello.client-1.0.0.jar | ||
start file:D:/may/sDrive/hello.client.gui/target/hello.client.gui-1.0.0.jar |
Binary file not shown.