Having just encountered this in the development of my server, I believe the
reason for option (3) is when you need to access multiple instances of a
service that happen to serve as different roles.  For instance, in my server
I am using the Cornerstone EventManager service.  However, I have the
concept of processing events coming from an external application(s) and the
concept of sending events to an external application(s).  I actually needed
two instances of EventManager to handle the pub/sub of both types of events
among a set blocks in my server application.  In other words, I might have a
block that needs to subscribe to events coming from some external
application, but needs to publish events destined to some external
application.  Two different Event Managers handle this.

In order to accomplish this, my blocks could not obtain the desired instance
of the EventManager simply by performing a lookup on the service ROLE or on
the server interface name.  I had to define two separate "arbitrary" roles
for each EventManager block that I defined in the assembly.xml.

"J Aaron Farr" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello.
>
> As best as I can tell there are a couple of different conventions for
naming
> your services:
>
> 1. Interface Names
>
>    The service is named after the java interface which defines it's
contract:
>
>   MyService myservice = (MyService)
m_manager.lookup("org.proj.MyService");
>  or
>   MyService myservice = (MyService)
> m_manager.lookup(MyService.class.getName());
>
>    (where m_manager = ServiceManager instance)
>
> 2. ROLE Names
>
>    Similiar to above, but the name itself is defined by a static ROLE
variable:
>
>    public interface MyService {
>       public static String ROLE = MyService.class.getName();
>    }
>
>    MyService myservice = (MyService) m_manager.lookup(MyService.ROLE);
>
> 3. Descriptive String Names
>
>    Some "arbitrary" descriptive string which is defined in a meta-info or
roles
> file. I've seen this in Merlin and in EOB (in examples):
>
>    MyService myservice = (MyService) m_manager.lookup( "MyService" );
>
>
> Is there a best practice?
>
> It seems to me that (1) is the most commonly used, though I've used the
ROLE
> method quite a bit myself.  (3) doesn't look like a good idea, or is there
a
> reasonable use case for it?
>
> Did I miss any? Also if I recall, there was a question about why we use
Strings
> at all instead of Class objects.
>
> Thanks,
> jaaron
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to