public <T> Optional<T> getOneAsComponent(Factory.Query<T> key) { Optional<NamedComponent<T>> namedComponent = getOne(key); if(namedComponent.isPresent()) { return Optional.of(namedComponent.get().getComponent()); } else { return Optional.absent(); } }
@Override public ComponentBox<SpecRecorderRoute> newComponent(SatisfiedBOM satisfiedBOM) { Optional<NamedComponent<RestxSpecRecorder.Repository>> recorder = satisfiedBOM.getOne(recordedSpecRepo); if (!recorder.isPresent()) { return new EmptyBox<>(RECORDER_ROUTE_NAME); } return BoundlessComponentBox.FACTORY.of(new NamedComponent<>(RECORDER_ROUTE_NAME, new SpecRecorderRoute(recorder.get().getComponent(), satisfiedBOM.getOneAsComponent(storageSettings).get(), satisfiedBOM.getOneAsComponent(securityManager).get(), satisfiedBOM.getOneAsComponent(permissionFactory).get() ))); }
@Override protected FactoryMachine doNewComponent(SatisfiedBOM satisfiedBOM) { FactoryMachine factoryMachine = alternatives.get(satisfiedBOM.getOne(query).get().getComponent()); if (factoryMachine != null) { return factoryMachine; } else { return NoopFactoryMachine.INSTANCE; } }
@Override public ComponentBox<SpecRecorderRoute> newComponent(SatisfiedBOM satisfiedBOM) { Optional<NamedComponent<RestxSpecRecorder.Repository>> recorder = satisfiedBOM.getOne(recordedSpecRepo); if (!recorder.isPresent()) { return new EmptyBox<>(RECORDER_ROUTE_NAME); } return BoundlessComponentBox.FACTORY.of(new NamedComponent<>(RECORDER_ROUTE_NAME, new SpecRecorderRoute(recorder.get().getComponent(), satisfiedBOM.getOneAsComponent(storageSettings).get(), satisfiedBOM.getOneAsComponent(securityManager).get(), satisfiedBOM.getOneAsComponent(permissionFactory).get() ))); }
@Override protected ComponentCustomizerEngine doNewComponent(SatisfiedBOM satisfiedBOM) { final Mapper mapper = satisfiedBOM.getOne(mapperQuery).get().getComponent(); final ObjectIdUpdater objectIdUpdater = mapper.getObjectIdUpdater(); return new SingleComponentClassCustomizerEngine<JongoCollection>(0, JongoCollection.class) { @Override public NamedComponent<JongoCollection> customize(NamedComponent<JongoCollection> namedComponent) { final JongoCollection collection = namedComponent.getComponent(); return new NamedComponent<>(namedComponent.getName(), new SequencingJongoCollection(tape, collection, mapper, objectIdUpdater)); } }; }
@Override protected ComponentCustomizerEngine doNewComponent(SatisfiedBOM satisfiedBOM) { final Mapper mapper = satisfiedBOM.getOne(mapperQuery).get().getComponent(); final ObjectIdUpdater objectIdUpdater = mapper.getObjectIdUpdater(); return new SingleComponentClassCustomizerEngine<JongoCollection>(0, JongoCollection.class) { @Override public NamedComponent<JongoCollection> customize(NamedComponent<JongoCollection> namedComponent) { final JongoCollection collection = namedComponent.getComponent(); return new NamedComponent<>(namedComponent.getName(), new SequencingJongoCollection(tape, collection, mapper, objectIdUpdater)); } }; }
@Override @SuppressWarnings("unchecked") protected T doNewComponent(SatisfiedBOM satisfiedBOM) { return (T) new StdJongoCollection(satisfiedBOM.getOne(jongoQuery).get().getComponent(), name.getName()); }
@Override @SuppressWarnings("unchecked") protected T doNewComponent(SatisfiedBOM satisfiedBOM) { return (T) new StdJongoCollection(satisfiedBOM.getOne(jongoQuery).get().getComponent(), name.getName()); }
@Override public ComponentBox<AdminPage> newComponent(SatisfiedBOM satisfiedBOM) { AppSettings settings = satisfiedBOM.getOne(appSettings).get().getComponent(); if (!RestxContext.Modes.RECORDING.equals(settings.mode())) { return new EmptyBox<>(ADMIN_PAGE_NAME); } return BoundlessComponentBox.FACTORY.of(new NamedComponent<>(ADMIN_PAGE_NAME, new AdminPage("/@/ui/recorder/", "Recorder"))); } }
@Override public ComponentBox<AdminPage> newComponent(SatisfiedBOM satisfiedBOM) { AppSettings settings = satisfiedBOM.getOne(appSettings).get().getComponent(); if (!RestxContext.Modes.RECORDING.equals(settings.mode())) { return new EmptyBox<>(ADMIN_PAGE_NAME); } return BoundlessComponentBox.FACTORY.of(new NamedComponent<>(ADMIN_PAGE_NAME, new AdminPage("/@/ui/recorder/", "Recorder"))); } }