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


Java FieldSignature类代码示例

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


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

示例1: non_method_joinpoints_cant_be_cached

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@Test
public void non_method_joinpoints_cant_be_cached() throws Throwable {
    // Given
    ProceedingJoinPoint pjp = mock(ProceedingJoinPoint.class);
    when(pjp.getSignature()).thenReturn(mock(FieldSignature.class));
    when(pjp.proceed()).thenReturn(new Result("foo"), new Result("foo"));

    // When
    Result firstResult = (Result) aspect.getMemoizedResultOrProceed(pjp);
    Result secondResult = (Result) aspect.getMemoizedResultOrProceed(pjp);

    // Then
    assertThat(firstResult != secondResult, is(true));
    assertThat(firstResult, equalTo(secondResult));
    verify(pjp, times(2)).proceed();
}
 
开发者ID:deezer,项目名称:Counsel,代码行数:17,代码来源:CacheableAspectTest.java

示例2: args

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@Around("set(@com.lib.logthisannotations.annotation.LogThis * *) && args(newVal) && target(t)")
public void weaveBeforeFieldLogThisJoinPoint(ProceedingJoinPoint joinPoint, Object t, Object newVal) throws Throwable {
    Logger logger = Logger.getInstance();
    if(logger != null && logger.isLoggerEnabled()) {
        FieldSignature fs = (FieldSignature) joinPoint.getSignature();
        String fieldName = fs.getName();
        Field field = fs.getField();
        field.setAccessible(true);
        Object oldVal = field.get(t);
        LogThis annotation = field.getAnnotation(com.lib.logthisannotations.annotation.LogThis.class);
        LoggerLevel loggerLevel = annotation.logger();
        StringBuilder builder = Strings.getStringFieldBuilder(fieldName, String.valueOf(oldVal), String.valueOf(newVal));

        logger.getLoggerInstance().log(t.getClass().getName(), "Field " + builder.toString(), loggerLevel, annotation.write());
        joinPoint.proceed();
    }
}
 
开发者ID:luispereira,项目名称:LogThis,代码行数:18,代码来源:LogAspect.java

示例3: getAnnotation

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
private static Annotation getAnnotation(final Signature signature,
                            final Class<? extends Annotation> annotationClass) {
    if (signature instanceof ConstructorSignature) {
        final Constructor<?> ctor = ConstructorSignature.class.cast(signature)
                                .getConstructor();
        return ctor.getAnnotation(annotationClass);
    } else if (signature instanceof MethodSignature) {
        return MethodSignature.class.cast(signature)
                .getMethod()
                .getAnnotation(annotationClass);
    } else if (signature instanceof FieldSignature) {
        return FieldSignature.class.cast(signature)
                .getField()
                .getAnnotation(annotationClass);
    }

    throw new RuntimeException(
            "Unsupported signature type " + signature.getClass().getName()
        );
}
 
开发者ID:cardillo,项目名称:joinery,代码行数:21,代码来源:Metrics.java

示例4: get

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@Around("target(object) && " +
		"(get([email protected] * @at.ac.tuwien.infosys.jcloudscale.annotations.CloudObject *.*) || " +
		" get([email protected] * @at.ac.tuwien.infosys.jcloudscale.annotations.CloudObjectParent *.*))")
public Object getCloudObjectField(Object object, ProceedingJoinPoint pjp) throws Throwable {
	
	// 
	
	if(JCloudScaleConfiguration.isServerContext())
		return pjp.proceed();
	
	UUID id = CloudObjects.getId(object);
	
	if(id == null) {
		// maybe we are just working on a cloudobjectparent that is not actually a cloud object
		return pjp.proceed();
	}
	
	FieldSignature sig = (FieldSignature) pjp.getSignature();
	Field field = sig.getField();
	
	return getFieldValue(id, field);
	
}
 
开发者ID:xLeitix,项目名称:jcloudscale,代码行数:24,代码来源:CloudObjectAspect.java

示例5: set

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@Around("args(newval) && set(@at.ac.tuwien.infosys.jcloudscale.annotations.CloudGlobal static * *.*)")
public void writeStaticValueToClient(ProceedingJoinPoint pjp, Object newval) throws Throwable {
	
	if(!JCloudScaleConfiguration.isServerContext())
	{
		pjp.proceed();
		return;
	}
	
	try(IMQWrapper mq = JCloudScaleConfiguration.createMQWrapper()) {
		UUID corrId = UUID.randomUUID();
		
		FieldSignature sig = (FieldSignature) pjp.getSignature();
		Field field = sig.getField();
		
		Object newValProcessed = JCloudScaleReferenceManager.getInstance().processField(field, newval);
		byte[] serialzed = SerializationUtil.serializeToByteArray(newValProcessed);
				
		SetStaticValueRequest req = new SetStaticValueRequest();
		req.setField(field.getName());
		req.setClassName(field.getDeclaringClass().getCanonicalName());
		req.setValue(serialzed);
		
		mq.createQueueProducer(JCloudScaleConfiguration.getConfiguration().server().getStaticFieldWriteRequestQueueName());
		mq.createTopicConsumer(JCloudScaleConfiguration.getConfiguration().server().getStaticFieldWriteResponseTopicName(),
				"JMSCorrelationID = '"+corrId.toString()+"'");
		
		// we send request and wait for response to ensure that we in fact 
		// changed the value before continuing. 
		mq.requestResponse(req, corrId);
		
	} catch (JMSException | NamingException | IOException e) {
		e.printStackTrace();
		log.severe("Could not write static field: "+e.getMessage());
	}
		
}
 
开发者ID:xLeitix,项目名称:jcloudscale,代码行数:38,代码来源:StaticFieldAspect.java

示例6: args

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@Around("target(object) && args(val) && " +
		"(set([email protected] * @at.ac.tuwien.infosys.jcloudscale.annotations.CloudObject *.*) || " +
		" set([email protected] * @at.ac.tuwien.infosys.jcloudscale.annotations.CloudObjectParent *.*))")
public void setCloudObjectField(Object object, Object val, ProceedingJoinPoint pjp) throws Throwable {
	
	if(JCloudScaleConfiguration.isServerContext()) {
		pjp.proceed();
		return;
	}
	
	UUID id = CloudObjects.getId(object);
	
	if(id == null) {
		// maybe we are just working on a cloudobjectparent that is not actually a cloud object
		pjp.proceed();
		return;
	}
	
	if(CloudObjects.isDestroyed(id)) {
		// throw new JCloudScaleException("Field access on already destroyed CloudObject!");
		// this case happens during regular object construction - just proceed
		pjp.proceed();
		return;
	}
	
	FieldSignature sig = (FieldSignature) pjp.getSignature();
	Field field = sig.getField();
	
	setFieldValue(id, field, val);
	
}
 
开发者ID:xLeitix,项目名称:jcloudscale,代码行数:32,代码来源:CloudObjectAspect.java

示例7: createFieldSignatureMock

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
private Signature createFieldSignatureMock(String fieldName) {
    final FieldSignature fieldSignature = mock(FieldSignature.class);
    when(fieldSignature.getField()).thenReturn(resolveField(fieldName));

    LOGGER.debug("FieldSignature Mock - getField() = {}", fieldSignature.getField());

    return fieldSignature;
}
 
开发者ID:loddar,项目名称:ajunit,代码行数:9,代码来源:FieldJoinPointMatcherTest.java

示例8: withParameterAnnotation

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@After("setValueToAnyField() && withParameterAnnotation()")
public void parameterValueChanged(JoinPoint joinPoint) {
    try {
        FieldSignature fieldSignature = (FieldSignature) joinPoint.getSignature();
        Parameter parameter = fieldSignature.getField().getAnnotation(Parameter.class);
        String name = parameter.value().isEmpty() ? fieldSignature.getName() : parameter.value();
        Allure.LIFECYCLE.fire(new AddParameterEvent(name, joinPoint.getArgs()[0].toString()));
    } catch (Exception ignored) {
    }
}
 
开发者ID:allure-framework,项目名称:allure1,代码行数:11,代码来源:AllureParametersAspects.java

示例9: FieldSetTest

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
public FieldSetTest() {
    super("eval.org.aspectj.lang.FieldSetAspect", JoinPoint.FIELD_SET, FieldSignature.class);
}
 
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:FieldSetTest.java

示例10: FieldGetTest

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
public FieldGetTest() {
    super("eval.org.aspectj.lang.FieldGetAspect", JoinPoint.FIELD_GET, FieldSignature.class);
}
 
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:FieldGetTest.java

示例11: FieldJoinPointMatcher

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
FieldJoinPointMatcher(AjJoinPointType joinPointType) {
    super(joinPointType, FieldSignature.class);
}
 
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:FieldJoinPointMatcher.java

示例12: doMatchSignature

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
@Override
protected boolean doMatchSignature(FieldSignature signature, AjJoinPoint ajUnitJoinPoint) {
    return signature.getField().equals(ajUnitJoinPoint.getField());
}
 
开发者ID:loddar,项目名称:ajunit,代码行数:5,代码来源:FieldJoinPointMatcher.java

示例13: access

import org.aspectj.lang.reflect.FieldSignature; //导入依赖的package包/类
/**
 * Aspect advice triggered on the access of all fields carrying an
 * {@link com.github.msoliter.iroh.container.annotations.Autowired} 
 * annotation. If the field has been marked for lazy injection, and has not 
 * been injected with an instance yet, this advice will properly initialize 
 * that field.
 * 
 * @param thisJoinPoint The join point carrying critical information about
 *  which field is being accessed, as well as its current contents.
 */
@Before("external() && access()")
public void lazilyInjectField(JoinPoint thisJoinPoint) {
    FieldSignature fs = (FieldSignature) thisJoinPoint.getSignature();
    Field field = fs.getField();
    Object target = thisJoinPoint.getTarget();
    injector.lazilyInject(target, field);
}
 
开发者ID:misha,项目名称:iroh,代码行数:18,代码来源:IrohAspect.java


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