karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <cmoulli...@gmail.com>
Subject Issue in the code - help requested
Date Fri, 16 Jul 2010 09:02:19 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message