You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by spamsucks <sp...@rhoderunner.com> on 2006/03/20 00:42:46 UTC

Using hivemind as an object factory?

I have a set of pojos.  Each pojo represents a distinct virtual file 
system (a stitch system).  Each of these pojo's take a distinct 
constructor argument (the file system path to the real file system).  
The problem that I am having is that I want only one pojo for each 
distinct file system path.  I do not want multiple instances of a pojo 
all pointing to the same file system location.  Up to now, I have not 
been concerned over lifecycle of these pojo's and just creating them via 
the constructor (e.g. StitchFolder stitch = new 
StitchFolder("/usr/local/stitch1")) 

While I could "code up" a singleton factory, I would rather see how 
hivemind would help me out here.  I would appreciate a pointer on an 
example that does as I described above. 



Thanks.

Phillip

http://stitches.authsum.org
The first CMS library



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


Re: Using hivemind as an object factory?

Posted by Chris Burnley <ch...@gmail.com>.
Do you need to refer to each folder seperately by a well known name or are
you going to iterate over a collection and display a list to the user etc.

If the latter, a hivemind approach would to be use a confiugration point
(I've not tested this so there might be some small errors,)

<configuration id="StitchFolders">
   <schema>
     <element name="folder" key-attribute="dir">
        <attribute name="dir" translator="string"/>
        <conversion class='package.name.of.StitchFolder/>
    </element>
  </schema>
</configuration>

contribute this to your service using the set-contribution element.

the above assumes you've got a no-args constructor and a method called
setDir
then later on, in the same module or different one, contribute to the
configuration :

<contribution id="moduleName.StitchFolders">
    <folder dir="/usr/local/stich1"/>
</contribution>

On 3/31/06, Ryan <ry...@evine.ca> wrote:
>
> You'll need to create a seperate service for each real file system path,
> but here goes my attempt to help.
>
> In your hivemodule.xml file:
>
>    <service-point id="Stitch1"  interface="StitchFolder">
>      <invoke-factory>
>        <construct class="StitchFolder">
>          <string>/usr/local/stitch1</string>
>        </construct>
>      </invoke-factory>
>    </service-point>
>
> Then you will need to inject this service into your code. Or maybe into
> another service that organizes all your virtal file systems.
>
> Is this all you're looking to use Hivemind for? I find it's not the sort
> of tool I can add in later, as it changes the way I develop (way more
> modular). If all you need is a singleton factory, I would likely just do
> it the 'old fashioned way'. But hey, I'm no Hivemind expert.
>
> --Ryan
>
> spamsucks wrote:
> >
> > I have a set of pojos.  Each pojo represents a distinct virtual file
> > system (a stitch system).  Each of these pojo's take a distinct
> > constructor argument (the file system path to the real file system).
> > The problem that I am having is that I want only one pojo for each
> > distinct file system path.  I do not want multiple instances of a pojo
> > all pointing to the same file system location.  Up to now, I have not
> > been concerned over lifecycle of these pojo's and just creating them via
> > the constructor (e.g. StitchFolder stitch = new
> > StitchFolder("/usr/local/stitch1"))
> > While I could "code up" a singleton factory, I would rather see how
> > hivemind would help me out here.  I would appreciate a pointer on an
> > example that does as I described above.
> >
> >
> > Thanks.
> >
> > Phillip
> >
> > http://stitches.authsum.org
> > The first CMS library
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>
>

Re: Using hivemind as an object factory?

Posted by Ryan <ry...@evine.ca>.
You'll need to create a seperate service for each real file system path, 
but here goes my attempt to help.

In your hivemodule.xml file:

   <service-point id="Stitch1"  interface="StitchFolder">
     <invoke-factory>
       <construct class="StitchFolder">
         <string>/usr/local/stitch1</string>
       </construct>
     </invoke-factory>
   </service-point>

Then you will need to inject this service into your code. Or maybe into 
another service that organizes all your virtal file systems.

Is this all you're looking to use Hivemind for? I find it's not the sort 
of tool I can add in later, as it changes the way I develop (way more 
modular). If all you need is a singleton factory, I would likely just do 
it the 'old fashioned way'. But hey, I'm no Hivemind expert.

--Ryan

spamsucks wrote:
> 
> I have a set of pojos.  Each pojo represents a distinct virtual file 
> system (a stitch system).  Each of these pojo's take a distinct 
> constructor argument (the file system path to the real file system).  
> The problem that I am having is that I want only one pojo for each 
> distinct file system path.  I do not want multiple instances of a pojo 
> all pointing to the same file system location.  Up to now, I have not 
> been concerned over lifecycle of these pojo's and just creating them via 
> the constructor (e.g. StitchFolder stitch = new 
> StitchFolder("/usr/local/stitch1"))
> While I could "code up" a singleton factory, I would rather see how 
> hivemind would help me out here.  I would appreciate a pointer on an 
> example that does as I described above.
> 
> 
> Thanks.
> 
> Phillip
> 
> http://stitches.authsum.org
> The first CMS library


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