Package org.apache.avalon.framework.service

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


                {
                    proxy.setType( InstrumentManagerClient.INSTRUMENT_TYPE_VALUE );
                }
                else
                {
                    throw new ServiceException( fullInstrumentName, "Encountered an unknown "
                        + "Instrument type for the Instrument with key, "
                        + fullInstrumentName + ": " + instrument.getClass().getName() );
                }

                // Mark the instrument proxy as registered.
                proxy.setRegistered();
               
                // Store a reference to the proxy in the Instrument.
                ( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );

                instrumentableProxy.addInstrumentProxy( proxy );
            }
            else
            {
                // Register the existing proxy with the Instrument.  Make sure that the
                //  type didn't change on us.
                if( instrument instanceof CounterInstrument )
                {
                    switch( proxy.getType() )
                    {
                        case InstrumentManagerClient.INSTRUMENT_TYPE_COUNTER:
                            // Type is the same.
                            // Store a reference to the proxy in the Instrument.
                            ( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
                            break;

                        case InstrumentManagerClient.INSTRUMENT_TYPE_NONE:
                            // Not yet set.  Created in configuration.
                            proxy.setType( InstrumentManagerClient.INSTRUMENT_TYPE_COUNTER );

                            // Store a reference to the proxy in the Instrument.
                            ( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
                            break;

                        default:
                            throw new ServiceException( instrumentName,
                                "Instruments of more than one type are assigned to name: "
                                + instrumentName );
                    }
                }
                else if( instrument instanceof ValueInstrument )
                {
                    switch( proxy.getType() )
                    {
                        case InstrumentManagerClient.INSTRUMENT_TYPE_VALUE:
                            // Type is the same.
                            // Store a reference to the proxy in the Instrument.
                            ( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
                            break;

                        case InstrumentManagerClient.INSTRUMENT_TYPE_NONE:
                            // Not yet set.  Created in configuration.
                            proxy.setType( InstrumentManagerClient.INSTRUMENT_TYPE_VALUE );

                            // Store a reference to the proxy in the Instrument.
                            ( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
                            break;

                        default:
                            throw new ServiceException( instrumentName,
                                "Instruments of more than one type are assigned to name: "
                                + instrumentName );
                    }
                }
                else
                {
                    throw new ServiceException( instrumentName, "Encountered an unknown Instrument "
                        + "type for the Instrument with name, " + instrumentName + ": "
                        + instrument.getClass().getName() );
                }
               
                // Mark the instrument proxy as registered.
                proxy.setRegistered();
            }
        }

        // Loop over the child Instrumentables published by this Instrumentable
        Instrumentable[] children = instrumentable.getChildInstrumentables();
        for ( int i = 0; i < children.length; i++ )
        {
            Instrumentable child = children[i];
           
            // Make sure that the child instrumentable name is set.
            String childName = child.getInstrumentableName();
            if( childName == null )
            {
                String msg = "The getInstrumentableName() method of a child Instrumentable of " +
                    instrumentableName + " returned null.  Child class: " +
                    child.getClass().getName();
                getLogger().debug( msg );
                throw new ServiceException( instrumentable.getClass().getName(), msg );
            }
           
            String fullChildName = instrumentableName + "." + childName;
           
            getLogger().debug( "Registering Child Instrumentable: " + fullChildName );
View Full Code Here


     */
    public List<FileItem> parseUpload(HttpServletRequest request) throws ServiceException
    {
        if (uploadService == null)
        {
            throw new ServiceException(ParserService.ROLE, "UploadService is not available.");
        }
        else
        {
            return uploadService.parseRequest(request);
        }
View Full Code Here

     */
    public FileItemIterator getItemIterator(HttpServletRequest request) throws ServiceException
    {
        if (uploadService == null)
        {
            throw new ServiceException(ParserService.ROLE, "UploadService is not available.");
        }
        else
        {
            return uploadService.getItemIterator(request);
        }
View Full Code Here

             * Automatic parsing of uploaded file items was requested but no
             * UploadService is available
             */
            if (getAutomaticUpload())
            {
                throw new ServiceException(ParserService.ROLE,
                        AUTOMATIC_KEY + " = true requires " +
                        UploadService.ROLE + " to be available");
            }
        }

        if (manager.hasService(PoolService.ROLE))
        {
            poolService = (PoolService)manager.lookup(PoolService.ROLE);
        }
        else
        {
            throw new ServiceException(ParserService.ROLE,
                    "Service requires " +
                    PoolService.ROLE + " to be available");
        }
    }
View Full Code Here

        {
            repConf = (Configuration)policy;
        }
        catch( final ClassCastException cce )
        {
            throw new ServiceException( policy.toString(), "Hint is of the wrong type. " +
                                                           "Must be a Configuration", cce );
        }

        URL destination = null;
        try
        {
            destination = new URL( repConf.getAttribute( "destinationURL" ) );
        }
        catch( final ConfigurationException ce )
        {
            throw new ServiceException( policy.toString(), "Malformed configuration has no " +
                                                           "destinationURL attribute", ce );
        }
        catch( final MalformedURLException mue )
        {
            throw new ServiceException( policy.toString(), "destination is malformed. " +
                                                           "Must be a valid URL", mue );
        }

        try
        {
            final String type = repConf.getAttribute( "type" );
            final String repID = destination + type;
            Repository reply = (Repository)m_repositories.get( repID );
            final String model = (String)repConf.getAttribute( "model" );

            if( null != reply )
            {
                if( m_models.get( repID ).equals( model ) )
                {
                    return reply;
                }
                else
                {
                    final String message = "There is already another repository with the " +
                        "same destination and type but with different model";
                    throw new ServiceException( policy.toString(), message );
                }
            }
            else
            {
                final String protocol = destination.getProtocol();
                final String repClass = (String)m_classes.get( protocol + type + model );

                getLogger().debug( "Need instance of " + repClass + " to handle: " +
                                   protocol + type + model );

                try
                {
                    reply = (Repository)Class.forName( repClass ).newInstance();

                    setupLogger( reply, "repository" );

                    ContainerUtil.contextualize( reply, m_context );
                    ContainerUtil.service( reply, m_serviceManager );
                    ContainerUtil.configure( reply, repConf );
                    ContainerUtil.initialize( reply );

                    m_repositories.put( repID, reply );
                    m_models.put( repID, model );
                    getLogger().info( "New instance of " + repClass + " created for " +
                                      destination );
                    return reply;
                }
                catch( final Exception e )
                {
                    final String message = "Cannot find or init repository: " + e.getMessage();
                    getLogger().warn( message, e );

                    throw new ServiceException( policy.toString(), message, e );
                }
            }
        }
        catch( final ConfigurationException ce )
        {
            throw new ServiceException( policy.toString(), "Malformed configuration", ce );
        }
    }
View Full Code Here

             * Automatic parsing of uploaded file items was requested but no
             * UploadService is available
             */
            if (getAutomaticUpload())
            {
                throw new ServiceException(ParserService.ROLE,
                        AUTOMATIC_KEY + " = true requires " +
                        UploadService.ROLE + " to be available");
            }
        }

        if (manager.hasService(PoolService.ROLE))
        {
            poolService = (PoolService)manager.lookup(PoolService.ROLE);
        }
        else
        {
            throw new ServiceException(ParserService.ROLE,
                    "Service requires " +
                    PoolService.ROLE + " to be available");
        }
    }
View Full Code Here

     */
    public List parseUpload(HttpServletRequest request) throws ServiceException
    {
        if (uploadService == null)
        {
            throw new ServiceException(ParserService.ROLE, "UploadService is not available.");
        }
        else
        {
            return uploadService.parseRequest(request);
        }
View Full Code Here

    {
        final Object component = m_dataSources.get( hint );

        if( null == component )
        {
            throw new ServiceException( hint.toString(), "Unable to provide DataSourceComponent for " + hint );
        }

        return component;
    }
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

    {
        final Object component = m_dataSources.get( hint );

        if( null == component )
        {
            throw new ServiceException( hint.toString(), "Unable to provide DataSourceComponent for " + hint );
        }

        return component;
    }
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.