New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CXF-7493] Add a default ClassUnwrapper for CDI integration. #313
Conversation
import org.apache.cxf.common.util.ClassUnwrapper; | ||
|
||
class CdiClassUnwrapper implements ClassUnwrapper { | ||
private static final List<String> UNWRAPPED_MARKERS = asList("OwbNormalScopeProxy", "WeldClientProxy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OWB has other suffixes, why not using $$ as in https://github.com/apache/meecrowave/blob/7bd58d4a254c0d40fb1a2ab0d19b24dbab4014ca/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java#L54 ? Would also handle TomEE proxies (EJB) BTW. Also any way it just gets merge with the default unwrapper? I don't see any reason to not have it out of the box since it doesn't depend on anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only seen the one suffix from OWB. Where can I find the list of suffixes? I saw what you did in TomEE, and I think using $$
could be problematic for non-CDI frameworks, so I wanted to explicitly list out the known suffixes.
I'm fine with putting something like this in core, and explicitly activating it in CDI, but would be concerned with being over eager with the swap out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For owb you need to check AbstractProxyFactory subclasses out, without more checking I had in mind $$OwbSubClass. In TomEE we also have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnament @rmannibucau Was going through this discussion (https://issues.jboss.org/browse/CDI-10), seems to be a known problem people struggle with. Not sure if it is better or not, what if we detect the CDI implementation at runtime (class probing) and delegate the unwrapping to the framework itself? F.e. in case of OWB, we could useNormalScopeProxyFactory.unwrapInstance(o)
, something similar should be available for Weld as well. Not ideal either, but more reliable may be? Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I don't think Weld has a behavior like unwrapInstance
but it could be done by us if its Weld. I also figured that checking by name would be easier since it avoid any compile time dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely the easiest / simplest way to do that, not sure how reliable it is though ... May be we could have some regex, like ^.+$$.+Proxy$
, the $$
usually depict a generated class, so we would cover Xxx$$OwbNormalScopeProxy
, Xxx$$WeldClientProxy
as well as Xxx$$LocalBeanProxy
like @rmannibucau pointed out as well. Should be pretty good heuristic, what do you think?
import org.apache.cxf.common.util.ClassUnwrapper; | ||
|
||
class CdiClassUnwrapper implements ClassUnwrapper { | ||
private static final Pattern PROXY_PATTERN = Pattern.compile(".+\\$\\$.+Proxy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reta @rmannibucau ok, this uses a pattern based on the discussion. Do we still want to move outside the CDI module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @johnament, I don't think it should be moved outside CDI integration, @rmannibucau any particular reasons to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep the reason is to ensure it is used by all integrations. Very few server uses cdi extension to comply to spec but all use proxies. Since the perf and behavior shouldnt hurt it can be added to the default IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi guys, but the problem is only showing itself on the CDI path ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. it has nothing to do with CDI actually except CDI uses proxies. It will happen each time a lib is using subclassing proxies, CDI is one big consumer but there are a lot of other ways to get it even in plain standalone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good plan, @sberyozkin are we good to merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear what the plan is, just leave it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Andriy, if all 3 of you are happy, then yes, please merge :-), I did not really contribute myself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnament Sorry, was not clear, I was referring to @sberyozkin suggestion for 2 stages, let us start from CDI first, and than make a decision if it worth going to core or not. Make sense?
@@ -63,6 +65,9 @@ public String getName() { | |||
@Override | |||
public ExtensionManagerBus create(final CreationalContext< ExtensionManagerBus > ctx) { | |||
final ExtensionManagerBus instance = injectionTarget.produce(ctx); | |||
if ("true".equals(SystemPropertyAction.getProperty("org.apache.cxf.cdi.useCdiUnwrapper", "true"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnament pretty minor, before merging could you please rename property org.apache.cxf.cdi.useCdiUnwrapper
to org.apache.cxf.cdi.unwrap.proxies
(or similar) so it kind of explains its purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
This is to avoid issues with proxies and class metadata.
Sure sounds good. Feel free to merge if good.
…On Sep 20, 2017 6:41 PM, "Andriy Redko" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In integration/cdi/src/main/java/org/apache/cxf/cdi/CdiClassUnwrapper.java
<#313 (comment)>:
> + *
+ * 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.cxf.cdi;
+
+import java.util.regex.Pattern;
+
+import org.apache.cxf.common.util.ClassUnwrapper;
+
+class CdiClassUnwrapper implements ClassUnwrapper {
+ private static final Pattern PROXY_PATTERN = Pattern.compile(".+\\$\\$.+Proxy");
@johnament <https://github.com/johnament> Sorry, was not clear, I was
referring to @sberyozkin <https://github.com/sberyozkin> suggestion for 2
stages, let us start from CDI first, and than make a decision if it worth
going to core or not. Make sense?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#313 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGmh5HMBhr0c0Q4hzG8G44zuxOsC72Cks5skZSDgaJpZM4Pau6x>
.
|
Thanks @johnament ! |
[CXF-7493] Add a default ClassUnwrapper for CDI integration.
[CXF-7493] Add a default ClassUnwrapper for CDI integration.
Ggrzybek alignment1
This is to avoid issues with proxies and class metadata.