Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2013 eXo Platform SAS
*
* 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 juzu.impl.plugin.binding;
import juzu.impl.common.Name;
import juzu.impl.plugin.application.metamodel.ApplicationMetaModel;
import juzu.impl.plugin.application.metamodel.ApplicationMetaModelPlugin;
import juzu.impl.metamodel.AnnotationKey;
import juzu.impl.metamodel.AnnotationState;
import juzu.impl.compiler.ElementHandle;
import juzu.impl.compiler.MessageCode;
import juzu.impl.compiler.ProcessingContext;
import juzu.impl.common.JSON;
import juzu.inject.ProviderFactory;
import juzu.plugin.binding.Bindings;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.util.ElementFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** @author Julien Viet */
public class BindingMetaModelPlugin extends ApplicationMetaModelPlugin {
/** . */
public static final MessageCode IMPLEMENTATION_NOT_ASSIGNABLE =
new MessageCode(
"BINDING_IMPLEMENTATION_NOT_ASSIGNABLE",
"The binding implementation type %1$s does not extend or implement the %2$s type");
/** . */
public static final MessageCode PROVIDER_NOT_ASSIGNABLE =
new MessageCode(
"BINDING_PROVIDER_NOT_ASSIGNABLE",
"The binding implementation type %1$s must provides a type %2$s that extends the %3$s type");
/** . */
public static final MessageCode IMPLEMENTATION_NOT_ABSTRACT =
new MessageCode(
"BINDING_PROVIDER_FACTORY_NOT_ABSTRACT",
"The binding implementation provider factory %1$s must not be abstract");
/** . */
public static final MessageCode PROVIDER_FACTORY_NOT_PUBLIC =
new MessageCode(
"BINDING_IMPLEMENTATION_NOT_PUBLIC",
"The binding implementation provider factory %1$s must be public");
/** . */
public static final MessageCode IMPLEMENTATION_INVALID_TYPE =
new MessageCode(
"BINDING_IMPLEMENTATION_INVALID_TYPE",
"The binding implementation provider factory %1$s must be a class");
/** . */
public static final MessageCode PROVIDER_FACTORY_NO_ZERO_ARG_CTOR =
new MessageCode(
"BINDING_PROVIDER_FACTORY_NO_ZERO_ARG_CTOR",
"The binding implementation provider factory %1$s must provides a public zero argument constructor");
/** . */
public static final MessageCode PROVIDER_FACTORY_NO_PUBLIC_CTOR =
new MessageCode(
"BINDING_PROVIDER_FACTORY_NO_PUBLIC_CTOR",
"The binding implementation provider factory %1$s must provides a public constructor");
/** . */
private static final Name BINDINGS = Name.create(Bindings.class);
/** . */
private Map state = new HashMap();
public BindingMetaModelPlugin() {
super("binding");
}
@Override
public Set> init(ProcessingContext env) {
return Collections.>singleton(Bindings.class);
}
@Override
public void processAnnotationAdded(ApplicationMetaModel metaModel, AnnotationKey key, AnnotationState added) {
ProcessingContext env = metaModel.model.processingContext;
//
TypeMirror providerFactoryTM = env.getTypeElement(ProviderFactory.class.getName()).asType();
TypeElement providerElt = env.getTypeElement("javax.inject.Provider");
DeclaredType providerTM = (DeclaredType)providerElt.asType();
TypeMirror rawProviderTM = env.erasure(providerTM);
//
List