1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server;
21
22
23 import org.apache.directory.server.core.api.InstanceLayout;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27
28
29
30
31
32
33 public class UberjarMain
34 {
35
36 private static final Logger LOG = LoggerFactory.getLogger( UberjarMain.class );
37
38
39 ApacheDsService service;
40
41
42
43
44
45
46
47
48 public static void main( String[] args ) throws Exception
49 {
50 if ( ( args != null ) && ( args.length == 1 ) )
51 {
52 UberjarMain uberjarMain = new UberjarMain();
53
54 uberjarMain.start( args );
55 }
56 else
57 {
58
59 throw new IllegalArgumentException(
60 "Program must be launched with 1 arguement, the path to the instance directory." );
61 }
62 }
63
64
65 public void start( String[] args )
66 {
67
68 service = new ApacheDsService();
69
70
71 InstanceLayout instanceLayout = new InstanceLayout( args[0] );
72
73
74 try
75 {
76 service.start( instanceLayout );
77 }
78 catch ( Exception e )
79 {
80 e.printStackTrace();
81 LOG.error( "Failed to start the service.", e );
82 System.exit( 1 );
83 }
84 }
85
86
87 public void stop()
88 {
89 if ( service != null )
90 {
91 try
92 {
93 service.stop();
94 }
95 catch ( Exception e )
96 {
97 e.printStackTrace();
98 LOG.error( "Failed to start the service.", e );
99 System.exit( 1 );
100 }
101 }
102 }
103 }