Rob Evans wrote:
Folks,
Is there a way to declare a service dependency such that Merlin will
fetch and instantiate from the repository a dependant service?
Yes.
Here are the details of what I am trying to do.
I have two teams (TeamA and TeamB) each of which creates and deploys
services in to a maven repository. TeamB would like to like to use a
service created by TeamA. How does TeamB declare a dependency on TeamA's
service such that Merlin will down load and initialize the service?
Lets assume that Team A is working on a Widget service and a DefaultWidget
implementation. They would define a maven project containing two suprojects,
api and impl. The api subproject would contain the defintion of the Widget
service (the interface) and the impl would contain the DefaultWidget class.
The artifacts produced by this project are classified by the groupId and
artifact id declared in the project.xml files. Let's assume that the widget
team are using group of "biz" and an artifact id of "widget-api" for the
api subproject and "widget-impl" for the impl subproject. Team A would
publish the resulting artifacts into a repository shared by Team A and
Team B. Assuming that the common repository is at F:/repository/, the using the
repository naming conventions the widget artifacts would be (assuming the
version is set to SNAPSHOT) added as:
F:/repository/biz/jars/eidget-api-SNAPSHOT.jar F:/repository/biz/jars/eidget-impl-SNAPSHOT.jar
Team B creates a project that will use Team A's Widget service. Let's assume
that team B have created a Gizmo service and that there DefaultGizmo compoent
depends on Widget. The project.xml for the Team B's impl would contain:
<dependencies> <dependency>
<groupId>biz</groupId>
<artifactId>widget-api</artifactId>
<version>SNAPSHOT</version>
</dependency>
</dependencies>
This address build time integration. However, lets assume that Team B want to run a test case that deploys Team A's Widget as a service used by Team B DefaultGizmo. In this case you define a container that import's Team A's service. You can either do this directlty or by import.
Here is a direct example:
<container name="demo">
<classloader>
<classpath>
<repository>
<resource id="biz:widget-api" version="SNAPSHOT"/>
<resource id="biz:widget-impl" version="SNAPSHOT"/>
<resource id="biz:gizmo-api" version="SNAPSHOT"/>
<resource id="biz:gizmo-impl" version="SNAPSHOT"/>
</repository>
</classpath>
</classloader><component name="gizmo"
class="biz.DefaultGizmo" activation="startup">
</component>
</container>
But this could be a lot cleaner. Insead of draggin in the implementation classes from Team A, we could make things a lot nicer by importing.
<container name="demo">
<classloader>
<classpath>
<repository>
<resource id="biz:widget-api" version="SNAPSHOT"/>
<resource id="biz:gizmo-api" version="SNAPSHOT"/>
<resource id="biz:gizmo-impl" version="SNAPSHOT"/>
</repository>
</classpath>
</classloader><include name="widget" id="biz:widget-impl" version="SNAPSHOT"/>
<component name="gizmo"
class="biz.DefaultGizmo" activation="startup">
</component>
</container>
In the above example - the implementation classes from Team A are maintaining in a seperate classloader. The classloader containing DefaultGizmo and Team A's classloader share the
API classes declared by Team A. To make this possible - Team A should make sure that their
block defintion exports the Widget service.
For example - Team A could publish a block like the follwing (not the addition of a service export at the beginning):
<container name="widgets">
<services>
<service type="biz.Widget">
<source>widget</source>
</service>
</services> <classloader>
<classpath>
<repository>
<resource id="biz:widget-api" version="SNAPSHOT"/>
<resource id="biz:widget-impl" version="SNAPSHOT"/>
</repository>
</classpath>
</classloader><component name="widget" class="biz.DefaultWidget"/>
</container>
So when Team B runs a testcase, Merlin will pull in all of the necessary resources using the repositories declared an avalon.properties file (located in the current working directory, the user's home directory, or the avalon home directory). The property entry would be something like:
avalon.repository.hosts = file:///F:/reposistory,http;//dpml.net/,...
Cheers, Steve.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--
Stephen J. McConnell mailto:[EMAIL PROTECTED]
|------------------------------------------------| | Magic by Merlin | | Production by Avalon | | | | http://avalon.apache.org/merlin | | http://dpml.net/ | |------------------------------------------------|
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
