List of usage examples for org.apache.commons.digester3.binder DigesterLoader newLoader
public static DigesterLoader newLoader(Iterable<RulesModule> rulesModules)
From source file:com.app.server.XMLDeploymentScanner.java
public void init(Vector serviceList, ServerConfig serverConfig, MBeanServer mbeanServer) { this.serviceList = serviceList; this.serverConfig = serverConfig; this.mbeanServer = mbeanServer; this.userLibDir = serverConfig.getServiceslibdirectory(); File userLibJars = new File(userLibDir); CopyOnWriteArrayList<String> jarList = new CopyOnWriteArrayList(); getUsersJars(userLibJars, jarList);// w ww . j a v a 2s. c o m URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); userLibJarLoader = new WebClassLoader(loader.getURLs()); for (String jarFilePath : jarList) { try { userLibJarLoader.addURL(new URL("file:/" + jarFilePath.replace("\\", "/"))); } catch (Exception e) { log.error("Error in url " + "file:/" + jarFilePath.replace("\\", "/"), e); //e2.printStackTrace(); } } DigesterLoader xmlDigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { try { loadXMLRules(new InputSource(new FileInputStream("./config/datasource-rules.xml"))); } catch (Exception e) { log.error("Error in loading config rules ./config/datasource-rules.xml", e); //e.printStackTrace(); } } }); xmlDigester = xmlDigesterLoader.newDigester(); try { ic = new InitialContext(); ic.createSubcontext("java:"); } catch (Exception e) { log.error("Error in creating subcontext", e); } log.info("initialized"); // TODO Auto-generated constructor stub }
From source file:edu.wustl.bulkoperator.templateImport.AbstractImportBulkOperation.java
/** * * @param operationName//from www . j a va2 s.c o m * @param dropdownName * @param csvFile * @param xmlFile * @param mappingXml * @return * @throws BulkOperationException * @throws SQLException * @throws IOException * @throws DAOException */ protected Set<String> validate(String operationName, String dropdownName, String csvFile, String xmlFile, String mappingXml, String xsdLocation) throws BulkOperationException, SQLException, IOException, DAOException { Set<String> errorList = null; CsvReader csvReader = null; try { csvReader = CsvFileReader.createCsvFileReader(csvFile, true); } catch (Exception exp) { ErrorKey errorkey = ErrorKey.getErrorKey("bulk.error.incorrect.csv.file"); throw new BulkOperationException(errorkey, exp, ""); } BulkOperationMetaData bulkOperationMetaData = null; try { SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); File schemaLocation = new File(xsdLocation); Schema schema = factory.newSchema(schemaLocation); DigesterLoader digesterLoader = DigesterLoader.newLoader(new XmlRulesModule(mappingXml)); Digester digester = digesterLoader.newDigester(); digester.setValidating(true); digester.setXMLSchema(schema); Validator validator = schema.newValidator(); Source xmlFileForValidation = new StreamSource(new File(xmlFile)); validator.validate(xmlFileForValidation); InputStream inputStream = new FileInputStream(xmlFile); bulkOperationMetaData = digester.parse(inputStream); } catch (SAXException e) { logger.debug(e.getMessage()); ErrorKey errorkey = ErrorKey.getErrorKey("bulk.error.xml.template"); throw new BulkOperationException(errorkey, e, e.getMessage()); } Collection<BulkOperationClass> classList = bulkOperationMetaData.getBulkOperationClass(); if (classList == null) { ErrorKey errorkey = ErrorKey.getErrorKey("bulk.no.templates.loaded.message"); throw new BulkOperationException(errorkey, null, ""); } else { Iterator<BulkOperationClass> iterator = classList.iterator(); if (iterator.hasNext()) { BulkOperationClass bulkOperationClass = iterator.next(); TemplateValidator templateValidator = new TemplateValidator(); errorList = templateValidator.validateXmlAndCsv(bulkOperationClass, operationName, csvReader); } } return errorList; }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.PluginConfigurationServiceDefault.java
public PluginConfigurationServiceDefault(@NotNull ServerPaths serverPaths) { File configDirectory = PluginFileUtils.getCanonicalFile(new File(serverPaths.getConfigDir())); this.xsdFile = new File(configDirectory, PluginConfigurationService.CONFIG_XSD_FILE_NAME); this.configFile = new File(configDirectory, PluginConfigurationService.CONFIG_XML_FILE_NAME); this.digesterLoader = DigesterLoader.newLoader(new ConfigurationDigesterModule()); this.configLock = new ReentrantReadWriteLock(); }
From source file:com.web.services.ExecutorServicesConstruct.java
/** * This method removes the configuration of the War file * @param servicesMap// w w w. j a va 2s. c om * @param exectorServicesXml * @param customClassLoader * @throws Exception */ public void removeExecutorServices(Hashtable servicesMap, File exectorServicesXml, WebClassLoader customClassLoader) throws Exception { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/executorservices-config.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); ExecutorServices executorServices = (ExecutorServices) serverdigester .parse(new InputSource(new FileInputStream(exectorServicesXml))); CopyOnWriteArrayList<ExecutorService> executorServicesList = executorServices.getExecutorServices(); ExecutorServiceAnnot executorServiceAnnot; for (ExecutorService executorService : executorServicesList) { Class executorServiceClass = customClassLoader .loadClass(executorService.getExecutorserviceclass().toString()); //System.out.println("executor class in ExecutorServicesConstruct"+executorServiceClass); //System.out.println(); Method[] methods = executorServiceClass.getDeclaredMethods(); for (Method method : methods) { Annotation[] annotations = method.getDeclaredAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof ExecutorServiceAnnot) { executorServiceAnnot = (ExecutorServiceAnnot) annotation; //if(servicesMap.get(executorServiceAnnot.servicename())==null)throw new Exception(); servicesMap.remove(executorServiceAnnot.servicename()); } } } } }
From source file:com.app.services.ExecutorServicesConstruct.java
/** * This method removes the configuration of the War file * @param servicesMap//w w w . j a v a2 s .c o m * @param exectorServicesXml * @param customClassLoader * @throws Exception */ public void removeExecutorServices(Hashtable servicesMap, File exectorServicesXml, WebClassLoader customClassLoader) throws Exception { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/executorservices-config.xml"))); } catch (Exception e) { log.error("Could not able to load xml rules ./config/executorservices-config.xml", e); // TODO Auto-generated catch block //e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); ExecutorServices executorServices = (ExecutorServices) serverdigester .parse(new InputSource(new FileInputStream(exectorServicesXml))); CopyOnWriteArrayList<ExecutorService> executorServicesList = executorServices.getExecutorServices(); ExecutorServiceAnnot executorServiceAnnot; for (ExecutorService executorService : executorServicesList) { Class executorServiceClass = customClassLoader .loadClass(executorService.getExecutorserviceclass().toString()); //log.info("executor class in ExecutorServicesConstruct"+executorServiceClass); //log.info(); Method[] methods = executorServiceClass.getDeclaredMethods(); for (Method method : methods) { Annotation[] annotations = method.getDeclaredAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof ExecutorServiceAnnot) { executorServiceAnnot = (ExecutorServiceAnnot) annotation; //if(servicesMap.get(executorServiceAnnot.servicename())==null)throw new Exception(); servicesMap.remove(executorServiceAnnot.servicename()); } } } } }
From source file:com.web.server.WarDeployer.java
public WarDeployer(String scanDirectory, String farmwarDir, String clusterGroup, Hashtable urlClassLoaderMap, Hashtable executorServiceMap, Hashtable messagingClassMap, ConcurrentHashMap servletMapping, MessagingElem messagingElem, ConcurrentHashMap sessionObjects) { this.scanDirectory = scanDirectory; this.urlClassLoaderMap = urlClassLoaderMap; this.executorServiceMap = executorServiceMap; this.messagingClassMap = messagingClassMap; this.servletMapping = servletMapping; this.sessionObjects = sessionObjects; farmWarFileTransfer = FarmWarFileTransfer.getInstance(scanDirectory + "/", farmwarDir, clusterGroup); try {/*from w w w .jav a2 s .co m*/ farmWarFileTransfer.start(); } catch (Exception e2) { // TODO Auto-generated catch block e2.printStackTrace(); } try { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/executorservices-config.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); serverdigester = serverdigesterLoader.newDigester(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/messagingclass-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); messagedigester = serverdigesterLoader.newDigester(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/webxml-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); webxmldigester = serverdigesterLoader.newDigester(); } catch (Exception ex) { //ex.printStackTrace(); } synchronized (messagingElem) { this.messagingElem = messagingElem; ConcurrentHashMap randomQueue = messagingElem.randomQueue; Set<String> randomQueueSet = randomQueue.keySet(); Iterator<String> ite = randomQueueSet.iterator(); while (ite.hasNext()) { Queue queue = (Queue) randomQueue.get(ite.next()); ConcurrentHashMap randomqueuemap = (ConcurrentHashMap) messagingClassMap.get("RandomQueue"); if (randomqueuemap == null) { randomqueuemap = new ConcurrentHashMap(); messagingClassMap.put("RandomQueue", randomqueuemap); } CopyOnWriteArrayList randomqueuelist = (CopyOnWriteArrayList) randomqueuemap .get(queue.getQueuename()); if (randomqueuelist == null) randomqueuemap.put(queue.getQueuename(), new CopyOnWriteArrayList()); } ConcurrentHashMap roundrobinQueue = messagingElem.roundrobinQueue; Set<String> roundrobinQueueSet = roundrobinQueue.keySet(); ite = roundrobinQueueSet.iterator(); while (ite.hasNext()) { Queue queue = (Queue) roundrobinQueue.get(ite.next()); ConcurrentHashMap roundrobinqueuemap = (ConcurrentHashMap) messagingClassMap.get("RoundRobinQueue"); if (roundrobinqueuemap == null) { roundrobinqueuemap = new ConcurrentHashMap(); messagingClassMap.put("RoundRobinQueue", roundrobinqueuemap); } CopyOnWriteArrayList randomqueuelist = (CopyOnWriteArrayList) roundrobinqueuemap .get(queue.getQueuename()); if (randomqueuelist == null) roundrobinqueuemap.put(queue.getQueuename(), new CopyOnWriteArrayList()); } ConcurrentHashMap topicMap = messagingElem.topicMap; Set<String> topicSet = topicMap.keySet(); Iterator<String> iter = topicSet.iterator(); while (iter.hasNext()) { Topic topic = (Topic) topicMap.get(iter.next()); ConcurrentHashMap topicmap = (ConcurrentHashMap) messagingClassMap.get("Topic"); if (topicmap == null) { topicmap = new ConcurrentHashMap(); messagingClassMap.put("Topic", topicmap); } CopyOnWriteArrayList randomqueuelist = (CopyOnWriteArrayList) topicmap.get(topic.getTopicname()); if (randomqueuelist == null) topicmap.put(topic.getTopicname(), new CopyOnWriteArrayList()); } System.out.println(messagingClassMap); } }
From source file:com.web.server.SARDeployer.java
/** * This method is the implementation of the SAR deployer *//*from w w w . j a v a 2 s . co m*/ public void run() { String filePath; FileInfo fileinfoTmp; ConcurrentHashMap filePrevMap = new ConcurrentHashMap(); ConcurrentHashMap fileCurrMap = new ConcurrentHashMap(); ; FileInfo filePrevLastModified; FileInfo fileCurrLastModified; DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/sar-config.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); sardigester = serverdigesterLoader.newDigester(); while (true) { try { File file = new File(deployDirectory); File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) continue; //Long lastModified=(Long) fileMap.get(files[i].getName()); if (files[i].getName().toLowerCase().endsWith(".sar")) { filePath = files[i].getAbsolutePath(); //logger.info("filePath"+filePath); filePath = filePath.substring(0, filePath.toLowerCase().lastIndexOf(".sar")); File sarDirectory = new File(filePath + "sar"); fileinfoTmp = new FileInfo(); fileinfoTmp.setFile(files[i]); fileinfoTmp.setLastModified(files[i].lastModified()); if (!sarDirectory.exists() || fileCurrMap.get(files[i].getName()) == null && filePrevMap.get(files[i].getName()) == null) { if (sarDirectory.exists()) { deleteDir(sarDirectory); } try { extractSar(files[i], sarDirectory.getAbsolutePath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //System.out.println("War Deployed Successfully in path: "+filePath); numberOfSarDeployed++; logger.info(files[i] + " Deployed"); sarsDeployed.add(files[i].getName()); filePrevMap.put(files[i].getName(), fileinfoTmp); } fileCurrMap.put(files[i].getName(), fileinfoTmp); } /*if(lastModified==null||lastModified!=files[i].lastModified()){ fileMap.put(files[i].getName(),files[i].lastModified()); }*/ } Set keyset = fileCurrMap.keySet(); Iterator ite = keyset.iterator(); String fileName; while (ite.hasNext()) { fileName = (String) ite.next(); //logger.info("fileName"+fileName); filePrevLastModified = (FileInfo) filePrevMap.get(fileName); fileCurrLastModified = (FileInfo) fileCurrMap.get(fileName); if (filePrevLastModified != null) //logger.info("lastmodified="+filePrevLastModified.getLastModified()); //System.out.println("prevmodified"+fileCurrLastModified.getLastModified()+""+filePrevLastModified.getLastModified()); if (fileCurrLastModified != null) { //System.out.println("prevmodified"+fileCurrLastModified.getLastModified()); } if (filePrevLastModified == null || filePrevLastModified.getLastModified() != fileCurrLastModified.getLastModified()) { filePath = fileCurrLastModified.getFile().getAbsolutePath(); //logger.info("filePath"+filePath); filePath = filePath.substring(0, filePath.toLowerCase().lastIndexOf(".sar")); File sarDirectory = new File(filePath + "sar"); //logger.info("WARDIRECTORY="+warDirectory.getAbsolutePath()); if (sarDirectory.exists() && sarDirectory.isDirectory()) { deleteDir(sarDirectory); sarsDeployed.remove(fileName); numberOfSarDeployed--; } try { extractSar(fileCurrLastModified.getFile(), sarDirectory.getAbsolutePath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //System.out.println("War Deployed Successfully in path: "+fileCurrLastModified.getFile().getAbsolutePath()); numberOfSarDeployed++; sarsDeployed.add(fileName); logger.info(filePath + ".sar Deployed"); } } keyset = filePrevMap.keySet(); ite = keyset.iterator(); while (ite.hasNext()) { fileName = (String) ite.next(); filePrevLastModified = (FileInfo) filePrevMap.get(fileName); fileCurrLastModified = (FileInfo) fileCurrMap.get(fileName); if (fileCurrLastModified == null) { filePath = filePrevLastModified.getFile().getAbsolutePath(); filePath = filePath.substring(0, filePath.toLowerCase().lastIndexOf(".sar")); logger.info("filePath" + filePath); File deleteDirectory = new File(filePath + "sar"); deleteDir(deleteDirectory); numberOfSarDeployed--; sarsDeployed.remove(fileName); logger.info(filePath + ".sar Undeployed"); } } filePrevMap.keySet().removeAll(filePrevMap.keySet()); filePrevMap.putAll(fileCurrMap); fileCurrMap.keySet().removeAll(fileCurrMap.keySet()); //System.out.println("filePrevMap="+filePrevMap); //System.out.println("fileCurrMap="+fileCurrMap); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); System.out.println("Sar Deployed"); } } }
From source file:com.app.server.SARDeployer.java
@Override public void init(Vector serviceList, ServerConfig serverConfig, MBeanServer server) { // TODO Auto-generated method stub this.serviceList = serviceList; this.serverConfig = serverConfig; this.mbeanServer = server; DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/sar-config.xml"))); } catch (Exception e) { log.error("Could not able to load the rules file sar-config.xml", e); // TODO Auto-generated catch block e.printStackTrace();//from ww w .j a va 2s . c om } } }); sardigester = serverdigesterLoader.newDigester(); log.info("initialized"); }
From source file:com.app.server.WarDeployer.java
public void init(Vector serviceList, ServerConfig serverConfig, MBeanServer mbeanServer) { try {//w w w .j a va2s .c om this.serviceList = serviceList; this.serverConfig = serverConfig; this.mbeanServer = mbeanServer; this.scanDirectory = serverConfig.getDeploydirectory(); DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { try { loadXMLRules(new InputSource(new FileInputStream("./config/executorservices-config.xml"))); } catch (Exception e) { log.error("Could not able to load config xml rules ./config/executorservices-config.xml", e); //e.printStackTrace(); } } }); serverdigester = serverdigesterLoader.newDigester(); } catch (Exception e1) { log.error("Could not create digester executorservices-config.xml", e1); //e1.printStackTrace(); } try { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { try { loadXMLRules(new InputSource(new FileInputStream("./config/messagingclass-rules.xml"))); } catch (FileNotFoundException e) { log.error("Could not able to load config xml rules ./config/messagingclass-rules.xml", e); //e.printStackTrace(); } } }); messagedigester = serverdigesterLoader.newDigester(); DigesterLoader messagingdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/messagingconfig-rules.xml"))); } catch (Exception e) { log.error("Could not able to load xml config file ./config/messagingclass-rules.xml", e); e.printStackTrace(); } } }); Digester messagingdigester = messagingdigesterLoader.newDigester(); messagingElem = (MessagingElem) messagingdigester .parse(new InputSource(new FileInputStream("./config/messaging.xml"))); synchronized (messagingElem) { ConcurrentHashMap randomQueue = messagingElem.randomQueue; Set<String> randomQueueSet = randomQueue.keySet(); Iterator<String> ite = randomQueueSet.iterator(); while (ite.hasNext()) { Queue queue = (Queue) randomQueue.get(ite.next()); ConcurrentHashMap randomqueuemap = (ConcurrentHashMap) messagingClassMap.get("RandomQueue"); if (randomqueuemap == null) { randomqueuemap = new ConcurrentHashMap(); messagingClassMap.put("RandomQueue", randomqueuemap); } CopyOnWriteArrayList randomqueuelist = (CopyOnWriteArrayList) randomqueuemap .get(queue.getQueuename()); if (randomqueuelist == null) randomqueuemap.put(queue.getQueuename(), new CopyOnWriteArrayList()); } ConcurrentHashMap roundrobinQueue = messagingElem.roundrobinQueue; Set<String> roundrobinQueueSet = roundrobinQueue.keySet(); ite = roundrobinQueueSet.iterator(); while (ite.hasNext()) { Queue queue = (Queue) roundrobinQueue.get(ite.next()); ConcurrentHashMap roundrobinqueuemap = (ConcurrentHashMap) messagingClassMap .get("RoundRobinQueue"); if (roundrobinqueuemap == null) { roundrobinqueuemap = new ConcurrentHashMap(); messagingClassMap.put("RoundRobinQueue", roundrobinqueuemap); } CopyOnWriteArrayList randomqueuelist = (CopyOnWriteArrayList) roundrobinqueuemap .get(queue.getQueuename()); if (randomqueuelist == null) roundrobinqueuemap.put(queue.getQueuename(), new CopyOnWriteArrayList()); } ConcurrentHashMap topicMap = messagingElem.topicMap; Set<String> topicSet = topicMap.keySet(); Iterator<String> iter = topicSet.iterator(); while (iter.hasNext()) { Topic topic = (Topic) topicMap.get(iter.next()); ConcurrentHashMap topicmap = (ConcurrentHashMap) messagingClassMap.get("Topic"); if (topicmap == null) { topicmap = new ConcurrentHashMap(); messagingClassMap.put("Topic", topicmap); } CopyOnWriteArrayList randomqueuelist = (CopyOnWriteArrayList) topicmap .get(topic.getTopicname()); if (randomqueuelist == null) topicmap.put(topic.getTopicname(), new CopyOnWriteArrayList()); } //log.info(messagingClassMap); } } catch (Exception e1) { log.error("", e1); //e1.printStackTrace(); } try { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { try { loadXMLRules(new InputSource(new FileInputStream("./config/webxml-rules.xml"))); } catch (FileNotFoundException e) { log.error("could not able to load xml config rules ./config/webxml-rules.xml", e); //e.printStackTrace(); } } }); webxmldigester = serverdigesterLoader.newDigester(); } catch (Exception ex) { log.error("could not able to create web.xml digester", ex); // ex.printStackTrace(); } log.info("initialized"); }
From source file:com.web.server.WebServer.java
/** * This is the start of the all the services in web server * @param args/*from w w w .j a v a 2 s. co m*/ * @throws IOException * @throws SAXException */ public static void main(String[] args) throws IOException, SAXException { Hashtable urlClassLoaderMap = new Hashtable(); Hashtable executorServicesMap = new Hashtable(); Hashtable ataMap = new Hashtable<String, ATAConfig>(); Hashtable messagingClassMap = new Hashtable(); ConcurrentHashMap servletMapping = new ConcurrentHashMap(); DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); final ServerConfig serverconfig = (ServerConfig) serverdigester .parse(new InputSource(new FileInputStream("./config/serverconfig.xml"))); DigesterLoader messagingdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/messagingconfig-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Digester messagingdigester = messagingdigesterLoader.newDigester(); MessagingElem messagingconfig = (MessagingElem) messagingdigester .parse(new InputSource(new FileInputStream("./config/messaging.xml"))); //System.out.println(messagingconfig); ////System.out.println(serverconfig.getDeploydirectory()); PropertyConfigurator.configure("log4j.properties"); /*MemcachedClient cache=new MemcachedClient( new InetSocketAddress("localhost", 1000));*/ // Store a value (async) for one hour //c.set("someKey", 36, new String("arun")); // Retrieve a value. System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming"); ExecutorService executor = java.util.concurrent.Executors.newCachedThreadPool(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = null; try { name = new ObjectName("com.web.server:type=WarDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } WarDeployer warDeployer = new WarDeployer(serverconfig.getDeploydirectory(), serverconfig.getFarmWarDir(), serverconfig.getClustergroup(), urlClassLoaderMap, executorServicesMap, messagingClassMap, servletMapping, messagingconfig, sessionObjects); warDeployer.setPriority(MIN_PRIORITY); try { mbs.registerMBean(warDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //warDeployer.start(); executor.execute(warDeployer); ServerSocketChannel serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.bind(new InetSocketAddress("0.0.0.0", Integer.parseInt(serverconfig.getPort()))); serverSocketChannel.configureBlocking(false); final byte[] shutdownBt = new byte[50]; WebServerRequestProcessor webserverRequestProcessor = new WebServer().new WebServerRequestProcessor( servletMapping, urlClassLoaderMap, serverSocketChannel, serverconfig.getDeploydirectory(), Integer.parseInt(serverconfig.getShutdownport()), 1); webserverRequestProcessor.setPriority(MIN_PRIORITY); try { name = new ObjectName("com.web.server:type=WebServerRequestProcessor"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //webserverRequestProcessor.start(); executor.execute(webserverRequestProcessor); for (int i = 0; i < 10; i++) { WebServerRequestProcessor webserverRequestProcessor1 = new WebServer().new WebServerRequestProcessor( servletMapping, urlClassLoaderMap, serverSocketChannel, serverconfig.getDeploydirectory(), Integer.parseInt(serverconfig.getShutdownport()), 2); webserverRequestProcessor1.setPriority(MIN_PRIORITY); try { name = new ObjectName("com.web.server:type=WebServerRequestProcessor" + (i + 1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverRequestProcessor1, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(webserverRequestProcessor1); } ServerSocketChannel serverSocketChannelServices = ServerSocketChannel.open(); serverSocketChannelServices .bind(new InetSocketAddress("0.0.0.0", Integer.parseInt(serverconfig.getServicesport()))); serverSocketChannelServices.configureBlocking(false); ExecutorServiceThread executorService = new ExecutorServiceThread(serverSocketChannelServices, executorServicesMap, Integer.parseInt(serverconfig.getShutdownport()), ataMap, urlClassLoaderMap, serverconfig.getDeploydirectory(), serverconfig.getServicesdirectory(), serverconfig.getEarservicesdirectory(), serverconfig.getNodesport()); try { name = new ObjectName("com.web.services:type=ExecutorServiceThread"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(executorService, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //executorService.start(); executor.execute(executorService); for (int i = 0; i < 10; i++) { ExecutorServiceThread executorService1 = new ExecutorServiceThread(serverSocketChannelServices, executorServicesMap, Integer.parseInt(serverconfig.getShutdownport()), ataMap, urlClassLoaderMap, serverconfig.getDeploydirectory(), serverconfig.getServicesdirectory(), serverconfig.getEarservicesdirectory(), serverconfig.getNodesport()); try { name = new ObjectName("com.web.services:type=ExecutorServiceThread" + (i + 1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(executorService1, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(executorService1); } WebServerHttpsRequestProcessor webserverHttpsRequestProcessor = new WebServer().new WebServerHttpsRequestProcessor( servletMapping, urlClassLoaderMap, Integer.parseInt(serverconfig.getHttpsport()), serverconfig.getDeploydirectory(), Integer.parseInt(serverconfig.getShutdownport()), serverconfig.getHttpscertificatepath(), serverconfig.getHttpscertificatepasscode(), 1); try { name = new ObjectName("com.web.server:type=WebServerHttpsRequestProcessor"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverHttpsRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } webserverHttpsRequestProcessor.setPriority(MAX_PRIORITY); //webserverRequestProcessor.start(); executor.execute(webserverHttpsRequestProcessor); /* for(int i=0;i<2;i++){ webserverHttpsRequestProcessor=new WebServer().new WebServerHttpsRequestProcessor(urlClassLoaderMap,Integer.parseInt(serverconfig.getHttpsport())+(i+1),serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),serverconfig.getHttpscertificatepath(),serverconfig.getHttpscertificatepasscode(),1); try { name = new ObjectName("com.web.server:type=WebServerHttpsRequestProcessor"+(i+1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverHttpsRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(webserverHttpsRequestProcessor); }*/ /*ATAServer ataServer=new ATAServer(serverconfig.getAtaaddress(),serverconfig.getAtaport(),ataMap); try { name = new ObjectName("com.web.services:type=ATAServer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ataServer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ataServer.start();*/ /*ATAConfigClient ataClient=new ATAConfigClient(serverconfig.getAtaaddress(),serverconfig.getAtaport(),serverconfig.getServicesport(),executorServicesMap); try { name = new ObjectName("com.web.services:type=ATAConfigClient"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ataClient, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ataClient.start();*/ MessagingServer messageServer = new MessagingServer(serverconfig.getMessageport(), messagingClassMap); try { name = new ObjectName("com.web.messaging:type=MessagingServer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(messageServer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //messageServer.start(); executor.execute(messageServer); RandomQueueMessagePicker randomqueuemessagepicker = new RandomQueueMessagePicker(messagingClassMap); try { name = new ObjectName("com.web.messaging:type=RandomQueueMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(randomqueuemessagepicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //randomqueuemessagepicker.start(); executor.execute(randomqueuemessagepicker); RoundRobinQueueMessagePicker roundrobinqueuemessagepicker = new RoundRobinQueueMessagePicker( messagingClassMap); try { name = new ObjectName("com.web.messaging:type=RoundRobinQueueMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(roundrobinqueuemessagepicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //roundrobinqueuemessagepicker.start(); executor.execute(roundrobinqueuemessagepicker); TopicMessagePicker topicpicker = new TopicMessagePicker(messagingClassMap); try { name = new ObjectName("com.web.messaging:type=TopicMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(topicpicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //topicpicker.start(); executor.execute(topicpicker); try { name = new ObjectName("com.web.server:type=SARDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } SARDeployer sarDeployer = SARDeployer.newInstance(serverconfig.getDeploydirectory()); try { mbs.registerMBean(sarDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(sarDeployer); /*try { mbs.invoke(name, "startDeployer", null, null); } catch (InstanceNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ReflectionException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory"); System.setProperty(Context.PROVIDER_URL, "rmi://localhost:" + serverconfig.getServicesregistryport()); ; Registry registry = LocateRegistry.createRegistry(Integer.parseInt(serverconfig.getServicesregistryport())); /*JarDeployer jarDeployer=new JarDeployer(registry,serverconfig.getServicesdirectory(), serverconfig.getServiceslibdirectory(),serverconfig.getCachedir(),executorServicesMap, urlClassLoaderMap); try { name = new ObjectName("com.web.server:type=JarDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(jarDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //jarDeployer.start(); executor.execute(jarDeployer);*/ EARDeployer earDeployer = new EARDeployer(registry, serverconfig.getEarservicesdirectory(), serverconfig.getDeploydirectory(), executorServicesMap, urlClassLoaderMap, serverconfig.getCachedir(), warDeployer); try { name = new ObjectName("com.web.server:type=EARDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(earDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //earDeployer.start(); executor.execute(earDeployer); JVMConsole jvmConsole = new JVMConsole(Integer.parseInt(serverconfig.getJvmConsolePort())); try { name = new ObjectName("com.web.server:type=JVMConsole"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(jvmConsole, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(jvmConsole); ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); XMLDeploymentScanner xmlDeploymentScanner = new XMLDeploymentScanner(serverconfig.getDeploydirectory(), serverconfig.getServiceslibdirectory()); exec.scheduleAtFixedRate(xmlDeploymentScanner, 0, 1000, TimeUnit.MILLISECONDS); EmbeddedJMS embeddedJMS = null; try { embeddedJMS = new EmbeddedJMS(); embeddedJMS.start(); } catch (Exception ex) { // TODO Auto-generated catch block ex.printStackTrace(); } EJBDeployer ejbDeployer = new EJBDeployer(serverconfig.getServicesdirectory(), registry, Integer.parseInt(serverconfig.getServicesregistryport()), embeddedJMS); try { name = new ObjectName("com.web.server:type=EJBDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ejbDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //jarDeployer.start(); executor.execute(ejbDeployer); new Thread() { public void run() { try { ServerSocket serverSocket = new ServerSocket(Integer.parseInt(serverconfig.getShutdownport())); while (true) { Socket sock = serverSocket.accept(); InputStream istream = sock.getInputStream(); istream.read(shutdownBt); String shutdownStr = new String(shutdownBt); String[] shutdownToken = shutdownStr.split("\r\n\r\n"); //System.out.println(shutdownStr); if (shutdownToken[0].startsWith("shutdown WebServer")) { synchronized (shutDownObject) { shutDownObject.notifyAll(); } } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { System.out.println("IN shutdown Hook"); synchronized (shutDownObject) { shutDownObject.notifyAll(); } } })); try { synchronized (shutDownObject) { shutDownObject.wait(); } executor.shutdownNow(); serverSocketChannel.close(); serverSocketChannelServices.close(); embeddedJMS.stop(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println("IN shutdown Hook1"); /*try{ Thread.sleep(10000); } catch(Exception ex){ }*/ //webserverRequestProcessor.stop(); //webserverRequestProcessor1.stop(); /*warDeployer.stop(); executorService.stop(); //ataServer.stop(); //ataClient.stop(); messageServer.stop(); randomqueuemessagepicker.stop(); roundrobinqueuemessagepicker.stop(); topicpicker.stop();*/ /*try { mbs.invoke(new ObjectName("com.web.server:type=SARDeployer"), "destroyDeployer", null, null); } catch (InstanceNotFoundException | MalformedObjectNameException | ReflectionException | MBeanException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ //earDeployer.stop(); System.exit(0); }