com.sun.org.apache.xalan.internal.utils.ObjectFactory Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.utils.ObjectFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FuncSystemProperty.java    From TencentKona-8 with GNU General Public License v2.0 7 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #2
Source File: EnvironmentCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report product version information from Ant.
 *
 * @param h Map to put information in
 */
protected void checkAntVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  try
  {
    final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main";
    final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs
    final Class noArgs[] = new Class[0];

    Class clazz = ObjectFactory.findProviderClass(ANT_VERSION_CLASS, true);

    Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs);
    Object returnValue = method.invoke(null, new Object[0]);

    h.put(VERSION + "ant", (String)returnValue);
  }
  catch (Exception e)
  {
    h.put(VERSION + "ant", CLASS_NOTPRESENT);
  }
}
 
Example #3
Source File: EnvironmentCheck.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report product version information from Ant.
 *
 * @param h Map to put information in
 */
protected void checkAntVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  try
  {
    final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main";
    final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs
    final Class noArgs[] = new Class[0];

    Class clazz = ObjectFactory.findProviderClass(ANT_VERSION_CLASS, true);

    Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs);
    Object returnValue = method.invoke(null, new Object[0]);

    h.put(VERSION + "ant", (String)returnValue);
  }
  catch (Exception e)
  {
    h.put(VERSION + "ant", CLASS_NOTPRESENT);
  }
}
 
Example #4
Source File: EnvironmentCheck.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Report version information about JAXP interfaces.
 *
 * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
 * and not found; only tests the interfaces, and does not
 * check for reference implementation versions.
 *
 * @param h Map to put information in
 */
protected void checkJAXPVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  Class clazz = null;

  try
  {
    final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";

    clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, true);

    // If we succeeded, we have JAXP 1.4 available
    h.put(VERSION + "JAXP", "1.4");
  }
  catch (Exception e)
  {
      h.put(ERROR + VERSION + "JAXP", "1.3");
      h.put(ERROR, ERROR_FOUND);
    }
    }
 
Example #5
Source File: EnvironmentCheck.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version information about JAXP interfaces.
 *
 * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
 * and not found; only tests the interfaces, and does not
 * check for reference implementation versions.
 *
 * @param h Map to put information in
 */
protected void checkJAXPVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  Class clazz = null;

  try
  {
    final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";

    clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, true);

    // If we succeeded, we have JAXP 1.4 available
    h.put(VERSION + "JAXP", "1.4");
  }
  catch (Exception e)
  {
      h.put(ERROR + VERSION + "JAXP", "1.3");
      h.put(ERROR, ERROR_FOUND);
    }
    }
 
Example #6
Source File: FuncLoader.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #7
Source File: FuncSystemProperty.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #8
Source File: FuncLoader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #9
Source File: FuncSystemProperty.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #10
Source File: FuncLoader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #11
Source File: EnvironmentCheck.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Report version information about JAXP interfaces.
 *
 * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
 * and not found; only tests the interfaces, and does not
 * check for reference implementation versions.
 *
 * @param h Map to put information in
 */
protected void checkJAXPVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  Class clazz = null;

  try
  {
    final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";

    clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, true);

    // If we succeeded, we have JAXP 1.4 available
    h.put(VERSION + "JAXP", "1.4");
  }
  catch (Exception e)
  {
      h.put(ERROR + VERSION + "JAXP", "1.3");
      h.put(ERROR, ERROR_FOUND);
    }
    }
 
Example #12
Source File: EnvironmentCheck.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Report product version information from Ant.
 *
 * @param h Map to put information in
 */
protected void checkAntVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  try
  {
    final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main";
    final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs
    final Class noArgs[] = new Class[0];

    Class clazz = ObjectFactory.findProviderClass(ANT_VERSION_CLASS, true);

    Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs);
    Object returnValue = method.invoke(null, new Object[0]);

    h.put(VERSION + "ant", (String)returnValue);
  }
  catch (Exception e)
  {
    h.put(VERSION + "ant", CLASS_NOTPRESENT);
  }
}
 
Example #13
Source File: EnvironmentCheck.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Report version info from DOM interfaces.
 *
 * @param h Map to put information in
 */
protected boolean checkDOML3(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  final String DOM_CLASS = "org.w3c.dom.Document";
  final String DOM_LEVEL3_METHOD = "getDoctype";  // no parameter

  try
  {
    Class clazz = ObjectFactory.findProviderClass(DOM_CLASS, true);

    Method method = clazz.getMethod(DOM_LEVEL3_METHOD, (Class<?>[])null);

    // If we succeeded, we have loaded interfaces from a
    //  level 3 DOM somewhere
    h.put(VERSION + "DOM", "3.0");
    return true;
  }
  catch (Exception e)
  {
    return false;
  }
}
 
Example #14
Source File: FuncSystemProperty.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #15
Source File: EnvironmentCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version information about JAXP interfaces.
 *
 * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
 * and not found; only tests the interfaces, and does not
 * check for reference implementation versions.
 *
 * @param h Map to put information in
 */
protected void checkJAXPVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  Class clazz = null;

  try
  {
    final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";

    clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, true);

    // If we succeeded, we have JAXP 1.4 available
    h.put(VERSION + "JAXP", "1.4");
  }
  catch (Exception e)
  {
      h.put(ERROR + VERSION + "JAXP", "1.3");
      h.put(ERROR, ERROR_FOUND);
    }
    }
 
Example #16
Source File: EnvironmentCheck.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Report product version information from Ant.
 *
 * @param h Map to put information in
 */
protected void checkAntVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  try
  {
    final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main";
    final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs
    final Class noArgs[] = new Class[0];

    Class clazz = ObjectFactory.findProviderClass(ANT_VERSION_CLASS, true);

    Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs);
    Object returnValue = method.invoke(null, new Object[0]);

    h.put(VERSION + "ant", (String)returnValue);
  }
  catch (Exception e)
  {
    h.put(VERSION + "ant", CLASS_NOTPRESENT);
  }
}
 
Example #17
Source File: EnvironmentCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version info from DOM interfaces.
 *
 * @param h Map to put information in
 */
protected boolean checkDOML3(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  final String DOM_CLASS = "org.w3c.dom.Document";
  final String DOM_LEVEL3_METHOD = "getDoctype";  // no parameter

  try
  {
    Class clazz = ObjectFactory.findProviderClass(DOM_CLASS, true);

    Method method = clazz.getMethod(DOM_LEVEL3_METHOD, (Class<?>[])null);

    // If we succeeded, we have loaded interfaces from a
    //  level 3 DOM somewhere
    h.put(VERSION + "DOM", "3.0");
    return true;
  }
  catch (Exception e)
  {
    return false;
  }
}
 
Example #18
Source File: FuncSystemProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #19
Source File: FuncLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #20
Source File: EnvironmentCheck.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version information about JAXP interfaces.
 *
 * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
 * and not found; only tests the interfaces, and does not
 * check for reference implementation versions.
 *
 * @param h Map to put information in
 */
protected void checkJAXPVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  Class clazz = null;

  try
  {
    final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";

    clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, true);

    // If we succeeded, we have JAXP 1.4 available
    h.put(VERSION + "JAXP", "1.4");
  }
  catch (Exception e)
  {
      h.put(ERROR + VERSION + "JAXP", "1.3");
      h.put(ERROR, ERROR_FOUND);
    }
    }
 
Example #21
Source File: EnvironmentCheck.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report product version information from Ant.
 *
 * @param h Map to put information in
 */
protected void checkAntVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  try
  {
    final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main";
    final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs
    final Class noArgs[] = new Class[0];

    Class clazz = ObjectFactory.findProviderClass(ANT_VERSION_CLASS, true);

    Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs);
    Object returnValue = method.invoke(null, new Object[0]);

    h.put(VERSION + "ant", (String)returnValue);
  }
  catch (Exception e)
  {
    h.put(VERSION + "ant", CLASS_NOTPRESENT);
  }
}
 
Example #22
Source File: EnvironmentCheck.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version info from DOM interfaces.
 *
 * @param h Map to put information in
 */
protected boolean checkDOML3(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  final String DOM_CLASS = "org.w3c.dom.Document";
  final String DOM_LEVEL3_METHOD = "getDoctype";  // no parameter

  try
  {
    Class clazz = ObjectFactory.findProviderClass(DOM_CLASS, true);

    Method method = clazz.getMethod(DOM_LEVEL3_METHOD, (Class<?>[])null);

    // If we succeeded, we have loaded interfaces from a
    //  level 3 DOM somewhere
    h.put(VERSION + "DOM", "3.0");
    return true;
  }
  catch (Exception e)
  {
    return false;
  }
}
 
Example #23
Source File: FuncSystemProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #24
Source File: FuncLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #25
Source File: FuncLoader.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #26
Source File: FuncLoader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}
 
Example #27
Source File: EnvironmentCheck.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version information about JAXP interfaces.
 *
 * Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
 * and not found; only tests the interfaces, and does not
 * check for reference implementation versions.
 *
 * @param h Map to put information in
 */
protected void checkJAXPVersion(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  Class clazz = null;

  try
  {
    final String JAXP1_CLASS = "javax.xml.stream.XMLStreamConstants";

    clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, true);

    // If we succeeded, we have JAXP 1.4 available
    h.put(VERSION + "JAXP", "1.4");
  }
  catch (Exception e)
  {
      h.put(ERROR + VERSION + "JAXP", "1.3");
      h.put(ERROR, ERROR_FOUND);
    }
    }
 
Example #28
Source File: EnvironmentCheck.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Report version info from DOM interfaces.
 *
 * @param h Map to put information in
 */
protected boolean checkDOML3(Map<String, Object> h)
{

  if (null == h)
    h = new HashMap<>();

  final String DOM_CLASS = "org.w3c.dom.Document";
  final String DOM_LEVEL3_METHOD = "getDoctype";  // no parameter

  try
  {
    Class clazz = ObjectFactory.findProviderClass(DOM_CLASS, true);

    Method method = clazz.getMethod(DOM_LEVEL3_METHOD, (Class<?>[])null);

    // If we succeeded, we have loaded interfaces from a
    //  level 3 DOM somewhere
    h.put(VERSION + "DOM", "3.0");
    return true;
  }
  catch (Exception e)
  {
    return false;
  }
}
 
Example #29
Source File: FuncSystemProperty.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example #30
Source File: FuncLoader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a Function instance that this instance is liaisoning for.
 *
 * @return non-null reference to Function derivative.
 *
 * @throws javax.xml.transform.TransformerException if ClassNotFoundException,
 *    IllegalAccessException, or InstantiationException is thrown.
 */
Function getFunction() throws TransformerException
{
  try
  {
    String className = m_funcName;
    if (className.indexOf(".") < 0) {
      className = "com.sun.org.apache.xpath.internal.functions." + className;
    }
    //hack for loading only built-in function classes.
    String subString = className.substring(0,className.lastIndexOf('.'));
    if(!(subString.equals ("com.sun.org.apache.xalan.internal.templates") ||
         subString.equals ("com.sun.org.apache.xpath.internal.functions"))) {
          throw new TransformerException("Application can't install his own xpath function.");
    }

    return (Function) ObjectFactory.newInstance(className, true);

  }
  catch (ConfigurationError e)
  {
    throw new TransformerException(e.getException());
  }
}