1 module hunt.http.codec.websocket.model.extension.ExtensionFactory; 2 3 import hunt.http.codec.websocket.model.extension.AbstractExtension; 4 5 import hunt.http.codec.websocket.model.Extension; 6 import hunt.http.codec.websocket.model.ExtensionConfig; 7 import hunt.http.codec.websocket.model.extension.compress.DeflateFrameExtension; 8 import hunt.http.codec.websocket.model.extension.compress.PerMessageDeflateExtension; 9 import hunt.http.codec.websocket.model.extension.compress.XWebkitDeflateFrameExtension; 10 import hunt.http.codec.websocket.model.extension.fragment.FragmentExtension; 11 import hunt.http.codec.websocket.model.extension.identity.IdentityExtension; 12 13 import hunt.collection.Map; 14 import hunt.collection.HashMap; 15 import hunt.logging; 16 import hunt.Exceptions; 17 18 19 abstract class ExtensionFactory { // : Iterable<Class<? : Extension>> 20 private Map!(string, AbstractExtension) availableExtensions; 21 22 this() { 23 availableExtensions = new HashMap!(string, AbstractExtension)(); 24 // implementationMissing(false); 25 // TODO: Tasks pending completion -@zxp at 11/13/2018, 3:18:21 PM 26 // 27 // for (Extension ext : extensionLoader) { 28 // if (ext !is null) { 29 // availableExtensions.put(ext.getName(), ext.getClass()); 30 // } 31 // } 32 // if (CollectionUtils.isEmpty(availableExtensions)) { 33 // availableExtensions.put(new DeflateFrameExtension().getName(), DeflateFrameExtension.class); 34 // availableExtensions.put(new PerMessageDeflateExtension().getName(), PerMessageDeflateExtension.class); 35 // availableExtensions.put(new XWebkitDeflateFrameExtension().getName(), XWebkitDeflateFrameExtension.class); 36 // availableExtensions.put(new IdentityExtension().getName(), IdentityExtension.class); 37 // availableExtensions.put(new FragmentExtension().getName(), FragmentExtension.class); 38 // } 39 } 40 41 // Map<string, Class<? : Extension>> getAvailableExtensions() { 42 // return availableExtensions; 43 // } 44 45 // Class<? : Extension> getExtension(string name) { 46 // return availableExtensions.get(name); 47 // } 48 49 // Set<string> getExtensionNames() { 50 // return availableExtensions.keySet(); 51 // } 52 53 bool isAvailable(string name) { 54 version(HUNT_HTTP_DEBUG) tracef("Extension: %s", name); 55 return availableExtensions.containsKey(name); 56 } 57 58 // override 59 // Iterator<Class<? : Extension>> iterator() { 60 // return availableExtensions.values().iterator(); 61 // } 62 63 abstract Extension newInstance(ExtensionConfig config); 64 65 // void register(string name, Class<? : Extension> extension) { 66 // availableExtensions.put(name, extension); 67 // } 68 69 // void unregister(string name) { 70 // availableExtensions.remove(name); 71 // } 72 }