Metro 2.0 and tubes

View: New views
13 Messages — Rating Filter:   Alert me  

Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Now that Metro 2.0 has been released is it possible if one of the devs can do an example of using the "highly pluggable framework" Tube?  The javadoc isn't very clear on how you go about plugging in a Tube implementation.
[Message sent by forum member 'ruroshin' (ruroshin)]

http://forums.java.net/jive/thread.jspa?messageID=353671

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yeah! Especially considering the fact that the tubes we wrote for Metro 1.5 don't work at all under 2.0.
[Message sent by forum member 'rustamabd' (rustamabd)]

http://forums.java.net/jive/thread.jspa?messageID=353740

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I too would like to see such an example so I can understand what is possible to do with a tube and how to take advantage of this feature.
[Message sent by forum member 'joe_roberts_z' (joe_roberts_z)]

http://forums.java.net/jive/thread.jspa?messageID=353747

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Pluggability of Tubes has been there from the beginning of JAX-WS 2.1.
The new feature in Metro 2.0 is the declarative Tube line assembly. You can find more about it at http://wikis.glassfish.org/metro/Wiki.jsp?page=DeclarativeTubelineAssemblerOnePager
[Message sent by forum member 'ramapulavarthi' (ramapulavarthi)]

http://forums.java.net/jive/thread.jspa?messageID=353804

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am interested to know what functionality of Tubes is broken from Metro 1.5 to Metro 2.0. Can you shed some details.
[Message sent by forum member 'ramapulavarthi' (ramapulavarthi)]

http://forums.java.net/jive/thread.jspa?messageID=353805

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tubes offer more flexibility and access to RI specific API.
You can find more about it in the blog entry http://weblogs.java.net/blog/jitu/archive/2007/02/tubes_in_jaxws.html

If you are using handlers approach, you could use Message Handlers as described in http://weblogs.java.net/blog/ramapulavarthi/archive/2007/12/extend_your_web.html
But handlers come after the message is processed by different layers like security etc. With Tubes you have more flexibility on where they get executed etc.
[Message sent by forum member 'ramapulavarthi' (ramapulavarthi)]

http://forums.java.net/jive/thread.jspa?messageID=353806

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ramapulavarthi, your blog shows the old way of plugging the tubes and in fact I could not get it to work that way with Metro 2.0.

Anyway, after looking at the wiki and checking out some of the existing metro tubes I've managed to get it working.  

Here's the basic for anybody else that's interested.

1.  Create your tube, extending com.sun.xml.ws.api.pipe.helper.AbstractFilterTubeImpl is probably easiest.  e.g.

public class MyTube extends AbstractFilterTubeImpl {

    MyTube(Tube next) {
        super(next);
    }

    MyTube(MyTube that, TubeCloner cloner) {
        super(that, cloner);
    }

    @Override
    public NextAction processRequest(Packet packet) {
         // do something with the request
        return super.processRequest(packet);
    }

    @Override
    public NextAction processResponse(Packet packet) {
        // do something with the response        
        return super.processResponse(packet);
    }    

    @Override
    public MyTube copy(TubeCloner cloner) {
        return new MyTube(this, cloner);
    }
}

2.  Create an implementation of TubeFactory.  For the Server tubeline you need to get the Terminal tube and not the Tubeline Head as I did originally which created strange result, such as the request message being returned as the response message.

public class CustomTubeFactory implements TubeFactory {

    public Tube createTube(ClientTubelineAssemblyContext context) throws WebServiceException {        
        return new MyTube(context.getTubelineHead());            
    }

    public Tube createTube(ServerTubelineAssemblyContext context) throws WebServiceException {        
        return new MyTube(context.getTerminalTube());
    }
}

3.  Create a metro.xml file and place in META-INF directory. You can put your TubeFactory implementation in client-side, endpoint-side or both.

<?xml version="1.0" encoding="UTF-8"?>
<metro  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://java.sun.com/xml/ns/metro/config' version="1.0">
    <tubelines default="#test-tubline">
        <tubeline name="test-tubeline">
        <client-side>
        <tube-factory className="test.CustomTubeFactory" />
        </client-side>
          <endpoint-side>
             <tube-factory className="test.CustomTubeFactory" />
          </endpoint-side>
        </tubeline>
    </tubelines>
</metro>

thats it.
[Message sent by forum member 'ruroshin' (ruroshin)]

http://forums.java.net/jive/thread.jspa?messageID=354299

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by Potociar Marek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 7.7.2009, at 5:11, metro@... wrote:

> 3.  Create a metro.xml file and place in META-INF directory. You can  
> put your TubeFactory implementation in client-side, endpoint-side or  
> both.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <metro  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://java.sun.com/xml/ns/metro/config' 
>  version="1.0">
>    <tubelines default="#test-tubline">
>        <tubeline name="test-tubeline">
>         <client-side>
>         <tube-factory className="test.CustomTubeFactory" />
>         </client-side>
>          <endpoint-side>
>             <tube-factory className="test.CustomTubeFactory" />
>          </endpoint-side>
>        </tubeline>
>    </tubelines>
> </metro>
>
> thats it.

There are two things you need to be aware of with this last step:

1. metro.xml and its content is not a public API yet and I can almost  
100% guarantee that at least the file name will be changed in the  
future. The reason is that we plan to consolidate all our  
configuration files into a single one in one of the next releases  
after Metro 2.0. We may also want to introduce relative positioning of  
tubes in a tubeline as well.

2. With the tubeline definition above you are excluding all Metro  
tubes from the tubeline ( => no validation, no WS-* feature  
support ... ). The only tube in the tubeline will be your CustomTube.  
If you wanted just to add your custom tube to the existing default  
Metro tubeline definition (say, after WS-Addressing tube), you would  
have to copy the default definition[1] and insert your tube factory at  
any place in the tubeline you want it to have, like this:

<metro  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns='http://java.sun.com/xml/ns/metro/config'
    version="1.0">
     <tubelines default="#test-tubline">
         <tubeline name="test-tubline">
             <client-side>
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.TerminalTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.HandlerTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.ValidationTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.MustUnderstandTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.MonitoringTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.AddressingTubeFactory" />

                 <tube-factory className="test.CustomTubeFactory" />

                 <tube-factory  
className="com.sun.xml.ws.tx.runtime.TxTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.rx.rm.runtime.RmTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.rx.mc.runtime.McTubeFactory" />
                 <tube-factory  
className="com.sun.xml.wss.provider.wsit.SecurityTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.rx.testing.PacketFilteringTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.dump.MessageDumpingTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.TransportTubeFactory" />
             </client-side>
             <endpoint-side>
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.TransportTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.dump.MessageDumpingTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.rx.testing.PacketFilteringTubeFactory" />
                 <tube-factory  
className="com.sun.xml.wss.provider.wsit.SecurityTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.rx.mc.runtime.McTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.AddressingTubeFactory" />

                 <tube-factory className="test.CustomTubeFactory" />

                 <tube-factory  
className="com.sun.xml.ws.rx.rm.runtime.RmTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.tx.runtime.TxTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.MonitoringTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.MustUnderstandTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.HandlerTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.ValidationTubeFactory" />
                 <tube-factory  
className="com.sun.xml.ws.assembler.jaxws.TerminalTubeFactory" />
             </endpoint-side>
         </tubeline>
     </tubelines>
</metro>

Btw. in case you are interested in the full format of metro.xml,  
here's the current XSD schema with some documentation:

https://wsit.dev.java.net/source/browse/wsit/wsit/etc/schemas/config/metro.xsd?view=markup

Thanks,
Marek

[1] located in https://wsit.dev.java.net/source/browse/*checkout*/wsit/wsit/etc/META-INF/metro-default.xml?content-type=text%2Fplain

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for that  Potociar.  

Actually its interesting that you say the Metro tubes will not get added if I don't place them in the custom metro.xml as that exactly what I did on my first time.  

I copied all the default Metro tubes into my metro.xml file and I got an error from one of the Metro Tubes during startup saying something about it already initialised.  This seems to indicate to me that the default metro.xml file loaded up the Metro tubes then it tried to load them up again in my metro.xml file.

I also confirmed this by having my metro.xml file containing only my custom tube then see if the MessageDumpingTube still worked as this was the easiest one to visually see.  It did work, so even if I leave them out of my custom tube it still seems to pick it up from the default metro.xml?
[Message sent by forum member 'ruroshin' (ruroshin)]

http://forums.java.net/jive/thread.jspa?messageID=356164

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by Potociar Marek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
what you describe is very interesting and certainly it should not work  
that way :) Could you please open a new issue on wsit.dev.java.net and  
if possible, attach to it a reproducible unit test (or an application  
that, when deployed, confirms the behavior you are describing) so that  
I can have a closer look at it? If there is an issue it needs to be  
fixed.

Many thanks in advance,
Marek


On 17.7.2009, at 4:56, metro@... wrote:

> Thanks for that  Potociar.
>
> Actually its interesting that you say the Metro tubes will not get  
> added if I don't place them in the custom metro.xml as that exactly  
> what I did on my first time.
>
> I copied all the default Metro tubes into my metro.xml file and I  
> got an error from one of the Metro Tubes during startup saying  
> something about it already initialised.  This seems to indicate to  
> me that the default metro.xml file loaded up the Metro tubes then it  
> tried to load them up again in my metro.xml file.
>
> I also confirmed this by having my metro.xml file containing only my  
> custom tube then see if the MessageDumpingTube still worked as this  
> was the easiest one to visually see.  It did work, so even if I  
> leave them out of my custom tube it still seems to pick it up from  
> the default metro.xml?
> [Message sent by forum member 'ruroshin' (ruroshin)]
>
> http://forums.java.net/jive/thread.jspa?messageID=356164
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello
I tried to create the tube and deploy an application on Glassfish 2.1. I installed metro 2.1 on it, so metro jars are placed in AS_HOME/lib directory.

But now I have a problem. My tube factory cannot be loaded. JAXWS tube line assembler is created before the app is deployed. And tube factory has another classloader (metro classes are loaded by the parent one). So I'm getting 'Unable to load tube factory class ' message within the runtime exception.

How can it be fixed?
[Message sent by forum member 'mazur_roman' ]

http://forums.java.net/jive/thread.jspa?messageID=371950

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by Potociar Marek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
creating multiple threads that describe the same problem does not help  
to resolve the issue :) Please, follow the instructions in my recent  
post to your other thread.

Thanks,
Marek

On 16.11.2009, at 12:27, metro@... wrote:

> Hello
> I tried to create the tube and deploy an application on Glassfish  
> 2.1. I installed metro 2.1 on it, so metro jars are placed in  
> AS_HOME/lib directory.
>
> But now I have a problem. My tube factory cannot be loaded. JAXWS  
> tube line assembler is created before the app is deployed. And tube  
> factory has another classloader (metro classes are loaded by the  
> parent one). So I'm getting 'Unable to load tube factory class '  
> message within the runtime exception.
>
> How can it be fixed?
> [Message sent by forum member 'mazur_roman' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=371950
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Metro 2.0 and tubes

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry for my flood. That was just a panic :).
Everyone interested can reffer to http://forums.java.net/jive/thread.jspa?threadID=69382&tstart=0
[Message sent by forum member 'mazur_roman' ]

http://forums.java.net/jive/thread.jspa?messageID=372000

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...