/**
 *  Copyright 2005-2014 Red Hat, Inc.
 *
 *  Red Hat licenses this file to you under the Apache License, version
 *  2.0 (the "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 *  implied.  See the License for the specific language governing
 *  permissions and limitations under the License.
 */
package org.jboss.jube.main;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.jboss.jube.apimaster.ApiMasterService;
import org.jboss.jube.apimaster.ApiMasterService;
import org.apache.cxf.feature.LoggingFeature;

import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

@ApplicationPath("/")
public class NodeApplication extends Application {
    @Produces
    private JacksonJsonProvider jacksonJsonProvider = new JacksonJsonProvider();

    @Inject
    private ApiMasterService apiMasterService;

    @Override
    public Set<Object> getSingletons() {
        return new HashSet<Object>(
                Arrays.asList(
                        apiMasterService,
                        jacksonJsonProvider,
/*
    TODO
                    new SwaggerFeature(),
                    new EnableJMXFeature(),
*/
                        new LoggingFeature()
                )
        );
    }
}


@@ -723,16 +723,129 @@
 ovider;%0A
+import org.apache.cxf.jaxrs.swagger.SwaggerFeature;%0Aimport org.apache.deltaspike.core.api.config.ConfigProperty;%0A
 import o
@@ -1176,16 +1176,39 @@
 ashSet;%0A
+import java.util.List;%0A
 import j
@@ -1451,16 +1451,128 @@
 rvice;%0A%0A
+    @Inject%0A    @ConfigProperty(name = %22CXF_LOG_REQUESTS%22, defaultValue = %22false%22)%0A    boolean cxfLogRequests;%0A%0A
     @Ove
@@ -1630,14 +1630,28 @@
     
-return
+Set%3CObject%3E answer =
  new
@@ -1667,16 +1667,18 @@
 Object%3E(
+);
 %0A       
@@ -1682,55 +1682,19 @@
     
-        Arrays.asList(%0A                        
+answer.add(
 apiM
@@ -1705,17 +1705,18 @@
 rService
-,
+);
 %0A       
@@ -1716,32 +1716,27 @@
         
-                
+answer.add(
 jacksonJ
@@ -1750,84 +1750,106 @@
 ider
-,%0A/*
+);
 %0A    
-TODO%0A                    new SwaggerFeature(),%0A                    
+    answer.add(new SwaggerFeature());%0A/*%0A    TODO%0A        answer.add();%0A        answer.add(
 new 
@@ -1866,17 +1866,18 @@
 eature()
-,
+);
 %0A*/%0A    
@@ -1872,33 +1872,54 @@
 ());%0A*/%0A        
- 
+if (cxfLogRequests) %7B%0A
                n
@@ -1914,19 +1914,27 @@
         
-   
+answer.add(
 new Logg
@@ -1945,16 +1945,18 @@
 eature()
+);
 %0A       
@@ -1956,24 +1956,26 @@
         
+%7D%0A
         
 )%0A      
@@ -1970,19 +1970,21 @@
     
-)%0A        )
+return answer
 ;%0A  

disable detailed REST logging unless an env var is set