Package org.rioproject.system.capability

Examples of org.rioproject.system.capability.PlatformCapability


     * @see org.rioproject.servicebean.ComputeResourceManager#getPlatformCapability
     */
    public PlatformCapability getPlatformCapability(final String name) {
        if(name == null)
            throw new IllegalArgumentException("name is null");
        PlatformCapability pCap = computeResource.getPlatformCapability(name);
        return (pCap);
    }
View Full Code Here


     */
    public static PlatformCapability createPlatformCapability(final String className, final Map<String, Object> mapping)
    throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        if(className == null)
            throw new IllegalArgumentException("className is null");
        PlatformCapability pCap;
        if(className.equals(SoftwareSupport.class.getSimpleName())) {
            pCap = new SoftwareSupport();
        } else if(className.equals(SoftwareSupport.class.getName())) {
            pCap = new SoftwareSupport();
        } else {
            CommonClassLoader cl = CommonClassLoader.getInstance();
            Class clazz = cl.loadClass(className);
            pCap = (PlatformCapability)clazz.newInstance();
        }
        if(mapping!=null)
            pCap.defineAll(mapping);
        return (pCap);
    }
View Full Code Here

             * Load default platform (qualitative) capabilities
             */
            ProcessorArchitecture processor = new ProcessorArchitecture();
            platforms.add(processor);

            PlatformCapability operatingSystem = new OperatingSystem();
            platforms.add(operatingSystem);

            PlatformCapability tcpIP = new TCPConnectivity();
            platforms.add(tcpIP);

            PlatformCapability j2se = new J2SESupport();
            platforms.add(j2se);

            List<PlatformCapability> platformCapabilityList = new ArrayList<PlatformCapability>();
            PlatformCapability[] pCaps = (PlatformCapability[])config.getEntry(COMPONENT,
                                                                               "platformCapabilities",
                                                                               PlatformCapability[].class,
                                                                               new PlatformCapability[0]);
            platformCapabilityList.addAll(Arrays.asList(pCaps));

            PlatformCapability[] addCaps = (PlatformCapability[])config.getEntry(COMPONENT,
                                                                                 "addPlatformCapabilities",
                                                                                 PlatformCapability[].class,
                                                                                 new PlatformCapability[0]);
            platformCapabilityList.addAll(Arrays.asList(addCaps));

            /*
             * Load the default capabilities
             */
            PlatformLoader loader = new PlatformLoader();
            pCaps = createPlatformCapabilities(loader.getDefaultPlatform(getRioHome()));
            platformCapabilityList.addAll(Arrays.asList(pCaps));
            /*
             * Get additional platform configurations
             */
            String platformDir = getPlatformConfigurationDirectory(config);
            if(platformDir!=null) {
                PlatformCapability[] caps = parsePlatformConfig(loader, platformDir);
                platformCapabilityList.addAll(Arrays.asList(caps));
            } else {
                logger.warn("Unable to establish the platform configuration directory, most likely RIO_HOME is not set.");
            }

            /*
             * Get the final array of PlatformCapability instances
             */
            pCaps = platformCapabilityList.toArray(new PlatformCapability[platformCapabilityList.size()]);
            for (PlatformCapability pCap : pCaps) {
                if (pCap.getClass().getName().equals(RIO)) {
                    if (getRioHome() != null) {
                        pCap.setPath(getRioHome());
                    }
                }               
                platforms.add(pCap);
            }

            /* Find out if we have loaded a StorageCapability class */               
            PlatformCapability storage = findCapability(platforms, STORAGE);
            if(storage==null) {
                storage = getPlatformCapability(STORAGE);
                platforms.add(storage);
            }

            /* Find out if we have loaded a Memory class */
            PlatformCapability memory = findCapability(platforms, MEMORY);
            if(memory == null) {
                memory = getPlatformCapability(MEMORY);
                platforms.add(memory);
            }

            /* Find out if we have loaded a SystemMemory class */
            PlatformCapability systemMemory = findCapability(platforms, SYSTEM_MEMORY);
            if(systemMemory == null) {
                systemMemory = getPlatformCapability(SYSTEM_MEMORY);
                platforms.add(systemMemory);
            }

            /* Create NativeLibrarySupport objects */
            String nativeLibDirs = System.getProperty(NATIVE_LIBS);
            List<File> dirList = new ArrayList<File>();
            if(nativeLibDirs!=null && nativeLibDirs.length()>0) {
                StringTokenizer st = new StringTokenizer(nativeLibDirs, File.pathSeparator+" ");
                while(st.hasMoreTokens()) {
                    String dirName = st.nextToken();
                    File dir = new File(dirName);
                    if(dir.isDirectory() && dir.canRead()) {
                        dirList.add(dir);
                        if(logger.isDebugEnabled())
                            logger.debug("Adding directory [{}] to check for native libraries", dirName);
                    } else {
                        logger.warn("Invalid directory name or access permissions to check for native libraries [{}]. Continuing ...",
                                    dirName);
                    }                      
                }
                final String[] libExtensions = getLibExtensions();
                File[] dirs = dirList.toArray(new File[dirList.size()]);
                for (File dir : dirs) {
                    File[] files = dir.listFiles(new FileFilter() {
                        public boolean accept(File pathName) {
                            try {
                                if(FileUtils.isSymbolicLink(pathName)) {
                                    return false;
                                }
                            } catch (IOException e) {
                                logger.warn( "Trying to determine whether the file is a symbolic link", e);
                            }
                            boolean matches = false;
                            for(String libExtension : libExtensions) {
                                if(pathName.getName().endsWith(libExtension)) {
                                    matches = true;
                                    break;
                                }
                            }
                            return matches;
                        }
                    });

                    for (File file : files) {
                        String fileName = file.getName();
                        int index = fileName.lastIndexOf(".");
                        if (index != -1) {
                            if (logger.isDebugEnabled())
                                logger.debug("Create NativeLibrarySupport object for [{}]", fileName);
                            PlatformCapability nLib = getPlatformCapability(NATIVE_LIB_CLASS);
                            String name;
                            /*if (!OperatingSystemType.isWindows()) {
                                name = fileName.substring(3, index);
                            } else {*/
                            name = fileName.substring(0, index);
                            //}
                            nLib.define(NativeLibrarySupport.NAME, name);
                            nLib.define(NativeLibrarySupport.FILENAME, fileName);
                            nLib.setPath(dir.getCanonicalPath());
                            platforms.add(nLib);
                        } else {
                            logger.warn("Illegal Shared Library name="+fileName);
                        }
                    }
View Full Code Here

    /*
     * Determine if a class has been loaded
     */
    private PlatformCapability findCapability(List<PlatformCapability> pCaps, String name) {
        PlatformCapability o = null;
        for(PlatformCapability pCap : pCaps) {
            if(pCap.getClass().getName().equals(name)) {
                o = pCap;
                break;
            }
View Full Code Here

                attrs.put(PlatformCapability.DESCRIPTION, caps[i].getDescription());
            if(caps[i].getManufacturer()!=null)
                attrs.put(PlatformCapability.MANUFACTURER, caps[i].getManufacturer());
            if(caps[i].getVersion()!=null)
                attrs.put(PlatformCapability.VERSION, caps[i].getVersion());
            PlatformCapability pCap = (PlatformCapability)Class.forName(caps[i].getPlatformClass()).newInstance();
            pCap.defineAll(attrs);
            if(caps[i].getClasspath()!=null)
                pCap.setClassPath(caps[i].getClasspath());
            if(caps[i].getPath()!=null)
                pCap.setPath(caps[i].getPath());
            if(caps[i].geCostModelClass()!=null) {
                ResourceCostModel costModel = (ResourceCostModel)Class.forName(caps[i].geCostModelClass()).newInstance();
                pCap.setResourceCostModel(costModel);
            }
            PlatformCapabilityLoader.getLoadableClassPath(pCap);
            pCaps[i] = pCap;
        }
        return(pCaps);
View Full Code Here

    public void testWrite() throws Exception {
        String cwd = System.getProperty("user.dir");
        File target = new File(cwd, "target");
        File platform = new File(target, "platform-file");
        platform.mkdirs();
        PlatformCapability pCap = new PlatformCapability();
        pCap.define(PlatformCapability.NAME, "Foo");
        pCap.define(PlatformCapability.VERSION, "1.0");
        pCap.setClassPath(new String[]{cwd+File.separator+"target"+File.separator+"classes"+File.separator});
        PlatformCapabilityWriter writer = new PlatformCapabilityWriter();
        String fileName = writer.write(pCap, platform.getPath());
        Assert.assertNotNull(fileName);
        PlatformLoader platformLoader = new PlatformLoader();
        PlatformCapabilityConfig[] pCapConfigs = platformLoader.parsePlatform(platform.getPath());
View Full Code Here

            if (className == null) {
                Map<String, String> pCapMap =
                    computeResource.getPlatformCapabilityNameTable();
                className = pCapMap.get(sysComp.getName());
            }
            PlatformCapability pCap = DefaultServiceBeanContext.createPlatformCapability(className,
                                                                                         sysComp.getAttributes());
            installedPlatformCapabilities.add(pCap);
            StagedSoftware staged = sysComp.getStagedSoftware();
            if(staged!=null) {
                DownloadRecord[] dlRecs = computeResource.provision(pCap, staged);
View Full Code Here

            super();
        }

        public Object getValueAt(int index, int columnIndex) {
            try {
                PlatformCapability pCap = tableData.elementAt(index);
                if(columnIndex==0) {
                    return (pCap.getValue(PlatformCapability.NAME));
                } else if(columnIndex==1) {
                    return(pCap.getDescription());
                } else {
                    return null;
                }
            } catch(Exception e) {
                e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.rioproject.system.capability.PlatformCapability

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.