EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.bindings.platform_sdk.component_services]

COVERAGE SUMMARY FOR SOURCE FILE [ComClassPathBuilder.java]

nameclass, %method, %block, %line, %
ComClassPathBuilder.java100% (1/1)100% (7/7)81%  (116/144)94%  (23.6/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComClassPathBuilder100% (1/1)100% (7/7)81%  (116/144)94%  (23.6/25)
addPaths (SortedMap, Preferences): void 100% (1/1)62%  (36/58)88%  (7/8)
userNodeForGroup (String): Preferences 100% (1/1)64%  (9/14)82%  (1.6/2)
<static initializer> 100% (1/1)92%  (11/12)91%  (0.9/1)
ComClassPathBuilder (String): void 100% (1/1)100% (11/11)100% (4/4)
buildClassPath (): URL [] 100% (1/1)100% (21/21)100% (4/4)
findNode (Preferences, String): Preferences 100% (1/1)100% (14/14)100% (4/4)
systemNodeForGroup (String): Preferences 100% (1/1)100% (14/14)100% (2/2)

1/*
2 * $Id: ComClassPathBuilder.java,v 1.3 2006/02/01 18:54:35 adamp Exp $
3 *
4 * (c) Copyright, Moebius Solutions, Inc., 2004
5 *
6 *                       All Rights Reserved
7 *
8 * This material may be reproduced by or for the U. S. Government
9 * pursuant to the copyright license under the clause at
10 * DFARS 252.227-7014 (OCT 2001).
11 */
12package com.moesol.bindings.platform_sdk.component_services;
13 
14import java.io.File;
15import java.net.MalformedURLException;
16import java.net.URL;
17import java.util.SortedMap;
18import java.util.TreeMap;
19import java.util.logging.Level;
20import java.util.logging.Logger;
21import java.util.prefs.BackingStoreException;
22import java.util.prefs.Preferences;
23 
24/**
25 * Build a class path array suitable for URLClassLoader from the system
26 * preferences and user preferences. If a component is installed only for the
27 * current user then these classpath values will only be in the user
28 * preferences, otherwise they will be in the system preferences. Here, we
29 * search both.
30 * 
31 * @author Hastings
32 */
33public class ComClassPathBuilder {
34        private final Preferences m_sys;
35        private final Preferences m_user;
36        
37        private static Logger s_logger = Logger.getLogger(ComClassPathBuilder.class.getName());
38        
39        public ComClassPathBuilder(String group_name) {
40                m_sys = systemNodeForGroup(group_name);
41                m_user = userNodeForGroup(group_name);
42        }
43        
44        public static Preferences systemNodeForGroup(String group_name) {
45                Preferences sys = Preferences.systemNodeForPackage(COM.class);
46                return findNode(sys, group_name);
47        }
48        
49        public static Preferences userNodeForGroup(String group_name) {
50                Preferences sys = Preferences.userNodeForPackage(COM.class);
51                return findNode(sys, group_name);
52        }
53        
54        private static Preferences findNode(Preferences pkg_root, String group_name) {
55                Preferences in_proc = pkg_root.node("com_inproc_groups");
56                Preferences group = in_proc.node(group_name); 
57                Preferences classpath = group.node("classpath");
58                return classpath;
59        }
60 
61        public URL[] buildClassPath() throws BackingStoreException, MalformedURLException {
62                SortedMap map = new TreeMap();
63                addPaths(map, m_sys);
64                addPaths(map, m_user);
65                return (URL[])map.values().toArray(new URL[0]);
66        }
67        
68        private void addPaths(SortedMap map, Preferences node) throws BackingStoreException, MalformedURLException {
69                String[] keys = node.keys();
70                for (int i = 0; i < keys.length; i++) {
71                        if (s_logger.isLoggable(Level.FINE)) {
72                                s_logger.log(Level.FINE, "Adding Path: " + keys[i] + " value: " + node.get(keys[i], null));
73                        }
74                        File f = new File(node.get(keys[i], null));
75                        URL url = f.toURL();
76                        map.put(keys[i], url);
77                }
78        }
79}

[all classes][com.moesol.bindings.platform_sdk.component_services]
EMMA 2.0.5312 (C) Vladimir Roubtsov