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