Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

maven refactor

  • Loading branch information...
commit 6e3f4dd0c141c004db6e353fffb73b4b7408c1bd 1 parent 1539779
@javasoze javasoze authored
View
0  contrib/dataproviders/jms/build.xml → zoie-jms/build.xml
File renamed without changes
View
0  contrib/dataproviders/jms/ivy.xml → zoie-jms/ivy.xml
File renamed without changes
View
70 zoie-jms/pom.xml
@@ -0,0 +1,70 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>com.sna-projects.zoie</groupId>
+ <artifactId>zoie-parent</artifactId>
+ <version>2.5.1-SNAPSHOT</version>
+ <relativePath>../zoie-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>zoie-jms</artifactId>
+ <packaging>jar</packaging>
+ <name>zoie-jms</name>
+ <description>zoie jms data provider</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>zoie-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+</project>
View
0  .../proj/zoie/dataprovider/jms/DataEventBuilder.java → .../proj/zoie/dataprovider/jms/DataEventBuilder.java
File renamed without changes
View
0  .../zoie/dataprovider/jms/JMSStreamDataProvider.java → .../zoie/dataprovider/jms/JMSStreamDataProvider.java
File renamed without changes
View
0  ...java/proj/zoie/dataprovider/jms/TopicFactory.java → ...java/proj/zoie/dataprovider/jms/TopicFactory.java
File renamed without changes
View
0  ...e/dataprovider/jms/TestJMSStreamDataProvider.java → ...e/dataprovider/jms/TestJMSStreamDataProvider.java
File renamed without changes
View
201 zoie-server/src/main/java/proj/zoie/server/ZoieServer.java
@@ -0,0 +1,201 @@
+package proj.zoie.server;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.thread.QueuedThreadPool;
+
+
+public class ZoieServer {
+ private static final Logger log = Logger.getLogger(ZoieServer.class);
+ /**
+ * @param args
+ */
+ @SuppressWarnings("unchecked")
+ public static void main(String[] args) throws Exception {
+ String confDirName=System.getProperty("conf.dir");
+ File confDir = null;
+ if (confDirName == null)
+ {
+ confDir = new File("conf");
+ }
+ else
+ {
+ confDir = new File(confDirName);
+ }
+
+ System.out.println("using config dir: "+confDir.getAbsolutePath());
+
+ Properties props = new Properties();
+ File serverPropFile = new File(confDir,"server.properties");
+ if (confDir.exists() && serverPropFile.exists())
+ {
+ FileInputStream fin =null;
+ try
+ {
+ fin = new FileInputStream(serverPropFile);
+ props.load(fin);
+ }
+ catch(Exception e)
+ {
+ log.error("propblem loading conf file, using default settings...");
+ }
+ finally
+ {
+ if (fin!=null)
+ {
+ fin.close();
+ }
+ }
+ }
+
+ log.info("loaded properties: "+props);
+
+ String warDirName = props.getProperty("war.dir");
+ if (warDirName == null) throw new IllegalArgumentException("war.dir property not specified");
+ File warDir = new File(warDirName);
+
+ int minThread;
+ try
+ {
+ minThread=Integer.parseInt(props.getProperty("min.thread"));
+ }
+ catch(Exception e)
+ {
+ log.error("defaulting min.thread to 50");
+ minThread=50;
+ }
+
+ int maxThread;
+ try
+ {
+ maxThread=Integer.parseInt(props.getProperty("max.thread"));
+ }
+ catch(Exception e)
+ {
+ log.error("defaulting max.thread to 75");
+ maxThread=75;
+ }
+
+
+ int maxIdleTime;
+ try
+ {
+ maxIdleTime=Integer.parseInt(props.getProperty("max.ideltime"));
+ }
+ catch(Exception e)
+ {
+ log.error("defaulting max.ideltime to 2000");
+ maxIdleTime=2000;
+ }
+
+ QueuedThreadPool threadPool = new QueuedThreadPool();
+ threadPool.setName("server(jetty) threads");
+ threadPool.setMinThreads(minThread);
+ threadPool.setMaxThreads(maxThread);
+ threadPool.setMaxIdleTimeMs(maxIdleTime);
+ threadPool.start();
+
+ log.info("request threadpool started.");
+
+ final Server server = new Server();
+ server.setThreadPool(threadPool);
+
+ log.info("loading properties: "+props);
+ System.getProperties().putAll(props);
+
+ String indexDir = props.getProperty("index.directory");
+
+ SelectChannelConnector connector = new SelectChannelConnector();
+ int serverPort;
+ try
+ {
+ serverPort = Integer.parseInt(props.getProperty("server.port"));
+ }
+ catch(Exception e)
+ {
+ log.warn("server port defaulting to 8888");
+ serverPort=8888;
+ }
+ connector.setPort(serverPort);
+ server.addConnector(connector);
+
+ File[] warFiles = warDir.listFiles(new FileFilter(){
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory()) return true;
+ String name = pathname.getName();
+ return name.endsWith(".war");
+ }
+ });
+
+ log.info("loading wars...");
+ for (File warFile : warFiles)
+ {
+ try
+ {
+ WebAppContext web = new WebAppContext();
+ String fileName=warFile.getName();
+ log.info("loading war: "+fileName);
+ if (!warFile.isDirectory()){
+ int index = fileName.lastIndexOf(".war");
+ fileName = fileName.substring(0, index);
+ web.setExtractWAR(true);
+ }
+ web.setContextPath("/"+fileName);
+ log.info("context path: /"+fileName);
+ web.setWar(warFile.getAbsolutePath());
+ if (indexDir!=null)
+ {
+ web.setAttribute("index.directory", indexDir);
+ }
+ server.addHandler(web);
+ }
+ catch(Exception e)
+ {
+ log.error("Problem deploying application: "+warFile,e);
+ }
+ }
+
+ log.info("finished loading wars.");
+
+ Runtime.getRuntime().addShutdownHook(new Thread(){
+ public void run()
+ {
+ log.info("shutting down...");
+ try {
+ server.stop();
+ } catch (Exception e) {
+ log.error(e.getMessage(),e);
+ }
+ finally
+ {
+ server.destroy();
+ log.info("shutdown successful");
+ }
+ }
+ });
+
+ try {
+ log.info("starting server ... ");
+ server.start();
+ log.info("server started.");
+ } catch (Exception e) {
+ log.error(e.getMessage(),e);
+ }
+
+ try
+ {
+ server.join();
+ }
+ catch(Exception e)
+ {
+ System.exit(100);
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.