Loading...

hivemind-dev@jakarta.apache.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

[jira] Commented: (HIVEMIND-179) Provide access to the Registry Jochen Zimmermann (JIRA) Fri Jul 11 10:06:46 2008

    [ 
https://issues.apache.org/jira/browse/HIVEMIND-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597796#action_12597796
 ] 

Jochen Zimmermann commented on HIVEMIND-179:
--------------------------------------------

I finally found a way. Perhaps it is to naiv and it is for sure a little hack 
(I explain), but it works and perhaps is not too bad for a first shot :-)

I defined the registry as a service in the hivemind.xml of the framework like 
this:

<service-point id="Registry" interface="Registry">
  <invoke-factory service-id="RegistryFactory"/>
</service-point>

I wrote the registry factory, which just returns an instance of RegistryImpl. 
That's the hack, because I had to get the RegistryInfrastructure from the 
static ServiceSerializationHelper and had to cast it.

public class RegistryFactory implements ServiceImplementationFactory
{
    public Object createCoreServiceImplementation(
            ServiceImplementationFactoryParameters factoryParameters)
    {
        RegistryInfrastructure r = (RegistryInfrastructure) 
ServiceSerializationHelper.getServiceSerializationSupport();
        return new RegistryImpl(r);
    }
}

Finally I changed the RegistryBuilder to not instantiate the Registry itself 
but obtain it from the RegistryInfrastructure.

      infrastructure.startup();
      return (Registry) infrastructure.getService(Registry.class, null);

This way the registry is a service itself ... 
If we could implement the RegistryFactory "clean" someway, what do you think, 
would this make any sense?


> Provide access to the Registry
> ------------------------------
>
>                 Key: HIVEMIND-179
>                 URL: https://issues.apache.org/jira/browse/HIVEMIND-179
>             Project: HiveMind
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Martin Strand
>         Attachments: HIVEMIND-179.txt
>
>
> There is currently no way for a service to access its own Registry.
> This would be useful sometimes, for example if you've got a listener that is 
> invoked from a non-Hivemind thread:
> public class MyService()
> {
>    private Registry registry;
>    public MyService()
>    {
>      registry = getRegistry(); // <-- Need this
>      OutsideHivemind.registerListener(this);
>    }
>    public void invokeListener()
>    {
>      registry.setupThread();
>      // Use some Hivemind services...
>      registry.cleanupThread();
>    }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.