|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ServiceInterceptorContributionImpl.java | 75% | 100% | 100% | 97.8% |
|
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.impl;
|
|
16 |
|
|
17 |
import java.util.List;
|
|
18 |
|
|
19 |
import org.apache.hivemind.InterceptorStack;
|
|
20 |
import org.apache.hivemind.ServiceInterceptorFactory;
|
|
21 |
import org.apache.hivemind.internal.Module;
|
|
22 |
import org.apache.hivemind.internal.ServiceInterceptorContribution;
|
|
23 |
import org.apache.hivemind.internal.ServicePoint;
|
|
24 |
import org.apache.hivemind.schema.Schema;
|
|
25 |
import org.apache.hivemind.util.ToStringBuilder;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Implementation of {@link org.apache.hivemind.internal.ServiceInterceptorContribution}.
|
|
29 |
*
|
|
30 |
* @author Howard Lewis Ship
|
|
31 |
*/
|
|
32 |
|
|
33 |
public final class ServiceInterceptorContributionImpl extends BaseLocatable implements |
|
34 |
ServiceInterceptorContribution |
|
35 |
{ |
|
36 |
private String _factoryServiceId;
|
|
37 |
|
|
38 |
private Module _contributingModule;
|
|
39 |
|
|
40 |
private List _parameters;
|
|
41 |
|
|
42 |
private List _convertedParameters;
|
|
43 |
|
|
44 |
private ServiceInterceptorFactory _factory;
|
|
45 |
|
|
46 |
private String _precedingInterceptorIds;
|
|
47 |
|
|
48 |
private String _followingInterceptorIds;
|
|
49 |
|
|
50 |
private String _name;
|
|
51 |
|
|
52 | 1 |
public String toString()
|
53 |
{ |
|
54 | 1 |
ToStringBuilder builder = new ToStringBuilder(this); |
55 | 1 |
builder.append("factoryServiceId", _factoryServiceId);
|
56 | 1 |
builder.append("parameters", _parameters);
|
57 | 1 |
builder.append("precedingInterceptorIds", _precedingInterceptorIds);
|
58 | 1 |
builder.append("followingInterceptorIds", _followingInterceptorIds);
|
59 | 1 |
builder.append("name", _name );
|
60 | 1 |
return builder.toString();
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
/**
|
|
65 |
* @return Returns the name.
|
|
66 |
*/
|
|
67 | 26 |
public String getName()
|
68 |
{ |
|
69 | 26 |
if( _name == null ) |
70 |
{ |
|
71 | 24 |
return getFactoryServiceId();
|
72 |
} |
|
73 | 2 |
return _name;
|
74 |
} |
|
75 |
|
|
76 | 32 |
public void setName( String name ) |
77 |
{ |
|
78 | 32 |
_name = name; |
79 |
} |
|
80 |
|
|
81 | 28 |
public String getFactoryServiceId()
|
82 |
{ |
|
83 | 28 |
return _factoryServiceId;
|
84 |
} |
|
85 |
|
|
86 | 38 |
public void setFactoryServiceId(String string) |
87 |
{ |
|
88 | 38 |
_factoryServiceId = string; |
89 |
} |
|
90 |
|
|
91 | 18 |
public void createInterceptor(InterceptorStack stack) |
92 |
{ |
|
93 | 18 |
setup(); |
94 |
|
|
95 | 15 |
_factory.createInterceptor(stack, _contributingModule, _convertedParameters); |
96 |
} |
|
97 |
|
|
98 | 18 |
private synchronized void setup() |
99 |
{ |
|
100 | 18 |
if (_factory == null) |
101 |
{ |
|
102 | 18 |
ServicePoint factoryPoint = _contributingModule.getServicePoint(_factoryServiceId); |
103 |
|
|
104 | 18 |
_factory = (ServiceInterceptorFactory) factoryPoint |
105 |
.getService(ServiceInterceptorFactory.class);
|
|
106 |
|
|
107 | 15 |
Schema schema = factoryPoint.getParametersSchema(); |
108 |
|
|
109 | 15 |
SchemaProcessorImpl processor = new SchemaProcessorImpl(factoryPoint.getErrorLog(),
|
110 |
schema); |
|
111 |
|
|
112 | 15 |
processor.process(_parameters, _contributingModule); |
113 |
|
|
114 | 15 |
_convertedParameters = processor.getElements(); |
115 |
} |
|
116 |
} |
|
117 |
|
|
118 | 30 |
public void setContributingModule(Module module) |
119 |
{ |
|
120 | 30 |
_contributingModule = module; |
121 |
} |
|
122 |
|
|
123 | 30 |
public void setParameters(List list) |
124 |
{ |
|
125 | 30 |
_parameters = list; |
126 |
} |
|
127 |
|
|
128 | 24 |
public String getFollowingInterceptorIds()
|
129 |
{ |
|
130 | 24 |
return _followingInterceptorIds;
|
131 |
} |
|
132 |
|
|
133 | 24 |
public String getPrecedingInterceptorIds()
|
134 |
{ |
|
135 | 24 |
return _precedingInterceptorIds;
|
136 |
} |
|
137 |
|
|
138 | 32 |
public void setFollowingInterceptorIds(String string) |
139 |
{ |
|
140 | 32 |
_followingInterceptorIds = string; |
141 |
} |
|
142 |
|
|
143 | 30 |
public void setPrecedingInterceptorIds(String string) |
144 |
{ |
|
145 | 30 |
_precedingInterceptorIds = string; |
146 |
} |
|
147 |
|
|
148 |
} |
|