/** * Registers a list of helpers. * * @param descriptorPath * Classpath to the descriptor file. * @param helpers * The list of helpers to update. * @param constructorClass * The constructor parameter class to look for. * @throws IOException */ public void registerHelpers(String descriptorPath, List<?> helpers, Class<?> constructorClass) throws IOException { ClassLoader classLoader = getClassLoader(); Enumeration<java.net.URL> configUrls = classLoader .getResources(descriptorPath); if (configUrls != null) { for (Enumeration<java.net.URL> configEnum = configUrls; configEnum .hasMoreElements();) { registerHelpers(classLoader, configEnum.nextElement(), helpers, constructorClass); } } }
/** * Registers the helpers for a given bundle. * * @param bundle * The bundle to inspect. * @param helpers * The helpers list to update. * @param constructorClass * The class to use as constructor parameter. * @param descriptorUrl * The descriptor URL to inspect. */ private void registerHelper(final Bundle bundle, List<?> helpers, Class<?> constructorClass, URL descriptorUrl) { Engine.getInstance().registerHelpers(new ClassLoader() { @Override public Class<?> loadClass(String name) throws ClassNotFoundException { return bundle.loadClass(name); } }, descriptorUrl, helpers, constructorClass); }
/** * Discovers the server and client connectors and register the default * connectors. * * @throws IOException */ private void discoverConnectors() throws IOException { registerHelpers(DESCRIPTOR_CLIENT_PATH, getRegisteredClients(), Client.class); registerHelpers(DESCRIPTOR_SERVER_PATH, getRegisteredServers(), org.restlet.Server.class); registerDefaultConnectors(); }
/** * Discovers the authenticator helpers and register the default helpers. * * @throws IOException */ private void discoverAuthenticators() throws IOException { registerHelpers(DESCRIPTOR_AUTHENTICATOR_PATH, getRegisteredAuthenticators(), null); registerDefaultAuthentications(); }
/** * Discovers the converter helpers and register the default helpers. * * @throws IOException */ private void discoverConverters() throws IOException { registerHelpers(DESCRIPTOR_CONVERTER_PATH, getRegisteredConverters(), null); registerDefaultConverters(); }
/** * Discovers the protocol helpers and register the default helpers. * * @throws IOException */ private void discoverProtocols() throws IOException { registerHelpers(DESCRIPTOR_PROTOCOL_PATH, getRegisteredProtocols(), null); registerDefaultProtocols(); }