當前位置: 首頁>>代碼示例>>Java>>正文


Java InjectionTargetInformation類代碼示例

本文整理匯總了Java中org.needle4j.injection.InjectionTargetInformation的典型用法代碼示例。如果您正苦於以下問題:Java InjectionTargetInformation類的具體用法?Java InjectionTargetInformation怎麽用?Java InjectionTargetInformation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InjectionTargetInformation類屬於org.needle4j.injection包,在下文中一共展示了InjectionTargetInformation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createArguments

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
private Object[] createArguments(final Class<?>[] parameterTypes,
        final InjectionTargetInformationFactory injectionTargetInformationFactory) {
    final Object[] arguments = new Object[parameterTypes.length];

    for (int i = 0; i < parameterTypes.length; i++) {
        final InjectionTargetInformation injectionTargetInformation = injectionTargetInformationFactory.create(
                parameterTypes[i], i);

        final Entry<Object, Object> injection = inject(injectionTargetInformation);

        if (injection != null) {
            arguments[i] = injection.getValue();
        }

    }

    return arguments;
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:19,代碼來源:NeedleTestcase.java

示例2: initFields

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
private void initFields(final Object instance) {

        final List<Field> fields = ReflectionUtil.getAllFieldsWithSupportedAnnotation(instance.getClass(),
                isSupportedAnnotationPredicate);

        for (final Field field : fields) {
            final InjectionTargetInformation injectionTargetInformation = new InjectionTargetInformation(
                    field.getType(), field);

            final Entry<Object, Object> injection = inject(injectionTargetInformation);

            if (injection != null) {
                try {
                    ReflectionUtil.setField(field, instance, injection.getValue());

                } catch (final Exception e) {
                    LOG.error(e.getMessage(), e);
                }
            }
        }

    }
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:23,代碼來源:NeedleTestcase.java

示例3: inject

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
private Entry<Object, Object> inject(final InjectionTargetInformation injectionTargetInformation) {
    for (final Collection<InjectionProvider<?>> collection : configuration.getInjectionProvider()) {
        final Entry<Object, Object> injection = configuration.handleInjectionProvider(collection,
                injectionTargetInformation);
        if (injection != null) {

            final Object injectionKey = injection.getKey();
            // check if mock object already created
            final Object injectionValue = context.getInjectedObject(injectionKey) == null ? injection.getValue()
                    : context.getInjectedObject(injectionKey);

            context.addInjectedObject(injectionKey, injectionValue);
            return new MapEntry<Object, Object>(injectionKey, injectionValue);
        }
    }

    return null;
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:19,代碼來源:NeedleTestcase.java

示例4: initMethodInjection

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
private void initMethodInjection(final Object instance) {
    final List<Method> methods = ReflectionUtil.getMethods(instance.getClass());

    for (final Method method : methods) {
        // if the method is not annotated with at least one supported
        // annotation, skip it!
        if (!isSupportedAnnotationPredicate.applyAny(method.getDeclaredAnnotations())) {
            continue;
        }

        final Class<?>[] parameterTypes = method.getParameterTypes();

        final InjectionTargetInformationFactory injectionTargetInformationFactory = new InjectionTargetInformationFactory() {

            @Override
            public InjectionTargetInformation create(final Class<?> parameterType, final int parameterIndex) {

                return new InjectionTargetInformation(parameterType, method,
                        method.getGenericParameterTypes()[parameterIndex],
                        method.getParameterAnnotations()[parameterIndex]);
            }
        };
        final Object[] arguments = createArguments(parameterTypes, injectionTargetInformationFactory);

        try {
            ReflectionUtil.invokeMethod(method, instance, arguments);
        } catch (final Exception e) {
            LOG.warn("could not invoke method", e);
        }

    }
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:33,代碼來源:NeedleTestcase.java

示例5: getInstanceByConstructorInjection

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
protected Object getInstanceByConstructorInjection(final Class<?> implementation)
        throws ObjectUnderTestInstantiationException {
    final Constructor<?>[] constructors = implementation.getConstructors();

    for (final Constructor<?> constructor : constructors) {
        // has the constructor at least one supported injection annotation?
        if (!isSupportedAnnotationPredicate.applyAny(constructor.getAnnotations())) {
            continue;
        }

        final Class<?>[] parameterTypes = constructor.getParameterTypes();
        final InjectionTargetInformationFactory injectionTargetInformationFactory = new InjectionTargetInformationFactory() {

            @Override
            public InjectionTargetInformation create(final Class<?> parameterType, final int parameterIndex) {
                return new InjectionTargetInformation(parameterType, constructor,
                        constructor.getGenericParameterTypes()[parameterIndex],
                        constructor.getParameterAnnotations()[parameterIndex]);
            }
        };

        final Object[] arguments = createArguments(parameterTypes, injectionTargetInformationFactory);

        try {
            return constructor.newInstance(arguments);
        } catch (final Exception e) {
            throw new ObjectUnderTestInstantiationException(e);
        }

    }

    return null;
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:34,代碼來源:NeedleTestcase.java

示例6: EntityManagerProvider

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
public EntityManagerProvider(final DatabaseTestcase databaseTestcase) {
    super();
    this.databaseTestcase = databaseTestcase;
    verifyer = new InjectionVerifier() {

        @Override
        public boolean verify(final InjectionTargetInformation information) {
            if (information.getType() == EntityManager.class) {
                return true;
            }
            return false;
        }
    };

}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:16,代碼來源:EntityManagerProvider.java

示例7: EntityManagerFactoryProvider

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
EntityManagerFactoryProvider(final DatabaseTestcase databaseTestcase) {
    super();
    this.databaseTestcase = databaseTestcase;
    verifier = new InjectionVerifier() {

        @Override
        public boolean verify(final InjectionTargetInformation information) {
            if (information.getType() == EntityManagerFactory.class) {
                return true;
            }
            return false;
        }
    };

}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:16,代碼來源:EntityManagerFactoryProvider.java

示例8: testVerify

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Test
public void testVerify() throws Exception {
    InjectionTargetInformation injectionTargetInformation = new InjectionTargetInformation(TransactionHelper.class,
            ReflectionUtil.getField(this.getClass(), "helper"));
    assertTrue(provider.verify(injectionTargetInformation));
    assertNotNull(provider.getInjectedObject(TransactionHelper.class));
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:8,代碼來源:TransactionHelperProviderTest.java

示例9: verify

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public boolean verify(InjectionTargetInformation injectionTargetInformation) {
  final Class<?> type = injectionTargetInformation.getType();
  return type.isAssignableFrom(mockProvider.getClass());
}
 
開發者ID:zaplatynski,項目名稱:fsm-packagetype,代碼行數:6,代碼來源:MavenProjectInjectionProvider.java

示例10: getKey

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public Object getKey(InjectionTargetInformation injectionTargetInformation) {
  return MockProvider.class;
}
 
開發者ID:zaplatynski,項目名稱:fsm-packagetype,代碼行數:5,代碼來源:MavenProjectInjectionProvider.java

示例11: getKey

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public Object getKey(final InjectionTargetInformation injectionTargetInformation) {
  return injectionProviderDelegate.getKey(injectionTargetInformation);
}
 
開發者ID:camunda,項目名稱:camunda-bpm-jbehave,代碼行數:5,代碼來源:CamundaSupport.java

示例12: verify

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public boolean verify(final InjectionTargetInformation injectionTargetInformation) {
  return injectionProviderDelegate.verify(injectionTargetInformation);
}
 
開發者ID:camunda,項目名稱:camunda-bpm-jbehave,代碼行數:5,代碼來源:CamundaSupport.java

示例13: verify

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public boolean verify(InjectionTargetInformation information) {
    return information.getType() == EntityTransaction.class ? true : false;
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:5,代碼來源:EntityTransactionProvider.java

示例14: getKey

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public Object getKey(InjectionTargetInformation information) {
    return EntityTransaction.class;
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:5,代碼來源:EntityTransactionProvider.java

示例15: verify

import org.needle4j.injection.InjectionTargetInformation; //導入依賴的package包/類
@Override
public boolean verify(InjectionTargetInformation information) {
    return information.getType() == TransactionHelper.class ? true : false;
}
 
開發者ID:needle4j,項目名稱:needle4j,代碼行數:5,代碼來源:TransactionHelperProvider.java


注:本文中的org.needle4j.injection.InjectionTargetInformation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。