// Path: alfresco-mvc-rest/src/main/java/com/gradecak/alfresco/mvc/rest/config/AlfrescoRestRegistrar.java
// public class AlfrescoRestRegistrar implements ImportBeanDefinitionRegistrar {
// 
// 	private AnnotationAttributes attributes;
// 
// 	public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
// 
// 		Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!");
// 		Assert.notNull(registry, "BeanDefinitionRegistry must not be null!");
// 
// 		Map<String, Object> annotationAttributes = annotationMetadata
// 				.getAnnotationAttributes(EnableAlfrescoMvcRest.class.getName());
// 		if (annotationAttributes == null) {
// 			Map<String, Object> annotationAttributes2 = annotationMetadata
// 					.getAnnotationAttributes(AlfrescoDispatcherWebscript.class.getName());
// 
// 			if (annotationAttributes2 != null) {
// 				annotationAttributes = new AnnotationAttributes();
// 				annotationAttributes.put("value", Collections.singleton(new AnnotationAttributes(annotationAttributes2))
// 						.toArray(new AnnotationAttributes[0]));
// 			}
// 
// 			this.attributes = new AnnotationAttributes(annotationAttributes);
// 
// 		} else {
// 			this.attributes = new AnnotationAttributes(annotationAttributes);
// 		}
// 
// 		AnnotationAttributes[] dispatcherWebscripts = (AnnotationAttributes[]) attributes.get("value");
// 
// 		for (AnnotationAttributes dispatcherWebscript : dispatcherWebscripts) {
// 			processDispatcherWebscript(dispatcherWebscript, registry);
// 		}
// 
// 	}
// 
// 	private void processDispatcherWebscript(AnnotationAttributes webscriptAttributes, BeanDefinitionRegistry registry) {
// 		String webscript = webscriptAttributes.getString("name");
// 		Assert.hasText(webscript, "Webscript name cannot be empty!");
// 
// 		Class<?> servletContext = webscriptAttributes.getClass("servletContext");
// 
// 		ServletConfigOptions[] servletConfigOptions = (ServletConfigOptions[]) webscriptAttributes
// 				.get("servletConfigOptions");
// 		Class<? extends WebApplicationContext> servletContextClass = webscriptAttributes
// 				.getClass("servletContextClass");
// 		HttpMethod[] httpMethods = (HttpMethod[]) webscriptAttributes.get("httpMethods");
// 		boolean inheritGlobalProperties = (Boolean) webscriptAttributes.get("inheritGlobalProperties");
// 
// 		GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
// 		beanDefinition.setBeanClass(DispatcherWebscript.class);
// 
// 		DispatcherWebscript ws = new DispatcherWebscript(webscript, inheritGlobalProperties);
// 		ws.setContextClass(servletContextClass);
// 		ws.setContextConfigLocation(servletContext.getName());
// 		ws.addServletConfigOptions(servletConfigOptions);
// 		beanDefinition.setInstanceSupplier(() -> ws);
// 		beanDefinition.setRole(BeanDefinition.ROLE_APPLICATION);
// 
// 		registry.registerBeanDefinition(webscript, beanDefinition);
// 
// 		for (HttpMethod httpMethod : httpMethods) {
// 			registry.registerAlias(webscript, getWebscriptName(webscript, httpMethod));
// 		}
// 	}
// 
// 	private String getWebscriptName(String webscript, HttpMethod httpMethod) {
// 		String beanName = "webscript." + webscript + "." + httpMethod.name();
// 		return beanName.toLowerCase();
// 	}
// }
// 
// Path: alfresco-mvc-rest/src/main/java/com/gradecak/alfresco/mvc/webscript/DispatcherWebscript.java
// public static enum ServletConfigOptions {
// 	DISABLED_PARENT_HANDLER_MAPPINGS, DISABLED_PARENT_HANDLER_ADAPTERS, DISABLED_PARENT_VIEW_RESOLVERS,
// 	DISABLED_PARENT_HANDLER_EXCEPTION_RESOLVERS
// }


import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpMethod;
import org.springframework.web.context.WebApplicationContext;
import com.gradecak.alfresco.mvc.rest.config.AlfrescoRestRegistrar;
import com.gradecak.alfresco.mvc.webscript.DispatcherWebscript.ServletConfigOptions;
/**
 * Copyright gradecak.com

 * 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.gradecak.alfresco.mvc.rest.annotation;




@Repeatable(EnableAlfrescoMvcRest.class)
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import(AlfrescoRestRegistrar.class)
public @interface AlfrescoDispatcherWebscript {
	String name() default "alfresco-mvc.mvc";

	HttpMethod[] httpMethods() default { HttpMethod.GET, HttpMethod.POST, HttpMethod.DELETE, HttpMethod.PUT };

	Class<?> servletContext();

	Class<? extends WebApplicationContext> servletContextClass() default org.springframework.web.context.support.AnnotationConfigWebApplicationContext.class;

	boolean inheritGlobalProperties() default false;

// Path: alfresco-mvc-rest/src/main/java/com/gradecak/alfresco/mvc/rest/config/AlfrescoRestRegistrar.java
// public class AlfrescoRestRegistrar implements ImportBeanDefinitionRegistrar {
// 
// 	private AnnotationAttributes attributes;
// 
// 	public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
// 
// 		Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!");
// 		Assert.notNull(registry, "BeanDefinitionRegistry must not be null!");
// 
// 		Map<String, Object> annotationAttributes = annotationMetadata
// 				.getAnnotationAttributes(EnableAlfrescoMvcRest.class.getName());
// 		if (annotationAttributes == null) {
// 			Map<String, Object> annotationAttributes2 = annotationMetadata
// 					.getAnnotationAttributes(AlfrescoDispatcherWebscript.class.getName());
// 
// 			if (annotationAttributes2 != null) {
// 				annotationAttributes = new AnnotationAttributes();
// 				annotationAttributes.put("value", Collections.singleton(new AnnotationAttributes(annotationAttributes2))
// 						.toArray(new AnnotationAttributes[0]));
// 			}
// 
// 			this.attributes = new AnnotationAttributes(annotationAttributes);
// 
// 		} else {
// 			this.attributes = new AnnotationAttributes(annotationAttributes);
// 		}
// 
// 		AnnotationAttributes[] dispatcherWebscripts = (AnnotationAttributes[]) attributes.get("value");
// 
// 		for (AnnotationAttributes dispatcherWebscript : dispatcherWebscripts) {
// 			processDispatcherWebscript(dispatcherWebscript, registry);
// 		}
// 
// 	}
// 
// 	private void processDispatcherWebscript(AnnotationAttributes webscriptAttributes, BeanDefinitionRegistry registry) {
// 		String webscript = webscriptAttributes.getString("name");
// 		Assert.hasText(webscript, "Webscript name cannot be empty!");
// 
// 		Class<?> servletContext = webscriptAttributes.getClass("servletContext");
// 
// 		ServletConfigOptions[] servletConfigOptions = (ServletConfigOptions[]) webscriptAttributes
// 				.get("servletConfigOptions");
// 		Class<? extends WebApplicationContext> servletContextClass = webscriptAttributes
// 				.getClass("servletContextClass");
// 		HttpMethod[] httpMethods = (HttpMethod[]) webscriptAttributes.get("httpMethods");
// 		boolean inheritGlobalProperties = (Boolean) webscriptAttributes.get("inheritGlobalProperties");
// 
// 		GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
// 		beanDefinition.setBeanClass(DispatcherWebscript.class);
// 
// 		DispatcherWebscript ws = new DispatcherWebscript(webscript, inheritGlobalProperties);
// 		ws.setContextClass(servletContextClass);
// 		ws.setContextConfigLocation(servletContext.getName());
// 		ws.addServletConfigOptions(servletConfigOptions);
// 		beanDefinition.setInstanceSupplier(() -> ws);
// 		beanDefinition.setRole(BeanDefinition.ROLE_APPLICATION);
// 
// 		registry.registerBeanDefinition(webscript, beanDefinition);
// 
// 		for (HttpMethod httpMethod : httpMethods) {
// 			registry.registerAlias(webscript, getWebscriptName(webscript, httpMethod));
// 		}
// 	}
// 
// 	private String getWebscriptName(String webscript, HttpMethod httpMethod) {
// 		String beanName = "webscript." + webscript + "." + httpMethod.name();
// 		return beanName.toLowerCase();
// 	}
// }
// 
// Path: alfresco-mvc-rest/src/main/java/com/gradecak/alfresco/mvc/webscript/DispatcherWebscript.java
// public static enum ServletConfigOptions {
// 	DISABLED_PARENT_HANDLER_MAPPINGS, DISABLED_PARENT_HANDLER_ADAPTERS, DISABLED_PARENT_VIEW_RESOLVERS,
// 	DISABLED_PARENT_HANDLER_EXCEPTION_RESOLVERS
// }


// Path: alfresco-mvc-rest/src/main/java/com/gradecak/alfresco/mvc/rest/annotation/AlfrescoDispatcherWebscript.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpMethod;
import org.springframework.web.context.WebApplicationContext;
import com.gradecak.alfresco.mvc.rest.config.AlfrescoRestRegistrar;
import com.gradecak.alfresco.mvc.webscript.DispatcherWebscript.ServletConfigOptions;

/**
 * Copyright gradecak.com

 * 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.gradecak.alfresco.mvc.rest.annotation;




@Repeatable(EnableAlfrescoMvcRest.class)
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import(AlfrescoRestRegistrar.class)
public @interface AlfrescoDispatcherWebscript {
	String name() default "alfresco-mvc.mvc";

	HttpMethod[] httpMethods() default { HttpMethod.GET, HttpMethod.POST, HttpMethod.DELETE, HttpMethod.PUT };

	Class<?> servletContext();

	Class<? extends WebApplicationContext> servletContextClass() default org.springframework.web.context.support.AnnotationConfigWebApplicationContext.class;

	boolean inheritGlobalProperties() default false;

	ServletConfigOptions[] servletConfigOptions() default {};