All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.glassfish.jersey.server.wadl.config.WadlGeneratorConfigLoader Maven / Gradle / Ivy

Go to download

A bundle project producing JAX-RS RI bundles. The primary artifact is an "all-in-one" OSGi-fied JAX-RS RI bundle (jaxrs-ri.jar). Attached to that are two compressed JAX-RS RI archives. The first archive (jaxrs-ri.zip) consists of binary RI bits and contains the API jar (under "api" directory), RI libraries (under "lib" directory) as well as all external RI dependencies (under "ext" directory). The secondary archive (jaxrs-ri-src.zip) contains buildable JAX-RS RI source bundle and contains the API jar (under "api" directory), RI sources (under "src" directory) as well as all external RI dependencies (under "ext" directory). The second archive also contains "build.xml" ANT script that builds the RI sources. To build the JAX-RS RI simply unzip the archive, cd to the created jaxrs-ri directory and invoke "ant" from the command line.

There is a newer version: 3.1.6
Show newest version
/*
 * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package org.glassfish.jersey.server.wadl.config;

import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import jakarta.ws.rs.ProcessingException;

import org.glassfish.jersey.internal.util.ReflectionHelper;
import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.server.internal.LocalizationMessages;

/**
 * Loads a {@link WadlGeneratorConfig} and provides access to the {@link org.glassfish.jersey.server.wadl.WadlGenerator}
 * provided by the loaded {@link WadlGeneratorConfig}.
* If no {@link WadlGeneratorConfig} is provided, the default {@link org.glassfish.jersey.server.wadl.WadlGenerator} * will be loaded.
* * @author Martin Grotzke (martin.grotzke at freiheit.com) */ public class WadlGeneratorConfigLoader { /** * Load the {@link WadlGeneratorConfig} from the provided {@link org.glassfish.jersey.server.ResourceConfig} using the * property {@link org.glassfish.jersey.server.ServerProperties#WADL_GENERATOR_CONFIG}. * *

* The type of this property must be a subclass or an instance of a subclass of * {@link WadlGeneratorConfig}.
* If it's not set, the default {@link org.glassfish.jersey.server.wadl.internal.generators.WadlGeneratorJAXBGrammarGenerator} * will be used. *

* * @param properties configuration properties of deployed Jersey application. * @return a configure {@link WadlGeneratorConfig}. */ public static WadlGeneratorConfig loadWadlGeneratorsFromConfig(final Map properties) { final Object wadlGeneratorConfigProperty = properties.get( ServerProperties.WADL_GENERATOR_CONFIG); if (wadlGeneratorConfigProperty == null) { return new WadlGeneratorConfig() { @Override public List configure() { return Collections.emptyList(); } }; } else { try { if (wadlGeneratorConfigProperty instanceof WadlGeneratorConfig) { return ((WadlGeneratorConfig) wadlGeneratorConfigProperty); } final Class configClazz; if (wadlGeneratorConfigProperty instanceof Class) { configClazz = ((Class) wadlGeneratorConfigProperty) .asSubclass(WadlGeneratorConfig.class); } else if (wadlGeneratorConfigProperty instanceof String) { configClazz = AccessController.doPrivileged(ReflectionHelper .classForNameWithExceptionPEA((String) wadlGeneratorConfigProperty)) .asSubclass(WadlGeneratorConfig.class); } else { throw new ProcessingException(LocalizationMessages.ERROR_WADL_GENERATOR_CONFIG_LOADER_PROPERTY( ServerProperties.WADL_GENERATOR_CONFIG, wadlGeneratorConfigProperty.getClass().getName())); } return configClazz.newInstance(); } catch (final PrivilegedActionException pae) { throw new ProcessingException(LocalizationMessages.ERROR_WADL_GENERATOR_CONFIG_LOADER( ServerProperties.WADL_GENERATOR_CONFIG), pae.getCause()); } catch (final Exception e) { throw new ProcessingException(LocalizationMessages.ERROR_WADL_GENERATOR_CONFIG_LOADER( ServerProperties.WADL_GENERATOR_CONFIG), e); } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy