Package org.apache.avalon.framework.service

Examples of org.apache.avalon.framework.service.ServiceException


            (ComponentHandler) m_container.get( m_key, hint );
        if ( null == handler )
        {
            final String message =
                "The hint does not exist in the ComponentSelector";
            throw new ServiceException( m_key + "/" + String.valueOf(hint),
                message );
        }
        return handler;
    }
View Full Code Here


                        m_constructorArguments[i] = component;
                        m_serviceManager.release(component);
                    }
                    catch (Exception e)
                    {
                        throw new ServiceException("ComponentFactory",
                                         "Unknown parameter type for constructor of component: " + current, e);
                    }
                }
            }
View Full Code Here

    public void initialize(ComponentHandler handler)
    throws Exception
    {
        if ( this.initialized )
        {
            throw new ServiceException(this.toString(), "Handable component is already initialized.");
        }
        if ( handler == null )
        {
            throw new ServiceException(this.toString(), "Handler is required.");
        }
        this.handler = handler;
        this.initialized = true;
    }
View Full Code Here

        if ( null == hintMap )
        {
            final String key = getRoleKey( role, hint );
            final String message = "Component does not exist";
            throw new ServiceException( key, message );
        }

        if ( null == hint )
        {
            // no hint -> try selector
            value = hintMap.get( SELECTOR_ENTRY );

            if ( null == value )
            {
                // no selector -> use default
                value = hintMap.get( DEFAULT_ENTRY );
            }

            return value;
        }

        // got a hint -> use it
        value = hintMap.get( hint );

        if ( null == value )
        {
            final String key = getRoleKey( role, hint );
            final String message = "Component does not exist";
            throw new ServiceException( key, message );
        }

        return value;
    }
View Full Code Here

{
    private static final String MESSAGE = "Could not return a reference to the Component";

    public Object lookup( String role ) throws ServiceException
    {
        throw new ServiceException(role, MESSAGE);
    }
View Full Code Here

        }

        if ( !( result instanceof ComponentHandler ) )
        {
            final String message = "Invalid entry in component manager";
            throw new ServiceException( role, message );
        }

        try
        {
            final ComponentHandler handler = (ComponentHandler) result;
            final Object component = handler.get();

            // we only have to keep track of components that don't implement
            // the ReleasableComponent interface
            if ( !(component instanceof ReleasableComponent) )
            {
                m_used.put( new ComponentKey( component ), handler );
            }
            return component;
        }
        catch ( final ServiceException ce )
        {
            throw ce; // rethrow
        }
        catch ( final Exception e )
        {
            final String message =
                "Could not return a reference to the Component";
            throw new ServiceException( role, message, e );
        }
    }
View Full Code Here

            return this.components.get(selectionKey);
        }

        /* Fail miserably */
        String message = "No component associated with " + selectionKey;
        throw new ServiceException((String) selectionKey, message);
    }
View Full Code Here

        }
    }

    public Object select(Object hint) throws ServiceException {
        if (!isSelectable(hint))
            throw new ServiceException((String)hint, "Non-existing component for this hint");
        String stringHint = (String)hint;
        return components.get(stringHint);
    }
View Full Code Here

        /* (non-Javadoc)
         * @see org.apache.avalon.framework.service.ServiceManager#lookup(java.lang.String)
         */
        public Object lookup(String role) throws ServiceException {
            if ( !SourceResolver.ROLE.equals(role) ) {
                throw new ServiceException("SimpleServiceManager", "Unable to lookup component with role: " + role);
            }
            return this.resolver;
        }
View Full Code Here

        {
            ContainerUtil.compose( m_factory, new WrapperComponentManager( serviceManager ) );
        }
        catch( final ComponentException ce )
        {
            throw new ServiceException( ConnectionHandlerFactory.class.getName(), ce.getMessage(), ce );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.service.ServiceException

Copyright © 2018 www.massapicom. 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.