1 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.ApplicationRuntimeException; 21 import org.apache.hivemind.ErrorLog; 22 import org.apache.hivemind.ServiceImplementationFactoryParameters; 23 import org.apache.hivemind.internal.Module; 24 import org.apache.hivemind.internal.ServicePoint; 25 import org.apache.hivemind.util.Defense; 26 27 34 public class ServiceImplementationFactoryParametersImpl implements 35 ServiceImplementationFactoryParameters 36 { 37 private ServicePoint _servicePoint; 38 39 private Module _invokingModule; 40 41 private Object _parameters; 42 43 public ServiceImplementationFactoryParametersImpl(ServicePoint servicePoint, 44 Module invokingModule, Object parameters) 45 { 46 Defense.notNull(servicePoint, "servicePoint"); 47 Defense.notNull(invokingModule, "invokingModule"); 48 49 _servicePoint = servicePoint; 50 _invokingModule = invokingModule; 51 _parameters = parameters; 52 } 53 54 57 58 public boolean equals(Object other) 59 { 60 ServiceImplementationFactoryParametersImpl p = (ServiceImplementationFactoryParametersImpl) other; 61 62 return _servicePoint == p._servicePoint && _invokingModule == p._invokingModule 63 && ((_parameters == null && p._parameters == null) || _parameters.equals(p._parameters)); 64 } 65 66 public String getServiceId() 67 { 68 return _servicePoint.getExtensionPointId(); 69 } 70 71 public Class getServiceInterface() 72 { 73 return _servicePoint.getServiceInterface(); 74 } 75 76 public Log getLog() 77 { 78 return _servicePoint.getLog(); 79 } 80 81 public ErrorLog getErrorLog() 82 { 83 return _servicePoint.getErrorLog(); 84 } 85 86 public Module getInvokingModule() 87 { 88 return _invokingModule; 89 } 90 91 public List getParameters() 92 { 93 if (_parameters instanceof List ) { 96 return (List ) _parameters; 97 } else { 98 throw new ApplicationRuntimeException("Parameters are not contained in a list. Use getParametersContainer instead."); 99 } 100 } 101 102 public Object getParametersContainer() 103 { 104 return _parameters; 105 } 106 107 public Object getFirstParameter() 108 { 109 if (_parameters instanceof List ) { 112 return ((List ) _parameters).isEmpty() ? null : ((List ) _parameters).get(0); 113 } else { 114 return _parameters; 115 } 116 } 117 118 } | Popular Tags |