Class ExternalXsltResourceLoader
ITextResource. It also exposes narrow Web3-only methods
for retrieving an ITextResource directly.
The supported web3:// form is deliberately narrower than the full
ERC-4804/6860 URL grammar:
web3://0x<40-hex-address>:<explicit-chain-id>/content
The loader calls content()(bytes) at the numeric
snapshotBlock supplied by the caller. It does not support name
services, cross-chain calls, userinfo/from addresses, manual resolve mode,
arbitrary methods, arguments, queries, or fragments.
HTTP access is denied unless the normalized host is explicitly listed in
ExternalXsltResourceLoader.Options. Automatic redirects are disabled and each redirect target is
checked against the same policy. Private and special-purpose addresses are
denied by default. Network-level egress controls are still recommended to
close DNS-rebinding and proxy-related gaps that cannot be eliminated by an
application-level URL check alone.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBase type for all expected resource-loading failures.static final classThe supplied URI or snapshot parameter is malformed.static final classImmutable loader policy.static final classResource access was rejected by the configured security policy.static final classLoading exceeded the configured network timeout.static final classThe resource exceeded the configured byte limit.static classThe remote HTTP server or renderer RPC failed. -
Constructor Summary
ConstructorsConstructorDescriptionExternalXsltResourceLoader(org.web3j.protocol.Web3j web3j, ExternalXsltResourceLoader.Options options) Creates a loader using the supplied application Web3j connection. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]load(URI uri, BigInteger snapshotBlock) Loads a stylesheet at a fixed EVM snapshot block.byte[]loadTextResource(String contractAddress, BigInteger snapshotBlock) Loads anITextResourceby contract address at a fixed EVM snapshot block.byte[]loadTextResource(URI web3Url, BigInteger snapshotBlock) Loads an on-chain text resource from its canonical Web3 URL at a fixed EVM snapshot block.
-
Constructor Details
-
ExternalXsltResourceLoader
public ExternalXsltResourceLoader(org.web3j.protocol.Web3j web3j, ExternalXsltResourceLoader.Options options) Creates a loader using the supplied application Web3j connection.- Parameters:
web3j- Web3j connection used for same-chain, block-pinnedweb3://calls.options- Immutable HTTP and resource-limit policy.
-
-
Method Details
-
load
public byte[] load(URI uri, BigInteger snapshotBlock) throws ExternalXsltResourceLoader.ExternalXsltResourceException Loads a stylesheet at a fixed EVM snapshot block.A numeric block is required for every scheme so callers cannot accidentally render state at one block and resolve a
web3://stylesheet at a movinglatestblock.- Parameters:
uri- Absolute external resource URI.snapshotBlock- Non-negative numeric snapshot block.- Returns:
- Raw stylesheet bytes, never larger than the configured limit.
- Throws:
ExternalXsltResourceLoader.ExternalXsltResourceException- If the URI is invalid or disallowed, the upstream cannot be read, or the resource is too large.
-
loadTextResource
public byte[] loadTextResource(URI web3Url, BigInteger snapshotBlock) throws ExternalXsltResourceLoader.ExternalXsltResourceException Loads an on-chain text resource from its canonical Web3 URL at a fixed EVM snapshot block.Only the canonical same-chain form
web3://<address>:<chain-id>/contentis accepted. The returned bytes are the exact value ofITextResource.content().- Parameters:
web3Url- Canonical Web3 URL of the text resource.snapshotBlock- Non-negative numeric snapshot block.- Returns:
- Exact resource bytes, never larger than the configured limit.
- Throws:
ExternalXsltResourceLoader.ExternalXsltResourceException- If the URL is malformed or disallowed, the RPC call fails, or the resource is too large.
-
loadTextResource
public byte[] loadTextResource(String contractAddress, BigInteger snapshotBlock) throws ExternalXsltResourceLoader.ExternalXsltResourceException Loads anITextResourceby contract address at a fixed EVM snapshot block. The configured RPC chain is used implicitly.- Parameters:
contractAddress- Address of theITextResourcecontract.snapshotBlock- Non-negative numeric snapshot block.- Returns:
- Exact resource bytes, never larger than the configured limit.
- Throws:
ExternalXsltResourceLoader.ExternalXsltResourceException- If the address is malformed, the RPC call fails, or the resource is too large.
-