01: // Copyright 2004, 2005 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.commons.logging.Log;
20: import org.apache.hivemind.ServiceImplementationFactoryParameters;
21: import org.apache.hivemind.ErrorLog;
22: import org.apache.hivemind.internal.Module;
23: import org.apache.hivemind.internal.ServicePoint;
24: import org.apache.hivemind.util.Defense;
25:
26: /**
27: * Wrapper around a {@link org.apache.hivemind.internal.ServicePoint} and a List of parameters,
28: * passed to a {@link org.apache.hivemind.ServiceImplementationFactory}.
29: *
30: * @author Howard M. Lewis Ship
31: * @since 1.1
32: */
33: public class ServiceImplementationFactoryParametersImpl implements
34: ServiceImplementationFactoryParameters {
35: private ServicePoint _servicePoint;
36:
37: private Module _invokingModule;
38:
39: private List _parameters;
40:
41: public ServiceImplementationFactoryParametersImpl(
42: ServicePoint servicePoint, Module invokingModule,
43: List parameters) {
44: Defense.notNull(servicePoint, "servicePoint");
45: Defense.notNull(invokingModule, "invokingModule");
46: Defense.notNull(parameters, "parameters");
47:
48: _servicePoint = servicePoint;
49: _invokingModule = invokingModule;
50: _parameters = parameters;
51: }
52:
53: /**
54: * This method is only used in testing.
55: */
56:
57: public boolean equals(Object other) {
58: ServiceImplementationFactoryParametersImpl p = (ServiceImplementationFactoryParametersImpl) other;
59:
60: return _servicePoint == p._servicePoint
61: && _invokingModule == p._invokingModule
62: && _parameters.equals(p._parameters);
63: }
64:
65: public String getServiceId() {
66: return _servicePoint.getExtensionPointId();
67: }
68:
69: public Class getServiceInterface() {
70: return _servicePoint.getServiceInterface();
71: }
72:
73: public Log getLog() {
74: return _servicePoint.getLog();
75: }
76:
77: public ErrorLog getErrorLog() {
78: return _servicePoint.getErrorLog();
79: }
80:
81: public Module getInvokingModule() {
82: return _invokingModule;
83: }
84:
85: public List getParameters() {
86: return _parameters;
87: }
88:
89: public Object getFirstParameter() {
90: return _parameters.isEmpty() ? null : _parameters.get(0);
91: }
92: }
|