| | |
| | | */ |
| | | package de.uhilger.neon; |
| | | |
| | | import de.uhilger.neon.entity.ActorDescriptor; |
| | | import com.google.gson.Gson; |
| | | import com.sun.net.httpserver.Authenticator; |
| | | import com.sun.net.httpserver.Filter; |
| | |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import de.uhilger.neon.Scanner.ScannerListener; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * Einen Neon-Server aus einer Beschreibungsdatei herstellen |
| | |
| | | */ |
| | | public class Factory implements ScannerListener { |
| | | |
| | | private Map<String, List<TempActor>> actorMap; |
| | | private Map<String, List<ActorDescriptor>> actorMap; |
| | | |
| | | public Factory() { |
| | | listeners = new ArrayList<>(); |
| | |
| | | * @param contextName Name des Kontext, dem der Handler zugeordnet ist |
| | | */ |
| | | private void wire(Handler h, String contextName) { |
| | | List<TempActor> actorList = actorMap.get(contextName); |
| | | Iterator<TempActor> i = actorList.iterator(); |
| | | List<ActorDescriptor> actorList = actorMap.get(contextName); |
| | | Iterator<ActorDescriptor> i = actorList.iterator(); |
| | | while(i.hasNext()) { |
| | | TempActor actor = i.next(); |
| | | ActorDescriptor actor = i.next(); |
| | | h.setActor(actor.getHttpMethod(), actor.getRoute(), actor.getActorClassName()); |
| | | } |
| | | } |
| | |
| | | if (action != null) { |
| | | List<String> actionHandlers = Arrays.asList(action.handler()); |
| | | for (String contextName : actionHandlers) { |
| | | TempActor tempActor = new TempActor(); |
| | | ActorDescriptor tempActor = new ActorDescriptor(); |
| | | tempActor.setContextName(contextName); |
| | | tempActor.setHttpMethod(action.type()); |
| | | tempActor.setRoute(action.route()); |
| | | tempActor.setActorClassName(foundClass.getName()); |
| | | |
| | | List<TempActor> actorList = actorMap.get(contextName); |
| | | List<ActorDescriptor> actorList = actorMap.get(contextName); |
| | | if(actorList == null) { |
| | | actorList = new ArrayList<>(); |
| | | } |