-
- All Implemented Interfaces:
-
ai.platon.pulsar.PulsarSession,java.lang.AutoCloseable
public abstract class AbstractPulsarSession implements PulsarSession
Created by vincent on 18-1-17. Copyright @ 2013-2017 Platon AI. All rights reserved
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAbstractPulsarSession.Companion
-
Field Summary
Fields Modifier and Type Field Description private final ImmutableConfigunmodifiedConfigprivate final BeanFactorysessionBeanFactoryprivate final Stringdisplayprivate final BooleanisActiveprivate final GlobalCacheFactoryglobalCacheFactoryprivate final ConcurrentExpiringLRUCache<String, WebPage>pageCacheprivate final ConcurrentExpiringLRUCache<String, FeaturedDocument>documentCacheprivate final AbstractPulsarContextcontextprivate final VolatileConfigsessionConfigprivate final Integerid
-
Constructor Summary
Constructors Constructor Description AbstractPulsarSession(AbstractPulsarContext context, VolatileConfig sessionConfig, Integer id)
-
Method Summary
Modifier and Type Method Description ImmutableConfiggetUnmodifiedConfig()BeanFactorygetSessionBeanFactory()The scoped bean factory: for each volatileConfig object, there is a bean factory TODO: session scoped? StringgetDisplay()final BooleangetIsActive()GlobalCacheFactorygetGlobalCacheFactory()ConcurrentExpiringLRUCache<String, WebPage>getPageCache()ConcurrentExpiringLRUCache<String, FeaturedDocument>getDocumentCache()AbstractPulsarContextgetContext()The pulsar context VolatileConfiggetSessionConfig()The session scope volatile config, every setting is supposed to be changed at any time and any place IntegergetId()The session id. BooleanregisterClosable(AutoCloseable closable)Close objects when sessions closes UnitdisableCache()LoadOptionsoptions(String args)Create a new options, with a new volatile config NormUrlnormalize(String url, LoadOptions options, Boolean toItemOption)List<NormUrl>normalize(Iterable<String> urls, LoadOptions options, Boolean toItemOption)NormUrlnormalize(UrlAware url, LoadOptions options, Boolean toItemOption)List<NormUrl>normalize(Collection<UrlAware> urls, LoadOptions options, Boolean toItemOption)NormUrlnormalizeOrNull(String url, LoadOptions options, Boolean toItemOption)NormUrlnormalizeOrNull(UrlAware url, LoadOptions options, Boolean toItemOption)WebPageinject(String url)Inject a url WebPageget(String url)WebPagegetOrNull(String url)Booleanexists(String url)CheckStatefetchState(WebPage page, LoadOptions options)WebPageload(String url, String args)Load a url with specified options WebPageload(String url, LoadOptions options)Load a url with specified options WebPageload(UrlAware url, String args)WebPageload(UrlAware url, LoadOptions options)WebPageload(NormUrl normUrl)WebPageloadDeferred(String url, LoadOptions options)WebPageloadDeferred(UrlAware url, String args)WebPageloadDeferred(UrlAware url, LoadOptions options)WebPageloadDeferred(NormUrl normUrl)Collection<WebPage>loadAll(Iterable<String> urls, LoadOptions options, Boolean areItems)Load all urls with specified options, this may cause a parallel fetching if required Collection<WebPage>loadOutPages(String portalUrl, String args)Load all out pages in a portal page Collection<WebPage>loadOutPages(String portalUrl, LoadOptions options)Load all out pages in a portal page FeaturedDocumentparse(WebPage page, Boolean noCache)Parse the Web page into DOM. FeaturedDocumentloadDocument(String url, String args)FeaturedDocumentloadDocument(String url, LoadOptions options)FeaturedDocumentloadDocument(NormUrl normUrl)Map<String, String>scrape(String url, String args, Iterable<String> fieldCss)Map<String, String>scrape(String url, String args, Map<String, String> fieldCss)List<Map<String, String>>scrape(String url, String args, String restrictCss, Iterable<String> fieldCss)List<Map<String, String>>scrape(String url, String args, String restrictCss, Map<String, String> fieldCss)List<Map<String, String>>scrapeOutPages(String portalUrl, String args, Iterable<String> fieldsCss)List<Map<String, String>>scrapeOutPages(String portalUrl, String args, String restrictCss, Iterable<String> fieldsCss)List<Map<String, String>>scrapeOutPages(String portalUrl, String args, Map<String, String> fieldsCss)List<Map<String, String>>scrapeOutPages(String portalUrl, String args, String restrictCss, Map<String, String> fieldsCss)ObjectgetVariable(String name)UnitsetVariable(String name, Object value)UnitputSessionBean(Object obj)final <T extends Any> TgetSessionBean()Unitdelete(String url)Unitflush()Booleanpersist(WebPage page)Pathexport(WebPage page, String ident)Pathexport(FeaturedDocument doc, String ident)PathexportTo(FeaturedDocument doc, Path path)Booleanequals(Object other)IntegerhashCode()StringtoString()Unitclose()-
-
Constructor Detail
-
AbstractPulsarSession
AbstractPulsarSession(AbstractPulsarContext context, VolatileConfig sessionConfig, Integer id)
-
-
Method Detail
-
getUnmodifiedConfig
ImmutableConfig getUnmodifiedConfig()
-
getSessionBeanFactory
BeanFactory getSessionBeanFactory()
The scoped bean factory: for each volatileConfig object, there is a bean factory TODO: session scoped?
-
getDisplay
String getDisplay()
-
getIsActive
final Boolean getIsActive()
-
getGlobalCacheFactory
GlobalCacheFactory getGlobalCacheFactory()
-
getPageCache
ConcurrentExpiringLRUCache<String, WebPage> getPageCache()
-
getDocumentCache
ConcurrentExpiringLRUCache<String, FeaturedDocument> getDocumentCache()
-
getContext
AbstractPulsarContext getContext()
The pulsar context
-
getSessionConfig
VolatileConfig getSessionConfig()
The session scope volatile config, every setting is supposed to be changed at any time and any place
-
getId
Integer getId()
The session id. Session id is expected to be set by the container, e.g. the h2 database runtime
-
registerClosable
Boolean registerClosable(AutoCloseable closable)
Close objects when sessions closes
-
disableCache
Unit disableCache()
-
options
LoadOptions options(String args)
Create a new options, with a new volatile config
-
normalize
NormUrl normalize(String url, LoadOptions options, Boolean toItemOption)
-
normalize
NormUrl normalize(UrlAware url, LoadOptions options, Boolean toItemOption)
-
normalize
List<NormUrl> normalize(Collection<UrlAware> urls, LoadOptions options, Boolean toItemOption)
-
normalizeOrNull
NormUrl normalizeOrNull(String url, LoadOptions options, Boolean toItemOption)
-
normalizeOrNull
NormUrl normalizeOrNull(UrlAware url, LoadOptions options, Boolean toItemOption)
-
fetchState
CheckState fetchState(WebPage page, LoadOptions options)
-
load
WebPage load(String url, String args)
Load a url with specified options
- Parameters:
url- The url to loadargs- The load args
-
load
WebPage load(String url, LoadOptions options)
Load a url with specified options
- Parameters:
url- The url to loadoptions- The load options
-
load
WebPage load(UrlAware url, LoadOptions options)
-
loadDeferred
WebPage loadDeferred(String url, LoadOptions options)
-
loadDeferred
WebPage loadDeferred(UrlAware url, String args)
-
loadDeferred
WebPage loadDeferred(UrlAware url, LoadOptions options)
-
loadDeferred
WebPage loadDeferred(NormUrl normUrl)
-
loadAll
Collection<WebPage> loadAll(Iterable<String> urls, LoadOptions options, Boolean areItems)
Load all urls with specified options, this may cause a parallel fetching if required
- Parameters:
urls- The urls to loadoptions- The load options for all urls
-
loadOutPages
Collection<WebPage> loadOutPages(String portalUrl, String args)
Load all out pages in a portal page
- Parameters:
portalUrl- The portal url from where to load pagesargs- The load args
-
loadOutPages
Collection<WebPage> loadOutPages(String portalUrl, LoadOptions options)
Load all out pages in a portal page
- Parameters:
portalUrl- The portal url from where to load pagesoptions- The load options
-
parse
FeaturedDocument parse(WebPage page, Boolean noCache)
Parse the Web page into DOM. If the Web page is not changed since last parse, use the last result if available
-
loadDocument
FeaturedDocument loadDocument(String url, String args)
-
loadDocument
FeaturedDocument loadDocument(String url, LoadOptions options)
-
loadDocument
FeaturedDocument loadDocument(NormUrl normUrl)
-
scrape
List<Map<String, String>> scrape(String url, String args, String restrictCss, Iterable<String> fieldCss)
-
scrape
List<Map<String, String>> scrape(String url, String args, String restrictCss, Map<String, String> fieldCss)
-
scrapeOutPages
List<Map<String, String>> scrapeOutPages(String portalUrl, String args, Iterable<String> fieldsCss)
-
scrapeOutPages
List<Map<String, String>> scrapeOutPages(String portalUrl, String args, String restrictCss, Iterable<String> fieldsCss)
-
scrapeOutPages
List<Map<String, String>> scrapeOutPages(String portalUrl, String args, Map<String, String> fieldsCss)
-
scrapeOutPages
List<Map<String, String>> scrapeOutPages(String portalUrl, String args, String restrictCss, Map<String, String> fieldsCss)
-
getVariable
Object getVariable(String name)
-
setVariable
Unit setVariable(String name, Object value)
-
putSessionBean
Unit putSessionBean(Object obj)
-
getSessionBean
final <T extends Any> T getSessionBean()
-
-
-
-