[wildfly-dev] Custom wildfly subsystem deployer

Dejan Kitic kdejan at gmail.com
Thu Nov 21 09:28:40 EST 2013


Hi Ales,

Thanks for reply, I ll try to elaborate bit more. Simple example of what I
am trying to do (besides figuring out how it all works together) is this:
I am trying to create custom subsystem with deployment processor that will
pick up any ear or war deployed, if that deployment contains say class A
with let say my own annotation @SomeServiceContext on attribute SomeService
someService, it will create instance of class SomeService for that
deployment. Idea then is when this class A is instantiated I want the
attribute someService to be initialized with  SomeService class created for
this deploymen.
More less this might be viewed as very simple implementation of my own
injection, reason is purely learning, I am aware that Weld does all this
for us already. This is more along the lines - figure out how weld does it
in the wildfly.

>From the examples that I have followed, I am able to create subsystem, and
detect if deployment contains my annotation. What I was trying to ask is
what would be the best way to proceed from here, few options that came to
my mind are:

 1. Service in my subsystem might bind SomeService for this deployment into
jndi, and I could use weld extensions to process classes with my
@SomeServiceContext        annotation to inject correct value of
SomeService prepared for that deployment during deploy of the application

or

2. More complicated option, might be to somehow modify the bytecode of the
class A, for example append as last line of default constructor of class A
code that will set the      attribute SomeService someService to the value
that service in my subsystem created for this deployment.



Option 2 is far more complicated and interesting to me, as from my naive
thinking this might be similar even to how weld is implemented, find all
annotated classes, and modify the their bytecode to inject correct values
when they are instantiated, combined with wildfly subsystem and deployers.


Regards,
Dejan









On Thu, Nov 21, 2013 at 1:59 PM, Ales Justin <ales.justin at gmail.com> wrote:

> What exactly are you trying to do -- a bit confusing description?
> Or, from what I can understand, a simple ClassFileTransformer could do the
> trick for you.
>
> -Ales
>
> On 20 Nov 2013, at 15:59, Dejan Kitic <kdejan at gmail.com> wrote:
>
> Hi,
>
> First of all my apologies, if I am asking the question in wrong place,
> though my gut feeling tells me that people on this list would know the most
> about this matter.
>
> I am trying to write my own subsystem, and have wrote most of it, using
> https://docs.jboss.org/author/display/AS72/Extending+JBoss+AS+7 and maven
> archtype there.
>
> I have my own annotation, which user can add onto the attribute of EJB or
> CDI bean, and deployment processor for my subsystem finds all classes with
> this annotation.
> From my understanding inside deployment processor executed during
> Phase.PARSE, getAttachment(Attachments.ANNOTATION_INDEX) will enable me to
> find all classes with my annotation, without loading the classes (jandex).
>
> After finding them all, I am trying to modify the class to inject instance
> to that annotated field with value that has been created in my subsystem
> for that deployment.
>
> I think options are to rely on Weld, or modify bytecode to set this field
> with my value stored in my subsystem when class is instantiated.
> If I change phase
>
> Am I going in the right direction with this, what would be recommended way
> to do something like this?  Any pointers would be welcome.
>
> Regards,
> Dejan
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
>
>
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/wildfly-dev/attachments/20131121/319e6a1f/attachment-0001.html 


More information about the wildfly-dev mailing list