예제 #1
0
 XPathSupport getXPathSupport() {
   if (jaxenXPathSupport != null) {
     return jaxenXPathSupport;
   }
   XPathSupport xps = null;
   Document doc = node.getOwnerDocument();
   if (doc == null) {
     doc = (Document) node;
   }
   synchronized (doc) {
     WeakReference ref = (WeakReference) xpathSupportMap.get(doc);
     if (ref != null) {
       xps = (XPathSupport) ref.get();
     }
     if (xps == null) {
       try {
         xps = (XPathSupport) xpathSupportClass.newInstance();
         xpathSupportMap.put(doc, new WeakReference(xps));
       } catch (Exception e) {
         logger.error("Error instantiating xpathSupport class", e);
       }
     }
   }
   return xps;
 }
예제 #2
0
  @SuppressWarnings("unchecked")
  Object getPrincipalFromClassName(Map params) {
    String type = this.getType(params);

    try {
      Class cls = Class.forName(type);

      return getSubject().getPrincipals().oneByType(cls);
    } catch (ClassNotFoundException ex) {
      log.error("Unable to find class for name [" + type + "]", ex);
    }

    return null;
  }
 private static ExpressionFactory tryExpressionFactoryImplementation(String packagePrefix) {
   String className = packagePrefix + ".el.ExpressionFactoryImpl";
   try {
     Class cl = ClassUtil.forName(className);
     if (ExpressionFactory.class.isAssignableFrom(cl)) {
       logger.info(
           "Using " + className + " as implementation of " + ExpressionFactory.class.getName());
       return (ExpressionFactory) cl.newInstance();
     }
     logger.warn(
         "Class " + className + " does not implement " + ExpressionFactory.class.getName());
   } catch (ClassNotFoundException e) {
   } catch (Exception e) {
     logger.error("Failed to instantiate " + className, e);
   }
   return null;
 }