本文整理汇总了Java中org.aspectj.lang.reflect.ConstructorSignature类的典型用法代码示例。如果您正苦于以下问题:Java ConstructorSignature类的具体用法?Java ConstructorSignature怎么用?Java ConstructorSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorSignature类属于org.aspectj.lang.reflect包,在下文中一共展示了ConstructorSignature类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: allConstructors
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Around("execution((@net.sf.oval.guard.Guarded *).new(..))")
public Object allConstructors(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
final ConstructorSignature signature = (ConstructorSignature) thisJoinPoint.getSignature();
LOG.debug("aroundConstructor() {1}", signature);
final Constructor<?> ctor = signature.getConstructor();
final Object[] args = thisJoinPoint.getArgs();
final Object target = thisJoinPoint.getTarget();
// pre conditions
{
guard.guardConstructorPre(target, ctor, args);
}
final Object result = thisJoinPoint.proceed();
// post conditions
{
guard.guardConstructorPost(target, ctor, args);
}
return result;
}
开发者ID:sebthom,项目名称:oval,代码行数:25,代码来源:GuardAspect2.java
示例2: getAnnotation
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的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
示例3: createNewCloudObject
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Around("call([email protected] (@at.ac.tuwien.infosys.jcloudscale.annotations.CloudObject *).new(..))")
public Object createNewCloudObject(ProceedingJoinPoint jp) throws Throwable
{
// check if we are running in a server context
if(JCloudScaleConfiguration.isServerContext())
return jp.proceed();
Class<?> coType = jp.getSignature().getDeclaringType();
Constructor<?> constructor = ((ConstructorSignature)jp.getSignature()).getConstructor();
// check if this is already a CGLib modified class
// TODO: it would be more efficient to add this to the pointcut def above
if(CgLibUtil.isCGLibEnhancedClass(coType))
return jp.proceed();
return deployCloudObject(coType, jp.getArgs(), constructor);
}
开发者ID:xLeitix,项目名称:jcloudscale,代码行数:19,代码来源:CloudObjectAspect.java
示例4: createByDefaultConstructor
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Test
public void createByDefaultConstructor() throws Exception {
// act / when
final InitializationTestFixture testFixture = new InitializationTestFixture();
// assert / then
assertJoinPoint(new AdditionalAssert() {
@Override
public void additionalAssert(final JoinPoint joinPoint, final String thisContext, final String targetContext) {
assertThat("This?", joinPoint.getThis(), sameInstance((Object) testFixture));
assertThat("Target?", joinPoint.getTarget(), sameInstance((Object) testFixture));
assertThat("#Arguments?", joinPoint.getArgs().length, is(0));
assertThat("This context?", thisContext, is("InitializationTestFixture{anyValue='default'}"));
assertThat("Target context?", targetContext, is("InitializationTestFixture{anyValue='default'}"));
assertThat("Constructor?", ((ConstructorSignature)joinPoint.getSignature()).getConstructor().toString(),
is("public eval.org.aspectj.lang.fixture.InitializationTestFixture()"));
}
});
}
开发者ID:loddar,项目名称:ajunit,代码行数:20,代码来源:InitializationTest.java
示例5: createByConstructorWithParameter
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Test
public void createByConstructorWithParameter() throws Exception {
// act / when
final InitializationTestFixture testFixture = new InitializationTestFixture("MY_VALUE");
// assert / then
assertJoinPoint(new AdditionalAssert() {
@Override
public void additionalAssert(final JoinPoint joinPoint, final String thisContext, final String targetContext) {
assertThat("This?", joinPoint.getThis(), sameInstance((Object) testFixture));
assertThat("Target?", joinPoint.getTarget(), sameInstance((Object) testFixture));
assertThat("#Arguments?", joinPoint.getArgs().length, is(1));
assertThat("Argument value?", joinPoint.getArgs()[0], is((Object)"MY_VALUE"));
assertThat("This context?", thisContext, is("InitializationTestFixture{anyValue='MY_VALUE'}"));
assertThat("Target context?", targetContext, is("InitializationTestFixture{anyValue='MY_VALUE'}"));
assertThat("Constructor?", ((ConstructorSignature)joinPoint.getSignature()).getConstructor().toString(),
is("public eval.org.aspectj.lang.fixture.InitializationTestFixture(java.lang.String)"));
}
});
}
开发者ID:loddar,项目名称:ajunit,代码行数:21,代码来源:InitializationTest.java
示例6: createByDefaultConstructor
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Test
public void createByDefaultConstructor() throws Exception {
// act / when
final PreInitializationTestFixture testFixture=new PreInitializationTestFixture();
// assert / then
assertJoinPoint(new AdditionalAssert() {
@Override
public void additionalAssert(final JoinPoint joinPoint, final String thisContext, final String targetContext) {
assertThat("This?", joinPoint.getThis(), nullValue());
assertThat("Target?", joinPoint.getTarget(), nullValue());
assertThat("#Arguments?", joinPoint.getArgs().length, is(0));
assertThat("Constructor?", ((ConstructorSignature)joinPoint.getSignature()).getConstructor().toString(),
is("public eval.org.aspectj.lang.fixture.PreInitializationTestFixture()"));
}
});
}
开发者ID:loddar,项目名称:ajunit,代码行数:18,代码来源:PreInitializationTest.java
示例7: createByConstructorWithParameter
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Test
public void createByConstructorWithParameter() throws Exception {
// act / when
final PreInitializationTestFixture testFixture=new PreInitializationTestFixture("MY_VALUE");
// assert / then
assertJoinPoint(new AdditionalAssert() {
@Override
public void additionalAssert(final JoinPoint joinPoint, final String thisContext, final String targetContext) {
assertThat("This?", joinPoint.getThis(), nullValue());
assertThat("Target?", joinPoint.getTarget(), nullValue());
assertThat("#Arguments?", joinPoint.getArgs().length, is(1));
assertThat("Argument value?", joinPoint.getArgs()[0], is((Object) "MY_VALUE"));
assertThat("Constructor?", ((ConstructorSignature)joinPoint.getSignature()).getConstructor().toString(),
is("public eval.org.aspectj.lang.fixture.PreInitializationTestFixture(java.lang.String)"));
}
});
}
开发者ID:loddar,项目名称:ajunit,代码行数:19,代码来源:PreInitializationTest.java
示例8: traceAndMeasureConstructorJoinPoint
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
/**
* Generate traces and gather statistics on a method.
*
* @param point The proceeding join point.
* @param gatherSizeLevel Logging level at which the returned value of the function should be measured.
* @param secure Is the method secure ? If so, both the arguments and the return value will be masked.
* @param trace Is trace enabled ? If it is, an exit trace will be printed if the logger bound to the class name is
* enabled at the FINE level. An entry log will be generated if the logger is enabled at the FINER level.
* @return The join point returned value.
* @throws Throwable If the join point throws an exception.
*/
public static Object traceAndMeasureConstructorJoinPoint( ProceedingJoinPoint point, Level gatherSizeLevel, boolean secure, boolean trace ) throws Throwable {
ConstructorSignature methodSignature = ConstructorSignature.class.cast( point.getSignature() );
Constructor<?> method = methodSignature.getConstructor();
String opName = method.toString();
Logger logger = null;
if ( trace ) {
logger = getLoggerByName( method.getDeclaringClass().getName() );
}
OperationMetric metric = initializeConstructorMetricIfEnabled( point, secure, logger, method, opName );
return traceAndMeasureJoinPointWithLogger( point, gatherSizeLevel, secure, metric, opName, logger, true, method );
}
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:26,代码来源:TraceUtilities.java
示例9: getAnnotations
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
/**
* Helper that returns all {@link java.lang.annotation.Annotation}s of the given call joint point needed for the
* CostHat UseCase
*
* @return list of all {@link java.lang.annotation.Annotation}
*/
private List<java.lang.annotation.Annotation> getAnnotations() {
Signature signature = getSignature();
if (signature instanceof MethodSignature) {
return Arrays.asList(((MethodSignature) getSignature()).getMethod().getAnnotations());
}
else if (signature instanceof ConstructorSignature) {
return Arrays.asList(((ConstructorSignature) getSignature()).getConstructor().getAnnotations());
}
return Lists.newArrayList();
}
开发者ID:sealuzh,项目名称:PerformanceHat,代码行数:17,代码来源:ProcedureCallJoinPoint.java
示例10: createConstructorSignatureMock
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
private Signature createConstructorSignatureMock(Class<?>... parameterClasses) {
final ConstructorSignature constructorSignature = mock(ConstructorSignature.class);
when(constructorSignature.getConstructor()).thenReturn(resolveConstructor(parameterClasses));
LOGGER.debug("ConstructorSignature Mock - getConstructor() = {}", constructorSignature.getConstructor());
return constructorSignature;
}
开发者ID:loddar,项目名称:ajunit,代码行数:9,代码来源:ConstructorJoinPointMatcherTest.java
示例11: beforeCtor
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
/**
* Validate arguments of constructor.
*
* <p>Try NOT to change the signature of this method, in order to keep
* it backward compatible.
*
* @param point Join point
* @checkstyle LineLength (3 lines)
*/
@Before("preinitialization(*.new(.., @(javax.validation.* || javax.validation.constraints.*) (*), ..))")
public void beforeCtor(final JoinPoint point) {
if (this.validator != null) {
@SuppressWarnings("unchecked")
final Constructor<Object> constructor = (Constructor<Object>)
ConstructorSignature.class.cast(point.getSignature())
.getConstructor();
this.validateConstructor(
constructor,
point.getArgs()
);
}
}
开发者ID:jcabi,项目名称:jcabi-aspects,代码行数:23,代码来源:MethodValidator.java
示例12: InitializationTest
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
public InitializationTest() {
super("eval.org.aspectj.lang.InitializationAspect", JoinPoint.INITIALIZATION, ConstructorSignature.class);
}
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:InitializationTest.java
示例13: ConstructorExecutionTest
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
public ConstructorExecutionTest() {
super("eval.org.aspectj.lang.ConstructorExecutionAspect", JoinPoint.CONSTRUCTOR_EXECUTION, ConstructorSignature.class);
}
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:ConstructorExecutionTest.java
示例14: ConstructorCallTest
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
public ConstructorCallTest() {
super("eval.org.aspectj.lang.ConstructorCallAspect", JoinPoint.CONSTRUCTOR_CALL, ConstructorSignature.class);
}
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:ConstructorCallTest.java
示例15: PreInitializationTest
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
public PreInitializationTest() {
super("eval.org.aspectj.lang.PreInitializationAspect", JoinPoint.PREINITIALIZATION, ConstructorSignature.class);
}
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:PreInitializationTest.java
示例16: ConstructorJoinPointMatcher
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
ConstructorJoinPointMatcher(AjJoinPointType joinPointType) {
super(joinPointType, ConstructorSignature.class);
}
开发者ID:loddar,项目名称:ajunit,代码行数:4,代码来源:ConstructorJoinPointMatcher.java
示例17: doMatchSignature
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
@Override
protected boolean doMatchSignature(ConstructorSignature signature, AjJoinPoint ajUnitJoinPoint) {
return signature.getConstructor().equals(ajUnitJoinPoint.getConstructor());
}
开发者ID:loddar,项目名称:ajunit,代码行数:5,代码来源:ConstructorJoinPointMatcher.java
示例18: traceAndMeasureConstructorJoinPointWithLogger
import org.aspectj.lang.reflect.ConstructorSignature; //导入依赖的package包/类
/**
* Generate traces and gather statistics on a constructor.
*
* @param point The proceeding join point.
* @param gatherSizeLevel Logging level at which the returned value of the function should be measured.
* @param secure Is the method secure ? If so, both the arguments and the return value will be masked.
* @param logger The logger to use.
* @param operationNamePrefix the name of the layer being measured, appended as a prefix to the operation name.
* @param printReturnValue option to print the returned value.f
* @return The join point returned value.
* @throws Throwable If the join point throws an exception.
*/
public static Object traceAndMeasureConstructorJoinPointWithLogger( ProceedingJoinPoint point, Level gatherSizeLevel, boolean secure, Logger logger, String operationNamePrefix, boolean printReturnValue ) throws Throwable {
ConstructorSignature constructorSignature = ConstructorSignature.class.cast( point.getSignature() );
Constructor<?> constructor = constructorSignature.getConstructor();
String opName = operationNamePrefix + constructor.toString();
OperationMetric metric = initializeConstructorMetricIfEnabled( point, secure, logger, constructor, opName );
return traceAndMeasureJoinPointWithLogger( point, gatherSizeLevel, secure, metric, opName, logger, printReturnValue, constructor );
}
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:22,代码来源:TraceUtilities.java
注:本文中的org.aspectj.lang.reflect.ConstructorSignature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论