You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2011/01/12 17:00:46 UTC

[jira] Created: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
--------------------------------------------------------------------------------------------------------------

                 Key: AMQNET-306
                 URL: https://issues.apache.org/jira/browse/AMQNET-306
             Project: ActiveMQ .Net
          Issue Type: Improvement
          Components: ActiveMQ
    Affects Versions: 1.5.0
            Reporter: Timothy Bish
            Assignee: Timothy Bish
            Priority: Minor
             Fix For: 1.5.0


Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.

One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  

Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981562#action_12981562 ] 

Timothy Bish commented on AMQNET-306:
-------------------------------------

Already done.  Testing out all my changes now.

> Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-306
>                 URL: https://issues.apache.org/jira/browse/AMQNET-306
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ
>    Affects Versions: 1.5.0
>            Reporter: Timothy Bish
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.
> One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  
> Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Posted by "Mark Gellings (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981554#action_12981554 ] 

Mark Gellings commented on AMQNET-306:
--------------------------------------

You can append the word "Attribute" to the end of the class name.  So "public class NMSTransportFactoryAttribute : Attribute".

Then you can still use it as an attribute minus the word Attribute.  Like:

[NMSTransportFactory("tcp")]

 I think this is sort of the defacto convention.

> Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-306
>                 URL: https://issues.apache.org/jira/browse/AMQNET-306
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ
>    Affects Versions: 1.5.0
>            Reporter: Timothy Bish
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.
> One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  
> Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981785#action_12981785 ] 

Timothy Bish commented on AMQNET-306:
-------------------------------------

Changes are in trunk if anyone wants to review them.  I named the attribute ActiveMQTransportFactory so that I could avoid clashes with other NMS providers that might like to do something similar (Stomp for instance).

> Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-306
>                 URL: https://issues.apache.org/jira/browse/AMQNET-306
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ
>    Affects Versions: 1.5.0
>            Reporter: Timothy Bish
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.
> One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  
> Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980781#action_12980781 ] 

Jim Gomes commented on AMQNET-306:
----------------------------------

Another potential solution for the run-time reflection discovery option would be to add support for custom attributes that would mark a transport implementation function.  The following pseudo-code demonstrates what the implementation would look like:

{code:title=CustomTransport.cs|borderStyle=solid}
[NMSTransport("transportname")]
public void MyCustomTransport()
{
}
{code}

The transport factory loader could look for the custom {{NMSTransport}} attribute on member functions, and then match the named transport field to find the correct implementation to call.  This allows self-documenting code (the attribute declares its purpose), and lessens the dependency on function naming conventions.

> Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-306
>                 URL: https://issues.apache.org/jira/browse/AMQNET-306
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ
>    Affects Versions: 1.5.0
>            Reporter: Timothy Bish
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.
> One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  
> Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQNET-306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish resolved AMQNET-306.
---------------------------------

    Resolution: Fixed

Seems to be working without any issues.  

> Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-306
>                 URL: https://issues.apache.org/jira/browse/AMQNET-306
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ
>    Affects Versions: 1.5.0
>            Reporter: Timothy Bish
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.
> One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  
> Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQNET-306) Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980973#action_12980973 ] 

Timothy Bish commented on AMQNET-306:
-------------------------------------

I'd propose that we use the Attribute method but we should indicate that its a transport factory being marked as we need to use a factory still to create each transport since the factory can have a default constructor but the transport might not.

{code:title=NMSTransportFactory.cs|borderStyle=solid}

namespace Apache.NMS.ActiveMQ.Transport
{
    /// <summary>
    /// Attribute that decorates ITransportFactory implementations to allow
    /// the TransportFactory to find all the available factories dynamically.
    /// </summary>

    [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
    public class NMSTransportFactory : Attribute
    {
        private string scheme;
        private string description;

        public NMSTransportFactory(string scheme) : base()
        {
            this.scheme = scheme;
        }

        public string Description
        {
            get { return this.description; }
            set { this.description = value; }
        }
    }
}

{code}

Not sure I'm crazy about the name, can't think of anything better right now though.

{code:title=TcpTransportFactory.cs|borderStyle=solid}
[NMSTransportFactory("tcp")]
public class TcpTransportFactory : ITransportFactory
{
    ...
}
{code}


> Provide a means of adding new Transports to the TransportFactory either et runtime or via some other mechanism
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-306
>                 URL: https://issues.apache.org/jira/browse/AMQNET-306
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ
>    Affects Versions: 1.5.0
>            Reporter: Timothy Bish
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.0
>
>
> Currently the only way to add new Transports to the Apache.NMS.ActiveMQ.Transport.TransportFactory is to hard code the mapping between the uri scheme and the ITransportFactory that is used to create transports of the scheme type.  This makes it difficult to add new transports or to inject new ones in the tests library for instance.  It would be nice if there was a way to register new TransportFactory mappings or even better to have the TransportFactory dynamically discover them.
> One option is to just add a RegisterTransportFactory method that takes a scheme and the name or type of a class that can later be created when a new ConnectionFactory is instantiated.  
> Another options might be to embed the information needed to map a scheme to an ITransportFactory in the Resources of an assenbly and have the TransportFactory enumerate the loaded assembles to attempt to find that information.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.