1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.backsource.xindice.server;
21 import java.io.File;
22 import javax.management.ObjectName;
23 import javax.management.MBeanServer;
24 import javax.management.MalformedObjectNameException;
25
26 import org.backsource.jmx.ServiceMBeanSupport;
27 import org.backsource.jmx.ObjectNameFactory;
28
29 import org.apache.xindice.server.Kernel;
30 /***
31 * An embedded Xindice server to be run i JBoss.
32 *
33 * <p>The server will use jboss.server.data.dir and append xindice to set up xindice.home if the property XindiceHome is not set in the MBean. This is the prefered method to do it, but is dependant on a correct setup of a jboss-service or manuall setup of the db/xindice directory in the JBoss server i use. by setting <b>XindiceHome</b> it is possible to use an external home, for example a directopry where you have installed a stand alone version of Xindice.</p>
34 <p><b>openorb.home</b> will be set to the embedded home: db/xindice/openorb, but it seems as if it works agains the db/xindice dir instead. This needs to be further checked.</p>
35 <p><b>Installation</b> To be able to redeploy this service it seems as if the openorb.jar must be placed in the central lib, for example server/default/lib.
36 </p>
37
38
39 * @author <a href="mailto:pra@tim.se"></a>
40 * @version $Revision: 1.1.1.1 $
41 * @jmx:mbean name="xindice:service=XindiceServer" extends="org.backsource.jmx.ServiceMBean"
42 */
43
44 public class XindiceService extends ServiceMBeanSupport implements org.backsource.xindice.server.XindiceServiceMBean{
45 public static final javax.management.ObjectName OBJECT_NAME = ObjectNameFactory.create("xindice:service=XindiceServer");
46 private ObjectName name = OBJECT_NAME;
47 private String xindiceHome;
48 private String xindiceDb;
49 private Kernel kernel;
50
51 public XindiceService (){
52
53 }
54 protected ObjectName getObjectName(MBeanServer server, ObjectName name)
55 throws MalformedObjectNameException
56 {
57 if ( name != null) {
58 this.name = name;
59 }
60
61 return name;
62 }
63
64 /***
65 * @jmx:managed-attribute
66 */
67 public void setXindiceHome(String xindiceHome) {
68 this.xindiceHome = xindiceHome;
69 }
70
71 /***
72 * Dont use this, only for testing!
73 * @jmx:managed-attribute
74 */
75 public void setXindiceDb(String xindiceDb) {
76 this.xindiceDb = xindiceDb;
77 }
78
79 protected void startService()
80 throws Exception
81 {
82 String db = System.getProperty("jboss.server.data.dir");
83 xindiceDb = db +"/xindice";
84
85 if ( xindiceHome != null && xindiceHome.length() >0) {
86 log.info("Setting xindice.home to an external home: " + xindiceHome);
87 System.setProperty("xindice.home",xindiceHome);
88 } else {
89 log.info("Setting xindice.home embedded home: " + xindiceDb);
90 System.setProperty("xindice.home",xindiceDb);
91 }
92
93
94 System.setProperty("openorb.home","file:"+xindiceDb+"/openorb");
95 File cfg = new File(new File( System.getProperty("xindice.home")), "/config/system.xml");
96 log.info("Starting Xindice in home: " + System.getProperty("xindice.home"));
97 kernel = new Kernel(cfg.getAbsolutePath(), false);
98 }
99
100 protected void stopService()
101 throws Exception
102 {
103 if ( kernel != null) {
104 kernel.shutDown(1, false);
105 }
106
107
108 }
109 }