속성을 사용하면 런타임 시 자바 코드에서 액세스할 수 있는 JavaCallout 정책에 이름/값 쌍을 지정할 수 있습니다. 각 속성에 리터럴 문자열 값을 지정해야 합니다. 이 요소에서는 흐름 변수를 참조할 수 없습니다.
속성을 사용하는 간단한 JavaCallout 정책 예시를 살펴보겠습니다. 이 예시에서는 JavaCallout 정책이 포함된 프록시를 만듭니다. 정책은 <Properties> 요소를 사용하여 이름/값 쌍을 지정합니다. 자바 코드에서 값을 검색한 다음 이 값을 사용하여 응답 헤더를 설정합니다.
이 샘플의 자바 코드는 JavaCallout 정책에 지정된 속성을 검색하는 방법을 보여줍니다. 샘플 프로젝트의 java-properties/callout/src/main/java/JavaProperties.java에서 소스 코드를 확인할 수 있습니다. 이 주제의 뒷부분에서 이 코드를 컴파일하고 배포하는 단계를 살펴보겠습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-19(UTC)"],[[["\u003cp\u003eThis page details how to use properties within Java callouts in Apigee and Apigee hybrid, enabling dynamic configuration of Java code at runtime.\u003c/p\u003e\n"],["\u003cp\u003eJava callout policies in Apigee use the \u003ccode\u003e<Properties>\u003c/code\u003e element to define name/value pairs that can be accessed from the Java code.\u003c/p\u003e\n"],["\u003cp\u003eThe provided example project, available on GitHub, demonstrates how to retrieve property values specified in the policy and use them to set response headers.\u003c/p\u003e\n"],["\u003cp\u003eCompilation instructions are provided for both Maven and \u003ccode\u003ejavac\u003c/code\u003e, including steps to ensure the JAR file is in the correct directory for proxy deployment.\u003c/p\u003e\n"],["\u003cp\u003eDeploying the sample proxy allows you to call it and verify that the Java callout correctly retrieves the property value, setting a response header accordingly.\u003c/p\u003e\n"]]],[],null,["# How to use properties in the JavaCallout\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nWhat is a Java callout?\n-----------------------\n\nIf you're new to JavaCallouts, we recommend that you start with [How to create a Java\ncallout](/apigee/docs/api-platform/develop/how-create-java-callout).\n\nUsing properties in JavaCallout policies\n----------------------------------------\n\nProperties let you specify name/value pairs in a JavaCallout policy that you can access from\nyour Java code at runtime. You must specify a literal string value for each property; you cannot\nreference flow variables in this element.\n\nLet's walk through a simple JavaCallout policy example that uses properties. In this example, we\ncreate a proxy with that includes a JavaCallout policy. The policy uses the\n`\u003cProperties\u003e` element to specify a name/value pair. In the Java code, we\nretrieve the value and use it to set a response header.\n\n### Download the project\n\nTo make things simple, you can download this project from the Apigee [api-platform-samples](https://github.com/apigee/api-platform-samples) repository on\nGitHub.\n\n1. Download or clone [api-platform-samples](https://github.com/apigee/api-platform-samples) to your system.\n2. In a terminal or code editor of your choice, go to the `api-platform-samples/doc-samples/java-properties` project.\n\n### The JavaCallout policy\n\nThe policy uses the `\u003cProperties\u003e` element. This element lets you specify\nname/value pairs. At runtime, your Java code can access the values of the properties specified in\nthe policy, as we'll see shortly. \n\n```java\n\u003cJavaCallout name=\"java-callout\"\u003e\n \u003cClassName\u003ecom.apigeesample.JavaProperties\u003c/ClassName\u003e\n \u003cResourceURL\u003ejava://edge-custom-policy-java-properties.jar\u003c/ResourceURL\u003e\n \u003cProperties\u003e\n \u003cProperty name=\"prop\"\u003eWORLD!\u003c/Property\u003e\n \u003c/Properties\u003e\n\u003c/JavaCallout\u003e\n```\n\n### The sample Java code\n\nThe Java code for this sample shows you how to retrieve a property that was specified in the\nJavaCallout policy. In the sample project, you can find the source code in\n`java-properties/callout/src/main/java/JavaProperties.java`. We'll walk through the\nsteps for compiling and deploying this code later in this topic. \n\n```java\npackage com.apigeesample;\n\nimport com.apigee.flow.execution.ExecutionContext;\nimport com.apigee.flow.execution.ExecutionResult;\nimport com.apigee.flow.execution.spi.Execution;\nimport com.apigee.flow.message.MessageContext;\n\nimport java.util.Map;\n\npublic class JavaProperties implements Execution {\n\n\tprivate Map \u003cString,String\u003e properties; // read-only\n\n\tpublic JavaProperties(Map \u003cString,String\u003e properties) {\n\t this.properties = properties;\n\t}\n\n\tpublic ExecutionResult execute(MessageContext messageContext, ExecutionContext executionContext) {\n\n\t\ttry {\n\n\t\t messageContext.getMessage().setHeader(\"X-PROPERTY-HELLO\", this.properties.get(\"prop\"));\n\n return ExecutionResult.SUCCESS;\n\n\t\t} catch (Exception e) {\n\t\t\treturn ExecutionResult.ABORT;\n\t\t}\n\t}\n}\n```\n| **Note:** To retrieve the properties specified in the policy, all you need to do is implement the Execution class constructor as shown above. Then, in the Java code, you can get the property value you want by name.\n\n### Compile your code with Maven\n\nThe project is set up so that you can compile with Maven. If you want to use\n`javac`, we'll include an example as well.\n| **Note:** The POM file and configuration for the Maven compile should work, but are offered in the Git repository as an example only. You may need to make adjustments for your environment. If you make changes to the sample code, you may also need to adjust the Maven configuration.\n\n1. Be sure that you have Maven installed: \n\n ```java\n mvn -version\n ```\n2. Execute the script `java-properties/buildsetup.sh`. This script installs the required JAR dependencies in your local Maven repo.\n3. cd to the `java-properties/callout` directory.\n4. Execute Maven: \n\n ```java\n mvn clean package\n ```\n | **Note:** If you get a Maven error, be sure that you are in the `java-properties/callout` directory.\n5. If you wish, verify that the JAR file `edge-custom-policy-java-properties.jar` was copied to `java-properties/apiproxy/resources/java`. This is the required location for JAR files that you wish to deploy with a proxy.\n\n### Compile with javac (optional)\n\nIf you want to use `javac` to compile the code, you can do something similar to the\nfollowing (from the `java-properties` directory). The required JAR files are provided\nfor you in the `java-properties/lib` directory.\n\n1. cd to `api-platform-samples/doc-samples/java-properties`.\n2. Be sure you have javac in your path. \n\n ```java\n javac -version\n ```\n3. Execute the following javac command: \n\n ```java\n javac -d . -classpath ./lib/expressions-1.0.0.jar:./lib/message-flow-1.0.0.jar:. callout/src/main/java/JavaProperties.java\n ```\n4. Create a JAR file: \n\n `jar -cvf edge-custom-policy-java-properties.jar\n ./com/apigeesample/JavaProperties.class` \n5. Copy the JAR file to the apiproxy/resources/java directory. This is the required location for JAR files that you wish to deploy with a proxy. \n\n ```java\n cp edge-custom-policy-java-properties.jar apiproxy/resources/java\n ```\n\n### Deploy and call the proxy\n\nA deploy script is provided in the `./java-properties` directory. But before you\nrun it, you need to do a quick setup.\n\n1. cd to `api-platform-samples/doc-samples/java-properties`\n2. The simplest way to deploy the proxy is to bundle it in a zip file and upload the proxy bundle to an environment in your Apigee organization. See [Creating an API proxy](/apigee/docs/api-platform/develop/ui-create-proxy). Be sure to use the **Upload Proxy Bundle** option. See also [Tips and tricks for uploading API proxy in a proxy bundle](https://community.apigee.com/questions/64498/tips-and-tricks-for-uploading-api-proxy-in-proxy-b.html) in the Apigee community.\n3. When the proxy is deployed, try calling it: \n\n ```java\n curl https://$HOSTNAME/java-properties\n ```\n\n The proxy returns the header: `X-PROPERTY-HELLO: WORLD!`. Remember that in the\n policy, we added a property name/value pair `\"prop/WORLD!\"`. The JavaCallout policy\n retrieves the value `\"WORLD!\"` and sets it in a header called\n `X-PROPERTY-HELLO`: \n\n ```java\n messageContext.getMessage().setHeader(\"X-PROPERTY-HELLO\", this.properties.get(\"prop\"));\n ```"]]