tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andygumbre...@apache.org
Subject svn commit: r1029733 - in /openejb/trunk/openejb3: assembly/openejb-standalone/ assembly/openejb-standalone/src/main/assembly/ assembly/openejb-standalone/src/main/resources/ server/ server/openejb-daemon/ server/openejb-daemon/src/ server/openejb-daem...
Date Mon, 01 Nov 2010 16:28:26 GMT
Author: andygumbrecht
Date: Mon Nov  1 16:28:25 2010
New Revision: 1029733

URL: http://svn.apache.org/viewvc?rev=1029733&view=rev
Log:
Run OpenEJB as a Windows NT Service.
Tested on Windows XP/Vista/7/2008 32 and 64 bit.

Added:
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.amd64.exe
  (with props)
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.ia64.exe
  (with props)
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.x86.exe
  (with props)
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.install.as.admin.bat
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.readme.txt
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.remove.as.admin.bat
    openejb/trunk/openejb3/server/openejb-daemon/
    openejb/trunk/openejb3/server/openejb-daemon/pom.xml
    openejb/trunk/openejb3/server/openejb-daemon/src/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/java/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/daemon/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/daemon/NTService.java
    openejb/trunk/openejb3/server/openejb-daemon/src/main/resources/
    openejb/trunk/openejb3/server/openejb-daemon/src/main/resources/META-INF/
    openejb/trunk/openejb3/server/openejb-daemon/src/test/
    openejb/trunk/openejb3/server/openejb-daemon/src/test/java/
    openejb/trunk/openejb3/server/openejb-daemon/src/test/resources/
Modified:
    openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml
    openejb/trunk/openejb3/assembly/openejb-standalone/src/main/assembly/bin.xml
    openejb/trunk/openejb3/server/pom.xml

Modified: openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml?rev=1029733&r1=1029732&r2=1029733&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml (original)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml Mon Nov  1 16:28:25 2010
@@ -186,6 +186,12 @@
       <optional>true</optional>
     </dependency>
     <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-daemon</artifactId>
+      <version>${project.version}</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

Modified: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/assembly/bin.xml?rev=1029733&r1=1029732&r2=1029733&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/src/main/assembly/bin.xml (original)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/src/main/assembly/bin.xml Mon Nov 
1 16:28:25 2010
@@ -41,6 +41,7 @@
       <outputDirectory>bin/</outputDirectory>
       <includes>
         <include>*.bat</include>
+        <include>service.readme.txt</include>
       </includes>
       <lineEnding>dos</lineEnding>
       <fileMode>0755</fileMode>
@@ -54,6 +55,13 @@
       <lineEnding>unix</lineEnding>
       <fileMode>0755</fileMode>
     </fileSet>
+	<fileSet>
+      <directory>${basedir}/src/main/resources</directory>
+      <outputDirectory>bin/</outputDirectory>
+      <includes>
+        <include>*.exe</include>
+      </includes>
+    </fileSet>
     <fileSet>
       <directory>${basedir}/src/main/conf</directory>
       <includes>

Added: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.amd64.exe
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.amd64.exe?rev=1029733&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.amd64.exe
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.ia64.exe
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.ia64.exe?rev=1029733&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.ia64.exe
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.x86.exe
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.x86.exe?rev=1029733&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/OpenEJB.x86.exe
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.install.as.admin.bat
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.install.as.admin.bat?rev=1029733&view=auto
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.install.as.admin.bat
(added)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.install.as.admin.bat
Mon Nov  1 16:28:25 2010
@@ -0,0 +1,109 @@
+@ECHO off
+CLS
+
+@IF NOT "%ECHO%" == ""  ECHO %ECHO%
+@IF "%OS%" == "Windows_NT" setlocal
+
+IF "%OS%" == "Windows_NT" (
+  SET "DIRNAME=%~dp0%"
+) ELSE (
+  SET DIRNAME=.\
+)
+
+pushd %DIRNAME%
+
+SET proc=undefined
+
+IF /i %PROCESSOR_ARCHITECTURE% EQU X86 SET proc="%~dp0OpenEJB.%PROCESSOR_ARCHITECTURE%.exe"
+IF /i %PROCESSOR_ARCHITECTURE% EQU AMD64 SET proc="%~dp0OpenEJB.%PROCESSOR_ARCHITECTURE%.exe"
+IF /i %PROCESSOR_ARCHITECTURE% EQU IA64 SET proc=%~dp0OpenEJB.%PROCESSOR_ARCHITECTURE%.exe"
+
+IF /i %proc% EQU undefined (
+	ECHO Failed to determine OS architecture
+	GOTO failed
+)
+
+SET jvm=auto
+REM SET JAVA_HOME=[Full path to JDK or JRE]
+
+REM Prefer a local JRE if we find one in the current directory
+IF EXIST "%~dp0jre" (
+	SET JAVA_HOME="%~dp0"
+	GOTO found_java_home
+)
+
+if not "%JAVA_HOME%" == "" GOTO found_java_home
+
+ECHO Environment variable JAVA_HOME is not set and no local JRE was found.
+ECHO Please set JAVA_HOME to the directory of your local JDK or JRE to avoid this message.
+GOTO skip_java_home
+
+:found_java_home
+
+REM Make an attempt to find either the server or client jvm.dll
+IF EXIST "%JAVA_HOME%\jre\bin\server\jvm.dll" (
+	SET jvm="%JAVA_HOME%\jre\bin\server\jvm.dll"
+) ELSE (
+	IF EXIST "%JAVA_HOME%\jre\bin\client\jvm.dll" (
+		SET jvm="%JAVA_HOME%\jre\bin\client\jvm.dll"
+	) ELSE (
+		IF EXIST "%JAVA_HOME%\bin\server\jvm.dll" (
+			SET jvm="%JAVA_HOME%\bin\server\jvm.dll"
+		) ELSE (
+			IF EXIST "%JAVA_HOME%\bin\client\jvm.dll" (
+				SET jvm="%JAVA_HOME%\bin\client\jvm.dll"
+			) ELSE (
+				ECHO Cannot locate a jvm.dll - Are you sure JAVA_HOME is set correctly?
+				ECHO The service installer will now attempt to locate and use 'any' JVM.
+			)
+		)
+	)
+)
+
+:skip_java_home
+
+SET openejb=.
+CD ..
+
+SET "openejb=%CD%"
+SET logs=%openejb%\logs
+SET lib=%openejb%\lib
+SET corejar="%lib%\openejb-core-*.jar"
+SET daemonjar="%lib%\openejb-daemon-*.jar"
+
+FOR %%a IN (%corejar%) DO (
+  SET corejar="%%a"
+)
+
+FOR %%a IN (%daemonjar%) DO (
+  SET daemonjar="%%a"
+)
+
+SET classpath="%corejar%;%daemonjar%"
+
+ECHO Installing service using JVM: %jvm%
+
+%proc% //IS//OpenEJBServer --DisplayName="OpenEJB Server" ^
+	--Install=%proc% ^
+	--Startup auto ^
+	--StartPath=%openejb% ^
+	--Description="OpenEJB Server Service" ^
+	--Jvm=%jvm% ^
+	--Classpath=%classpath% ^
+	--StartMode=jvm ^
+	--StartClass=org.apache.openejb.daemon.NTService --StartMethod=start ^
+	--StopMode=jvm ^
+	--StopClass=org.apache.openejb.daemon.NTService --StopMethod=stop ^
+	--LogPrefix=service ^
+	--LogPath=%logs% --StdOutput="%logs%\service.out.log" --StdError="%logs%\service.err.log"
--PidFile=service.pid ^
+	--LogLevel=Info ^
+	++JvmOptions=-Dopenejb.home="%openejb%";-Xms128M;-Xmx512M;-XX:MaxPermSize=256M
+	rem ++DependsOn= \
+
+GOTO complete
+
+:failed
+
+ECHO Failed to install service
+
+:complete
\ No newline at end of file

Added: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.readme.txt
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.readme.txt?rev=1029733&view=auto
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.readme.txt
(added)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.readme.txt
Mon Nov  1 16:28:25 2010
@@ -0,0 +1 @@
+Windows NT Service
==================

The two batch files for creating and removing OpenEJB
as a Windows Service are basically
self explanatory. Both scripts must be run using an account
that has rights to install
or de-install a service. This is usually an administrator account.

service.install.as.admin.bat
service.remove.as.admin.bat
\ No newline at end of file

Added: openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.remove.as.admin.bat
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.remove.as.admin.bat?rev=1029733&view=auto
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.remove.as.admin.bat
(added)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/service.remove.as.admin.bat
Mon Nov  1 16:28:25 2010
@@ -0,0 +1,31 @@
+@echo off
+cls
+
+@if not "%ECHO%" == ""  echo %ECHO%
+@if "%OS%" == "Windows_NT" setlocal
+
+if "%OS%" == "Windows_NT" (
+  set "DIRNAME=%~dp0%"
+) else (
+  set DIRNAME=.\
+)
+
+pushd %DIRNAME%
+
+SET proc=undefined
+
+if /i %PROCESSOR_ARCHITECTURE% EQU X86 SET proc="%~dp0OpenEJB.%PROCESSOR_ARCHITECTURE%.exe"
+if /i %PROCESSOR_ARCHITECTURE% EQU AMD64 SET proc="%~dp0OpenEJB.%PROCESSOR_ARCHITECTURE%.exe"
+if /i %PROCESSOR_ARCHITECTURE% EQU IA64 SET proc=%~dp0OpenEJB.%PROCESSOR_ARCHITECTURE%.exe"
+
+if /i %proc% EQU undefined GOTO failed
+
+%proc% //DS//OpenEJBServer
+
+GOTO complete
+
+:failed
+
+ECHO Failed to determine OS architecture
+
+:complete
\ No newline at end of file

Added: openejb/trunk/openejb3/server/openejb-daemon/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-daemon/pom.xml?rev=1029733&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-daemon/pom.xml (added)
+++ openejb/trunk/openejb3/server/openejb-daemon/pom.xml Mon Nov  1 16:28:25 2010
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+<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">
+  <parent>
+    <artifactId>server</artifactId>
+    <groupId>org.apache.openejb</groupId>
+    <version>3.2-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>openejb-daemon</artifactId>
+  <packaging>jar</packaging>
+  <name>OpenEJB :: Server :: Daemon</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-server</artifactId>
+      <version>${project.version}</version>
+    </dependency> 
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
+

Added: openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/daemon/NTService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/daemon/NTService.java?rev=1029733&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/daemon/NTService.java
(added)
+++ openejb/trunk/openejb3/server/openejb-daemon/src/main/java/org/apache/openejb/daemon/NTService.java
Mon Nov  1 16:28:25 2010
@@ -0,0 +1,97 @@
+package org.apache.openejb.daemon;
+
+import org.apache.openejb.cli.Bootstrap;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.Server;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class NTService {
+
+    private static final NTService instance = new NTService();
+    private final AtomicBoolean running = new AtomicBoolean(false);
+
+    /**
+     * Called by Apache Daemon
+     *
+     * @param args Start arguments
+     */
+    public static void start(final String[] args) {
+        try {
+            instance.startImpl(args);
+        } catch (Throwable e) {
+            e.printStackTrace(System.err);
+        }
+    }
+
+    /**
+     * Called by Apache Daemon
+     *
+     * @param args Stop arguments - Not used
+     */
+    public static void stop(final String[] args) {
+        try {
+            instance.stopImpl();
+        } catch (Throwable e) {
+            e.printStackTrace(System.err);
+        }
+    }
+
+    private NTService() {
+    }
+
+    private void startImpl(String[] args) {
+        if (!running.getAndSet(true)) {
+
+            if (null == args) {
+                args = new String[0];
+            }
+
+            if (null == System.getProperty("openejb.home")) {
+                System.setProperty("openejb.home", System.getProperty("user.dir"));
+            }
+
+            final ArrayList<String> list = new ArrayList<String>();
+            list.addAll(Arrays.asList(args));
+
+            if (!list.contains("start")) {
+                list.add("start");
+            }
+
+            try {
+                System.out.println("Starting NTService: " + list);
+                Bootstrap.main(list.toArray(new String[list.size()]));
+
+                //The process has finished
+                running.set(false);
+
+            } catch (Exception e) {
+                running.set(false);
+                throw new RuntimeException("Failed to Bootstrap OpenEJB", e);
+            }
+
+        }
+    }
+
+    private void stopImpl() {
+        if (running.getAndSet(false)) {
+
+            final Server server = SystemInstance.get().getComponent(Server.class);
+
+            if (null != server) {
+                try {
+                    System.out.println("Stopping NTService");
+                    server.stop();
+                } catch (Exception e) {
+
+                    //Failed to stop
+                    running.set(true);
+                    e.printStackTrace(System.err);
+                }
+            }
+        }
+    }
+
+}

Modified: openejb/trunk/openejb3/server/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/pom.xml?rev=1029733&r1=1029732&r2=1029733&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/pom.xml (original)
+++ openejb/trunk/openejb3/server/pom.xml Mon Nov  1 16:28:25 2010
@@ -43,6 +43,7 @@
     <module>openejb-axis2</module>
     <module>openejb-cxf</module>
     <module>openejb-multicast</module>
+    <module>openejb-daemon</module>
   </modules>
 </project>
 



Mime
View raw message