当前位置: 首页>>代码示例>>Java>>正文


Java Requirement类代码示例

本文整理汇总了Java中org.codehaus.plexus.component.annotations.Requirement的典型用法代码示例。如果您正苦于以下问题:Java Requirement类的具体用法?Java Requirement怎么用?Java Requirement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Requirement类属于org.codehaus.plexus.component.annotations包,在下文中一共展示了Requirement类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createComponentRequirement

import org.codehaus.plexus.component.annotations.Requirement; //导入依赖的package包/类
public static ComponentRequirement createComponentRequirement(Field field, Requirement requirement) {
    ComponentRequirement cr = new ComponentRequirement();
    cr.setFieldName(field.getName());
    cr.setOptional(requirement.optional());
    if (requirement.role() != null && requirement.role() != Object.class) {
        cr.setRole(requirement.role().getName());
    }
    else {
        cr.setRole(field.getType().getName());
    }
    if (requirement.hint() != null) {
        cr.setRoleHint(requirement.hint());
    }

    return cr;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:17,代码来源:AludraServiceUtil.java

示例2: createComponentRequirement

import org.codehaus.plexus.component.annotations.Requirement; //导入依赖的package包/类
private static ComponentRequirement createComponentRequirement(Field field, Requirement requirement) {
    ComponentRequirement cr = new ComponentRequirement();
    cr.setFieldName(field.getName());
    cr.setOptional(requirement.optional());
    if (requirement.role() != null && requirement.role() != Object.class) {
        cr.setRole(requirement.role().getName());
    }
    else {
        cr.setRole(field.getType().getName());
    }
    if (requirement.hint() != null) {
        cr.setRoleHint(requirement.hint());
    }

    return cr;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:17,代码来源:DefaultGUIComponentFactory.java

示例3: buildComponentDescriptor

import org.codehaus.plexus.component.annotations.Requirement; //导入依赖的package包/类
private <T> ComponentDescriptor<T> buildComponentDescriptor(Class<?> ifaceClass, Class<T> implClass, ClassRealm realm) {
    ComponentDescriptor<T> desc = new ComponentDescriptor<T>(implClass, realm);
    desc.setRole(ifaceClass.getName());

    // check for AludraTest singleton strategy
    InternalComponent ic = ifaceClass.getAnnotation(InternalComponent.class);
    if (ic != null && ic.singleton()) {
        desc.setInstantiationStrategy("singleton");
    }

    // check for Plexus Requirements
    for (Field f : implClass.getDeclaredFields()) {
        Requirement req = f.getAnnotation(Requirement.class);
        if (req != null) {
            desc.addRequirement(buildRequirement(f, req));
        }
    }

    return desc;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:21,代码来源:AludraTestComponentDiscoverer.java

示例4: buildRequirement

import org.codehaus.plexus.component.annotations.Requirement; //导入依赖的package包/类
private ComponentRequirement buildRequirement(Field field, Requirement requirement) {
    ComponentRequirement req = new ComponentRequirement();
    req.setFieldName(field.getName());

    if (requirement.role() != null && requirement.role() != Object.class) {
        req.setRole(requirement.role().getName());
    }
    else {
        req.setRole(field.getType().getName());
    }

    if (requirement.hint() != null && requirement.hint().length() > 0) {
        req.setRoleHint(requirement.hint());
    }

    if (requirement.optional()) {
        req.setOptional(true);
    }

    return req;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:22,代码来源:AludraTestComponentDiscoverer.java

示例5: createComponentDescriptor

import org.codehaus.plexus.component.annotations.Requirement; //导入依赖的package包/类
private <T> ComponentDescriptor<T> createComponentDescriptor(Class<T> iface, String instanceName, ClassRealm realm)
        throws ClassNotFoundException {
    ComponentDescriptor<T> cd = new ComponentDescriptor<T>();
    cd.setRole(iface.getName());
    cd.setRoleClass(iface);
    if (instanceName != null) {
        cd.setRoleHint(instanceName);
    }

    String implClass = serviceRegistry.getImplementationClassName(iface.getName());
    if (implClass == null) {
        throw new AutomationException("No implementor class configured for interface " + iface.getName());
    }
    cd.setImplementation(implClass);
    cd.setInstantiationStrategy(AludraServiceUtil.isSingleton(iface) ? "singleton" : "per-lookup");
    cd.setRealm(realm);

    // lookup Requirements in class and parent classes
    Class<?> clazz = realm.loadClass(implClass);
    while (clazz != null && clazz != Object.class) {
        for (Field f : clazz.getDeclaredFields()) {
            Requirement req = f.getAnnotation(Requirement.class);
            if (req != null) {
                cd.addRequirement(AludraServiceUtil.createComponentRequirement(f, req));
            }
        }
        clazz = clazz.getSuperclass();
    }

    return cd;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:32,代码来源:AludraServiceManagerImpl.java

示例6: registerComponentDescriptor

import org.codehaus.plexus.component.annotations.Requirement; //导入依赖的package包/类
private <T> void registerComponentDescriptor(Class<T> componentClass, Class<? extends T> implClass)
        throws CycleDetectedInComponentGraphException, ComponentLookupException {
    if (!componentClass.isAssignableFrom(implClass)) {
        throw new ComponentLookupException("Class " + implClass.getName() + " does not implement interface "
                + componentClass.getName(), componentClass.getName(), getRoleHint());
    }

    ComponentDescriptor<T> desc = new ComponentDescriptor<T>();
    desc.setRole(componentClass.getName());
    desc.setRoleClass(componentClass);
    desc.setRoleHint(getRoleHint());
    desc.setImplementationClass(implClass);
    desc.setIsolatedRealm(false);
    desc.setInstantiationStrategy("per-lookup");

    ClassRealm realm = plexusContainer.getLookupRealm();
    if (realm == null) {
        realm = plexusContainer.getContainerRealm();
    }
    desc.setRealm(realm);

    // lookup Requirements in class and parent classes
    Class<?> clazz = implClass;
    while (clazz != null && clazz != Object.class) {
        for (Field f : implClass.getDeclaredFields()) {
            Requirement req = f.getAnnotation(Requirement.class);
            if (req != null) {
                desc.addRequirement(createComponentRequirement(f, req));
            }

        }
        clazz = clazz.getSuperclass();
    }

    plexusContainer.addComponentDescriptor(desc);
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:37,代码来源:DefaultGUIComponentFactory.java


注:本文中的org.codehaus.plexus.component.annotations.Requirement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。