It is really going to depend on your library and bundles you use.  I used
to do it in my activator like


import java.util.Dictionary;
import org.ops4j.pax.web.extender.whiteboard.ResourceMapping;
import org.ops4j.pax.web.extender.whiteboard.runtime.DefaultResourceMapping;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
*
* @author ddaniel
*/
public class Activator implements BundleActivator {

/**
* Logger.
*/
private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
private ServiceRegistration<ResourceMapping> resourcesReg;

public void start(final BundleContext bundleContext) throws Exception {
Dictionary<String, String> props;

// Registering resource mappings as service
DefaultResourceMapping resourceMapping = new DefaultResourceMapping();
resourceMapping.setAlias("/webIngest");
resourceMapping.setPath("/content");
resourcesReg = bundleContext.registerService(ResourceMapping.class,
resourceMapping, null);
}

public void stop(BundleContext bundleContext) throws Exception {
if (resourcesReg != null) {
resourcesReg.unregister();
resourcesReg = null;
}
}
}

I have since moved to using the enroute web simple provider

https://github.com/osgi/osgi.enroute.bundles/tree/master/osgi.enroute.web.simple.provider

You will likely need to pick a framework karaf/enroute/amdatu and follow
their documentation.  Without a clear framework things become more
difficult and you have to know your bundles well.

On Wed, Nov 16, 2016 at 6:42 AM, Tim Ward <t...@telensa.com> wrote:

> Basically I was just trying to understand the documentation I quoted; I'd
> been led there whilst looking for some way to serve a static resource from
> a less complicated URL. I have not found any documentation of how to
> actually use ConditionalServlet - your response below tells me that I can
> do whatever I like, but doesn't give enough information for me to be able
> to work out *how* to do it.
>
>
> On 15/11/2016 21:45, David Leangen wrote:
>
>
> Hi Tim,
>
> You just need a class that implements ConditionalServlet, and register it
> (for example) using DS.
>
> By following the ConditionalServlet algorithm, you should be able to
> accomplish anything you need to do.
>
>
> It may be easier if you have more specific questions. What are you trying
> to accomplish?
>
> Cheers,
> =David
>
>
> On Nov 16, 2016, at 12:52 AM, Tim Ward <t...@telensa.com> wrote:
>
> In
>
> https://github.com/osgi/osgi.enroute.bundles/tree/master/
> osgi.enroute.web.simple.provider
>
> it says
>
> "By adding, removing, and reordering ConditionalServlets, you can gain
> unlimited control of what happens on the root path."
>
> How, exactly? - what does one actually *do* to "add" (eg) a
> ConditionalServlet?
>
> --
> Tim Ward
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
>
>
> _______________________________________________
> OSGi Developer Mail 
> listosgi-...@mail.osgi.orghttps://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
>
> --
> Tim Ward
>
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to