Changeset 659


Ignore:
Timestamp:
04/07/11 23:27:30 (2 years ago)
Author:
philsmart
Message:
 
Location:
raptor-web/trunk/src/main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/engine/RaptorWebEngine.java

    r642 r659  
    3131 */ 
    3232public 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*/ 
    3638    private MUARegistry registry; 
    3739 
    38     /* constructs downloadable reports from that currently displayed*/ 
     40    /** constructs downloadable reports from that currently displayed*/ 
    3941    private ReportHandler reportHandler; 
    4042 
    41     /* holds the currently attached MUA */ 
     43    /** holds the currently attached MUA */ 
    4244    private MUAEntry attachedMUA; 
    4345 
    44     /* holds the capabilities and statistical information for the currently attached MUA */ 
     46    /** holds the capabilities and statistical information for the currently attached MUA */ 
    4547    private Capabilities currentlyAttachedCapabilities; 
    4648 
    47     /* holds basic metadata about this particular RaptorWeb engine instance*/ 
     49    /** holds basic metadata about this particular RaptorWeb engine instance*/ 
    4850    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    } 
    5064 
    5165    /** 
     
    7185        log.info("Attaching {} and retrieving abilities",entry); 
    7286        this.attachedMUA = entry; 
    73         currentlyAttachedCapabilities = ServiceEndpointClient.discoverMUACapabilities(attachedMUA); 
     87        currentlyAttachedCapabilities = serviceEndpointClient.discoverMUACapabilities(attachedMUA); 
    7488    } 
    7589 
     
    103117                } 
    104118            } 
    105             Capabilities capabilities = ServiceEndpointClient.discoverMUACapabilities(attached); 
     119            Capabilities capabilities = serviceEndpointClient.discoverMUACapabilities(attached); 
    106120            if (capabilities!=null && !capabilities.isError()){ 
    107121                log.debug("Has retrieved {} statistics", capabilities.getStatisticalServices().size()); 
     
    122136     */ 
    123137    public Capabilities getCapabilities(MUAEntry selectedEndpoint) { 
    124         return ServiceEndpointClient.discoverMUACapabilities(selectedEndpoint); 
     138        return serviceEndpointClient.discoverMUACapabilities(selectedEndpoint); 
    125139    } 
    126140 
     
    135149 
    136150    public AggregatorGraphModel invokeStatisticalUnit(StatisticalUnitInformation selectedStatisticalUnit) { 
    137         AggregatorGraphModel gmodel = ServiceEndpointClient.invokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit.getStatisticParameters().getUnitName()); 
     151        AggregatorGraphModel gmodel = serviceEndpointClient.invokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit.getStatisticParameters().getUnitName()); 
    138152        return gmodel; 
    139153 
     
    141155 
    142156    public AggregatorGraphModel updateAndInvokeStatisticalUnit(StatisticalUnitInformation selectedStatisticalUnit) { 
    143         AggregatorGraphModel gmodel = ServiceEndpointClient.updateAndinvokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit); 
     157        AggregatorGraphModel gmodel = serviceEndpointClient.updateAndinvokeStatisticalUnit(getCurrentlyAttached(), selectedStatisticalUnit); 
    144158        return gmodel; 
    145159 
     
    173187        log.debug("Updating statistic {} ",model.getSelectedStatisticalUnit().getStatisticalUnitInformation().getStatisticParameters().getUnitName()); 
    174188        log.debug("Has startDate {}",model.getSelectedStatisticalUnit().getStatisticalUnitInformation().getStatisticParameters().getStartTimeAsDate()); 
    175         ServiceEndpointClient.updateStatisticalUnit(attachedMUA,model.getSelectedStatisticalUnit().getStatisticalUnitInformation()); 
     189        serviceEndpointClient.updateStatisticalUnit(attachedMUA,model.getSelectedStatisticalUnit().getStatisticalUnitInformation()); 
    176190    } 
    177191 
     
    200214        else 
    201215            function.setRequester("UNKNOWN"); 
    202         boolean success = ServiceEndpointClient.invokeAdministrativeFunction(attachedMUA, function); 
     216        boolean success = serviceEndpointClient.invokeAdministrativeFunction(attachedMUA, function); 
    203217        log.debug("Removal successfull {}",success); 
    204218        if (!success) model.setProcessingResult("ERROR: Entries did not remove"); 
     
    221235    } 
    222236 
     237    public void setServiceEndpointClient(ServiceEndpointClient serviceEndpointClient) { 
     238        this.serviceEndpointClient = serviceEndpointClient; 
     239    } 
     240 
     241    public ServiceEndpointClient getServiceEndpointClient() { 
     242        return serviceEndpointClient; 
     243    } 
     244 
    223245 
    224246} 
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/sei/ServiceEndpointClient.java

    r655 r659  
    3333 
    3434/** 
    35  * 
    36  * 
     35 *  
     36 *  
    3737 * @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 the Client 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 *  
    4242 */ 
    4343public class ServiceEndpointClient { 
    4444 
    4545    /** Class logger */ 
    46     private static final Logger log = LoggerFactory.getLogger(ServiceEndpointClient.class); 
     46    private final Logger log = LoggerFactory.getLogger(ServiceEndpointClient.class); 
    4747 
    4848    /** Raptor specific TLS parameters class, that can return cxf TLSParameters */ 
    49     private static ClientTLSParameters tlsParameters; 
    50  
    51     public static MultiUnitAggregator 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 { 
    5252        ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); 
    5353        factory.setServiceClass(MultiUnitAggregator.class); 
     
    6161        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 
    6262        httpClientPolicy.setConnectionTimeout(1000); 
    63         httpClientPolicy.setReceiveTimeout(2000); 
     63        httpClientPolicy.setReceiveTimeout(20000); 
    6464        httpConduit.setClient(httpClientPolicy); 
    6565 
    66         if (tlsParameters!=null) 
     66        if (tlsParameters != null) 
    6767            httpConduit.setTlsClientParameters(tlsParameters.getTlsClientParameters()); 
    6868 
     
    7373     * Method to determine and return the <code>Capabilities</code> of a MultiUnitAggregator. This method uses a hard set connection timeout of 10 miliseconds, 
    7474     * 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     *  
    7676     * @param endpoint 
    7777     * @return 
    7878     */ 
    79     public static Capabilities discoverMUACapabilities(MUAEntry endpoint) { 
     79    public Capabilities discoverMUACapabilities(MUAEntry endpoint) { 
    8080        Capabilities capabilities = null; 
    8181        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); 
    9683            log.debug("Accessing the MUA version " + client.getVersion()); 
    9784            capabilities = client.getCapabilities(); 
     
    10289            capabilities.setError(true); 
    10390            capabilities.setErrorMessage(e.getMessage()); 
    104             // e.printStackTrace(); 
     91            e.printStackTrace(); 
    10592        } catch (Exception e) { 
    10693            log.error("Problem trying to retrieving capabilities from MUA [{}] -> {}", new Object[] { endpoint, e.getMessage() }); 
     
    10895            capabilities.setError(true); 
    10996            capabilities.setErrorMessage(e.getMessage()); 
    110             // e.printStackTrace(); 
     97            e.printStackTrace(); 
    11198        } 
    11299        return capabilities; 
     
    118105     * <code>StatisicalUnitInformation</code> instance encapsulates the parameters for a single statistical unit. Allowing the values to be sent back and 
    119106     * changed on the MultiUnitAggregator 
    120      * 
     107     *  
    121108     * @param endpoint 
    122109     * @param statisticalUnitInformation 
    123110     * @return 
    124111     */ 
    125     public static Capabilities updateStatisticalUnit(MUAEntry endpoint, StatisticalUnitInformation statisticalUnitInformation) { 
     112    public Capabilities updateStatisticalUnit(MUAEntry endpoint, StatisticalUnitInformation statisticalUnitInformation) { 
    126113        Capabilities capabilities = null; 
    127114        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); 
    142116            log.debug("Accessing the MUA version {}", client.getVersion()); 
    143117            log.debug("Updating statistic {} from the MUA {}", statisticalUnitInformation.getStatisticParameters().getUnitName(), endpoint); 
     
    164138     * @param selectedStatisticalUnit 
    165139     */ 
    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); 
    182143            log.debug("Accessing the MUA version " + client.getVersion()); 
    183144            AggregatorGraphModel gmodel = client.invokeStatisticalUnit(selectedStatisticalUnit); 
     
    198159     * @param removeall 
    199160     */ 
    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); 
    216164            // client.invokeStatisticalUnit(selectedStatisticalUnit); 
    217165            log.debug("Accessing the MUA version {}", client.getVersion()); 
     
    230178    } 
    231179 
    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); 
    248183            log.debug("Accessing the MUA version " + client.getVersion()); 
    249184            AggregatorGraphModel gmodel = client.updateAndInvokeStatisticalUnit(statisticalUnit); 
  • raptor-web/trunk/src/main/webapp/WEB-INF/config/web-setup.xml

    r642 r659  
    2424                <property name="reportHandler"><ref bean="reportHandler"></ref></property> 
    2525                <property name="webMetadata"><ref bean="webMetadata"></ref></property> 
     26        <constructor-arg index="0"><ref bean="serviceEndpointClient"/></constructor-arg> 
    2627        </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> 
    2739 
    2840        <!-- MUA Metadata --> 
Note: See TracChangeset for help on using the changeset viewer.