public class OembedService extends Object
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
OembedService(org.apache.http.client.HttpClient httpClient,
net.sf.ehcache.CacheManager cacheManager,
List<OembedEndpoint> endpoints,
String applicationName)
Creates a new
OembedService. |
| Modifier and Type | Method and Description |
|---|---|
org.jsoup.nodes.Document |
embedUrls(org.jsoup.nodes.Document document)
A convenience method to embed urls in an existing document.
|
String |
embedUrls(String textWithEmbeddableUrls,
Optional<String> baseUrl) |
<T> T |
embedUrls(String textWithEmbeddableUrls,
Optional<String> baseUrl,
Class<? extends T> targetClass)
Scans the text
textWithEmbeddableUrls for anchor tags and tries
to find OembedEndpoint for those urls. |
String |
getCacheName() |
long |
getDefaultCacheAge() |
Optional<OembedResponse> |
getOembedResponseFor(String url)
Tries to find an
OembedResponse for the URL url. |
OembedParser |
getParser(OembedResponse.Format format)
Returns an instance of an
OembedParser for the given
OembedResponse.Format. |
boolean |
isAutodiscovery() |
void |
setAutodiscovery(boolean autodiscovery)
Updates to configuration of oembed autodiscovery.
|
void |
setCacheName(String cacheName)
Changes the name of the cache used.
|
void |
setDefaultCacheAge(long defaultCacheAge)
Changes the default cache age.
|
public OembedService(org.apache.http.client.HttpClient httpClient,
net.sf.ehcache.CacheManager cacheManager,
List<OembedEndpoint> endpoints,
String applicationName)
OembedService. This service depends on a
HttpClient and can use a CacheManager for caching
requests.httpClient - Mandatory http clientcacheManager - Optional cache managerendpoints - The static endpointsapplicationName - Optional application namepublic boolean isAutodiscovery()
public void setAutodiscovery(boolean autodiscovery)
autodiscovery - New flag wether oembed endpoints should be
autodiscoveredpublic String getCacheName()
public void setCacheName(String cacheName)
cacheName - The new cache namepublic long getDefaultCacheAge()
public void setDefaultCacheAge(long defaultCacheAge)
defaultCacheAge - New default cache age in secondspublic Optional<OembedResponse> getOembedResponseFor(String url)
OembedResponse for the URL url. If a
cache manager is present, it tries that first. If an
OembedResponse can be discovered and a cache manager is present,
that response will be cached.url - The URL that might be represented by oembed.public String embedUrls(String textWithEmbeddableUrls, Optional<String> baseUrl)
textWithEmbeddableUrls - Text that may contain linksbaseUrl - Base url for constructing absolute linksembedUrls(java.lang.String, java.util.Optional, java.lang.Class)public <T> T embedUrls(String textWithEmbeddableUrls, Optional<String> baseUrl, Class<? extends T> targetClass)
textWithEmbeddableUrls for anchor tags and tries
to find OembedEndpoint for those urls. If such an endpoint
exists, it tries to get an OembedResponse of that url from the
endpoint. This response will then be rendered as html and is used to
replace the anchor tag.T - Type of the resulting document with embedded linkstextWithEmbeddableUrls - Text that contains embeddable urlsbaseUrl - An optional base url for resolving relative urlstargetClass - The concrete classe for the document nodepublic org.jsoup.nodes.Document embedUrls(org.jsoup.nodes.Document document)
document - Existing document, will be modifiedembedUrls(java.lang.String, java.util.Optional, java.lang.Class)public OembedParser getParser(OembedResponse.Format format)
OembedParser for the given
OembedResponse.Format.format - The format for which a parser is neededCopyright © 2010–2016 michael-simons.eu. All rights reserved.