Package org.rhq.core.pluginapi.inventory

Examples of org.rhq.core.pluginapi.inventory.ResourceComponent


            }

            return false;
        }

        ResourceComponent component = container.getResourceComponent();
        ResourceComponentState state = container.getResourceComponentState();

        // state is a transient field, so reinitialize it just in case this is invoked just after loadFromDisk()
        if (state == null) {
            container.setResourceComponentState(ResourceComponentState.STOPPED);
View Full Code Here


        if (prepareResourceForActivation(resource, container, updatedPluginConfig)) {
            container.setResourceComponentState(ResourceComponentState.STARTING);

            ResourceContext context;
            ResourceComponent component;

            try {
                context = container.getResourceContext();

                // 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(),
View Full Code Here

    @NotNull
    Set<Resource> executeComponentDiscovery(ResourceType resourceType, ResourceDiscoveryComponent discoveryComponent,
        ResourceContainer parentContainer, List<ProcessScanResult> processScanResults) {

        ResourceContext parentResourceContext = parentContainer.getResourceContext();
        ResourceComponent parentComponent = parentContainer.getResourceComponent();
        Resource parentResource = parentContainer.getResource();

        long startTime = System.currentTimeMillis();
        if (log.isDebugEnabled()) {
            log.debug("Executing discovery for [" + resourceType.getName() + "] Resources...");
View Full Code Here

            }

            PluginComponentFactory componentFactory = PluginContainer.getInstance().getPluginComponentFactory();
            InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager();
            ResourceContainer platformContainer = inventoryManager.getResourceContainer(inventoryManager.getPlatform());
            ResourceComponent platformComponent = inventoryManager.getResourceComponent(inventoryManager.getPlatform());
            ResourceDiscoveryComponent discoveryComponent = componentFactory.getDiscoveryComponent(resourceType,
                platformContainer);

            ResourceDiscoveryContext context = new ResourceDiscoveryContext(resourceType, platformComponent,
                platformContainer.getResourceContext(), systemInfo, scanResults, Collections.EMPTY_LIST, pcName,
View Full Code Here

                    + 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.
View Full Code Here

            return proxy;
        }
    }

    public boolean supportsFacet(Class facetInterface) {
        ResourceComponent thisComponent = this.getResourceComponent();
        if (thisComponent == null) {
            return false;
        }
        return facetInterface.isAssignableFrom(thisComponent.getClass());

    }
View Full Code Here

                if (pluginClassLoader == null) {
                    throw new IllegalStateException("No plugin class loader was specified for " + this + ".");
                }
                thread.setContextClassLoader(pluginClassLoader);
                // This is the actual call into the resource component's facet interface.
                ResourceComponent resourceComponent = this.resourceContainer.getResourceComponent();
                return this.method.invoke(resourceComponent, this.args);
            } catch (InvocationTargetException e) {
                Throwable cause = e.getCause();
                //noinspection ThrowableInstanceNeverThrown
                throw (cause instanceof Exception) ? (Exception) cause : new Exception(cause);
View Full Code Here

    public ResourceComponent buildResourceComponent(Resource resource) throws PluginContainerException,
        ResourceTypeNotEnabledException {

        ResourceType resourceType = resource.getResourceType();
        if (PluginMetadataManager.TEST_PLATFORM_TYPE.equals(resourceType)) {
            return new ResourceComponent() {
                public AvailabilityType getAvailability() {
                    return AvailabilityType.UP;
                }

                public void start(ResourceContext context) {
                }

                public void stop() {
                }
            };
        }
        String className = pluginManager.getMetadataManager().getComponentClass(resourceType);
        ResourceContainer resourceContainer = inventoryManager.getResourceContainer(resource);
        if (resourceContainer == null) {
            throw new PluginContainerException("Resource container not found for " + resource + " - cannot create ResourceComponent.");
        }
        ClassLoader resourceClassloader = resourceContainer.getResourceClassLoader();
        if (resourceClassloader == null) {
            throw new PluginContainerException("Resource classLoader not found for " + resource + " - cannot create ResourceComponent.");
        }
        ResourceComponent component = (ResourceComponent) instantiateClass(resourceClassloader, className);

        if (log.isDebugEnabled()) {
            log.debug("Created resource component [" + className + "] of resource type [" + resourceType + ']');
        }
        return component;
View Full Code Here

            LOG.debug("SUCCESS!");
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("Testing proxy call that should fail...");
        }
        ResourceComponent naughtyResourceComponent = new MockResourceComponent(true);
        resourceContainer.setResourceComponent(naughtyResourceComponent);
        resourceComponentProxy = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
            FacetLockType.NONE, Long.MAX_VALUE, true, false, true);
        try {
            resourceComponentProxy.getAvailability();
View Full Code Here

        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        ResourceContainer resourceContainer = new ResourceContainer(resource, contextClassLoader);
        ResourceContext resourceContext = new ResourceContext(resource, null, null, null, null, null, null, null, null,
                null, null, null, null, null, new ComponentInvocationContextImpl());
        resourceContainer.setResourceContext(resourceContext);
        ResourceComponent resourceComponent = new MockResourceComponent(false);
        resourceContainer.setResourceComponent(resourceComponent);
        resourceComponent.start(resourceContext);
        return resourceContainer;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.inventory.ResourceComponent

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.