01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.catalina.tribes.membership;
19:
20: import java.io.IOException;
21: import org.apache.catalina.tribes.util.Arrays;
22:
23: /**
24: * <p>Title: </p>
25: *
26: * <p>Description: </p>
27: *
28: * <p>Company: </p>
29: *
30: * @author not attributable
31: * @version 1.0
32: */
33: public class StaticMember extends MemberImpl {
34: public StaticMember() {
35: super ();
36: }
37:
38: public StaticMember(String host, int port, long aliveTime)
39: throws IOException {
40: super (host, port, aliveTime);
41: }
42:
43: public StaticMember(String host, int port, long aliveTime,
44: byte[] payload) throws IOException {
45: super (host, port, aliveTime, payload);
46: }
47:
48: /**
49: * @param host String, either in byte array string format, like {214,116,1,3}
50: * or as a regular hostname, 127.0.0.1 or tomcat01.mydomain.com
51: */
52: public void setHost(String host) {
53: if (host == null)
54: return;
55: if (host.startsWith("{"))
56: setHost(Arrays.fromString(host));
57: else
58: try {
59: setHostname(host);
60: } catch (IOException x) {
61: throw new RuntimeException(x);
62: }
63:
64: }
65:
66: /**
67: * @param domain String, either in byte array string format, like {214,116,1,3}
68: * or as a regular string value like 'mydomain'. The latter will be converted using ISO-8859-1 encoding
69: */
70: public void setDomain(String domain) {
71: if (domain == null)
72: return;
73: if (domain.startsWith("{"))
74: setDomain(Arrays.fromString(domain));
75: else
76: setDomain(Arrays.convert(domain));
77: }
78:
79: /**
80: * @param id String, must be in byte array string format, like {214,116,1,3} and exactly 16 bytes long
81: */
82: public void setUniqueId(String id) {
83: byte[] uuid = Arrays.fromString(id);
84: if (uuid == null || uuid.length != 16)
85: throw new RuntimeException(
86: "UUID must be exactly 16 bytes, not:" + id);
87: setUniqueId(uuid);
88: }
89:
90: }
|