Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 99856fac3eb59f57fbe6aa3baa8fafa63edf1aab (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
/*******************************************************************************
 * Copyright (c) 2007 Versant Corp.
 * 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:
 *     Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
 ******************************************************************************/
package org.eclipse.ecf.provider.jslp.container;

import ch.ethz.iks.slp.ServiceLocationException;
import ch.ethz.iks.slp.ServiceURL;
import java.net.URI;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.discovery.*;
import org.eclipse.ecf.discovery.identity.*;
import org.eclipse.ecf.internal.provider.jslp.ServicePropertiesAdapter;
import org.eclipse.ecf.internal.provider.jslp.ServiceURLAdapter;
import org.eclipse.ecf.provider.jslp.identity.JSLPNamespace;

public class JSLPServiceInfo extends ServiceInfo implements IServiceInfo {

	private static final long serialVersionUID = 6828789192986625259L;

	public JSLPServiceInfo(URI anURI, IServiceID serviceID, int priority, int weight, IServiceProperties props) {
		super(anURI, serviceID, priority, weight, props);
	}

	public JSLPServiceInfo(IServiceID serviceID) {
		//TODO-mkuppe https://bugs.eclipse.org/230182
		super(null, serviceID, -1, -1, new ServiceProperties());
	}

	public JSLPServiceInfo(IServiceInfo aSI) throws IDCreateException, SecurityException {
		this(aSI.getLocation(), ServiceIDFactory.getDefault().createServiceID(IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME), aSI.getServiceID().getServiceTypeID(), aSI.getServiceID().getServiceName()), aSI.getPriority(), aSI.getWeight(), aSI.getServiceProperties());
	}

	//If decided to transport prio, proto and weight as ServiceProperties, here would be a good place (remove prio and weight)
	public JSLPServiceInfo(ServiceURLAdapter anAdapter, int priority, int weight, ServicePropertiesAdapter aServicePropertiesAdapter) {
		this(anAdapter.getURI(), anAdapter.getIServiceID(), priority, weight, aServicePropertiesAdapter.toServiceProperties());
	}

	public ServiceURL getServiceURL() throws ServiceLocationException {
		IServiceTypeID stid = getServiceID().getServiceTypeID();
		URI location = getLocation();
		String scheme = location.getScheme();
		String authority = location.getAuthority();
		String path = location.getPath() == null ? "" : location.getPath(); //$NON-NLS-1$
		return new ServiceURL(stid.getInternal() + "://" + scheme + "://" + authority + path, ServiceURL.LIFETIME_PERMANENT); //$NON-NLS-1$ //$NON-NLS-2$
	}
}

Back to the top