Skip to content

Commit 2e9aabf

Browse files
author
ares
committedJan 4, 2012
1 parent 05ccd15 commit 2e9aabf

File tree

9 files changed

+101
-29
lines changed

9 files changed

+101
-29
lines changed
 

‎modctrl-app/nb-configuration.xml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
3+
<!--
4+
This file contains additional configuration written by modules in the NetBeans IDE.
5+
The configuration is intended to be shared among all the users of project and
6+
therefore it is assumed to be part of version control checkout.
7+
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10+
<!--
11+
Properties that influence various parts of the IDE, especially code formatting and the like.
12+
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13+
That way multiple projects can share the same settings (useful for formatting rules for example).
14+
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15+
-->
16+
<netbeans.hint.jdkPlatform>JDK_1.6</netbeans.hint.jdkPlatform>
17+
</properties>
18+
</project-shared-configuration>

‎modctrl-app/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@
158158
<artifactId>commons-vfs2</artifactId>
159159
<version>2.0</version>
160160
</dependency>
161+
<dependency>
162+
<groupId>log4j</groupId>
163+
<artifactId>log4j</artifactId>
164+
<version>1.2.15</version>
165+
</dependency>
161166
</dependencies>
162167

163168

‎modctrl-app/src/main/java/modbus/control/service/WrapperMainServiceWin.java

+45-25
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@
1111
package modbus.control.service;
1212

1313
import java.io.File;
14+
import java.util.ArrayList;
15+
import java.util.Collections;
16+
import java.util.HashMap;
17+
import java.util.List;
18+
import java.util.Map;
1419
import java.util.concurrent.ExecutorService;
1520
import java.util.concurrent.Executors;
1621
import java.util.concurrent.Future;
1722
import java.util.concurrent.TimeUnit;
1823

1924
import jnacontrib.win32.Win32Service;
2025

26+
import org.apache.log4j.Logger;
2127
import org.rzo.yajsw.boot.WrapperLoader;
22-
import org.rzo.yajsw.config.YajswConfiguration;
23-
import org.rzo.yajsw.config.YajswConfigurationImpl;
2428
import org.rzo.yajsw.os.OperatingSystem;
2529
import org.rzo.yajsw.os.StopableService;
2630
import org.rzo.yajsw.wrapper.WrappedProcess;
@@ -40,6 +44,7 @@ public class WrapperMainServiceWin extends Win32Service implements StopableServi
4044
/** The service. */
4145
static WrapperMainServiceWin service;
4246
static ExecutorService pool = Executors.newFixedThreadPool(5);
47+
private static final Logger logger = Logger.getLogger(WrapperMainServiceWin.class);
4348

4449
/**
4550
* Instantiates a new wrapper main service.
@@ -56,16 +61,23 @@ public WrapperMainServiceWin() {
5661
*/
5762
public static void main(String[] args) {
5863
System.setProperty("wrapper.config", System.getProperty("user.dir") + "\\src\\main\\resources\\wrapper.conf");
59-
64+
System.setProperty("wrapper.java.app.mainclass", "modbus.control.EmbeddedJetty"); // system properties overwrite properties in conf file.
65+
System.setProperty("wrapper.tray", "false");
66+
6067
String wrapperJar = WrapperLoader.getWrapperJar();
6168
// set home dir of the service to the wrapper jar parent, so that we may find required libs
6269
String homeDir = new File(wrapperJar).getParent();
63-
OperatingSystem.instance().setWorkingDir(System.getProperty("user.dir") + "\\target\\dependency");
64-
YajswConfigurationImpl _config = new YajswConfigurationImpl(true);
65-
70+
OperatingSystem.instance().setWorkingDir(System.getProperty("user.dir"));
71+
6672
service = new WrapperMainServiceWin();
73+
74+
75+
if (false) {
76+
service.install("Modbus Control", "control modbus PLC", null, "ares", "Jas1MinB", true);
77+
return;
78+
}
79+
6780
// set service shutdown timeout
68-
service.setServiceName(_config.getString("wrapper.ntservice.name"));
6981
// int timeout = _config.getInt("wrapper.shutdown.timeout", Constants.DEFAULT_SHUTDOWN_TIMEOUT) * 1000;
7082
// timeout += _config.getInt("wrapper.script.STOP.timeout", 0) * 1000;
7183
// timeout += _config.getInt("wrapper.script.SHUTDOWN.timeout", 0) * 1000;
@@ -75,26 +87,11 @@ public static void main(String[] args) {
7587
//
7688
// timeout = _config.getInt("wrapper.startup.timeout", Constants.DEFAULT_STARTUP_TIMEOUT) * 1000;
7789
service.setStartupTimeout(3000);
78-
//
79-
// service.setAutoReportStartup(_config.getBoolean("wrapper.ntservice.autoreport.startup", true));
80-
//
81-
// if (_config.containsKey("wrapperx.config"))
82-
// {
83-
// List<String> configs = _config.getList("wrapperx.config");
84-
// wList = WrappedProcessFactory.createProcessList(new HashMap(), configs, true);
85-
// for (WrappedProcess p : wList)
86-
// {
87-
// p.setService(service);
88-
// }
89-
// }
90-
// else
91-
// {
9290

93-
// global configuration
91+
Map configuration = new HashMap();
92+
WrappedProcess wp = (WrappedProcess) WrappedProcessFactory.createProcess(configuration, true);
93+
9494

95-
WrappedProcess wp = WrappedProcessFactory.createProcess((YajswConfiguration)_config);
96-
97-
9895
// set service in wrapper so that we may stop the service in case the application terminates and we need to shutdown the wrapper
9996
wp.setService(service);
10097
wp.init();
@@ -148,6 +145,29 @@ public void run() {
148145
Runtime.getRuntime().halt(0);
149146
}
150147

148+
@Override
149+
public boolean install(String displayName, String description, String[] dependencies, String account, String password, boolean delayedAutostart) {
150+
File prjFolder = new File(System.getProperty("user.dir") + "\\target\\dependency");
151+
if (!prjFolder.exists()) {
152+
prjFolder = new File(System.getProperty("user.dir") + "\\..\\lib");
153+
if (!prjFolder.exists()) {
154+
logger.error("NO LIBRARYS FOUND");
155+
return false;
156+
}
157+
}
158+
159+
List<String> depFiles = new ArrayList<String>();
160+
for (File dependencyFile : prjFolder.listFiles()) {
161+
162+
if (dependencyFile.isFile() && dependencyFile.getName().endsWith("jar")) {
163+
depFiles.add(dependencyFile.getAbsolutePath());
164+
}
165+
}
166+
dependencies = depFiles.toArray(new String[0]);
167+
168+
return super.install(displayName, description, dependencies, account, password, delayedAutostart);
169+
}
170+
151171
/*
152172
* (non-Javadoc)
153173
*
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
3+
<log4j:configuration>
4+
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
5+
<layout class="org.apache.log4j.PatternLayout">
6+
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
7+
</layout>
8+
</appender>
9+
<root>
10+
<priority value="debug"></priority>
11+
<appender-ref ref="stdout"/>
12+
</root>
13+
</log4j:configuration>

‎modctrl-app/src/main/resources/wrapper.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ wrapper.daemon.run_level_dir=${if (new File('/etc/rc0.d').exists()) return '/etc
236236
# Wrapper System Tray Properties
237237
#********************************************************************
238238
# enable system tray
239-
wrapper.tray = true
239+
wrapper.tray = false
240240

241241
# TCP/IP port. If none is defined multicast discovery is used to find the port
242242
# Set the port in case multicast is not possible.

‎modctrl-app/wrapper.log.0

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
INFO|wrapper|yajsw|12-01-04 19:55:44|init
2+
INFO|wrapper|yajsw|12-01-04 19:55:44|set state IDLE->STARTING
3+
INFO|wrapper|yajsw|12-01-04 19:55:44|starting Process
4+
INFO|wrapper|yajsw|12-01-04 19:55:44|Win service: before service init
5+
INFO|wrapper|yajsw|12-01-04 19:55:44|error in StartServiceCtrlDispatcher
6+
INFO|wrapper|yajsw|12-01-04 19:55:44|87:Falscher Parameter.
7+
INFO|wrapper|yajsw|12-01-04 19:55:44|Win service: terminated correctly
8+
INFO|wrapper|yajsw|12-01-04 19:55:44|Controller State: UNKNOWN -> WAITING
9+
INFO|wrapper|yajsw|12-01-04 21:09:44|init
10+
INFO|wrapper|yajsw|12-01-04 21:09:44|set state IDLE->STARTING
11+
INFO|wrapper|yajsw|12-01-04 21:09:44|Win service: before service init
12+
INFO|wrapper|yajsw|12-01-04 21:09:44|starting Process
13+
INFO|wrapper|yajsw|12-01-04 21:09:44|error in StartServiceCtrlDispatcher
14+
INFO|wrapper|yajsw|12-01-04 21:09:44|87:Falscher Parameter.
15+
INFO|wrapper|yajsw|12-01-04 21:09:44|Win service: terminated correctly
16+
INFO|wrapper|yajsw|12-01-04 21:09:44|Controller State: UNKNOWN -> WAITING

‎modctrl-app/wrapper.log.0.lck

Whitespace-only changes.

‎modctrl-webapp/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
<artifactId>log4j</artifactId>
5050
</dependency>
5151
<dependency>
52-
<groupId>repository.net.wimpi.modbus</groupId>
53-
<artifactId>jamodTcp</artifactId>
52+
<groupId>net.wimpi.modbus</groupId>
53+
<artifactId>jamod</artifactId>
5454
<version>1.2-SNAPSHOT</version>
5555
</dependency>
5656
</dependencies>

‎yajsw/nb-configuration.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ You can copy and paste the single properties, into the pom.xml file and the IDE
1313
That way multiple projects can share the same settings (useful for formatting rules for example).
1414
Any value defined here will override the pom.xml file value but is only applicable to the current project.
1515
-->
16-
<netbeans.hint.jdkPlatform>JDK__1.6</netbeans.hint.jdkPlatform>
16+
<netbeans.hint.jdkPlatform>JDK_1.6</netbeans.hint.jdkPlatform>
1717
</properties>
1818
</project-shared-configuration>

0 commit comments

Comments
 (0)
Please sign in to comment.