The file is on the classpath. More precisely, I put its path in a
-Xbootclasspath jvm argument with append option. This usually works well
with wss4j property files, so I thought it could work also with jetty...


-----Messaggio originale-----
Da: Sergey Beryozkin [mailto:sberyoz...@gmail.com] 
Inviato: mercoledì 8 febbraio 2012 22:25
A: users@cxf.apache.org
Oggetto: Re: serve static content through jetty

Hi

On 08/02/12 17:10, matteo rulli wrote:
> Dear all,
>
> I publish some soap-WS through CXF (v. 2.5.0 - bundled into OSGi equinox)
on
> the following URI:
>
>
>
> http://10.0.2.243:8160/Persistence
>
>
>
> The problem is that when a Silverlight client tries to consume my WS, a
> "get" request for a resource called clientaccesspolicy.xml is generated,
> namely
>
> http:// 10.0.2.243:8160/clientaccesspolicy.xml
> <http://%2010.0.2.243:8160/clientaccesspolicy.xml>

where exactly is this file located/created ? Is it available before the 
bundle is even started for the very first time ?

Cheers, Sergey


>
>
>
> Is there a way to configure Jetty to serve this file? I should perform
this
> programmatically. I tried with something like (sorry for that, I know it
is
> a very awkward attempt of mine to reproduce the
> <http://cxf.apache.org/docs/standalone-http-transport.html>
> http://cxf.apache.org/docs/standalone-http-transport.html example):
>
>
>
> String address = "http:// 10.0.2.243:8160";
>
> Bus _defaultBUS = BusFactory.getDefaultBus();
>
> JettyHTTPServerEngineFactory jettyFactory =
>
>
> _defaultBUS.getExtension(JettyHTTPServerEngineFactory.class);
>
> // get the jetty server form the destination
>
> EndpointInfo ei = new EndpointInfo();
>
> ei.setAddress(address);
>
> DestinationFactoryManager dfm =
>
> _defaultBUS.getExtension(DestinationFactoryManager.class);
>
> DestinationFactory df = dfm.getDestinationFactoryForUri(address);
>
> JettyHTTPDestination destination =
>
>          (JettyHTTPDestination) df.getDestination(ei);
>
>
>
> JettyHTTPDestination jettyDestination = (JettyHTTPDestination)
destination;
>
> ServerEngine engine = jettyDestination.getEngine();
>
> Handler handler = engine.getServant(new URL(address));
>
> org.eclipse.jetty.server.Server server = handler.getServer(); // The
Server
>
>
>
> // We have to create a HandlerList structure that includes both a
> ResourceHandler for the static
>
> // content as well as the ContextHandlerCollection created by CXF (which
we
> retrieve as serverHandler).
>
> Handler serverHandler = server.getHandler();
>
> HandlerList handlerList = new HandlerList();
>
> ResourceHandler resourceHandler = new ResourceHandler();
>
> handlerList.addHandler(resourceHandler);
>
> handlerList.addHandler(serverHandler);
>
>
>
> // replace the CXF servlet connect collection with the list.
>
> server.setHandler(handlerList);
>
> // and tell the handler list that it is alive.
>
> handlerList.start();
>
>
>
> // setup the resource handler
>
> File staticContentFile = new File(staticContentPath); // ordinary
pathname.
>
> URL targetURL = new URL("file://" + staticContentFile.getCanonicalPath());
>
> FileResource fileResource = new FileResource(targetURL);
>
> resourceHandler.setBaseResource(fileResource);
>
>
>
> But unfortunately it does not work and it spoils my endpoint.
>
>
>
> Could you suggest an alternative java-based approach to serve the
> clientaccesspolicy.xml file?
>
>
>
> Thank you very much.
>
>
>
> Matteo Rulli
>
>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com


Reply via email to