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  
16  package org.fourthline.cling.transport.impl;
17  
18  import org.fourthline.cling.transport.spi.ServletContainerAdapter;
19  import org.fourthline.cling.transport.spi.StreamServerConfiguration;
20  
21  /**
22   * Settings for the async Servlet 3.0 implementation.
23   * <p>
24   * If you are trying to integrate Cling with an existing/running servlet
25   * container, implement {@link org.fourthline.cling.transport.spi.ServletContainerAdapter}.
26   * </p>
27   *
28   * @author Christian Bauer
29   */
30  public class AsyncServletStreamServerConfigurationImpl implements StreamServerConfiguration {
31  
32      protected ServletContainerAdapter servletContainerAdapter;
33      protected int listenPort = 0;
34      protected int asyncTimeoutSeconds = 60;
35  
36      /**
37       * Defaults to port '0', ephemeral.
38       */
39      public AsyncServletStreamServerConfigurationImpl(ServletContainerAdapter servletContainerAdapter) {
40          this.servletContainerAdapter = servletContainerAdapter;
41      }
42  
43      public AsyncServletStreamServerConfigurationImpl(ServletContainerAdapter servletContainerAdapter,
44                                                       int listenPort) {
45          this.servletContainerAdapter = servletContainerAdapter;
46          this.listenPort = listenPort;
47      }
48  
49      public AsyncServletStreamServerConfigurationImpl(ServletContainerAdapter servletContainerAdapter,
50                                                       int listenPort,
51                                                       int asyncTimeoutSeconds) {
52          this.servletContainerAdapter = servletContainerAdapter;
53          this.listenPort = listenPort;
54          this.asyncTimeoutSeconds = asyncTimeoutSeconds;
55      }
56  
57      /**
58       * @return Defaults to <code>0</code>.
59       */
60      public int getListenPort() {
61          return listenPort;
62      }
63  
64      public void setListenPort(int listenPort) {
65          this.listenPort = listenPort;
66      }
67  
68      /**
69       * The time in seconds this server wait for the {@link org.fourthline.cling.transport.Router}
70       * to execute a {@link org.fourthline.cling.transport.spi.UpnpStream}.
71       *
72       * @return The default of 60 seconds.
73       */
74      public int getAsyncTimeoutSeconds() {
75          return asyncTimeoutSeconds;
76      }
77  
78      public void setAsyncTimeoutSeconds(int asyncTimeoutSeconds) {
79          this.asyncTimeoutSeconds = asyncTimeoutSeconds;
80      }
81  
82      public ServletContainerAdapter getServletContainerAdapter() {
83          return servletContainerAdapter;
84      }
85  
86      public void setServletContainerAdapter(ServletContainerAdapter servletContainerAdapter) {
87          this.servletContainerAdapter = servletContainerAdapter;
88      }
89  }