Package org.apache.felix.scr.impl.config

Examples of org.apache.felix.scr.impl.config.ComponentHolder


     */
    final ComponentRegistryKey checkComponentName( final Bundle bundle, final String name )
    {
        // register the name if no registration for that name exists already
        final ComponentRegistryKey key = new ComponentRegistryKey( bundle, name );
        ComponentHolder existingRegistration = null;
        boolean present;
        synchronized ( m_componentHoldersByName )
        {
            present = m_componentHoldersByName.containsKey( key );
            if ( !present )
            {
                m_componentHoldersByName.put( key, null );
            }
            else
            {
                existingRegistration = m_componentHoldersByName.get( key );
            }
        }

        // there was a registration already, throw an exception and use the
        // existing registration to provide more information if possible
        if ( present )
        {
            String message = "The component name '" + name + "' has already been registered";

            if ( existingRegistration != null )
            {
                Bundle cBundle = existingRegistration.getActivator().getBundleContext().getBundle();
                ComponentMetadata cMeta = existingRegistration.getComponentMetadata();

                StringBuffer buf = new StringBuffer( message );
                buf.append( " by Bundle " ).append( cBundle.getBundleId() );
                if ( cBundle.getSymbolicName() != null )
                {
View Full Code Here


     * <p>
     * After calling this method, the name can be reused by other components.
     */
    final void unregisterComponentHolder( final ComponentRegistryKey key )
    {
        ComponentHolder component;
        synchronized ( m_componentHoldersByName )
        {
            component = m_componentHoldersByName.remove( key );
        }

        if (component != null) {
            Activator.log(LogService.LOG_DEBUG, null,
                    "Unregistering component with pid {0} for bundle {1}",
                    new Object[] {component.getComponentMetadata().getConfigurationPid(), key.getBundleId()}, null);
            synchronized (m_componentHoldersByPid)
            {
                String configurationPid = component.getComponentMetadata().getConfigurationPid();
                Set<ComponentHolder> componentsForPid = m_componentHoldersByPid.get(configurationPid);
                if (componentsForPid != null)
                {
                    componentsForPid.remove(component);
                    if (componentsForPid.size() == 0)
View Full Code Here

     * Factory method to issue {@link ComponentHolder} instances to manage
     * components described by the given component <code>metadata</code>.
     */
    public ComponentHolder createComponentHolder( BundleComponentActivator activator, ComponentMetadata metadata )
    {
        ComponentHolder holder;

        if (metadata.isFactory())
        {
            // 112.2.4 SCR must register a Component Factory
            // service on behalf of the component
View Full Code Here

                    // validate the component metadata
                    metadata.validate( this );

                    // Request creation of the component manager
                    ComponentHolder holder = m_componentRegistry.createComponentHolder( this, metadata );

                    // register the component after validation
                    m_componentRegistry.registerComponentHolder( key, holder );
                    m_managers.add( holder );
View Full Code Here

            log( LogService.LOG_DEBUG, "BundleComponentActivator : Bundle [{0}] will destroy {1} instances", new Object[]
                    { m_bundle.getBundleId(), m_managers.size() }, null, null, null );

            while ( m_managers.size() != 0 )
            {
                ComponentHolder holder = m_managers.get( 0 );
                try
                {
                    m_managers.remove( holder );
                    holder.disposeComponents( reason );
                }
                catch ( Exception e )
                {
                    log( LogService.LOG_ERROR, "BundleComponentActivator : Exception invalidating", holder
                            .getComponentMetadata(), null, e );
                }
                finally
                {
                    m_componentRegistry.unregisterComponentHolder( m_bundle, holder.getComponentMetadata()
                            .getName() );
                }

            }
View Full Code Here

        if ( name == null )
        {
            return m_managers.toArray( new ComponentHolder[m_managers.size()] );
        }

        ComponentHolder componentHolder = m_componentRegistry.getComponentHolder( m_bundle, name );
        if (componentHolder != null)
        {
            return new ComponentHolder[] { componentHolder };
        }
View Full Code Here

TOP

Related Classes of org.apache.felix.scr.impl.config.ComponentHolder

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.