So after some experimentation I've created a ClientHelper and registered
that into restlet, only I'm stuck on the new content negotiation.  I have a
Directory mounted to my new osgi://bundle/resource URI scheme, but when I
request /admin/index.html this translates to
osgi://bundle/resource/admin/index which I have no means to resolve.

When I mount my Directory, I'm calling setNegotiate(false) in the hopes that
this would prevent this, but that doesn't seem to help.  Any ideas?

For what its worth, my current ClientHelper looks like this (very raw, just
trying to get the data out at the moment).  It's quite possible I'm going
about this entirely wrong as I'm still rather new to restlet, esp. the
internals:

public class BundleResourceClientHelper extends ClientHelper {

    public static final Protocol OSGI = new Protocol("osgi", "OSGI",
            "OSGI Bundle Resource", Protocol.UNKNOWN_PORT);

    public BundleResourceClientHelper(Client client) {
        super(client);
        getProtocols().add(Protocol.valueOf("OSGI"));
    }

    public void handle(Request request, Response response) {
        Matcher matcher =
Pattern.compile("(osgi://)([^/]*)").matcher(request.getResourceRef().getHostIdentifier());
        if (matcher.matches()) {
            Bundle[] bundles = RestActivator.bundleContext.getBundles();
            for (Bundle bundle : bundles) {
                if (matcher.group(2).equals(bundle.getSymbolicName())) {

                    URL url =
bundle.getResource(request.getResourceRef().getPath());

                    if (url != null) {
                        try {
                            InputRepresentation ir = new
InputRepresentation(url.openStream(), null);
                            response.setEntity(ir);
                        } catch (IOException e) {
                            e.printStackTrace();  //To change body of catch
statement use File | Settings | File Templates.
                        }
                    }
                }
            }
        }
    }
}


On Thu, May 8, 2008 at 5:23 PM, Mark Derricutt <[EMAIL PROTECTED]> wrote:

> Hi all,
>
> I was wondering if anyones managed to get CLAP resources working under an
> OSGi environment?
>


-- 
"It is easier to optimize correct code than to correct optimized code." --
Bill Harlan

Reply via email to