Class JsonStreamService
- java.lang.Object
-
- org.jboss.set.aphrodite.stream.services.json.JsonStreamService
-
- All Implemented Interfaces:
StreamService
public class JsonStreamService extends Object implements StreamService
A stream service which reads stream data from the specified JSON file. This implementation assumes that streams are written in order in the json file, i.e. the most recent (upstream) issue is specified as the first JSON object in the "streams" JSON array. An example JSON file can be found at https://github.com/jboss-set/jboss-streams- Author:
- Ryan Emerson, baranowb
-
-
Constructor Summary
Constructors Constructor Description JsonStreamService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jboss.set.aphrodite.domain.StreamComponentgetComponentBy(URI repositoryURL, org.jboss.set.aphrodite.domain.Codebase codebase)Get the StreamComponent which specifies the given repository and codebase.List<URI>getDistinctURLRepositories()Retrieve all Repositories across all Streams.List<URI>getDistinctURLRepositoriesByStream(String streamName)Retrieve the URLs of all Repositories associated with a given Stream.org.jboss.set.aphrodite.domain.StreamgetStream(String streamName)Get a specificStreamobject based upon its String name.List<org.jboss.set.aphrodite.domain.Stream>getStreams()Returns all streams discovered by this service.List<org.jboss.set.aphrodite.domain.Stream>getStreamsBy(URI repositoryURL, org.jboss.set.aphrodite.domain.Codebase codebase)Find all the streams associated to the given repository and codebasebooleaninit(Aphrodite aphrodite, AphroditeConfig config)Initialize the stream service.voidserializeStreams(URL url, OutputStream out)Serialize streams for certain URL.org.jboss.set.aphrodite.domain.StreamComponentupdateStreamComponent(org.jboss.set.aphrodite.domain.StreamComponent streamComponent)Updates stream component version in memory and in back end storage if possible.booleanupdateStreams()Trigger for updating streams information.
-
-
-
Method Detail
-
init
public boolean init(Aphrodite aphrodite, AphroditeConfig config) throws NotFoundException
Description copied from interface:StreamServiceInitialize the stream service.- Specified by:
initin interfaceStreamService- Throws:
NotFoundException
-
updateStreams
public boolean updateStreams() throws NotFoundExceptionDescription copied from interface:StreamServiceTrigger for updating streams information. Generally implementation if free to decide if updtes only on change on method being triggered or via other means(timed). Note, that internally, service is free to keep information up2date by any means is sees fit.- Specified by:
updateStreamsin interfaceStreamService- Returns:
- true - if streams information has been updated
- false - if streams information remain unchanged
- Throws:
NotFoundException
-
getStreams
public List<org.jboss.set.aphrodite.domain.Stream> getStreams()
Description copied from interface:StreamServiceReturns all streams discovered by this service.- Specified by:
getStreamsin interfaceStreamService- Returns:
- a list of all streams discovered by this
StreamService, or an empty list if no streams exist.
-
getStream
public org.jboss.set.aphrodite.domain.Stream getStream(String streamName)
Description copied from interface:StreamServiceGet a specificStreamobject based upon its String name.- Specified by:
getStreamin interfaceStreamService- Parameters:
streamName- the name of theStreamto be returned.- Returns:
- Stream the
Streamobject which corresponds to the specified streamName if it exists, otherwise null.
-
getDistinctURLRepositories
public List<URI> getDistinctURLRepositories()
Description copied from interface:StreamServiceRetrieve all Repositories across all Streams. Note, that only Repository objects with distinct URLs are returned. This method should never return the same repository twice.- Specified by:
getDistinctURLRepositoriesin interfaceStreamService- Returns:
- a list of unique Repositories.
-
getDistinctURLRepositoriesByStream
public List<URI> getDistinctURLRepositoriesByStream(String streamName)
Description copied from interface:StreamServiceRetrieve the URLs of all Repositories associated with a given Stream. Note, that only Repository objects with distinct URLs are returned. This method should never return the same repository twice.- Specified by:
getDistinctURLRepositoriesByStreamin interfaceStreamService- Parameters:
streamName- the name of theStreamcontaining the returned repositories.- Returns:
- a list of unique Repositories.
-
getStreamsBy
public List<org.jboss.set.aphrodite.domain.Stream> getStreamsBy(URI repositoryURL, org.jboss.set.aphrodite.domain.Codebase codebase)
Description copied from interface:StreamServiceFind all the streams associated to the given repository and codebase- Specified by:
getStreamsByin interfaceStreamService- Parameters:
repositoryURL- theRepositoryto search against.codebase- theCodebaseto search against.- Returns:
- a list of named
Streamobjects.
-
getComponentBy
public org.jboss.set.aphrodite.domain.StreamComponent getComponentBy(URI repositoryURL, org.jboss.set.aphrodite.domain.Codebase codebase)
Description copied from interface:StreamServiceGet the StreamComponent which specifies the given repository and codebase. Note, this returns the first matching component in the Stream data.- Specified by:
getComponentByin interfaceStreamService- Parameters:
repositoryURL- the Repository to be searched against.codebase- the codebase to be searched against.- Returns:
- the StreamComponent associated with the given repository and codebase, or null if a StreamComponent does not exist
-
updateStreamComponent
public org.jboss.set.aphrodite.domain.StreamComponent updateStreamComponent(org.jboss.set.aphrodite.domain.StreamComponent streamComponent) throws org.jboss.set.aphrodite.domain.StreamComponentUpdateExceptionDescription copied from interface:StreamServiceUpdates stream component version in memory and in back end storage if possible.- Specified by:
updateStreamComponentin interfaceStreamService- Parameters:
streamComponent- - component which should be updated- Returns:
- mutated object with new component version, after update.
- Throws:
org.jboss.set.aphrodite.domain.StreamComponentUpdateException- - in case there is some error on update.
-
serializeStreams
public void serializeStreams(URL url, OutputStream out) throws NotFoundException
Description copied from interface:StreamServiceSerialize streams for certain URL.- Specified by:
serializeStreamsin interfaceStreamService- Parameters:
url- - urlout- - sink for bytes- Throws:
NotFoundException- - if url does not match any set of streams
-
-