001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.hivemind.impl; 016 017 import java.util.List; 018 019 import org.apache.commons.logging.Log; 020 import org.apache.hivemind.ServiceImplementationFactoryParameters; 021 import org.apache.hivemind.ErrorLog; 022 import org.apache.hivemind.internal.Module; 023 import org.apache.hivemind.internal.ServicePoint; 024 import org.apache.hivemind.util.Defense; 025 026 /** 027 * Wrapper around a {@link org.apache.hivemind.internal.ServicePoint} and a List of parameters, 028 * passed to a {@link org.apache.hivemind.ServiceImplementationFactory}. 029 * 030 * @author Howard M. Lewis Ship 031 * @since 1.1 032 */ 033 public class ServiceImplementationFactoryParametersImpl implements 034 ServiceImplementationFactoryParameters 035 { 036 private ServicePoint _servicePoint; 037 038 private Module _invokingModule; 039 040 private List _parameters; 041 042 public ServiceImplementationFactoryParametersImpl(ServicePoint servicePoint, 043 Module invokingModule, List parameters) 044 { 045 Defense.notNull(servicePoint, "servicePoint"); 046 Defense.notNull(invokingModule, "invokingModule"); 047 Defense.notNull(parameters, "parameters"); 048 049 _servicePoint = servicePoint; 050 _invokingModule = invokingModule; 051 _parameters = parameters; 052 } 053 054 /** 055 * This method is only used in testing. 056 */ 057 058 public boolean equals(Object other) 059 { 060 ServiceImplementationFactoryParametersImpl p = (ServiceImplementationFactoryParametersImpl) other; 061 062 return _servicePoint == p._servicePoint && _invokingModule == p._invokingModule 063 && _parameters.equals(p._parameters); 064 } 065 066 public String getServiceId() 067 { 068 return _servicePoint.getExtensionPointId(); 069 } 070 071 public Class getServiceInterface() 072 { 073 return _servicePoint.getServiceInterface(); 074 } 075 076 public Log getLog() 077 { 078 return _servicePoint.getLog(); 079 } 080 081 public ErrorLog getErrorLog() 082 { 083 return _servicePoint.getErrorLog(); 084 } 085 086 public Module getInvokingModule() 087 { 088 return _invokingModule; 089 } 090 091 public List getParameters() 092 { 093 return _parameters; 094 } 095 096 public Object getFirstParameter() 097 { 098 return _parameters.isEmpty() ? null : _parameters.get(0); 099 } 100 }