View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  package org.fourthline.cling.transport.spi;
16  
17  import org.fourthline.cling.model.ServerClientTokens;
18  
19  import java.util.concurrent.ExecutorService;
20  
21  /**
22   * @author Christian Bauer
23   */
24  public abstract class AbstractStreamClientConfiguration implements StreamClientConfiguration {
25  
26      protected ExecutorService requestExecutorService;
27      protected int timeoutSeconds = 60;
28      protected int logWarningSeconds = 5;
29  
30      protected AbstractStreamClientConfiguration(ExecutorService requestExecutorService) {
31          this.requestExecutorService = requestExecutorService;
32      }
33  
34      protected AbstractStreamClientConfiguration(ExecutorService requestExecutorService, int timeoutSeconds) {
35          this.requestExecutorService = requestExecutorService;
36          this.timeoutSeconds = timeoutSeconds;
37      }
38  
39      protected AbstractStreamClientConfiguration(ExecutorService requestExecutorService, int timeoutSeconds, int logWarningSeconds) {
40          this.requestExecutorService = requestExecutorService;
41          this.timeoutSeconds = timeoutSeconds;
42          this.logWarningSeconds = logWarningSeconds;
43      }
44  
45      public ExecutorService getRequestExecutorService() {
46          return requestExecutorService;
47      }
48  
49      public void setRequestExecutorService(ExecutorService requestExecutorService) {
50          this.requestExecutorService = requestExecutorService;
51      }
52  
53      /**
54       * @return Configured value or default of 60 seconds.
55       */
56      public int getTimeoutSeconds() {
57          return timeoutSeconds;
58      }
59  
60      public void setTimeoutSeconds(int timeoutSeconds) {
61          this.timeoutSeconds = timeoutSeconds;
62      }
63  
64      /**
65       * @return Configured value or default of 5 seconds.
66       */
67      public int getLogWarningSeconds() {
68          return logWarningSeconds;
69      }
70  
71      public void setLogWarningSeconds(int logWarningSeconds) {
72          this.logWarningSeconds = logWarningSeconds;
73      }
74  
75      /**
76       * @return Defaults to string value of {@link org.fourthline.cling.model.ServerClientTokens}.
77       */
78      public String getUserAgentValue(int majorVersion, int minorVersion) {
79          return new ServerClientTokens(majorVersion, minorVersion).toString();
80      }
81  }