View Javadoc

1   package fr.in2p3.jsaga.impl.job;
2   
3   import fr.in2p3.jsaga.engine.factories.JobAdaptorFactory;
4   import fr.in2p3.jsaga.engine.factories.JobMonitorAdaptorFactory;
5   import fr.in2p3.jsaga.impl.AbstractSagaObjectImpl;
6   import org.ogf.saga.SagaObject;
7   import org.ogf.saga.error.*;
8   import org.ogf.saga.job.JobFactory;
9   import org.ogf.saga.job.JobService;
10  import org.ogf.saga.session.Session;
11  import org.ogf.saga.task.Task;
12  import org.ogf.saga.task.TaskMode;
13  import org.ogf.saga.url.URL;
14  
15  /* ***************************************************
16  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
17  * ***             http://cc.in2p3.fr/             ***
18  * ***************************************************
19  * File:   JobFactoryImpl
20  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
21  * Date:   18 sept. 2007
22  * ***************************************************
23  * Description:                                      */
24  /**
25   *
26   */
27  public class JobFactoryImpl extends AbstractAsyncJobFactoryImpl {
28      public JobFactoryImpl(JobAdaptorFactory adaptorFactory, JobMonitorAdaptorFactory monitorAdaptorFactory) {
29          super(adaptorFactory, monitorAdaptorFactory);
30      }
31  
32      protected JobService doCreateJobService(Session session, URL rm) throws NotImplementedException, BadParameterException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, TimeoutException, NoSuccessException {
33          float timeout = this.getTimeout("createJobService", rm);
34          if (timeout == SagaObject.WAIT_FOREVER) {
35              return super.doCreateJobServiceSync(session, rm);
36          } else {
37              try {
38                  return (JobService) this.getResult(super.doCreateJobService(TaskMode.ASYNC, session, rm), timeout);
39              }
40              catch (IncorrectStateException e) {throw new NoSuccessException(e);}
41              catch (AlreadyExistsException e) {throw new NoSuccessException(e);}
42              catch (DoesNotExistException e) {throw new NoSuccessException(e);}
43              catch (SagaIOException e) {throw new NoSuccessException(e);}
44          }
45      }
46  
47      ////////////////////////////////////////// private methods //////////////////////////////////////////
48  
49      private float getTimeout(String methodName, URL rm) throws NoSuccessException {
50          return AbstractSagaObjectImpl.getTimeout(JobFactory.class, methodName, rm.getScheme());
51      }
52  
53      private Object getResult(Task task, float timeout)
54              throws NotImplementedException, IncorrectURLException,
55              AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException,
56              BadParameterException, IncorrectStateException, AlreadyExistsException, DoesNotExistException,
57              TimeoutException, NoSuccessException, SagaIOException
58      {
59          return AbstractSagaObjectImpl.getResult(task, timeout);
60      }
61  }