Package com.softwarementors.extjs.djn.api

Examples of com.softwarementors.extjs.djn.api.RegisteredAction


  protected RegisteredStandardMethod getStandardMethod(String actionName, String methodName) {
    assert !StringUtils.isEmpty(actionName);
    assert !StringUtils.isEmpty(methodName);

    RegisteredAction action = getRegistry().getAction(actionName);
    if( action == null ) {
      throw RequestException.forActionNotFound( actionName );
    }

    RegisteredStandardMethod method = action.getStandardMethod(methodName);
    if( method == null ) {
      throw RequestException.forActionMethodNotFound( action.getName(), methodName );
    }
    return method;
  }
View Full Code Here


    // Create a new api programmatically
    String apiFile = config.getServletContext().getRealPath("test/ProgrammaticApi.js");
    RegisteredApi api = registry.addApi( "programmaticApi", "test/ProgrammaticApi.js", apiFile, "Djn.programmaticNamespace", "Djn.programmaticNamespace" );
   
    // Register a new action with a method
    RegisteredAction action = api.addAction( CustomRegistryConfiguratorHandlingTest.class, "MyCustomRegistryConfiguratorHandlingTest");
    Method m = getMethod( CustomRegistryConfiguratorHandlingTest.class, "test_programmaticMethod", String.class);
    action.addStandardMethod( "myProgrammaticMethod", m, false);
   
    // Register a poll method
    Method pm = getMethod( CustomRegistryConfiguratorHandlingTest.class, "test_programmaticPollMethod", Map.class);
    action.addPollMethod( "myProgrammaticPollMethod", pm);
  }
View Full Code Here

    }

    List<RegisteredAction> actions = new ArrayList<RegisteredAction>();
    for( String actionName : actionNames ) {
      if( this.registry.hasAction( actionName ) ) {
        RegisteredAction existingAction = this.registry.getAction( actionName );
        ApiConfigurationException ex = ApiConfigurationException.forActionAlreadyRegistered(actionName, actionClass, existingAction.getActionClass());
        logger.fatal( ex.getMessage(), ex );
        throw ex;
      }
      RegisteredAction action = api.addAction( actionClass, actionName );
      actions.add( action );
    }
   
    return actions;
  }
View Full Code Here

  private void scanAndRegisterActionClass(List<RegisteredAction> actions) {
    assert actions != null;
    assert !actions.isEmpty();
   
    RegisteredAction actionTemplate = actions.get(0);
   
    // *All* methods are candidates, including those in base classes,
    // even if the base class does not have a DirectAction annotation!
    List<Method> allMethods = new ArrayList<Method>();
    Class<?> cls = actionTemplate.getActionClass();
    while( cls != null ) {
      Method[] methods = cls.getDeclaredMethods(); // Get private, protected and other methods!
      Collections.addAll( allMethods, methods );
      cls = cls.getSuperclass();
    }
   
    for( Method method : allMethods ) {
      // Check if the kind of direct method -if any
      DirectMethod methodAnnotation = method.getAnnotation(DirectMethod.class);
      boolean isStandardMethod = methodAnnotation != null;
      if( !isStandardMethod ) {
        isStandardMethod = method.getName().startsWith(STANDARD_METHOD_NAME_PREFIX);
      }
     
      DirectFormPostMethod postMethodAnnotation = method.getAnnotation(DirectFormPostMethod.class);
      boolean isFormPostMethod = postMethodAnnotation != null;
      if( !isFormPostMethod ) {
        isFormPostMethod = method.getName().startsWith(FORM_POST_METHOD_NAME_PREFIX)
      }
     
      DirectPollMethod pollMethodAnnotation = method.getAnnotation(DirectPollMethod.class);
      boolean isPollMethod = pollMethodAnnotation != null;
      if( !isPollMethod ) {
        isPollMethod = method.getName().startsWith( POLL_METHOD_NAME_PREFIX );
      }
     
      // Check that a method is just of only one kind of method
      if( isStandardMethod && isFormPostMethod ) {
        ApiConfigurationException ex = ApiConfigurationException.forMethodCantBeStandardAndFormPostMethodAtTheSameTime(actionTemplate, method);
        logger.fatal( ex.getMessage(), ex );
        throw ex;
      }
      if( (methodAnnotation != null || postMethodAnnotation != null) && isPollMethod) {
        ApiConfigurationException ex = ApiConfigurationException.forPollMethodCantBeStandardOrFormPostMethodAtTheSameTime(actionTemplate, method);
        logger.fatal( ex.getMessage(), ex );
        throw ex;
      }

      // Process standard and form post methods together, as they are very similar
      if( isStandardMethod || isFormPostMethod) {
       
        String methodName = "";
        if( isStandardMethod ) {
          methodName = getStandardMethodName(method, methodAnnotation);
        }
        else {
          methodName = getFormPostMethodName( method, postMethodAnnotation);
        }       
        if( actionTemplate.hasStandardMethod(methodName)  ) {
          ApiConfigurationException ex = ApiConfigurationException.forMethodAlreadyRegisteredInAction(methodName, actionTemplate.getName());
          logger.fatal( ex.getMessage(), ex );
          throw ex;
        }
       
        if( isFormPostMethod && !RegisteredStandardMethod.isValidFormHandlingMethod(method)) {
          ApiConfigurationException ex = ApiConfigurationException.forMethodHasWrongParametersForAFormHandler( actionTemplate.getName(), methodName );
          logger.fatal( ex.getMessage(), ex );
          throw ex;
        }

        for( RegisteredAction actionToRegister : actions ) {
View Full Code Here

TOP

Related Classes of com.softwarementors.extjs.djn.api.RegisteredAction

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.