You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Aaron Mulder (JIRA)" <ji...@apache.org> on 2010/11/11 22:53:24 UTC

[jira] Created: (CAMEL-3331) Support URI inline strings as resources

Support URI inline strings as resources
---------------------------------------

                 Key: CAMEL-3331
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
             Project: Apache Camel
          Issue Type: Improvement
          Components: camel-core
    Affects Versions: 2.5.0
            Reporter: Aaron Mulder
            Priority: Minor


This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.

The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.

I'm looking for something like this:

<to uri="xslt:string:<xsl:transform ... >" />

In practice you need to turn < and > into &lt; and &gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63288#action_63288 ] 

Claus Ibsen commented on CAMEL-3331:
------------------------------------

And having a XSLT template which tend to get big and contains a lot of XML elements, which you then need to escape just complicates matters.

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Updated: (CAMEL-3331) Support URI inline strings as resources

Posted by "Aaron Mulder (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Mulder updated CAMEL-3331:
--------------------------------

    Description: 
This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.

The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.

I'm looking for something like this:

<to uri="xslt:string:<xsl:transform ... >" />

In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

  was:
This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.

The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.

I'm looking for something like this:

<to uri="xslt:string:<xsl:transform ... >" />

In practice you need to turn < and > into &lt; and &gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI


> Support URI inline strings as resources
> ---------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Updated: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3331:
-------------------------------

    Summary: xslt component - Support URI inline strings as resources  (was: Support URI inline strings as resources)

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Hadrian Zbarcea (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63321#action_63321 ] 

Hadrian Zbarcea commented on CAMEL-3331:
----------------------------------------

@Mark. I agree.

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63289#action_63289 ] 

Claus Ibsen commented on CAMEL-3331:
------------------------------------

We could also introduce a ref so you can look a bean in the registry to use as the template

{code}
bean id="xxx" class="com.foo.MyTemplate">

<to uri="xstl:ref:xxx"/>
{code}


> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Aaron Mulder (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63284#action_63284 ] 

Aaron Mulder commented on CAMEL-3331:
-------------------------------------

That would be another option.

FWIW, it seemed to be agreed on IRC that it would be a good idea to support inline strings in the default ResourceLoader for all components.

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Updated: (CAMEL-3331) Support URI inline strings as resources

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3331:
-------------------------------

      Component/s:     (was: camel-core)
                   camel-spring
    Fix Version/s: Future
       Issue Type: New Feature  (was: Improvement)

> Support URI inline strings as resources
> ---------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63287#action_63287 ] 

Claus Ibsen commented on CAMEL-3331:
------------------------------------

Its best to make the components behave the same and have similar options/features.

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Aaron Mulder (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63318#action_63318 ] 

Aaron Mulder commented on CAMEL-3331:
-------------------------------------

To give more background:

In this system the user does things in the UI, and as a result, Camel routes are generated automatically and executed.  As well, there's a strong preference for avoiding any files on disk.  But also, writing beans would be best avoided since it invokes a compile phase (unless the bean is specifically built beforehand and added to a generic "bean library" that can be called on four the routes).  So when the user clicks a button, the app assembles a Camel Spring XML in memory and loads it.

Since it's all automated, it's not so onerous to put an escaped XSL into a URI even though it looks a little ugly when done by hand.  It may desirable to do that for other things too, it's just that XSLT is the first we've come across so far.

It would be possible to instead construct the route with a setHeader(constant(XSLT)) type arrangement, but we'd also need to change the URI processing for the XSLT component for it to read an XSL out of a header, right?  And then you'd probably want to clear that header to avoid propagating that header to your outbound endpoint.  Plus, that solves it only for the one component, whereas the proposal to accept inline strings in the URI would be more generally applicable.

It would be possible to create a bean where you you just paste the XSLT into a property in the bean definition and it spits it back when its method is invoked.  But if you're going to be changing the URI processing anyway (to support beans), why make it the case that the user always has to write some code (the bean) in order to take advantage of it?  Instead of just letting them put the configuration data right there in the URI.

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) xslt component - Support URI inline strings as resources

Posted by "Mark Ford (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63319#action_63319 ] 

Mark Ford commented on CAMEL-3331:
----------------------------------

I can't imagine anyone configuring the xslt endpoint with the template embedded (and escaped) within the endpoint URI. I understand your use case where you're dynamically constructing the spring config. As a result it's trivial to embed the escaped values with code. However, this is not something you'd see in practice in other use cases.

My preference would be for a feature that worked well in both environments. I think the Dynamic templates from Velocity is a reasonable approach. Supporting a reference would also be good. 

> xslt component - Support URI inline strings as resources
> --------------------------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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


[jira] Commented: (CAMEL-3331) Support URI inline strings as resources

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=63278#action_63278 ] 

Claus Ibsen commented on CAMEL-3331:
------------------------------------

It would be better if you can provide the template in a header, like what velocity can do.

See section _Dynamic templates_
http://camel.apache.org/velocity

> Support URI inline strings as resources
> ---------------------------------------
>
>                 Key: CAMEL-3331
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3331
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-spring
>    Affects Versions: 2.5.0
>            Reporter: Aaron Mulder
>            Priority: Minor
>             Fix For: Future
>
>
> This came up for an application where it's inconvenient to access the filesystem and desirable to embed as much as possible in the Camel routes.  In particular, to write an inline XSLT sheet instead of referring to an external one.
> The XsltComponent (among many others) uses a Spring ResourceLoader to load resources, and while it supports things like classpath: or file: or http: there's no way to cause it to just read the rest of the URI and make that a String and use it as the resource.
> I'm looking for something like this:
> <to uri="xslt:string:<xsl:transform ... >" />
> In practice you need to turn < and > into & lt; and & gt; and do something with ? (to avoid problems when it looks for ?option=value), but stuff like that aside, it appears to work to extend DefaultResourceLoader to use a ByteArrayResource based on the remainder of the URI

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