From 6d035581440fd2b5f037328ce092a44ec8bc28cc Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 23 Oct 2009 17:56:07 +0000 Subject: Adding missing source folder to expertise-rest sample git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@829150 13f79535-47bb-0310-9956-ffa450edef68 --- .../expertise/restfull/ExpertRegistryImpl.java | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 sandbox/sca-cloud-tutorial/expertise-rest-appengine-webapp/src/org/apache/tuscany/expertise/restfull/ExpertRegistryImpl.java (limited to 'sandbox/sca-cloud-tutorial/expertise-rest-appengine-webapp/src/org/apache/tuscany/expertise/restfull/ExpertRegistryImpl.java') diff --git a/sandbox/sca-cloud-tutorial/expertise-rest-appengine-webapp/src/org/apache/tuscany/expertise/restfull/ExpertRegistryImpl.java b/sandbox/sca-cloud-tutorial/expertise-rest-appengine-webapp/src/org/apache/tuscany/expertise/restfull/ExpertRegistryImpl.java new file mode 100644 index 0000000000..800dc101a0 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/expertise-rest-appengine-webapp/src/org/apache/tuscany/expertise/restfull/ExpertRegistryImpl.java @@ -0,0 +1,92 @@ +/* + * 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.tuscany.expertise.restfull; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.expertise.Expert; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; + +@Service(ExpertRegistry.class) +public class ExpertRegistryImpl implements ExpertRegistry { + private List experts = new ArrayList(); + + public ExpertRegistryImpl() { + + } + + @Init + public void init() { + Expert expert; + + expert = new Expert(); + expert.setId("1"); + expert.setName("John Smith"); + expert.setLocation("CA"); + expert.getExpertise().add("SOA"); + expert.getExpertise().add("SCA"); + expert.getExpertise().add("WAS"); + + experts.add(expert); + + expert = new Expert(); + expert.setId("2"); + expert.setName("Ken Johnson"); + expert.setLocation("NY"); + expert.getExpertise().add("Search"); + + experts.add(expert); + + expert = new Expert(); + expert.setId("3"); + expert.setName("Mark Smith"); + expert.setLocation("CA"); + expert.getExpertise().add("SCA"); + expert.getExpertise().add("WASCE"); + + experts.add(expert); + } + + public void addExpert(Expert expert) { + experts.add(expert); + } + + public void removeExpert(Expert expert) { + experts.remove(expert); + } + + public List getExperts() { + return experts; + } + + public List getExpertsByExpertise(String expertise) { + List expertsByExpertise = new ArrayList(); + + for (Expert expert : experts) { + if (expert.getExpertise().contains(expertise)) { + expertsByExpertise.add(expert); + } + } + + return expertsByExpertise; + } +} -- cgit v1.2.3