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
93
94
95
96
|
/*******************************************************************************
* Copyright (c) 2009 EclipseSource 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:
* EclipseSource - initial API and implementation
*******************************************************************************/
package org.eclipse.ecf.remoteservice.rest.identity;
import java.net.URL;
import org.eclipse.ecf.core.identity.BaseID;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.remoteservice.IRemoteServiceID;
import org.eclipse.ecf.remoteservice.rest.RestContainer;
/**
* An ECF ID to instatiate a {@link RestContainer}.
*/
public class RestID extends BaseID implements IRemoteServiceID {
private static final long serialVersionUID = -7725015677223101132L;
URL baseUrl;
private Long serviceID;
private ID containerId;
/**
* Contructor to create a RestID with a {@link Namespace}.
*
* @param namespace Must be an instance of {@link RestNamespace}.
* @param baseURL an URL which will be associated with this ID to call REST services,
* i.e. http://twitter.com for Twitter services.
*/
public RestID( Namespace namespace, URL baseURL ) {
super(namespace);
this.baseUrl = baseURL;
}
/**
* @see RestID#RestID(Namespace, URL).
*
* @param serviceID the service ID to use.
*/
public RestID(RestNamespace restNamespace, URL url, Long serviceID) {
this(restNamespace, url);
this.serviceID = serviceID;
}
/**
* @see RestID#RestID(RestNamespace, URL, Long).
*
* @param containerId the ID of the associated container.
*/
public RestID(RestNamespace restNamespace, URL url, ID containerId, Long serviceID) {
this(restNamespace, url, serviceID);
this.containerId = containerId;
}
public int namespaceCompareTo(BaseID o) {
return this.baseUrl.toExternalForm().compareTo(((RestID) o).toExternalForm());
}
public boolean namespaceEquals(BaseID o) {
return this.baseUrl.equals(((RestID) o).baseUrl);
}
public String namespaceGetName() {
return this.baseUrl.toExternalForm();
}
public int namespaceHashCode() {
return this.baseUrl.hashCode();
}
public URL getBaseURL() {
return baseUrl;
}
public ID getContainerID() {
return containerId;
}
public long getContainerRelativeID() {
if(serviceID == null)
return 0;
return serviceID.longValue();
}
public void setBaseUrl(URL baseUrl) {
this.baseUrl = baseUrl;
}
}
|