Examples of BundleState


Examples of org.apache.karaf.cellar.bundle.BundleState

            if (key == null) {
                System.err.println("Bundle " + key + " not found in cluster group " + groupName);
                return null;
            }

            BundleState state = clusterBundles.get(key);
            if (state == null) {
                System.err.println("Bundle " + key + " not found in cluster group " + groupName);
                return null;
            }
            state.setStatus(BundleEvent.STOPPED);
            location = state.getLocation();

            // check if the bundle is allowed
            CellarSupport support = new CellarSupport();
            support.setClusterManager(this.clusterManager);
            support.setGroupManager(this.groupManager);
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

            if (key == null) {
                System.err.println("Bundle " + key + " not found in cluster group " + groupName);
            }

            BundleState state = clusterBundles.get(key);
            if (state == null) {
                System.err.println("Bundle " + key + " not found in cluster group " + groupName);
                return null;
            }
            location = state.getLocation();

            // check if the bundle is allowed
            CellarSupport support = new CellarSupport();
            support.setClusterManager(this.clusterManager);
            support.setGroupManager(this.groupManager);
            support.setConfigurationAdmin(this.configurationAdmin);
            if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
                System.err.println("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
                return null;
            }

            state.setStatus(BundleEvent.STARTED);
            clusterBundles.put(key, state);
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

                // update the bundles in the cluster group
                // TODO does it make really sense
                List<BundleInfo> bundles = featuresService.getFeature(feature.getName(), version).getBundles();
                Map<String, BundleState> clusterBundles = clusterManager.getMap(org.apache.karaf.cellar.bundle.Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
                for (BundleInfo bundle : bundles) {
                    BundleState state = new BundleState();
                    state.setLocation(bundle.getLocation());
                    state.setStatus(BundleEvent.STARTED);
                    clusterBundles.put(bundle.toString(), state);
                }
            } catch (Exception e) {
                // ignore
            }
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
            // update the cluster group
            Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
            BundleState state = new BundleState();
            state.setName(name);
            state.setLocation(location);
            state.setStatus(BundleEvent.INSTALLED);
            clusterBundles.put(name + "/" + version, state);
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

            if (key == null) {
                throw new IllegalArgumentException("Bundle " + key + " is not found in cluster group " + groupName);
            }

            BundleState state = clusterBundles.get(key);
            if (state == null) {
                throw new IllegalArgumentException("Bundle " + key + " is not found in cluster group " + groupName);
            }
            location = state.getLocation();

            // check if the bundle location is allowed outbound
            CellarSupport support = new CellarSupport();
            support.setClusterManager(this.clusterManager);
            support.setGroupManager(this.groupManager);
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

            if (key == null) {
                throw new IllegalStateException("Bundle " + key + " is not found in cluster group " + groupName);
            }

            BundleState state = clusterBundles.get(key);
            if (state == null) {
                throw new IllegalStateException("Bundle " + key + " is not found in cluster group " + groupName);
            }
            location = state.getLocation();

            // check if the bundle location is allowed
            CellarSupport support = new CellarSupport();
            support.setClusterManager(this.clusterManager);
            support.setGroupManager(this.groupManager);
            support.setConfigurationAdmin(this.configurationAdmin);
            if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
                throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
            }

            state.setStatus(BundleEvent.STARTED);
            clusterBundles.put(key, state);
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

            if (key == null) {
                throw new IllegalStateException("Bundle " + key + " is not found in cluster group " + groupName);
            }

            BundleState state = clusterBundles.get(key);
            if (state == null) {
                throw new IllegalStateException("Bundle " + key + " is not found in cluster group " + groupName);
            }
            location = state.getLocation();

            // check if the bundle location is allowed
            CellarSupport support = new CellarSupport();
            support.setClusterManager(this.clusterManager);
            support.setGroupManager(this.groupManager);
            support.setConfigurationAdmin(this.configurationAdmin);
            if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
                throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
            }

            state.setStatus(BundleEvent.STOPPED);
            clusterBundles.put(key, state);
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

                    name = tokens[0];
                    version = tokens[1];
                } else {
                    name = bundle;
                }
                BundleState state = clusterBundles.get(bundle);
                String status;
                switch (state.getStatus()) {
                    case BundleEvent.INSTALLED:
                        status = "Installed";
                        break;
                    case BundleEvent.RESOLVED:
                        status = "Resolved";
                        break;
                    case BundleEvent.STARTED:
                        status = "Active";
                        break;
                    case BundleEvent.STARTING:
                        status = "Starting";
                        break;
                    case BundleEvent.STOPPED:
                        status = "Resolved";
                        break;
                    case BundleEvent.STOPPING:
                        status = "Stopping";
                        break;
                    case BundleEvent.UNINSTALLED:
                        status = "Uninstalled";
                        break;
                    default:
                        status = "";
                        break;
                }
                CompositeData data = new CompositeDataSupport(compositeType,
                        new String[]{"id", "name", "version", "status", "location"},
                        new Object[]{id, name, version, status, state.getLocation()});
                table.put(data);
                id++;
            }
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

                // add regex support
                Pattern namePattern = Pattern.compile(name);

                // looking for bundle using only the name
                for (String bundle : clusterBundles.keySet()) {
                    BundleState state = clusterBundles.get(bundle);
                    if (state.getName() != null) {
                        // bundle name is populated, check if it matches the regex
                        Matcher matcher = namePattern.matcher(state.getName());
                        if (matcher.find()) {
                            key = bundle;
                            break;
                        } else {
                            // no match on bundle name, fall back to symbolic name and check if it matches the regex
                            String[] split = bundle.split("/");
                            matcher = namePattern.matcher(split[0]);
                            if (matcher.find()) {
                                key = bundle;
                                break;
                            }
                        }
                    } else {
                        // no bundle name, fall back to symbolic name and check if it matches the regex
                        String[] split = bundle.split("/");
                        Matcher matcher = namePattern.matcher(split[0]);
                        if (matcher.find()) {
                            key = bundle;
                            break;
                        }
                    }
                }
            }
        } else {
            // looking for the bundle using name and version

            // add regex support of the name
            Pattern namePattern = Pattern.compile(name);

            for (String bundle : clusterBundles.keySet()) {
                String[] split = bundle.split("/");
                BundleState state = clusterBundles.get(bundle);
                if (split[1].equals(version)) {
                    if (state.getName() != null) {
                        // bundle name is populated, check if it matches the regex
                        Matcher matcher = namePattern.matcher(state.getName());
                        if (matcher.find()) {
                            key = bundle;
                            break;
                        } else {
                            // no match on bundle name, fall back to symbolic name and check if it matches the regex
View Full Code Here

Examples of org.apache.karaf.cellar.bundle.BundleState

                System.out.println(String.format(OUTPUT_FORMAT, "Name", "Version", "Status", "Location"));
                for (String bundle : bundles.keySet()) {
                    String[] tokens = bundle.split("/");
                    String name = tokens[0];
                    String version = tokens[1];
                    BundleState state = bundles.get(bundle);
                    String status;
                    switch (state.getStatus()) {
                        case BundleEvent.INSTALLED:
                            status = "Installed";
                            break;
                        case BundleEvent.RESOLVED:
                            status = "Resolved";
                            break;
                        case BundleEvent.STARTED:
                            status = "Started";
                            break;
                        case BundleEvent.STARTING:
                            status = "Starting";
                            break;
                        case BundleEvent.STOPPED:
                            status = "Stopped";
                            break;
                        case BundleEvent.STOPPING:
                            status = "Stopping";
                            break;
                        case BundleEvent.UNINSTALLED:
                            status = "Uninstalled";
                            break;
                        default:
                            status = "";
                            break;
                    }
                    System.out.println(String.format(OUTPUT_FORMAT, name, version, status, state.getLocation()));
                }
            } else {
                System.err.println("No bundles found for cluster group: " + groupName);
            }
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.