DynamicScriptResource.java
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.adapter.annotations.Adaptable
* org.apache.sling.adapter.annotations.Adapter
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceMetadata
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.SyntheticResource
*/
package com.adobe.cq.projects.impl.workflow;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.apache.sling.adapter.annotations.Adaptable;
import org.apache.sling.adapter.annotations.Adapter;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.SyntheticResource;
@Adaptable(adaptableClass=Resource.class, adapters={@Adapter(value={InputStream.class})})
public class DynamicScriptResource
extends SyntheticResource {
protected byte[] script;
public DynamicScriptResource(ResourceResolver resourceResolver, String script) {
super(resourceResolver, new ResourceMetadata(), "nt:file");
this.script = script.getBytes();
}
public String getPath() {
return "/etc/workflow/scripts/dynamic.ecma";
}
public <T> T adaptTo(Class<T> clazz) {
if (clazz == InputStream.class) {
return (T)new ByteArrayInputStream(this.script);
}
return (T)super.adaptTo(clazz);
}
}