@questa, @Denker:
Wat jullie met 'main' returnen bedoelen snap ik even niet.
Met een batch file start ik de main van mijn java class.
Deze blijft vervolgens draaien.
Deze class start wel een andere java class op die als RMI server draait.
Het idee van 'Alarmnummer' gaat niet werken omdat de class die het geheel aan het rollen brengt zelf niks met RMI te maken heeft.
Dan moet ik het een en ander gaan aanpassen, wat overblijft als ik geen simpelere methode kan vinden.
De class die het geheel start ziet er zo uit:
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| public class ProductManagerServer {
static Logger log = Logger.getLogger("ProductManagerServer");
public ProductManagerServer()
{
super();
}
public static void main(String[] args) {
System.out.println("Starting ProductManagerServer - Version 1.0 ");
log.info("\n\n");
log.info(" -- Starting ProductManagerServer - Version 1.0 -- ");
// Properties file
final String PROPFILE= "jc_se_rmi.properties";
// Create and install a security manager
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
log.debug( "Load properties file: "+PROPFILE );
Properties props = loadProperties(PROPFILE);
/* Register new DataSource */
log.debug( "Try registering the DataSource connection.");
DSConnectionPoolFactory dscf = new DSConnectionPoolFactory(props);
dscf.createMySQLDataSourceJNDI();
/* Register ProductManager */
try {
// Instantiate.
log.debug( "Constructing a ProductManagerImpl");
ProductManagerImpl impl = new ProductManagerImpl(PROPFILE);
// Bind into the registry using the java.rmi.Naming API.
log.debug("(re)binding it");
Naming.rebind ("//"+props.getProperty("rmi.host")+":"+props.getProperty("rmi.port")+"/"+props.getProperty("rmi.servicename"), impl);
log.debug("ProductManagerImpl ready and waiting on clients");
} catch (RemoteException re) {
log.error(re);
} catch (MalformedURLException mue) {
log.error(mue);
}
}
private static Properties loadProperties(String fileName) {
InputStream propsFile;
Properties tempProp = new Properties();
try {
propsFile = new FileInputStream(fileName);
tempProp.load(propsFile);
propsFile.close();
} catch (IOException ioe) {
log.error("I/O Exception.");
log.error( ioe.getMessage() );
System.exit(0);
}
return tempProp;
}
} |
[
Voor 7% gewijzigd door
rvrbtcpt op 29-11-2005 13:26
]