Example #1
0
 @Override
 public void doStop() throws Exception {
   super.doStop();
   // clean up / unregister everything
   server.removeMapping(hostName, "admin");
   handler.stop(null);
 }
Example #2
0
  @Override
  public void doStart() throws Exception {
    super.doStart();

    // create a handler
    handler = new AdminHandler();

    // create app context
    adminContext =
        new FileSystemXmlApplicationContext(
            new String[] {"classpath:/admin-security.xml"}, true, context);

    // set the context
    handler.setContext(adminContext);

    // get a ref to the "default" global scope
    GlobalScope global = (GlobalScope) server.getGlobal("default");

    // create a scope resolver
    ScopeResolver scopeResolver = new ScopeResolver();
    scopeResolver.setGlobalScope(global);

    AuthClientRegistry registry = (AuthClientRegistry) adminContext.getBean("authClientRegistry");

    // create a context - this takes the place of the previous web context
    Context ctx = new Context(adminContext, "admin");
    ctx.setClientRegistry(registry);
    ctx.setMappingStrategy(new MappingStrategy());
    ctx.setPersistanceStore(global.getStore());
    ctx.setScopeResolver(scopeResolver);
    ctx.setServiceInvoker(new ServiceInvoker());

    // create a scope for the admin
    //		Scope scope = new Scope.Builder((IScope) global, "scope", "admin", false).build();
    //
    //		scope.setContext(ctx);
    //		scope.setHandler(handler);
    //
    //		//set the scope on the handler
    //		handler.setScope(scope);

    server.addMapping(hostName, "admin", "default");

    //		if (global.addChildScope(scope)) {
    //			log.info("Admin scope was added to global (default) scope");
    //
    //		} else {
    //			log.warn("Admin scope was not added to global (default) scope");
    //		}
  }