-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dubbo-2678] Add ability to turn off SPI auto injection, special supp…
…ort for Object type. (#2681) * Add ability to turn off SPI auto injection, special support for generic Object type injection. * Add ability to turn off SPI auto injection, special support for generic Object type injection. * disable() is redundant in DisableInject annotation.
- Loading branch information
Showing
7 changed files
with
143 additions
and
3 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/DisableInject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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; | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
public @interface DisableInject { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
dubbo-common/src/test/java/com/alibaba/dubbo/common/extensionloader/injection/InjectExt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.extensionloader.injection; | ||
|
||
import com.alibaba.dubbo.common.extension.SPI; | ||
|
||
/** | ||
* | ||
*/ | ||
@SPI("injection") | ||
public interface InjectExt { | ||
String echo(String msg); | ||
} |
61 changes: 61 additions & 0 deletions
61
.../src/test/java/com/alibaba/dubbo/common/extensionloader/injection/impl/InjectExtImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.extensionloader.injection.impl; | ||
|
||
|
||
import com.alibaba.dubbo.common.extension.DisableInject; | ||
import com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt; | ||
import com.alibaba.dubbo.common.extensionloader.injection.InjectExt; | ||
|
||
public class InjectExtImpl implements InjectExt { | ||
|
||
private SimpleExt simpleExt; | ||
|
||
private SimpleExt simpleExt1; | ||
|
||
private Object genericType; | ||
|
||
public void setSimpleExt(SimpleExt simpleExt) { | ||
this.simpleExt = simpleExt; | ||
} | ||
|
||
@DisableInject | ||
public void setSimpleExt1(SimpleExt simpleExt1) { | ||
this.simpleExt1 = simpleExt1; | ||
} | ||
|
||
public void setGenericType(Object genericType) { | ||
this.genericType = genericType; | ||
} | ||
|
||
@Override | ||
public String echo(String msg) { | ||
return null; | ||
} | ||
|
||
public SimpleExt getSimpleExt() { | ||
return simpleExt; | ||
} | ||
|
||
public SimpleExt getSimpleExt1() { | ||
return simpleExt1; | ||
} | ||
|
||
public Object getGenericType() { | ||
return genericType; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...rces/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.injection.InjectExt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
injection=com.alibaba.dubbo.common.extensionloader.injection.impl.InjectExtImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters