Using Merlin

Behind the Scenes -info

To get a better understanding of what is happening we can ask Merlin to present a summary of the source information and resources used in our component deployment scenario by including the -info command line modifier.

$ merlin -execute target\classes -info

  Version: Merlin SMP 3.0
  Environment: Windows NT 4.0 Java 1.4.2
  Deployment Home: ${user.dir}/home
  Runtime Repository: F:\system\maven
  Library Anchor: ${user.dir}
  Kernel Path: resource:/kernel.xml
  Deployment Blocks: file:/${user.dir}/target/classes/
  Override Path:
  Server Flag: false
  Debug Flag: true

[INFO   ] (tutorial.hello): logging
[INFO   ] (tutorial.hello): initialization
[INFO   ] (tutorial.hello): execution
[INFO   ] (tutorial.hello): disposal

Targetted debugging using -config

We can also override the logging priority for the component using a target override directive.

${basedir}\conf\config.xml

<targets>
  <target path="/tutorial/hello">
    <categories priority="DEBUG"/>
  </target>
</targets>

The behind the scenes activity is detailed under the <component-path>.appliance logging category as shown below.

$ merlin -execute target\classes -config conf\config.xml

[DEBUG  ] (tutorial.hello.appliance): assembly phase
[DEBUG  ] (tutorial.hello.appliance): deployment (transient) [true]
[DEBUG  ] (tutorial.hello.appliance): new instance: 24531886
[DEBUG  ] (tutorial.hello.appliance): applying logger to: 24531886
[INFO   ] (tutorial.hello): logging
[DEBUG  ] (tutorial.hello.appliance): applying initialization to: 24531886
[INFO   ] (tutorial.hello): initialization
[DEBUG  ] (tutorial.hello.appliance): executing: 24531886
[INFO   ] (tutorial.hello): execution
[DEBUG  ] (tutorial.hello.appliance): component established: 24531886
[DEBUG  ] (tutorial.hello.appliance): activated instance: 24531886
[DEBUG  ] (tutorial.hello.appliance): decommissioning phase
[DEBUG  ] (tutorial.hello.appliance): component disposal: 24531886
[DEBUG  ] (tutorial.hello.appliance): disposing of: 24531886
[INFO   ] (tutorial.hello): disposal
[DEBUG  ] (tutorial.hello.appliance): destroyed instance: 24531886
[DEBUG  ] (tutorial.hello.appliance): dissassembly phase
[DEBUG  ] (tutorial.hello.appliance): disposal

The following information presents the above listing step by step.

Launch merlin in execute mode using the "target\classes" directory as an implicit classpath entry and a deployment scenario defined in the file target\classes\BLOCK-INF\block.xml.

$ merlin -execute target\classes -config conf\config.xml

The assembly phase checks the component for any service dependencies and reolves them automatically. In our demonstration component there are not dependencies. Later tutorials will revisit this aspect.

[DEBUG  ] (tutorial.hello.appliance): assembly phase

As the compoent has been declared in the block.xml file, the default deployment policy is to deploy it on startup. In this example the component is a transient component. The logging message details the lifestyle and policy during activation on startup.

[DEBUG  ] (tutorial.hello.appliance): deployment (transient) [true]

Deployment commences with the initialization of a new instance.

[DEBUG  ] (tutorial.hello.appliance): new instance: 24531886

A logger is assigned because the component implements the LogEnabled interface.

[DEBUG  ] (tutorial.hello.appliance): applying logger to: 24531886
[INFO   ] (tutorial.hello): logging

A component is initialized because it implements the Initializable interface.

[DEBUG  ] (tutorial.hello.appliance): applying initialization to: 24531886
[INFO   ] (tutorial.hello): initialization

If the component implemeted the Startable interface it would be started at this point. If it dowes not implement Startable, Merlin will check to see if it implements Executable and if so, the container invokes execute on the component.

[DEBUG  ] (tutorial.hello.appliance): executing: 24531886
[INFO   ] (tutorial.hello): execution
[DEBUG  ] (tutorial.hello.appliance): component established: 24531886
[DEBUG  ] (tutorial.hello.appliance): activated instance: 24531886

When merlin is launched in execute mode (using the -execute command line parameter), Merlin automatically initiates container decomissioning once deployment is complete. If the -execute parameter is absent, Merlin will continue until a ^C interup is encountered.

Decommissioning of a component involves stopping the compoent if it implements the Startable interface, followed by component disposal.

[DEBUG  ] (tutorial.hello.appliance): decommissioning phase
[DEBUG  ] (tutorial.hello.appliance): component disposal: 24531886
[DEBUG  ] (tutorial.hello.appliance): disposing of: 24531886
[INFO   ] (tutorial.hello): disposal
[DEBUG  ] (tutorial.hello.appliance): destroyed instance: 24531886

Internally the appliance instance managing the deployment scenario is taken down during which it is dissassembled and disposed of.

[DEBUG  ] (tutorial.hello.appliance): dissassembly phase
[DEBUG  ] (tutorial.hello.appliance): disposal

The -debug command line switch

For a really deep look inside Merlin, you can select the -debug command line switch. Some of the addition information visible here includes the setup of classloaders

$ merlin -execute target\classes -debug

[DEBUG  ] (kernel.logging): default priority: DEBUG
[DEBUG  ] (kernel.logging): adding category: kernel, null
[DEBUG  ] (kernel.context): logging system established
[DEBUG  ] (kernel.context): using bootstrap repository
[DEBUG  ] (kernel.logging): adding category: kernel, null
[DEBUG  ] (kernel.context): model factory established
[DEBUG  ] (kernel): creating root containment context
[DEBUG  ] (kernel.classloader): base: ${user.dir}
[DEBUG  ] (kernel.classloader): classpath:
[DEBUG  ] (kernel.classloader.types): type install count: 0
[DEBUG  ] (kernel): construction phase
[DEBUG  ] (kernel): install phase
[INFO   ] (kernel): installing: file:/${user.dir}/target/classes/
[DEBUG  ] (kernel): installing: tutorial
[DEBUG  ] (kernel.tutorial.classloader): base: ${user.dir}
[DEBUG  ] (kernel.tutorial): implicit entries: 1
[DEBUG  ] (kernel.tutorial): repository declarations: 1
[DEBUG  ] (kernel.tutorial): repository 0 contains 1 entries.
[DEBUG  ] (kernel.tutorial.classloader): classpath: 
  file:/${user.dir}/target/classes/;
  file:/${merlin.home}/repository/avalon-framework/jars/
    avalon-framework-impl-SNAPSHOT.jar
[DEBUG  ] (kernel.tutorial.classloader.scanner): scanning: 
file:/${user.dir}/target/classes/
[DEBUG  ] (kernel.tutorial.classloader.scanner): type: tutorial.HelloComponent
[DEBUG  ] (kernel.tutorial.classloader.scanner): scanning: 
  file:/${merlin.home}/repository/avalon-framework/
jars/avalon-framework-impl-SNAPSHOT.jar
[DEBUG  ] (kernel.tutorial.classloader.types): type install count: 1
[DEBUG  ] (kernel.tutorial.classloader.types): registered 
  [type:tutorial.HelloComponent/1].
[DEBUG  ] (kernel.tutorial): installing: hello
[DEBUG  ] (kernel): customization phase
[DEBUG  ] (kernel): composition phase
[DEBUG  ] (kernel.logging): adding category: , null
[DEBUG  ] (): creating block: /tutorial
[DEBUG  ] (kernel.logging): adding category: tutorial, null
[DEBUG  ] (tutorial): creating appliance: /tutorial/hello
[DEBUG  ] (kernel.logging): adding category: tutorial.hello, null
[DEBUG  ] (kernel): assembly phase
[DEBUG  ] (): assembly phase
[DEBUG  ] (tutorial): assembly phase
[DEBUG  ] (tutorial.hello.appliance): assembly phase
[DEBUG  ] (kernel): deployment phase
[DEBUG  ] (): deployment: block:/tutorial
[DEBUG  ] (tutorial): deployment: appliance:/tutorial/hello
[DEBUG  ] (tutorial.hello.appliance): deployment (transient) [true]
[DEBUG  ] (tutorial.hello.appliance): new instance: 10040639
[DEBUG  ] (tutorial.hello.appliance): applying logger to: 10040639
[INFO   ] (tutorial.hello): logging
[DEBUG  ] (tutorial.hello.appliance): applying initialization to: 10040639
[INFO   ] (tutorial.hello): initialization
[DEBUG  ] (tutorial.hello.appliance): executing: 10040639
[INFO   ] (tutorial.hello): execution
[DEBUG  ] (tutorial.hello.appliance): component established: 10040639
[DEBUG  ] (tutorial.hello.appliance): activated instance: 10040639
[INFO   ] (kernel): decommissioning phase
[DEBUG  ] (): decommissioning: block:/tutorial
[DEBUG  ] (tutorial): decommissioning: appliance:/tutorial/hello
[DEBUG  ] (tutorial.hello.appliance): decommissioning phase
[DEBUG  ] (tutorial.hello.appliance): component disposal: 10040639
[DEBUG  ] (tutorial.hello.appliance): disposing of: 10040639
[INFO   ] (tutorial.hello): disposal
[DEBUG  ] (tutorial.hello.appliance): destroyed instance: 10040639
[INFO   ] (kernel): dissassembly phase
[DEBUG  ] (): dissassembly phase
[DEBUG  ] (tutorial): dissassembly phase
[DEBUG  ] (tutorial.hello.appliance): dissassembly phase
[INFO   ] (kernel): disposal phase
[DEBUG  ] (): disposal phase
[DEBUG  ] (tutorial): disposal phase
[DEBUG  ] (tutorial.hello.appliance): disposal
[INFO   ] (kernel): bye (1)

Next Steps

We are now ready to move onto the next series of tutorials dealing with component configuration management .