private static void injectServices(Object contributor) { if (gatewayServices != null) { Statement stmt; for(String serviceName : gatewayServices.getServiceNames()) { try { // TODO: this is just a temporary injection solution // TODO: test for the existence of the setter before attempting it // TODO: avoid exception throwing when there is no setter stmt = new Statement(contributor, "set" + serviceName, new Object[]{gatewayServices.getService(serviceName)}); stmt.execute(); } catch (NoSuchMethodException e) { // TODO: eliminate the possibility of this being thrown up front } catch (Exception e) { // Maybe it makes sense to throw exception log.failedToInjectService( serviceName, e ); throw new DeploymentException("Failed to inject service.", e); } } } }
private static void injectServices(Object contributor) { if (gatewayServices != null) { Statement stmt = null; for(String serviceName : gatewayServices.getServiceNames()) { try { // TODO: this is just a temporary injection solution // TODO: test for the existence of the setter before attempting it // TODO: avoid exception throwing when there is no setter stmt = new Statement(contributor, "set" + serviceName, new Object[]{gatewayServices.getService(serviceName)}); stmt.execute(); } catch (NoSuchMethodException e) { // TODO: eliminate the possibility of this being thrown up front } catch (Exception e) { // Maybe it makes sense to throw exception log.failedToInjectService( serviceName, e ); throw new DeploymentException("Failed to inject service.", e); } } } }