public interface ExternalReferenceSPI extends Cloneable
When used within the workflow engine implementations of this interface are always contained in a ReferenceSet instance.
Implementors of this interface are strongly advised to use the AbstractExternalReference superclass - this provides the necessary primary key information used by hibernate-based implementations of the reference manager. Technically we don't require it as it's possible that other backend stores may exist, but the core store used by T2 is based on hibernate so it's a very good idea to follow this! Basically if you don't your code won't work in the current system.
This interface is an SPI - while implementations are never constructed based on the SPI registry it is used to discover all implementing classes and automatically register their hibernate mapping files. Implementors should add their implementation class name to a META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI file in the implementation artifact. For examples please refer to the t2reference-core-extensions module, this contains implementations of this interface for common basic reference types.
Note - if your implementation class has a complex hibernate mapping that uses components which are themselves mapped into the database (perfectly legal to do) then you must mark those components as instances of HibernateMappedEntity so their corresponding mapping and class definitions are loaded by the Hibernate backed reference set dao. If your implementation class uses inline compound keys or other component types where you reference another class but the other class is not mapped itself in hibernate you must instead make the component class an instance of HibernateComponentClass - a marker interface - for the same reason. Both of these are SPIs themselves, and require the appropriate entries to be added to their service metadata files in your extension jar.
Modifier and Type | Method and Description |
---|---|
ExternalReferenceSPI |
clone() |
Long |
getApproximateSizeInBytes()
Approximate size of the stored data or -1 if we do not know.
|
String |
getCharset()
For textual data return the character set that should be used to pull
data into a java String object.
|
ReferencedDataNature |
getDataNature()
Determine, if possible, whether the data this reference refers to is
textual or binary in nature.
|
float |
getResolutionCost()
Resolution cost is an informal guide to how costly the process of
de-referencing this reference would be.
|
InputStream |
openStream(ReferenceContext context)
Open and return an InputStream to the data referenced using, if required,
any facilities within the supplied context.
|
ReferencedDataNature getDataNature()
String getCharset()
null
if binary or unknown type.InputStream openStream(ReferenceContext context) throws DereferenceException
context
- the ReferenceContext object used to obtain e.g. security
agents or other facilities required when de-referencing this
reference.DereferenceException
- if the reference cannot be de-referenced. This may be because
of problems with the context such as security failures, or it
may be because the reference is inherently not possible to
de-reference (as in the case of a non-serializable API
consumer reference).Long getApproximateSizeInBytes()
float getResolutionCost()
ExternalReferenceSPI clone() throws CloneNotSupportedException
CloneNotSupportedException
Copyright © 2015–2016 The Apache Software Foundation. All rights reserved.