Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DUBBO-615: 实现基本功能,并能够运行demo #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ public Class<?> toClass()
}
}
}
return mCtc.toClass(ClassHelper.getCallerClassLoader(getClass()), null);
// mPool.getClassloader() 能够得到正确的classloader.
return mCtc.toClass(null, null);
}
catch(RuntimeException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ public abstract class Proxy
*/
public static Proxy getProxy(Class<?>... ics)
{
return getProxy(ClassHelper.getCallerClassLoader(Proxy.class), ics);
if(null == ics || ics.length == 0) // 貌似这种情况应该不会出现吧?先加上再说,以防万一。
return getProxy(ClassHelper.getCallerClassLoader(Proxy.class), ics);

// 按照我的理解,Proxy是用在根据dubbo:reference创建接口代理的。那么按照OSGi blurprint的定义,这里应该使用当前定义dubbo:reference的bundle作为类加载器。
// 因为只有这个bundle才能正确的找到所有必须的接口类。
// 另外dubbo应该还不支持在一个dubbo:reference中定义多个接口吧?
return getProxy(ClassHelper.getCallerClassLoader(ics[0]), ics);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ private static Wrapper makeWrapper(Class<?> c)
throw new IllegalArgumentException("Can not create wrapper for primitive type: " + c);

String name = c.getName();
ClassLoader cl = ClassHelper.getCallerClassLoader(Wrapper.class);
// 在OSGi环境下通过c可以得到当前发布service的bundle的类路径。
// 在常规servlet容器里,通过c应该也可以得到正确的类路径。
ClassLoader cl = ClassHelper.getCallerClassLoader(c);

StringBuilder c1 = new StringBuilder("public void setPropertyValue(Object o, String n, Object v){ ");
StringBuilder c2 = new StringBuilder("public Object getPropertyValue(Object o, String n){ ");
Expand Down
38 changes: 38 additions & 0 deletions dubbo/osgi.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Export-Package: com.alibaba.dubbo.*;version="${project.version}",\
com.alibaba.com.caucho.hessian.*;version="${hessian_lite_version}"

Import-Package: org.apache.commons.logging;version="1.1",\
javassist.*;version="[3.15,4.0)",\
org.springframework.*;version="[2.5.6,4.0)",\
org.jboss.netty.*;version="3.2",\
ch.qos.logback.*;version="0.9";resolution:=optional,\
com.alibaba.com.caucho.hessian.*;version="[3.2,4.0)";resolution:=optional,\
com.alibaba.fastjson.*;version="[1.1,2.0)";resolution:=optional,\
com.caucho.hessian.*;version="[4.0,5.0)";resolution:=optional,\
com.netflix.curator.*;version="[1.1,2.0)";resolution:=optional,\
javax.cache.*;version="0";resolution:=optional,\
javax.script.*;version="1.1";resolution:=optional,\
javax.servlet.*;version="2.5";resolution:=optional,\
javax.sql.*,\
javax.tools.*,\
javax.validation.*;version="1.0";resolution:=optional,\
net.rubyeye.xmemcached.*;version="1.3.6";resolution:=optional,\
org.I0Itec.zkclient.*;version="0.1";resolution:=optional,\
org.apache.commons.lang,\
org.apache.commons.pool.impl,\
org.apache.cxf.*;version="[2.6,3.0)";resolution:=optional,\
org.apache.http.*;version="0";resolution:=optional,\
org.apache.log4j.*;version="[1.2,2.0)";resolution:=optional,\
org.apache.mina.*;version="[1.1,2.0)";resolution:=optional,\
org.apache.thrift.*;version="0.8";resolution:=optional,\
org.apache.zookeeper.*;version="[3.3,4.0)";resolution:=optional,\
org.glassfish.grizzly.*;version="[2.1,3.0)";resolution:=optional,\
org.mortbay.*;version="6.1";resolution:=optional,\
org.slf4j.*;version="[1.6,2.0)";resolution:=optional,\
org.w3c.dom,\
redis.clients.jedis.*;version="[2.1,3.0)";resolution:=optional,\
*
15 changes: 13 additions & 2 deletions dubbo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<version>2.5.3-SNAPSHOT</version>
</parent>
<artifactId>dubbo</artifactId>
<packaging>jar</packaging>
<packaging>bundle</packaging>
<name>${project.artifactId}</name>
<description>The all in one project of dubbo</description>
<properties>
Expand Down Expand Up @@ -295,7 +295,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -475,6 +475,17 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_include>-osgi.bnd</_include>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>