01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * 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, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.jee;
18:
19: import javax.xml.bind.annotation.*;
20: import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
21: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
22: import java.util.ArrayList;
23: import java.util.List;
24: import java.util.Map;
25: import java.util.LinkedHashMap;
26:
27: /**
28: * The interceptorsType element declares one or more interceptor
29: * classes used by components within this ejb-jar. The declaration
30: * consists of :
31: * <p/>
32: * - An optional description.
33: * - One or more interceptor elements.
34: */
35: @XmlAccessorType(XmlAccessType.FIELD)
36: @XmlType(name="interceptorsType",propOrder={"description","interceptor"})
37: public class Interceptors {
38:
39: @XmlElement(required=true)
40: protected List<Text> description;
41:
42: @XmlTransient
43: protected Map<String, Interceptor> interceptors = new LinkedHashMap<String, Interceptor>();
44:
45: @XmlAttribute
46: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
47: @XmlID
48: protected String id;
49:
50: public List<Text> getDescription() {
51: if (description == null) {
52: description = new ArrayList<Text>();
53: }
54: return this .description;
55: }
56:
57: public String getId() {
58: return id;
59: }
60:
61: public void setId(String value) {
62: this .id = value;
63: }
64:
65: @XmlElement(name="interceptor",required=true)
66: public Interceptor[] getInterceptor() {
67: return interceptors.values().toArray(new Interceptor[] {});
68: }
69:
70: public void setInterceptor(Interceptor[] v) {
71: interceptors.clear();
72: for (Interceptor e : v)
73: addInterceptor(e);
74: }
75:
76: public Interceptor addInterceptor(Interceptor interceptor) {
77: interceptors
78: .put(interceptor.getInterceptorClass(), interceptor);
79: return interceptor;
80: }
81:
82: public Interceptor getInterceptor(String className) {
83: return interceptors.get(className);
84: }
85: }
|