00001
00025 package org.objectweb.jonas.service;
00026
00027 import javax.naming.Context;
00028
00029 import org.objectweb.jonas.common.JProp;
00030 import org.objectweb.jonas.management.ReconfigDispatcher;
00031
00035 public abstract class AbsServiceImpl extends ReconfigDispatcher implements Service {
00036
00040 private String name = null;
00044 private boolean started = false;
00045
00049 private String domainName = null;
00050
00054 private String jonasServerName = null;
00055
00056
00062 public void init(Context ctx) throws ServiceException {
00063
00064 try {
00065 JProp oProp = JProp.getInstance();
00066 domainName = oProp.getValue(JProp.DOMAIN_NAME, JProp.JONAS_DEF_NAME);
00067 jonasServerName = oProp.getValue(JProp.JONAS_NAME, JProp.JONAS_DEF_NAME);
00068 } catch (Exception e) {
00069 domainName = JProp.JONAS_DEF_NAME;
00070 jonasServerName = JProp.JONAS_DEF_NAME;
00071 }
00072 this.doInit(ctx);
00073 }
00074
00079 public void start() throws ServiceException {
00080 this.doStart();
00081 this.started = true;
00082 }
00083
00088 public void stop() throws ServiceException {
00089 if (this.isStarted()) {
00090 this.started = false;
00091 this.doStop();
00092 }
00093 }
00094
00099 public boolean isStarted() {
00100 return this.started;
00101 }
00102
00107 public String getName() {
00108 return this.name;
00109 }
00110
00115 public void setName(String name) {
00116 this.name = name;
00117 }
00118
00119
00124 public String getDomainName() {
00125 return this.domainName;
00126 }
00127
00132 public String getJonasServerName() {
00133 return this.jonasServerName;
00134 }
00135
00141 protected abstract void doInit(Context ctx) throws ServiceException;
00146 protected abstract void doStart() throws ServiceException;
00151 protected abstract void doStop() throws ServiceException;
00152 }