|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractServiceDescriptor.java | 100% | 100% | 100% | 100% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.hivemind.parse; | |
16 | ||
17 | import java.util.ArrayList; | |
18 | import java.util.List; | |
19 | ||
20 | import org.apache.hivemind.util.ToStringBuilder; | |
21 | ||
22 | /** | |
23 | * Base class for {@link org.apache.hivemind.parse.ServicePointDescriptor} and | |
24 | * {@link org.apache.hivemind.parse.ImplementationDescriptor}. | |
25 | * | |
26 | * | |
27 | * @author Howard Lewis Ship | |
28 | */ | |
29 | public abstract class AbstractServiceDescriptor extends BaseAnnotationHolder | |
30 | { | |
31 | private InstanceBuilder _instanceBuilder; | |
32 | private List _interceptors; | |
33 | ||
34 | ||
35 | 2 | public String toString() |
36 | { | |
37 | 2 | ToStringBuilder builder = new ToStringBuilder(this); |
38 | ||
39 | 2 | extendDescription(builder); |
40 | ||
41 | 2 | builder.append("instanceBuilder", _instanceBuilder); |
42 | 2 | builder.append("interceptors", _interceptors); |
43 | ||
44 | 2 | return builder.toString(); |
45 | } | |
46 | ||
47 | /** | |
48 | * Implemented in subclasses to provide details about the instance. | |
49 | */ | |
50 | protected abstract void extendDescription(ToStringBuilder builder); | |
51 | ||
52 | 2617 | public InstanceBuilder getInstanceBuilder() |
53 | { | |
54 | 2617 | return _instanceBuilder; |
55 | } | |
56 | ||
57 | /** | |
58 | * A service extension may contribute one instance builder. | |
59 | */ | |
60 | 2620 | public void setInstanceBuilder(InstanceBuilder descriptor) |
61 | { | |
62 | 2620 | _instanceBuilder = descriptor; |
63 | } | |
64 | ||
65 | 66 | public void addInterceptor(InterceptorDescriptor interceptor) |
66 | { | |
67 | 66 | if (_interceptors == null) |
68 | 54 | _interceptors = new ArrayList(); |
69 | ||
70 | 66 | _interceptors.add(interceptor); |
71 | } | |
72 | ||
73 | /** | |
74 | * Returns a list of {@link InterceptorDescriptor}. May | |
75 | * return null. The caller should not modify the returned list. | |
76 | */ | |
77 | 2618 | public List getInterceptors() |
78 | { | |
79 | 2618 | return _interceptors; |
80 | } | |
81 | ||
82 | } |
|