ExtensionLoader { protected String[] parseAliasAndClassName(String line) { if (StringUtils.isBlank(line)) { return null; } line = line.trim(); int i0 = line.indexOf('#'); if (i0 == 0 || line.length() == 0) { return null; } if (i0 > 0) { line = line.substring(0, i0).trim(); } String alias = null; String className; int i = line.indexOf('='); if (i > 0) { alias = line.substring(0, i).trim(); className = line.substring(i + 1).trim(); } else { className = line; } if (className.length() == 0) { return null; } return new String[] { alias, className }; } ExtensionLoader(Class<T> interfaceClass, ExtensionLoaderListener<T> listener); protected  ExtensionLoader(Class<T> interfaceClass); protected  ExtensionLoader(Class<T> interfaceClass, boolean autoLoad, ExtensionLoaderListener<T> listener); ConcurrentMap<String, ExtensionClass<T>> getAllExtensions(); ExtensionClass<T> getExtensionClass(String alias); T getExtension(String alias); T getExtension(String alias, Class[] argTypes, Object[] args); void loadExtension(Class loadedClass); void addListener(ExtensionLoaderListener<T> listener);  }
@Test public void testParseAliasAndClassName() throws Exception { ExtensionLoader loader = new ExtensionLoader<Filter>(Filter.class); Assert.assertNull(loader.parseAliasAndClassName(null)); Assert.assertNull(loader.parseAliasAndClassName("")); Assert.assertNull(loader.parseAliasAndClassName(" ")); Assert.assertNull(loader.parseAliasAndClassName("\t")); Assert.assertNull(loader.parseAliasAndClassName("\r\n")); Assert.assertNull(loader.parseAliasAndClassName(" # xxxx")); Assert.assertNull(loader.parseAliasAndClassName("# xxxx")); Assert.assertNull(loader.parseAliasAndClassName("xxx=")); Assert.assertArrayEquals(loader.parseAliasAndClassName("1111"), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" 1111"), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" 1111 "), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("1111 "), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("1111#aa"), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" 1111#aa"), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("1111#aa "), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" 1111#aa "), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("1111 #aa"), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" 1111 #aa"), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("1111 #aa "), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" 1111 #aa "), new String[] { null, "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("aa=1111"), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" aa=1111"), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("aa=1111 "), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" aa=1111 "), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("aa=1111#aa"), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" aa=1111#aa"), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("aa=1111#aa "), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" aa=1111#aa "), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("aa=1111 #aa"), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" aa=1111 #aa"), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName("aa=1111 #aa "), new String[] { "aa", "1111" }); Assert.assertArrayEquals(loader.parseAliasAndClassName(" aa=1111 #aa "), new String[] { "aa", "1111" }); }