01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: */package org.codehaus.xfire.aegis.inheritance.ws2.impl;
19:
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: import org.codehaus.xfire.aegis.inheritance.ws2.WS2;
24: import org.codehaus.xfire.aegis.inheritance.ws2.common.ParentBean;
25: import org.codehaus.xfire.aegis.inheritance.ws2.common.exception.AlreadyExistsException;
26: import org.codehaus.xfire.aegis.inheritance.ws2.common.exception.NotFoundException;
27: import org.codehaus.xfire.aegis.inheritance.ws2.common.pack1.ContentBean1;
28: import org.codehaus.xfire.aegis.inheritance.ws2.common.pack2.ContentBean2;
29:
30: /**
31: * <br/>
32: *
33: * @author xfournet
34: */
35: public class WS2Impl implements WS2 {
36: private Map<String, ParentBean> map = new HashMap<String, ParentBean>();
37:
38: public WS2Impl() {
39: ParentBean x = new ParentBean("X", new ContentBean1("data1-X"));
40: ParentBean y = new ParentBean("Y", new ContentBean2("data1-Y",
41: "content2-Y"));
42: map.put(x.getId(), x);
43: map.put(y.getId(), y);
44: }
45:
46: public synchronized void putParentBean(ParentBean parentBean)
47: throws AlreadyExistsException {
48: String id = parentBean.getId();
49: if (map.containsKey(id)) {
50: throw new AlreadyExistsException(id);
51: }
52: map.put(id, parentBean);
53: }
54:
55: public synchronized ParentBean getParentBean(String id)
56: throws NotFoundException {
57: ParentBean result = map.get(id);
58: if (result == null) {
59: throw new NotFoundException(id);
60: }
61:
62: return result;
63: }
64: }
|