You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Tom Mercelis <to...@gmail.com> on 2012/10/02 12:57:04 UTC

Re: Making custom NamespaceHandler

Hello,

So I can now make objects from XML, and use them as properties to
beans I'm constructing as in this example:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:st="http://pizzaonline.demo.org/xmlns/menus-0.2"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<bean class="org.demo.pizzaonline.api.OrderInterface">
		<property name="menuChoices">
			<menu xmlns="http://pizzaonline.demo.org/xmlns/menus-0.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<meals>
				<meal name="Pizza Tonno" description="Tomato basis with tuna and
cheese" price="9.5"/>
				<meal name="Pizza Quatro Fromagi" description="Four cheeses" price="8.5"/>
			</meals>
			</menu>
		</property>
	</bean>
</blueprint>

But is there a possibility to make the "menu" object a bean directly?
I'd like to make the "<menu>" a service, that can be referenced to by
other beans. But if I put the <menu> directly in a <service> or <bean>
tag, the XML parsing fails. In the example given aboven, it seems I
can build a wrapper around the objects build from XBean, but I wonder
wether it's possible to do without the wrapper.

Kind regards,

Tom Mercelis

2012/9/18 Tom Mercelis <to...@gmail.com>:
> I found a pretty good explanation on xbean-spring in this blog:
> http://www.christianposta.com/blog/?p=111
> I'm now trying it out but running into an xml validation exception and
> I'm not yet sure why.
>
> Kind regards,
>
> Tom Mercelis
>
> 2012/9/17 Johan Edstrom <se...@gmail.com>:
>> If you want simpler NSHandlers I'd look at the cxf code.
>> Tons of little ones in there that should be pretty self explanatory.
>>
>> /je
>>
>> On Sep 17, 2012, at 10:42 AM, David Jencks <da...@yahoo.com> wrote:
>>
>>> I poked around a little bit for xbean-spring but couldn't find any real documentation there either.  I thought there used to be a fairly good explanation of how it works.  You use the xbean-spring maven plugin for both xbean-spring and xbean-blueprint.
>>>
>>> You javadoc-annotate your classes and properties and bean references and the xbean-spring maven plugin/ant task generates the schema and property files to describe the components and mapping between the components and the blueprint data structures.  At runtime the xbean-spring namespace handler uses the property files to map the xml plan elements following the schema to the internal blueprint data structures.
>>>
>>> I think the examples to look at are probably the xbean-blueprint tests, activemq, and servicemix.  Hopefully by following along from annotations to property files to blueprint components you will see how to use it.
>>>
>>> Source code is still in xbean at e.g. https://svn.apache.org/repos/asf/geronimo/xbean/tags/xbean-3.9 (no source modifications after this, although there are 3 more releases of xbean).
>>>
>>> hope this helps, wish I had more time :-/
>>> david jencks
>>>
>>> On Sep 17, 2012, at 1:44 AM, Tom Mercelis wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm trying to find "xbean-blueprint"; but besides dozens of sites
>>>> which offer browsing the sourcecode, the only "homepage" seems to be
>>>> http://geronimo.apache.org/xbean/ and it seems terribly outdated (it
>>>> mentions version 2.8 from 2007 as the latest version)... did the
>>>> project move? What's the new official location?
>>>>
>>>> Kind regards,
>>>>
>>>> Tom Mercelis
>>>>
>>>> 2012/9/14 David Jencks <da...@yahoo.com>:
>>>>> xbean-blueprint works fine and is a lot newer than 2007....  I really recommend using it rather than trying to rewrite the functionality.
>>>>>
>>>>> If you deploy the xbean-blueprint bundle and imitate activemq you should be able to get it to work.  Sorry about the lack of docs....
>>>>>
>>>>> You might try looking at what happens during the activemq build with the maven plugin that generates the required property files from the javaodc "annotations" and how those are used by xbean-blueprint.
>>>>>
>>>>> david jencks
>>>>>
>>>>>
>>>>> On Sep 14, 2012, at 9:09 AM, Tom Mercelis wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I wanted to be able to configure my bean with XML, like ActiveMQ
>>>>>> brokers can be configured in a blueprint XML file.
>>>>>> So far I got my "NamespaceHandler" registered and the parse method is
>>>>>> called on it when blueprint reads my .xml file in Karaf's deploy
>>>>>> folder.
>>>>>> But now I'm lost at what to do next? Am I supposed to instantiate new
>>>>>> objects in the parse function and register them in the osgi container?
>>>>>> I have no clue what to put in the "Metadata" return object and how it
>>>>>> will be processed by blueprint.
>>>>>>
>>>>>> I was inspired to try it this way based on this article:
>>>>>> http://www.tips4java.com/osgiextending-blueprint-with-namespaces/
>>>>>>
>>>>>> The example given there doesn't quite seem to cover what blueprint
>>>>>> does, so I also started looking into the blueprint source to find out
>>>>>> what is done with the (Component)Metadata that is returned from the
>>>>>> parse method.
>>>>>>
>>>>>> Not really getting it, I also tried to figure out how ActiveMQ does
>>>>>> it. ActiveMQ seems not to implement the NamespaceHandler itself, but
>>>>>> relies on "XBean", but that seems really underdocumented and the last
>>>>>> release dates back from 2007... so I wonder whether that's the way to
>>>>>> go.
>>>>>>
>>>>>> Is there anyone who can give me (point me to) an explanation on how to
>>>>>> implement a NamespaceHandler. My goal isn't too complex: I just want
>>>>>> to create a bean with a list of records instead of just key-value
>>>>>> pairs as one can do with blueprint out-of-the-box.
>>>>>>
>>>>>> Kind regards,
>>>>>>
>>>>>> Tom Mercelis
>>>>>
>>>
>>