You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Michael Mattox <mi...@verideon.com> on 2005/09/01 19:03:34 UTC

How to construct registry for web service

I'm using the hivemind servlet filter for my webapp which works great. 
I'm curious how I can use it for my web service.  For now I'm working on a
small webapp that has both a webapp and a web service in the same webapp. 
If I use:

RegistryBuilder.constructDefaultRegistry();

then will I destroy the registry created by the filter?

Another idea I had was to create a static class with a static method
getRegistry.  A servlet could get the registry from the servlet filter and
set it on the static class, so then the web service would just get the
registry from the static class.  This seems like a lot of work though just
to get the registry.  Is there a better way?

-Michael



--
This E-mail is confidential.  It may also be legally privileged.  If you are
not the addressee you may not copy, forward, disclose or use any part of it.
If you have received this message in error, please delete it and all copies
from your system and notify the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free.  The sender does not accept liability for any errors or omissions.


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


RE: How to construct registry for web service

Posted by Jean-Francois Poilpret <jf...@hcm.vnn.vn>.
Hi Michael,

For testing with Junit, it depends on how your web service is implemented.
But the basic idea would be to have your actual service injected with
dependencies through HiveMind, ie, no need to directly refer to the
Registry.

This is what I have done in HiveRemoting: I created a servlet that just
dispatches calls to the actual service, the servlet uses the Registry (from
the HiveMindFilter, in this case even no need for the
HiveMindRegistryPublishFilter) to look up the actual service, and since that
service is declared in hivemodule.xml, then all necessary dependencies are
transparently injected by HiveMind (so, no need for the Registry in the
service).

If you do it this way, then unit testing of your service is a breeze: just
inject dependencies (possibly mock objects) in your web service and off you
go!

I don't know which library you use to build web services, but if you use
Caucho hessian or burlap, then I would strongly advise you to use the
HiveRemoting module from HiveMind Utilities, if you use another library,
then HiveRemoting would also be worth a look to get inspiration maybe.

Cheers

	Jean-Francois

-----Original Message-----
From: Michael Mattox [mailto:michael@verideon.com] 
Sent: Friday, September 02, 2005 12:49 AM
To: Jean-Francois Poilpret
Cc: hivemind-user@jakarta.apache.org
Subject: RE: How to construct registry for web service

Jean-Francois,

Thanks for the quick reply.  This is definitely a cleaner solution.  I
knew I needed the request object, which I don't have in my web service,
but I didn't think of another servlet filter.

Just one question..  I like to test my web service with JUnit, without
going through the web service.  I'm curious if there is a mechanism in
place to create the registry in the event that the application is not
being run as a web service.  If not, this would be a nice feature.  Kind
of a last resort to create the registry.

Thanks,
Michael


> Hi,
>
> For the time being, you can try to use HiveMindRegistryPublishFilter from
> the hiveutils module in HiveMind Utilities project (you can go to URL
> http://hivetranse.sourceforge.net for more info).
> You just have to put this Filter right after HiveMindFilter, then call its
> getRegistry() static method to obtain the registry that was constructed by
> HiveMindFilter. That filter uses a ThreadLocal to store the Registry.
>
> Cheers
>
> 	Jean-Francois
>
> -----Original Message-----
> From: James Carman [mailto:james@carmanconsulting.com]
> Sent: Friday, September 02, 2005 12:08 AM
> To: hivemind-user@jakarta.apache.org; michael@verideon.com
> Subject: RE: How to construct registry for web service
>
> There should be (and maybe soon will be) a ThreadLocalRegistry class (or
> whatever you want to call it) in HiveMind which holds a reference to a
> registry to be used by the currently executing thread.  HiveMindFilter
> should be retrofitted to use this class.
>
> -----Original Message-----
> From: Michael Mattox [mailto:michael@verideon.com]
> Sent: Thursday, September 01, 2005 1:04 PM
> To: hivemind-user@jakarta.apache.org
> Subject: How to construct registry for web service
>
> I'm using the hivemind servlet filter for my webapp which works great.
> I'm curious how I can use it for my web service.  For now I'm working on a
> small webapp that has both a webapp and a web service in the same webapp.
> If I use:
>
> RegistryBuilder.constructDefaultRegistry();
>
> then will I destroy the registry created by the filter?
>
> Another idea I had was to create a static class with a static method
> getRegistry.  A servlet could get the registry from the servlet filter and
> set it on the static class, so then the web service would just get the
> registry from the static class.  This seems like a lot of work though just
> to get the registry.  Is there a better way?
>
> -Michael
>
>
>
> --
> This E-mail is confidential.  It may also be legally privileged.  If you
> are
> not the addressee you may not copy, forward, disclose or use any part of
> it.
> If you have received this message in error, please delete it and all
> copies
> from your system and notify the sender immediately by return E-mail.
> Internet communications cannot be guaranteed to be timely, secure, error
> or
> virus-free.  The sender does not accept liability for any errors or
> omissions.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>
>
>



--
This E-mail is confidential.  It may also be legally privileged.  If you are
not the addressee you may not copy, forward, disclose or use any part of it.
If you have received this message in error, please delete it and all copies
from your system and notify the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free.  The sender does not accept liability for any errors or
omissions.


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


RE: How to construct registry for web service

Posted by Michael Mattox <mi...@verideon.com>.
Jean-Francois,

Thanks for the quick reply.  This is definitely a cleaner solution.  I
knew I needed the request object, which I don't have in my web service,
but I didn't think of another servlet filter.

Just one question..  I like to test my web service with JUnit, without
going through the web service.  I'm curious if there is a mechanism in
place to create the registry in the event that the application is not
being run as a web service.  If not, this would be a nice feature.  Kind
of a last resort to create the registry.

Thanks,
Michael


> Hi,
>
> For the time being, you can try to use HiveMindRegistryPublishFilter from
> the hiveutils module in HiveMind Utilities project (you can go to URL
> http://hivetranse.sourceforge.net for more info).
> You just have to put this Filter right after HiveMindFilter, then call its
> getRegistry() static method to obtain the registry that was constructed by
> HiveMindFilter. That filter uses a ThreadLocal to store the Registry.
>
> Cheers
>
> 	Jean-Francois
>
> -----Original Message-----
> From: James Carman [mailto:james@carmanconsulting.com]
> Sent: Friday, September 02, 2005 12:08 AM
> To: hivemind-user@jakarta.apache.org; michael@verideon.com
> Subject: RE: How to construct registry for web service
>
> There should be (and maybe soon will be) a ThreadLocalRegistry class (or
> whatever you want to call it) in HiveMind which holds a reference to a
> registry to be used by the currently executing thread.  HiveMindFilter
> should be retrofitted to use this class.
>
> -----Original Message-----
> From: Michael Mattox [mailto:michael@verideon.com]
> Sent: Thursday, September 01, 2005 1:04 PM
> To: hivemind-user@jakarta.apache.org
> Subject: How to construct registry for web service
>
> I'm using the hivemind servlet filter for my webapp which works great.
> I'm curious how I can use it for my web service.  For now I'm working on a
> small webapp that has both a webapp and a web service in the same webapp.
> If I use:
>
> RegistryBuilder.constructDefaultRegistry();
>
> then will I destroy the registry created by the filter?
>
> Another idea I had was to create a static class with a static method
> getRegistry.  A servlet could get the registry from the servlet filter and
> set it on the static class, so then the web service would just get the
> registry from the static class.  This seems like a lot of work though just
> to get the registry.  Is there a better way?
>
> -Michael
>
>
>
> --
> This E-mail is confidential.  It may also be legally privileged.  If you
> are
> not the addressee you may not copy, forward, disclose or use any part of
> it.
> If you have received this message in error, please delete it and all
> copies
> from your system and notify the sender immediately by return E-mail.
> Internet communications cannot be guaranteed to be timely, secure, error
> or
> virus-free.  The sender does not accept liability for any errors or
> omissions.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>
>
>



--
This E-mail is confidential.  It may also be legally privileged.  If you are
not the addressee you may not copy, forward, disclose or use any part of it.
If you have received this message in error, please delete it and all copies
from your system and notify the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free.  The sender does not accept liability for any errors or omissions.


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


RE: How to construct registry for web service

Posted by Jean-Francois Poilpret <jf...@hcm.vnn.vn>.
Hi,

For the time being, you can try to use HiveMindRegistryPublishFilter from
the hiveutils module in HiveMind Utilities project (you can go to URL
http://hivetranse.sourceforge.net for more info).
You just have to put this Filter right after HiveMindFilter, then call its
getRegistry() static method to obtain the registry that was constructed by
HiveMindFilter. That filter uses a ThreadLocal to store the Registry.

Cheers

	Jean-Francois

-----Original Message-----
From: James Carman [mailto:james@carmanconsulting.com] 
Sent: Friday, September 02, 2005 12:08 AM
To: hivemind-user@jakarta.apache.org; michael@verideon.com
Subject: RE: How to construct registry for web service

There should be (and maybe soon will be) a ThreadLocalRegistry class (or
whatever you want to call it) in HiveMind which holds a reference to a
registry to be used by the currently executing thread.  HiveMindFilter
should be retrofitted to use this class. 

-----Original Message-----
From: Michael Mattox [mailto:michael@verideon.com] 
Sent: Thursday, September 01, 2005 1:04 PM
To: hivemind-user@jakarta.apache.org
Subject: How to construct registry for web service

I'm using the hivemind servlet filter for my webapp which works great. 
I'm curious how I can use it for my web service.  For now I'm working on a
small webapp that has both a webapp and a web service in the same webapp. 
If I use:

RegistryBuilder.constructDefaultRegistry();

then will I destroy the registry created by the filter?

Another idea I had was to create a static class with a static method
getRegistry.  A servlet could get the registry from the servlet filter and
set it on the static class, so then the web service would just get the
registry from the static class.  This seems like a lot of work though just
to get the registry.  Is there a better way?

-Michael



--
This E-mail is confidential.  It may also be legally privileged.  If you are
not the addressee you may not copy, forward, disclose or use any part of it.
If you have received this message in error, please delete it and all copies
from your system and notify the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free.  The sender does not accept liability for any errors or
omissions.


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


RE: How to construct registry for web service

Posted by James Carman <ja...@carmanconsulting.com>.
There should be (and maybe soon will be) a ThreadLocalRegistry class (or
whatever you want to call it) in HiveMind which holds a reference to a
registry to be used by the currently executing thread.  HiveMindFilter
should be retrofitted to use this class. 

-----Original Message-----
From: Michael Mattox [mailto:michael@verideon.com] 
Sent: Thursday, September 01, 2005 1:04 PM
To: hivemind-user@jakarta.apache.org
Subject: How to construct registry for web service

I'm using the hivemind servlet filter for my webapp which works great. 
I'm curious how I can use it for my web service.  For now I'm working on a
small webapp that has both a webapp and a web service in the same webapp. 
If I use:

RegistryBuilder.constructDefaultRegistry();

then will I destroy the registry created by the filter?

Another idea I had was to create a static class with a static method
getRegistry.  A servlet could get the registry from the servlet filter and
set it on the static class, so then the web service would just get the
registry from the static class.  This seems like a lot of work though just
to get the registry.  Is there a better way?

-Michael



--
This E-mail is confidential.  It may also be legally privileged.  If you are
not the addressee you may not copy, forward, disclose or use any part of it.
If you have received this message in error, please delete it and all copies
from your system and notify the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely, secure, error or
virus-free.  The sender does not accept liability for any errors or
omissions.


---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org