我有两个切入点相同的方面类,但建议不同。我需要先执行一个,然后再执行另一个方面。我不能使用 Spring "@Ordered" 注释,因为我使用的是纯 aspectJ。
我在x86 Linux上有一个用于嵌入式系统(mipsel)的交叉编译工具链.我知道如何为它构建一个自定义内核(让我们调用图像"vmlinux")以及如何通过
objcopy -S -O binary vmlinux vmlinux.bin
Run Code Online (Sandbox Code Playgroud)
为了进一步处理,我还需要图像的加载地址和入口点.在剥离之前,通过scripts/mksysmap或更明确地通过via 确定它们是没有问题的
nm -n vmlinux | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > System.map
Run Code Online (Sandbox Code Playgroud)
然后我可以确定加载地址和入口点
awk '/A _text/ { print "0x"$1; }' < _System.map
awk '/T kernel_entry/ { print "0x"$1; }' < System.map
Run Code Online (Sandbox Code Playgroud)
现在的挑战是,有时候我不是自己构建内核,而是在通过objcopy删除了它的符号后得到一个预构建的内核.谁能告诉我怎么做?我对内核构建和工具链的使用不是很熟练.这两种纳米和objdump的不喜欢剥图像,说
vmlinux.bin: File format not recognized
Run Code Online (Sandbox Code Playgroud) Java 7应该通过解压缩包含UTF-8以外字符集的zip存档来解决一个老问题.这可以通过构造函数来实现ZipInputStream(InputStream, Charset).到现在为止还挺好.在明确设置ISO-8859-1字符集时,我可以解压缩包含文件名的zip存档,其中包含变音符号.
但问题是:当使用流迭代流时ZipInputStream.getNextEntry(),条目的名称中包含错误的特殊字符.在我的情况下,变音符号"ü"被"?"取代 性格,这显然是错误的.有人知道如何解决这个问题吗?显然ZipEntry忽略了Charset它的基础ZipInputStream.它看起来像是另一个与zip相关的JDK错误,但我也可能做错了.
...
zipStream = new ZipInputStream(
new BufferedInputStream(new FileInputStream(archiveFile), BUFFER_SIZE),
Charset.forName("ISO-8859-1")
);
while ((zipEntry = zipStream.getNextEntry()) != null) {
// wrong name here, something like "M?nchen" instead of "München"
System.out.println(zipEntry.getName());
...
}
Run Code Online (Sandbox Code Playgroud) 我需要使用 spring-aop 拦截带注释的方法。我已经有了拦截器,它实现了 AOP 联盟的 MethodInterceptor。
这是代码:
@Configuration
public class MyConfiguration {
// ...
@Bean
public MyInterceptor myInterceptor() {
return new MyInterceptor();
}
}
Run Code Online (Sandbox Code Playgroud)
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
// ...
}
Run Code Online (Sandbox Code Playgroud)
public class MyInterceptor implements MethodInterceptor {
// ...
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
//does some stuff
}
}
Run Code Online (Sandbox Code Playgroud)
从我过去读到的内容来看,我可以使用 @SpringAdvice 注释来指定拦截器何时应该拦截某些东西,但现在已经不存在了。
谁能帮我?
非常感谢!
卢卡斯
我想为带有方法注释的方法设置AspectJ切入点@Scheduled。尝试了不同的方法,但没有任何效果。
1.)
@Pointcut("execution(@org.springframework.scheduling.annotation.Scheduled * * (..))")
public void scheduledJobs() {}
@Around("scheduledJobs()")
public Object profileScheduledJobs(ProceedingJoinPoint joinPoint) throws Throwable {
LOG.info("testing")
}
Run Code Online (Sandbox Code Playgroud)
2.)
@Pointcut("within(@org.springframework.scheduling.annotation.Scheduled *)")
public void scheduledJobs() {}
@Pointcut("execution(public * *(..))")
public void publicMethod() {}
@Around("scheduledJobs() && publicMethod()")
public Object profileScheduledJobs(ProceedingJoinPoint joinPoint) throws Throwable {
LOG.info("testing")
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以提出任何其他方式都around/ before上建议@Scheduled注解的方法?
我们在函数上有一个注释如下
public class AnInterfaceImpl implements AnInterface {
@FairThreadUsageByEntity(entityName = "XYXYXYX",
numberOfThreads = 1)
public Report getReport(final String One, final String Two) {
//implementation.
}
}
public interface AnInterface {
String BEAN_NAME = "AnInterface"; //used for injection in spring.
Report getReport(final String One, final String two);
}
Run Code Online (Sandbox Code Playgroud)
弹簧配置:
<aop:aspectj-autoproxy />
<bean class="com.amazon.utils.fairthreadusage.aspect.FairThreadUsageByEntityAdvice" />
Run Code Online (Sandbox Code Playgroud)
注释作为一个方面实现.基本功能是限制特定类型功能使用的线程数,让我们说下载.以下是注释的代码FairThreadUsageByEntity:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface FairThreadUsageByEntity {
public String entityName();
public int numberOfThreads();
}
@Aspect
public class FairThreadUsageByEntityAdvice extends FairThreadUsageBase {
@Around("@annotation(fairUsage)")
public Object fairThreadUsageByEntity(final ProceedingJoinPoint …Run Code Online (Sandbox Code Playgroud) Concurent Transaction使我的Sql语句失败.我正在尝试使用[这] dellroad-stuff 1.但它似乎被忽略了.我正在使用spring 3和hibernate 4.
错误 :
15:32:11,331 WARN SqlExceptionHelper:145 - SQL Error: 1213, SQLState: 40001
15:32:11,331 ERROR SqlExceptionHelper:147 - Deadlock found when trying to get lock; try restarting transaction
15:32:11,334 INFO AbstractBatchImpl:195 - HHH000010: On release of batch it still contained JDBC statements
Run Code Online (Sandbox Code Playgroud)
如果失败则重写事务的annoted函数:
@Override
@RetryTransaction
@Transactional
public void save(AnalyseResult analyseResult) {
final int attempt = RetryTransactionAspect.aspectOf().getAttemptNumber();
System.out.println("#############");
System.out.println("Retry Transact : "+attempt);
System.out.println("#############");
analyseResultDao.save(analyseResult);
}
Run Code Online (Sandbox Code Playgroud)
Beans.xml
<!-- An @AspectJ aspect will be interpreted as an aspect by …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Aspectj 进行 AOP,但我不知道为什么不执行我的方面,它只运行主类。这是我第一次这样做,所以我可能做错了什么。
这是我的代码:
方面:
@Aspect
public class YourAspect {
@Pointcut("@annotation(yourAnnotationVariableName)")
public void annotationPointCutDefinition(YourAnnotation yourAnnotationVariableName){
}
@Pointcut("execution(* *(..))")
public void atExecution(){}
@Around("annotationPointCutDefinition(yourAnnotationVariableName) && atExecution()")
public Object aroundAdvice(ProceedingJoinPoint joinPoint, YourAnnotation yourAnnotationVariableName) throws Throwable {
if(yourAnnotationVariableName.isRun()) {
Object returnObject = null;
try {
System.out.println("aspects.YourAspect's aroundAdvice's body is now executed Before yourMethodAround is called.");
returnObject = joinPoint.proceed();
} catch (Throwable throwable) {
throw throwable;
} finally {
System.out.println("aspects.YourAspect's aroundAdvice's body is now executed After yourMethodAround is called.");
}
return returnObject;
}
return …Run Code Online (Sandbox Code Playgroud) 我有这个简单的豆子 PerformanceMonitorInterceptor
@Configuration
@EnableAspectJAutoProxy
@Aspect
public class PerfMetricsConfiguration {
/**
* Monitoring pointcut.
*/
@Pointcut("execution(* com.lapots.breed.judge.repository.*Repository.*(..))")
public void monitor() {
}
/**
* Creates instance of performance monitor interceptor.
* @return performance monitor interceptor
*/
@Bean
public PerformanceMonitorInterceptor performanceMonitorInterceptor() {
return new PerformanceMonitorInterceptor(true);
}
/**
* Creates instance of performance monitor advisor.
* @return performance monitor advisor
*/
@Bean
public Advisor performanceMonitorAdvisor() {
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression("com.lapots.breed.judge.repository.PerfMetricsConfiguration.monitor()");
return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor());
}
}
Run Code Online (Sandbox Code Playgroud)
它应该跟踪Repository名称结尾的接口中的任何方法调用。我在设置日志记录级别application.properties
logging.level.org.springframework.aop.interceptor.PerformanceMonitorInterceptor=TRACE …Run Code Online (Sandbox Code Playgroud) 我很难理解为什么以下内容没有给我相同的结果。
如果我使用 Javers 来比较两个列表(其中的项目顺序不同),那么我不会得到任何差异,因为我已指定 AS_SET 列表比较来忽略列表中项目的顺序。
如果我随后将这些列表包装为对象的属性,Javers 会返回列表的元素因列表中项目的顺序而不同。
AS_SET 应该应用于对象内的列表吗?就好像被忽视一样
public class App {
public static void main(String[] args) {
List<ListItem> list1 = ImmutableList.of(
ListItem.builder()
.itemName("item1")
.itemValue("value")
.build(),
ListItem.builder()
.itemName("item2")
.itemValue("value2")
.build()
);
List<ListItem> list2 = ImmutableList.of(
ListItem.builder()
.itemName("item2")
.itemValue("value2")
.build(),
ListItem.builder()
.itemName("item1")
.itemValue("value")
.build()
);
TopLevelClass tlc1 = TopLevelClass.builder().items(list1).build();
TopLevelClass tlc2 = TopLevelClass.builder().items(list2).build();
Diff diff = JaversBuilder.javers().withListCompareAlgorithm(ListCompareAlgorithm.AS_SET).build().compare(list1, list2);
System.out.println(diff);
Diff diffTlc = JaversBuilder.javers().withListCompareAlgorithm(ListCompareAlgorithm.AS_SET).build().compare(tlc1, tlc2);
System.out.println(diffTlc);
}
}
Run Code Online (Sandbox Code Playgroud)
以下类别:
package wibble;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Builder …Run Code Online (Sandbox Code Playgroud) java ×6
aspectj ×5
aop ×3
spring ×3
spring-aop ×2
aopalliance ×1
javers ×1
maven ×1
spring-boot ×1
transactions ×1