summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/contrib
diff options
context:
space:
mode:
authorfmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68>2011-06-05 14:19:36 +0000
committerfmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68>2011-06-05 14:19:36 +0000
commit2f683d4b8bc2f7fcc872d93bc712e7514b6ee38e (patch)
tree53a52bbdf415138f73179332f163889e3aa28b23 /sca-java-2.x/contrib
parentdc3bc3775abbe9459fc6de3243470f2aae76ad37 (diff)
Replace the use of absolute path with relative path when using a file in the webapp.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1132415 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/contrib')
-rw-r--r--sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/CountryRepositoryImpl.java73
-rw-r--r--sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/resources/countries.txt (renamed from sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/countries.txt)0
-rw-r--r--sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/web.composite2
3 files changed, 38 insertions, 37 deletions
diff --git a/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/CountryRepositoryImpl.java b/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/CountryRepositoryImpl.java
index 736f919a12..65ac77723e 100644
--- a/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/CountryRepositoryImpl.java
+++ b/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/java/org/apache/tuscany/sca/sample/comet/CountryRepositoryImpl.java
@@ -20,8 +20,8 @@ package org.apache.tuscany.sca.sample.comet;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
@@ -39,44 +39,45 @@ import org.oasisopen.sca.annotation.Service;
@Service(CountryRepository.class)
public class CountryRepositoryImpl implements CountryRepository {
- @Context
- protected ComponentContext context;
+ @Context
+ protected ComponentContext context;
- private String fileName;
- private List<Country> countries;
+ private String fileName;
+ private List<Country> countries;
- @Constructor
- public CountryRepositoryImpl(@Property(name = "fileName") String fileName) {
- this.fileName = fileName;
- countries = new ArrayList<Country>();
- }
+ @Constructor
+ public CountryRepositoryImpl(@Property(name = "fileName") String fileName) {
+ this.fileName = fileName;
+ countries = new ArrayList<Country>();
+ }
- @Init
- public void start() {
- try {
- BufferedReader reader = new BufferedReader(new FileReader(fileName));
- String line;
- while ((line = reader.readLine()) != null) {
- Country c = new Country();
- c.setName(line);
- countries.add(c);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ @Init
+ public void start() {
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader()
+ .getResourceAsStream(fileName)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ Country c = new Country();
+ c.setName(line);
+ countries.add(c);
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
- @Override
- public List<Country> getStartingWith(String text) {
- List<Country> result = new ArrayList<Country>();
- for (Country c : countries) {
- if (c.getName().toLowerCase().startsWith(text.toLowerCase())) {
- result.add(c);
- }
- }
- return result;
- }
+ @Override
+ public List<Country> getStartingWith(String text) {
+ List<Country> result = new ArrayList<Country>();
+ for (Country c : countries) {
+ if (c.getName().toLowerCase().startsWith(text.toLowerCase())) {
+ result.add(c);
+ }
+ }
+ return result;
+ }
}
diff --git a/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/countries.txt b/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/resources/countries.txt
index 271bbd5dd1..271bbd5dd1 100644
--- a/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/countries.txt
+++ b/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/resources/countries.txt
diff --git a/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/web.composite b/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/web.composite
index e065902cb0..f7cee35452 100644
--- a/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/web.composite
+++ b/sca-java-2.x/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/web.composite
@@ -35,7 +35,7 @@
<component name="CountryRepositoryComponent">
<implementation.java
class="org.apache.tuscany.sca.sample.comet.CountryRepositoryImpl" />
- <property name="fileName">/home/fmoga/coding/apache-tuscany/contrib/samples/learning-more/binding-comet/single-response-webapp/src/main/webapp/WEB-INF/countries.txt</property>
+ <property name="fileName">countries.txt</property>
</component>
</composite> \ No newline at end of file