Adam,

OK got it to work, the following is what I did along with a little bit of code.

In hivemodule.xml:

<service-point id="MySqueezeAdaptor" interface="com.azudio.project1.MySqueezeAdaptor">
        <invoke-factory>
            <construct class="com.azudio.project1.MySqueezeAdaptor"/>
<set-object property="myService" value="spring:myService" />
        </invoke-factory>
    </service-point>

    <contribution configuration-id="tapestry.data.SqueezeAdaptors">
        <adaptor object="service:MySqueezeAdaptor" />
    </contribution>

The Adaptor class:
*Note: This is not a complete implementation, ie: the adaptor isn't really useful but just demonstrates how to get a SqueezeAdaptor set up and registered, although it works, it squeezes a SomeBase instance and reconstitutes it later.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry.services.DataSqueezer;
import org.apache.tapestry.util.io.SqueezeAdaptor;

public class MySqueezeAdaptor implements SqueezeAdaptor {

private static final Log log = LogFactory.getLog (MySqueezeAdaptor.class);

    private MySpringBean _myService;

    public MySpringBean getMyService(){
        return _myService;
    }
    public void setMyService(MySpringBean myService){
        _myService = myService;
    }


    private static final String PREFIX = "H";

    public String getPrefix() {
        return PREFIX;
    }

    public Class getDataClass() {
        log.debug("Getting DataClass");
        return  SomeBase.class;
    }

    public String squeeze(DataSqueezer datasqueezer, Object entity) {
        log.debug("Squeezing Object");

        // Will return something like: "H:XXX:1234"
        return getPrefix() + ":" + "XXX:" + ((SomeBase)entity).getId();
    }

public Object unsqueeze(DataSqueezer dataSqueezer, String stringRepresentation) {
        log.debug("Unsqueezing Object");

        String parts[] = stringRepresentation.split(":");

        Long id = Long.parseLong(parts[2]);

        log.debug("Id: " + id);

        return getMyService().getSomeBase(id);
    }

}

I'm assuming that the Spring context is all set up etc.

Hope that helps.

Adam.

On 3 Sep 2005, at 01:14, Adam Greene wrote:

Ok, first thing right off. You do not need to subclass BaseEngine. The steps are :

1. Your class implements org.apache.tapestry.services.DataSqueezer.
2.  Setup your class as a service in hivemodule.xml:
3. Then contribute to the tapestry.data.SqueezeAdaptors configuration point, put something like this in your hivemodule.xml:

<contribution configuration-id="tapestry.data.SqueezeAdaptors">
   <adaptor object="service:YourAdaptor"/>
</contribution>

if you look at tapestry-4.0.jar!/META-INF/tapestry-data.xml, you will see how this all works. The examples there are based on "instance:" but you can use "service:"

----- Original Message ----- From: "Adam Henderson Azudio" <[EMAIL PROTECTED]>
To: "Tapestry users" <tapestry-user@jakarta.apache.org>
Sent: Friday, September 02, 2005 11:22 AM
Subject: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate



Hi,

I've written a SqueezeAdaptor for use with my Hibernate entities and it works well in T3.

My HibernateSqueezeAdaptor unsqueezes the string by decoding a entity type code along with the id, then it accesses my Spring appService bean and asks it to retrieve my entity.

I'm attempting to upgrade/convert to T4 and I'm a bit stumped as how to do the conversion.

How do I create and register a SqueezeAdaptor that uses a Spring service object, what do I put in my subclass of BaseEngine?, do I need to subclass BaseEngine? How do I inject my spring service into my adaptor? Do I need a hivemodule.xml? if so what do I put in it?

What would be the logical steps needed to implement this. Also is there any security issues with what I'm doing?

Many thanks

Adam.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: tapestry-user- [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to