org.gradle.internal.reflect.DirectInstantiator Java Examples
The following examples show how to use
org.gradle.internal.reflect.DirectInstantiator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtocolToModelAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void invoke(MethodInvocation invocation) throws Throwable { if (current.get() != null) { // Already invoking a method on the mix-in return; } if (instance == null) { instance = new DirectInstantiator().newInstance(mixInClass, proxy); } MethodInvocation beanInvocation = new MethodInvocation(invocation.getName(), invocation.getReturnType(), invocation.getGenericReturnType(), invocation.getParameterTypes(), instance, invocation.getParameters()); current.set(beanInvocation); try { next.invoke(beanInvocation); } finally { current.set(null); } if (beanInvocation.found()) { invocation.setResult(beanInvocation.getResult()); } }
Example #2
Source File: ProtocolToModelAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void invoke(MethodInvocation invocation) throws Throwable { if (current.get() != null) { // Already invoking a method on the mix-in return; } if (instance == null) { instance = new DirectInstantiator().newInstance(mixInClass, proxy); } MethodInvocation beanInvocation = new MethodInvocation(invocation.getName(), invocation.getReturnType(), invocation.getGenericReturnType(), invocation.getParameterTypes(), instance, invocation.getParameters()); current.set(beanInvocation); try { next.invoke(beanInvocation); } finally { current.set(null); } if (beanInvocation.found()) { invocation.setResult(beanInvocation.getResult()); } }
Example #3
Source File: ProtocolToModelAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void invoke(MethodInvocation invocation) throws Throwable { if (current.get() != null) { // Already invoking a method on the mix-in return; } if (instance == null) { instance = new DirectInstantiator().newInstance(mixInClass, proxy); } MethodInvocation beanInvocation = new MethodInvocation(invocation.getName(), invocation.getReturnType(), invocation.getGenericReturnType(), invocation.getParameterTypes(), instance, invocation.getParameters()); current.set(beanInvocation); try { next.invoke(beanInvocation); } finally { current.set(null); } if (beanInvocation.found()) { invocation.setResult(beanInvocation.getResult()); } }
Example #4
Source File: DefaultArtifactResolutionQuery.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private <T extends JvmLibraryArtifact> void addJvmLibraryArtifacts(Set<T> artifacts, Class<T> type, Class<? extends T> implType, ComponentMetaData component, ArtifactResolver artifactResolver) { ArtifactResolveContext context = new ArtifactTypeResolveContext(type); BuildableArtifactSetResolveResult artifactSetResolveResult = new DefaultBuildableArtifactSetResolveResult(); artifactResolver.resolveModuleArtifacts(component, context, artifactSetResolveResult); Instantiator instantiator = new DirectInstantiator(); for (ComponentArtifactMetaData artifactMetaData : artifactSetResolveResult.getArtifacts()) { BuildableArtifactResolveResult resolveResult = new DefaultBuildableArtifactResolveResult(); artifactResolver.resolveArtifact(artifactMetaData, component.getSource(), resolveResult); if (resolveResult.getFailure() != null) { artifacts.add(instantiator.newInstance(implType, resolveResult.getFailure())); } else { artifacts.add(instantiator.newInstance(implType, resolveResult.getFile())); } } }
Example #5
Source File: DefaultArtifactResolutionQuery.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private <T extends JvmLibraryArtifact> void addJvmLibraryArtifacts(Set<T> artifacts, Class<T> type, Class<? extends T> implType, ComponentMetaData component, ArtifactResolver artifactResolver) { ArtifactResolveContext context = new ArtifactTypeResolveContext(type); BuildableArtifactSetResolveResult artifactSetResolveResult = new DefaultBuildableArtifactSetResolveResult(); artifactResolver.resolveModuleArtifacts(component, context, artifactSetResolveResult); Instantiator instantiator = new DirectInstantiator(); for (ComponentArtifactMetaData artifactMetaData : artifactSetResolveResult.getArtifacts()) { BuildableArtifactResolveResult resolveResult = new DefaultBuildableArtifactResolveResult(); artifactResolver.resolveArtifact(artifactMetaData, component.getSource(), resolveResult); if (resolveResult.getFailure() != null) { artifacts.add(instantiator.newInstance(implType, resolveResult.getFailure())); } else { artifacts.add(instantiator.newInstance(implType, resolveResult.getFile())); } } }
Example #6
Source File: ProtocolToModelAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void invoke(MethodInvocation invocation) throws Throwable { if (current.get() != null) { // Already invoking a method on the mix-in return; } if (instance == null) { instance = new DirectInstantiator().newInstance(mixInClass, proxy); } MethodInvocation beanInvocation = new MethodInvocation(invocation.getName(), invocation.getReturnType(), invocation.getGenericReturnType(), invocation.getParameterTypes(), instance, invocation.getParameters()); current.set(beanInvocation); try { next.invoke(beanInvocation); } finally { current.set(null); } if (beanInvocation.found()) { invocation.setResult(beanInvocation.getResult()); } }
Example #7
Source File: ThreadGlobalInstantiator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public static Instantiator getOrCreate() { Instantiator instantiator = get(); if (instantiator != null) { return instantiator; } else { return new ClassGeneratorBackedInstantiator(new AsmBackedClassGenerator(), new DirectInstantiator()); } }
Example #8
Source File: ServiceLocator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public T newInstance(Object... params) { Instantiator instantiator = new DirectInstantiator(); try { return instantiator.newInstance(implementationClass, params); } catch (ObjectInstantiationException t) { throw new RuntimeException(String.format("Could not create an implementation of service '%s'.", serviceType.getName()), t); } }
Example #9
Source File: BaseLanguageSourceSet.java From javaide with GNU General Public License v3.0 | 5 votes |
public static <T extends LanguageSourceSet> T create(Class<? extends LanguageSourceSet> publicType, Class<T> implementationType, ComponentSpecIdentifier componentId, SourceDirectorySetFactory sourceDirectorySetFactory) { NEXT_SOURCE_SET_INFO.set(new SourceSetInfo(componentId, publicType, sourceDirectorySetFactory)); try { try { return DirectInstantiator.INSTANCE.newInstance(implementationType); } catch (ObjectInstantiationException e) { throw new ModelInstantiationException(String.format("Could not create LanguageSourceSet of type %s", publicType.getSimpleName()), e.getCause()); } } finally { NEXT_SOURCE_SET_INFO.set(null); } }
Example #10
Source File: ServiceLocator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public T newInstance(Object... params) { Instantiator instantiator = new DirectInstantiator(); try { return instantiator.newInstance(implementationClass, params); } catch (ObjectInstantiationException t) { throw new RuntimeException(String.format("Could not create an implementation of service '%s'.", serviceType.getName()), t); } }
Example #11
Source File: ThreadGlobalInstantiator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static Instantiator getOrCreate() { Instantiator instantiator = get(); if (instantiator != null) { return instantiator; } else { return new ClassGeneratorBackedInstantiator(new AsmBackedClassGenerator(), new DirectInstantiator()); } }
Example #12
Source File: ServiceLocator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public T newInstance(Object... params) { Instantiator instantiator = new DirectInstantiator(); try { return instantiator.newInstance(implementationClass, params); } catch (ObjectInstantiationException t) { throw new RuntimeException(String.format("Could not create an implementation of service '%s'.", serviceType.getName()), t); } }
Example #13
Source File: ThreadGlobalInstantiator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public static Instantiator getOrCreate() { Instantiator instantiator = get(); if (instantiator != null) { return instantiator; } else { return new ClassGeneratorBackedInstantiator(new AsmBackedClassGenerator(), new DirectInstantiator()); } }
Example #14
Source File: ThreadGlobalInstantiator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public static Instantiator getOrCreate() { Instantiator instantiator = get(); if (instantiator != null) { return instantiator; } else { return new ClassGeneratorBackedInstantiator(new AsmBackedClassGenerator(), new DirectInstantiator()); } }
Example #15
Source File: ServiceLocator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public T newInstance(Object... params) { Instantiator instantiator = new DirectInstantiator(); try { return instantiator.newInstance(implementationClass, params); } catch (ObjectInstantiationException t) { throw new RuntimeException(String.format("Could not create an implementation of service '%s'.", serviceType.getName()), t); } }
Example #16
Source File: ReflectiveNamedDomainObjectFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ReflectiveNamedDomainObjectFactory(Class<? extends T> type, Object... extraArgs) { this(type, new DirectInstantiator(), extraArgs); }
Example #17
Source File: WrapUtil.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
/** * Wraps the given items in a named domain object set. */ public static <T extends Named> NamedDomainObjectSet<T> toNamedDomainObjectSet(Class<T> type, T... items) { DefaultNamedDomainObjectSet<T> domainObjectSet = new DefaultNamedDomainObjectSet<T>(type, new DirectInstantiator()); CollectionUtils.addAll(domainObjectSet, items); return domainObjectSet; }
Example #18
Source File: AbstractClassGenerator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public <T> T newInstance(Class<T> type, Object... parameters) { Instantiator instantiator = new DirectInstantiator(); return instantiator.newInstance(generate(type), parameters); }
Example #19
Source File: GlobalScopeServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
Instantiator createInstantiator(ClassGenerator classGenerator) { return new ClassGeneratorBackedInstantiator(classGenerator, new DirectInstantiator()); }
Example #20
Source File: AbstractClassGenerator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public <T> T newInstance(Class<T> type, Object... parameters) { Instantiator instantiator = new DirectInstantiator(); return instantiator.newInstance(generate(type), parameters); }
Example #21
Source File: ComponentTypeRuleDefinitionHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ComponentTypeRuleDefinitionHandler(final Instantiator instantiator) { super("component", ComponentType.class, ComponentSpec.class, BaseComponentSpec.class, ComponentTypeBuilder.class, JavaReflectionUtil.factory(new DirectInstantiator(), DefaultComponentTypeBuilder.class), new RegistrationAction(instantiator)); }
Example #22
Source File: GlobalScopeServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
Instantiator createInstantiator(ClassGenerator classGenerator) { return new ClassGeneratorBackedInstantiator(classGenerator, new DirectInstantiator()); }
Example #23
Source File: ReflectiveNamedDomainObjectFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ReflectiveNamedDomainObjectFactory(Class<? extends T> type, Object... extraArgs) { this(type, new DirectInstantiator(), extraArgs); }
Example #24
Source File: BinaryTypeRuleDefinitionHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public BinaryTypeRuleDefinitionHandler(final Instantiator instantiator) { super("binary", BinaryType.class, BinarySpec.class, BaseBinarySpec.class, BinaryTypeBuilder.class, JavaReflectionUtil.factory(new DirectInstantiator(), DefaultBinaryTypeBuilder.class), new RegistrationAction(instantiator)); }
Example #25
Source File: ComponentTypeRuleDefinitionHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ComponentTypeRuleDefinitionHandler(final Instantiator instantiator) { super("component", ComponentType.class, ComponentSpec.class, BaseComponentSpec.class, ComponentTypeBuilder.class, JavaReflectionUtil.factory(new DirectInstantiator(), DefaultComponentTypeBuilder.class), new RegistrationAction(instantiator)); }
Example #26
Source File: GlobalScopeServices.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
Instantiator createInstantiator(ClassGenerator classGenerator) { return new ClassGeneratorBackedInstantiator(classGenerator, new DirectInstantiator()); }
Example #27
Source File: AbstractClassGenerator.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public <T> T newInstance(Class<T> type, Object... parameters) { Instantiator instantiator = new DirectInstantiator(); return instantiator.newInstance(generate(type), parameters); }
Example #28
Source File: ReflectiveNamedDomainObjectFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ReflectiveNamedDomainObjectFactory(Class<? extends T> type, Object... extraArgs) { this(type, new DirectInstantiator(), extraArgs); }
Example #29
Source File: WrapUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
/** * Wraps the given items in a named domain object set. */ public static <T extends Named> NamedDomainObjectSet<T> toNamedDomainObjectSet(Class<T> type, T... items) { DefaultNamedDomainObjectSet<T> domainObjectSet = new DefaultNamedDomainObjectSet<T>(type, new DirectInstantiator()); CollectionUtils.addAll(domainObjectSet, items); return domainObjectSet; }
Example #30
Source File: GlobalScopeServices.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
Instantiator createInstantiator(ClassGenerator classGenerator) { return new ClassGeneratorBackedInstantiator(classGenerator, new DirectInstantiator()); }