Methods Summary |
---|
public static void | commitContentPrefixList()Make changes to the content prefix-list persistent.
This method throws a SecurityException if the calling thread
does not have access to system properties.
if (pm != null && mCommitContentPrefixList != null) {
runMethod(mCommitContentPrefixList, null);
}
|
public static void | commitProtocolPrefixList()Make changes to the protocol package-prefix list persistent.
This method throws a SecurityException if the calling thread
does not have access to system properties.
if (pm != null && mCommitProtocolPrefixList != null) {
runMethod(mCommitProtocolPrefixList, null);
}
|
public static java.util.Vector | getContentPrefixList()Get the current value of the content package-prefix list.
Any changes made to this list take effect immediately.
// Default value
contentPrefixList = new Vector();
contentPrefixList.addElement("javax");
contentPrefixList.addElement("com.sun");
if (pm != null && mGetContentPrefixList != null) {
return (Vector) runMethod(mGetContentPrefixList, null);
} else
return contentPrefixList;
|
static java.lang.reflect.Method | getDeclaredMethod(java.lang.Class c, java.lang.String name, java.lang.Class[] params)netscape browser throws SecurityException when you call
Class.getDeclaredMethod or Class.getDeclaredMethods
There is a privilege called UniversalMemberAccess which should
allow this call. But Netscape has disabled this privilege; they
mention this in in their security faq. So, we call getMethod and
using getDeclaringClass method, check to see if it the subclass
overrided it or not.
Note: this code is used in all cases, not just netscape
Method m = c.getMethod(name, params);
if (m.getDeclaringClass() == c) {
return m;
} else {
return null;
}
|
public static java.util.Vector | getProtocolPrefixList()Get the current value of the protocol package-prefix list.
if (pm != null && mGetProtocolPrefixList != null) {
return (Vector) runMethod(mGetProtocolPrefixList, null);
} else
return protoPrefixList;
|
private static java.lang.Object | runMethod(java.lang.reflect.Method m, java.lang.Object[] params)
// Default value
protoPrefixList = new Vector();
protoPrefixList.addElement("javax");
protoPrefixList.addElement("com.sun");
try {
Class pmClass = Class.forName("javax.media.pm.PackageManager");
if (pmClass != null) {
Object tryPM = pmClass.newInstance();
if (tryPM instanceof PackageManager) {
pm = (PackageManager) tryPM;
mGetProtocolPrefixList =
getDeclaredMethod(pmClass, "getProtocolPrefixList",
sigNone);
mSetProtocolPrefixList =
getDeclaredMethod(pmClass, "setProtocolPrefixList",
sigVector);
mCommitProtocolPrefixList =
getDeclaredMethod(pmClass, "commitProtocolPrefixList",
sigNone);
mGetContentPrefixList =
getDeclaredMethod(pmClass, "getContentPrefixList",
sigNone);
mSetContentPrefixList =
getDeclaredMethod(pmClass, "setContentPrefixList",
sigVector);
mCommitContentPrefixList =
getDeclaredMethod(pmClass, "commitContentPrefixList",
sigNone);
}
}
} catch (ClassNotFoundException cnfe) {
System.err.println(cnfe);
} catch (InstantiationException ie) {
System.err.println(ie);
} catch (IllegalAccessException iae) {
System.err.println(iae);
} catch (SecurityException se) {
System.out.println("PackageManager: SecurityException: " + se);
System.err.println(se);
} catch (NoSuchMethodException nsme) {
}
try {
return m.invoke(null, params);
} catch (IllegalAccessException iae) {
} catch (IllegalArgumentException iare) {
} catch (InvocationTargetException ite) {
}
return null;
|
public static void | setContentPrefixList(java.util.Vector list)Set the current value of the content package-prefix list.
This is required for changes to take effect.
if (pm != null && mSetContentPrefixList != null) {
Object [] params = new Object[1];
params[0] = list.clone();
runMethod(mSetContentPrefixList, params);
contentPrefixList = getContentPrefixList();
} else
contentPrefixList = (Vector)list.clone();
|
public static void | setProtocolPrefixList(java.util.Vector list)Set the protocol package-prefix list.
This is required for changes to take effect.
if (pm != null && mSetProtocolPrefixList != null) {
Object [] params = new Object[1];
params[0] = list.clone();
runMethod(mSetProtocolPrefixList, params);
protoPrefixList = getProtocolPrefixList();
} else
protoPrefixList = (Vector)list.clone();
|