- DataInput dis = new DataInputStream(is);
- // or
- // dis = new InputStreamReadable(is, <max limit>) to protect from OOM
-
- org.simantics.databoard.container.DataContainer container =
- DataContainers.readFile(dis);
-
- Binding binding = TransferableGraph1.BINDING;
- TransferableGraph1 graph = (TransferableGraph1)container.content.getValue(binding);
-// TransferableGraph1 graph = (TransferableGraph1) Files.readFile(is, binding);
-// System.out.println("getGraph(" + bundle.getSymbolicName() + "): read transferable graph in " + (System.nanoTime()-start)*1e-6 + "ms");
- org.osgi.framework.Version osgiVersion = bundle.getVersion();
- Version p2Version = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro(), osgiVersion.getQualifier());
- String id = bundle.getSymbolicName();
- VersionedId vid = new VersionedId(id, p2Version);
- String name = (String) bundle.getHeaders().get("Bundle-Name");
- if (name == null) name = id;
- String immutable = (String) bundle.getHeaders().get("Immutable");
- boolean isImmutable =
- immutable != null ?
- "true".equals(immutable) :
- true;
-
-// System.out.println("getGraph(" + bundle.getSymbolicName() + "): before hashcode calculation in " + (System.nanoTime()-start)*1e-6 + "ms");
- GraphBundleEx entry = new GraphBundleEx(name, graph, vid, isImmutable);
-// System.out.println("getGraph(" + bundle.getSymbolicName() + "): completed in " + (System.nanoTime()-start)*1e-6 + "ms");
- return entry;
- } catch (SerializationException e) {
- throw new IOException(e);
- } catch (IOException e) {
- throw new IOException("Problem loading graph.tg from bundle " + bundle.getSymbolicName(), e);
- } catch (RuntimeException e) {
+ String id = tgFileId(bundle, url);
+ return new GraphBundleEx(
+ getBundleName(bundle, id),
+ readTG(url),
+ new VersionedId(id, toP2Version(bundle)),
+ isImmutable(bundle));
+ } catch (Exception e) {