001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.remote; 014 015import static org.apache.juneau.internal.StringUtils.*; 016 017import java.lang.reflect.*; 018 019import org.apache.juneau.internal.*; 020 021/** 022 * Contains the meta-data about a Java method on a remote class. 023 * 024 * <p> 025 * Captures the information in {@link RemoteInterface @RemoteInterface} annotations for caching and reuse. 026 * 027 * <ul class='seealso'> 028 * <li class='link'>{@doc juneau-rest-server.restRPC} 029 * </ul> 030 */ 031public class RemoteInterfaceMethod { 032 033 private final String url, path; 034 private final Method method; 035 036 /** 037 * Constructor. 038 * 039 * @param restUrl The absolute URL of the REST interface backing the interface proxy. 040 * @param m The Java method. 041 */ 042 public RemoteInterfaceMethod(final String restUrl, Method m) { 043 this.method = m; 044 this.path = m.getName() + '/' + HttpUtils.getMethodArgsSignature(m, true); 045 this.url = trimSlashes(restUrl) + '/' + urlEncode(path); 046 } 047 048 /** 049 * Returns the absolute URL of the REST interface invoked by this Java method. 050 * 051 * @return The absolute URL of the REST interface, never <jk>null</jk>. 052 */ 053 public String getUrl() { 054 return url; 055 } 056 057 /** 058 * Returns the HTTP path of this method. 059 * 060 * @return 061 * The HTTP path of this method relative to the parent interface. 062 * <br>Never <jk>null</jk>. 063 * <br>Never has leading or trailing slashes. 064 */ 065 public String getPath() { 066 return path; 067 } 068 069 /** 070 * Returns the underlying Java method that this metadata is about. 071 * 072 * @return 073 * The underlying Java method that this metadata is about. 074 * <br>Never <jk>null</jk>. 075 */ 076 public Method getJavaMethod() { 077 return method; 078 } 079}