Skip to main content

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

It is not technically wrong but it is completely inconsistent with ICE's architecture. DS also has some significant advantages over ServiceReferences albeit at the cost of explicitly implementing an operation for each service, (which you can get around if you need to).

ICE is designed to be as declarative as possible so that changing components does not mean changing code.

Jay

On 06/22/2015 04:26 PM, McCaskey, Alex wrote:
Even though all our services come from DS, is it technically wrong to grab the service reference like Greg suggests? I ask because I actually implemented a fix for this before reading Andrew’s PTP emails, and it works fine and I was about to push. But if we aren’t supposed to use services like this then I’ll restructure. 

Alex


On Jun 22, 2015, at 3:02 PM, Jay Jay Billings <jayjaybillings@xxxxxxxxx> wrote:

Andrew,

You need to acquire these services using OSGi Declarative Services (DS) instead of services references. Every service used by ICE is obtained using the former and there are no instances of the latter in the entire ICE codebase (unless someone snuck one in).

If you don't know how to use DS, let us know and we can show you. For reference, the component.xml files in ICE that you needed to create for VIBE and PROTEUS are DS components.

Jay

---------- Forwarded message ----------
From: Greg Watson <g.watson@xxxxxxxxxxxx>
Date: Mon, Jun 22, 2015 at 3:08 PM
Subject: Re: [ptp-dev] [ptp-user] Refactoring code for Mars
To: PTP User list <ptp-user@xxxxxxxxxxx>
Cc: Parallel Tools Platform general developers <ptp-dev@xxxxxxxxxxx>


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

_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ptp-dev



--
Jay Jay Billings
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings
_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev

Alex McCaskey
ORNL Computer Science Research
(865) 574-8715





_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev

-- 
Jay Jay Billings
Oak Ridge National Laboratory
(865) 241-6308
Twitter Handle: @jayjaybillings

I only check email at 8:30, 12:30 and 16:30 every day. Please call me or send 
me a tweet if your message is urgent and I will take a look.

Back to the top