001package jmri.server.json.util; 002 003import com.fasterxml.jackson.databind.ObjectMapper; 004import jmri.server.json.JSON; 005import jmri.server.json.JsonConnection; 006import jmri.server.json.JsonException; 007import jmri.spi.JsonServiceFactory; 008import org.openide.util.lookup.ServiceProvider; 009 010/** 011 * @author Randall Wood 012 */ 013@ServiceProvider(service = JsonServiceFactory.class) 014public class JsonUtilServiceFactory implements JsonServiceFactory<JsonUtilHttpService, JsonUtilSocketService> { 015 016 @Override 017 public String[] getTypes(String version) { 018 return new String[]{JSON.GOODBYE, 019 JSON.HELLO, 020 JSON.METADATA, 021 JSON.NETWORK_SERVICE, 022 JSON.NETWORK_SERVICES, 023 JSON.NODE, 024 JSON.PANEL, 025 JSON.PANELS, 026 JSON.RAILROAD, 027 JSON.SYSTEM_CONNECTION, 028 JSON.SYSTEM_CONNECTIONS, 029 JSON.CONFIG_PROFILE, 030 JSON.CONFIG_PROFILES, 031 JSON.VERSION 032 }; 033 } 034 035 @Override 036 public String[] getSentTypes(String version) { 037 // retain ERROR on behalf of JsonException for schema handling 038 // retain LIST on behalf of JSON servers for schema handling 039 // retain PONG on behalf of JSON servers for schema handling 040 return new String[]{JsonException.ERROR, JSON.LIST, JSON.PONG}; 041 } 042 043 @Override 044 public String[] getReceivedTypes(String version) { 045 // retain LOCALE on behalf of JSON servers for schema handling 046 // retain PING on behalf of JSON servers for schema handling 047 return new String[]{JSON.LOCALE, JSON.PING}; 048 } 049 050 @Override 051 public JsonUtilSocketService getSocketService(JsonConnection connection, String version) { 052 return new JsonUtilSocketService(connection); 053 } 054 055 @Override 056 public JsonUtilHttpService getHttpService(ObjectMapper mapper, String version) { 057 return new JsonUtilHttpService(mapper); 058 } 059 060}