/** * The TypeReference class is a sun specific class that is found in two different locations * depending on environment. In IBM JDK the class is not available at all. So we have to load it * at runtime. * * @param n * @param cls * @return initiated TypeReference */ private static Object createTypeReference(QName n, Class<?> cls) { Class<?> refClass = null; try { refClass = ClassLoaderUtils.loadClass( "com.sun.xml.bind.api.TypeReference", JAXBContextInitializer.class); } catch (Throwable ex) { try { refClass = ClassLoaderUtils.loadClass( "com.sun.xml.internal.bind.api.TypeReference", JAXBContextInitializer.class); } catch (Throwable ex2) { // ignore } } if (refClass != null) { try { return refClass .getConstructor(QName.class, Type.class, new Annotation[0].getClass()) .newInstance(n, cls, new Annotation[0]); } catch (Throwable e) { // ignore } } return null; }
private static UserOperation getOperationFromElement(Element e) { UserOperation op = new UserOperation(); op.setName(e.getAttribute("name")); op.setVerb(e.getAttribute("verb")); op.setPath(e.getAttribute("path")); op.setOneway(Boolean.parseBoolean(e.getAttribute("oneway"))); op.setConsumes(e.getAttribute("consumes")); op.setProduces(e.getAttribute("produces")); List<Element> paramEls = DOMUtils.findAllElementsByTagNameNS(e, "http://cxf.apache.org/jaxrs", "param"); List<Parameter> params = new ArrayList<Parameter>(paramEls.size()); for (int i = 0; i < paramEls.size(); i++) { Element paramEl = paramEls.get(i); Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name")); p.setEncoded(Boolean.valueOf(paramEl.getAttribute("encoded"))); p.setDefaultValue(paramEl.getAttribute("defaultValue")); String pClass = paramEl.getAttribute("class"); if (!StringUtils.isEmpty(pClass)) { try { p.setJavaType(ClassLoaderUtils.loadClass(pClass, ResourceUtils.class)); } catch (Exception ex) { throw new RuntimeException(ex); } } params.add(p); } op.setParameters(params); return op; }
private static Class<?> loadClass(String cName) { try { return ClassLoaderUtils.loadClass(cName.trim(), ResourceUtils.class); } catch (ClassNotFoundException ex) { throw new RuntimeException("No class " + cName.trim() + " can be found", ex); } }
public JaxWsWebServicePublisherBeanPostProcessor() throws SecurityException, NoSuchMethodException, ClassNotFoundException { try { servletClass = ClassLoaderUtils.loadClass(CXF_SERVLET_CLASS_NAME, getClass()); } catch (ClassNotFoundException e) { Message message = new Message("SERVLET_CLASS_MISSING", LOG, CXF_SERVLET_CLASS_NAME); LOG.severe(message.toString()); throw e; } servletGetBusMethod = servletClass.getMethod("getBus"); }
static { Class<?> cls = SpringEndpointImpl.class; try { if (ProviderImpl.isJaxWs22()) { cls = ClassLoaderUtils.loadClass( "org.apache.cxf.jaxws22.spring.JAXWS22SpringEndpointImpl", EndpointDefinitionParser.class); } } catch (Throwable t) { cls = SpringEndpointImpl.class; } EP_CLASS = cls; }
static { boolean b = false; try { // JAX-WS 2.2 would have the HttpContext class in the classloader Class<?> cls = ClassLoaderUtils.loadClass("javax.xml.ws.spi.http.HttpContext", ProviderImpl.class); // In addition to that, the Endpoint class we pick up on the classloader // should have a publish method that uses it. Otherwise, we MAY be // be getting the HttpContext from the 2.2 jaxws-api jar, but the Endpoint // class from the 2.1 JRE Method m = Endpoint.class.getMethod("publish", cls); b = m != null; } catch (Throwable ex) { b = false; } JAXWS_22 = b; }
public void initializeRhino() { rhinoContextFactory = new ContextFactory(); if (System.getProperty("cxf.jsdebug") != null && !rhinoDebuggerUp) { try { Class<?> debuggerMain = ClassLoaderUtils.loadClass("org.mozilla.javascript.tools.debugger.Main", getClass()); if (debuggerMain != null) { Method mainMethod = debuggerMain.getMethod( "mainEmbedded", ContextFactory.class, Scriptable.class, String.class); mainMethod.invoke(null, rhinoContextFactory, rhinoScope, "Debug embedded JavaScript."); rhinoDebuggerUp = true; } } catch (Exception e) { LOG.log(Level.WARNING, "Failed to launch Rhino debugger", e); } } rhinoContext = rhinoContextFactory.enterContext(); rhinoScope = rhinoContext.initStandardObjects(); try { ScriptableObject.defineClass(rhinoScope, JsAssert.class); ScriptableObject.defineClass(rhinoScope, Trace.class); ScriptableObject.defineClass(rhinoScope, Notifier.class); ScriptableObject.defineClass(rhinoScope, CountDownNotifier.class); // so that the stock test for IE can gracefully fail. rhinoContext.evaluateString(rhinoScope, "var window = new Object();", "<internal>", 0, null); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } finally { Context.exit(); } JsSimpleDomNode.register(rhinoScope); JsSimpleDomParser.register(rhinoScope); JsNamedNodeMap.register(rhinoScope); JsXMLHttpRequest.register(rhinoScope); }