gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.util / org.gvsig.tools.util.impl / src / main / java / org / gvsig / simplehttpservice / SimpleServerConfigImpl.java @ 2213
History | View | Annotate | Download (2.71 KB)
1 |
package org.gvsig.simplehttpservice; |
---|---|
2 |
|
3 |
import java.beans.PropertyChangeListener; |
4 |
import java.beans.PropertyChangeSupport; |
5 |
import java.util.Collection; |
6 |
import java.util.HashMap; |
7 |
import java.util.Map; |
8 |
import org.gvsig.simplehttpservice.commands.CommandFactory; |
9 |
import org.gvsig.simplehttpservice.commands.HelpFactory; |
10 |
|
11 |
/**
|
12 |
*
|
13 |
* @author jjdelcerro
|
14 |
*/
|
15 |
public class SimpleServerConfigImpl implements SimpleServerConfig { |
16 |
|
17 |
private int port; |
18 |
private int timeout; |
19 |
private String serverInfo; |
20 |
private boolean autostart; |
21 |
private final PropertyChangeSupport propertyChangeSupport; |
22 |
private final Map<String, CommandFactory> commandFactories; |
23 |
|
24 |
public SimpleServerConfigImpl() {
|
25 |
this.port = 9876; |
26 |
this.timeout = 15000; |
27 |
this.serverInfo = "Test/1.1"; |
28 |
this.propertyChangeSupport = new PropertyChangeSupport(this); |
29 |
this.commandFactories = new HashMap<>(); |
30 |
|
31 |
HelpFactory factory = new HelpFactory();
|
32 |
this.commandFactories.put(factory.getName().toLowerCase(), factory);
|
33 |
} |
34 |
|
35 |
@Override
|
36 |
public int getPort() { |
37 |
return this.port; |
38 |
} |
39 |
|
40 |
@Override
|
41 |
public SimpleServerConfig setPort(int port) { |
42 |
int oldValue = this.port; |
43 |
this.port = port;
|
44 |
this.propertyChangeSupport.firePropertyChange("port", oldValue, port); |
45 |
return this; |
46 |
} |
47 |
|
48 |
@Override
|
49 |
public int getTimeout() { |
50 |
return this.timeout; |
51 |
} |
52 |
|
53 |
@Override
|
54 |
public SimpleServerConfig setTimeout(int timeout) { |
55 |
int oldValue = this.timeout; |
56 |
this.timeout = timeout;
|
57 |
this.propertyChangeSupport.firePropertyChange("timeout", oldValue, timeout); |
58 |
return this; |
59 |
} |
60 |
|
61 |
@Override
|
62 |
public String getServerInfo() { |
63 |
return this.serverInfo; |
64 |
} |
65 |
|
66 |
@Override
|
67 |
public SimpleServerConfig setServerInfo(String serverInfo) { |
68 |
String oldValue = this.serverInfo; |
69 |
this.serverInfo = serverInfo;
|
70 |
this.propertyChangeSupport.firePropertyChange("serverInfo", oldValue, serverInfo); |
71 |
return this; |
72 |
} |
73 |
|
74 |
@Override
|
75 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
76 |
this.propertyChangeSupport.addPropertyChangeListener(listener);
|
77 |
} |
78 |
|
79 |
@Override
|
80 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
81 |
this.propertyChangeSupport.removePropertyChangeListener(listener);
|
82 |
} |
83 |
|
84 |
@Override
|
85 |
public Collection<CommandFactory> getCommandFactories() { |
86 |
return this.commandFactories.values(); |
87 |
} |
88 |
|
89 |
@Override
|
90 |
public SimpleServerConfig addCommandFactory(CommandFactory factory) {
|
91 |
this.commandFactories.put(factory.getName().toLowerCase(), factory);
|
92 |
return this; |
93 |
} |
94 |
|
95 |
@Override
|
96 |
public void removeCommandFactory(CommandFactory factory) { |
97 |
this.commandFactories.remove(factory.getName());
|
98 |
} |
99 |
|
100 |
@Override
|
101 |
public void removeCommandFactory(String name) { |
102 |
this.commandFactories.remove(name);
|
103 |
} |
104 |
|
105 |
} |