Package org.apache.avalon.fortress.impl.handler

Examples of org.apache.avalon.fortress.impl.handler.ComponentHandler


      throw new ServiceException(role, message);
    }

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

      m_used.put(new ComponentKeelKey(component), handler);

      return component;
    }
View Full Code Here


  public void release(final Object component)
  {
    try
    {
      final ComponentHandler handler = (ComponentHandler) m_used.remove(new ComponentKeelKey(component));

      if (null == handler)
      {
        if (null == m_parent)
        {
          /*
           * This is a purplexing problem. SOmetimes the m_used hash
           * returns null for the component--usually a ThreadSafe
           * component. When there is no handler and no parent, that
           * is an error condition--but if the component is usually
           * ThreadSafe, the impact is essentially nill.
           */

          // Pete: This occurs when objects are released more often
          // than
          // when they are aquired
          // Pete: It also happens when a release of a
          // ComponentSelector occurs
        }
        else
        {
          m_parent.release(component);
        }
      }
      else
      {
        handler.put(component);
      }
    }
    catch (Exception x)
    {
      System.out.println("ERROR [KeelServiceManager]: " + x);
View Full Code Here

        super( name );
    }

    public void testComponentHandlerEntry()
    {
        ComponentHandler handler = new TestComponentHandler();
        ComponentHandlerMetaData meta = new ComponentHandlerMetaData(
            "component1", Component1.class.getName(),
            new DefaultConfiguration( "test" ), true );
        ComponentHandlerEntry entry = new ComponentHandlerEntry( handler, meta );
View Full Code Here

        assertSame( meta, entry.getMetaData() );
    }

    public void testNullPointerException()
    {
        ComponentHandler handler = new TestComponentHandler();
        ComponentHandlerMetaData meta = new ComponentHandlerMetaData(
            "component1", Component1.class.getName(),
            new DefaultConfiguration( "test" ), true );

        try
View Full Code Here

    public boolean handleCommandFailure( final Command command, final Throwable throwable )
    {
        if ( command instanceof PrepareHandlerCommand )
        {
            PrepareHandlerCommand phc = (PrepareHandlerCommand)command;
            ComponentHandler handler = phc.getHandler();

            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "Could not prepare ComponentHandler for: "
                    + handler.getComponentClass().getName(), throwable );
            }
        }
        else
        {
            if ( getLogger().isErrorEnabled() )
View Full Code Here

            throws Exception
    {
        final Configuration configuration = metaData.getConfiguration();

        // get info from params
        final ComponentHandler handler;

        try
        {
            final ObjectFactory factory =
                    createObjectFactory( classname, configuration );

            // create the appropriate handler instance
            final ComponentHandler targetHandler =
                    (ComponentHandler) handlerClass.newInstance();

            // do the handler lifecycle
            ContainerUtil.enableLogging( targetHandler, getLogger() );
            ContainerUtil.contextualize( targetHandler, m_context );
View Full Code Here

            {
                throw new IllegalArgumentException( "Using a reserved id name" + metaData.getName() );
            }

            // create a handler for the combo of Role+MetaData
            final ComponentHandler handler =
                    getComponentHandler( className,
                                         getComponentHandlerClass( className, shortName),
                                         metaData );

            // put the role into our role mapper. If the role doesn't exist
View Full Code Here

        if ( component instanceof ReleasableComponent )
        {
            ((ReleasableComponent)component).releaseOnComponentHandler();
            return;
        }
        final ComponentHandler handler =
            (ComponentHandler) m_used.remove( new ComponentKey( component ) );
        if ( null != handler )
        {
            handler.put( component );
        }
    }
View Full Code Here

        {
            final String message = "hint cannot be null";
            throw new IllegalArgumentException( message );
        }

        final ComponentHandler handler =
            (ComponentHandler) m_container.get( m_key, hint );
        if ( null == handler )
        {
            final String message =
                "The hint does not exist in the ComponentSelector";
View Full Code Here

            throw new IllegalArgumentException( "Using a reserved id name" + metaData.getName() );
        }

        Iterator it = metaEntry.getRoles();
        // create a handler for the combo of Role+MetaData
        final ComponentHandler handler =
                getComponentHandler( metaEntry, metaData );

        while ( it.hasNext() )
        {
            final String role = (String) it.next();
View Full Code Here

TOP

Related Classes of org.apache.avalon.fortress.impl.handler.ComponentHandler

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.