准备工作:下载spring-DM以来的包,并以插件的形式导入到工程中
1.创建一个plug-in project:UserInterface用于接口编写
public interface UserInterface {
public void addUserInfo(UserInfo userInfo);
}
public class UserInfo {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
MANIFEST.MF中将方法所在的包导出
2.创建一个plug-in project:UserImpl用于接口实现编写
MANIFEST.MF中将1导出的包导入
public class UserImpl implements UserInterface{
public static final Log log = LogFactory.getLog(UserImpl.class);
@Override
public void addUserInfo(UserInfo userInfo) {
log.info("addUserInfo excu...");
}
}
在META-INF下创建文件夹spring:
在spring文件夹下新建:
bean.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd" default-autowire="byName">
<bean id="userImpl" class="com.oohla.service.impl.UserImpl"></bean>
</beans>
services-public-cxf.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd" default-autowire="byName">
<osgi:service id="userInterface" ref="userImpl" interface="com.oohla.service.UserInterface"></osgi:service>
</beans>
3.创建一个plug-in project:Test用于测试接口
MANIFEST.MF中将1导出的包导入
测试类:
public class Test {
private UserInterface userInterface;
public UserInterface getUserInterface() {
return userInterface;
}
public void setUserInterface(UserInterface userInterface) {
this.userInterface = userInterface;
}
public void setUser(UserInterface userInterface) {
this.userInterface = userInterface;
}
public void addUser(){
UserInfo userInfo = new UserInfo();
userInfo.setId(1);
userInfo.setUsername("mz");
userInfo.setPassword("123");
System.out.println("Test addUser...");
userInterface.addUserInfo(userInfo);
}
}
在META-INF下创建文件夹spring:
在spring文件夹下新建:
beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd" default-autowire="byName">
<!-- 启动通话监听任务 -->
<bean id="test" class="com.oohla.test.Test" init-method="addUser">
<property name="userInterface" ref="userInterface"></property>
</bean>
</beans>
services-reference-cxf.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd" default-autowire="byName">
<osgi:reference id="userInterface" interface="com.oohla.service.UserInterface"></osgi:reference>
</beans>
分享到:
相关推荐
spring-osgi-1.2.1-with-dependencies.zip spring-osgi-1.2.1-with-dependencies.zip spring-osgi-1.2.1-with-dependencies.zip
spring-osgi-1.2.0-rc1-with-dependencies.zip
spring-osgi-1.2.0-with-dependencies.zip spring-osgi-1.2.0-with-dependencies.zip spring-osgi-1.2.0-with-dependencies.zip
spring-dm整合osgi所需所有jar包
赠送jar包:osgi-resource-locator-1.0.1.jar;...使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。
Spring-DM指的是 Spring ...Spring-DM 的主要目的是能够方便地将 Spring 框架和OSGi框架结合在一起,使得使用Spring的应用程序可以方便简单地部署在OSGi环境中,利用OSGi框架提供的服务,将应用变得 更加模块化。
java 未来10年:OSGi、Spring_DM
spring-osgi-1.2.1-with-dependencies完整包
spring-osgi-core-1.2.1.jar spring-osgi-core-1.2.1-sources.jar spring-osgi-extender-1.2.1.jar spring-osgi-extender-1.2.1-sources.jar spring-osgi-io-1.2.1.jar spring-osgi-io-1.2.1-sources.jar spring-...
spring1.2的包文件 spring-osgi-1.2.0.zip
自制CHM版的API文档,带索引。 注:如果各位下载后打开或无法显示页面,请在CHM文件右键—属性—解除锁定即可。
spring-dm一章对应的demo,里面包括1..1和1..n的实现
使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。 双语对照,边学技术、边学英语。
Spring-DM指的是 Spring ...Spring-DM 的主要目的是能够方便地将 Spring 框架和OSGi框架结合在一起,使得使用Spring的应用程序可以方便简单地部署在OSGi环境中,利用OSGi框架提供的服务,将应用变得 更加模块化。
osgi最新jar包org.osgi.core-4.2.0
实测可用
实测可用
实测可用
实测可用
实测可用