public class MyService { public void doSomething() { System.out.println("Doing something..."); } } <bean id="myService" class="com.example.MyService" osgi:export="true"/> @Autowired private MyService myService; public class MyBean { public void doSomething() { } } <bean id="myBean" class="com.example.MyBean"/> <bean id="loggingAspect" class="com.example.LoggingAspect"/> <aop:config> <aop:aspect ref="loggingAspect"> <aop:pointcut expression="execution(* com.example.MyBean.*(..))"/> <aop:before method="beforeAdvice" pointcut-ref="myPointcut"/> </aop:aspect> </aop:config> <dependencies> <dependency> <groupId>org.springframework.osgi</groupId> <artifactId>spring-osgi-core</artifactId> <version>2.0.0</version> </dependency> </dependencies> <bean id="bundleContext" class="org.springframework.osgi.context.BundleContextAware"> <property name="bundleContext" ref="osgiBundleContext"/> </bean>


上一篇:
下一篇:
切换中文