Examples of WadlGenerator


Examples of org.apache.cxf.jaxrs.model.wadl.WadlGenerator

        control.makeThreadSafe(true);
    }
   
    @Test
    public void testWadlInJsonFormat() throws Exception {
        WadlGenerator wg = new WadlGenerator();
        wg.setUseJaxbContextForQnames(false);
        wg.setIgnoreMessageWriters(false);
       
        wg.setExternalLinks(Collections.singletonList("json.schema"));
       
        ClassResourceInfo cri =
            ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
        Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, null);
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Accept", Collections.singletonList("application/json"));
        m.put(Message.PROTOCOL_HEADERS, headers);
        Response r = wg.handleRequest(m, cri);
        assertEquals("application/json",
                r.getMetadata().getFirst("Content-Type").toString());
       
        ByteArrayOutputStream os = new ByteArrayOutputStream();
       
View Full Code Here

Examples of org.apache.cxf.jaxrs.model.wadl.WadlGenerator

        String query = (String)m.get(Message.QUERY_STRING);
        if (query != null && query.contains(WadlGenerator.WADL_QUERY)) {
            String requestURI = (String)m.get(Message.REQUEST_URI);
            String baseAddress = HttpUtils.getBaseAddress(m);
            if (baseAddress.equals(requestURI)) {
                Response r = new WadlGenerator().handleRequest(m, null);
                if (r != null) {
                    m.getExchange().put(Response.class, r);
                }
            }
        }
View Full Code Here

Examples of org.apache.wink.common.model.wadl.WADLGenerator

    }
   
    private void handleWadlRequest(HttpServletRequest request, HttpServletResponse response) {
        try {
            org.apache.wink.common.model.wadl.Application wadlDocument = null;
            WADLGenerator generator = new WADLGenerator();
            Set<Class<?>> classes = new HashSet<Class<?>>();
            classes.add(resourceClass);
            wadlDocument = generator.generate(binding.getURI(), classes);
           
            MessageBodyWriter<org.apache.wink.common.model.wadl.Application> writer =
                this.getDeploymentConfiguration().getProvidersRegistry().
                     getMessageBodyWriter(org.apache.wink.common.model.wadl.Application.class,
                                          org.apache.wink.common.model.wadl.Application.class,
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

        this.serviceLocator = serviceLocator;
        this.wadlGeneratorConfig = WadlGeneratorConfigLoader.loadWadlGeneratorsFromConfig(configuration.getProperties());

        // TODO perhaps this should be done another way for the moment
        // create a temporary generator just to do this one task
        final WadlGenerator wadlGenerator = wadlGeneratorConfig.createWadlGenerator(serviceLocator);

        JAXBContext jaxbContextCandidate;

        final ClassLoader contextClassLoader = AccessController.doPrivileged(ReflectionHelper.getContextClassLoaderPA());
        try {
            // Nasty ClassLoader magic. JAXB-API has some strange limitation about what classloader can
            // be used in OSGi environment - it must be same as context ClassLoader. Following code just
            // workarounds this limitation
            // see JERSEY-1818
            // see JSR222-46

            final ClassLoader jerseyModuleClassLoader =
                    AccessController.doPrivileged(ReflectionHelper.getClassLoaderPA(wadlGenerator.getClass()));

            AccessController.doPrivileged(ReflectionHelper.setContextClassLoaderPA(jerseyModuleClassLoader));

            jaxbContextCandidate = JAXBContext.newInstance(wadlGenerator.getRequiredJaxbContextPath(), jerseyModuleClassLoader);

        } catch (JAXBException ex) {
            try {
                // fallback for glassfish
                LOGGER.log(Level.FINE, LocalizationMessages.WADL_JAXB_CONTEXT_FALLBACK(), ex);
                jaxbContextCandidate = JAXBContext.newInstance(wadlGenerator.getRequiredJaxbContextPath());
            } catch (JAXBException innerEx) {
                throw new ProcessingException(LocalizationMessages.ERROR_WADL_JAXB_CONTEXT(), ex);
            }
        } finally {
            AccessController.doPrivileged(ReflectionHelper.setContextClassLoaderPA(contextClassLoader));
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

        // Get the root application description
        //

        ApplicationDescription description = getApplication(info, detailedWadl);

        WadlGenerator wadlGenerator = wadlGeneratorConfig.createWadlGenerator(serviceLocator);
        Application application = new WadlBuilder(wadlGenerator, detailedWadl, info).generate(description, resource);
        if (application == null) {
            return null;
        }
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

    private static final Logger LOGGER = Logger.getLogger(WadlGeneratorLoader.class.getName());

    static WadlGenerator loadWadlGenerators(
            List<WadlGenerator> wadlGenerators) throws Exception {
        WadlGenerator wadlGenerator = new WadlGeneratorJAXBGrammarGenerator();
        if (wadlGenerators != null && !wadlGenerators.isEmpty()) {
            for (WadlGenerator generator : wadlGenerators) {
                generator.setWadlGeneratorDelegate(wadlGenerator);
                wadlGenerator = generator;
            }
        }
        wadlGenerator.init();
        return wadlGenerator;
    }
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

        return loadWadlGeneratorDescriptions(serviceLocator, list);
    }

    static WadlGenerator loadWadlGeneratorDescriptions(ServiceLocator serviceLocator,
                                                       List<WadlGeneratorDescription> wadlGeneratorDescriptions) throws Exception {
        WadlGenerator wadlGenerator = new WadlGeneratorJAXBGrammarGenerator();

        final CallbackList callbacks = new CallbackList();
        try {
            if (wadlGeneratorDescriptions != null && !wadlGeneratorDescriptions.isEmpty()) {
                for (WadlGeneratorDescription wadlGeneratorDescription : wadlGeneratorDescriptions) {
                    final WadlGeneratorControl control = loadWadlGenerator(serviceLocator, wadlGeneratorDescription, wadlGenerator);
                    wadlGenerator = control.wadlGenerator;
                    callbacks.add(control.callback);
                }
            }
            wadlGenerator.init();
        } finally {
            callbacks.callback();
        }

        return wadlGenerator;
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

    private static WadlGeneratorControl loadWadlGenerator(ServiceLocator serviceLocator,
            WadlGeneratorDescription wadlGeneratorDescription,
            WadlGenerator wadlGeneratorDelegate) throws Exception {
        LOGGER.info("Loading wadlGenerator " + wadlGeneratorDescription.getGeneratorClass().getName());
        final WadlGenerator generator = Injections.getOrCreate(serviceLocator, wadlGeneratorDescription.getGeneratorClass());
        generator.setWadlGeneratorDelegate(wadlGeneratorDelegate);
        CallbackList callbacks = null;
        if (wadlGeneratorDescription.getProperties() != null
                && !wadlGeneratorDescription.getProperties().isEmpty()) {
            callbacks = new CallbackList();
            final Properties wadlGeneratorProperties = wadlGeneratorDescription.getProperties();
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

     * provided by {@link #configure()}.
     *
     * @return the initialized {@link org.glassfish.jersey.server.wadl.WadlGenerator}
     */
    public WadlGenerator createWadlGenerator(ServiceLocator locator) {
        WadlGenerator wadlGenerator;
        List<WadlGeneratorDescription> wadlGeneratorDescriptions;
        try {
            wadlGeneratorDescriptions = configure();
        } catch (Exception e) {
            throw new ProcessingException(LocalizationMessages.ERROR_WADL_GENERATOR_CONFIGURE(), e);
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.WadlGenerator

     * provided by {@link #configure()}.
     *
     * @return the initialized {@link org.glassfish.jersey.server.wadl.WadlGenerator}
     */
    public WadlGenerator createWadlGenerator(final ServiceLocator locator) {
        final WadlGenerator wadlGenerator;
        final List<WadlGeneratorDescription> wadlGeneratorDescriptions;
        try {
            wadlGeneratorDescriptions = configure();
        } catch (final Exception e) {
            throw new ProcessingException(LocalizationMessages.ERROR_WADL_GENERATOR_CONFIGURE(), e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.