-
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][For Master] Add ability to turn off SPI auto injection, …
…special support for Object type. (#2682) * Add ability to turn off SPI auto injection, special support for generic Object type injection. * Change Inject to AutoInject since it's main purpose is to turn off auto-injection. * disable is redundant in DisableInject annotation
- Loading branch information
Showing
7 changed files
with
144 additions
and
5 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
dubbo-common/src/main/java/org/apache/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 org.apache.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/org/apache/dubbo/common/extension/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 org.apache.dubbo.common.extension.injection; | ||
|
||
import org.apache.dubbo.common.extension.SPI; | ||
|
||
/** | ||
* | ||
*/ | ||
@SPI("injection") | ||
public interface InjectExt { | ||
String echo(String msg); | ||
} |
60 changes: 60 additions & 0 deletions
60
...-common/src/test/java/org/apache/dubbo/common/extension/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,60 @@ | ||
/* | ||
* 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 org.apache.dubbo.common.extension.injection.impl; | ||
|
||
import org.apache.dubbo.common.extension.DisableInject; | ||
import org.apache.dubbo.common.extension.ext1.SimpleExt; | ||
import org.apache.dubbo.common.extension.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
...t/resources/META-INF/dubbo/internal/org.apache.dubbo.common.extension.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=org.apache.dubbo.common.extension.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