You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ch...@apache.org on 2013/01/31 18:48:19 UTC

[1/3] git commit: SQOOP-850: Move server initialization from server module to core

SQOOP-850: Move server initialization from server module to core

(Jarcec Cecho via Cheolsoo Park)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/8f074b07
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/8f074b07
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/8f074b07

Branch: refs/heads/sqoop2
Commit: 8f074b07fcfef90f029d23c0e24374d329955ab0
Parents: 199b06c
Author: Cheolsoo Park <ch...@apache.org>
Authored: Thu Jan 31 09:46:47 2013 -0800
Committer: Cheolsoo Park <ch...@apache.org>
Committed: Thu Jan 31 09:47:56 2013 -0800

----------------------------------------------------------------------
 .../java/org/apache/sqoop/core/SqoopServer.java    |   54 +++++++++++++++
 .../org/apache/sqoop/server/ServerInitializer.java |   30 +-------
 2 files changed, 58 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/8f074b07/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/core/SqoopServer.java b/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
new file mode 100644
index 0000000..84896d6
--- /dev/null
+++ b/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.core;
+
+import org.apache.log4j.Logger;
+import org.apache.sqoop.connector.ConnectorManager;
+import org.apache.sqoop.framework.FrameworkManager;
+import org.apache.sqoop.repository.RepositoryManager;
+
+/**
+ * Entry point for initializing and destroying Sqoop server
+ */
+public class SqoopServer {
+
+  private static final Logger LOG = Logger.getLogger(SqoopServer.class);
+
+  public static void destroy() {
+    LOG.info("Shutting down Sqoop server");
+    FrameworkManager.getInstance().destroy();
+    ConnectorManager.getInstance().destroy();
+    RepositoryManager.getInstance().destroy();
+    SqoopConfiguration.getInstance().destroy();
+    LOG.info("Sqoop server has been correctly terminated");
+  }
+
+  public static void initialize() {
+    try {
+      LOG.info("Booting up Sqoop server");
+      SqoopConfiguration.getInstance().initialize();
+      RepositoryManager.getInstance().initialize();
+      ConnectorManager.getInstance().initialize();
+      FrameworkManager.getInstance().initialize();
+      LOG.info("Sqoop server has successfully boot up");
+    } catch (Exception ex) {
+      LOG.error("Server startup failure", ex);
+      throw new RuntimeException("Failure in server initialization", ex);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8f074b07/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java b/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
index 5998e01..44aea2e 100644
--- a/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
+++ b/server/src/main/java/org/apache/sqoop/server/ServerInitializer.java
@@ -17,44 +17,22 @@
  */
 package org.apache.sqoop.server;
 
+import org.apache.sqoop.core.SqoopServer;
+
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import org.apache.log4j.Logger;
-import org.apache.sqoop.connector.ConnectorManager;
-import org.apache.sqoop.core.SqoopConfiguration;
-import org.apache.sqoop.framework.FrameworkManager;
-import org.apache.sqoop.repository.RepositoryManager;
-
 /**
  * Initializes the Sqoop server. This listener is also responsible for
  * cleaning up any resources occupied by the server during the system shutdown.
  */
 public class ServerInitializer implements ServletContextListener {
 
-  private static final Logger LOG =
-      Logger.getLogger(ServerInitializer.class);
-
   public void contextDestroyed(ServletContextEvent arg0) {
-    LOG.info("Shutting down Sqoop server");
-    FrameworkManager.getInstance().destroy();
-    ConnectorManager.getInstance().destroy();
-    RepositoryManager.getInstance().destroy();
-    SqoopConfiguration.getInstance().destroy();
-    LOG.info("Sqoop server has been correctly terminated");
+    SqoopServer.destroy();
   }
 
   public void contextInitialized(ServletContextEvent arg0) {
-    try {
-      LOG.info("Booting up Sqoop server");
-      SqoopConfiguration.getInstance().initialize();
-      RepositoryManager.getInstance().initialize();
-      ConnectorManager.getInstance().initialize();
-      FrameworkManager.getInstance().initialize();
-      LOG.info("Sqoop server has successfully boot up");
-    } catch (Exception ex) {
-      LOG.error("Server startup failure", ex);
-      throw new RuntimeException("Failure in server initialization", ex);
-    }
+    SqoopServer.initialize();
   }
 }