Package org.codehaus.loom.components.assembler.data

Source Code of org.codehaus.loom.components.assembler.data.Component4

/*
* Copyright (C) The Loom Group. All rights reserved.
*
* This software is published under the terms of the Loom
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.codehaus.loom.components.assembler.data;

import java.util.Iterator;
import java.util.Map;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;

/**
* A test component.
*
* @author Peter Donald
* @version $Revision: 1.2 $ $Date: 2004/05/01 12:48:35 $
* @dna.component
*/
public class Component4
    implements Serviceable
{
    /**
     * @dna.dependency type="Service1{}"
     */
    public void service( final ServiceManager manager )
        throws ServiceException
    {
        final Map services =
            (Map)manager.lookup( Service1.class.getName() + "{}" );
        System.out.println( "Passed the following services: " +
                            services.keySet() );
        if( 3 != services.size() )
        {
            final String message =
                "Expected to get 3 services but got " + services.size();
            throw new ServiceException( Service1.class.getName() + "{}",
                                        message );
        }

        final Iterator iterator = services.keySet().iterator();
        while( iterator.hasNext() )
        {
            final String key = (String)iterator.next();
            final Service1 service1 = (Service1)services.get( key );
            if( null == service1 )
            {
                final String message = "Expected non null service entry for " +
                    key;
                throw new ServiceException( Service1[].class.getName(),
                                            message );
            }
        }
    }
}
TOP

Related Classes of org.codehaus.loom.components.assembler.data.Component4

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.