Home » Eclipse Projects » Equinox » aspectj load-time weaving works for OSGi
aspectj load-time weaving works for OSGi [message #31757] |
Wed, 31 December 2003 11:27  |
Eclipse User |
|
|
|
Hi,
I succeeded to integrate the load-time weaving for AspectJ into the M6
version of the OSGi-based runtime. Thanks for the help.
There are a few points where I somehow struggled with the OSGi runtime.
Any ideas how to improve these things are welcome.
- I wrote my own adaptor to create special class loaders, to start an
additional bundle at startup time and to register a special service.
That is all fine except from the fact that there is currently no
official way to hook my adaptor into the system (as well as to provide
some additional packages to other bundles). Therefore I wrote a bug
report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=48695
- I need to add dependencies between bundles at runtime (as a result of
a woven class, for example). I didn't find a way to do this via the
normal dependency handling inside the OSGi runtime. I finally enhanced
my special class loader with a list of additional required bundles.
These bundles are asked to load a class if the first attempt to load the
class fails. New required bundles can be added at runtime.
-> works for me and does not require any changes to the Eclipse code.
-> but is somehow duplicated code for dependency handling.
- The weaver of AspectJ needs a lot of type information to weave a class
(the class itself and all required types within that class and all
required types of these classes and so on). In my first implementation
for Eclipse 2.1 I collected all required plugins (recursively) for a
plugin, asked for the classpath URLs of the plugins and added them to
the weaver. This is more complicated inside the new runtime. Now I am
using the Bundle.getResource method to load the bytecode for a class if
the weaver asks for it. This is a lot more elegant than the old
implementation but has one problem: Bundle.getResource loads only
resources that are found within the bundle itself or required (or
imported) bundles. I need to find even resources of bundles that are
required (or imported) by required bundles and so on. Therefore I need
an elegant way to collect all required (or imported) bundles from a
bundle recursively. (This part is not part of my special adaptor so I
can use only official API stuff. I found similar code inside the
StateImpl class which I could not adapt because of internal API usage.)
Any ideas and comments are welcome. Thanks!!!
Best regards,
Martin
|
|
| |
Re: aspectj load-time weaving works for OSGi [message #32008 is a reply to message #31831] |
Wed, 07 January 2004 05:41   |
Eclipse User |
|
|
|
Hi,
> We will address the bug in the next couple weeks. Expect something for M7.
Perfect!!! Thanks a lot for that!
> As for the dependency info, the State interface is the thing you want. It
> is not official API but will likely end up as "experimental" API in 3.0.
> You should look at the PlatformAdmin service and from there get the current
> state and traverse the state to find everything you need. Let us know if
> there is something you need that you cannot get through this mechanism.
Okay, the State interface seems to be pretty fine for that. Thanks for
the hint.
Any idea or comment about this:
I need to add dependencies between bundles at runtime (as a result of
a woven class, for example). I didn't find a way to do this via the
normal dependency handling inside the OSGi runtime. I finally enhanced
my special class loader with a list of additional required bundles.
These bundles are asked to load a class if the first attempt to load the
class fails. New required bundles can be added at runtime.
-> works for me and does not require any changes to the Eclipse code.
-> but is somehow duplicated code for dependency handling.
Thanks again!
Best regards,
Martin
>
> Jeff
>
> "Martin Lippert" <lippert@acm.org> wrote in message
> news:bsutb7$nk0$1@eclipse.org...
>
>>Hi,
>>
>>I succeeded to integrate the load-time weaving for AspectJ into the M6
>>version of the OSGi-based runtime. Thanks for the help.
>>
>>There are a few points where I somehow struggled with the OSGi runtime.
>>Any ideas how to improve these things are welcome.
>>
>>- I wrote my own adaptor to create special class loaders, to start an
>>additional bundle at startup time and to register a special service.
>>That is all fine except from the fact that there is currently no
>>official way to hook my adaptor into the system (as well as to provide
>>some additional packages to other bundles). Therefore I wrote a bug
>>report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=48695
>>
>>- I need to add dependencies between bundles at runtime (as a result of
>>a woven class, for example). I didn't find a way to do this via the
>>normal dependency handling inside the OSGi runtime. I finally enhanced
>>my special class loader with a list of additional required bundles.
>>These bundles are asked to load a class if the first attempt to load the
>>class fails. New required bundles can be added at runtime.
>>-> works for me and does not require any changes to the Eclipse code.
>>-> but is somehow duplicated code for dependency handling.
>>
>>- The weaver of AspectJ needs a lot of type information to weave a class
>>(the class itself and all required types within that class and all
>>required types of these classes and so on). In my first implementation
>>for Eclipse 2.1 I collected all required plugins (recursively) for a
>>plugin, asked for the classpath URLs of the plugins and added them to
>>the weaver. This is more complicated inside the new runtime. Now I am
>>using the Bundle.getResource method to load the bytecode for a class if
>>the weaver asks for it. This is a lot more elegant than the old
>>implementation but has one problem: Bundle.getResource loads only
>>resources that are found within the bundle itself or required (or
>>imported) bundles. I need to find even resources of bundles that are
>>required (or imported) by required bundles and so on. Therefore I need
>>an elegant way to collect all required (or imported) bundles from a
>>bundle recursively. (This part is not part of my special adaptor so I
>>can use only official API stuff. I found similar code inside the
>>StateImpl class which I could not adapt because of internal API usage.)
>>
>>Any ideas and comments are welcome. Thanks!!!
>>
>>Best regards,
>>Martin
>>
>>
>>
>>
>
>
>
|
|
|
Re: aspectj load-time weaving works for OSGi [message #32256 is a reply to message #32008] |
Fri, 09 January 2004 16:57   |
Eclipse User |
|
|
|
Originally posted by: jeff_mcaffer_REMOVE.ca.ibm.com
for adding dependencies, can you install bundles to add the dependencies?
This allows them to be added ot the state and properly managed by the
runtime.
Jeff
"Martin Lippert" <lippert@acm.org> wrote in message
news:btgnnq$3c1$1@eclipse.org...
> Hi,
>
> > We will address the bug in the next couple weeks. Expect something for
M7.
>
> Perfect!!! Thanks a lot for that!
>
> > As for the dependency info, the State interface is the thing you want.
It
> > is not official API but will likely end up as "experimental" API in 3.0.
> > You should look at the PlatformAdmin service and from there get the
current
> > state and traverse the state to find everything you need. Let us know
if
> > there is something you need that you cannot get through this mechanism.
>
> Okay, the State interface seems to be pretty fine for that. Thanks for
> the hint.
>
> Any idea or comment about this:
>
> I need to add dependencies between bundles at runtime (as a result of
> a woven class, for example). I didn't find a way to do this via the
> normal dependency handling inside the OSGi runtime. I finally enhanced
> my special class loader with a list of additional required bundles.
> These bundles are asked to load a class if the first attempt to load the
> class fails. New required bundles can be added at runtime.
> -> works for me and does not require any changes to the Eclipse code.
> -> but is somehow duplicated code for dependency handling.
>
> Thanks again!
>
> Best regards,
> Martin
>
>
>
>
> >
> > Jeff
> >
> > "Martin Lippert" <lippert@acm.org> wrote in message
> > news:bsutb7$nk0$1@eclipse.org...
> >
> >>Hi,
> >>
> >>I succeeded to integrate the load-time weaving for AspectJ into the M6
> >>version of the OSGi-based runtime. Thanks for the help.
> >>
> >>There are a few points where I somehow struggled with the OSGi runtime.
> >>Any ideas how to improve these things are welcome.
> >>
> >>- I wrote my own adaptor to create special class loaders, to start an
> >>additional bundle at startup time and to register a special service.
> >>That is all fine except from the fact that there is currently no
> >>official way to hook my adaptor into the system (as well as to provide
> >>some additional packages to other bundles). Therefore I wrote a bug
> >>report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=48695
> >>
> >>- I need to add dependencies between bundles at runtime (as a result of
> >>a woven class, for example). I didn't find a way to do this via the
> >>normal dependency handling inside the OSGi runtime. I finally enhanced
> >>my special class loader with a list of additional required bundles.
> >>These bundles are asked to load a class if the first attempt to load the
> >>class fails. New required bundles can be added at runtime.
> >>-> works for me and does not require any changes to the Eclipse code.
> >>-> but is somehow duplicated code for dependency handling.
> >>
> >>- The weaver of AspectJ needs a lot of type information to weave a class
> >>(the class itself and all required types within that class and all
> >>required types of these classes and so on). In my first implementation
> >>for Eclipse 2.1 I collected all required plugins (recursively) for a
> >>plugin, asked for the classpath URLs of the plugins and added them to
> >>the weaver. This is more complicated inside the new runtime. Now I am
> >>using the Bundle.getResource method to load the bytecode for a class if
> >>the weaver asks for it. This is a lot more elegant than the old
> >>implementation but has one problem: Bundle.getResource loads only
> >>resources that are found within the bundle itself or required (or
> >>imported) bundles. I need to find even resources of bundles that are
> >>required (or imported) by required bundles and so on. Therefore I need
> >>an elegant way to collect all required (or imported) bundles from a
> >>bundle recursively. (This part is not part of my special adaptor so I
> >>can use only official API stuff. I found similar code inside the
> >>StateImpl class which I could not adapt because of internal API usage.)
> >>
> >>Any ideas and comments are welcome. Thanks!!!
> >>
> >>Best regards,
> >>Martin
> >>
> >>
> >>
> >>
> >
> >
> >
>
|
|
| | | | | | | | | | | | | | |
Re: aspectj load-time weaving works for OSGi [message #37070 is a reply to message #36869] |
Thu, 11 March 2004 14:59  |
Eclipse User |
|
|
|
Hi,
> Sorry for the delay in responding. For some reason my news reader only just
> decided to show my your post...
>
> Please enter an enhancement request. #2 looks good/easy.
Done. Take a look at:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=54524
Thanks for the support!!!
-Martin
>
> Jeff
>
> "Martin Lippert" <lippert@acm.org> wrote in message
> news:c288tg$pu4$1@eclipse.org...
>
>>Hi,
>>
>>
>>>Can you do what you need to or do you need changes? For now we can hack
>
> to
>
>>>get you going and understand how to do this more elegantly later.
>>
>>I observed one problem with my dynamic adding of DynamicImportPackages.
>>The list of dynamic imports inside BundleLoader is growing with each
>>class that is loaded because the loader does not check if the package
>>that is added via initDynamicImportPackage is already in the list of
>>dynamic imports. They are always added and I got a huge number of
>>duplicates in it. I would like to solve this problem. Therefore I found
>>two options:
>>
>>1. Make the initDynamicImportPackage method of BundleLoader aware of
>>duplicates.
>>2. Make the method isDynamicallyImported of BundleLoader public so that
>>I can check if the package is already importet before I call
>>initDynamicImportPackage to add it.
>>
>>I would prefer option 2 since it requires less changes to the code of
>>BundleLoader. What do you think?
>>
>>Thanks!!!
>>
>>Best regards,
>>Martin
>>
>>
>>
>>
>>
>>
>>>Jeff
>>>
>>>"Martin Lippert" <lippert@acm.org> wrote in message
>>>news:bus9dd$8d5$1@eclipse.org...
>>>
>>>
>>>>Hi,
>>>>
>>>>
>>>>
>>>>>>>I took a look at the dynamic package import functionality and it
>
> seems
>
>>>>>>>to me that mainly the BundleLoader deals with it. Therefore I don't
>>>
>>>know
>>>
>>>
>>>>>>>how to add, for example, a new dynamic import to that loader or to
>>>>>>>change the setting to "*" at runtime. Did I ignore something?
>>>>>>
>>>>>>Any idea on that?
>>>>>
>>>>>Not right now. I'd have to dig through the code to see what is
>>>
>>>happening
>>>
>>>
>>>>>where. what you say about the BundleLoader sounds right though. Try
>>>
>>>adding
>>>
>>>
>>>>>something to bundle loader like addDynamicImport(). The implementation
>>>>>should be reasonably straightforward. If you can prototype this we can
>>>
>>>look
>>>
>>>
>>>>>at adding the support for real. Otherwise we are all up to our necks
>>>>>preparing for EclipseCon and M7 so cannot be too proactive on
>>>
>>>non-critical
>>>
>>>
>>>>>items.
>>>>
>>>>The BundleLoader has a method called "initDynamicImportPackage". This
>>>>method could be used to add dynamic imports at runtime, from my point of
>>>>view. For that it only has to be set to public visibility.
>>>>
>>>>The way to access this method (for example from my special adaptor or
>>>>class loader) would still be somewhat ugly, but that might be okay (two
>>>>ways to access the BundleLoader: cast from Bundle to BundleHost to call
>>>>the method getBundleLoader on BundleHost or access the protected field
>>>>of BundleClassLoader "delegate" to BundleLoader).
>>>>
>>>>Does that sounds reasonable?
>>>>
>>>>Thanks again!
>>>>
>>>>Best regards,
>>>>Martin
>>>>
>>>
>>>
>>>
>
>
|
|
|
Goto Forum:
Current Time: Tue Jul 15 09:26:59 EDT 2025
Powered by FUDForum. Page generated in 0.35321 seconds
|