You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Markus Wiederkehr <ma...@gmail.com> on 2005/03/07 14:41:05 UTC

Problems with push-attribute

I'm writing a service that requires a single string as configuration.
Here's the definition of the configuration point and contribution:

  <configuration-point id="Factory" occurs="1">
    <schema>
      <element name="config">
        <attribute name="location" required="true"/>

        <rules>
          <push-attribute attribute="location"/>
          <invoke-parent method="addElement"/>
        </rules>
      </element>
    </schema>
  </configuration-point>

  <contribution configuration-id="Factory">
    <config location="/usr/bin/pdftotext"/>
  </contribution>

According to the documentation the attribute should be treated as a
single sting, since I don't provide a translator. Nevertheless I get
this error:

org.apache.hivemind.ApplicationRuntimeException: Unable to translate
'/usr/bin/pdftotext' to type java.lang.Object: No property editor for
java.lang.Object.

What am I missing here?

Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Problems with push-attribute

Posted by Giorgio Gallo <gi...@overlord.it>.
Hi!

I had the same problem, but solved it writing my own "string" translator:

package xx.yy.zz;

import org.apache.hivemind.Location;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.schema.Translator;

public class StringTranslator implements Translator{

	public Object translate(Module contributingModule, Class propertyType, 
String inputValue, Location location){
		return inputValue;
	}

}

Then I contributed my translator to hivemind.Translators:

<contribution configuration-id="hivemind.Translators">
	<translator name="string" class="xx.yy.zz.StringTranslator"/>
</contribution>

And used the new translator inside the schema:

<element name="lookup">
	<attribute name="key" required="true" translator="string" />
	<rules>
		<push-attribute attribute="key" />
		<invoke-parent method="addElement" />
	</rules>
</element>

Don't know if this is better than the string object provider suggested 
by Knut - honestly, I've not quite understood the difference between an 
object provider and a translator! :)

Knut Wannheden wrote:
> Markus,
> 
> This was reported as a bug against HiveMind 1.0
> (http://issues.apache.org/jira/browse/HIVEMIND-15) and has been fixed
> in HiveMind 1.1.
> 
> If you would like to stay with HiveMind 1.0 you have the following
> possibilities:
> 
>  - Use the "resource" translator (it seems like it would work for you)
>  - Create Java objects with a writable String property (e.g.
> setLocation(String location)) to wrap your strings
>  - Implement a "string" object provider and use the "object"
> translator (e.g. <config location="string:/usr/bin/pdftotext"/>
> 
> HTH,
> 
> --knut
> 
> On Mon, 7 Mar 2005 14:41:05 +0100, Markus Wiederkehr
> <ma...@gmail.com> wrote:
> 
>>I'm writing a service that requires a single string as configuration.
>>Here's the definition of the configuration point and contribution:
>>
>>  <configuration-point id="Factory" occurs="1">
>>    <schema>
>>      <element name="config">
>>        <attribute name="location" required="true"/>
>>
>>        <rules>
>>          <push-attribute attribute="location"/>
>>          <invoke-parent method="addElement"/>
>>        </rules>
>>      </element>
>>    </schema>
>>  </configuration-point>
>>
>>  <contribution configuration-id="Factory">
>>    <config location="/usr/bin/pdftotext"/>
>>  </contribution>
>>
>>According to the documentation the attribute should be treated as a
>>single sting, since I don't provide a translator. Nevertheless I get
>>this error:
>>
>>org.apache.hivemind.ApplicationRuntimeException: Unable to translate
>>'/usr/bin/pdftotext' to type java.lang.Object: No property editor for
>>java.lang.Object.
>>
>>What am I missing here?
>>
>>Markus
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Problems with push-attribute

Posted by Knut Wannheden <kn...@gmail.com>.
Markus,

This was reported as a bug against HiveMind 1.0
(http://issues.apache.org/jira/browse/HIVEMIND-15) and has been fixed
in HiveMind 1.1.

If you would like to stay with HiveMind 1.0 you have the following
possibilities:

 - Use the "resource" translator (it seems like it would work for you)
 - Create Java objects with a writable String property (e.g.
setLocation(String location)) to wrap your strings
 - Implement a "string" object provider and use the "object"
translator (e.g. <config location="string:/usr/bin/pdftotext"/>

HTH,

--knut

On Mon, 7 Mar 2005 14:41:05 +0100, Markus Wiederkehr
<ma...@gmail.com> wrote:
> I'm writing a service that requires a single string as configuration.
> Here's the definition of the configuration point and contribution:
> 
>   <configuration-point id="Factory" occurs="1">
>     <schema>
>       <element name="config">
>         <attribute name="location" required="true"/>
> 
>         <rules>
>           <push-attribute attribute="location"/>
>           <invoke-parent method="addElement"/>
>         </rules>
>       </element>
>     </schema>
>   </configuration-point>
> 
>   <contribution configuration-id="Factory">
>     <config location="/usr/bin/pdftotext"/>
>   </contribution>
> 
> According to the documentation the attribute should be treated as a
> single sting, since I don't provide a translator. Nevertheless I get
> this error:
> 
> org.apache.hivemind.ApplicationRuntimeException: Unable to translate
> '/usr/bin/pdftotext' to type java.lang.Object: No property editor for
> java.lang.Object.
> 
> What am I missing here?
> 
> Markus
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org