David Bernard wrote:
Hi,
Three possible approaches:** Decorator/Interceptor *** decorate Queue with QueueLogger (to send notification, log) *** decorate Queue with QueuePersistancer (to manage stop(crash)/start, based on Prevayler concept) *** decorate Queue with QueueBounder (to limit size,...)
a) the queue component implementation is a type that declares
dependencies and receives references to QueueLogger,
QueuePersistancer, and QueueBounder via a service manager.
No, my goal is to follow "decorator" design pattern, so decorated ignore possible decoration.
Are the decorations declarable at the level of a profile or is more dynamic than that? If its at the level of a profile then either a custom contexulizer or a lifecycle extension (which are two options noted below).
b) the queue component implementation is a type that declares deployment lifecycle stage dependencies and you declare the lifecycle stage handlers in the block.xml
c) the queue component implementation is a type that
declares a deployment dependency on a custom
contextualization provider in which case you provide
the provider the will handle the contextualization
(or any other invocations) against target components
I don't understand b and c.
Warning: the following links will not be available for a few hours.
B: Lifecycle Extensions
Both Merlin and Fortress provide support for the addition of custom lifecycle stages. Lifecycle stages can be invoked either during deployment/decommisioning or during access/release of a component.
http://avalon.apache.org/sandbox/merlin/starting/advanced/lifecycle/index.html
OPTION C: Defining a custom contextualization handler
While the above lifecycle extension mechanisms gives you the ability to add new stages, there is also the ability to replace the contextualization handler. This gives the ability to do anything you want including the implementation of completely different component models. My guess is this is what you will want to do to support the sort of things your thinking of.
http://avalon.apache.org/sandbox/merlin/starting/advanced/context.html (placeholder)
Example: merlin/merlin-core/src/test/org/apache/avalon/playground/*
My goals :
public interface Queue { ... }
public class QueueImplA implements Queue { ... }
public class QueueImplB implements Queue { ... }
public class QueueDecoratorX implements Queue { ... }
public class QueueDecoratorY implements Queue { ... }
and in config I like to be able to write :
<stage ...> <queue class="QueueImplA"/> <stage>
or <stage ...>
<queue class="QueueImplB"/>
<stage>
or <stage ...>
<queue class="QueueDecoratorX">
<queue class="QueueImplA"/>
</queue>
<stage>
or <stage ...>
<queue class="QueueDecoratorX">
<queue class="QueueDecoratorY">
<queue class="QueueImplA"/>
</queue>
</queue>
<stage>
or <stage ...>
<queue class="QueueDecoratorY">
<queue class="QueueDecoratorX">
<queue class="QueueImplA"/>
</queue>
</queue>
<stage>
* Decorator like any component have its own configuration, dependencies... * I know that <stage> could be <container name="stage-x"> and <queue> could be <component/container name="queue">...
All of the above can be done using the engine within a component assigned as a container. The Engine interface is entry point. Take a look at EngineTestCase in the merlin/assembly package for a working example of creating and assemblying coimponents dynamically.
If the composite queue can get everything it needs from context and/or serviceable stages, then your in classic "component" space. If on the other hand you composite queue is creating components then your in "containment" space. If you in "containment" space (i.e. building and deploying components) then you need to working with and extended Appliance or Block. My impression is that you could do what you want with a custom context provider which would keep things simple.** Composite *** create Composite Queue to manage subQueue (like this I could maintain ordre and use ThreadPool,...)
I'll investigate your suggestion (context provider).
to follow previous sample my goal is ablity to have :
// generate sub-queue by clone a prototype (design pattern) queue public class QueueCompositeM implements Queue { ... }
<stage> <queue class="QueueCompositeM"> <prototype class="QueueImplA"/> </queue> </stage> or <stage> <queue class="QueueCompositeM"> <prototype class="QueueDecoratorX"> <queue class="QueueImplA"/> </prototype> </queue> </stage> or ...
You can intercept the contextualization stage by creating a custom contextualization handler. An example is in the CVS under the path*** Stage is compose with : **** 1..1 queue (maybe a decorator or composite) **** 0..n processor (sorted) **** 0..1 Dispatcher (to
So Stage :
* construction ** need to define some context for queue, processor, disptacher (like the name, workdir...)
merlin/merlin-core/src/test/org/apache/avalon/playground
thanks
No problem - these would be represented as named components.** assemble/chain the processor(s) and disptacher * life style/algo (simple version) ** receive message from any component : other stage (via its dispather, service X like a socket listener...) and enqueue it ** select a Thread and wait message from the Queue ** take message from Queue and submit it to the chain of processor ** if message processing and dispatching is ok then remove message from the queue (ack)
Currently I've got a version running under Phoenix but with heavy configuration (Queue, Processor, Dispatcher are managed (lifecycle...) by Stage): * need 'cut and paste' stage's definition in assembly to be able to have several stage (with different name)
I know Merlin use well "name" attribute (include in my helloworld
version), it's against Pheonix "cut and paste".
Sorry - didn't understand the above - could you expand?
If I understand correctly - what you are describing is a dynamic component. I.e. a component that is programmatically established outside of the general deployment phase. Is this possible? Yes. Is a component acting as a container the right place to do it? Yes.* need to define Queue, Processor and Dispatcher dependencies has Stage dependencies, not very flexibeable : when I create a new Processor with other dependencies than the already exists in Stage, I need to modify the source of Stage (java generate .xinfo), all the defintion of stage instance in assembly.xml...
And if I choose to try Merlin it's first because Merlin is presented has able to manage sub/custom container. (And I saw the source/config of larm : http://marc.theaimsgroup.com/?l=avalon-users&m=104554030111477&w=2)
Inside the component implementation declared for the container, you has a supplementary default context entry "urn:assembly:engine". This context entry is only available to components acting as containers. Once you have access to the engine, you can narrow it to the Engine interface and use create or locate appliances within the current engine (immediate and parent engines). You locate services by locating the appliance and resolving the service from the appliance. If this sounds like what you want to do I can post additional details (examples are not available yet in the doc but test cases are available).
Example:
public void contextualize( Context context ) { Engine engine = (Engine) context.get( Engine.KEY );
// do dynamic stuff based on the operations exposed // on the Engine interface
}
See the Engine javadoc for details:
http://avalon.apache.org/sandbox/merlin/api/org/apache/avalon/assembly/engine/Engine.html
I've got lot of stuffs for near days ;-)
:-)
I don't see any problems based on what is described above. The main things appear to be (a) confirming that I understand your requirements correctly, and (b) getting in-place examples of both custom contextualization handlers and containers acting dynamically.I've got also an other constraint : production is targetted to september. If you see some incompatibility, hard stuff... please tell me
My best suggestion is to get together in a pub somewhere in Paris and talk about over a beer or two.and may be give some direction to investigate (fortress ??, custom like Cocoon team done...). Thanks a lot for your help.
With pleasur.
We'll have to drag Laurent in as well.
:-)
Cheers, Steve.
--
Stephen J. McConnell mailto:[EMAIL PROTECTED] http://www.osm.net
Sent via James running under Merlin as an NT service. http://avalon.apache.org/sandbox/merlin
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
