You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Baptiste Gaillard <b_...@hotmail.com> on 2009/10/02 10:48:19 UTC

OSGI bootdelegation and java.io.File ?

Hi, we are building a platform which allow to deploy and execute OSGI components. 

Those OSGI components are developed by our customers and we do not have control one those components.
The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.

We have encounter problems when OSGI components do things like that in their code: 

  File file = new File("relative_path/myfile.txt"); 

This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt. 
This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader. 

So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ? 

Thanks, 


Baptiste



 		 	   		  
_________________________________________________________________
Découvrez toutes les possibilités de communication avec vos proches
http://www.microsoft.com/windows/windowslive/default.aspx

Re: OSGI bootdelegation and java.io.File ?

Posted by Karl Pauls <ka...@gmail.com>.
On Fri, Oct 2, 2009 at 11:52 AM, Baptiste Gaillard
<b_...@hotmail.com> wrote:
>
> I thought the problem could also be solve with AspectJ (I do not know very well that).
>
> Perhaps we can know where the calls to java.ui.File() are done, if it is in a component of our platform we can try to execute an advice (wired on the File constructor) which retrieve the relative path and change it to an absolute one using BundleContext.getDataFile(String)
>
> But I don't know how to do that, perhaps it's not possible...

Yeah, you should be able to get that to work but it will not be super easy...

regards,

Karl

>
>> Date: Fri, 2 Oct 2009 11:40:05 +0200
>> From: fmeschbe@gmail.com
>> To: users@felix.apache.org
>> Subject: Re: OSGI bootdelegation and java.io.File ?
>>
>> Hi,
>>
>> Besides that probably not working at all, here my €0.02 to your idea:
>>
>>   * Bundle.getBundleLocation() returns an URL string and not a File.
>>   * I would assume that your clients should know what they do when
>>     creating relative files - creating files realtive to the
>>     path set in the "user.dir" system property.
>>   * If your clients want to write files in their private bundle
>>     area they should use the BundleContext.getDataFile(String) method.
>>
>>
>> Regards
>> Felix
>>
>> Baptiste Gaillard schrieb:
>> > The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers.
>> >
>> > We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise.
>> >
>> > What I wanted to do with:
>> >  new File("relative_path")
>> >
>> > is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File().
>> >
>> > Something like :
>> >
>> > /**
>> >  * Our version of java.io.File
>> >  */
>> > class File {
>> >
>> >     public File(String relativePath)
>> >     {
>> >           this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
>> >           this.prefixLength = fs.prefixLength(this.path);
>> >     }
>> >
>> > }
>> >
>> > /**
>> >  * SUN version of java.io.File
>> >  */
>> > class File {
>> >
>> >
>> >
>> >     public File(String pathname)
>> >
>> >     {
>> >
>> >           this.path = fs.normalize(pathname);
>> >
>> >           this.prefixLength = fs.prefixLength(this.path);
>> >
>> >     }
>> >
>> >
>> >
>> > }
>>
>> >
>> > Do you think something like that is feasible ?
>> >
>> >
>> >
>> >
>> >> Date: Fri, 2 Oct 2009 10:51:21 +0200
>> >> Subject: Re: OSGI bootdelegation and java.io.File ?
>> >> From: karlpauls@gmail.com
>> >> To: users@felix.apache.org
>> >>
>> >> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
>> >> <b_...@hotmail.com> wrote:
>> >>> Hi, we are building a platform which allow to deploy and execute OSGI components.
>> >>>
>> >>> Those OSGI components are developed by our customers and we do not have control one those components.
>> >>> The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
>> >>>
>> >>> We have encounter problems when OSGI components do things like that in their code:
>> >>>
>> >>>  File file = new File("relative_path/myfile.txt");
>> >>>
>> >>> This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
>> >>> This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
>> >>>
>> >>> So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
>> >>> Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
>> >> No. That is not possible. However, I'm not sure I really understand
>> >> what it is you are trying to do. Can you tell us more about that -
>> >> maybe there is a different solution to your problem...
>> >>
>> >> regards,
>> >>
>> >> Karl
>> >>
>> >>> Thanks,
>> >>>
>> >>>
>> >>> Baptiste
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> _________________________________________________________________
>> >>> Découvrez toutes les possibilités de communication avec vos proches
>> >>> http://www.microsoft.com/windows/windowslive/default.aspx
>> >>
>> >>
>> >> --
>> >> Karl Pauls
>> >> karlpauls@gmail.com
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> >> For additional commands, e-mail: users-help@felix.apache.org
>> >>
>> >
>> > _________________________________________________________________
>> > Découvrez toutes les possibilités de communication avec vos proches
>> > http://www.microsoft.com/windows/windowslive/default.aspx
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> _________________________________________________________________
> Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger !
> http://www.ilovemessenger.fr/Emoticones/EmoticonesDejantees.aspx



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: OSGI bootdelegation and java.io.File ?

Posted by Baptiste Gaillard <b_...@hotmail.com>.
I thought the problem could also be solve with AspectJ (I do not know very well that). 

Perhaps we can know where the calls to java.ui.File() are done, if it is in a component of our platform we can try to execute an advice (wired on the File constructor) which retrieve the relative path and change it to an absolute one using BundleContext.getDataFile(String)

But I don't know how to do that, perhaps it's not possible...


> Date: Fri, 2 Oct 2009 11:40:05 +0200
> From: fmeschbe@gmail.com
> To: users@felix.apache.org
> Subject: Re: OSGI bootdelegation and java.io.File ?
> 
> Hi,
> 
> Besides that probably not working at all, here my €0.02 to your idea:
> 
>   * Bundle.getBundleLocation() returns an URL string and not a File.
>   * I would assume that your clients should know what they do when
>     creating relative files - creating files realtive to the
>     path set in the "user.dir" system property.
>   * If your clients want to write files in their private bundle
>     area they should use the BundleContext.getDataFile(String) method.
> 
> 
> Regards
> Felix
> 
> Baptiste Gaillard schrieb:
> > The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers. 
> > 
> > We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise. 
> > 
> > What I wanted to do with: 
> >  new File("relative_path") 
> > 
> > is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File(). 
> > 
> > Something like : 
> > 
> > /**
> >  * Our version of java.io.File
> >  */
> > class File {
> > 
> >     public File(String relativePath) 
> >     {
> >           this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
> >           this.prefixLength = fs.prefixLength(this.path);
> >     }
> > 
> > }
> > 
> > /**
> >  * SUN version of java.io.File
> >  */
> > class File {
> > 
> > 
> > 
> >     public File(String pathname) 
> > 
> >     {
> > 
> >           this.path = fs.normalize(pathname);
> > 
> >           this.prefixLength = fs.prefixLength(this.path);
> > 
> >     }
> > 
> > 
> > 
> > }
> 
> > 
> > Do you think something like that is feasible ?
> > 
> > 
> > 
> > 
> >> Date: Fri, 2 Oct 2009 10:51:21 +0200
> >> Subject: Re: OSGI bootdelegation and java.io.File ?
> >> From: karlpauls@gmail.com
> >> To: users@felix.apache.org
> >>
> >> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
> >> <b_...@hotmail.com> wrote:
> >>> Hi, we are building a platform which allow to deploy and execute OSGI components.
> >>>
> >>> Those OSGI components are developed by our customers and we do not have control one those components.
> >>> The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
> >>>
> >>> We have encounter problems when OSGI components do things like that in their code:
> >>>
> >>>  File file = new File("relative_path/myfile.txt");
> >>>
> >>> This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
> >>> This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
> >>>
> >>> So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
> >>> Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
> >> No. That is not possible. However, I'm not sure I really understand
> >> what it is you are trying to do. Can you tell us more about that -
> >> maybe there is a different solution to your problem...
> >>
> >> regards,
> >>
> >> Karl
> >>
> >>> Thanks,
> >>>
> >>>
> >>> Baptiste
> >>>
> >>>
> >>>
> >>>
> >>> _________________________________________________________________
> >>> Découvrez toutes les possibilités de communication avec vos proches
> >>> http://www.microsoft.com/windows/windowslive/default.aspx
> >>
> >>
> >> -- 
> >> Karl Pauls
> >> karlpauls@gmail.com
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >> For additional commands, e-mail: users-help@felix.apache.org
> >>
> >  		 	   		  
> > _________________________________________________________________
> > Découvrez toutes les possibilités de communication avec vos proches
> > http://www.microsoft.com/windows/windowslive/default.aspx
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
 		 	   		  
_________________________________________________________________
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger !
http://www.ilovemessenger.fr/Emoticones/EmoticonesDejantees.aspx

Re: OSGI bootdelegation and java.io.File ?

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Besides that probably not working at all, here my €0.02 to your idea:

  * Bundle.getBundleLocation() returns an URL string and not a File.
  * I would assume that your clients should know what they do when
    creating relative files - creating files realtive to the
    path set in the "user.dir" system property.
  * If your clients want to write files in their private bundle
    area they should use the BundleContext.getDataFile(String) method.


Regards
Felix

Baptiste Gaillard schrieb:
> The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers. 
> 
> We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise. 
> 
> What I wanted to do with: 
>  new File("relative_path") 
> 
> is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File(). 
> 
> Something like : 
> 
> /**
>  * Our version of java.io.File
>  */
> class File {
> 
>     public File(String relativePath) 
>     {
>           this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
>           this.prefixLength = fs.prefixLength(this.path);
>     }
> 
> }
> 
> /**
>  * SUN version of java.io.File
>  */
> class File {
> 
> 
> 
>     public File(String pathname) 
> 
>     {
> 
>           this.path = fs.normalize(pathname);
> 
>           this.prefixLength = fs.prefixLength(this.path);
> 
>     }
> 
> 
> 
> }

> 
> Do you think something like that is feasible ?
> 
> 
> 
> 
>> Date: Fri, 2 Oct 2009 10:51:21 +0200
>> Subject: Re: OSGI bootdelegation and java.io.File ?
>> From: karlpauls@gmail.com
>> To: users@felix.apache.org
>>
>> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
>> <b_...@hotmail.com> wrote:
>>> Hi, we are building a platform which allow to deploy and execute OSGI components.
>>>
>>> Those OSGI components are developed by our customers and we do not have control one those components.
>>> The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
>>>
>>> We have encounter problems when OSGI components do things like that in their code:
>>>
>>>  File file = new File("relative_path/myfile.txt");
>>>
>>> This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
>>> This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
>>>
>>> So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
>>> Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
>> No. That is not possible. However, I'm not sure I really understand
>> what it is you are trying to do. Can you tell us more about that -
>> maybe there is a different solution to your problem...
>>
>> regards,
>>
>> Karl
>>
>>> Thanks,
>>>
>>>
>>> Baptiste
>>>
>>>
>>>
>>>
>>> _________________________________________________________________
>>> Découvrez toutes les possibilités de communication avec vos proches
>>> http://www.microsoft.com/windows/windowslive/default.aspx
>>
>>
>> -- 
>> Karl Pauls
>> karlpauls@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>  		 	   		  
> _________________________________________________________________
> Découvrez toutes les possibilités de communication avec vos proches
> http://www.microsoft.com/windows/windowslive/default.aspx


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: OSGI bootdelegation and java.io.File ?

Posted by Stuart McCulloch <mc...@gmail.com>.
2009/10/2 Baptiste Gaillard <b_...@hotmail.com>

>
> Hum, yes using BundleContext.getDataFile() would be a good idea, but in our
> case we can't do that.
>
> I explain me a little more...
>
> In fact our customers are developping components using a framework called
> UIMA (http://incubator.apache.org/uima/).
> To deploy the components on our platform, control the Class
> Loading/UnLoading/etc. we have added an OSGI layer.
> Now, the components are OSGI wrappers around UIMA components.
> Unfortunately in UIMA components we do not have access to
> BundleContext.getDataFile() :-(
>
> > Replace File via the boot class path, as Karl mentions, is do-able, but
> > I am not sure if it is a good idea.
>
> I agree, this should work well to solve the 'new File(relativePath)'
> problem.
> But as the application is deployed in JBoss AS there will be lot of other
> problems... Jboss will not be able to find his files...
> Perhaps it's feasible via the boot class path but the 'java.io.File' class
> to developp will be very compilcated.
>

If possible I would try to move clients to use some sort of URL /
inputstream approach
rather than raw Files, because then it would be very easy to map requests
onto either
the file-system or the bundle storage. You can also use resource
abstractions like the
ones provided by the Spring framework

Another benefit is that it should be much easier to move your components
onto the cloud,
where you don't always have access to the raw file-system. The File API is
good for quick
prototyping, but these days I mostly try to abstract it beneath a general
resource API.

-- 
Cheers, Stuart

Thanks,
>
> Baptiste
>
> > Date: Fri, 2 Oct 2009 11:34:13 +0200
> > From: heavy@ungoverned.org
> > To: users@felix.apache.org
> > Subject: Re: OSGI bootdelegation and java.io.File ?
> >
> > You certainly need to tell your customers to use
> > BundleContext.getDataFile() instead of creating file objects directly.
> >
> > Replace File via the boot class path, as Karl mentions, is do-able, but
> > I am not sure if it is a good idea.
> >
> > -> richard
> >
> > On 10/2/09 11:23, Karl Pauls wrote:
> > > Well, in this case I guess you will have to have your customers
> > > special case for OSGi I guess as their is no way (that I know) to
> > > replace java.io.File (unless you override it with our own version
> > > using the -Xbootclasspath/p option of the jvm).
> > >
> > > regards,
> > >
> > > Karl
> > >
> > > On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
> > > <b_...@hotmail.com>  wrote:
> > >
> > >> The main problem is that we do not have control on the OSGI components
> deployed on our application because they are developped by our customers.
> > >>
> > >> We can write a guide and explain what to do and not to do with OSGI,
> but we hoped to solve the majority of problems otherwise.
> > >>
> > >> What I wanted to do with:
> > >>   new File("relative_path")
> > >>
> > >> is to change the way relative paths are built by replacing
> java.io.File() with our version of java.io.File().
> > >>
> > >> Something like :
> > >>
> > >> /**
> > >>   * Our version of java.io.File
> > >>   */
> > >> class File {
> > >>
> > >>     public File(String relativePath)
> > >>     {
> > >>           this.path =
> fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath()
> + '/' + relativePath);
> > >>           this.prefixLength = fs.prefixLength(this.path);
> > >>     }
> > >>
> > >> }
> > >>
> > >> /**
> > >>   * SUN version of java.io.File
> > >>   */
> > >> class File {
> > >>
> > >>
> > >>
> > >>     public File(String pathname)
> > >>
> > >>     {
> > >>
> > >>           this.path = fs.normalize(pathname);
> > >>
> > >>           this.prefixLength = fs.prefixLength(this.path);
> > >>
> > >>     }
> > >>
> > >>
> > >>
> > >> }
> > >>
> > >> Do you think something like that is feasible ?
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>> Date: Fri, 2 Oct 2009 10:51:21 +0200
> > >>> Subject: Re: OSGI bootdelegation and java.io.File ?
> > >>> From: karlpauls@gmail.com
> > >>> To: users@felix.apache.org
> > >>>
> > >>> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
> > >>> <b_...@hotmail.com>  wrote:
> > >>>
> > >>>> Hi, we are building a platform which allow to deploy and execute
> OSGI components.
> > >>>>
> > >>>> Those OSGI components are developed by our customers and we do not
> have control one those components.
> > >>>> The application is a JEE one and is deployed inside JBoss AS, we
> also use an embedded Felix container.
> > >>>>
> > >>>> We have encounter problems when OSGI components do things like that
> in their code:
> > >>>>
> > >>>>   File file = new File("relative_path/myfile.txt");
> > >>>>
> > >>>> This return a file which point to
> %JBOSS_HOME%/relative_path/myfile.txt.
> > >>>> This seems perfectly normal because OSGI delegate Class Loading for
> 'java.*' classes used to the parent Class Loader.
> > >>>>
> > >>>> So, how is it possible to have a path to the Bundle location (we use
> unzipped bundles) instead of %JBOSS_HOME% by calling new
> File("relative_path") ?
> > >>>> Is it possible to force OSGI to load delegate the Class Loading for
> java.io.File classes ?
> > >>>>
> > >>> No. That is not possible. However, I'm not sure I really understand
> > >>> what it is you are trying to do. Can you tell us more about that -
> > >>> maybe there is a different solution to your problem...
> > >>>
> > >>> regards,
> > >>>
> > >>> Karl
> > >>>
> > >>>
> > >>>> Thanks,
> > >>>>
> > >>>>
> > >>>> Baptiste
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> _________________________________________________________________
> > >>>> Découvrez toutes les possibilités de communication avec vos proches
> > >>>> http://www.microsoft.com/windows/windowslive/default.aspx
> > >>>>
> > >>>
> > >>>
> > >>> --
> > >>> Karl Pauls
> > >>> karlpauls@gmail.com
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > >>> For additional commands, e-mail: users-help@felix.apache.org
> > >>>
> > >>>
> > >> _________________________________________________________________
> > >> Découvrez toutes les possibilités de communication avec vos proches
> > >> http://www.microsoft.com/windows/windowslive/default.aspx
> > >>
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
>
> _________________________________________________________________
> Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger !
> http://www.ilovemessenger.fr/Emoticones/EmoticonesDejantees.aspx
>

RE: OSGI bootdelegation and java.io.File ?

Posted by Baptiste Gaillard <b_...@hotmail.com>.
Hum, yes using BundleContext.getDataFile() would be a good idea, but in our case we can't do that.

I explain me a little more...

In fact our customers are developping components using a framework called UIMA (http://incubator.apache.org/uima/). 
To deploy the components on our platform, control the Class Loading/UnLoading/etc. we have added an OSGI layer. 
Now, the components are OSGI wrappers around UIMA components.
Unfortunately in UIMA components we do not have access to BundleContext.getDataFile() :-(

> Replace File via the boot class path, as Karl mentions, is do-able, but 
> I am not sure if it is a good idea.

I agree, this should work well to solve the 'new File(relativePath)' problem. 
But as the application is deployed in JBoss AS there will be lot of other problems... Jboss will not be able to find his files... 
Perhaps it's feasible via the boot class path but the 'java.io.File' class to developp will be very compilcated.

Thanks, 

Baptiste
 
> Date: Fri, 2 Oct 2009 11:34:13 +0200
> From: heavy@ungoverned.org
> To: users@felix.apache.org
> Subject: Re: OSGI bootdelegation and java.io.File ?
> 
> You certainly need to tell your customers to use 
> BundleContext.getDataFile() instead of creating file objects directly.
> 
> Replace File via the boot class path, as Karl mentions, is do-able, but 
> I am not sure if it is a good idea.
> 
> -> richard
> 
> On 10/2/09 11:23, Karl Pauls wrote:
> > Well, in this case I guess you will have to have your customers
> > special case for OSGi I guess as their is no way (that I know) to
> > replace java.io.File (unless you override it with our own version
> > using the -Xbootclasspath/p option of the jvm).
> >
> > regards,
> >
> > Karl
> >
> > On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
> > <b_...@hotmail.com>  wrote:
> >    
> >> The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers.
> >>
> >> We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise.
> >>
> >> What I wanted to do with:
> >>   new File("relative_path")
> >>
> >> is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File().
> >>
> >> Something like :
> >>
> >> /**
> >>   * Our version of java.io.File
> >>   */
> >> class File {
> >>
> >>     public File(String relativePath)
> >>     {
> >>           this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
> >>           this.prefixLength = fs.prefixLength(this.path);
> >>     }
> >>
> >> }
> >>
> >> /**
> >>   * SUN version of java.io.File
> >>   */
> >> class File {
> >>
> >>
> >>
> >>     public File(String pathname)
> >>
> >>     {
> >>
> >>           this.path = fs.normalize(pathname);
> >>
> >>           this.prefixLength = fs.prefixLength(this.path);
> >>
> >>     }
> >>
> >>
> >>
> >> }
> >>
> >> Do you think something like that is feasible ?
> >>
> >>
> >>
> >>
> >>      
> >>> Date: Fri, 2 Oct 2009 10:51:21 +0200
> >>> Subject: Re: OSGI bootdelegation and java.io.File ?
> >>> From: karlpauls@gmail.com
> >>> To: users@felix.apache.org
> >>>
> >>> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
> >>> <b_...@hotmail.com>  wrote:
> >>>        
> >>>> Hi, we are building a platform which allow to deploy and execute OSGI components.
> >>>>
> >>>> Those OSGI components are developed by our customers and we do not have control one those components.
> >>>> The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
> >>>>
> >>>> We have encounter problems when OSGI components do things like that in their code:
> >>>>
> >>>>   File file = new File("relative_path/myfile.txt");
> >>>>
> >>>> This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
> >>>> This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
> >>>>
> >>>> So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
> >>>> Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
> >>>>          
> >>> No. That is not possible. However, I'm not sure I really understand
> >>> what it is you are trying to do. Can you tell us more about that -
> >>> maybe there is a different solution to your problem...
> >>>
> >>> regards,
> >>>
> >>> Karl
> >>>
> >>>        
> >>>> Thanks,
> >>>>
> >>>>
> >>>> Baptiste
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> _________________________________________________________________
> >>>> Découvrez toutes les possibilités de communication avec vos proches
> >>>> http://www.microsoft.com/windows/windowslive/default.aspx
> >>>>          
> >>>
> >>>
> >>> --
> >>> Karl Pauls
> >>> karlpauls@gmail.com
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >>> For additional commands, e-mail: users-help@felix.apache.org
> >>>
> >>>        
> >> _________________________________________________________________
> >> Découvrez toutes les possibilités de communication avec vos proches
> >> http://www.microsoft.com/windows/windowslive/default.aspx
> >>      
> >
> >
> >    
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
 		 	   		  
_________________________________________________________________
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger !
http://www.ilovemessenger.fr/Emoticones/EmoticonesDejantees.aspx

Re: OSGI bootdelegation and java.io.File ?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
You certainly need to tell your customers to use 
BundleContext.getDataFile() instead of creating file objects directly.

Replace File via the boot class path, as Karl mentions, is do-able, but 
I am not sure if it is a good idea.

-> richard

On 10/2/09 11:23, Karl Pauls wrote:
> Well, in this case I guess you will have to have your customers
> special case for OSGi I guess as their is no way (that I know) to
> replace java.io.File (unless you override it with our own version
> using the -Xbootclasspath/p option of the jvm).
>
> regards,
>
> Karl
>
> On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
> <b_...@hotmail.com>  wrote:
>    
>> The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers.
>>
>> We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise.
>>
>> What I wanted to do with:
>>   new File("relative_path")
>>
>> is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File().
>>
>> Something like :
>>
>> /**
>>   * Our version of java.io.File
>>   */
>> class File {
>>
>>     public File(String relativePath)
>>     {
>>           this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
>>           this.prefixLength = fs.prefixLength(this.path);
>>     }
>>
>> }
>>
>> /**
>>   * SUN version of java.io.File
>>   */
>> class File {
>>
>>
>>
>>     public File(String pathname)
>>
>>     {
>>
>>           this.path = fs.normalize(pathname);
>>
>>           this.prefixLength = fs.prefixLength(this.path);
>>
>>     }
>>
>>
>>
>> }
>>
>> Do you think something like that is feasible ?
>>
>>
>>
>>
>>      
>>> Date: Fri, 2 Oct 2009 10:51:21 +0200
>>> Subject: Re: OSGI bootdelegation and java.io.File ?
>>> From: karlpauls@gmail.com
>>> To: users@felix.apache.org
>>>
>>> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
>>> <b_...@hotmail.com>  wrote:
>>>        
>>>> Hi, we are building a platform which allow to deploy and execute OSGI components.
>>>>
>>>> Those OSGI components are developed by our customers and we do not have control one those components.
>>>> The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
>>>>
>>>> We have encounter problems when OSGI components do things like that in their code:
>>>>
>>>>   File file = new File("relative_path/myfile.txt");
>>>>
>>>> This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
>>>> This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
>>>>
>>>> So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
>>>> Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
>>>>          
>>> No. That is not possible. However, I'm not sure I really understand
>>> what it is you are trying to do. Can you tell us more about that -
>>> maybe there is a different solution to your problem...
>>>
>>> regards,
>>>
>>> Karl
>>>
>>>        
>>>> Thanks,
>>>>
>>>>
>>>> Baptiste
>>>>
>>>>
>>>>
>>>>
>>>> _________________________________________________________________
>>>> Découvrez toutes les possibilités de communication avec vos proches
>>>> http://www.microsoft.com/windows/windowslive/default.aspx
>>>>          
>>>
>>>
>>> --
>>> Karl Pauls
>>> karlpauls@gmail.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>        
>> _________________________________________________________________
>> Découvrez toutes les possibilités de communication avec vos proches
>> http://www.microsoft.com/windows/windowslive/default.aspx
>>      
>
>
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: OSGI bootdelegation and java.io.File ?

Posted by Karl Pauls <ka...@gmail.com>.
Well, in this case I guess you will have to have your customers
special case for OSGi I guess as their is no way (that I know) to
replace java.io.File (unless you override it with our own version
using the -Xbootclasspath/p option of the jvm).

regards,

Karl

On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
<b_...@hotmail.com> wrote:
>
> The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers.
>
> We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise.
>
> What I wanted to do with:
>  new File("relative_path")
>
> is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File().
>
> Something like :
>
> /**
>  * Our version of java.io.File
>  */
> class File {
>
>    public File(String relativePath)
>    {
>          this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
>          this.prefixLength = fs.prefixLength(this.path);
>    }
>
> }
>
> /**
>  * SUN version of java.io.File
>  */
> class File {
>
>
>
>    public File(String pathname)
>
>    {
>
>          this.path = fs.normalize(pathname);
>
>          this.prefixLength = fs.prefixLength(this.path);
>
>    }
>
>
>
> }
>
> Do you think something like that is feasible ?
>
>
>
>
>> Date: Fri, 2 Oct 2009 10:51:21 +0200
>> Subject: Re: OSGI bootdelegation and java.io.File ?
>> From: karlpauls@gmail.com
>> To: users@felix.apache.org
>>
>> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
>> <b_...@hotmail.com> wrote:
>> >
>> > Hi, we are building a platform which allow to deploy and execute OSGI components.
>> >
>> > Those OSGI components are developed by our customers and we do not have control one those components.
>> > The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
>> >
>> > We have encounter problems when OSGI components do things like that in their code:
>> >
>> >  File file = new File("relative_path/myfile.txt");
>> >
>> > This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
>> > This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
>> >
>> > So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
>> > Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
>>
>> No. That is not possible. However, I'm not sure I really understand
>> what it is you are trying to do. Can you tell us more about that -
>> maybe there is a different solution to your problem...
>>
>> regards,
>>
>> Karl
>>
>> > Thanks,
>> >
>> >
>> > Baptiste
>> >
>> >
>> >
>> >
>> > _________________________________________________________________
>> > Découvrez toutes les possibilités de communication avec vos proches
>> > http://www.microsoft.com/windows/windowslive/default.aspx
>>
>>
>>
>> --
>> Karl Pauls
>> karlpauls@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> _________________________________________________________________
> Découvrez toutes les possibilités de communication avec vos proches
> http://www.microsoft.com/windows/windowslive/default.aspx



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: OSGI bootdelegation and java.io.File ?

Posted by Karl Pauls <ka...@gmail.com>.
On Fri, Oct 2, 2009 at 11:26 AM, Toni Menzel <to...@okidokiteam.com> wrote:
> I think this is not feasible.
> If you want to overwrite resource localization, thats what URLs and URL
> Handlers are made for.
> There you can make all kinds of things (not sure if you can overwrite built
> in protocols like file).

You can.

regards,

Karl

> Or you come up with an abstracted resource api (i think there are tons out
> there).
>
> Toni
>
> On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
> <b_...@hotmail.com>wrote:
>
>>
>> The main problem is that we do not have control on the OSGI components
>> deployed on our application because they are developped by our customers.
>>
>> We can write a guide and explain what to do and not to do with OSGI, but we
>> hoped to solve the majority of problems otherwise.
>>
>> What I wanted to do with:
>>  new File("relative_path")
>>
>> is to change the way relative paths are built by replacing java.io.File()
>> with our version of java.io.File().
>>
>> Something like :
>>
>> /**
>>  * Our version of java.io.File
>>  */
>> class File {
>>
>>    public File(String relativePath)
>>    {
>>          this.path =
>> fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath()
>> + '/' + relativePath);
>>          this.prefixLength = fs.prefixLength(this.path);
>>    }
>>
>> }
>>
>> /**
>>  * SUN version of java.io.File
>>  */
>> class File {
>>
>>
>>
>>    public File(String pathname)
>>
>>    {
>>
>>          this.path = fs.normalize(pathname);
>>
>>          this.prefixLength = fs.prefixLength(this.path);
>>
>>    }
>>
>>
>>
>> }
>>
>> Do you think something like that is feasible ?
>>
>>
>>
>>
>> > Date: Fri, 2 Oct 2009 10:51:21 +0200
>> > Subject: Re: OSGI bootdelegation and java.io.File ?
>> > From: karlpauls@gmail.com
>> > To: users@felix.apache.org
>> >
>> > On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
>> > <b_...@hotmail.com> wrote:
>> > >
>> > > Hi, we are building a platform which allow to deploy and execute OSGI
>> components.
>> > >
>> > > Those OSGI components are developed by our customers and we do not have
>> control one those components.
>> > > The application is a JEE one and is deployed inside JBoss AS, we also
>> use an embedded Felix container.
>> > >
>> > > We have encounter problems when OSGI components do things like that in
>> their code:
>> > >
>> > >  File file = new File("relative_path/myfile.txt");
>> > >
>> > > This return a file which point to
>> %JBOSS_HOME%/relative_path/myfile.txt.
>> > > This seems perfectly normal because OSGI delegate Class Loading for
>> 'java.*' classes used to the parent Class Loader.
>> > >
>> > > So, how is it possible to have a path to the Bundle location (we use
>> unzipped bundles) instead of %JBOSS_HOME% by calling new
>> File("relative_path") ?
>> > > Is it possible to force OSGI to load delegate the Class Loading for
>> java.io.File classes ?
>> >
>> > No. That is not possible. However, I'm not sure I really understand
>> > what it is you are trying to do. Can you tell us more about that -
>> > maybe there is a different solution to your problem...
>> >
>> > regards,
>> >
>> > Karl
>> >
>> > > Thanks,
>> > >
>> > >
>> > > Baptiste
>> > >
>> > >
>> > >
>> > >
>> > > _________________________________________________________________
>> > > Découvrez toutes les possibilités de communication avec vos proches
>> > > http://www.microsoft.com/windows/windowslive/default.aspx
>> >
>> >
>> >
>> > --
>> > Karl Pauls
>> > karlpauls@gmail.com
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> > For additional commands, e-mail: users-help@felix.apache.org
>> >
>>
>> _________________________________________________________________
>> Découvrez toutes les possibilités de communication avec vos proches
>> http://www.microsoft.com/windows/windowslive/default.aspx
>>
>
>
>
> --
> Toni Menzel
> Independent Software Developer
> Professional Profile: http://okidokiteam.com
> toni@okidokiteam.com
> http://www.ops4j.org     - New Energy for OSS Communities - Open
> Participation Software.
>



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: OSGI bootdelegation and java.io.File ?

Posted by Baptiste Gaillard <b_...@hotmail.com>.
Ok, so I think the best solution in this case is to write a guide and explain what to do and not to do to make the components compatible with our platform. 

Thanks a lot, 

Baptiste

> Date: Fri, 2 Oct 2009 11:26:08 +0200
> Subject: Re: OSGI bootdelegation and java.io.File ?
> From: toni@okidokiteam.com
> To: users@felix.apache.org
> 
> I think this is not feasible.
> If you want to overwrite resource localization, thats what URLs and URL
> Handlers are made for.
> There you can make all kinds of things (not sure if you can overwrite built
> in protocols like file).
> 
> Or you come up with an abstracted resource api (i think there are tons out
> there).
> 
> Toni
> 
> On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
> <b_...@hotmail.com>wrote:
> 
> >
> > The main problem is that we do not have control on the OSGI components
> > deployed on our application because they are developped by our customers.
> >
> > We can write a guide and explain what to do and not to do with OSGI, but we
> > hoped to solve the majority of problems otherwise.
> >
> > What I wanted to do with:
> >  new File("relative_path")
> >
> > is to change the way relative paths are built by replacing java.io.File()
> > with our version of java.io.File().
> >
> > Something like :
> >
> > /**
> >  * Our version of java.io.File
> >  */
> > class File {
> >
> >    public File(String relativePath)
> >    {
> >          this.path =
> > fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath()
> > + '/' + relativePath);
> >          this.prefixLength = fs.prefixLength(this.path);
> >    }
> >
> > }
> >
> > /**
> >  * SUN version of java.io.File
> >  */
> > class File {
> >
> >
> >
> >    public File(String pathname)
> >
> >    {
> >
> >          this.path = fs.normalize(pathname);
> >
> >          this.prefixLength = fs.prefixLength(this.path);
> >
> >    }
> >
> >
> >
> > }
> >
> > Do you think something like that is feasible ?
> >
> >
> >
> >
> > > Date: Fri, 2 Oct 2009 10:51:21 +0200
> > > Subject: Re: OSGI bootdelegation and java.io.File ?
> > > From: karlpauls@gmail.com
> > > To: users@felix.apache.org
> > >
> > > On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
> > > <b_...@hotmail.com> wrote:
> > > >
> > > > Hi, we are building a platform which allow to deploy and execute OSGI
> > components.
> > > >
> > > > Those OSGI components are developed by our customers and we do not have
> > control one those components.
> > > > The application is a JEE one and is deployed inside JBoss AS, we also
> > use an embedded Felix container.
> > > >
> > > > We have encounter problems when OSGI components do things like that in
> > their code:
> > > >
> > > >  File file = new File("relative_path/myfile.txt");
> > > >
> > > > This return a file which point to
> > %JBOSS_HOME%/relative_path/myfile.txt.
> > > > This seems perfectly normal because OSGI delegate Class Loading for
> > 'java.*' classes used to the parent Class Loader.
> > > >
> > > > So, how is it possible to have a path to the Bundle location (we use
> > unzipped bundles) instead of %JBOSS_HOME% by calling new
> > File("relative_path") ?
> > > > Is it possible to force OSGI to load delegate the Class Loading for
> > java.io.File classes ?
> > >
> > > No. That is not possible. However, I'm not sure I really understand
> > > what it is you are trying to do. Can you tell us more about that -
> > > maybe there is a different solution to your problem...
> > >
> > > regards,
> > >
> > > Karl
> > >
> > > > Thanks,
> > > >
> > > >
> > > > Baptiste
> > > >
> > > >
> > > >
> > > >
> > > > _________________________________________________________________
> > > > Découvrez toutes les possibilités de communication avec vos proches
> > > > http://www.microsoft.com/windows/windowslive/default.aspx
> > >
> > >
> > >
> > > --
> > > Karl Pauls
> > > karlpauls@gmail.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > > For additional commands, e-mail: users-help@felix.apache.org
> > >
> >
> > _________________________________________________________________
> > Découvrez toutes les possibilités de communication avec vos proches
> > http://www.microsoft.com/windows/windowslive/default.aspx
> >
> 
> 
> 
> -- 
> Toni Menzel
> Independent Software Developer
> Professional Profile: http://okidokiteam.com
> toni@okidokiteam.com
> http://www.ops4j.org     - New Energy for OSS Communities - Open
> Participation Software.
 		 	   		  
_________________________________________________________________
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger !
http://www.ilovemessenger.fr/Emoticones/EmoticonesDejantees.aspx

Re: OSGI bootdelegation and java.io.File ?

Posted by Toni Menzel <to...@okidokiteam.com>.
I think this is not feasible.
If you want to overwrite resource localization, thats what URLs and URL
Handlers are made for.
There you can make all kinds of things (not sure if you can overwrite built
in protocols like file).

Or you come up with an abstracted resource api (i think there are tons out
there).

Toni

On Fri, Oct 2, 2009 at 11:14 AM, Baptiste Gaillard
<b_...@hotmail.com>wrote:

>
> The main problem is that we do not have control on the OSGI components
> deployed on our application because they are developped by our customers.
>
> We can write a guide and explain what to do and not to do with OSGI, but we
> hoped to solve the majority of problems otherwise.
>
> What I wanted to do with:
>  new File("relative_path")
>
> is to change the way relative paths are built by replacing java.io.File()
> with our version of java.io.File().
>
> Something like :
>
> /**
>  * Our version of java.io.File
>  */
> class File {
>
>    public File(String relativePath)
>    {
>          this.path =
> fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath()
> + '/' + relativePath);
>          this.prefixLength = fs.prefixLength(this.path);
>    }
>
> }
>
> /**
>  * SUN version of java.io.File
>  */
> class File {
>
>
>
>    public File(String pathname)
>
>    {
>
>          this.path = fs.normalize(pathname);
>
>          this.prefixLength = fs.prefixLength(this.path);
>
>    }
>
>
>
> }
>
> Do you think something like that is feasible ?
>
>
>
>
> > Date: Fri, 2 Oct 2009 10:51:21 +0200
> > Subject: Re: OSGI bootdelegation and java.io.File ?
> > From: karlpauls@gmail.com
> > To: users@felix.apache.org
> >
> > On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
> > <b_...@hotmail.com> wrote:
> > >
> > > Hi, we are building a platform which allow to deploy and execute OSGI
> components.
> > >
> > > Those OSGI components are developed by our customers and we do not have
> control one those components.
> > > The application is a JEE one and is deployed inside JBoss AS, we also
> use an embedded Felix container.
> > >
> > > We have encounter problems when OSGI components do things like that in
> their code:
> > >
> > >  File file = new File("relative_path/myfile.txt");
> > >
> > > This return a file which point to
> %JBOSS_HOME%/relative_path/myfile.txt.
> > > This seems perfectly normal because OSGI delegate Class Loading for
> 'java.*' classes used to the parent Class Loader.
> > >
> > > So, how is it possible to have a path to the Bundle location (we use
> unzipped bundles) instead of %JBOSS_HOME% by calling new
> File("relative_path") ?
> > > Is it possible to force OSGI to load delegate the Class Loading for
> java.io.File classes ?
> >
> > No. That is not possible. However, I'm not sure I really understand
> > what it is you are trying to do. Can you tell us more about that -
> > maybe there is a different solution to your problem...
> >
> > regards,
> >
> > Karl
> >
> > > Thanks,
> > >
> > >
> > > Baptiste
> > >
> > >
> > >
> > >
> > > _________________________________________________________________
> > > Découvrez toutes les possibilités de communication avec vos proches
> > > http://www.microsoft.com/windows/windowslive/default.aspx
> >
> >
> >
> > --
> > Karl Pauls
> > karlpauls@gmail.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
>
> _________________________________________________________________
> Découvrez toutes les possibilités de communication avec vos proches
> http://www.microsoft.com/windows/windowslive/default.aspx
>



-- 
Toni Menzel
Independent Software Developer
Professional Profile: http://okidokiteam.com
toni@okidokiteam.com
http://www.ops4j.org     - New Energy for OSS Communities - Open
Participation Software.

RE: OSGI bootdelegation and java.io.File ?

Posted by Baptiste Gaillard <b_...@hotmail.com>.
The main problem is that we do not have control on the OSGI components deployed on our application because they are developped by our customers. 

We can write a guide and explain what to do and not to do with OSGI, but we hoped to solve the majority of problems otherwise. 

What I wanted to do with: 
 new File("relative_path") 

is to change the way relative paths are built by replacing java.io.File() with our version of java.io.File(). 

Something like : 

/**
 * Our version of java.io.File
 */
class File {

    public File(String relativePath) 
    {
          this.path = fs.normalize(StaticBundleAccessor.getBundle().getBundleLocation().getAbsolutePath() + '/' + relativePath);
          this.prefixLength = fs.prefixLength(this.path);
    }

}

/**
 * SUN version of java.io.File
 */
class File {



    public File(String pathname) 

    {

          this.path = fs.normalize(pathname);

          this.prefixLength = fs.prefixLength(this.path);

    }



}

Do you think something like that is feasible ?




> Date: Fri, 2 Oct 2009 10:51:21 +0200
> Subject: Re: OSGI bootdelegation and java.io.File ?
> From: karlpauls@gmail.com
> To: users@felix.apache.org
> 
> On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
> <b_...@hotmail.com> wrote:
> >
> > Hi, we are building a platform which allow to deploy and execute OSGI components.
> >
> > Those OSGI components are developed by our customers and we do not have control one those components.
> > The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
> >
> > We have encounter problems when OSGI components do things like that in their code:
> >
> >  File file = new File("relative_path/myfile.txt");
> >
> > This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
> > This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
> >
> > So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
> > Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?
> 
> No. That is not possible. However, I'm not sure I really understand
> what it is you are trying to do. Can you tell us more about that -
> maybe there is a different solution to your problem...
> 
> regards,
> 
> Karl
> 
> > Thanks,
> >
> >
> > Baptiste
> >
> >
> >
> >
> > _________________________________________________________________
> > Découvrez toutes les possibilités de communication avec vos proches
> > http://www.microsoft.com/windows/windowslive/default.aspx
> 
> 
> 
> -- 
> Karl Pauls
> karlpauls@gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
 		 	   		  
_________________________________________________________________
Découvrez toutes les possibilités de communication avec vos proches
http://www.microsoft.com/windows/windowslive/default.aspx

Re: OSGI bootdelegation and java.io.File ?

Posted by Karl Pauls <ka...@gmail.com>.
On Fri, Oct 2, 2009 at 10:48 AM, Baptiste Gaillard
<b_...@hotmail.com> wrote:
>
> Hi, we are building a platform which allow to deploy and execute OSGI components.
>
> Those OSGI components are developed by our customers and we do not have control one those components.
> The application is a JEE one and is deployed inside JBoss AS, we also use an embedded Felix container.
>
> We have encounter problems when OSGI components do things like that in their code:
>
>  File file = new File("relative_path/myfile.txt");
>
> This return a file which point to %JBOSS_HOME%/relative_path/myfile.txt.
> This seems perfectly normal because OSGI delegate Class Loading for 'java.*' classes used to the parent Class Loader.
>
> So, how is it possible to have a path to the Bundle location (we use unzipped bundles) instead of %JBOSS_HOME% by calling new File("relative_path") ?
> Is it possible to force OSGI to load delegate the Class Loading for java.io.File classes ?

No. That is not possible. However, I'm not sure I really understand
what it is you are trying to do. Can you tell us more about that -
maybe there is a different solution to your problem...

regards,

Karl

> Thanks,
>
>
> Baptiste
>
>
>
>
> _________________________________________________________________
> Découvrez toutes les possibilités de communication avec vos proches
> http://www.microsoft.com/windows/windowslive/default.aspx



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org