1 50 package org.apache.excalibur.instrument.manager.altrmi; 51 52 import org.apache.altrmi.server.PublicationDescription; 53 import org.apache.altrmi.server.impl.AbstractServer; 54 import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer; 55 import org.apache.avalon.framework.activity.Startable; 56 import org.apache.avalon.framework.configuration.Configurable; 57 import org.apache.avalon.framework.configuration.Configuration; 58 import org.apache.avalon.framework.configuration.ConfigurationException; 59 import org.apache.avalon.framework.logger.AbstractLogEnabled; 60 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager; 61 import org.apache.excalibur.instrument.manager.InstrumentManagerClientLocalImpl; 62 import org.apache.excalibur.instrument.manager.InstrumentManagerConnector; 63 import org.apache.excalibur.instrument.manager.interfaces.InstrumentDescriptor; 64 import org.apache.excalibur.instrument.manager.interfaces.InstrumentManagerClient; 65 import org.apache.excalibur.instrument.manager.interfaces.InstrumentSampleDescriptor; 66 import org.apache.excalibur.instrument.manager.interfaces.InstrumentableDescriptor; 67 68 74 public class InstrumentManagerAltrmiConnector 75 extends AbstractLogEnabled 76 implements InstrumentManagerConnector, Configurable, Startable 77 { 78 79 public static final int DEFAULT_PORT = 15555; 80 81 private DefaultInstrumentManager m_manager; 82 private int m_port; 83 private AbstractServer m_server; 84 85 88 91 public InstrumentManagerAltrmiConnector() 92 { 93 } 94 95 98 103 public void setInstrumentManager( DefaultInstrumentManager manager ) 104 { 105 m_manager = manager; 106 } 107 108 111 public void configure( Configuration configuration ) 112 throws ConfigurationException 113 { 114 m_port = configuration.getAttributeAsInteger( "port", DEFAULT_PORT ); 115 } 116 117 120 public void start() 121 throws Exception 122 { 123 getLogger().debug( "Starting Instrument Manager Altrmi Connector" ); 124 InstrumentManagerClientLocalImpl client = new InstrumentManagerClientLocalImpl( m_manager ); 125 126 m_server = new CompleteSocketCustomStreamServer( m_port ); 128 129 Class [] additionalFacadeClasses = new Class [] 130 { 131 InstrumentableDescriptor.class, 132 InstrumentDescriptor.class, 133 InstrumentSampleDescriptor.class 134 }; 135 136 m_server.publish( client, "InstrumentManagerClient", 137 new PublicationDescription( InstrumentManagerClient.class, additionalFacadeClasses ) ); 138 139 m_server.start(); 140 getLogger().info( "Instrument Manager Altrmi Connector listening on port: " + m_port ); 141 142 getLogger().warn("The AltRMI Connector is an \"expermental feature\" until AltRMI reaches 1.0."); 143 } 144 145 public void stop() 146 throws Exception 147 { 148 getLogger().debug( "Stopping Instrument Manager Altrmi Connector" ); 149 m_server.stop(); 150 m_server = null; 151 } 152 } 153 154 | Popular Tags |