|
|||||||||||||||||||
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 | 50% | 100% | 100% | 97.2% |
|
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 | 1 |
public String toString()
|
51 |
{ |
|
52 | 1 |
ToStringBuilder builder = new ToStringBuilder(this); |
53 | 1 |
builder.append("factoryServiceId", _factoryServiceId);
|
54 | 1 |
builder.append("parameters", _parameters);
|
55 | 1 |
builder.append("precedingInterceptorIds", _precedingInterceptorIds);
|
56 | 1 |
builder.append("followingInterceptorIds", _followingInterceptorIds);
|
57 |
|
|
58 | 1 |
return builder.toString();
|
59 |
} |
|
60 |
|
|
61 | 22 |
public String getFactoryServiceId()
|
62 |
{ |
|
63 | 22 |
return _factoryServiceId;
|
64 |
} |
|
65 |
|
|
66 | 30 |
public void setFactoryServiceId(String string) |
67 |
{ |
|
68 | 30 |
_factoryServiceId = string; |
69 |
} |
|
70 |
|
|
71 | 18 |
public void createInterceptor(InterceptorStack stack) |
72 |
{ |
|
73 | 18 |
setup(); |
74 |
|
|
75 | 15 |
_factory.createInterceptor(stack, _contributingModule, _convertedParameters); |
76 |
} |
|
77 |
|
|
78 | 18 |
private synchronized void setup() |
79 |
{ |
|
80 | 18 |
if (_factory == null) |
81 |
{ |
|
82 | 18 |
ServicePoint factoryPoint = _contributingModule.getServicePoint(_factoryServiceId); |
83 |
|
|
84 | 18 |
_factory = (ServiceInterceptorFactory) factoryPoint |
85 |
.getService(ServiceInterceptorFactory.class);
|
|
86 |
|
|
87 | 15 |
Schema schema = factoryPoint.getParametersSchema(); |
88 |
|
|
89 | 15 |
SchemaProcessorImpl processor = new SchemaProcessorImpl(factoryPoint.getErrorLog(),
|
90 |
schema); |
|
91 |
|
|
92 | 15 |
processor.process(_parameters, _contributingModule); |
93 |
|
|
94 | 15 |
_convertedParameters = processor.getElements(); |
95 |
} |
|
96 |
} |
|
97 |
|
|
98 | 30 |
public void setContributingModule(Module module) |
99 |
{ |
|
100 | 30 |
_contributingModule = module; |
101 |
} |
|
102 |
|
|
103 | 30 |
public void setParameters(List list) |
104 |
{ |
|
105 | 30 |
_parameters = list; |
106 |
} |
|
107 |
|
|
108 | 18 |
public String getFollowingInterceptorIds()
|
109 |
{ |
|
110 | 18 |
return _followingInterceptorIds;
|
111 |
} |
|
112 |
|
|
113 | 18 |
public String getPrecedingInterceptorIds()
|
114 |
{ |
|
115 | 18 |
return _precedingInterceptorIds;
|
116 |
} |
|
117 |
|
|
118 | 30 |
public void setFollowingInterceptorIds(String string) |
119 |
{ |
|
120 | 30 |
_followingInterceptorIds = string; |
121 |
} |
|
122 |
|
|
123 | 30 |
public void setPrecedingInterceptorIds(String string) |
124 |
{ |
|
125 | 30 |
_precedingInterceptorIds = string; |
126 |
} |
|
127 |
|
|
128 |
} |
|