Package org.mule.umo.manager

Examples of org.mule.umo.manager.ObjectNotFoundException


  public Object getComponent(Object key)
    throws ObjectNotFoundException
  {
    if (key == null)
      throw new ObjectNotFoundException("Component key is null");

    if (log.isLoggable(Level.FINE)) {
      log.fine(L.l("ResinContainerContext.getComponent({0} with type {1})",
                   key, key.getClass().getName()));
    }

    if (key instanceof ContainerKeyPair) {
      ContainerKeyPair pair = (ContainerKeyPair) key;

      // XXX pair.getContainerName() appears to be null most of the time
      // ignore it?

      key = pair.getKey();
    }

    if (key instanceof Class) {
      Class clazz = (Class) key;
      ComponentFactory component = null;

      if (log.isLoggable(Level.FINE))
        log.fine("Creating new instance from " + clazz);

      synchronized (_componentMap) {
        component = _componentMap.get(clazz);

        if (component == null) {
          component = _webBeans.resolveByType(clazz);

          if (component == null)
            component = _webBeans.createTransient(clazz);

          _componentMap.put(clazz, component);
        }
      }

      return component.get();
    }
    else if (key instanceof String) {
      ComponentFactory component = _webBeans.findByName((String) key);

      if (component == null) {
        throw new ObjectNotFoundException(L.l("Cannot find component with name '{0}'", key));
      }

      return component.get();
    }
    else {
      throw new ObjectNotFoundException(L.l("Component keys of type {0} are not understood", key.getClass().getName()));
    }
  }
View Full Code Here


    /**
     * Mostly copied from org.mule.extras.spring.SpringContainerContext
     */
    public Object getComponent(Object key) throws ObjectNotFoundException {
        if (key == null) {
            throw new ObjectNotFoundException("Component not found for null key");
        }

        if (key instanceof Class) {
            // We will assume that there should only be one object of
            // this class in the container for now
            // String[] names = getBeanFactory().getBeanDefinitionNames((Class)
            // key);
            // if (names == null || names.length == 0 || names.length > 1)
            // {
            throw new ObjectNotFoundException(
                    "The container is unable to build single instance of "
                            + ((Class) key).getName() + " number of instances found was: 0");
            // }
            // else
            // {
            // key = names[0];
            // }
        }
        try {
            return beanFactory.getBean(key.toString());
        } catch (BeansException e) {
            throw new ObjectNotFoundException("Component not found for key: " + key.toString(), e);
        }
    }
View Full Code Here

  public Object getComponent(Object key)
    throws ObjectNotFoundException
  {
    if (key == null)
      throw new ObjectNotFoundException("Component key is null");

    if (log.isLoggable(Level.FINE)) {
      log.fine(L.l("ResinContainerContext.getComponent({0} with type {1})",
                   key, key.getClass().getName()));
    }

    if (key instanceof ContainerKeyPair) {
      ContainerKeyPair pair = (ContainerKeyPair) key;

      // XXX pair.getContainerName() appears to be null most of the time
      // ignore it?

      key = pair.getKey();
    }

    if (key instanceof Class) {
      Class clazz = (Class) key;
      ComponentFactory component = null;

      if (log.isLoggable(Level.FINE))
        log.fine("Creating new instance from " + clazz);

      synchronized (_componentMap) {
        component = _componentMap.get(clazz);

        if (component == null) {
          component = _webBeans.resolveByType(clazz);

          if (component == null)
            component = _webBeans.createTransient(clazz);

          _componentMap.put(clazz, component);
        }
      }

      return component.get();
    }
    else if (key instanceof String) {
      ComponentFactory component = _webBeans.findByName((String) key);

      if (component == null) {
        throw new ObjectNotFoundException(L.l("Cannot find component with name '{0}'", key));
      }

      return component.get();
    }
    else {
      throw new ObjectNotFoundException(L.l("Component keys of type {0} are not understood", key.getClass().getName()));
    }
  }
View Full Code Here

TOP

Related Classes of org.mule.umo.manager.ObjectNotFoundException

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.