Package org.rhq.core.clientapi.agent

Examples of org.rhq.core.clientapi.agent.PluginContainerException


                // Wrap the component in a proxy that will provide locking and a timeout for the call to start().
                component = container.createResourceComponentProxy(ResourceComponent.class, FacetLockType.READ,
                    COMPONENT_START_TIMEOUT, true, false, true);
            } catch (Throwable t) {
                container.setResourceComponentState(ResourceComponentState.STOPPED);
                throw new PluginContainerException("Failed getting proxy for resource " + resource + ".", t);
            }

            try {
                component.start(context);
                container.setResourceComponentState(ResourceComponentState.STARTED);
                resource.setConnected(true); // This tells the server-side that the resource has connected successfully.

            } catch (Throwable t) {
                // Don't leave in a STARTING state. Don't actually call component.stop(),
                // because we're not actually STARTED
                container.setResourceComponentState(ResourceComponentState.STOPPED);

                StringBuilder messageBuilder = new StringBuilder("Failed to start component for ").append(resource);
                if (isNotBlank(t.getMessage())) {
                    messageBuilder.append(" - ").append(t.getMessage());
                }
                if (t.getCause() != null) {
                    messageBuilder.append(" - Cause: ").append(t.getClass().getName());
                    if (isNotBlank(t.getCause().getMessage())) {
                        messageBuilder.append(": ").append(t.getCause().getMessage());
                    }
                }
                String message = messageBuilder.toString();

                if (updatedPluginConfig || (t instanceof InvalidPluginConfigurationException)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Resource has a bad config, waiting for this to go away: " + resource);
                    }
                    InventoryEventListener iel = new ResourceGotActivatedListener();
                    addInventoryEventListener(iel);

                    throw new InvalidPluginConfigurationException(message);
                }

                throw new PluginContainerException(message);
            }

            // We purposefully do not get availability of this resource yet
            // We need availability checked during the normal availability executor timeframe.
            // Otherwise, new resources will not have their availabilities shipped up to the server because
View Full Code Here


            ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);
                overseer.initialize(context);
            } catch (Throwable t) {
                throw new PluginContainerException("Plugin Lifecycle Listener failed to initialize plugin", t);
            } finally {
                Thread.currentThread().setContextClassLoader(originalContextClassLoader);
            }
        }
View Full Code Here

     */
    public <T> T createResourceComponentProxy(Class<T> facetInterface, FacetLockType lockType, long timeout,
        boolean daemonThread, boolean onlyIfStarted, boolean transferInterrupt) throws PluginContainerException {
        if (onlyIfStarted) {
            if (!ResourceComponentState.STARTED.equals(getResourceComponentState())) {
                throw new PluginContainerException("Resource component could not be retrieved for resource ["
                    + getResource() + "] because the component is not started. Its state is ["
                    + getResourceComponentState() + "]");
            }
        }

        ResourceComponent resourceComponent = this.getResourceComponent();

        if (resourceComponent == null) {
            throw new PluginContainerException("Component does not exist for resource: " + getResource());
        }

        if (!(facetInterface.isAssignableFrom(resourceComponent.getClass()))) {
            throw new PluginContainerException("Component does not support the [" + facetInterface.getName()
                + "] interface: " + this);
        }

        // If no locking is required and there is no timeout, there is no need for a proxy - return the actual component.
        if (lockType == FacetLockType.NONE && timeout == 0) {
View Full Code Here

        try {
            Class<?> clazz = Class.forName(className, true, loader);
            log.debug("Loaded class [" + clazz + "].");
            return clazz.newInstance();
        } catch (InstantiationException e) {
            throw new PluginContainerException("Could not instantiate plugin class [" + className
                + "] from plugin environment [" + environment + "]", e);
        } catch (IllegalAccessException e) {
            throw new PluginContainerException("Could not access plugin class " + className
                + "] from plugin environment [" + environment + "]", e);
        } catch (ClassNotFoundException e) {
            throw new PluginContainerException("Could not find plugin class " + className
                + "] from plugin environment [" + environment + "]", e);
        } catch (NullPointerException npe) {
            throw new PluginContainerException("Plugin class was 'null' in plugin environment [" + environment + "]",
                npe);
        }
    }
View Full Code Here

            // purge all resources from disabled plugins
            removeIgnoredResourcesFromChildren(this.platform, uuidsToIgnore);
            return;
        } catch (Exception e) {
            throw new PluginContainerException("Cannot load inventory file: " + inventoryFile, e);
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (Exception e) {
View Full Code Here

    private final KeyTypePlugin resourceKeyTypePlugin;
    private final List<KeyTypePlugin> ancestorKeyTypePlugins;

    public CanonicalResourceKey(Resource resource, Resource parent) throws PluginContainerException {
        if (resource == null) {
            throw new PluginContainerException("resource must not be null");
        }
        if (parent == null) {
            throw new PluginContainerException("parent must not be null");
        }

        this.resourceKeyTypePlugin = new KeyTypePlugin(resource.getResourceKey(), resource.getResourceType());

        this.ancestorKeyTypePlugins = new ArrayList<KeyTypePlugin>(5);
View Full Code Here

        public final String type;
        public final String plugin;

        KeyTypePlugin(String key, ResourceType type) throws PluginContainerException {
            if (key == null) {
                throw new PluginContainerException("key must not be null");
            }
            if (type == null) {
                throw new PluginContainerException("type must not be null");
            }
            if (type.getName() == null) {
                throw new PluginContainerException("type name must not be null");
            }
            if (type.getPlugin() == null) {
                throw new PluginContainerException("plugin must not be null");
            }
            this.key = key.intern();
            this.type = type.getName().intern();
            this.plugin = type.getPlugin().intern();
        }
View Full Code Here

     */
    public synchronized ClassLoader obtainResourceClassLoader(Resource resource, ResourceContainer parent,
        List<URL> additionalJars) throws PluginContainerException {

        if (resource == null) {
            throw new PluginContainerException("resource must not be null");
        }
        if (parent == null) {
            throw new PluginContainerException("parent must not be null");
        }

        CanonicalResourceKey mapKey = new CanonicalResourceKey(resource, parent.getResource());
        ClassLoader resourceCL = this.resourceClassLoaders.get(mapKey);
        if (resourceCL == null) {
View Full Code Here

            // This is the proxy that will look like the discovery component object that the caller will use.
            T proxy = (T) Proxy.newProxyInstance(pluginClassLoader, new Class<?>[] { componentInterface }, handler);
            return proxy;

        } catch (Throwable t) {
            throw new PluginContainerException("Cannot get discovery component proxy for [" + component + "]", t);
        }
    }
View Full Code Here

            runner = new UpdateResourceConfigurationRunner(configurationServerService, resourceType, configMgmt,
                request);

            response = getThreadPool().submit(runner).get();
        } catch (Exception e) {
            throw new PluginContainerException("Error occurred in delete resource thread", e);
        }

        return response;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.agent.PluginContainerException

Copyright © 2018 www.massapicom. 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.