// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/ApplicationBuilder.java
// public class ApplicationBuilder {
// 
//     private final ResourcesBuilder resourcesBuilder;
//     private final IncludeBuilder includeBuilder;
// 
//     public ApplicationBuilder(ApplicationContext ctx) {
//         resourcesBuilder = new ResourcesBuilder(ctx);
//         includeBuilder = new IncludeBuilder(ctx.getGrammarsDiscoverer());
//     }
// 
//     public Application build(HttpServletRequest request) {
//         return build(HttpServletRequestUtils.getBaseUrlOf(request));
//     }
// 
//     public Application build(String baseUrl) {
//         return new Application()
//                 .withDoc(new Doc().withTitle("REST Service WADL"))
//                 .withResources(resourcesBuilder.build(baseUrl))
//                 .withGrammars(new Grammars().withInclude(includeBuilder.build()));
//     }
// }
// 
// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/ApplicationContext.java
// public class ApplicationContext implements Iterable<MethodContext> {
// 
//     private final MethodContextIterator methodContextIterator;
//     private final GrammarsDiscoverer grammarsDiscoverer;
// 
//     public ApplicationContext(MethodContextIterator methodContextIterator, GrammarsDiscoverer grammarsDiscoverer) {
//         this.methodContextIterator = methodContextIterator;
//         this.grammarsDiscoverer = grammarsDiscoverer;
//     }
// 
//     @Override
//     public MethodContextIterator iterator() {
//         methodContextIterator.initWith(this);
//         return methodContextIterator;
//     }
// 
//     public GrammarsDiscoverer getGrammarsDiscoverer() {
//         return grammarsDiscoverer;
//     }
// }
// 
// Path: spring-wadl-generator/src/main/java/com/autentia/xml/schema/ClassTypeDiscoverer.java
// public class ClassTypeDiscoverer {
// 
//     final QNameBuilder qNameBuilder;
//     final ClassTypeInMemoryStore classTypeStore = new ClassTypeInMemoryStore();
// 
//     public ClassTypeDiscoverer(QNameBuilder qNameBuilder) {
//         this.qNameBuilder = qNameBuilder;
//     }
// 
//     public ClassType discoverFor(ClassMetadata classMetadata) {
//         ClassType classType = classTypeStore.findBy(classMetadata.getType());
//         if (classType == null) {
//             classType = buildClassTypeFor(classMetadata);
//             classTypeStore.add(classType);
//         }
// 
//         return classType;
//     }
// 
//     private ClassType buildClassTypeFor(ClassMetadata classMetadata) {
//         final ClassType classType;
//         if (classMetadata.isCollection()) {
//             final QName collectionQName = qNameBuilder.buildForCollectionOf(classMetadata.getComponentType());
//             final QName elementsQName = qNameBuilder.buildFor(classMetadata.getComponentType());
//             classType = new CollectionType(classMetadata.getType(), collectionQName, elementsQName);
// 
//         } else {
//             final QName qName = qNameBuilder.buildFor(classMetadata.getType());
//             classType = new SingleType(classMetadata.getType(), qName);
//         }
//         return classType;
//     }
// 
//     public ClassType getBy(String localPart) {
//         final ClassType classType = classTypeStore.findBy(localPart);
//         if (classType == null) {
//             throw new ClassTypeNotFoundException("Cannot find class type for localPart: " + localPart);
//         }
//         return classType;
//     }
// 
//     public Map<String, ClassType> getAllByLocalPart() {
//         return classTypeStore.getAllByLocalPart();
//     }
// }
// 
// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/namespace/QNameBuilderFactory.java
// public class QNameBuilderFactory {
// 
//     public QNameBuilder getBuilder() {
//         return new QNameBuilder(
//                 new QNameMemory(
//                         initCacheForSingleTypes(),
//                         initCacheForCollectionTypes(),
//                         initCacheForAlreadyUsedPrefixes()));
//     }
// 
//     private QNamesCache initCacheForSingleTypes() {
//         return new InMemoryQNamesCache(BASIC_SINGLE_TYPES);
//     }
// 
//     private QNamesCache initCacheForCollectionTypes() {
//         return new InMemoryQNamesCache(BASIC_COLLECTION_TYPES);
//     }
// 
//     private QNamePrefixesCache initCacheForAlreadyUsedPrefixes() {
//         final QNamePrefixesCache cache = new InMemoryQNamePrefixesCache();
//         cache.add("xs");
//         cache.add("wadl");
//         cache.add("tc");
// 
//         return cache;
//     }
// }


import com.autentia.web.rest.wadl.builder.ApplicationBuilder;
import com.autentia.web.rest.wadl.builder.ApplicationContext;
import com.autentia.xml.schema.ClassTypeDiscoverer;
import com.autentia.web.rest.wadl.builder.namespace.GrammarsDiscoverer;
import com.autentia.web.rest.wadl.builder.namespace.QNameBuilderFactory;
import com.autentia.xml.schema.SchemaBuilder;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
/**
 *    Copyright 2013 Autentia Real Business Solution S.L.
 *
 *    Licensed 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 com.autentia.web.rest.wadl.builder.impl.springframework;


public class SpringWadlBuilderFactory {

    private final ApplicationBuilder applicationBuilder;
    private final SchemaBuilder schemaBuilder;

    public SpringWadlBuilderFactory(RequestMappingHandlerMapping handlerMapping) {
        final ClassTypeDiscoverer classTypeDiscoverer = new ClassTypeDiscoverer(new QNameBuilderFactory().getBuilder());
// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/ApplicationBuilder.java
// public class ApplicationBuilder {
// 
//     private final ResourcesBuilder resourcesBuilder;
//     private final IncludeBuilder includeBuilder;
// 
//     public ApplicationBuilder(ApplicationContext ctx) {
//         resourcesBuilder = new ResourcesBuilder(ctx);
//         includeBuilder = new IncludeBuilder(ctx.getGrammarsDiscoverer());
//     }
// 
//     public Application build(HttpServletRequest request) {
//         return build(HttpServletRequestUtils.getBaseUrlOf(request));
//     }
// 
//     public Application build(String baseUrl) {
//         return new Application()
//                 .withDoc(new Doc().withTitle("REST Service WADL"))
//                 .withResources(resourcesBuilder.build(baseUrl))
//                 .withGrammars(new Grammars().withInclude(includeBuilder.build()));
//     }
// }
// 
// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/ApplicationContext.java
// public class ApplicationContext implements Iterable<MethodContext> {
// 
//     private final MethodContextIterator methodContextIterator;
//     private final GrammarsDiscoverer grammarsDiscoverer;
// 
//     public ApplicationContext(MethodContextIterator methodContextIterator, GrammarsDiscoverer grammarsDiscoverer) {
//         this.methodContextIterator = methodContextIterator;
//         this.grammarsDiscoverer = grammarsDiscoverer;
//     }
// 
//     @Override
//     public MethodContextIterator iterator() {
//         methodContextIterator.initWith(this);
//         return methodContextIterator;
//     }
// 
//     public GrammarsDiscoverer getGrammarsDiscoverer() {
//         return grammarsDiscoverer;
//     }
// }
// 
// Path: spring-wadl-generator/src/main/java/com/autentia/xml/schema/ClassTypeDiscoverer.java
// public class ClassTypeDiscoverer {
// 
//     final QNameBuilder qNameBuilder;
//     final ClassTypeInMemoryStore classTypeStore = new ClassTypeInMemoryStore();
// 
//     public ClassTypeDiscoverer(QNameBuilder qNameBuilder) {
//         this.qNameBuilder = qNameBuilder;
//     }
// 
//     public ClassType discoverFor(ClassMetadata classMetadata) {
//         ClassType classType = classTypeStore.findBy(classMetadata.getType());
//         if (classType == null) {
//             classType = buildClassTypeFor(classMetadata);
//             classTypeStore.add(classType);
//         }
// 
//         return classType;
//     }
// 
//     private ClassType buildClassTypeFor(ClassMetadata classMetadata) {
//         final ClassType classType;
//         if (classMetadata.isCollection()) {
//             final QName collectionQName = qNameBuilder.buildForCollectionOf(classMetadata.getComponentType());
//             final QName elementsQName = qNameBuilder.buildFor(classMetadata.getComponentType());
//             classType = new CollectionType(classMetadata.getType(), collectionQName, elementsQName);
// 
//         } else {
//             final QName qName = qNameBuilder.buildFor(classMetadata.getType());
//             classType = new SingleType(classMetadata.getType(), qName);
//         }
//         return classType;
//     }
// 
//     public ClassType getBy(String localPart) {
//         final ClassType classType = classTypeStore.findBy(localPart);
//         if (classType == null) {
//             throw new ClassTypeNotFoundException("Cannot find class type for localPart: " + localPart);
//         }
//         return classType;
//     }
// 
//     public Map<String, ClassType> getAllByLocalPart() {
//         return classTypeStore.getAllByLocalPart();
//     }
// }
// 
// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/namespace/QNameBuilderFactory.java
// public class QNameBuilderFactory {
// 
//     public QNameBuilder getBuilder() {
//         return new QNameBuilder(
//                 new QNameMemory(
//                         initCacheForSingleTypes(),
//                         initCacheForCollectionTypes(),
//                         initCacheForAlreadyUsedPrefixes()));
//     }
// 
//     private QNamesCache initCacheForSingleTypes() {
//         return new InMemoryQNamesCache(BASIC_SINGLE_TYPES);
//     }
// 
//     private QNamesCache initCacheForCollectionTypes() {
//         return new InMemoryQNamesCache(BASIC_COLLECTION_TYPES);
//     }
// 
//     private QNamePrefixesCache initCacheForAlreadyUsedPrefixes() {
//         final QNamePrefixesCache cache = new InMemoryQNamePrefixesCache();
//         cache.add("xs");
//         cache.add("wadl");
//         cache.add("tc");
// 
//         return cache;
//     }
// }


// Path: spring-wadl-generator/src/main/java/com/autentia/web/rest/wadl/builder/impl/springframework/SpringWadlBuilderFactory.java
import com.autentia.web.rest.wadl.builder.ApplicationBuilder;
import com.autentia.web.rest.wadl.builder.ApplicationContext;
import com.autentia.xml.schema.ClassTypeDiscoverer;
import com.autentia.web.rest.wadl.builder.namespace.GrammarsDiscoverer;
import com.autentia.web.rest.wadl.builder.namespace.QNameBuilderFactory;
import com.autentia.xml.schema.SchemaBuilder;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 *    Copyright 2013 Autentia Real Business Solution S.L.
 *
 *    Licensed 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 com.autentia.web.rest.wadl.builder.impl.springframework;


public class SpringWadlBuilderFactory {

    private final ApplicationBuilder applicationBuilder;
    private final SchemaBuilder schemaBuilder;

    public SpringWadlBuilderFactory(RequestMappingHandlerMapping handlerMapping) {
        final ClassTypeDiscoverer classTypeDiscoverer = new ClassTypeDiscoverer(new QNameBuilderFactory().getBuilder());
        final GrammarsDiscoverer grammarsDiscoverer = new GrammarsDiscoverer(classTypeDiscoverer);