Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Best Practices
Best Practices [message #459964] Fri, 08 December 2006 17:50 Go to next message
Eclipse UserFriend
Originally posted by: jkidd.kiddcorp.com

We are in the process of building an RCP application. Where can I find some best practices? Questions like inter plugin communication, having a separate business tier access layer in the client, etc..

One concrete issue I have right now is this:
I have View element A
I have Spring Service plugin B

I want A to use B. Now I can access directly in a singletone type fashion but is that a best practice? It seems that I could also do an OSGI service but I can't find how to get to that from an Action class..


Any direction would be good. I have the Adddison Wesley RCP and Plugin books but there are still a lot of un-answered questions..

John
Re: Best Practices [message #459982 is a reply to message #459964] Sun, 10 December 2006 10:05 Go to previous messageGo to next message
Eclipse UserFriend
John Kidd wrote:
> We are in the process of building an RCP application. Where can I find some best practices? Questions like inter plugin communication, having a separate business tier access layer in the client, etc..
>
> One concrete issue I have right now is this:
> I have View element A
> I have Spring Service plugin B
>
> I want A to use B. Now I can access directly in a singletone type fashion but is that a best practice? It seems that I could also do an OSGI service but I can't find how to get to that from an Action class..


So I have heard good things about
http://wiki.eclipse.org/index.php/RCP_Book and
http://www.amazon.com/Eclipse-Building-Commercial-Quality-Pl ug-ins/dp/0321228472
although it sounds like you might have those books already.

It sounds like you have 3 choices.

1. if you want a view to display your spring framework information, then
have A depend on B and just call methods. In eclipse the common
pattern would be to put a manager or registry in B's plugin activator,
since that will be the singleton. Then in A you can access it as
ActivatorB.getDefault().getSpringManager() ...

2. if you want your view to display a certain kind of information, and
your spring plugin is one source of that information, then write an
extension point and some interfaces in A, and have B depend on A,
provide an extension to A, and implement A's interfaces. Your view is
basically using the extension point to determine if there are any
sources of information, and using the eclipse framework and
IConfigurationElement#createExecutableExtension(*) to instantiate
classes from B (that implement A interfaces).

3. you can do this with OSGi services if you really want ... you write a
service interface and register that with OSGi. Then one of A or B
implements the service and registers with OSGi. Then the other of B or
A would use its own activator to save the BundleContext and can retrieve
the service from OSGi.

Then you decide if you're providing a view service that B could use, or
a spring service that A could use :-)

There are certainly no lack of options, it depends on your design
constraints and possible ways you think your application would grow.

If you are just viewing your spring service, I would go with 1.

If you suspect your viewer is more generalized so you could plug other
sources into it, I would go with 2.

If you think that OSGi could benefit from your service (or are
considering other OSGi implementations), you could go with 3.


Later,
PW
Re: Best Practices [message #459991 is a reply to message #459982] Sun, 10 December 2006 15:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jkidd.kiddcorp.com

So how do I get the OSGI service from an action class? :-)


John
Re: Best Practices [message #460006 is a reply to message #459991] Mon, 11 December 2006 08:58 Go to previous message
Eclipse UserFriend
John Kidd wrote:
> So how do I get the OSGI service from an action class? :-)
>

You're going to have to put the "service management" code in your
activator, since that's the easiest way to access the BundleContext.
Then your action would ask your activator for the information or service.

ex:

MyService service = MyPlugin.getDefault().getMyService();
// use service
// if you don't want to hold the service around as a singleton,
// the you can release it
MyPlugin.getDefault().releaseMyService(s);


"Service Management" code looks something like:

ServiceReference packageAdminRef = context
.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = null;
if (packageAdminRef != null) {
packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
}
// use packageAdmin service
context.ungetService(packageAdminRef);

Later,
PW
Previous Topic:plugin editor
Next Topic:EditorParts, doSave(), commands, and key bindings
Goto Forum:
  


Current Time: Sat Mar 15 23:58:25 EDT 2025

Powered by FUDForum. Page generated in 0.40203 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top