Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Server_Extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Server_Extension
Commits
b713eced
Commit
b713eced
authored
10 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
build and cache remote dataset XML in the constructor (split out into helper method)
parent
4a6b8ebc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/bdv/server/BigDataServer.java
+1
-1
1 addition, 1 deletion
src/main/java/bdv/server/BigDataServer.java
src/main/java/bdv/server/CellHandler.java
+31
-29
31 additions, 29 deletions
src/main/java/bdv/server/CellHandler.java
with
32 additions
and
30 deletions
src/main/java/bdv/server/BigDataServer.java
+
1
−
1
View file @
b713eced
...
...
@@ -264,7 +264,7 @@ public class BigDataServer
LOG
.
info
(
"Dataset added: {"
+
name
+
", "
+
xmlpath
+
"}"
);
}
private
static
ContextHandlerCollection
createHandlers
(
final
String
baseURL
,
final
Map
<
String
,
String
>
dataSet
)
throws
SpimDataException
private
static
ContextHandlerCollection
createHandlers
(
final
String
baseURL
,
final
Map
<
String
,
String
>
dataSet
)
throws
SpimDataException
,
IOException
{
final
ContextHandlerCollection
handlers
=
new
ContextHandlerCollection
();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/bdv/server/CellHandler.java
+
31
−
29
View file @
b713eced
package
bdv.server
;
import
bdv.BigDataViewer
;
import
bdv.img.cache.CacheHints
;
import
bdv.img.cache.LoadingStrategy
;
import
bdv.img.cache.VolatileCell
;
...
...
@@ -54,25 +55,34 @@ public class CellHandler extends ContextHandler
private
final
String
dataSetURL
;
// Cached XML string for provideXML()
private
String
remoteXmlString
=
null
;
/**
* Cached dataset XML to be send to and opened by {@link BigDataViewer}
* clients.
*/
private
final
String
datasetXmlString
;
/**
* Cached JSON representation of the {@link RemoteImageLoaderMetaData} to be
* send to clients.
*/
private
final
String
metadataJson
;
// Cached XML string for provideXML()
private
boolean
remoteSettingsChecked
=
false
;
private
String
remoteSettingsString
=
null
;
private
final
String
metadataJson
;
public
CellHandler
(
final
String
baseUrl
,
final
String
xmlFilename
)
throws
SpimDataException
public
CellHandler
(
final
String
baseUrl
,
final
String
xmlFilename
)
throws
SpimDataException
,
IOException
{
final
SpimDataMinimal
spimData
=
new
XmlIoSpimDataMinimal
().
load
(
xmlFilename
);
final
XmlIoSpimDataMinimal
io
=
new
XmlIoSpimDataMinimal
();
final
SpimDataMinimal
spimData
=
io
.
load
(
xmlFilename
);
final
SequenceDescriptionMinimal
seq
=
spimData
.
getSequenceDescription
();
final
Hdf5ImageLoader
imgLoader
=
(
Hdf5ImageLoader
)
seq
.
getImgLoader
();
cache
=
imgLoader
.
getCache
();
cacheHints
=
new
CacheHints
(
LoadingStrategy
.
BLOCKING
,
0
,
false
);
datasetXmlString
=
buildRemoteDatasetXML
(
io
,
spimData
,
baseUrl
);
metadataJson
=
buildMetadataJsonString
(
imgLoader
,
seq
);
// dataSetURL property is used for providing the XML file by replace
...
...
@@ -156,35 +166,13 @@ public class CellHandler extends ContextHandler
public
void
provideXML
(
final
Request
baseRequest
,
final
HttpServletResponse
response
)
throws
IOException
,
ServletException
{
if
(
null
==
remoteXmlString
)
{
try
{
final
XmlIoSpimDataMinimal
io
=
new
XmlIoSpimDataMinimal
();
final
SpimDataMinimal
spimData
=
io
.
load
(
xmlFilename
);
final
SequenceDescriptionMinimal
seq
=
spimData
.
getSequenceDescription
();
seq
.
setImgLoader
(
new
RemoteImageLoader
(
dataSetURL
)
);
final
Document
doc
=
new
Document
(
io
.
toXml
(
spimData
,
spimData
.
getBasePath
()
)
);
final
XMLOutputter
xout
=
new
XMLOutputter
(
Format
.
getPrettyFormat
()
);
final
StringWriter
sw
=
new
StringWriter
();
xout
.
output
(
doc
,
sw
);
remoteXmlString
=
sw
.
toString
();
}
catch
(
final
SpimDataException
e
)
{
throw
new
ServletException
(
e
);
}
}
response
.
setContentType
(
"application/xml"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
PrintWriter
ow
=
response
.
getWriter
();
ow
.
write
(
remote
XmlString
);
ow
.
write
(
dataset
XmlString
);
ow
.
close
();
}
...
...
@@ -334,4 +322,18 @@ public class CellHandler extends ContextHandler
gsonBuilder
.
enableComplexMapKeySerialization
();
return
gsonBuilder
.
create
().
toJson
(
metadata
);
}
/**
* Create a modified dataset XML by replacing the ImageLoader with an
* {@link RemoteImageLoader} pointing to the data we are serving.
*/
private
static
String
buildRemoteDatasetXML
(
final
XmlIoSpimDataMinimal
io
,
final
SpimDataMinimal
spimData
,
final
String
baseUrl
)
throws
IOException
,
SpimDataException
{
final
SpimDataMinimal
s
=
new
SpimDataMinimal
(
spimData
,
new
RemoteImageLoader
(
baseUrl
,
false
)
);
final
Document
doc
=
new
Document
(
io
.
toXml
(
s
,
s
.
getBasePath
()
)
);
final
XMLOutputter
xout
=
new
XMLOutputter
(
Format
.
getPrettyFormat
()
);
final
StringWriter
sw
=
new
StringWriter
();
xout
.
output
(
doc
,
sw
);
return
sw
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment