use of org.mobicents.smsc.mproc.MProcRuleFactory in project smscgateway by RestComm.
the class MProcManagement method start.
public void start() throws Exception {
this.smscPropertiesManagement = SmscPropertiesManagement.getInstance();
if (this.smscManagement != null) {
for (MProcRuleFactory ruleFactory : this.smscManagement.getMProcRuleFactories2()) {
this.bindAlias(ruleFactory);
}
}
try {
boolean servFound = false;
String agentId = "jboss";
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
if (servers != null && servers.size() > 0) {
for (MBeanServer server : servers) {
String defaultDomain = server.getDefaultDomain();
if (defaultDomain != null && defaultDomain.equals(agentId)) {
mbeanServer = server;
servFound = true;
logger.info(String.format("Found MBeanServer matching for agentId=%s", agentId));
} else {
logger.warn(String.format("Found non-matching MBeanServer with default domian = %s", defaultDomain));
}
}
}
if (!servFound) {
this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
}
logger.info("servFound =" + servFound + ", this.mbeanServer = " + this.mbeanServer);
} catch (Exception e) {
}
this.persistFile.clear();
if (persistDir != null) {
this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
} else {
persistFile.append(System.getProperty(SmscManagement.SMSC_PERSIST_DIR_KEY, System.getProperty(SmscManagement.USER_DIR_KEY))).append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
}
logger.info(String.format("Loading MProcRule configuration from %s", persistFile.toString()));
try {
this.load();
} catch (FileNotFoundException e) {
logger.warn(String.format("Failed to load the ProcRule configuration file. \n%s", e.getMessage()));
}
this.resortRules(this.mprocs);
this.store();
for (MProcRule rule : this.mprocs) {
this.registerMProcRuleMbean(rule);
}
}
use of org.mobicents.smsc.mproc.MProcRuleFactory in project smscgateway by RestComm.
the class MProcManagement method createMProcRule.
@Override
public MProcRule createMProcRule(int id, String ruleFactoryName, String parametersString) throws Exception {
logger.info("createMProcRule: id=" + id + ", ruleFactoryName=" + ruleFactoryName + ", parametersString=" + parametersString);
if (ruleFactoryName == null) {
throw new Exception(String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_RULE_CLASS_NAME_NULL_VALUE));
}
MProcRuleFactory ruleClass = null;
if (this.smscManagement != null) {
ruleClass = this.smscManagement.getRuleFactory(ruleFactoryName);
}
if (ruleClass == null) {
throw new Exception(String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_RULE_CLASS_NOT_FOUND, ruleFactoryName));
}
if (this.getMProcRuleById(id) != null) {
throw new Exception(String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_ALREADY_EXIST, id));
}
MProcRule mProcRule = ruleClass.createMProcRuleInstance();
mProcRule.setId(id);
mProcRule.setInitialRuleParameters(parametersString);
FastList<MProcRule> lstTag = new FastList<MProcRule>(this.mprocs);
lstTag.add(mProcRule);
this.resortRules(lstTag);
this.store();
this.registerMProcRuleMbean(mProcRule);
return mProcRule;
}
use of org.mobicents.smsc.mproc.MProcRuleFactory in project smscgateway by RestComm.
the class SmscService method initSmscManagementMBean.
private SmscManagement initSmscManagementMBean(SmppManagement smppManagement) throws StartException {
String dataDir = pathManagerInjector.getValue().getPathEntry(DATA_DIR).resolvePath();
SmscManagement smscManagementMBean = SmscManagement.getInstance("SmscManagement");
smscManagementMBean.setPersistDir(dataDir);
smscManagementMBean.setSmppManagement(smppManagement);
// specify mproc rules factories
ArrayList<MProcRuleFactory> ruleFactories = new ArrayList<MProcRuleFactory>();
String factoryNames = getPropertyString("SmscManagement", "MProcRuleFactories", "org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault");
String[] mProcRuleFactories = factoryNames.split(",");
ClassLoader parent = SmscService.class.getClassLoader();
for (String s : mProcRuleFactories) {
try {
log.info("Loading mproc Factory class: " + s);
Class<MProcRuleFactory> c = (Class<MProcRuleFactory>) parent.loadClass(s);
MProcRuleFactory fact = c.newInstance();
ruleFactories.add(fact);
log.info("Loaded mproc Factory class: " + s + ", object: " + fact);
} catch (Throwable e) {
log.error("Error of loading mproc Factory class: " + s, e);
}
}
smscManagementMBean.setMProcRuleFactories(ruleFactories);
// specify of smsRoutingRuleClass class
String smsRoutingRuleClass = getPropertyString("SmscManagement", "smsRoutingRuleClass", null);
if (smsRoutingRuleClass != null) {
log.info("Loaded smsRoutingRuleClass class name: " + smsRoutingRuleClass);
smscManagementMBean.setSmsRoutingRuleClass(smsRoutingRuleClass);
} else {
log.info("smsRoutingRuleClass class not found in config");
}
try {
smscManagementMBean.start();
} catch (Exception e) {
throw new StartException("SmscShellExecutor MBean creating is failed: " + e.getMessage(), e);
}
registerMBean(smscManagementMBean, "org.mobicents.smsc.domain:name=SmscManagement");
return smscManagementMBean;
}
use of org.mobicents.smsc.mproc.MProcRuleFactory in project smscgateway by RestComm.
the class SmscManagement method setMProcRuleFactories.
public void setMProcRuleFactories(List ruleFactories) {
this.mprocFactories = new FastList<MProcRuleFactory>();
for (Object obj : ruleFactories) {
if (obj != null && obj instanceof MProcRuleFactory) {
MProcRuleFactory ruleFactory = (MProcRuleFactory) obj;
this.mprocFactories.add(ruleFactory);
if (this.mProcManagement != null) {
this.mProcManagement.bindAlias(ruleFactory);
}
}
}
}
Aggregations