public TableDescription useFactoryService(Class<? extends FactoryService> factoryType) { if (getFactoryLink() == null) { String factoryLink = getSelfLinkFieldValue(factoryType); if (factoryLink == null) { throw new IllegalArgumentException(String.format( "Failed to add factory %s, missing SELF_LINK field", factoryType.getCanonicalName())); } setFactoryLink(factoryLink); } try { FactoryService factoryService = factoryType.newInstance(); useFactoryService(factoryService); return this; } catch (Throwable e) { throw new IllegalArgumentException(String.format( "Failed to add factory %s", factoryType.getCanonicalName()), e); } }
public TableDescription useFactoryService(FactoryService factoryService) { if (factoryService.getHost() == null) { factoryService.setHost(this.host); } try { if (getFactoryLink() == null) { setFactoryLink(factoryService.getSelfLink()); } StatefulService childService = (StatefulService) factoryService.createServiceInstance(); useStatefulService(childService); return this; } catch (Throwable e) { throw new IllegalArgumentException(String.format( "Failed to add factory %s", factoryService.getClass().getCanonicalName()), e); } }
public TableDescription useStatefulService(StatefulService service) { if (service.getHost() == null) { service.setHost(this.host); } if (getFactoryLink() == null) { Class<? extends StatefulService> serviceType = service.getClass(); String factoryLink = getFactoryLinkFieldValue(serviceType); if (factoryLink == null) { throw new IllegalArgumentException( "Failed to add factory, missing FACTORY_LINK field"); } setFactoryLink(factoryLink); } setStateType(service.getStateType()); setServiceDocumentDescription(service.getDocumentTemplate().documentDescription); return this; }
public void addFactory(String factoryLink, StatefulService childService) { addTable(td -> { td.setFactoryLink(factoryLink); td.useStatefulService(childService); }); }
void addFactory(String factoryLink, Class<? extends ServiceDocument> stateType, ServiceDocumentDescription sdd) { addTable(td -> { td.setFactoryLink(factoryLink); td.setStateType(stateType); td.setServiceDocumentDescription(sdd); }); }
public void addFactory(String factoryLink, Class<? extends StatefulService> serviceType) { addTable(td -> { td.setFactoryLink(factoryLink); td.useStatefulService(serviceType); }); }