Exemplo n.º 1
0
  private Class<?> loadBeanClass() {
    if (beanClass == null) {
      String className = beanInfo.getClassName();
      Class<?> clazz = loadClass(className);
      ApplicationAssociate associate = ApplicationAssociate.getCurrentInstance();

      if (!associate.isDevModeEnabled()) {
        beanClass = clazz;
      }

      // validate the bean class is public and has a public
      // no-arg ctor
      int classModifiers = clazz.getModifiers();
      if (!Modifier.isPublic(classModifiers)) {
        String message =
            MessageUtils.getExceptionMessageString(
                MessageUtils.MANAGED_BEAN_CLASS_IS_NOT_PUBLIC_ERROR_ID,
                className,
                beanInfo.getName());
        queueMessage(message);
      }
      if (Modifier.isInterface(classModifiers) || Modifier.isAbstract(classModifiers)) {
        String message =
            MessageUtils.getExceptionMessageString(
                MessageUtils.MANAGED_BEAN_CLASS_IS_ABSTRACT_ERROR_ID,
                className,
                beanInfo.getName());
        queueMessage(message);
      }

      try {
        Constructor ctor = clazz.getConstructor(RIConstants.EMPTY_CLASS_ARGS);
        if (!Modifier.isPublic(ctor.getModifiers())) {
          String message =
              MessageUtils.getExceptionMessageString(
                  MessageUtils.MANAGED_BEAN_CLASS_NO_PUBLIC_NOARG_CTOR_ERROR_ID,
                  className,
                  beanInfo.getName());
          queueMessage(message);
        }
      } catch (NoSuchMethodException nsme) {
        String message =
            MessageUtils.getExceptionMessageString(
                MessageUtils.MANAGED_BEAN_CLASS_NO_PUBLIC_NOARG_CTOR_ERROR_ID,
                className,
                beanInfo.getName());
        queueMessage(message);
      }

      if (!hasMessages()) {
        // class is ok, scan for annotations
        this.isInjectible = scanForAnnotations(clazz);
      }
      return clazz;
    }
    return beanClass;
  }
Exemplo n.º 2
0
 /**
  * This constructor uses the current <code>Application</code> instance to obtain the navigation
  * mappings used to make navigational decisions.
  */
 public NavigationHandlerImpl() {
   super();
   if (logger.isLoggable(Level.FINE)) {
     logger.log(Level.FINE, "Created NavigationHandler instance ");
   }
   // if the user is using the decorator pattern, this would cause
   // our ApplicationAssociate to be created, if it isn't already
   // created.
   ApplicationFactory aFactory =
       (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
   aFactory.getApplication();
   ApplicationAssociate associate =
       ApplicationAssociate.getInstance(FacesContext.getCurrentInstance().getExternalContext());
   if (associate != null) {
     caseListMap = associate.getNavigationCaseListMappings();
     wildCardSet = associate.getNavigationWildCardList();
     navigationConfigured = (wildCardSet != null && caseListMap != null);
     development = associate.isDevModeEnabled();
   }
 }