use of org.apache.cxf.feature.Feature in project fabric8 by fabric8io.
the class Java2SwaggerJsonMojo method execute.
public void execute() throws MojoExecutionException {
List<Class<?>> resourceClasses = loadResourceClasses();
List<Object> resourceObjects = new ArrayList<Object>();
for (Class<?> resourceClass : resourceClasses) {
try {
resourceObjects.add(resourceClass.newInstance());
} catch (InstantiationException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (IllegalAccessException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
Thread.currentThread().setContextClassLoader(getClassLoader());
List<Feature> features = new ArrayList<Feature>();
features.add(new SwaggerFeature());
JAXRSServerFactoryBean serverFacBean = new JAXRSServerFactoryBean();
serverFacBean.setAddress(address);
serverFacBean.setServiceBeans(resourceObjects);
serverFacBean.setFeatures(features);
Server server = serverFacBean.create();
InputStream in = null;
try {
String serverAddress = server.getEndpoint().getEndpointInfo().getAddress();
String apiDocs = serverAddress + "/swagger.json";
URL url = new URL(apiDocs);
in = url.openStream();
String res = getStringFromInputStream(in);
generateJson(resourceClasses, res);
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
server.stop();
}
}
use of org.apache.cxf.feature.Feature in project jbossws-cxf by jbossws.
the class FeatureUtils method createFeatures.
private static List<Feature> createFeatures(String propValue, MapToBeanConverter converter) {
List<Feature> list = new ArrayList<Feature>();
StringTokenizer st = new StringTokenizer(propValue, ", ", false);
while (st.hasMoreTokens()) {
Feature feature = (Feature) newInstance(st.nextToken(), converter);
if (feature != null) {
list.add(feature);
}
}
return list;
}
Aggregations