public static Bundle getBundle(Osgi osgi, String bundleSpec) { Bundle bundle = osgi.getBundle(ComponentSpecification.fromString(bundleSpec)); if (bundle == null) { throw new IllegalArgumentException("Bundle not found: " + bundleSpec); } return bundle; }
/** * Set the desired format for result rendering. If null, use the default renderer. */ public void setFormat(@Nullable String format) { setRenderer(ComponentSpecification.fromString(format)); }
public Jersey2Servlet(String bindingPath) { super(new ComponentModel( new BundleInstantiationSpecification(idSpecFromPath(bindingPath), ComponentSpecification.fromString(CLASS), ComponentSpecification.fromString(BUNDLE))), bindingPath + BINDING_SUFFIX); }
/** * Looks up source.(sourceId).provider in the query properties. * @return null if the default provider should be used */ private ComponentSpecification providerSpecificationForSource(Properties queryProperties) { String spec = queryProperties.getString("source." + sourceId().stringValue() + ".provider"); return ComponentSpecification.fromString(spec); }
public DummySslProvider(String serverName) { super(new ComponentModel( new BundleInstantiationSpecification(new ComponentId(COMPONENT_ID_PREFIX + serverName), fromString(COMPONENT_CLASS), fromString(COMPONENT_BUNDLE)))); }
public JettyHttpServer(ComponentId id) { super(new ComponentModel( new BundleInstantiationSpecification(id, fromString("com.yahoo.jdisc.http.server.jetty.JettyHttpServer"), fromString("jdisc_http_service")) )); final FilterBindingsProviderComponent filterBindingsProviderComponent = new FilterBindingsProviderComponent(id); addChild(filterBindingsProviderComponent); inject(filterBindingsProviderComponent); }
public CustomSslProvider(String serverName, String className, String bundle) { super(new ComponentModel( new BundleInstantiationSpecification(new ComponentId(COMPONENT_ID_PREFIX + serverName), fromString(className), fromString(bundle)))); }
public ServletProvider(SimpleComponent servletToProvide, String bindingPath, Map<String, String> servletConfig) { super(new ComponentModel( new BundleInstantiationSpecification(servletToProvide.getComponentId().nestInNamespace(SERVLET_PROVIDER_NAMESPACE), ComponentSpecification.fromString(CLASS), ComponentSpecification.fromString(BUNDLE))), bindingPath); inject(servletToProvide); addChild(servletToProvide); this.servletConfig = servletConfig; }
private void configureFilters(List<FilterSpec> filtersConfig, FilterChainRepository filterChainRepository) { for (FilterSpec filterConfig : filtersConfig) { Object filter = filterChainRepository.getFilter(ComponentSpecification.fromString(filterConfig.getId())); if (filter == null) { throw new RuntimeException("No http filter with id " + filterConfig.getId()); } addFilter(filter, filterConfig.getBinding()); } }
public DefaultSslProvider(String servername, String privateKeyPath, String certificatePath, String caCertificatePath, String clientAuthentication) { super(new ComponentModel( new BundleInstantiationSpecification(new ComponentId(COMPONENT_ID_PREFIX+servername), fromString(COMPONENT_CLASS), fromString(COMPONENT_BUNDLE)))); this.privateKeyPath = privateKeyPath; this.certificatePath = certificatePath; this.caCertificatePath = caCertificatePath; this.clientAuthentication = mapToConfigEnum(clientAuthentication); }
private static Renderer selectRenderer(com.yahoo.processing.Request processingRequest, ComponentRegistry<Renderer> renderers, Renderer defaultRenderer) { Renderer renderer = null; // TODO: Support setting a particular renderer instead of just selecting // by name? String rendererId = processingRequest.properties().getString("format"); if (rendererId != null && !"".equals(rendererId)) { renderer = renderers.getComponent(ComponentSpecification.fromString(rendererId)); if (renderer == null) processingRequest.errors().add(new ErrorMessage("Could not find renderer","Requested '" + rendererId + "', has " + renderers.allComponents())); } if (renderer == null) renderer = defaultRenderer; return renderer; }
public ConnectorFactory(String name, int listenPort, SimpleComponent sslProviderComponent) { super(new ComponentModel( new BundleInstantiationSpecification(new ComponentId(name), fromString("com.yahoo.jdisc.http.server.jetty.ConnectorFactory"), fromString("jdisc_http_service")))); this.name = name; this.listenPort = listenPort; this.sslProviderComponent = sslProviderComponent; addChild(sslProviderComponent); inject(sslProviderComponent); }
public AbstractProcessingHandler(ChainRegistry<COMPONENT> chainRegistry, ComponentRegistry<Renderer> renderers, Executor executor, AccessLog accessLog, Metric metric) { super(executor, accessLog, metric, true); renderingExecutor = executor; this.chainRegistry = chainRegistry; this.renderers = renderers; // Default is the one with id "default", or the ProcessingRenderer if there is no such renderer Renderer defaultRenderer = renderers.getComponent(ComponentSpecification.fromString(DEFAULT_RENDERER_ID)); if (defaultRenderer == null) { defaultRenderer = new ProcessingRenderer(); renderers.register(ComponentId.fromString(DEFAULT_RENDERER_ID), defaultRenderer); } this.defaultRenderer = defaultRenderer; }
public void addMbusServer(ComponentId chainId) { ComponentId serviceId = chainId.nestInNamespace(ComponentId.fromString("MbusServer")); addComponent( new Component<>(new ComponentModel(new BundleInstantiationSpecification( serviceId, ComponentSpecification.fromString(MbusServerProvider.class.getName()), null)))); }
@SuppressWarnings("unchecked") private HttpResponse errorResponse(HttpRequest request, ErrorMessage errorMessage) { Query query = new Query(); Result result = new Result(query, errorMessage); Renderer renderer = getRendererCopy(ComponentSpecification.fromString(request.getProperty("format"))); return new HttpSearchResponse(getHttpResponseStatus(request, result), result, query, renderer); }
@Override protected RestApiContext newInstance() { Object instance = super.newInstance(); RestApiContext restApiContext = (RestApiContext) instance; List<JerseyBundlesConfig.Bundles> bundles = restApiContext.bundlesConfig.bundles(); for (JerseyBundlesConfig.Bundles bundleConfig : bundles) { BundleClasses bundleClasses = osgi.getBundleClasses(ComponentSpecification.fromString(bundleConfig.spec()), new HashSet<>(bundleConfig.packages())); restApiContext.addBundle(createBundleInfo(bundleClasses.bundle(), bundleClasses.classEntries())); } componentsToInject.forEach(component -> restApiContext.addInjectableComponent(component.instanceKey(), component.componentId(), component.newOrCachedInstance())); return restApiContext; }