Registering resources - ResourceRegistrationException [message #83443] |
Thu, 17 April 2008 06:16  |
Eclipse User |
|
|
|
Hi,
I'm trying to register a directory which I intend to write files to at
runtime, making them available to users via a URL. So far I've specified
the directory as a resource in my plugin.xml:
<extension
point="org.eclipse.equinox.http.registry.resources">
<resource
alias="/project-bin"
base-name="/project-bin">
</resource>
</extension>
And at runtime I've tried calling
RWT.getResourceManager().register("project-bin/testfile"); (testfile is
just a file I've placed there). I get the exception:
org.eclipse.rwt.internal.resources.ResourceRegistrationExcep tion: Failed
to register resource 'project-bin/test'.
Could anyone tell me what I've done wrong and also how to access this
directory in my Java code so I write to it?
Thanks,
Mike
|
|
|
|
Re: Registering resources - ResourceRegistrationException [message #83497 is a reply to message #83443] |
Thu, 17 April 2008 22:55   |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
just one thing I forgot. The resource directory you've mapped using the
resources extension point resides in your local project and - think
about deployment time on a linux-machine for example - therefore you
should not try to write to this directory at runtime.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Frank Appel
Bereitgestellt: Freitag, 18. April 2008 04:45
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Registering resources - ResourceRegistrationException
Betreff: Re: Registering resources - ResourceRegistrationException
Hi,
where exactly did you place the testfile? In your case the file is
expected on the classpath of the current context classloader of the
ResourceManager, so probably your file isn't found. The usage is s.th.
Like this:
ClassLoader loader = Activator.class.getClassLoader();
IResourceManager manager = ResourceManager.getInstance();
ClassLoader bufferedLoader = manager.getContextLoader();
manager.setContextLoader( loader );
try {
String path = "path/to/image.jpg";
manager.register( path, loader, getResourceAsStream( path );
} finally {
manager.setContextLoader( bufferedLoader );
}
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Mike Wrighton [mailto:mike.wrighton@googlemail.com]
Bereitgestellt: Donnerstag, 17. April 2008 12:16 Bereitgestellt in:
eclipse.technology.rap
Unterhaltung: Registering resources - ResourceRegistrationException
Betreff: Registering resources - ResourceRegistrationException
Hi,
I'm trying to register a directory which I intend to write files to at
runtime, making them available to users via a URL. So far I've specified
the directory as a resource in my plugin.xml:
<extension
point="org.eclipse.equinox.http.registry.resources">
<resource
alias="/project-bin"
base-name="/project-bin">
</resource>
</extension>
And at runtime I've tried calling
RWT.getResourceManager().register("project-bin/testfile"); (testfile is
just a file I've placed there). I get the exception:
org.eclipse.rwt.internal.resources.ResourceRegistrationExcep tion: Failed
to register resource 'project-bin/test'.
Could anyone tell me what I've done wrong and also how to access this
directory in my Java code so I write to it?
Thanks,
Mike
|
|
|
Re: Registering resources - ResourceRegistrationException [message #83553 is a reply to message #83497] |
Fri, 18 April 2008 06:02   |
Eclipse User |
|
|
|
Thanks, the registering code works but with regards to writing to
resource directories, that's what I'm trying to achieve - being able to
generate files at runtime so that my custom widgets can download them
via URLs. What would you suggest is the best way of doing this? Maybe
there's a much simpler approach?
Mike
Frank Appel wrote:
> Hi,
>
> just one thing I forgot. The resource directory you've mapped using the
> resources extension point resides in your local project and - think
> about deployment time on a linux-machine for example - therefore you
> should not try to write to this directory at runtime.
>
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Frank Appel
> Bereitgestellt: Freitag, 18. April 2008 04:45
> Bereitgestellt in: eclipse.technology.rap
> Unterhaltung: Registering resources - ResourceRegistrationException
> Betreff: Re: Registering resources - ResourceRegistrationException
>
>
> Hi,
>
> where exactly did you place the testfile? In your case the file is
> expected on the classpath of the current context classloader of the
> ResourceManager, so probably your file isn't found. The usage is s.th.
> Like this:
>
> ClassLoader loader = Activator.class.getClassLoader();
> IResourceManager manager = ResourceManager.getInstance();
> ClassLoader bufferedLoader = manager.getContextLoader();
> manager.setContextLoader( loader );
> try {
> String path = "path/to/image.jpg";
> manager.register( path, loader, getResourceAsStream( path );
> } finally {
> manager.setContextLoader( bufferedLoader );
> }
>
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Mike Wrighton [mailto:mike.wrighton@googlemail.com]
> Bereitgestellt: Donnerstag, 17. April 2008 12:16 Bereitgestellt in:
> eclipse.technology.rap
> Unterhaltung: Registering resources - ResourceRegistrationException
> Betreff: Registering resources - ResourceRegistrationException
>
>
> Hi,
>
> I'm trying to register a directory which I intend to write files to at
> runtime, making them available to users via a URL. So far I've specified
> the directory as a resource in my plugin.xml:
>
> <extension
> point="org.eclipse.equinox.http.registry.resources">
> <resource
> alias="/project-bin"
> base-name="/project-bin">
> </resource>
> </extension>
>
> And at runtime I've tried calling
> RWT.getResourceManager().register("project-bin/testfile"); (testfile is
> just a file I've placed there). I get the exception:
>
> org.eclipse.rwt.internal.resources.ResourceRegistrationExcep tion: Failed
> to register resource 'project-bin/test'.
>
> Could anyone tell me what I've done wrong and also how to access this
> directory in my Java code so I write to it?
>
> Thanks,
> Mike
>
>
|
|
|
Re: Registering resources - ResourceRegistrationException [message #83772 is a reply to message #83553] |
Mon, 21 April 2008 04:38  |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
there are several possibilities I guess and it depends on the exact case
and maybe your taste which one you use. I case that you generate files
at runtime you can use the ResourceManager approach I mentioned in a
previous post (sorry for the typo in the register paramenter list). This
approach register the files automatically to the download directory
root. Another way could be to use the bundle's statelocation to store
the files and use a servlet or a service-handler for delivery. It's not
easy from my point a view to propose the best way, since I don't know
much about your usecase, e.g. are those resources only relevant for one
user-session or are they shared for all users etc.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Mike Wrighton [mailto:mike.wrighton@googlemail.com]
Bereitgestellt: Freitag, 18. April 2008 12:02
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Registering resources - ResourceRegistrationException
Betreff: Re: Registering resources - ResourceRegistrationException
Thanks, the registering code works but with regards to writing to
resource directories, that's what I'm trying to achieve - being able to
generate files at runtime so that my custom widgets can download them
via URLs. What would you suggest is the best way of doing this? Maybe
there's a much simpler approach?
Mike
Frank Appel wrote:
> Hi,
>
> just one thing I forgot. The resource directory you've mapped using
> the resources extension point resides in your local project and -
> think about deployment time on a linux-machine for example - therefore
> you should not try to write to this directory at runtime.
>
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Frank Appel
> Bereitgestellt: Freitag, 18. April 2008 04:45 Bereitgestellt in:
> eclipse.technology.rap
> Unterhaltung: Registering resources - ResourceRegistrationException
> Betreff: Re: Registering resources - ResourceRegistrationException
>
>
> Hi,
>
> where exactly did you place the testfile? In your case the file is
> expected on the classpath of the current context classloader of the
> ResourceManager, so probably your file isn't found. The usage is s.th.
> Like this:
>
> ClassLoader loader = Activator.class.getClassLoader();
> IResourceManager manager = ResourceManager.getInstance();
> ClassLoader bufferedLoader = manager.getContextLoader();
> manager.setContextLoader( loader );
> try {
> String path = "path/to/image.jpg";
> manager.register( path, loader, getResourceAsStream( path );
> } finally {
> manager.setContextLoader( bufferedLoader );
> }
>
>
> Ciao
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Mike Wrighton [mailto:mike.wrighton@googlemail.com]
> Bereitgestellt: Donnerstag, 17. April 2008 12:16 Bereitgestellt in:
> eclipse.technology.rap
> Unterhaltung: Registering resources - ResourceRegistrationException
> Betreff: Registering resources - ResourceRegistrationException
>
>
> Hi,
>
> I'm trying to register a directory which I intend to write files to at
> runtime, making them available to users via a URL. So far I've
> specified the directory as a resource in my plugin.xml:
>
> <extension
> point="org.eclipse.equinox.http.registry.resources">
> <resource
> alias="/project-bin"
> base-name="/project-bin">
> </resource>
> </extension>
>
> And at runtime I've tried calling
> RWT.getResourceManager().register("project-bin/testfile"); (testfile
> is just a file I've placed there). I get the exception:
>
> org.eclipse.rwt.internal.resources.ResourceRegistrationExcep tion:
> Failed to register resource 'project-bin/test'.
>
> Could anyone tell me what I've done wrong and also how to access this
> directory in my Java code so I write to it?
>
> Thanks,
> Mike
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.05326 seconds