Examples of ApiMethod


Examples of com.caucho.config.gen.ApiMethod

                                           Class []param,
                                           ApiMethod sourceMethod,
                                           ApiClass sourceClass)
    throws ConfigException
  {
    ApiMethod method = null;
    ApiClass beanClass = getEJBClassWrapper();

    method = getMethod(beanClass, methodName, param);

    if (method == null && sourceMethod != null) {
      throw error(L.l("{0}: '{1}' expected to match {2}.{3}",
                      beanClass.getName(),
                      getFullMethodName(methodName, param),
                      sourceMethod.getDeclaringClass().getSimpleName(),
                      getFullMethodName(sourceMethod)));
    }
    else if (method == null) {
      throw error(L.l("{0}: '{1}' expected",
                      beanClass.getName(),
                      getFullMethodName(methodName, param)));
    }
    /*
      else if (Modifier.isAbstract(method.getModifiers()) &&
      getBeanManagedPersistence()) {
      throw error(L.l("{0}: '{1}' must not be abstract",
      beanClass.getName(),
      getFullMethodName(methodName, param)));
      }
    */
    else if (! method.isPublic()) {
      throw error(L.l("{0}: '{1}' must be public",
                      beanClass.getName(),
                      getFullMethodName(methodName, param)));
    }

    if (method.isStatic()) {
      throw error(L.l("{0}: '{1}' must not be static",
                      beanClass.getName(),
                      getFullMethodName(methodName, param)));
    }

    if (method.isFinal()) {
      throw error(L.l("{0}: '{1}' must not be final.",
                      beanClass.getName(),
                      getFullMethodName(methodName, param),
                      beanClass.getName()));
    }
View Full Code Here

Examples of com.caucho.config.gen.ApiMethod

           ApiMethod sourceMethod,
           ApiClass sourceClass,
           boolean isOptional)
    throws ConfigException
  {
    ApiMethod method = validateMethod(methodName, param,
              sourceMethod, sourceClass,
              isOptional);

    if (method == null && isOptional)
      return null;

    if (method.isFinal())
      throw error(L.l("{0}: '{1}' must not be final",
                      _ejbClass.getName(),
                      getFullMethodName(method)));


    if (method.isStatic())
      throw error(L.l("{0}: '{1}' must not be static",
                      _ejbClass.getName(),
                      getFullMethodName(method)));

    return method;
View Full Code Here

Examples of com.caucho.config.gen.ApiMethod

  protected ApiMethod validateMethod(String methodName, Class []param,
         ApiMethod sourceMethod, ApiClass sourceClass,
         boolean isOptional)
    throws ConfigException
  {
    ApiMethod method = null;

    method = getMethod(_ejbClass, methodName, param);

    if (method == null && isOptional)
      return null;

    if (method == null && sourceMethod != null) {
      throw error(L.l("{0}: missing '{1}' needed to match {2}.{3}",
                      _ejbClass.getName(),
                      getFullMethodName(methodName, param),
                      sourceClass.getSimpleName(),
                      getFullMethodName(sourceMethod)));
    }
    else if (method == null) {
      throw error(L.l("{0}: expected '{1}'",
                      _ejbClass.getName(),
                      getFullMethodName(methodName, param)));
    }

    ApiClass declaringClass = method.getDeclaringClass();

    if (method.isAbstract()) {
      if (method.getDeclaringClass().getName().equals("javax.ejb.EntityBean"))
        throw error(L.l("{0}: '{1}' must not be abstract.  Entity beans must implement the methods in EntityBean.",
                        _ejbClass.getName(),
                        getFullMethodName(methodName, param)));
      else if (method.getDeclaringClass().getName().equals("javax.ejb.SessionBean"))
        throw error(L.l("{0}: '{1}' must not be abstract.  Session beans must implement the methods in SessionBean.",
                        _ejbClass.getName(),
                        getFullMethodName(methodName, param)));
      else if (sourceMethod != null)
        throw error(L.l("{0}: '{1}' must not be abstract.  All methods from '{2}' must be implemented in the bean.",
                        _ejbClass.getName(),
                        getFullMethodName(methodName, param),
                        sourceClass.getName()));
      else
        throw error(L.l("{0}: '{1}' must not be abstract.  Business methods must be implemented.",
                        _ejbClass.getName(),
                        getFullMethodName(methodName, param)));
    } else if (! method.isPublic()) {
      throw error(L.l("{0}: '{1}' must be public.  Business method implementations must be public.",
                      _ejbClass.getName(),
                      getFullMethodName(methodName, param)));
    }
    if (method.isStatic()) {
      throw error(L.l("{0}: '{1}' must not be static.  Business method implementations must not be static.",
                      _ejbClass.getName(),
                      getFullMethodName(method)));
    }
View Full Code Here

Examples of com.caucho.config.gen.ApiMethod

            String name,
            Class []param)
  {
   
    for (int i = 0; i < apiList.size(); i++) {
      ApiMethod method = getMethod(apiList.get(i), name, param);

      if (method != null)
        return method;
    }
View Full Code Here

Examples of com.caucho.config.gen.ApiMethod

   */
  public static ApiMethod findMethod(ArrayList<ApiMethod> methods, ApiMethod method)
  {
    loop:
    for (int i = 0; i < methods.size(); i++) {
      ApiMethod oldMethod = methods.get(i);

      if (oldMethod.equals(method))
  return oldMethod;
    }

    return null;
  }
View Full Code Here

Examples of com.caucho.config.gen.ApiMethod

   * Tests is a method is declared in a class.
   */
  public boolean classHasMethod(ApiMethod method, ApiClass cl)
  {
    try {
      ApiMethod match = cl.getMethod(method.getName(),
             method.getParameterTypes());
      return match != null;
    } catch (Exception e) {
      return false;
    }
View Full Code Here

Examples of com.google.api.explorer.client.base.ApiMethod

   * When a ServiceLoadedEvent fires, the Display becomes visible and displays
   * the user as un-authenticated by default.
   */

  public void testServiceLoadedWithoutAuth() {
    ApiMethod method1 = EasyMock.createControl().createMock(ApiMethod.class);
    ApiMethod method2 = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(service.allMethods()).andReturn(
        ImmutableMap.of("method.one", method1, "method.two", method2));
    EasyMock.expect(service.getName()).andReturn("service");
    display.setScopes(Collections.<String, ApiService.AuthScope>emptyMap());
    display.setState(State.PUBLIC, EMPTY_SCOPES, EMPTY_SCOPES);
View Full Code Here

Examples of com.google.api.explorer.client.base.ApiMethod

    EasyMock.verify(display);
  }

  /** Check the flow which sets up the display for auth. */
  public void testAuthGranted() {
    ApiMethod method1 = EasyMock.createControl().createMock(ApiMethod.class);
    ApiMethod method2 = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(method1.getScopes()).andReturn(ImmutableList.of("scopeName")).anyTimes();
    ImmutableSet<String> authScopes = ImmutableSet.of("scopeName");
    Map<String, AuthInformation> auth = generateAuthInformation(authScopes);
    EasyMock.expect(service.getAuth()).andReturn(auth).anyTimes();

View Full Code Here

Examples of com.google.api.explorer.client.base.ApiMethod

    assertEquals(mockService.getVersion(), apiResult.getService().getVersion());
  }

  /** Test that method names and descriptions get indexed correctly. */
  public void testMethods() {
    ApiMethod mockMethod = EasyMock.createMock(ApiMethod.class);
    EasyMock.expect(mockMethod.getDescription()).andReturn("method description").anyTimes();
    EasyMock.expect(mockMethod.getId()).andReturn("collection.methodName").anyTimes();
    EasyMock.expect(mockMethod.getParameters()).andReturn(null).anyTimes();

    ApiMethod mockMethod2 = EasyMock.createMock(ApiMethod.class);
    EasyMock.expect(mockMethod2.getDescription()).andReturn("anotherMethod description").anyTimes();
    EasyMock.expect(mockMethod2.getId()).andReturn("collection.anotherMethod").anyTimes();
    EasyMock.expect(mockMethod2.getParameters()).andReturn(null).anyTimes();

    EasyMock.expect(mockService.allMethods()).andReturn(ImmutableMap.of(
        "collection.methodName", mockMethod, "collection.anotherMethod", mockMethod2));

    EasyMock.replay(mockService, mockMethod, mockMethod2);

    List<SearchEntry> entries = ImmutableList.copyOf(discoveryStrategy.index(mockService));

    EasyMock.verify(mockService, mockMethod, mockMethod2);

    assertEquals(3, entries.size());

    // Extract the entries.
    SearchEntry method1Entry = null;
    SearchEntry method2Entry = null;
    SearchEntry serviceEntry = null;
    for (SearchEntry entry : entries) {
      SearchResult result = entry.getSearchResult();

      if (result.getKind() == Kind.SERVICE) {
        serviceEntry = entry;
      } else if (result.getKind() == Kind.METHOD) {
        if (mockMethod.equals(result.getMethodBundle().getMethod())) {
          method1Entry = entry;
        } else if (mockMethod2.equals(result.getMethodBundle().getMethod())) {
          method2Entry = entry;
        } else {
          fail("Unexpected method result: " + result.getMethodBundle().getMethod());
        }
      } else {
View Full Code Here

Examples of com.google.api.explorer.client.base.ApiMethod

        .andReturn("parameterDescription description").anyTimes();

    Schema noDescription = EasyMock.createMock(Schema.class);
    EasyMock.expect(noDescription.getDescription()).andReturn(null).anyTimes();

    ApiMethod mockMethod = EasyMock.createMock(ApiMethod.class);
    EasyMock.expect(mockMethod.getDescription()).andReturn("method description").anyTimes();
    EasyMock.expect(mockMethod.getId()).andReturn("collection.methodName").anyTimes();
    EasyMock.expect(mockMethod.getParameters())
        .andReturn(ImmutableMap.of("paramName", parameter, "noDescription", noDescription))
        .anyTimes();

    EasyMock.expect(mockService.allMethods())
        .andReturn(ImmutableMap.of("collection.methodName", mockMethod));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.