Changeset 659
- Timestamp:
- 04/07/11 23:27:30 (2 years ago)
- Location:
- raptor-web/trunk/src/main
- Files:
-
- 3 edited
-
java/uk/ac/cardiff/raptorweb/engine/RaptorWebEngine.java (modified) (9 diffs)
-
java/uk/ac/cardiff/raptorweb/sei/ServiceEndpointClient.java (modified) (9 diffs)
-
webapp/WEB-INF/config/web-setup.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/engine/RaptorWebEngine.java
r642 r659 31 31 */ 32 32 public class RaptorWebEngine { 33 static Logger log = LoggerFactory.getLogger(RaptorWebEngine.class); 34 35 /* the registry which holds information about all MUAs injected from the xml file*/ 33 34 /** Class Logger */ 35 private final Logger log = LoggerFactory.getLogger(RaptorWebEngine.class); 36 37 /** the registry which holds information about all MUAs injected from the xml file*/ 36 38 private MUARegistry registry; 37 39 38 /* constructs downloadable reports from that currently displayed*/40 /** constructs downloadable reports from that currently displayed*/ 39 41 private ReportHandler reportHandler; 40 42 41 /* holds the currently attached MUA */43 /** holds the currently attached MUA */ 42 44 private MUAEntry attachedMUA; 43 45 44 /* holds the capabilities and statistical information for the currently attached MUA */46 /** holds the capabilities and statistical information for the currently attached MUA */ 45 47 private Capabilities currentlyAttachedCapabilities; 46 48 47 /* holds basic metadata about this particular RaptorWeb engine instance*/49 /** holds basic metadata about this particular RaptorWeb engine instance*/ 48 50 private ServerMetadata webMetadata; 49 51 52 /** The client used to set up, connect to, action and return results from the attached MUA*/ 53 private ServiceEndpointClient serviceEndpointClient; 54 55 /** 56 * Constructor, pass the service endpoint client so initialisation on certain getters can be performed. 57 * 58 * @param serviceEndpointClient 59 */ 60 private RaptorWebEngine(ServiceEndpointClient serviceEndpointClient){ 61 //TODO initialise all values after spring bean creation, 62 this.serviceEndpointClient = serviceEndpointClient; 63 } 50 64 51 65 /** … … 71 85 log.info("Attaching {} and retrieving abilities",entry); 72 86 this.attachedMUA = entry; 73 currentlyAttachedCapabilities = ServiceEndpointClient.discoverMUACapabilities(attachedMUA);87 currentlyAttachedCapabilities = serviceEndpointClient.discoverMUACapabilities(attachedMUA); 74 88 } 75 89 … … 103 117 } 104 118 } 105 Capabilities capabilities = ServiceEndpointClient.discoverMUACapabilities(attached);119 Capabilities capabilities = serviceEndpointClient.discoverMUACapabilities(attached); 106 120 if (capabilities!=null && !capabilities.isError()){ 107 121 log.debug("Has retrieved {} statistics", capabilities.getStatisticalServices().size()); … … 122 136 */ 123 137 public Capabilities getCapabilities(MUAEntry selectedEndpoint) { 124 return ServiceEndpointClient.discoverMUACapabilities(selectedEndpoint);138 return serviceEndpointClient.discoverMUACapabilities(selectedEndpoint); 125 139 } 126 140 … … 135 149 136 150 public AggregatorGraphModel invokeStatisticalUnit(StatisticalUnitInformation selectedStatisticalUnit) { 137 AggregatorGraphModel gmodel = ServiceEndpointClient.invokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit.getStatisticParameters().getUnitName());151 AggregatorGraphModel gmodel = serviceEndpointClient.invokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit.getStatisticParameters().getUnitName()); 138 152 return gmodel; 139 153 … … 141 155 142 156 public AggregatorGraphModel updateAndInvokeStatisticalUnit(StatisticalUnitInformation selectedStatisticalUnit) { 143 AggregatorGraphModel gmodel = ServiceEndpointClient.updateAndinvokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit);157 AggregatorGraphModel gmodel = serviceEndpointClient.updateAndinvokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit); 144 158 return gmodel; 145 159 … … 173 187 log.debug("Updating statistic {} ",model.getSelectedStatisticalUnit().getStatisticalUnitInformation().getStatisticParameters().getUnitName()); 174 188 log.debug("Has startDate {}",model.getSelectedStatisticalUnit().getStatisticalUnitInformation().getStatisticParameters().getStartTimeAsDate()); 175 ServiceEndpointClient.updateStatisticalUnit(attachedMUA,model.getSelectedStatisticalUnit().getStatisticalUnitInformation());189 serviceEndpointClient.updateStatisticalUnit(attachedMUA,model.getSelectedStatisticalUnit().getStatisticalUnitInformation()); 176 190 } 177 191 … … 200 214 else 201 215 function.setRequester("UNKNOWN"); 202 boolean success = ServiceEndpointClient.invokeAdministrativeFunction(attachedMUA, function);216 boolean success = serviceEndpointClient.invokeAdministrativeFunction(attachedMUA, function); 203 217 log.debug("Removal successfull {}",success); 204 218 if (!success) model.setProcessingResult("ERROR: Entries did not remove"); … … 221 235 } 222 236 237 public void setServiceEndpointClient(ServiceEndpointClient serviceEndpointClient) { 238 this.serviceEndpointClient = serviceEndpointClient; 239 } 240 241 public ServiceEndpointClient getServiceEndpointClient() { 242 return serviceEndpointClient; 243 } 244 223 245 224 246 } -
raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/sei/ServiceEndpointClient.java
r655 r659 33 33 34 34 /** 35 * 36 * 35 * 36 * 37 37 * @author philsmart 38 * 39 * Instances of this class are responsible for retrieving data from a service endpoint. This class should not be static 40 * and should not recreate theClient for every request.41 * 38 * 39 * Instances of this class are responsible for retrieving data from a service endpoint. This class should not be static and should not recreate the 40 * Client for every request. 41 * 42 42 */ 43 43 public class ServiceEndpointClient { 44 44 45 45 /** Class logger */ 46 private staticfinal Logger log = LoggerFactory.getLogger(ServiceEndpointClient.class);46 private final Logger log = LoggerFactory.getLogger(ServiceEndpointClient.class); 47 47 48 48 /** Raptor specific TLS parameters class, that can return cxf TLSParameters */ 49 private staticClientTLSParameters tlsParameters;50 51 public staticMultiUnitAggregator getEndpointConnection(MUAEntry endpoint) throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {49 private ClientTLSParameters tlsParameters; 50 51 public MultiUnitAggregator getEndpointConnection(MUAEntry endpoint) throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException { 52 52 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 53 53 factory.setServiceClass(MultiUnitAggregator.class); … … 61 61 HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 62 62 httpClientPolicy.setConnectionTimeout(1000); 63 httpClientPolicy.setReceiveTimeout(2000 );63 httpClientPolicy.setReceiveTimeout(20000); 64 64 httpConduit.setClient(httpClientPolicy); 65 65 66 if (tlsParameters !=null)66 if (tlsParameters != null) 67 67 httpConduit.setTlsClientParameters(tlsParameters.getTlsClientParameters()); 68 68 … … 73 73 * Method to determine and return the <code>Capabilities</code> of a MultiUnitAggregator. This method uses a hard set connection timeout of 10 miliseconds, 74 74 * and a receive timeout of 20 smilieconds, under the assumption that the capabilities of a MultiUnitAggregator can be sent inside small XML documents. 75 * 75 * 76 76 * @param endpoint 77 77 * @return 78 78 */ 79 public staticCapabilities discoverMUACapabilities(MUAEntry endpoint) {79 public Capabilities discoverMUACapabilities(MUAEntry endpoint) { 80 80 Capabilities capabilities = null; 81 81 try { 82 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 83 factory.setServiceClass(MultiUnitAggregator.class); 84 AegisDatabinding databinding = new AegisDatabinding(); 85 factory.setAddress(endpoint.getServiceEndpoint()); 86 factory.getServiceFactory().setDataBinding(databinding); 87 88 MultiUnitAggregator client = (MultiUnitAggregator) factory.create(); 89 org.apache.cxf.endpoint.Client cl = ClientProxy.getClient(client); 90 HTTPConduit httpConduit = (HTTPConduit) cl.getConduit(); 91 HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 92 httpClientPolicy.setConnectionTimeout(1000); 93 httpClientPolicy.setReceiveTimeout(2000); 94 httpConduit.setClient(httpClientPolicy); 95 httpConduit.setTlsClientParameters(getTlsSettings(endpoint)); 82 MultiUnitAggregator client = getEndpointConnection(endpoint); 96 83 log.debug("Accessing the MUA version " + client.getVersion()); 97 84 capabilities = client.getCapabilities(); … … 102 89 capabilities.setError(true); 103 90 capabilities.setErrorMessage(e.getMessage()); 104 //e.printStackTrace();91 e.printStackTrace(); 105 92 } catch (Exception e) { 106 93 log.error("Problem trying to retrieving capabilities from MUA [{}] -> {}", new Object[] { endpoint, e.getMessage() }); … … 108 95 capabilities.setError(true); 109 96 capabilities.setErrorMessage(e.getMessage()); 110 //e.printStackTrace();97 e.printStackTrace(); 111 98 } 112 99 return capabilities; … … 118 105 * <code>StatisicalUnitInformation</code> instance encapsulates the parameters for a single statistical unit. Allowing the values to be sent back and 119 106 * changed on the MultiUnitAggregator 120 * 107 * 121 108 * @param endpoint 122 109 * @param statisticalUnitInformation 123 110 * @return 124 111 */ 125 public staticCapabilities updateStatisticalUnit(MUAEntry endpoint, StatisticalUnitInformation statisticalUnitInformation) {112 public Capabilities updateStatisticalUnit(MUAEntry endpoint, StatisticalUnitInformation statisticalUnitInformation) { 126 113 Capabilities capabilities = null; 127 114 try { 128 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 129 factory.setServiceClass(MultiUnitAggregator.class); 130 AegisDatabinding databinding = new AegisDatabinding(); 131 factory.setAddress(endpoint.getServiceEndpoint()); 132 factory.getServiceFactory().setDataBinding(databinding); 133 134 MultiUnitAggregator client = (MultiUnitAggregator) factory.create(); 135 org.apache.cxf.endpoint.Client cl = ClientProxy.getClient(client); 136 HTTPConduit httpConduit = (HTTPConduit) cl.getConduit(); 137 HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 138 httpClientPolicy.setConnectionTimeout(100000); 139 httpClientPolicy.setReceiveTimeout(200000); 140 httpConduit.setClient(httpClientPolicy); 141 httpConduit.setTlsClientParameters(getTlsSettings(endpoint)); 115 MultiUnitAggregator client = getEndpointConnection(endpoint); 142 116 log.debug("Accessing the MUA version {}", client.getVersion()); 143 117 log.debug("Updating statistic {} from the MUA {}", statisticalUnitInformation.getStatisticParameters().getUnitName(), endpoint); … … 164 138 * @param selectedStatisticalUnit 165 139 */ 166 public static AggregatorGraphModel invokeStatisticalUnit(MUAEntry endpoint, String selectedStatisticalUnit) { 167 try { 168 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 169 factory.setServiceClass(MultiUnitAggregator.class); 170 AegisDatabinding databinding = new AegisDatabinding(); 171 factory.setAddress(endpoint.getServiceEndpoint()); 172 factory.getServiceFactory().setDataBinding(databinding); 173 MultiUnitAggregator client = (MultiUnitAggregator) factory.create(); 174 175 org.apache.cxf.endpoint.Client cl = ClientProxy.getClient(client); 176 HTTPConduit httpConduit = (HTTPConduit) cl.getConduit(); 177 HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 178 httpClientPolicy.setConnectionTimeout(100000); 179 httpClientPolicy.setReceiveTimeout(200000); 180 httpConduit.setClient(httpClientPolicy); 181 httpConduit.setTlsClientParameters(getTlsSettings(endpoint)); 140 public AggregatorGraphModel invokeStatisticalUnit(MUAEntry endpoint, String selectedStatisticalUnit) { 141 try { 142 MultiUnitAggregator client = getEndpointConnection(endpoint); 182 143 log.debug("Accessing the MUA version " + client.getVersion()); 183 144 AggregatorGraphModel gmodel = client.invokeStatisticalUnit(selectedStatisticalUnit); … … 198 159 * @param removeall 199 160 */ 200 public static boolean invokeAdministrativeFunction(MUAEntry endpoint, AdministrativeFunction function) { 201 try { 202 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 203 factory.setServiceClass(MultiUnitAggregator.class); 204 AegisDatabinding databinding = new AegisDatabinding(); 205 factory.setAddress(endpoint.getServiceEndpoint()); 206 factory.getServiceFactory().setDataBinding(databinding); 207 MultiUnitAggregator client = (MultiUnitAggregator) factory.create(); 208 209 org.apache.cxf.endpoint.Client cl = ClientProxy.getClient(client); 210 HTTPConduit httpConduit = (HTTPConduit) cl.getConduit(); 211 HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 212 httpClientPolicy.setConnectionTimeout(100000); 213 httpClientPolicy.setReceiveTimeout(200000); 214 httpConduit.setClient(httpClientPolicy); 215 httpConduit.setTlsClientParameters(getTlsSettings(endpoint)); 161 public boolean invokeAdministrativeFunction(MUAEntry endpoint, AdministrativeFunction function) { 162 try { 163 MultiUnitAggregator client = getEndpointConnection(endpoint); 216 164 // client.invokeStatisticalUnit(selectedStatisticalUnit); 217 165 log.debug("Accessing the MUA version {}", client.getVersion()); … … 230 178 } 231 179 232 public static AggregatorGraphModel updateAndinvokeStatisticalUnit(MUAEntry endpoint, StatisticalUnitInformation statisticalUnit) { 233 try { 234 ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 235 factory.setServiceClass(MultiUnitAggregator.class); 236 AegisDatabinding databinding = new AegisDatabinding(); 237 factory.setAddress(endpoint.getServiceEndpoint()); 238 factory.getServiceFactory().setDataBinding(databinding); 239 MultiUnitAggregator client = (MultiUnitAggregator) factory.create(); 240 241 org.apache.cxf.endpoint.Client cl = ClientProxy.getClient(client); 242 HTTPConduit httpConduit = (HTTPConduit) cl.getConduit(); 243 HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 244 httpClientPolicy.setConnectionTimeout(100000); 245 httpClientPolicy.setReceiveTimeout(200000); 246 httpConduit.setClient(httpClientPolicy); 247 httpConduit.setTlsClientParameters(getTlsSettings(endpoint)); 180 public AggregatorGraphModel updateAndinvokeStatisticalUnit(MUAEntry endpoint, StatisticalUnitInformation statisticalUnit) { 181 try { 182 MultiUnitAggregator client = getEndpointConnection(endpoint); 248 183 log.debug("Accessing the MUA version " + client.getVersion()); 249 184 AggregatorGraphModel gmodel = client.updateAndInvokeStatisticalUnit(statisticalUnit); -
raptor-web/trunk/src/main/webapp/WEB-INF/config/web-setup.xml
r642 r659 24 24 <property name="reportHandler"><ref bean="reportHandler"></ref></property> 25 25 <property name="webMetadata"><ref bean="webMetadata"></ref></property> 26 <constructor-arg index="0"><ref bean="serviceEndpointClient"/></constructor-arg> 26 27 </bean> 28 29 <bean id="serviceEndpointClient" class="uk.ac.cardiff.raptorweb.sei.ServiceEndpointClient"> 30 <property name="tlsParameters"> 31 <bean class="uk.ac.cardiff.raptor.remoting.client.sei.impl.ClientTLSParameters"> 32 <property name="trustStoreLocation"><value>/Users/philsmart/Documents/Java/RaptorWorkspace/keys/mua-public.jks</value></property> 33 <property name="trustStorePassword"><value>phil11</value></property> 34 <property name="keyStoreLocation"><value>/Users/philsmart/Documents/Java/RaptorWorkspace/keys/raptor-ica.jks</value></property> 35 <property name="keyStorePassword"><value>phil11</value></property> 36 </bean> 37 </property> 38 </bean> 27 39 28 40 <!-- MUA Metadata -->
Note: See TracChangeset
for help on using the changeset viewer.
