1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.client.runtime.async;
20
21 import org.apache.chemistry.opencmis.client.api.AsyncSession;
22 import org.apache.chemistry.opencmis.client.api.AsyncSessionFactory;
23 import org.apache.chemistry.opencmis.client.api.Session;
24
25
26
27
28 public class AsyncSessionFactoryImpl implements AsyncSessionFactory {
29
30 protected AsyncSessionFactoryImpl() {
31 }
32
33 public static AsyncSessionFactoryImpl newInstance() {
34 return new AsyncSessionFactoryImpl();
35 }
36
37 @Override
38 public AsyncSession createAsyncSession(Session session) {
39 return createAsyncSession(session, 5);
40 }
41
42 @Override
43 public AsyncSession createAsyncSession(Session session, int maxParallelRequests) {
44 if (session == null) {
45 throw new IllegalArgumentException("Session must be set!");
46 }
47
48 if (maxParallelRequests < 1) {
49 throw new IllegalArgumentException("maxParallelRequests must be >0!");
50 }
51
52 return new ThreadPoolExecutorAsyncSession(session, maxParallelRequests);
53 }
54 }