Files as Resources?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Files as Resources?

Carsten Haerle
Our applications needs various files, which we would like to include in the
package and version with STS, like icons, konfiguration files, stubs. Is it
possible to store these in packages. If not is it possible to store a binary
resource not only a view resource in a package? We could then write method
whiches saves the resource in a file at post load time.

Currently our workarround is to version files in methods, where generate a
method which saves the file contents in a bytearray in a method. When this
method is executed it saved the file back into current working directory.
This works ok, but the size of the files is very limited because the whole
file is also stored in the source code (the bytearray) which consumes 3-4
bytes source code per byte of the file.

I saw that the is an abstract class Resource which has ViewResource and
StringResource as subclasses. Is it possible to define a new subclass and
how could it be used? I also found, that StringResource as no reference in
the image. What is it used for?

Regards

Carsten Haerle


Reply | Threaded
Open this post in threaded view
|

Re: Files as Resources?

Chris Uppal-3
Carsten Haerle wrote:

> Our applications needs various files, which we would like to include in
> the package and version with STS, like icons, konfiguration files, stubs.
> Is it possible to store these in packages. If not is it possible to store
> a binary resource not only a view resource in a package? We could then
> write method whiches saves the resource in a file at post load time.

One thing you might try is have one or more LookupTables as a global variables
owned by one of your packages. The tables would map String names to String or
ByteArray objects representing your files.  The tables would get saved to disk
with your package's .PAC file (probably making it rather large ;-) and --
iirc -- STS supports saving globals that are part of packages too (but do check
before relying on it!).

> I saw that the is an abstract class Resource which has ViewResource and
> StringResource as subclasses. Is it possible to define a new subclass and
> how could it be used? I also found, that StringResource as no reference in
> the image. What is it used for?

My guess is that it's intended to allow a more disciplined way of doing what I
was suggesting above.  I've never tried it, though, so I don't know for sure
how it would work.

    -- chris