标注需要被 export 的类
git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1920 1a56cb94-b969-4eaa-88fa-be21384802f2
This commit is contained in:
parent
980844bd53
commit
82b9d6d25f
|
|
@ -28,6 +28,7 @@ import com.alibaba.dubbo.rpc.cluster.support.FailoverCluster;
|
|||
* <a href="http://en.wikipedia.org/wiki/Fault-tolerant_system">Fault-Tolerant</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI(FailoverCluster.NAME)
|
||||
public interface Cluster {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.alibaba.dubbo.common.URL;
|
|||
* Configurator. (SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Configurator extends Comparable<Configurator> {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* ConfiguratorFactory. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface ConfiguratorFactory {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.alibaba.dubbo.rpc.RpcException;
|
|||
*
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Directory<T> extends Node {
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc.cluster;
|
||||
|
||||
package com.alibaba.dubbo.rpc.cluster;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
|
|
@ -24,28 +24,29 @@ import com.alibaba.dubbo.rpc.Invocation;
|
|||
import com.alibaba.dubbo.rpc.Invoker;
|
||||
import com.alibaba.dubbo.rpc.RpcException;
|
||||
import com.alibaba.dubbo.rpc.cluster.loadbalance.RandomLoadBalance;
|
||||
|
||||
/**
|
||||
* LoadBalance. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Load_balancing_(computing)">Load-Balancing</a>
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
*/
|
||||
@SPI(RandomLoadBalance.NAME)
|
||||
public interface LoadBalance {
|
||||
|
||||
/**
|
||||
* select one invoker in list.
|
||||
*
|
||||
|
||||
/**
|
||||
* LoadBalance. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Load_balancing_(computing)">Load-Balancing</a>
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI(RandomLoadBalance.NAME)
|
||||
public interface LoadBalance {
|
||||
|
||||
/**
|
||||
* select one invoker in list.
|
||||
*
|
||||
* @param invokers invokers.
|
||||
* @param url refer url
|
||||
* @param invocation invocation.
|
||||
* @return selected invoker.
|
||||
* @param invocation invocation.
|
||||
* @return selected invoker.
|
||||
*/
|
||||
@Adaptive("loadbalance")
|
||||
<T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException;
|
||||
|
||||
@Adaptive("loadbalance")
|
||||
<T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException;
|
||||
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
|
||||
/**
|
||||
* @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a>
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface Merger<T> {
|
||||
|
|
|
|||
|
|
@ -13,24 +13,25 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc.cluster;
|
||||
|
||||
package com.alibaba.dubbo.rpc.cluster;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.rpc.Invocation;
|
||||
import com.alibaba.dubbo.rpc.Invoker;
|
||||
import com.alibaba.dubbo.rpc.RpcException;
|
||||
|
||||
/**
|
||||
* Router. (SPI, Prototype, ThreadSafe)
|
||||
|
||||
/**
|
||||
* Router. (SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Routing">Routing</a>
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Directory#list(Invocation)
|
||||
* @author chao.liuc
|
||||
*/
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Directory#list(Invocation)
|
||||
* @author chao.liuc
|
||||
* @export
|
||||
*/
|
||||
public interface Router extends Comparable<Router> {
|
||||
|
||||
/**
|
||||
|
|
@ -38,17 +39,17 @@ public interface Router extends Comparable<Router> {
|
|||
*
|
||||
* @return url
|
||||
*/
|
||||
URL getUrl();
|
||||
|
||||
/**
|
||||
* route.
|
||||
*
|
||||
URL getUrl();
|
||||
|
||||
/**
|
||||
* route.
|
||||
*
|
||||
* @param invokers
|
||||
* @param url refer url
|
||||
* @param invocation
|
||||
* @return routed invokers
|
||||
* @throws RpcException
|
||||
*/
|
||||
<T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException;
|
||||
|
||||
* @param invocation
|
||||
* @return routed invokers
|
||||
* @throws RpcException
|
||||
*/
|
||||
<T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException;
|
||||
|
||||
}
|
||||
|
|
@ -13,32 +13,33 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc.cluster;
|
||||
|
||||
package com.alibaba.dubbo.rpc.cluster;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
import com.alibaba.dubbo.rpc.Invocation;
|
||||
|
||||
/**
|
||||
* RouterFactory. (SPI, Singleton, ThreadSafe)
|
||||
|
||||
/**
|
||||
* RouterFactory. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* <a href="http://en.wikipedia.org/wiki/Routing">Routing</a>
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Cluster#join(Directory)
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Directory#list(Invocation)
|
||||
* @author chao.liuc
|
||||
* @see com.alibaba.dubbo.rpc.cluster.Directory#list(Invocation)
|
||||
* @author chao.liuc
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface RouterFactory {
|
||||
|
||||
/**
|
||||
* Create router.
|
||||
*
|
||||
* @param url
|
||||
* @return router
|
||||
*/
|
||||
@Adaptive("protocol")
|
||||
Router getRouter(URL url);
|
||||
|
||||
@SPI
|
||||
public interface RouterFactory {
|
||||
|
||||
/**
|
||||
* Create router.
|
||||
*
|
||||
* @param url
|
||||
* @return router
|
||||
*/
|
||||
@Adaptive("protocol")
|
||||
Router getRouter(URL url);
|
||||
|
||||
}
|
||||
|
|
@ -38,6 +38,7 @@ import java.lang.annotation.Target;
|
|||
* @deprecated
|
||||
* @author william.liangf
|
||||
* @author ding.lid
|
||||
* @export
|
||||
*/
|
||||
@Deprecated
|
||||
@Documented
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.alibaba.dubbo.common.URL;
|
|||
* Node. (API/SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Node {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* Compiler. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("javassist")
|
||||
public interface Compiler {
|
||||
|
|
|
|||
|
|
@ -13,26 +13,27 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.common.extension;
|
||||
|
||||
package com.alibaba.dubbo.common.extension;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Activate.
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface Activate {
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface Activate {
|
||||
|
||||
String[] group() default {};
|
||||
|
||||
|
||||
String[] value() default {};
|
||||
|
||||
String[] before() default {};
|
||||
|
|
@ -40,5 +41,5 @@ public @interface Activate {
|
|||
String[] after() default {};
|
||||
|
||||
int order() default 0;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +1,33 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.common.extension;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
|
||||
/**
|
||||
* 在{@link ExtensionLoader}生成Extension的Adaptive Instance时,为{@link ExtensionLoader}提供信息。
|
||||
*
|
||||
* @author ding.lid
|
||||
* @export
|
||||
*
|
||||
* @see ExtensionLoader
|
||||
* @see URL
|
||||
|
|
@ -53,6 +54,6 @@ public @interface Adaptive {
|
|||
*
|
||||
* @see SPI#value()
|
||||
*/
|
||||
String[] value() default {};
|
||||
|
||||
String[] value() default {};
|
||||
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ package com.alibaba.dubbo.common.extension;
|
|||
* ExtensionFactory
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface ExtensionFactory {
|
||||
|
|
|
|||
|
|
@ -833,12 +833,7 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
|
||||
private static ClassLoader findClassLoader() {
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (classLoader != null) {
|
||||
return classLoader;
|
||||
}
|
||||
classLoader = ExtensionLoader.class.getClassLoader();
|
||||
return classLoader;
|
||||
return ExtensionLoader.class.getClassLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author william.liangf
|
||||
* @author ding.lid
|
||||
* @export
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.common.serialize;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
* Data input.
|
||||
*
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface DataInput {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.common.serialize;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
* Data output.
|
||||
*
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface DataOutput {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,28 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.common.serialize;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Object input.
|
||||
*
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface ObjectInput extends DataInput {
|
||||
|
||||
|
|
@ -38,14 +39,14 @@ public interface ObjectInput extends DataInput {
|
|||
* @param cls object type.
|
||||
* @return object.
|
||||
*/
|
||||
<T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* read object.
|
||||
*
|
||||
* @param cls object type.
|
||||
* @return object.
|
||||
*/
|
||||
<T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* read object.
|
||||
*
|
||||
* @param cls object type.
|
||||
* @return object.
|
||||
*/
|
||||
<T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException;
|
||||
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.common.serialize;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
* Object output.
|
||||
*
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface ObjectOutput extends DataOutput {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
*
|
||||
* @author ding.lid
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("hessian2")
|
||||
public interface Serialization {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* ThreadPool
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("fixed")
|
||||
public interface ThreadPool {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import com.alibaba.dubbo.config.support.Parameter;
|
|||
* AbstractConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public abstract class AbstractConfig implements Serializable {
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import com.alibaba.dubbo.rpc.support.MockInvoker;
|
|||
* AbstractDefaultConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.alibaba.dubbo.rpc.cluster.LoadBalance;
|
|||
* AbstractMethodConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public abstract class AbstractMethodConfig extends AbstractConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.alibaba.dubbo.rpc.InvokerListener;
|
|||
*
|
||||
* @see com.alibaba.dubbo.config.ReferenceConfig
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.alibaba.dubbo.rpc.ExporterListener;
|
|||
* AbstractServiceConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public abstract class AbstractServiceConfig extends AbstractInterfaceConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.alibaba.dubbo.config.support.Parameter;
|
|||
* ApplicationConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ApplicationConfig extends AbstractConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,27 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.alibaba.dubbo.config.support.Parameter;
|
||||
|
||||
import com.alibaba.dubbo.config.support.Parameter;
|
||||
|
||||
/**
|
||||
* @author chao.liuc
|
||||
* @export
|
||||
*/
|
||||
public class ArgumentConfig implements Serializable {
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.alibaba.dubbo.config;
|
|||
* ConsumerConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ConsumerConfig extends AbstractReferenceConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.config.support.Parameter;
|
|||
* MethodConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class MethodConfig extends AbstractMethodConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.config.support.Parameter;
|
|||
* ModuleConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ModuleConfig extends AbstractConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.alibaba.dubbo.config.support.Parameter;
|
|||
* MonitorConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class MonitorConfig extends AbstractConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.alibaba.dubbo.rpc.Protocol;
|
|||
* ProtocolConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ProtocolConfig extends AbstractConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
|
|||
* @see com.alibaba.dubbo.config.ProtocolConfig
|
||||
* @see com.alibaba.dubbo.config.ServiceConfig
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ProviderConfig extends AbstractServiceConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import com.alibaba.dubbo.rpc.service.GenericService;
|
|||
* ReferenceConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.alibaba.dubbo.remoting.Transporter;
|
|||
* RegistryConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class RegistryConfig extends AbstractConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import com.alibaba.dubbo.rpc.service.GenericService;
|
|||
* ServiceConfig
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ServiceConfig<T> extends AbstractServiceConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.lang.annotation.Target;
|
|||
* Reference
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.lang.annotation.Target;
|
|||
* Service
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import com.alibaba.dubbo.config.annotation.Service;
|
|||
* AnnotationBean
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class AnnotationBean extends AbstractConfig implements DisposableBean, BeanFactoryPostProcessor, BeanPostProcessor, ApplicationContextAware {
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.config.spring;
|
||||
|
||||
package com.alibaba.dubbo.config.spring;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -35,18 +35,19 @@ import com.alibaba.dubbo.config.RegistryConfig;
|
|||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory;
|
||||
import com.alibaba.dubbo.config.support.Parameter;
|
||||
|
||||
/**
|
||||
* ReferenceFactoryBean
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean, ApplicationContextAware, InitializingBean, DisposableBean {
|
||||
|
||||
private static final long serialVersionUID = 213195494150089726L;
|
||||
|
||||
private transient ApplicationContext applicationContext;
|
||||
|
||||
|
||||
/**
|
||||
* ReferenceFactoryBean
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean, ApplicationContextAware, InitializingBean, DisposableBean {
|
||||
|
||||
private static final long serialVersionUID = 213195494150089726L;
|
||||
|
||||
private transient ApplicationContext applicationContext;
|
||||
|
||||
public ReferenceBean() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -55,22 +56,22 @@ public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean,
|
|||
super(reference);
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
SpringExtensionFactory.addApplicationContext(applicationContext);
|
||||
}
|
||||
|
||||
public Object getObject() throws Exception {
|
||||
return get();
|
||||
}
|
||||
SpringExtensionFactory.addApplicationContext(applicationContext);
|
||||
}
|
||||
|
||||
public Object getObject() throws Exception {
|
||||
return get();
|
||||
}
|
||||
|
||||
public Class<?> getObjectType() {
|
||||
return getInterfaceClass();
|
||||
}
|
||||
public Class<?> getObjectType() {
|
||||
return getInterfaceClass();
|
||||
}
|
||||
|
||||
@Parameter(excluded = true)
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
@Parameter(excluded = true)
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked"})
|
||||
|
|
@ -170,6 +171,6 @@ public class ReferenceBean<T> extends ReferenceConfig<T> implements FactoryBean,
|
|||
if (b != null && b.booleanValue()) {
|
||||
getObject();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.config.spring;
|
||||
|
||||
package com.alibaba.dubbo.config.spring;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -40,23 +40,24 @@ import com.alibaba.dubbo.config.RegistryConfig;
|
|||
import com.alibaba.dubbo.config.ServiceConfig;
|
||||
import com.alibaba.dubbo.config.annotation.Service;
|
||||
import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory;
|
||||
|
||||
/**
|
||||
* ServiceFactoryBean
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener, BeanNameAware {
|
||||
|
||||
private static final long serialVersionUID = 213195494150089726L;
|
||||
|
||||
private static transient ApplicationContext SPRING_CONTEXT;
|
||||
|
||||
private transient ApplicationContext applicationContext;
|
||||
|
||||
private transient String beanName;
|
||||
|
||||
private transient boolean supportedApplicationListener;
|
||||
|
||||
/**
|
||||
* ServiceFactoryBean
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener, BeanNameAware {
|
||||
|
||||
private static final long serialVersionUID = 213195494150089726L;
|
||||
|
||||
private static transient ApplicationContext SPRING_CONTEXT;
|
||||
|
||||
private transient ApplicationContext applicationContext;
|
||||
|
||||
private transient String beanName;
|
||||
|
||||
private transient boolean supportedApplicationListener;
|
||||
|
||||
public ServiceBean() {
|
||||
super();
|
||||
|
|
@ -66,19 +67,19 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
super(service);
|
||||
}
|
||||
|
||||
public static ApplicationContext getSpringContext() {
|
||||
return SPRING_CONTEXT;
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
public static ApplicationContext getSpringContext() {
|
||||
return SPRING_CONTEXT;
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
SpringExtensionFactory.addApplicationContext(applicationContext);
|
||||
if (applicationContext != null) {
|
||||
SPRING_CONTEXT = applicationContext;
|
||||
try {
|
||||
Method method = applicationContext.getClass().getMethod("addApplicationListener", new Class<?>[]{ApplicationListener.class}); // 兼容Spring2.0.1
|
||||
SpringExtensionFactory.addApplicationContext(applicationContext);
|
||||
if (applicationContext != null) {
|
||||
SPRING_CONTEXT = applicationContext;
|
||||
try {
|
||||
Method method = applicationContext.getClass().getMethod("addApplicationListener", new Class<?>[]{ApplicationListener.class}); // 兼容Spring2.0.1
|
||||
method.invoke(applicationContext, new Object[] {this});
|
||||
supportedApplicationListener = true;
|
||||
supportedApplicationListener = true;
|
||||
} catch (Throwable t) {
|
||||
if (applicationContext instanceof AbstractApplicationContext) {
|
||||
try {
|
||||
|
|
@ -90,39 +91,39 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
supportedApplicationListener = true;
|
||||
} catch (Throwable t2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (ContextRefreshedEvent.class.getName().equals(event.getClass().getName())) {
|
||||
if (isDelay()) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("The service ready on spring started. service: " + getInterface());
|
||||
}
|
||||
export();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDelay() {
|
||||
Integer delay = getDelay();
|
||||
ProviderConfig provider = getProvider();
|
||||
if (delay == null && provider != null) {
|
||||
delay = provider.getDelay();
|
||||
}
|
||||
return supportedApplicationListener && (delay == null || delay.intValue() == -1);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (getProvider() == null) {
|
||||
Map<String, ProviderConfig> providerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (ContextRefreshedEvent.class.getName().equals(event.getClass().getName())) {
|
||||
if (isDelay()) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("The service ready on spring started. service: " + getInterface());
|
||||
}
|
||||
export();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDelay() {
|
||||
Integer delay = getDelay();
|
||||
ProviderConfig provider = getProvider();
|
||||
if (delay == null && provider != null) {
|
||||
delay = provider.getDelay();
|
||||
}
|
||||
return supportedApplicationListener && (delay == null || delay.intValue() == -1);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (getProvider() == null) {
|
||||
Map<String, ProviderConfig> providerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false);
|
||||
if (providerConfigMap != null && providerConfigMap.size() > 0) {
|
||||
Map<String, ProtocolConfig> protocolConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);
|
||||
if ((protocolConfigMap == null || protocolConfigMap.size() == 0)
|
||||
|
|
@ -149,13 +150,13 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
if (providerConfig != null) {
|
||||
setProvider(providerConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getApplication() == null
|
||||
&& (getProvider() == null || getProvider().getApplication() == null)) {
|
||||
Map<String, ApplicationConfig> applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false);
|
||||
if (applicationConfigMap != null && applicationConfigMap.size() > 0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getApplication() == null
|
||||
&& (getProvider() == null || getProvider().getApplication() == null)) {
|
||||
Map<String, ApplicationConfig> applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false);
|
||||
if (applicationConfigMap != null && applicationConfigMap.size() > 0) {
|
||||
ApplicationConfig applicationConfig = null;
|
||||
for (ApplicationConfig config : applicationConfigMap.values()) {
|
||||
if (config.isDefault() == null || config.isDefault().booleanValue()) {
|
||||
|
|
@ -167,8 +168,8 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
}
|
||||
if (applicationConfig != null) {
|
||||
setApplication(applicationConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getModule() == null
|
||||
&& (getProvider() == null || getProvider().getModule() == null)) {
|
||||
|
|
@ -187,28 +188,28 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
setModule(moduleConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((getRegistries() == null || getRegistries().size() == 0)
|
||||
}
|
||||
if ((getRegistries() == null || getRegistries().size() == 0)
|
||||
&& (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().size() == 0)
|
||||
&& (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) {
|
||||
Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false);
|
||||
&& (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) {
|
||||
Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false);
|
||||
if (registryConfigMap != null && registryConfigMap.size() > 0) {
|
||||
List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>();
|
||||
for (RegistryConfig config : registryConfigMap.values()) {
|
||||
if (config.isDefault() == null || config.isDefault().booleanValue()) {
|
||||
registryConfigs.add(config);
|
||||
}
|
||||
}
|
||||
if (registryConfigs != null && registryConfigs.size() > 0) {
|
||||
super.setRegistries(registryConfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getMonitor() == null
|
||||
}
|
||||
if (registryConfigs != null && registryConfigs.size() > 0) {
|
||||
super.setRegistries(registryConfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getMonitor() == null
|
||||
&& (getProvider() == null || getProvider().getMonitor() == null)
|
||||
&& (getApplication() == null || getApplication().getMonitor() == null)) {
|
||||
Map<String, MonitorConfig> monitorConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, MonitorConfig.class, false, false);
|
||||
if (monitorConfigMap != null && monitorConfigMap.size() > 0) {
|
||||
&& (getApplication() == null || getApplication().getMonitor() == null)) {
|
||||
Map<String, MonitorConfig> monitorConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, MonitorConfig.class, false, false);
|
||||
if (monitorConfigMap != null && monitorConfigMap.size() > 0) {
|
||||
MonitorConfig monitorConfig = null;
|
||||
for (MonitorConfig config : monitorConfigMap.values()) {
|
||||
if (config.isDefault() == null || config.isDefault().booleanValue()) {
|
||||
|
|
@ -220,12 +221,12 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
}
|
||||
if (monitorConfig != null) {
|
||||
setMonitor(monitorConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((getProtocols() == null || getProtocols().size() == 0)
|
||||
&& (getProvider() == null || getProvider().getProtocols() == null || getProvider().getProtocols().size() == 0)) {
|
||||
Map<String, ProtocolConfig> protocolConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((getProtocols() == null || getProtocols().size() == 0)
|
||||
&& (getProvider() == null || getProvider().getProtocols() == null || getProvider().getProtocols().size() == 0)) {
|
||||
Map<String, ProtocolConfig> protocolConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);
|
||||
if (protocolConfigMap != null && protocolConfigMap.size() > 0) {
|
||||
List<ProtocolConfig> protocolConfigs = new ArrayList<ProtocolConfig>();
|
||||
for (ProtocolConfig config : protocolConfigMap.values()) {
|
||||
|
|
@ -235,23 +236,23 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean
|
|||
}
|
||||
if (protocolConfigs != null && protocolConfigs.size() > 0) {
|
||||
super.setProtocols(protocolConfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getPath() == null || getPath().length() == 0) {
|
||||
if (beanName != null && beanName.length() > 0
|
||||
&& getInterface() != null && getInterface().length() > 0
|
||||
&& beanName.startsWith(getInterface())) {
|
||||
setPath(beanName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getPath() == null || getPath().length() == 0) {
|
||||
if (beanName != null && beanName.length() > 0
|
||||
&& getInterface() != null && getInterface().length() > 0
|
||||
&& beanName.startsWith(getInterface())) {
|
||||
setPath(beanName);
|
||||
}
|
||||
}
|
||||
if (! isDelay()) {
|
||||
export();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() throws Exception {
|
||||
unexport();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,62 +1,63 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.config.spring.schema;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.extension.ExtensionLoader;
|
||||
import com.alibaba.dubbo.common.logger.Logger;
|
||||
import com.alibaba.dubbo.common.logger.LoggerFactory;
|
||||
import com.alibaba.dubbo.common.utils.ReflectUtils;
|
||||
import com.alibaba.dubbo.common.utils.StringUtils;
|
||||
import com.alibaba.dubbo.config.ArgumentConfig;
|
||||
import com.alibaba.dubbo.config.MethodConfig;
|
||||
import com.alibaba.dubbo.config.MonitorConfig;
|
||||
import com.alibaba.dubbo.config.ProtocolConfig;
|
||||
import com.alibaba.dubbo.config.ProviderConfig;
|
||||
import com.alibaba.dubbo.config.RegistryConfig;
|
||||
import com.alibaba.dubbo.config.spring.ReferenceBean;
|
||||
import com.alibaba.dubbo.config.spring.ServiceBean;
|
||||
import com.alibaba.dubbo.rpc.Protocol;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.extension.ExtensionLoader;
|
||||
import com.alibaba.dubbo.common.logger.Logger;
|
||||
import com.alibaba.dubbo.common.logger.LoggerFactory;
|
||||
import com.alibaba.dubbo.common.utils.ReflectUtils;
|
||||
import com.alibaba.dubbo.common.utils.StringUtils;
|
||||
import com.alibaba.dubbo.config.ArgumentConfig;
|
||||
import com.alibaba.dubbo.config.MethodConfig;
|
||||
import com.alibaba.dubbo.config.MonitorConfig;
|
||||
import com.alibaba.dubbo.config.ProtocolConfig;
|
||||
import com.alibaba.dubbo.config.ProviderConfig;
|
||||
import com.alibaba.dubbo.config.RegistryConfig;
|
||||
import com.alibaba.dubbo.config.spring.ReferenceBean;
|
||||
import com.alibaba.dubbo.config.spring.ServiceBean;
|
||||
import com.alibaba.dubbo.rpc.Protocol;
|
||||
|
||||
/**
|
||||
* AbstractBeanDefinitionParser
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
|
|
@ -73,9 +74,9 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
return parse(element, parserContext, beanClass, required);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static BeanDefinition parse(Element element, ParserContext parserContext, Class<?> beanClass, boolean required) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition();
|
||||
beanDefinition.setBeanClass(beanClass);
|
||||
|
|
@ -83,12 +84,12 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
String id = element.getAttribute("id");
|
||||
if ((id == null || id.length() == 0) && required) {
|
||||
String generatedBeanName = element.getAttribute("name");
|
||||
if (generatedBeanName == null || generatedBeanName.length() == 0) {
|
||||
if (ProtocolConfig.class.equals(beanClass)) {
|
||||
generatedBeanName = "dubbo";
|
||||
if (generatedBeanName == null || generatedBeanName.length() == 0) {
|
||||
if (ProtocolConfig.class.equals(beanClass)) {
|
||||
generatedBeanName = "dubbo";
|
||||
} else {
|
||||
generatedBeanName = element.getAttribute("interface");
|
||||
}
|
||||
generatedBeanName = element.getAttribute("interface");
|
||||
}
|
||||
}
|
||||
if (generatedBeanName == null || generatedBeanName.length() == 0) {
|
||||
generatedBeanName = beanClass.getName();
|
||||
|
|
@ -103,7 +104,7 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
if (parserContext.getRegistry().containsBeanDefinition(id)) {
|
||||
throw new IllegalStateException("Duplicate spring bean id " + id);
|
||||
}
|
||||
parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);
|
||||
parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);
|
||||
beanDefinition.getPropertyValues().addPropertyValue("id", id);
|
||||
}
|
||||
if (ProtocolConfig.class.equals(beanClass)) {
|
||||
|
|
@ -117,21 +118,21 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (ServiceBean.class.equals(beanClass)) {
|
||||
String className = element.getAttribute("class");
|
||||
if(className != null && className.length() > 0) {
|
||||
RootBeanDefinition classDefinition = new RootBeanDefinition();
|
||||
classDefinition.setBeanClass(ReflectUtils.forName(className));
|
||||
classDefinition.setLazyInit(false);
|
||||
parseProperties(element.getChildNodes(), classDefinition);
|
||||
beanDefinition.getPropertyValues().addPropertyValue("ref", new BeanDefinitionHolder(classDefinition, id + "Impl"));
|
||||
}
|
||||
} else if (ProviderConfig.class.equals(beanClass)) {
|
||||
parseNested(element, parserContext, ServiceBean.class, true, "service", "provider", id, beanDefinition);
|
||||
} else if (ProviderConfig.class.equals(beanClass)) {
|
||||
parseNested(element, parserContext, ReferenceBean.class, false, "reference", "consumer", id, beanDefinition);
|
||||
}
|
||||
Set<String> props = new HashSet<String>();
|
||||
} else if (ServiceBean.class.equals(beanClass)) {
|
||||
String className = element.getAttribute("class");
|
||||
if(className != null && className.length() > 0) {
|
||||
RootBeanDefinition classDefinition = new RootBeanDefinition();
|
||||
classDefinition.setBeanClass(ReflectUtils.forName(className));
|
||||
classDefinition.setLazyInit(false);
|
||||
parseProperties(element.getChildNodes(), classDefinition);
|
||||
beanDefinition.getPropertyValues().addPropertyValue("ref", new BeanDefinitionHolder(classDefinition, id + "Impl"));
|
||||
}
|
||||
} else if (ProviderConfig.class.equals(beanClass)) {
|
||||
parseNested(element, parserContext, ServiceBean.class, true, "service", "provider", id, beanDefinition);
|
||||
} else if (ProviderConfig.class.equals(beanClass)) {
|
||||
parseNested(element, parserContext, ReferenceBean.class, false, "reference", "consumer", id, beanDefinition);
|
||||
}
|
||||
Set<String> props = new HashSet<String>();
|
||||
ManagedMap parameters = null;
|
||||
for (Method setter : beanClass.getMethods()) {
|
||||
String name = setter.getName();
|
||||
|
|
@ -139,7 +140,7 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
&& Modifier.isPublic(setter.getModifiers())
|
||||
&& setter.getParameterTypes().length == 1) {
|
||||
Class<?> type = setter.getParameterTypes()[0];
|
||||
String property = StringUtils.camelToSplitName(name.substring(3, 4).toLowerCase() + name.substring(4), "-");
|
||||
String property = StringUtils.camelToSplitName(name.substring(3, 4).toLowerCase() + name.substring(4), "-");
|
||||
props.add(property);
|
||||
Method getter = null;
|
||||
try {
|
||||
|
|
@ -161,7 +162,7 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
parseMethods(id, element.getChildNodes(), beanDefinition, parserContext);
|
||||
} else if ("arguments".equals(property)) {
|
||||
parseArguments(id, element.getChildNodes(), beanDefinition, parserContext);
|
||||
} else {
|
||||
} else {
|
||||
String value = element.getAttribute(property);
|
||||
if (value != null) {
|
||||
value = value.trim();
|
||||
|
|
@ -200,11 +201,11 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
ProtocolConfig protocol = new ProtocolConfig();
|
||||
protocol.setName(value);
|
||||
reference = protocol;
|
||||
} else if ("monitor".equals(property)
|
||||
&& (! parserContext.getRegistry().containsBeanDefinition(value)
|
||||
|| ! MonitorConfig.class.getName().equals(parserContext.getRegistry().getBeanDefinition(value).getBeanClassName()))) {
|
||||
// 兼容旧版本配置
|
||||
reference = convertMonitor(value);
|
||||
} else if ("monitor".equals(property)
|
||||
&& (! parserContext.getRegistry().containsBeanDefinition(value)
|
||||
|| ! MonitorConfig.class.getName().equals(parserContext.getRegistry().getBeanDefinition(value).getBeanClassName()))) {
|
||||
// 兼容旧版本配置
|
||||
reference = convertMonitor(value);
|
||||
} else if ("onreturn".equals(property)) {
|
||||
int index = value.lastIndexOf(".");
|
||||
String returnRef = value.substring(0, index);
|
||||
|
|
@ -216,7 +217,7 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
String throwRef = value.substring(0, index);
|
||||
String throwMethod = value.substring(index + 1);
|
||||
reference = new RuntimeBeanReference(throwRef);
|
||||
beanDefinition.getPropertyValues().addPropertyValue("onthrowMethod", throwMethod);
|
||||
beanDefinition.getPropertyValues().addPropertyValue("onthrowMethod", throwMethod);
|
||||
} else {
|
||||
if ("ref".equals(property) && parserContext.getRegistry().containsBeanDefinition(value)) {
|
||||
BeanDefinition refBean = parserContext.getRegistry().getBeanDefinition(value);
|
||||
|
|
@ -232,50 +233,50 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NamedNodeMap attributes = element.getAttributes();
|
||||
int len = attributes.getLength();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node node = attributes.item(i);
|
||||
String name = node.getLocalName();
|
||||
if (! props.contains(name)) {
|
||||
if (parameters == null) {
|
||||
parameters = new ManagedMap();
|
||||
}
|
||||
String value = node.getNodeValue();
|
||||
parameters.put(name, new TypedStringValue(value, String.class));
|
||||
}
|
||||
}
|
||||
if (parameters != null) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue("parameters", parameters);
|
||||
}
|
||||
NamedNodeMap attributes = element.getAttributes();
|
||||
int len = attributes.getLength();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node node = attributes.item(i);
|
||||
String name = node.getLocalName();
|
||||
if (! props.contains(name)) {
|
||||
if (parameters == null) {
|
||||
parameters = new ManagedMap();
|
||||
}
|
||||
String value = node.getNodeValue();
|
||||
parameters.put(name, new TypedStringValue(value, String.class));
|
||||
}
|
||||
}
|
||||
if (parameters != null) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue("parameters", parameters);
|
||||
}
|
||||
return beanDefinition;
|
||||
}
|
||||
|
||||
private static final Pattern GROUP_AND_VERION = Pattern.compile("^[\\-.0-9_a-zA-Z]+(\\:[\\-.0-9_a-zA-Z]+)?$");
|
||||
|
||||
protected static MonitorConfig convertMonitor(String monitor) {
|
||||
if (monitor == null || monitor.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (GROUP_AND_VERION.matcher(monitor).matches()) {
|
||||
String group;
|
||||
String version;
|
||||
int i = monitor.indexOf(':');
|
||||
if (i > 0) {
|
||||
group = monitor.substring(0, i);
|
||||
version = monitor.substring(i + 1);
|
||||
} else {
|
||||
group = monitor;
|
||||
version = null;
|
||||
}
|
||||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
monitorConfig.setGroup(group);
|
||||
monitorConfig.setVersion(version);
|
||||
return monitorConfig;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern GROUP_AND_VERION = Pattern.compile("^[\\-.0-9_a-zA-Z]+(\\:[\\-.0-9_a-zA-Z]+)?$");
|
||||
|
||||
protected static MonitorConfig convertMonitor(String monitor) {
|
||||
if (monitor == null || monitor.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (GROUP_AND_VERION.matcher(monitor).matches()) {
|
||||
String group;
|
||||
String version;
|
||||
int i = monitor.indexOf(':');
|
||||
if (i > 0) {
|
||||
group = monitor.substring(0, i);
|
||||
version = monitor.substring(i + 1);
|
||||
} else {
|
||||
group = monitor;
|
||||
version = null;
|
||||
}
|
||||
MonitorConfig monitorConfig = new MonitorConfig();
|
||||
monitorConfig.setGroup(group);
|
||||
monitorConfig.setVersion(version);
|
||||
return monitorConfig;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isPrimitive(Class<?> cls) {
|
||||
return cls.isPrimitive() || cls == Boolean.class || cls == Byte.class
|
||||
|
|
@ -299,58 +300,58 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
}
|
||||
}
|
||||
beanDefinition.getPropertyValues().addPropertyValue(property, list);
|
||||
}
|
||||
|
||||
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
|
||||
NodeList nodeList = element.getChildNodes();
|
||||
if (nodeList != null && nodeList.getLength() > 0) {
|
||||
boolean first = true;
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node node = nodeList.item(i);
|
||||
if (node instanceof Element) {
|
||||
if (tag.equals(node.getNodeName())
|
||||
|| tag.equals(node.getLocalName())) {
|
||||
if (first) {
|
||||
first = false;
|
||||
String isDefault = element.getAttribute("default");
|
||||
if (isDefault == null || isDefault.length() == 0) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue("default", "false");
|
||||
}
|
||||
}
|
||||
BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
|
||||
if (subDefinition != null && ref != null && ref.length() > 0) {
|
||||
subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
|
||||
if (nodeList != null && nodeList.getLength() > 0) {
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node node = nodeList.item(i);
|
||||
if (node instanceof Element) {
|
||||
if ("property".equals(node.getNodeName())
|
||||
|| "property".equals(node.getLocalName())) {
|
||||
String name = ((Element) node).getAttribute("name");
|
||||
if (name != null && name.length() > 0) {
|
||||
String value = ((Element) node).getAttribute("value");
|
||||
String ref = ((Element) node).getAttribute("ref");
|
||||
if (value != null && value.length() > 0) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue(name, value);
|
||||
} else if (ref != null && ref.length() > 0) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
|
||||
NodeList nodeList = element.getChildNodes();
|
||||
if (nodeList != null && nodeList.getLength() > 0) {
|
||||
boolean first = true;
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node node = nodeList.item(i);
|
||||
if (node instanceof Element) {
|
||||
if (tag.equals(node.getNodeName())
|
||||
|| tag.equals(node.getLocalName())) {
|
||||
if (first) {
|
||||
first = false;
|
||||
String isDefault = element.getAttribute("default");
|
||||
if (isDefault == null || isDefault.length() == 0) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue("default", "false");
|
||||
}
|
||||
}
|
||||
BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
|
||||
if (subDefinition != null && ref != null && ref.length() > 0) {
|
||||
subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
|
||||
if (nodeList != null && nodeList.getLength() > 0) {
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node node = nodeList.item(i);
|
||||
if (node instanceof Element) {
|
||||
if ("property".equals(node.getNodeName())
|
||||
|| "property".equals(node.getLocalName())) {
|
||||
String name = ((Element) node).getAttribute("name");
|
||||
if (name != null && name.length() > 0) {
|
||||
String value = ((Element) node).getAttribute("value");
|
||||
String ref = ((Element) node).getAttribute("ref");
|
||||
if (value != null && value.length() > 0) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue(name, value);
|
||||
} else if (ref != null && ref.length() > 0) {
|
||||
beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static ManagedMap parseParameters(NodeList nodeList, RootBeanDefinition beanDefinition) {
|
||||
|
|
@ -373,9 +374,9 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser {
|
|||
parameters.put(key, new TypedStringValue(value, String.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.config.spring.schema;
|
||||
|
||||
package com.alibaba.dubbo.config.spring.schema;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
|
||||
import com.alibaba.dubbo.common.Version;
|
||||
|
|
@ -28,18 +28,19 @@ import com.alibaba.dubbo.config.RegistryConfig;
|
|||
import com.alibaba.dubbo.config.spring.AnnotationBean;
|
||||
import com.alibaba.dubbo.config.spring.ReferenceBean;
|
||||
import com.alibaba.dubbo.config.spring.ServiceBean;
|
||||
|
||||
/**
|
||||
* DubboNamespaceHandler
|
||||
*
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class DubboNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
static {
|
||||
Version.checkDuplicate(DubboNamespaceHandler.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DubboNamespaceHandler
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class DubboNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
static {
|
||||
Version.checkDuplicate(DubboNamespaceHandler.class);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
|
||||
registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
|
||||
|
|
@ -52,5 +53,5 @@ public class DubboNamespaceHandler extends NamespaceHandlerSupport {
|
|||
registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
|
||||
registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ package com.alibaba.dubbo.cache;
|
|||
* Cache
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Cache {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* CacheFactory
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("lru")
|
||||
public interface CacheFactory {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* Validation
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("jvalidation")
|
||||
public interface Validation {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.alibaba.dubbo.validation;
|
|||
* Validator
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Validator {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alibaba.dubbo.common.Node;
|
|||
*
|
||||
* @see com.alibaba.dubbo.monitor.MonitorFactory#getMonitor(com.alibaba.dubbo.common.URL)
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Monitor extends Node, MonitorService {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* MonitorFactory. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("dubbo")
|
||||
public interface MonitorFactory {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.alibaba.dubbo.common.URL;
|
|||
* MonitorService. (SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface MonitorService {
|
||||
|
||||
|
|
|
|||
|
|
@ -13,21 +13,22 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.registry;
|
||||
|
||||
package com.alibaba.dubbo.registry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
|
||||
/**
|
||||
* NotifyListener. (API, Prototype, ThreadSafe)
|
||||
*
|
||||
* @see com.alibaba.dubbo.registry.RegistryService#subscribe(URL, NotifyListener)
|
||||
* @author william.liangf
|
||||
*/
|
||||
public interface NotifyListener {
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* NotifyListener. (API, Prototype, ThreadSafe)
|
||||
*
|
||||
* @see com.alibaba.dubbo.registry.RegistryService#subscribe(URL, NotifyListener)
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface NotifyListener {
|
||||
|
||||
/**
|
||||
* 当收到服务变更通知时触发。
|
||||
*
|
||||
* 通知需处理契约:<br>
|
||||
|
|
@ -37,8 +38,8 @@ public interface NotifyListener {
|
|||
* 4. 如果一种类型的数据为空,需通知一个empty协议并带category参数的标识性URL数据。<br>
|
||||
* 5. 通知者(即注册中心实现)需保证通知的顺序,比如:单线程推送,队列串行化,带版本对比。<br>
|
||||
*
|
||||
* @param urls 已注册信息列表,总不为空,含义同{@link com.alibaba.dubbo.registry.RegistryService#lookup(URL)}的返回值。
|
||||
*/
|
||||
void notify(List<URL> urls);
|
||||
|
||||
* @param urls 已注册信息列表,总不为空,含义同{@link com.alibaba.dubbo.registry.RegistryService#lookup(URL)}的返回值。
|
||||
*/
|
||||
void notify(List<URL> urls);
|
||||
|
||||
}
|
||||
|
|
@ -13,17 +13,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.registry;
|
||||
|
||||
package com.alibaba.dubbo.registry;
|
||||
|
||||
import com.alibaba.dubbo.common.Node;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
|
||||
/**
|
||||
* Registry. (SPI, Prototype, ThreadSafe)
|
||||
|
||||
/**
|
||||
* Registry. (SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @see com.alibaba.dubbo.registry.RegistryFactory#getRegistry(URL)
|
||||
* @see com.alibaba.dubbo.registry.RegistryFactory#getRegistry(URL)
|
||||
* @see com.alibaba.dubbo.registry.support.AbstractRegistry
|
||||
* @author william.liangf
|
||||
*/
|
||||
public interface Registry extends Node, RegistryService {
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Registry extends Node, RegistryService {
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
*
|
||||
* @see com.alibaba.dubbo.registry.support.AbstractRegistryFactory
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("dubbo")
|
||||
public interface RegistryFactory {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.alibaba.dubbo.common.URL;
|
|||
* @see com.alibaba.dubbo.registry.Registry
|
||||
* @see com.alibaba.dubbo.registry.RegistryFactory#getRegistry(URL)
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface RegistryService {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
@ -25,6 +25,7 @@ import java.net.InetSocketAddress;
|
|||
* @see com.alibaba.dubbo.remoting.Server#getChannel(InetSocketAddress)
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Channel extends Endpoint {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -25,7 +25,8 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* @see com.alibaba.dubbo.remoting.Transporter#connect(com.alibaba.dubbo.common.URL, ChannelHandler)
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
*/
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface ChannelHandler {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.common.Resetable;
|
|||
*
|
||||
* @see com.alibaba.dubbo.remoting.Transporter#connect(com.alibaba.dubbo.common.URL, ChannelHandler)
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface Client extends Endpoint, Channel, Resetable {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* Codec. (SPI, Singleton, ThreadSafe)
|
||||
|
|
@ -29,8 +29,9 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* @author qianlei
|
||||
* @author ding.lid
|
||||
* @author william.liangf
|
||||
*/
|
||||
@SPI
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface Codec {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,30 +1,31 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
import com.alibaba.dubbo.remoting.transport.dispather.all.AllDispather;
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
import com.alibaba.dubbo.remoting.transport.dispather.all.AllDispather;
|
||||
|
||||
/**
|
||||
* ChannelHandlerWrapper (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author chao.liuc
|
||||
* @export
|
||||
*/
|
||||
@SPI(AllDispather.NAME)
|
||||
public interface Dispather {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.alibaba.dubbo.common.URL;
|
|||
* @see com.alibaba.dubbo.remoting.Client
|
||||
* @see com.alibaba.dubbo.remoting.Server
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Endpoint {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
|
|||
* ReceiveException
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class ExecutionException extends RemotingException {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
@ -28,6 +28,7 @@ import java.net.InetSocketAddress;
|
|||
* @see com.alibaba.dubbo.remoting.Transporter#bind(com.alibaba.dubbo.common.URL, ChannelHandler)
|
||||
* @see com.alibaba.dubbo.remoting.Transporter#connect(com.alibaba.dubbo.common.URL, ChannelHandler)
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public class RemotingException extends Exception {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.alibaba.dubbo.common.Resetable;
|
|||
*
|
||||
* @see com.alibaba.dubbo.remoting.Transporter#bind(com.alibaba.dubbo.common.URL, ChannelHandler)
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface Server extends Endpoint, Resetable {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
@ -23,6 +23,7 @@ import java.net.InetSocketAddress;
|
|||
* @see com.alibaba.dubbo.remoting.exchange.ResponseFuture#get()
|
||||
* @see com.alibaba.dubbo.remoting.exchange.ResponseFuture#get(int)
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public class TimeoutException extends RemotingException {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.remoting;
|
||||
|
||||
import javax.sound.midi.Receiver;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
import javax.sound.midi.Receiver;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* Transporter. (SPI, Singleton, ThreadSafe)
|
||||
|
|
@ -31,6 +31,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* @see com.alibaba.dubbo.remoting.Transporters
|
||||
* @author ding.lid
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("netty")
|
||||
public interface Transporter {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alibaba.dubbo.remoting.RemotingException;
|
|||
* ExchangeChannel. (API/SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface ExchangeChannel extends Channel {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.alibaba.dubbo.remoting.Client;
|
|||
* ExchangeClient. (API/SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface ExchangeClient extends Client, ExchangeChannel {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
|
|||
* ExchangeHandler. (API, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface ExchangeHandler extends ChannelHandler, TelnetHandler {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.remoting.Server;
|
|||
* ExchangeServer. (API/SPI, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface ExchangeServer extends Server {
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchanger;
|
|||
* <a href="http://en.wikipedia.org/wiki/Request-response">Request-Response</a>
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI(HeaderExchanger.NAME)
|
||||
public interface Exchanger {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.remoting.RemotingException;
|
|||
* @see com.alibaba.dubbo.remoting.exchange.ExchangeChannel#request(Object, int)
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface ResponseFuture {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alibaba.dubbo.remoting.exchange.ExchangeChannel;
|
|||
* Replier. (API, Prototype, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Replier<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package com.alibaba.dubbo.rpc;
|
|||
* @see com.alibaba.dubbo.rpc.ExporterListener
|
||||
* @see com.alibaba.dubbo.rpc.protocol.AbstractExporter
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Exporter<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* ExporterListener. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface ExporterListener {
|
||||
|
|
|
|||
|
|
@ -13,34 +13,35 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* Filter. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
/**
|
||||
* Filter. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface Filter {
|
||||
|
||||
/**
|
||||
* do invoke filter.
|
||||
*
|
||||
public interface Filter {
|
||||
|
||||
/**
|
||||
* do invoke filter.
|
||||
*
|
||||
* <code>
|
||||
* // before filter
|
||||
* // before filter
|
||||
* Result result = invoker.invoke(invocation);
|
||||
* // after filter
|
||||
* return result;
|
||||
* </code>
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.Invoker#invoke(Invocation)
|
||||
* @param invoker service
|
||||
* @param invocation invocation.
|
||||
* @return invoke result.
|
||||
* @throws RpcException
|
||||
* return result;
|
||||
* </code>
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.Invoker#invoke(Invocation)
|
||||
* @param invoker service
|
||||
* @param invocation invocation.
|
||||
* @return invoke result.
|
||||
* @throws RpcException
|
||||
*/
|
||||
Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException;
|
||||
|
||||
Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException;
|
||||
|
||||
}
|
||||
|
|
@ -13,51 +13,52 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
import java.util.Map;
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
/**
|
||||
* Invocation. (API, Prototype, NonThreadSafe)
|
||||
*
|
||||
* @serial Don't change the class name and package name.
|
||||
* @see com.alibaba.dubbo.rpc.Invoker#invoke(Invocation)
|
||||
* @see com.alibaba.dubbo.rpc.RpcInvocation
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
*/
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Invocation. (API, Prototype, NonThreadSafe)
|
||||
*
|
||||
* @serial Don't change the class name and package name.
|
||||
* @see com.alibaba.dubbo.rpc.Invoker#invoke(Invocation)
|
||||
* @see com.alibaba.dubbo.rpc.RpcInvocation
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Invocation {
|
||||
|
||||
/**
|
||||
* get method name.
|
||||
|
||||
/**
|
||||
* get method name.
|
||||
*
|
||||
* @serial
|
||||
* @return method name.
|
||||
*/
|
||||
String getMethodName();
|
||||
|
||||
/**
|
||||
* get parameter types.
|
||||
* @serial
|
||||
* @return method name.
|
||||
*/
|
||||
String getMethodName();
|
||||
|
||||
/**
|
||||
* get parameter types.
|
||||
*
|
||||
* @serial
|
||||
* @return parameter types.
|
||||
*/
|
||||
Class<?>[] getParameterTypes();
|
||||
|
||||
/**
|
||||
* get arguments.
|
||||
* @serial
|
||||
* @return parameter types.
|
||||
*/
|
||||
Class<?>[] getParameterTypes();
|
||||
|
||||
/**
|
||||
* get arguments.
|
||||
*
|
||||
* @serial
|
||||
* @return arguments.
|
||||
*/
|
||||
Object[] getArguments();
|
||||
|
||||
/**
|
||||
* get attachments.
|
||||
* @serial
|
||||
* @return arguments.
|
||||
*/
|
||||
Object[] getArguments();
|
||||
|
||||
/**
|
||||
* get attachments.
|
||||
*
|
||||
* @serial
|
||||
* @return attachments.
|
||||
*/
|
||||
* @serial
|
||||
* @return attachments.
|
||||
*/
|
||||
Map<String, String> getAttachments();
|
||||
|
||||
/**
|
||||
|
|
@ -83,5 +84,5 @@ public interface Invocation {
|
|||
* @return invoker.
|
||||
*/
|
||||
Invoker<?> getInvoker();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ import com.alibaba.dubbo.common.Node;
|
|||
* @see com.alibaba.dubbo.rpc.InvokerListener
|
||||
* @see com.alibaba.dubbo.rpc.protocol.AbstractInvoker
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Invoker<T> extends Node {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alibaba.dubbo.common.extension.SPI;
|
|||
* InvokerListener. (SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI
|
||||
public interface InvokerListener {
|
||||
|
|
|
|||
|
|
@ -13,26 +13,27 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* Protocol. (API/SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
|
||||
/**
|
||||
* Protocol. (API/SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("dubbo")
|
||||
public interface Protocol {
|
||||
|
||||
/**
|
||||
* 获取缺省端口,当用户没有配置端口时使用。
|
||||
*
|
||||
* @return 缺省端口
|
||||
*/
|
||||
int getDefaultPort();
|
||||
@SPI("dubbo")
|
||||
public interface Protocol {
|
||||
|
||||
/**
|
||||
* 获取缺省端口,当用户没有配置端口时使用。
|
||||
*
|
||||
* @return 缺省端口
|
||||
*/
|
||||
int getDefaultPort();
|
||||
|
||||
/**
|
||||
* 暴露远程服务:<br>
|
||||
|
|
@ -62,13 +63,13 @@ public interface Protocol {
|
|||
*/
|
||||
@Adaptive
|
||||
<T> Invoker<T> refer(Class<T> type, URL url) throws RpcException;
|
||||
|
||||
|
||||
/**
|
||||
* 释放协议:<br>
|
||||
* 1. 取消该协议所有已经暴露和引用的服务。<br>
|
||||
* 1. 取消该协议所有已经暴露和引用的服务。<br>
|
||||
* 2. 释放协议所占用的所有资源,比如连接和端口。<br>
|
||||
* 3. 协议在释放后,依然能暴露和引用新的服务。<br>
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
* 3. 协议在释放后,依然能暴露和引用新的服务。<br>
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
}
|
||||
|
|
@ -1,29 +1,30 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.extension.Adaptive;
|
||||
import com.alibaba.dubbo.common.extension.SPI;
|
||||
|
||||
/**
|
||||
* ProxyFactory. (API/SPI, Singleton, ThreadSafe)
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
@SPI("javassist")
|
||||
public interface ProxyFactory {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +23,7 @@ package com.alibaba.dubbo.rpc;
|
|||
* @see com.alibaba.dubbo.rpc.RpcResult
|
||||
* @author qianlei
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface Result {
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public interface Result {
|
|||
*
|
||||
* @return result. if no result return null.
|
||||
*/
|
||||
Object getValue();
|
||||
Object getValue();
|
||||
|
||||
/**
|
||||
* Get exception.
|
||||
|
|
@ -39,13 +40,13 @@ public interface Result {
|
|||
* @return exception. if no exception return null.
|
||||
*/
|
||||
Throwable getException();
|
||||
|
||||
/**
|
||||
* Has exception.
|
||||
*
|
||||
* @return has exception.
|
||||
*/
|
||||
boolean hasException();
|
||||
|
||||
/**
|
||||
* Has exception.
|
||||
*
|
||||
* @return has exception.
|
||||
*/
|
||||
boolean hasException();
|
||||
|
||||
/**
|
||||
* Recreate.
|
||||
|
|
@ -56,18 +57,18 @@ public interface Result {
|
|||
* } else {
|
||||
* return getValue();
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @return result.
|
||||
* </code>
|
||||
*
|
||||
* @return result.
|
||||
* @throws if has exception throw it.
|
||||
*/
|
||||
Object recreate() throws Throwable;
|
||||
|
||||
/**
|
||||
* @deprecated Replace to getValue()
|
||||
* @see com.alibaba.dubbo.rpc.Result#getValue()
|
||||
*/
|
||||
@Deprecated
|
||||
Object getResult();
|
||||
|
||||
/**
|
||||
* @deprecated Replace to getValue()
|
||||
* @see com.alibaba.dubbo.rpc.Result#getValue()
|
||||
*/
|
||||
@Deprecated
|
||||
Object getResult();
|
||||
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -31,43 +31,44 @@ import java.util.concurrent.TimeoutException;
|
|||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.utils.NetUtils;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Thread local context. (API, ThreadLocal, ThreadSafe)
|
||||
*
|
||||
* 注意:RpcContext是一个临时状态记录器,当接收到RPC请求,或发起RPC请求时,RpcContext的状态都会变化。
|
||||
* 比如:A调B,B再调C,则B机器上,在B调C之前,RpcContext记录的是A调B的信息,在B调C之后,RpcContext记录的是B调C的信息。
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.filter.ContextFilter
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
*/
|
||||
public class RpcContext {
|
||||
|
||||
private static final ThreadLocal<RpcContext> LOCAL = new ThreadLocal<RpcContext>() {
|
||||
@Override
|
||||
protected RpcContext initialValue() {
|
||||
return new RpcContext();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* get context.
|
||||
*
|
||||
* @return context
|
||||
*/
|
||||
public static RpcContext getContext() {
|
||||
return LOCAL.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* remove context.
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.filter.ContextFilter
|
||||
*/
|
||||
public static void removeContext() {
|
||||
LOCAL.remove();
|
||||
}
|
||||
* 比如:A调B,B再调C,则B机器上,在B调C之前,RpcContext记录的是A调B的信息,在B调C之后,RpcContext记录的是B调C的信息。
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.filter.ContextFilter
|
||||
* @author qian.lei
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class RpcContext {
|
||||
|
||||
private static final ThreadLocal<RpcContext> LOCAL = new ThreadLocal<RpcContext>() {
|
||||
@Override
|
||||
protected RpcContext initialValue() {
|
||||
return new RpcContext();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* get context.
|
||||
*
|
||||
* @return context
|
||||
*/
|
||||
public static RpcContext getContext() {
|
||||
return LOCAL.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* remove context.
|
||||
*
|
||||
* @see com.alibaba.dubbo.rpc.filter.ContextFilter
|
||||
*/
|
||||
public static void removeContext() {
|
||||
LOCAL.remove();
|
||||
}
|
||||
|
||||
private Future<?> future;
|
||||
|
||||
|
|
@ -80,10 +81,10 @@ public class RpcContext {
|
|||
private Class<?>[] parameterTypes;
|
||||
|
||||
private Object[] arguments;
|
||||
|
||||
private InetSocketAddress localAddress;
|
||||
|
||||
private InetSocketAddress remoteAddress;
|
||||
|
||||
private InetSocketAddress localAddress;
|
||||
|
||||
private InetSocketAddress remoteAddress;
|
||||
|
||||
private final Map<String, String> attachments = new HashMap<String, String>();
|
||||
|
||||
|
|
@ -97,9 +98,9 @@ public class RpcContext {
|
|||
|
||||
@Deprecated
|
||||
private Invocation invocation;
|
||||
|
||||
protected RpcContext() {
|
||||
}
|
||||
|
||||
protected RpcContext() {
|
||||
}
|
||||
|
||||
/**
|
||||
* is provider side.
|
||||
|
|
@ -123,7 +124,7 @@ public class RpcContext {
|
|||
}
|
||||
return url.getPort() != address.getPort() ||
|
||||
! NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* is consumer side.
|
||||
|
|
@ -179,7 +180,7 @@ public class RpcContext {
|
|||
|
||||
public URL getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public void setUrl(URL url) {
|
||||
this.url = url;
|
||||
|
|
@ -223,155 +224,155 @@ public class RpcContext {
|
|||
public void setArguments(Object[] arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* set local address.
|
||||
*
|
||||
* @param address
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setLocalAddress(InetSocketAddress address) {
|
||||
this.localAddress = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set local address.
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setLocalAddress(String host, int port) {
|
||||
if (port < 0) {
|
||||
port = 0;
|
||||
}
|
||||
this.localAddress = InetSocketAddress.createUnresolved(host, port);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get local address.
|
||||
*
|
||||
* @return local address
|
||||
*/
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
public String getLocalAddressString() {
|
||||
return getLocalHost() + ":" + getLocalPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get local host name.
|
||||
*
|
||||
* @return local host name
|
||||
*/
|
||||
public String getLocalHostName() {
|
||||
String host = localAddress == null ? null : localAddress.getHostName();
|
||||
if (host == null || host.length() == 0) {
|
||||
return getLocalHost();
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* set remote address.
|
||||
*
|
||||
* @param address
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setRemoteAddress(InetSocketAddress address) {
|
||||
this.remoteAddress = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set remote address.
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setRemoteAddress(String host, int port) {
|
||||
if (port < 0) {
|
||||
port = 0;
|
||||
}
|
||||
this.remoteAddress = InetSocketAddress.createUnresolved(host, port);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote address.
|
||||
*
|
||||
* @return remote address
|
||||
*/
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote address string.
|
||||
*
|
||||
* @return remote address string.
|
||||
*/
|
||||
public String getRemoteAddressString() {
|
||||
return getRemoteHost() + ":" + getRemotePort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote host name.
|
||||
*
|
||||
* @return remote host name
|
||||
*/
|
||||
public String getRemoteHostName() {
|
||||
return remoteAddress == null ? null : remoteAddress.getHostName();
|
||||
}
|
||||
|
||||
/**
|
||||
* get local host.
|
||||
*
|
||||
* @return local host
|
||||
*/
|
||||
public String getLocalHost() {
|
||||
String host = localAddress == null ? null :
|
||||
|
||||
/**
|
||||
* set local address.
|
||||
*
|
||||
* @param address
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setLocalAddress(InetSocketAddress address) {
|
||||
this.localAddress = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set local address.
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setLocalAddress(String host, int port) {
|
||||
if (port < 0) {
|
||||
port = 0;
|
||||
}
|
||||
this.localAddress = InetSocketAddress.createUnresolved(host, port);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get local address.
|
||||
*
|
||||
* @return local address
|
||||
*/
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
public String getLocalAddressString() {
|
||||
return getLocalHost() + ":" + getLocalPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get local host name.
|
||||
*
|
||||
* @return local host name
|
||||
*/
|
||||
public String getLocalHostName() {
|
||||
String host = localAddress == null ? null : localAddress.getHostName();
|
||||
if (host == null || host.length() == 0) {
|
||||
return getLocalHost();
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* set remote address.
|
||||
*
|
||||
* @param address
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setRemoteAddress(InetSocketAddress address) {
|
||||
this.remoteAddress = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set remote address.
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setRemoteAddress(String host, int port) {
|
||||
if (port < 0) {
|
||||
port = 0;
|
||||
}
|
||||
this.remoteAddress = InetSocketAddress.createUnresolved(host, port);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote address.
|
||||
*
|
||||
* @return remote address
|
||||
*/
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote address string.
|
||||
*
|
||||
* @return remote address string.
|
||||
*/
|
||||
public String getRemoteAddressString() {
|
||||
return getRemoteHost() + ":" + getRemotePort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote host name.
|
||||
*
|
||||
* @return remote host name
|
||||
*/
|
||||
public String getRemoteHostName() {
|
||||
return remoteAddress == null ? null : remoteAddress.getHostName();
|
||||
}
|
||||
|
||||
/**
|
||||
* get local host.
|
||||
*
|
||||
* @return local host
|
||||
*/
|
||||
public String getLocalHost() {
|
||||
String host = localAddress == null ? null :
|
||||
localAddress.getAddress() == null ? localAddress.getHostName()
|
||||
: NetUtils.filterLocalHost(localAddress.getAddress().getHostAddress());
|
||||
if (host == null || host.length() == 0) {
|
||||
return NetUtils.getLocalHost();
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* get local port.
|
||||
*
|
||||
* @return port
|
||||
*/
|
||||
public int getLocalPort() {
|
||||
return localAddress == null ? 0 : localAddress.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote host.
|
||||
*
|
||||
* @return remote host
|
||||
*/
|
||||
public String getRemoteHost() {
|
||||
return remoteAddress == null ? null :
|
||||
: NetUtils.filterLocalHost(localAddress.getAddress().getHostAddress());
|
||||
if (host == null || host.length() == 0) {
|
||||
return NetUtils.getLocalHost();
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* get local port.
|
||||
*
|
||||
* @return port
|
||||
*/
|
||||
public int getLocalPort() {
|
||||
return localAddress == null ? 0 : localAddress.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote host.
|
||||
*
|
||||
* @return remote host
|
||||
*/
|
||||
public String getRemoteHost() {
|
||||
return remoteAddress == null ? null :
|
||||
remoteAddress.getAddress() == null ? remoteAddress.getHostName()
|
||||
: NetUtils.filterLocalHost(remoteAddress.getAddress().getHostAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote port.
|
||||
*
|
||||
* @return remote port
|
||||
*/
|
||||
public int getRemotePort() {
|
||||
return remoteAddress == null ? 0 : remoteAddress.getPort();
|
||||
}
|
||||
: NetUtils.filterLocalHost(remoteAddress.getAddress().getHostAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* get remote port.
|
||||
*
|
||||
* @return remote port
|
||||
*/
|
||||
public int getRemotePort() {
|
||||
return remoteAddress == null ? 0 : remoteAddress.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* get attachment.
|
||||
|
|
@ -382,33 +383,33 @@ public class RpcContext {
|
|||
public String getAttachment(String key) {
|
||||
return attachments.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* set attachment.
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setAttachment(String key, String value) {
|
||||
if (value == null) {
|
||||
attachments.remove(key);
|
||||
} else {
|
||||
attachments.put(key, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove attachment.
|
||||
*
|
||||
* @param key
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext removeAttachment(String key) {
|
||||
attachments.remove(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set attachment.
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext setAttachment(String key, String value) {
|
||||
if (value == null) {
|
||||
attachments.remove(key);
|
||||
} else {
|
||||
attachments.put(key, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove attachment.
|
||||
*
|
||||
* @param key
|
||||
* @return context
|
||||
*/
|
||||
public RpcContext removeAttachment(String key) {
|
||||
attachments.remove(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get attachments.
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc;
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +23,7 @@ package com.alibaba.dubbo.rpc;
|
|||
* @see com.alibaba.dubbo.rpc.Invoker#invoke(Invocation)
|
||||
* @author shawn.qianx
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public final class RpcException extends RuntimeException {
|
||||
|
||||
|
|
@ -36,9 +37,9 @@ public final class RpcException extends RuntimeException {
|
|||
|
||||
public static final int BIZ_EXCEPTION = 3;
|
||||
|
||||
public static final int FORBIDDEN_EXCEPTION = 4;
|
||||
|
||||
public static final int SERIALIZATION_EXCEPTION = 5;
|
||||
public static final int FORBIDDEN_EXCEPTION = 4;
|
||||
|
||||
public static final int SERIALIZATION_EXCEPTION = 5;
|
||||
|
||||
private int code; // RpcException不能有子类,异常类型用ErrorCode表示,以便保持兼容。
|
||||
|
||||
|
|
@ -93,16 +94,16 @@ public final class RpcException extends RuntimeException {
|
|||
public boolean isForbidded() {
|
||||
return code == FORBIDDEN_EXCEPTION;
|
||||
}
|
||||
|
||||
public boolean isTimeout() {
|
||||
return code == TIMEOUT_EXCEPTION;
|
||||
}
|
||||
|
||||
public boolean isTimeout() {
|
||||
return code == TIMEOUT_EXCEPTION;
|
||||
}
|
||||
|
||||
public boolean isNetwork() {
|
||||
return code == NETWORK_EXCEPTION;
|
||||
}
|
||||
|
||||
public boolean isSerialization() {
|
||||
return code == SERIALIZATION_EXCEPTION;
|
||||
}
|
||||
|
||||
public boolean isSerialization() {
|
||||
return code == SERIALIZATION_EXCEPTION;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc.service;
|
||||
|
||||
/**
|
||||
* Echo service.
|
||||
*
|
||||
* @author qian.lei
|
||||
* @export
|
||||
*/
|
||||
public interface EchoService {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alibaba.dubbo.common.utils.StringUtils;
|
|||
*
|
||||
* @serial Don't change the class name and properties.
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public class GenericException extends RuntimeException {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,25 @@
|
|||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.dubbo.rpc.service;
|
||||
|
||||
/**
|
||||
* 通用服务接口
|
||||
*
|
||||
* @author william.liangf
|
||||
* @export
|
||||
*/
|
||||
public interface GenericService {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue