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
17
18
19
20
21
22
23
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
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 }