Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 357daad39c91d0e6f52c807dae6c3957077837a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*******************************************************************************
 * Copyright (c) 2004 Composent, Inc. and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: Composent, Inc. - initial API and implementation
 ******************************************************************************/

package org.eclipse.ecf.discovery;

import java.io.Serializable;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;

import org.eclipse.ecf.discovery.identity.ServiceID;


/**
 * Information provided by discovery protocol about a remote service
 */
public class ServiceInfo implements IServiceInfo, Serializable {

	private static final long serialVersionUID = 1L;
	InetAddress addr = null;
	ServiceID serviceID;
	int port;
	int priority;
	int weight;
	IServiceProperties properties;

	public ServiceInfo(InetAddress address, String type, int port, int priority, int weight, IServiceProperties props) {
		this.addr = address;
		this.serviceID = new ServiceID(type,null);
		this.port = port;
		this.weight = weight;
		this.properties = props;
	}
	public ServiceInfo(InetAddress address, ServiceID id, int port,
			int priority, int weight, IServiceProperties props) {
		this.addr = address;
		this.serviceID = id;
		this.port = port;
		this.priority = priority;
		this.weight = weight;
		this.properties = props;
	}

	public InetAddress getAddress() {
		return addr;
	}

	protected void setAddress(InetAddress address) {
		this.addr = address;
	}

	public ServiceID getServiceID() {
		return serviceID;
	}

	public int getPort() {
		return port;
	}

	public int getPriority() {
		return priority;
	}

	public int getWeight() {
		return weight;
	}

	public IServiceProperties getServiceProperties() {
		return properties;
	}
	public boolean isResolved() {
		return (addr != null);
	}
	public String toString() {
		StringBuffer buf = new StringBuffer("ServiceInfo[");
		buf.append("addr=").append(addr).append(";id=").append(serviceID).append(
				";port=").append(port).append(";priority=").append(priority)
				.append(";weight=").append(weight).append(";props=").append(
						properties).append("]");
		return buf.toString();
	}
	
	public URI getServiceURI() throws URISyntaxException {
		throw new URISyntaxException(this.toString(),"ServiceInfo doesn't support URI syntax");
	}
}

Back to the top