Differences between revisions 1 and 2
Revision 1 as of 2005-11-14 18:36:07
Size: 2271
Editor: RonPiterman
Comment:
Revision 2 as of 2009-09-20 23:20:32
Size: 2273
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
[[TableOfContents]] <<TableOfContents>>
Line 42: Line 42:
 1. the above syntax creates a singleton service, which means, your service will be instanciated once and will be used from all threads of the application. Hivemind offers 4 instaciation models. To use them, use the {{{model}}} attribute of the {{{<invoke-factory>}}} element. See [http://jakarta.apache.org/hivemind/services.html#Defining+Services here] for details.  1. the above syntax creates a singleton service, which means, your service will be instanciated once and will be used from all threads of the application. Hivemind offers 4 instaciation models. To use them, use the {{{model}}} attribute of the {{{<invoke-factory>}}} element. See [[http://jakarta.apache.org/hivemind/services.html#Defining+Services|here]] for details.

Hivemind for Beginners

hivemind configuration file location

Hivemind is configured through an xml file called hivemodule.xml. Tapestry configures hivemind to look for this file in three different places. All can be used simultaniously or alternatively:

  •  /META-INF  hivemind will load all  /META-INF/hivemodule.xml  on the classpath. this includes all classes directories and jar files.

  •  <context>/WEB-INF/ 

  •  <context>/WEB-INF/<app-name>/  practical if you have more than one tapestry application in the same context and you don't wish them to share certain hivemind configuration.

creating a service

Here is a simple example of the  hivemodule.xml .

<?xml version="1.0"?>
<module id="moduleid" version ="1.0.0" package="package.name">
  <service-point id="ServiceId"   
    interface="interface.name.relative.to.package.or.absolute">
    <invoke-factory>

      <construct
     class="implementation.class.name.relative.to.package.or.absolute"/>

    </invoke-factory>
  </service-point>
</module>

alternativley, you can separate <service-point> as an empty element, and use the <invoke-factory> element in an...

<implementation service-id="ServiceId">
  <invoke-factory...
</implementation>

To use your service in tapestry components or pages you "inject" it, using the following syntax (in the .jwc or .page file)

<inject object="service:moduleid.ServiceId" property="nameOfProperty"/>

If you want to use annotations, use:

@InjectObject("service:moduleid.ServiceId")
public abstract ServiceInterface getXXX();

notes

  1. the above syntax creates a singleton service, which means, your service will be instanciated once and will be used from all threads of the application. Hivemind offers 4 instaciation models. To use them, use the model attribute of the <invoke-factory> element. See here for details.

  2. All module/services names are case sensitive.

Referencing other files from hivemodule.xml

<sub-module descriptor="relative.path.to.another.module.description.xml"/>

Hivemind4Beginners (last edited 2009-09-20 23:20:32 by localhost)