You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by ruchi goel <Ru...@Sun.COM> on 2007/02/28 12:25:49 UTC

how to shutdown a remote repository

Hi,
   *I have a program which registers,starts the repository and then 
exposes it as remote repository by following code :
*
            Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
            env.put(Context.PROVIDER_URL, "localhost");
           
            InitialContext ctx = new InitialContext(env);

            RegistryHelper.registerRepository(ctx, REPOSITORY_NAME, 
REPOSITORY_CONFIG, REPOSITORY_DIR, true);
             repository = (Repository) ctx.lookup(REPOSITORY_NAME);
            
             //bind repository
            ServerAdapterFactory factory = new ServerAdapterFactory();
            RemoteRepository remote = 
factory.getRemoteRepository(repository);
            Registry reg = LocateRegistry.createRegistry(new 
Integer(REPOSITORY_PORT).intValue());
            reg.rebind("jackrabbit", remote);


*Now , I want a module to shutdown the above repository. I have tried 
the following :*
          Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
            env.put(Context.PROVIDER_URL, "localhost"); 
            InitialContext ctx = new InitialContext(env);
           repository = (Repository) ctx.lookup(REPOSITORY_NAME);
          RegistryHelper.unregisterRepository(ctx,REPOSITORY_NAME);

*But the above is not able to do a lookup for the repository.

Then tried looking up as  via RMI url :*
 ClientRepositoryFactory factory = new ClientRepositoryFactory();
         try{
           repository = 
factory.getRepository("rmi://localhost:1101/jackrabbit");
  
         }catch(Exception e){
           System.out.println(e.getMessage());
           e.printStackTrace();
         }

*But here RemoteRepository does not have a method to shutdown !!

Is there some other way to shutdown the repository ?*

Thanks,
Ruchi

Re: how to shutdown a remote repository

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 2/28/07, ruchi goel <Ru...@sun.com> wrote:
> *But here RemoteRepository does not have a method to shutdown !!
>
> Is there some other way to shutdown the repository ?*

No, the RMI layer currently does not expose the shutdown() method. The
reason for this was that the responsibility of stopping the repository
should be on the component that started it in the first place, not on
some remote client. It is a separate question on whether that
component want's to expose some mechanism (perhaps another RMI
interface) for remote clients to request repository shutdown.

One alternative you might want to consider is to use
TransientRepository as the repository that's gets bound remotely. The
TransientRepository class automatically shuts down the repository when
there are no active sessions connected to it.

BR,

Jukka Zitting