Refine search
public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris, boolean jaxbOnly) { return getAllRequestResponseTypes(cris, jaxbOnly, null); }
@Override protected boolean resourceAvailable(String resourceName) { return ResourceUtils.getClasspathResourceURL(resourceName, RequestDispatcherProvider.class, getBus()) != null; } }
private String transformLocally(Message m, UriInfo ui, Source source) throws Exception { InputStream is = ResourceUtils.getResourceStream(stylesheetReference, m.getExchange().getBus()); TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = transformerFactory.newTemplates(new StreamSource(is)).newTransformer(); t.setParameter("base.path", m.get("http.base.path")); StringWriter stringWriter = new StringWriter(); t.transform(source, new StreamResult(stringWriter)); return stringWriter.toString(); }
public PerRequestResourceProvider(Class<?> clazz) { c = ResourceUtils.findResourceConstructor(clazz, true); if (c == null) { throw new RuntimeException("Resource class " + clazz + " has no valid constructor"); } postConstructMethod = ResourceUtils.findPostConstructMethod(clazz); preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz); }
public static List<UserResource> getUserResources(String loc, Bus bus) { try (InputStream is = ResourceUtils.getResourceStream(loc, bus)) { if (is == null) { return null; } return getUserResources(is); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc); } return null; }
@Override public void init(List<ClassResourceInfo> cris) { if (singleJaxbContext) { JAXBContext context = null; Set<Class<?>> allTypes = null; if (cris != null) { allTypes = new HashSet<Class<?>>(ResourceUtils.getAllRequestResponseTypes(cris, true) .getAllTypes().keySet()); context = ResourceUtils.createJaxbContext(allTypes, extraClass, cProperties); } else if (extraClass != null) { allTypes = new HashSet<Class<?>>(Arrays.asList(extraClass)); context = ResourceUtils.createJaxbContext(allTypes, null, cProperties); } if (context != null) { for (Class<?> cls : allTypes) { if (useSingleContextForPackages) { packageContexts.put(PackageUtils.getPackageName(cls), context); } else { classContexts.put(cls, context); } } } } }
public static Object[] createConstructorArguments(Constructor<?> c, Message m) { Class<?>[] params = c.getParameterTypes(); Annotation[][] anns = c.getParameterAnnotations(); Type[] genericTypes = c.getGenericParameterTypes(); @SuppressWarnings("unchecked") MultivaluedMap<String, String> templateValues = m == null ? null : (MultivaluedMap<String, String>)m.get(URITemplate.TEMPLATE_PARAMETERS); Object[] values = new Object[params.length]; for (int i = 0; i < params.length; i++) { if (AnnotationUtils.getAnnotation(anns[i], Context.class) != null) { values[i] = JAXRSUtils.createContextValue(m, genericTypes[i], params[i]); } else { Parameter p = ResourceUtils.getParameter(i, anns[i], params[i]); values[i] = JAXRSUtils.createHttpParameterValue( p, params[i], genericTypes[i], anns[i], m, templateValues, null); } } return values; } public static JAXRSServerFactoryBean createApplication(Application app, boolean ignoreAppPath) {
public Response getExistingWadl(Message m, UriInfo ui, MediaType mt) { Endpoint ep = m.getExchange().getEndpoint(); if (ep != null) { String loc = (String)ep.get(JAXRSUtils.DOC_LOCATION); if (loc != null) { try { InputStream is = ResourceUtils.getResourceStream(loc, (Bus)ep.get(Bus.class.getName())); if (is != null) { Object contextProp = m.getContextualProperty(CONVERT_WADL_RESOURCES_TO_DOM); boolean doConvertResourcesToDOM = contextProp == null ? convertResourcesToDOM : PropertyUtils.isTrue(contextProp);
loc = loc.substring(0, fragmentIndex); InputStream is = ResourceUtils.getResourceStream(loc, m.getExchange().getBus()); if (is != null) { Element docEl = StaxUtils.read(is).getDocumentElement(); InputStream is = ResourceUtils.getResourceStream(href, m.getExchange().getBus()); return Response.ok().type(MediaType.APPLICATION_XML_TYPE).entity(is).build();
ClassResourceInfo cri = subResources.get(key); if (cri == null) { cri = ResourceUtils.createClassResourceInfo(typedClass, instanceClass, this, false, resolveContexts, getBus()); if (cri != null) { if (message != null) { ProviderInfo<?> appProvider = (ProviderInfo<?>)message.getExchange().getEndpoint().get(Application.class.getName()); if (appProvider != null) { app = (Application)appProvider.getProvider();
public static Properties loadProperties(String propertiesLocation, Bus bus) throws Exception { Properties props = new Properties(); try (InputStream is = getResourceStream(propertiesLocation, bus)) { props.load(is); } return props; }
Class<?> cls = realReturnType; if (cls == Response.class) { cls = getActualJaxbType(cls, method, false); checkJaxbType(cls, realReturnType == Response.class ? cls : type, types, method.getAnnotations(), jaxbWriter); } else { Type paramType = method.getGenericParameterTypes()[pm.getIndex()]; if (jaxbOnly) { checkJaxbType(inType, paramType, types, method.getParameterAnnotations()[pm.getIndex()], jaxbWriter); } else { if (!isRecursiveSubResource(resource, sub)) { getAllTypesForResource(sub, types, jaxbOnly, jaxbWriter);
protected Properties getSwaggerProperties(Bus bus) { InputStream is = ResourceUtils.getClasspathResourceStream(propertiesLocation, AbstractSwaggerFeature.class, bus); Properties props = null; if (is != null) { props = new Properties(); try { props.load(is); } catch (IOException ex) { props = null; } finally { try { is.close(); } catch (IOException ignore) { // ignore } } } return props; } protected void initBeanConfig(BeanConfig beanConfig, Properties props) {
public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass, final Class<?> sClass, boolean root, boolean enableStatic, Bus bus) { return createClassResourceInfo(rClass, sClass, null, root, enableStatic, bus); }
public static List<UserResource> getUserResources(InputStream is) throws Exception { Document doc = StaxUtils.read(new InputStreamReader(is, StandardCharsets.UTF_8)); return getResourcesFromElement(doc.getDocumentElement()); }
protected JAXRSServerFactoryBean createFactoryBeanFromApplication(Application app) { return ResourceUtils.createApplication(app, false, true, false, getBus()); } protected static Set<String> parseSetProperty(String componentScanProp) {
private Map<Parameter, Object> getClassParameters(ClassResourceInfo cri) { Map<Parameter, Object> classParams = new LinkedHashMap<>(); List<Method> paramMethods = cri.getParameterMethods(); for (Method m : paramMethods) { classParams.put(ResourceUtils.getParameter(0, m.getAnnotations(), m.getParameterTypes()[0]), m); } List<Field> fieldParams = cri.getParameterFields(); for (Field f : fieldParams) { classParams.put(ResourceUtils.getParameter(0, f.getAnnotations(), f.getType()), f); } return classParams; }
theActualType = InjectionUtils.getActualType(opMethod.getGenericReturnType()); } else { theActualType = ResourceUtils.getActualJaxbType(type, opMethod, false);
private void validateConstructorExists() { // only validate it here otherwise we'll fail for CDI injections constructor = ResourceUtils.findResourceConstructor(clazz, true); if (constructor == null) { throw new RuntimeException("Resource class " + clazz + " has no valid constructor"); } }
(MultivaluedMap<String, String>)m.get(URITemplate.TEMPLATE_PARAMETERS); Object[] values = new Object[params.length]; for (int i = 0; i < params.length; i++) { Parameter p = ResourceUtils.getParameter(i, anns[i], params[i]); values[i] = JAXRSUtils.createHttpParameterValue( p, params[i], genericTypes[i], anns[i], m, templateValues, null);