KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > jmx > MX4JComponentAdapter


1 /*****************************************************************************
2  * Copyright (C) NanoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by James Strachan and Mauro Talevi *
9  *****************************************************************************/

10 package org.exoplatform.container.jmx;
11
12 import org.exoplatform.container.ExoContainer;
13 import org.picocontainer.PicoContainer;
14 import org.picocontainer.defaults.AbstractComponentAdapter;
15 /**
16  * @author James Strachan
17  * @author Mauro Talevi
18  * @author Jeppe Cramon
19  * @author Benjamin Mestrallet
20  * @version $Revision: 1.5 $
21  */

22 public class MX4JComponentAdapter extends AbstractComponentAdapter {
23     
24   private Object JavaDoc instance_ ;
25     
26     public MX4JComponentAdapter(Object JavaDoc key, Class JavaDoc implementation) {
27     super(key, implementation) ;
28     }
29     
30     public Object JavaDoc getComponentInstance(PicoContainer container) {
31     if(instance_ != null ) return instance_ ;
32     ExoContainer exocontainer = (ExoContainer) container ;
33     try {
34       synchronized(container) {
35         instance_ = exocontainer.createComponent(getComponentImplementation()) ;
36         exocontainer.manageMBean(this.getComponentKey(), instance_) ;
37       }
38     } catch (Exception JavaDoc ex) {
39       throw new RuntimeException JavaDoc("Cannot instantiate component " + getComponentImplementation(), ex) ;
40     }
41         return instance_ ;
42     }
43   
44    public void verify(PicoContainer container) { }
45 }
Popular Tags