To dynamically manage context details you might have some luck creating a
DeploymentManager[1] AppLifeCycle.Binding[2] that does the context specific
configurations in a way you desire.

[1]
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/package-summary.html
[2]
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/AppLifeCycle.Binding.html

Check out the jetty-webapp-logging project on the codehaus side for an
example of how this is setup.
The Binding[3] is loaded into the DeploymentManager via a jetty xml
configuration[4] at startup, and all Apps that are deployed pass through
your binding at the lifecycle point of your choice.

[3]
http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=blob;f=jetty-webapp-logging/src/main/java/org/mortbay/jetty/webapp/logging/CentralizedWebAppLoggingBinding.java;h=c68b31a6f248c31f1fc6b641ef12aee239506165;hb=HEAD
[4]
http://git.codehaus.org/gitweb.cgi?p=jetty-project.git;a=blob;f=jetty-webapp-logging/src/main/config/etc/jetty-webapp-logging.xml;h=f69d9b540986b7c24a58de8c366844c717c0df20;hb=HEAD

--
Joakim Erdfelt
[email protected]

http://webtide.com | http://intalio.com
(the people behind jetty and cometd)



On Thu, Sep 8, 2011 at 6:15 AM, Jesse McConnell <[email protected]> wrote:

> ah, jetty-policy work
>
> ok, so yes this approach is possible, and its recommended that you use
> a work directory here
>
> the way I have done in the past is to have a context.xml file that
> unpacks the webapp to a specific location and then have a
> corresponding policy file that sets up the codebase to that specific
> location, working with tmp directories is too hit or miss for my
> tastes
>
> steps I took doing this:
>
> - remove the jetty webapp deployer from startup
> - use jetty context deployer exclusively to deploy your webapps
> - set the location for unpacking the webapp in the context.xml
> - create the policy file you want for that webapp location and drop it
> into the lib/policy directory (should be picked up automatically if I
> remember right, might be a property governing that
>
> I never got around to making it all dynamic, I had plans but time to
> devote to that sort of setup was never available.  Also thought about
> wiring jetty-policy up to jmx to make it possible to influence it
> during runtime better
>
> cheers,
> jesse
>
>
> --
> jesse mcconnell
> [email protected]
>
> http://webtide.com / http://intalio.com
> (the folks behind jetty and cometd)
>
>
>
> On Wed, Sep 7, 2011 at 22:01, zhiwei chen <[email protected]> wrote:
> > I mean, one app can read and write it's own directory .
> > When I add a new app, I want to add it's own directory and own policy in
> > policy files.
> > for example:
> > I have 2 app,and two directory,like
> > /webapps/app1.war
> > /webapps/app2.war
> > /read_write/app1/
> > /read_write/app2/
> > app1.war can only read and write /read_write/app1/ and app2.war can only
> > read and write /read_write/app2/
> > I use policy file to realize this principle.
> > app1.policy file:
> > grant codeBase "file:/tmp/jetty-0.0.0.0-10000-app1.war-_app1-any-/-" {
> >    permission java.io.FilePermission "/read_write/app1/-", "read, write";
> > };
> > app2.policy file:
> > grant codeBase "file:/tmp/jetty-0.0.0.0-10000-app2.war-_app2-any-/-" {
> >    permission java.io.FilePermission "/read_write/app2/-", "read, write";
> > };
> > but when I add app3.war , I should add an app3.policy file like this:
> > app3.policy file:
> > grant codeBase "file:/tmp/jetty-0.0.0.0-10000-app3.war-_app3-any-/-" {
> >    permission java.io.FilePermission "/read_write/app3/-", "read, write";
> > };
> > How can I dynamically realize this? Should I modify jetty's source code?
> > BTW, what's the difference between java.io.tmpdir and jetty's work
> > directory?
> > Thank you very much.
> >
> > On Wed, Sep 7, 2011 at 10:09 PM, Jesse McConnell <[email protected]>
> wrote:
> >>
> >> that would be my best guess as a solution...
> >>
> >> if its not what you need could you explain in a bit more detail?
> >>
> >> cheers,
> >> jesse
> >>
> >> --
> >> jesse mcconnell
> >> [email protected]
> >>
> >> http://webtide.com / http://intalio.com
> >> (the folks behind jetty and cometd)
> >>
> >>
> >>
> >> On Wed, Sep 7, 2011 at 04:07, John English <[email protected]>
> wrote:
> >> > On 06/09/2011 05:58, zhiwei chen wrote:
> >> >>
> >> >> hi,all.
> >> >>
> >> >> I have run many app under jetty, and I want to give one app a
> specified
> >> >> read_write dir.
> >> >> like this:
> >> >>
> >> >> /webapps/app1.war  read_write_dir is   /dir/app1/
> >> >> /webapps/app2.war  read_write_dir is   /dir/app2/
> >> >> /webapps/app3.war  read_write_dir is   /dir/app3/
> >> >> .......
> >> >>
> >> >> How to dynamically specified app's read_write_dir when app are
> comming?
> >> >
> >> > Not sure if I understand the question, but could you use context
> params
> >> > in the web.xml of each app to specify the directory path?
> >> >
> >> >
> ------------------------------------------------------------------------
> >> >  John English | My old University of Brighton home page is still here:
> >> >              | http://www.cem.brighton.ac.uk/staff/je/
> >> >
> ------------------------------------------------------------------------
> >> > _______________________________________________
> >> > jetty-users mailing list
> >> > [email protected]
> >> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >> >
> >> _______________________________________________
> >> jetty-users mailing list
> >> [email protected]
> >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> >
> > _______________________________________________
> > jetty-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> >
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to