View Javadoc
1 package org.jadetower.dao.impl; 2 3 /* 4 Copyright (c) 2003, J Aaron Farr 5 All rights reserved. 6 7 This software is published under the terms of the JadeTower Software License, 8 a BSD derived license, a copy of which has been included with this 9 distribution in the LICENSE file. <http://www.jadetower.org> 10 */ 11 12 13 import org.apache.avalon.framework.service.ServiceManager; 14 import org.apache.avalon.framework.service.ServiceException; 15 import org.picocontainer.PicoContainer; 16 import org.apache.avalon.framework.service.Serviceable; 17 18 /*** 19 * Avalon ServiceManager and PicoContainer Wrapper 20 */ 21 public class DaoServiceManager 22 implements ServiceManager, Serviceable 23 { 24 25 protected ServiceManager m_parent = null; 26 protected PicoContainer m_container = null; 27 28 public DaoServiceManager(ServiceManager parent, PicoContainer container) { 29 m_parent = parent; 30 m_container = container; 31 } 32 33 public Object lookup(String name) throws org.apache.avalon.framework.service.ServiceException { 34 Object service = null; 35 if(m_parent != null && m_parent.hasService(name)){ 36 service = m_parent.lookup(name); 37 } 38 if(m_container != null && m_container.hasComponent(name)){ 39 service = m_container.getComponentInstance(name); 40 } 41 return service; 42 } 43 44 public boolean hasService(String name) { 45 boolean contains = false; 46 if(m_parent != null) 47 contains = m_parent.hasService(name); 48 if(m_container != null && contains == false) 49 contains = m_container.hasComponent(name); 50 return contains; 51 } 52 public void release(Object service) { 53 if(m_parent != null) 54 m_parent.release(service); 55 } 56 57 public void service(ServiceManager serviceManager) { 58 if(m_parent == null) 59 m_parent = serviceManager; 60 } 61 }

This page was automatically generated by Maven