Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ptp-user] Refactoring code for Mars

Andrew,

Documentation is definitely one thing that needs to be improved…

Basically, RemoteServices has been replaced with IRemoteServicesManager, and IRemoteServices and IRemoteConnectionManager have been replaced with IRemoteConnectionType. Most of the other interfaces are the same, except they have been replaced with *Service versions. e.g. IRemoteFileManager -> IRemoteFileService. 

You can think of a “connection type” as representing a communication protocol, like SSH, Serial, Telnet, etc. 

Everything is now a service, so you need to add some code like this to your plugin:

	/**
	 * Return the OSGi service with the given service interface.
	 * 
	 * @param service service interface
	 * @return the specified service or null if it's not registered
	 */
	public static <T> T getService(Class<T> service) {
		BundleContext context = plugin.getBundle().getBundleContext();
		ServiceReference<T> ref = context.getServiceReference(service);
		return ref != null ? context.getService(ref) : null;
	}

Now you obtain the “root” of the tree, IRemoteServicesManager using:

	IRemoteServicesManager mgr = getService(IRemoteServicesManager.class);

Next, you obtain the IRemoteConnectionType interface using:

	IRemoteConnectionType connType = mgr.getConnectionType(“ssh://url”);

A connection type has methods for creating and retrieving IRemoteConnection interfaces, in much the same way as IRemoteConnectionManager.

Pretty much everything else is a service. To obtain the interface, you need to check if it is a "connection type” service (extends IRemoteConnectionType.Service) or a “connection” service (extends IRemoteConnection.Service), then call the getService() method on the corresponding interface.

e.g. to obtain an IRemoteFileService (extends IRemoteConnection.Service):

	IRemoteFileService fileSvc = connection.getService(IRemoteFileService.class).

To obtain an IRemoteUIFileService (extends IRemoteConnectionType.Service):

	IRemoteUIFileService uiFileSvc = connectionType.getService(IRemoteUIFileService.class);

Let me know if there is anything else I can clarify.

Greg



> On Jun 22, 2015, at 2:09 PM, Bennett, Andrew R. <bennettar@xxxxxxxx> wrote:
> 
> HI, I'm a developer on Eclipse ICE (https://projects.eclipse.org/projects/technology.ice/developer) and we are working on moving our default platform from Kepler to Mars.  It looks like there have been some API changes to org.eclipse.remote that we are unsure about how to resolve.  Specifically the pieces we are having some trouble with are:
> 
> org.eclipse.remote.core.IRemoteConnectionManager
> org.eclipse.remote.core.IRemoteFileManager
> org.eclipse.remote.core.IRemoteServices
> org.eclipse.remote.core.RemoteServices
> 
> Could anyone offer up advice on how to port these to the most recent version of the Remote Services plugin?  
> 
> Thanks,
> Andrew
> _______________________________________________
> ptp-user mailing list
> ptp-user@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/ptp-user



Back to the top