19 package org.turro.elephant.snippet;
22 import java.util.Optional;
23 import java.util.TreeMap;
24 import org.turro.lock.Initializer;
25 import org.turro.reflection.ClassNames;
26 import org.turro.reflection.Reflections;
34 public static final String
JSONPAR =
"jsonpar";
36 public static Optional<ISnippetService>
service(String path) {
37 Class wsclass =
instance().snippets.get(path);
39 return Optional.ofNullable((
ISnippetService) Reflections.of(wsclass).instance());
41 return Optional.empty();
46 private static final Initializer<Snippets> INIT =
new Initializer<>();
56 private final Map<String, Class> snippets;
59 snippets =
new TreeMap<>();
63 private void loadSnippets() {
64 for(String className : ClassNames.cached().byAnnotation(Snippet.class.getName())) {
65 Class wsclass = Reflections.check(className);
67 if(Reflections.of(wsclass).canCast(ISnippetService.class)) {
68 snippets.put(((Snippet) wsclass.getAnnotation(Snippet.class)).path(), wsclass);
static Optional< ISnippetService > service(String path)
static Snippets instance()
static final String JSONPAR