You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Charles Moulliard <cm...@gmail.com> on 2010/07/16 11:02:19 UTC

Issue in the code - help requested

Hi,

In debug mode, I see that something is wrong in my code :

public class FeaturesServiceImpl implements FeaturesService {
...

    protected static class InstallationState {
        final Set<Bundle> installed = new HashSet<Bundle>();
        final List<Bundle> bundles = new ArrayList<Bundle>();
        final Map<Long, BundleInfo> bundleInfos = new HashMap<Long,
BundleInfo>();
        final Map<Feature, Set<Long>> features = new HashMap<Feature,
Set<Long>>();
    }

   protected void doInstallFeature(InstallationState state, Feature feature)
throws Exception {
...
        Set<Long> bundles = new TreeSet<Long>();
        for (BundleInfo bInfo : resolve(feature)) {
            Bundle b = installBundleIfNeeded(state, bInfo);
            bundles.add(b.getBundleId());
            state.bundleInfos.put(b.getBundleId(), bInfo);
        }
        state.features.put(feature, bundles);
    }

    public void installFeatures(Set<Feature> features, EnumSet<Option>
options) throws Exception {
        InstallationState state = new InstallationState();
        InstallationState failure = new InstallationState();
        try {
            // Install everything
            for (Feature f : features) {
                InstallationState s = new InstallationState();
                try {
                    doInstallFeature(s, f);
                     state.bundles.addAll(s.bundles); // Ok --> ArrayList of
BundleImpl is well copied in state.bundles
                     state.bundleInfos.putAll(s.bundleInfos); // NOK -->
HashMap of s.bundleInfos is not copied to state.bundleInfos and
s.bundleInfos contains well in the HashMap BundleInfo objects
                     ...
                } catch (Exception e) {

What is wrong in the java code (the fact that we use a HashMap defined in
InstallationState to copy it from object s to object state, ...) ?

Help is welcome ?

Kind regards,


Charles Moulliard

Senior Enterprise Architect (J2EE, .NET, SOA)
Apache Camel - ServiceMix Committer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Blog : http://cmoulliard.blogspot.com |  Twitter :
http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard

Re: Issue in the code - help requested

Posted by Charles Moulliard <cm...@gmail.com>.
I have made a test without remote debugging and it works now. I continue the
tests and commit soon this modification to be able to have the start
attribute available for <bundle>

On Fri, Jul 16, 2010 at 2:11 PM, Charles Moulliard <cm...@gmail.com>wrote:

> I'm sure. I will send you two png files on your email address.
>
>
> On Fri, Jul 16, 2010 at 1:53 PM, Guillaume Nodet <gn...@gmail.com> wrote:
>
>> Are you sure they aren't added to the map ? I don't see how that could not
>> work.
>>
>> On Fri, Jul 16, 2010 at 11:02, Charles Moulliard <cm...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > In debug mode, I see that something is wrong in my code :
>> >
>> > public class FeaturesServiceImpl implements FeaturesService {
>> > ...
>> >
>> >    protected static class InstallationState {
>> >        final Set<Bundle> installed = new HashSet<Bundle>();
>> >        final List<Bundle> bundles = new ArrayList<Bundle>();
>> >        final Map<Long, BundleInfo> bundleInfos = new HashMap<Long,
>> > BundleInfo>();
>> >        final Map<Feature, Set<Long>> features = new HashMap<Feature,
>> > Set<Long>>();
>> >    }
>> >
>> >   protected void doInstallFeature(InstallationState state, Feature
>> feature)
>> > throws Exception {
>> > ...
>> >        Set<Long> bundles = new TreeSet<Long>();
>> >        for (BundleInfo bInfo : resolve(feature)) {
>> >            Bundle b = installBundleIfNeeded(state, bInfo);
>> >            bundles.add(b.getBundleId());
>> >            state.bundleInfos.put(b.getBundleId(), bInfo);
>> >        }
>> >        state.features.put(feature, bundles);
>> >    }
>> >
>> >    public void installFeatures(Set<Feature> features, EnumSet<Option>
>> > options) throws Exception {
>> >        InstallationState state = new InstallationState();
>> >        InstallationState failure = new InstallationState();
>> >        try {
>> >            // Install everything
>> >            for (Feature f : features) {
>> >                InstallationState s = new InstallationState();
>> >                try {
>> >                    doInstallFeature(s, f);
>> >                     state.bundles.addAll(s.bundles); // Ok --> ArrayList
>> of
>> > BundleImpl is well copied in state.bundles
>> >                     state.bundleInfos.putAll(s.bundleInfos); // NOK -->
>> > HashMap of s.bundleInfos is not copied to state.bundleInfos and
>> > s.bundleInfos contains well in the HashMap BundleInfo objects
>> >                     ...
>> >                } catch (Exception e) {
>> >
>> > What is wrong in the java code (the fact that we use a HashMap defined
>> in
>> > InstallationState to copy it from object s to object state, ...) ?
>> >
>> > Help is welcome ?
>> >
>> > Kind regards,
>> >
>> >
>> > Charles Moulliard
>> >
>> > Senior Enterprise Architect (J2EE, .NET, SOA)
>> > Apache Camel - ServiceMix Committer
>> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> > Blog : http://cmoulliard.blogspot.com |  Twitter :
>> > http://twitter.com/cmoulliard
>> > Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype:
>> cmoulliard
>> >
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>
>

Re: Issue in the code - help requested

Posted by Charles Moulliard <cm...@gmail.com>.
I'm sure. I will send you two png files on your email address.

On Fri, Jul 16, 2010 at 1:53 PM, Guillaume Nodet <gn...@gmail.com> wrote:

> Are you sure they aren't added to the map ? I don't see how that could not
> work.
>
> On Fri, Jul 16, 2010 at 11:02, Charles Moulliard <cm...@gmail.com>
> wrote:
> > Hi,
> >
> > In debug mode, I see that something is wrong in my code :
> >
> > public class FeaturesServiceImpl implements FeaturesService {
> > ...
> >
> >    protected static class InstallationState {
> >        final Set<Bundle> installed = new HashSet<Bundle>();
> >        final List<Bundle> bundles = new ArrayList<Bundle>();
> >        final Map<Long, BundleInfo> bundleInfos = new HashMap<Long,
> > BundleInfo>();
> >        final Map<Feature, Set<Long>> features = new HashMap<Feature,
> > Set<Long>>();
> >    }
> >
> >   protected void doInstallFeature(InstallationState state, Feature
> feature)
> > throws Exception {
> > ...
> >        Set<Long> bundles = new TreeSet<Long>();
> >        for (BundleInfo bInfo : resolve(feature)) {
> >            Bundle b = installBundleIfNeeded(state, bInfo);
> >            bundles.add(b.getBundleId());
> >            state.bundleInfos.put(b.getBundleId(), bInfo);
> >        }
> >        state.features.put(feature, bundles);
> >    }
> >
> >    public void installFeatures(Set<Feature> features, EnumSet<Option>
> > options) throws Exception {
> >        InstallationState state = new InstallationState();
> >        InstallationState failure = new InstallationState();
> >        try {
> >            // Install everything
> >            for (Feature f : features) {
> >                InstallationState s = new InstallationState();
> >                try {
> >                    doInstallFeature(s, f);
> >                     state.bundles.addAll(s.bundles); // Ok --> ArrayList
> of
> > BundleImpl is well copied in state.bundles
> >                     state.bundleInfos.putAll(s.bundleInfos); // NOK -->
> > HashMap of s.bundleInfos is not copied to state.bundleInfos and
> > s.bundleInfos contains well in the HashMap BundleInfo objects
> >                     ...
> >                } catch (Exception e) {
> >
> > What is wrong in the java code (the fact that we use a HashMap defined in
> > InstallationState to copy it from object s to object state, ...) ?
> >
> > Help is welcome ?
> >
> > Kind regards,
> >
> >
> > Charles Moulliard
> >
> > Senior Enterprise Architect (J2EE, .NET, SOA)
> > Apache Camel - ServiceMix Committer
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Blog : http://cmoulliard.blogspot.com |  Twitter :
> > http://twitter.com/cmoulliard
> > Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype:
> cmoulliard
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>

Re: Issue in the code - help requested

Posted by Guillaume Nodet <gn...@gmail.com>.
Are you sure they aren't added to the map ? I don't see how that could not work.

On Fri, Jul 16, 2010 at 11:02, Charles Moulliard <cm...@gmail.com> wrote:
> Hi,
>
> In debug mode, I see that something is wrong in my code :
>
> public class FeaturesServiceImpl implements FeaturesService {
> ...
>
>    protected static class InstallationState {
>        final Set<Bundle> installed = new HashSet<Bundle>();
>        final List<Bundle> bundles = new ArrayList<Bundle>();
>        final Map<Long, BundleInfo> bundleInfos = new HashMap<Long,
> BundleInfo>();
>        final Map<Feature, Set<Long>> features = new HashMap<Feature,
> Set<Long>>();
>    }
>
>   protected void doInstallFeature(InstallationState state, Feature feature)
> throws Exception {
> ...
>        Set<Long> bundles = new TreeSet<Long>();
>        for (BundleInfo bInfo : resolve(feature)) {
>            Bundle b = installBundleIfNeeded(state, bInfo);
>            bundles.add(b.getBundleId());
>            state.bundleInfos.put(b.getBundleId(), bInfo);
>        }
>        state.features.put(feature, bundles);
>    }
>
>    public void installFeatures(Set<Feature> features, EnumSet<Option>
> options) throws Exception {
>        InstallationState state = new InstallationState();
>        InstallationState failure = new InstallationState();
>        try {
>            // Install everything
>            for (Feature f : features) {
>                InstallationState s = new InstallationState();
>                try {
>                    doInstallFeature(s, f);
>                     state.bundles.addAll(s.bundles); // Ok --> ArrayList of
> BundleImpl is well copied in state.bundles
>                     state.bundleInfos.putAll(s.bundleInfos); // NOK -->
> HashMap of s.bundleInfos is not copied to state.bundleInfos and
> s.bundleInfos contains well in the HashMap BundleInfo objects
>                     ...
>                } catch (Exception e) {
>
> What is wrong in the java code (the fact that we use a HashMap defined in
> InstallationState to copy it from object s to object state, ...) ?
>
> Help is welcome ?
>
> Kind regards,
>
>
> Charles Moulliard
>
> Senior Enterprise Architect (J2EE, .NET, SOA)
> Apache Camel - ServiceMix Committer
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Blog : http://cmoulliard.blogspot.com |  Twitter :
> http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com