← 返回 Skills 市场
yndu13

Alibabacloud Sdk Client Initialization For Java

作者 yndu13 · GitHub ↗ · v0.0.2-beta · MIT-0
cross-platform ⚠ suspicious
103
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install alibabacloud-sdk-client-initialization-for-java
功能描述
Initialize and manage Alibaba Cloud SDK clients in Java. Covers singleton pattern, thread safety, endpoint vs region configuration, VPC endpoints, sync vs as...
使用说明 (SKILL.md)

Client Initialization Best Practices (Java)

Core Rules

  • Client is thread-safe — safe to share across threads without synchronization.
  • Use singleton pattern — do NOT create new client instances per request. Frequent new Client() calls waste resources and hurt performance.
  • Prefer explicit endpoint over region-based endpoint resolution.
  • preview version

Recommended Client Creation

public class ClientFactory {
    private static volatile com.aliyun.ecs20140526.Client instance;

    public static com.aliyun.ecs20140526.Client getInstance() throws Exception {
        if (instance == null) {
            synchronized (ClientFactory.class) {
                if (instance == null) {
                    com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                        .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                        .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
                    config.setEndpoint("ecs.cn-hangzhou.aliyuncs.com");
                    instance = new com.aliyun.ecs20140526.Client(config);
                }
            }
        }
        return instance;
    }
}

Endpoint Configuration

Priority: explicit endpoint > region-based resolution via regionId.

// Preferred: explicit endpoint
config.setEndpoint("ecs.cn-hangzhou.aliyuncs.com");

// Alternative: SDK resolves endpoint from region
config.setRegionId("cn-hangzhou");

VPC Endpoints

Use VPC endpoints when running inside Alibaba Cloud VPC (hybrid cloud, leased lines, multi-region):

config.setEndpoint("ecs-vpc.cn-hangzhou.aliyuncs.com");

File Upload APIs (Advance)

For file upload APIs (e.g., Visual Intelligence), set both regionId and endpoint to the same region. Otherwise you may see timeouts due to cross-region OSS access:

config.setRegionId("cn-shanghai");
config.setEndpoint("objectdet.cn-shanghai.aliyuncs.com");
// For VPC file upload authorization:
client._openPlatformEndpoint = "openplatform-vpc.cn-shanghai.aliyuncs.com";

Synchronous vs Asynchronous

Mode SDK Artifact When to Use
Synchronous com.aliyun:{productCode}{version} Simple flows, low concurrency, easier debugging
Asynchronous com.aliyun:alibabacloud-{productCode}{version} High concurrency/throughput, non-blocking I/O

Async example:

AsyncClient client = AsyncClient.builder()
    .region("cn-hangzhou")
    .credentialsProvider(provider)
    .overrideConfiguration(ClientOverrideConfiguration.create()
        .setEndpointOverride("ecs.cn-chengdu.aliyuncs.com"))
    .build();

CompletableFuture\x3CDescribeRegionsResponse> response = client.describeRegions(request);
response.thenAccept(resp -> System.out.println(new Gson().toJson(resp)))
    .exceptionally(throwable -> { System.out.println(throwable.getMessage()); return null; });
// Always close async client when done
client.close();
安全使用建议
This is primarily an examples/instructions-only skill for Alibaba Cloud Java SDK clients and appears functionally coherent, but note two issues before installing or using it: (1) the SKILL.md examples rely on ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables, yet the skill metadata does not declare any required credentials — ask the publisher to explicitly declare required env vars or update the metadata; (2) the source and homepage are unknown, which reduces trust — prefer skills with a verifiable author or repo. If you proceed, avoid exposing long-lived root keys: use least-privilege credentials, Alibaba RAM roles or STS temporary tokens where possible, don't paste secrets into chat, and confirm how the agent will obtain/use those environment variables. Request clarification from the author about credential handling and the intended deployment environment to raise confidence.
功能分析
Type: OpenClaw Skill Name: alibabacloud-sdk-client-initialization-for-java Version: 0.0.2-beta The skill bundle provides standard documentation and best practices for initializing Alibaba Cloud SDK clients in Java. The instructions in SKILL.md cover legitimate topics such as the singleton pattern, thread safety, and VPC endpoint configuration. There is no evidence of malicious intent, data exfiltration, or prompt injection; the code snippets provided are typical for legitimate SDK usage and follow standard security practices like reading credentials from environment variables.
能力评估
Purpose & Capability
The skill's name and content are consistent with initializing Alibaba Cloud Java SDK clients. However, the example code calls System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID") and System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") while the skill metadata declares no required environment variables or primary credential. Credentials are central to the skill's purpose and should be explicitly declared.
Instruction Scope
The SKILL.md contains runnable Java examples that read environment variables for credentials and set endpoints; these actions are within scope for a cloud SDK guide. It does not instruct the agent to read unrelated files, system config, or exfiltrate data. Still, the examples implicitly expect secrets in the environment which the metadata omits.
Install Mechanism
No install spec and no code files (instruction-only). This minimizes filesystem risk; nothing is fetched or executed by an installer.
Credentials
The SKILL.md uses sensitive environment variables (ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET) but the skill metadata does not list them under required env or primary credential. Requiring cloud credentials would be proportionate to the purpose, but the omission is an inconsistency that could hide expected secret access.
Persistence & Privilege
always is false and there are no install actions or configuration changes. The skill does not request persistent system privileges or to modify other skills.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install alibabacloud-sdk-client-initialization-for-java
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /alibabacloud-sdk-client-initialization-for-java 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.0.2-beta
- Bumped version to 0.0.2-beta. - Added "preview version" mention to Core Rules section in documentation. - No other changes to guidance, examples, or API recommendations.
v0.0.1
Initial release providing best practices and code examples for Alibaba Cloud SDK client initialization in Java. - Explains thread safety and recommends the singleton pattern for client reuse. - Details explicit endpoint configuration, region-based alternatives, and VPC endpoint usage. - Covers both synchronous and asynchronous client usage scenarios. - Includes advice for file upload APIs to ensure reliable, region-matched configuration. - Provides ready-to-use sample code for client factory implementation and async API calls.
元数据
Slug alibabacloud-sdk-client-initialization-for-java
版本 0.0.2-beta
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Alibabacloud Sdk Client Initialization For Java 是什么?

Initialize and manage Alibaba Cloud SDK clients in Java. Covers singleton pattern, thread safety, endpoint vs region configuration, VPC endpoints, sync vs as... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 103 次。

如何安装 Alibabacloud Sdk Client Initialization For Java?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install alibabacloud-sdk-client-initialization-for-java」即可一键安装,无需额外配置。

Alibabacloud Sdk Client Initialization For Java 是免费的吗?

是的,Alibabacloud Sdk Client Initialization For Java 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Alibabacloud Sdk Client Initialization For Java 支持哪些平台?

Alibabacloud Sdk Client Initialization For Java 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Alibabacloud Sdk Client Initialization For Java?

由 yndu13(@yndu13)开发并维护,当前版本 v0.0.2-beta。

💬 留言讨论