You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Alejandro Scandroli <al...@gmail.com> on 2007/10/22 20:50:06 UTC

constructor-based injection

Hi

I need to do some constructor-based injection and I can't find the way.
I need to create an instance of
org.apache.tapestry.util.ComponentAddress, the constructor takes 2
Strings as parameters.
I know it should be simple but I'm lost.

Alejandro.

Re: constructor-based injection

Posted by Kalle Korhonen <ka...@gmail.com>.
The original hivemind documentation describes constructor-based injection
fairly well:
http://hivemind.apache.org/hivemind1/hivemind/BuilderFactory.html

Also, this post is about the same subject:
http://mail-archives.apache.org/mod_mbox/hivemind-user/200506.mbox/%3C200506221538.j5MFcqJr014219@carmanconsulting.com%3E

Kalle

On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
>
> Hi
>
> I need to do some constructor-based injection and I can't find the way.
> I need to create an instance of
> org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> Strings as parameters.
> I know it should be simple but I'm lost.
>
> Alejandro.
>

Re: constructor-based injection

Posted by Alejandro Scandroli <al...@gmail.com>.
Hi James

Yes in deed, I'm hivemindizing the editorSerivce (the editors
registration piece), to allow new modules to contribute new editors
using the "pluginnable" HiveMind magic.
I'm also trying to avoid spring dependencies as much as I can.
I will try to create a "rule" and I will let you know how it goes.

Saludos.
Alejandro.

On 10/23/07, James Carman <ja...@carmanconsulting.com> wrote:
> I figured this had something to do with Trails (not many other folks
> use ComponentAddresses).  Are you hivemindizing the editors
> registration piece?  I wanted to do that long ago.  In this case, you
> could probably just define your own "rule" in HiveMind to process the
> "editor" element into a ComponentAddress which can be added to your
> map.  I would also put a unique="true" on the "key" attribute so that
> you don't get two editors defined by folks with the same name.
>
> On 10/23/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > Hi
> >
> > I made it work using a contribution point and a EditorContribution class:
> >
> >         <configuration-point id="Editors" occurs="1..n">
> >                 <schema>
> >                         <element name="editor">
> >                                 <attribute name="key"/>
> >                                 <attribute name="container" required="true"/>
> >                                 <attribute name="component" required="true"/>
> >                                 <conversion class="org.amneris.trails.EditorContribution"/>
> >                         </element>
> >                 </schema>
> >         </configuration-point>
> >
> > Then creating the ComponentAddress entry on initialization
> >
> >         public void initialize()
> >         {
> >                 for (EditorContribution editorContribution : contributions)
> >                 {
> >                         getEditorMap().put(editorContribution.getKey(), new
> > ComponentAddress(editorContribution.getContainer(),
> > editorContribution.getComponent()));
> >                 }
> >         }
> >
> > Is there any way to create the ComponentAddress directly on HiveMind?
> > I still can't find how to use constructor parameters.
> >
> > Alejandro.
> >
> >
> > On 10/23/07, James Carman <ja...@carmanconsulting.com> wrote:
> > > I would probably handle that via a configuration point in HiveMind.
> > >
> > > On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > > > Hi James
> > > >
> > > > I'm trying to migrate some Spring code to Hivemind.
> > > > I need to create a Map<String , ComponentAddress> in the Hivemind registry.
> > > > This is what it looks like on spring:
> > > >
> > > >         <bean id="viewerService" class="org.trails.descriptor.EditorBlockFinder">
> > > >                 <property name="defaultBlockAddress">
> > > >                         <bean class="org.apache.tapestry.util.ComponentAddress">
> > > >                                 <constructor-arg index="0">
> > > >                                         <value>trails:Viewers</value>
> > > >                                 </constructor-arg>
> > > >                                 <constructor-arg index="1">
> > > >                                         <value>stringViewer</value>
> > > >                                 </constructor-arg>
> > > >                         </bean>
> > > >                 </property>
> > > >                 <property name="editorMap">
> > > >                         <map>
> > > >                                 <entry>
> > > >                                         <key>
> > > >                                                 <value>hidden</value>
> > > >                                         </key>
> > > >                                         <bean class="org.apache.tapestry.util.ComponentAddress">
> > > >                                                 <constructor-arg index="0">
> > > >                                                         <value>trails:Viewers</value>
> > > >                                                 </constructor-arg>
> > > >                                                 <constructor-arg index="1">
> > > >                                                         <value>hidden</value>
> > > >                                                 </constructor-arg>
> > > >                                         </bean>
> > > >                                 </entry>
> > > >                         </map>
> > > >                 </property>
> > > >         </bean>
> > > >
> > > > Alejandro.
> > > >
> > > > On 10/22/07, James Carman <ja...@carmanconsulting.com> wrote:
> > > > > A ComponentAddress, in Tapestry, isn't really a "service", though.
> > > > > Why would you want to put this type of object in your HiveMind
> > > > > registry?  I can see it being part of a configuration, but not
> > > > > necessarily a service.  What exactly are you trying to do?
> > > > >
> > > > > On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > > > > > Hi
> > > > > >
> > > > > > I need to do some constructor-based injection and I can't find the way.
> > > > > > I need to create an instance of
> > > > > > org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> > > > > > Strings as parameters.
> > > > > > I know it should be simple but I'm lost.
> > > > > >
> > > > > > Alejandro.
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: constructor-based injection

Posted by James Carman <ja...@carmanconsulting.com>.
I figured this had something to do with Trails (not many other folks
use ComponentAddresses).  Are you hivemindizing the editors
registration piece?  I wanted to do that long ago.  In this case, you
could probably just define your own "rule" in HiveMind to process the
"editor" element into a ComponentAddress which can be added to your
map.  I would also put a unique="true" on the "key" attribute so that
you don't get two editors defined by folks with the same name.

On 10/23/07, Alejandro Scandroli <al...@gmail.com> wrote:
> Hi
>
> I made it work using a contribution point and a EditorContribution class:
>
>         <configuration-point id="Editors" occurs="1..n">
>                 <schema>
>                         <element name="editor">
>                                 <attribute name="key"/>
>                                 <attribute name="container" required="true"/>
>                                 <attribute name="component" required="true"/>
>                                 <conversion class="org.amneris.trails.EditorContribution"/>
>                         </element>
>                 </schema>
>         </configuration-point>
>
> Then creating the ComponentAddress entry on initialization
>
>         public void initialize()
>         {
>                 for (EditorContribution editorContribution : contributions)
>                 {
>                         getEditorMap().put(editorContribution.getKey(), new
> ComponentAddress(editorContribution.getContainer(),
> editorContribution.getComponent()));
>                 }
>         }
>
> Is there any way to create the ComponentAddress directly on HiveMind?
> I still can't find how to use constructor parameters.
>
> Alejandro.
>
>
> On 10/23/07, James Carman <ja...@carmanconsulting.com> wrote:
> > I would probably handle that via a configuration point in HiveMind.
> >
> > On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > > Hi James
> > >
> > > I'm trying to migrate some Spring code to Hivemind.
> > > I need to create a Map<String , ComponentAddress> in the Hivemind registry.
> > > This is what it looks like on spring:
> > >
> > >         <bean id="viewerService" class="org.trails.descriptor.EditorBlockFinder">
> > >                 <property name="defaultBlockAddress">
> > >                         <bean class="org.apache.tapestry.util.ComponentAddress">
> > >                                 <constructor-arg index="0">
> > >                                         <value>trails:Viewers</value>
> > >                                 </constructor-arg>
> > >                                 <constructor-arg index="1">
> > >                                         <value>stringViewer</value>
> > >                                 </constructor-arg>
> > >                         </bean>
> > >                 </property>
> > >                 <property name="editorMap">
> > >                         <map>
> > >                                 <entry>
> > >                                         <key>
> > >                                                 <value>hidden</value>
> > >                                         </key>
> > >                                         <bean class="org.apache.tapestry.util.ComponentAddress">
> > >                                                 <constructor-arg index="0">
> > >                                                         <value>trails:Viewers</value>
> > >                                                 </constructor-arg>
> > >                                                 <constructor-arg index="1">
> > >                                                         <value>hidden</value>
> > >                                                 </constructor-arg>
> > >                                         </bean>
> > >                                 </entry>
> > >                         </map>
> > >                 </property>
> > >         </bean>
> > >
> > > Alejandro.
> > >
> > > On 10/22/07, James Carman <ja...@carmanconsulting.com> wrote:
> > > > A ComponentAddress, in Tapestry, isn't really a "service", though.
> > > > Why would you want to put this type of object in your HiveMind
> > > > registry?  I can see it being part of a configuration, but not
> > > > necessarily a service.  What exactly are you trying to do?
> > > >
> > > > On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > > > > Hi
> > > > >
> > > > > I need to do some constructor-based injection and I can't find the way.
> > > > > I need to create an instance of
> > > > > org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> > > > > Strings as parameters.
> > > > > I know it should be simple but I'm lost.
> > > > >
> > > > > Alejandro.
> > > > >
> > > >
> > >
> >
>

Re: constructor-based injection

Posted by Alejandro Scandroli <al...@gmail.com>.
Hi

I made it work using a contribution point and a EditorContribution class:

	<configuration-point id="Editors" occurs="1..n">
		<schema>
			<element name="editor">
				<attribute name="key"/>
				<attribute name="container" required="true"/>
				<attribute name="component" required="true"/>
				<conversion class="org.amneris.trails.EditorContribution"/>
			</element>
		</schema>
	</configuration-point>

Then creating the ComponentAddress entry on initialization

	public void initialize()
	{
		for (EditorContribution editorContribution : contributions)
		{
			getEditorMap().put(editorContribution.getKey(), new
ComponentAddress(editorContribution.getContainer(),
editorContribution.getComponent()));
		}
	}

Is there any way to create the ComponentAddress directly on HiveMind?
I still can't find how to use constructor parameters.

Alejandro.


On 10/23/07, James Carman <ja...@carmanconsulting.com> wrote:
> I would probably handle that via a configuration point in HiveMind.
>
> On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > Hi James
> >
> > I'm trying to migrate some Spring code to Hivemind.
> > I need to create a Map<String , ComponentAddress> in the Hivemind registry.
> > This is what it looks like on spring:
> >
> >         <bean id="viewerService" class="org.trails.descriptor.EditorBlockFinder">
> >                 <property name="defaultBlockAddress">
> >                         <bean class="org.apache.tapestry.util.ComponentAddress">
> >                                 <constructor-arg index="0">
> >                                         <value>trails:Viewers</value>
> >                                 </constructor-arg>
> >                                 <constructor-arg index="1">
> >                                         <value>stringViewer</value>
> >                                 </constructor-arg>
> >                         </bean>
> >                 </property>
> >                 <property name="editorMap">
> >                         <map>
> >                                 <entry>
> >                                         <key>
> >                                                 <value>hidden</value>
> >                                         </key>
> >                                         <bean class="org.apache.tapestry.util.ComponentAddress">
> >                                                 <constructor-arg index="0">
> >                                                         <value>trails:Viewers</value>
> >                                                 </constructor-arg>
> >                                                 <constructor-arg index="1">
> >                                                         <value>hidden</value>
> >                                                 </constructor-arg>
> >                                         </bean>
> >                                 </entry>
> >                         </map>
> >                 </property>
> >         </bean>
> >
> > Alejandro.
> >
> > On 10/22/07, James Carman <ja...@carmanconsulting.com> wrote:
> > > A ComponentAddress, in Tapestry, isn't really a "service", though.
> > > Why would you want to put this type of object in your HiveMind
> > > registry?  I can see it being part of a configuration, but not
> > > necessarily a service.  What exactly are you trying to do?
> > >
> > > On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > > > Hi
> > > >
> > > > I need to do some constructor-based injection and I can't find the way.
> > > > I need to create an instance of
> > > > org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> > > > Strings as parameters.
> > > > I know it should be simple but I'm lost.
> > > >
> > > > Alejandro.
> > > >
> > >
> >
>

Re: constructor-based injection

Posted by James Carman <ja...@carmanconsulting.com>.
I would probably handle that via a configuration point in HiveMind.

On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> Hi James
>
> I'm trying to migrate some Spring code to Hivemind.
> I need to create a Map<String , ComponentAddress> in the Hivemind registry.
> This is what it looks like on spring:
>
>         <bean id="viewerService" class="org.trails.descriptor.EditorBlockFinder">
>                 <property name="defaultBlockAddress">
>                         <bean class="org.apache.tapestry.util.ComponentAddress">
>                                 <constructor-arg index="0">
>                                         <value>trails:Viewers</value>
>                                 </constructor-arg>
>                                 <constructor-arg index="1">
>                                         <value>stringViewer</value>
>                                 </constructor-arg>
>                         </bean>
>                 </property>
>                 <property name="editorMap">
>                         <map>
>                                 <entry>
>                                         <key>
>                                                 <value>hidden</value>
>                                         </key>
>                                         <bean class="org.apache.tapestry.util.ComponentAddress">
>                                                 <constructor-arg index="0">
>                                                         <value>trails:Viewers</value>
>                                                 </constructor-arg>
>                                                 <constructor-arg index="1">
>                                                         <value>hidden</value>
>                                                 </constructor-arg>
>                                         </bean>
>                                 </entry>
>                         </map>
>                 </property>
>         </bean>
>
> Alejandro.
>
> On 10/22/07, James Carman <ja...@carmanconsulting.com> wrote:
> > A ComponentAddress, in Tapestry, isn't really a "service", though.
> > Why would you want to put this type of object in your HiveMind
> > registry?  I can see it being part of a configuration, but not
> > necessarily a service.  What exactly are you trying to do?
> >
> > On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > > Hi
> > >
> > > I need to do some constructor-based injection and I can't find the way.
> > > I need to create an instance of
> > > org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> > > Strings as parameters.
> > > I know it should be simple but I'm lost.
> > >
> > > Alejandro.
> > >
> >
>

Re: constructor-based injection

Posted by Alejandro Scandroli <al...@gmail.com>.
Hi James

I'm trying to migrate some Spring code to Hivemind.
I need to create a Map<String , ComponentAddress> in the Hivemind registry.
This is what it looks like on spring:

	<bean id="viewerService" class="org.trails.descriptor.EditorBlockFinder">
		<property name="defaultBlockAddress">
			<bean class="org.apache.tapestry.util.ComponentAddress">
				<constructor-arg index="0">
					<value>trails:Viewers</value>
				</constructor-arg>
				<constructor-arg index="1">
					<value>stringViewer</value>
				</constructor-arg>
			</bean>
		</property>
		<property name="editorMap">
			<map>
				<entry>
					<key>
						<value>hidden</value>
					</key>
					<bean class="org.apache.tapestry.util.ComponentAddress">
						<constructor-arg index="0">
							<value>trails:Viewers</value>
						</constructor-arg>
						<constructor-arg index="1">
							<value>hidden</value>
						</constructor-arg>
					</bean>
				</entry>
			</map>
		</property>
	</bean>

Alejandro.

On 10/22/07, James Carman <ja...@carmanconsulting.com> wrote:
> A ComponentAddress, in Tapestry, isn't really a "service", though.
> Why would you want to put this type of object in your HiveMind
> registry?  I can see it being part of a configuration, but not
> necessarily a service.  What exactly are you trying to do?
>
> On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> > Hi
> >
> > I need to do some constructor-based injection and I can't find the way.
> > I need to create an instance of
> > org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> > Strings as parameters.
> > I know it should be simple but I'm lost.
> >
> > Alejandro.
> >
>

Re: constructor-based injection

Posted by James Carman <ja...@carmanconsulting.com>.
A ComponentAddress, in Tapestry, isn't really a "service", though.
Why would you want to put this type of object in your HiveMind
registry?  I can see it being part of a configuration, but not
necessarily a service.  What exactly are you trying to do?

On 10/22/07, Alejandro Scandroli <al...@gmail.com> wrote:
> Hi
>
> I need to do some constructor-based injection and I can't find the way.
> I need to create an instance of
> org.apache.tapestry.util.ComponentAddress, the constructor takes 2
> Strings as parameters.
> I know it should be simple but I'm lost.
>
> Alejandro.
>