View Javadoc

1   /*
2    * @(#)JobMonitorDelegateImpl.java   1.1
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.3, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10   */
11  
12  package org.astrogrid.jes.delegate.impl;
13  
14  import org.astrogrid.jes.delegate.JesDelegateException;
15  import org.astrogrid.jes.delegate.v1.jobmonitor.JobMonitorServiceLocator;
16  import org.astrogrid.jes.delegate.v1.jobmonitor.JobMonitorServiceSoapBindingStub;
17  import org.astrogrid.jes.types.v1.cea.axis.JobIdentifierType;
18  import org.astrogrid.jes.types.v1.cea.axis.MessageType;
19  
20  import java.io.IOException;
21  import java.net.MalformedURLException;
22  import java.net.URL;
23  
24  /***
25      SOAP-based implementation of a job monitor delegate
26   */
27  public class JobMonitorDelegateImpl extends JobMonitorDelegate {
28      
29      public JobMonitorDelegateImpl( String targetEndPoint ) {
30        this.targetEndPoint = targetEndPoint;
31      }
32      
33      public JobMonitorDelegateImpl( String targetEndPoint, int timeout ) { 
34        this.targetEndPoint = targetEndPoint;
35        this.timeout = timeout;
36      }
37      
38  
39      
40      public void monitorJob(JobIdentifierType id,MessageType info ) throws JesDelegateException {
41            
42              
43          try {
44              JobMonitorServiceSoapBindingStub binding = (JobMonitorServiceSoapBindingStub)
45                            new JobMonitorServiceLocator().getJobMonitorService( new URL( this.getTargetEndPoint() ) );                        
46              binding.setTimeout( this.getTimeout() ) ;    
47              binding.monitorJob(id,info);
48          }
49          catch( MalformedURLException mex ) {
50              throw new JesDelegateException( mex ) ;
51          }
52          catch( IOException  rex) {
53              throw new JesDelegateException( rex ) ;            
54          }
55          catch( javax.xml.rpc.ServiceException sex ) {
56              throw new JesDelegateException( sex ) ;    
57          }
58  
59    
60      } // end of monitorJob()    
61      
62  }