/** * Creates a new helper for a given client connector. * * @param client The client to help. * @param helperClass Optional helper class name. * @return The new helper. */ @SuppressWarnings("unchecked") public ConnectorHelper<Client> createHelper(Client client, String helperClass) { ConnectorHelper<Client> result = null; if (client.getProtocols().size() > 0) { ConnectorHelper<Client> connector = null; for (final Iterator<ConnectorHelper<Client>> iter = getRegisteredClients().iterator(); (result == null) && iter.hasNext(); ) { connector = iter.next(); if (connector.getProtocols().containsAll(client.getProtocols())) { if ((helperClass == null) || connector.getClass().getCanonicalName().equals(helperClass)) { try { result = connector.getClass().getConstructor(Client.class).newInstance(client); } catch (Exception e) { Context.getCurrentLogger() .log( Level.SEVERE, "Exception during the instantiation of the client connector.", e); } } } } if (result == null) { // Couldn't find a matching connector StringBuilder sb = new StringBuilder(); sb.append("No available client connector supports the required protocols: "); for (Protocol p : client.getProtocols()) { sb.append("'").append(p.getName()).append("' "); } sb.append(". Please add the JAR of a matching connector to your classpath."); if (Edition.CURRENT == Edition.ANDROID) { sb.append(" Then, register this connector helper manually."); } Context.getCurrentLogger().log(Level.WARNING, sb.toString()); } } return result; }