1 /* 2 * Copyright (c) 1998-2004 The Jgroup Team. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * 17 */ 18 package jgroup.relacs.gmi; 19 20 import java.rmi.Remote; 21 import java.rmi.server.ExportException; 22 23 import jgroup.core.ExternalGMIService; 24 import jgroup.core.GroupManager; 25 import jgroup.relacs.config.AppConfig; 26 import net.jini.export.Exporter; 27 28 29 /** 30 * This class can be used together with Jini2 config files 31 * to export a proxy. It uses <code>JeriEGMILayer</code> as 32 * the invocation factory. 33 * 34 * @author Rohnny Moland 35 */ 36 public class JeriGroupExporter implements Exporter 37 { 38 /** Service proxy **/ 39 private ExternalGMIService externalGMIService; 40 41 /** 42 * Obtains a <code>GroupManager</code> from the application 43 * name, and an <code>ExternalGMIService</code>. 44 * 45 * @param name the application name 46 */ 47 public JeriGroupExporter(String name) 48 { 49 AppConfig app = AppConfig.getApplication(name); 50 int gid = app.getGroupId(); 51 GroupManager gm = GroupManager.getGroupManager(gid); 52 externalGMIService = (ExternalGMIService) gm.getService(ExternalGMIService.class); 53 } 54 55 /* (non-Javadoc) 56 * @see net.jini.export.Exporter#export(java.rmi.Remote) 57 */ 58 public Remote export(Remote impl) 59 throws ExportException 60 { 61 return externalGMIService.getProxy(impl); 62 } 63 64 /* (non-Javadoc) 65 * @see net.jini.export.Exporter#unexport(boolean) 66 */ 67 public boolean unexport(boolean force) 68 { 69 return false; 70 } 71 }