Skip to main content
summaryrefslogtreecommitdiffstats
blob: 577304cb8b591a33456d33048bee487e49db2b26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?xml version="1.0"?>
<project name="Test OSEE Application Server Launcher" default="run" basedir=".">

	<!--
	${extraVMargs}

	$osee.db.name=psql.osee.eclipse.org \
   $osee.db.user=osee.eclipse \
   $osee.db.passwd=osee.eclipse \
   $osee.db.address=127.0.0.1 \
   $osee.db.port=1623 \
   $osee.db.type=H2,PGSQL,DERBY \

	${osee.app.server.home}	
	${osee.app.server.port}
	-->

	<target name="init">
		<echo message="extraVMargs: [${extraVMargs}]" />

		<for param="argline" delimiter=" -D" list="${extraVMargs}" trim="true">
			<sequential>
				<propertyregex property="argName" override="true" input="@{argline}" regexp="(.*?)=" select="\1" casesensitive="false" />
				<propertyregex property="argValue" override="true" input="@{argline}" regexp="=(.*)" select="\1" casesensitive="false" />
				<echo message="Found arg - [${argName}]=[${argValue}]" />
				<property name="${argName}" value="${argValue}" />
			</sequential>
		</for>

		<var name="isDerbyLaunch" value="false" />
		<var name="isPostgreSqlLaunch" value="false" />
		<var name="isH2Launch" value="false" />
		<if>
			<equals arg1="${osee.db.type}" arg2="H2" />
			<then>
				<var name="isH2Launch" value="true" />
			</then>
			<elseif>
				<equals arg1="${osee.db.type}" arg2="PGSQL" />
				<then>
					<var name="isPostgreSqlLaunch" value="true" />
				</then>
			</elseif>
			<elseif>
				<equals arg1="${osee.db.type}" arg2="DERBY" />
				<then>
					<var name="isDerbyLaunch" value="true" />
				</then>
			</elseif>
			<else>
				<fail message="Osee Db Type Undefined [${osee.db.type}] - [H2,PGSQL,DERBY] are allowed" />
			</else>
		</if>

		<property name="osee.app.server.data" value="${osee.app.server.home}/${eclipse-home}/testWorkspace/serverBinData" />
		<property name="osee.app.server.connectionFile" value="${osee.app.server.home}/test.osee.client.db.connection.xml" />
		<property name="osee.app.server.connectionId" value="test.osee.client.db.connection.id" />

		<echo message="Osee Application Server Home: [${osee.app.server.home}]" />
		<echo message="Osee Application Server Port: [${osee.app.server.port}]" />
		<echo message="Osee Application Server Is H2: [${isH2Launch}]" />
		<echo message="Osee Application Server Is Derby: [${isDerbyLaunch}]" />
		<echo message="Osee Application Server Is Postgresql: [${isPostgreSqlLaunch}]" />
	</target>

	<target name="writePosgresqlConnectionFile" if="isPostgreSqlLaunch">
		<writeConnectionFile 
			dbType="postgresql" 
			dbPrefix="jdbc:postgresql" 
			dbDriver="postgresql.db.connection" 
			dbName="${osee.db.name}" 
			dbUser="${osee.db.user}" 
			dbPasswd="${osee.db.passwd}" 
			dbAddress="${osee.db.address}" 
			dbPort="${osee.db.port}" 
			connectionFilePath="${osee.app.server.connectionFile}" 
			connectionid="${osee.app.server.connectionId}" />
		<property name="additionalJvmArgs" value=" " />
	</target>

	<target name="writeDerbyConnectionFile" if="isDerbyLaunch">
		<writeConnectionFile 
			dbType="derby" 
			dbPrefix="jdbc:derby" 
			dbDriver="net.derby.db.connection" 
			dbName="${osee.db.name}" 
			dbUser="${osee.db.user}" 
			dbPasswd="${osee.db.passwd}" 
			dbAddress="${osee.db.address}" 
			dbPort="${osee.db.port}" 
			connectionFilePath="${osee.app.server.connectionFile}" 
			connectionid="${osee.app.server.connectionId}" />
		<property name="additionalJvmArgs" value=" -Dosee.db.embedded.server=${osee.db.address}:${osee.db.port}" />
	</target>

	<target name="writeH2ConnectionFile" if="isH2Launch">
		<writeConnectionFile 
			dbType="h2" 
			dbPrefix="jdbc:h2" 
			dbDriver="h2.db.connection"
			dbName="${osee.db.name}" 
			dbUser="${osee.db.user}" 
			dbPasswd="${osee.db.passwd}" 
			dbAddress="${osee.db.address}" 
			dbPort="${osee.db.port}" 
			connectionFilePath="${osee.app.server.connectionFile}" 
			connectionid="${osee.app.server.connectionId}" />
		<property name="additionalJvmArgs" value=" -Dosee.db.embedded.server=${osee.db.address}:${osee.db.port}" />
	</target>

	<target name="run" depends="init,writeH2ConnectionFile,writePosgresqlConnectionFile,writeDerbyConnectionFile,launchServer" />

	<target name="launchServer">
		<pathconvert property="launcherJarPath" setonempty="false">
			<path>
				<fileset dir="${osee.app.server.home}/plugins">
					<include name="org.eclipse.equinox.launcher_*.jar" />
				</fileset>
			</path>
		</pathconvert>
		<forget>
			<echo message="Launching Osee Application Server..." />
			<java taskname="build" jvm="${JAVA_HOME}/bin/java" failonerror="true" maxmemory="1024m" timeout="10800000" jar="${launcherJarPath}" fork="true">
				<classpath>
					<fileset dir="${osee.app.server.home}/plugins" includes="org.eclipse.equinox.launcher_*.jar" />
					<pathelement location="${osee.app.server.home}/plugins" />
				</classpath>
				<jvmarg line=" -Dorg.osgi.service.http.port=${osee.app.server.port}" />
				<jvmarg line=" -Dosee.db.connection.id=${osee.app.server.connectionId}" />
				<jvmarg line=" -Dosee.connection.info.uri=${osee.app.server.connectionFile}" />
				<jvmarg line=" -Dosee.application.server.data=${osee.app.server.data}" />
				<jvmarg line="${additionalJvmArgs}" />
				<jvmarg line=" -Dosee.check.tag.queue.on.startup=false" />
				<arg line=" -console -consoleLog" />
			</java>
		</forget>

		<waitfor maxwait="1" maxwaitunit="minute" checkevery="100" checkeveryunit="millisecond">
			<http url="http://127.0.0.1:${osee.app.server.port}" />
		</waitfor>
	</target>

	<macrodef name="writeConnectionFile">
		<attribute name="dbName" />
		<attribute name="dbUser" />
		<attribute name="dbPasswd" />
		<attribute name="dbType" />
		<attribute name="dbPrefix" />
		<attribute name="dbDriver" />
		<attribute name="dbAddress" />
		<attribute name="dbPort" />
		<attribute name="connectionId" />
		<attribute name="connectionFilePath" />
		<sequential>
			<echo message="Writing [@{dbType}] Db Connection File" />
			<echo file="@{connectionFilePath}">
			&lt;DbConnection&gt;
				&lt;DatabaseInfo id=&quot;db.connection.info&quot;&gt;${line.separator}
					&lt;DatabaseHome key=&quot;#DBHOME#&quot; /&gt;${line.separator}
					&lt;DatabaseName key=&quot;#DBNAME#&quot; value=&quot;@{dbName}&quot; /&gt;${line.separator}
					&lt;DatabaseType key=&quot;#TYPE#&quot; value=&quot;@{dbType}&quot; /&gt;${line.separator}
					&lt;Prefix key=&quot;#PREFIX#&quot; value=&quot;@{dbPrefix}&quot; /&gt;${line.separator}
					&lt;UserName key=&quot;#USERNAME#&quot; value=&quot;@{dbUser}&quot; /&gt;${line.separator}
					&lt;Password key=&quot;#PASSWORD#&quot; value=&quot;@{dbPasswd}&quot; /&gt;${line.separator}
					&lt;Host key=&quot;#HOST#&quot; value=&quot;@AvailableDbServices.hostAddress&quot; /&gt;${line.separator}
					&lt;Port key=&quot;#PORT#&quot; value=&quot;@AvailableDbServices.port&quot; /&gt;${line.separator}
				&lt;/DatabaseInfo&gt;${line.separator}
				${line.separator}
				&lt;ConnectionDescription id=&quot;h2.db.connection&quot;&gt;${line.separator}
					&lt;Driver&gt;org.h2.Driver&lt;/Driver&gt;${line.separator}
					&lt;Url&gt;#PREFIX#:tcp://#HOST#:#PORT#/#DBHOME##DBNAME#;IGNORECASE=TRUE;SCHEMA_SEARCH_PATH=OSEE, PUBLIC&lt;/Url&gt;${line.separator}
				&lt;/ConnectionDescription&gt;${line.separator}
				${line.separator}				
				&lt;ConnectionDescription id=&quot;postgresql.db.connection&quot;&gt;${line.separator}
					&lt;Driver&gt;org.postgresql.Driver&lt;/Driver&gt;${line.separator}
					&lt;Url&gt;#PREFIX#://#HOST#:#PORT#/#DBHOME##DBNAME#&lt;/Url&gt;${line.separator}
				&lt;/ConnectionDescription&gt;${line.separator}
				${line.separator}
				&lt;ConnectionDescription id=&quot;net.derby.db.connection&quot;&gt;${line.separator}
					&lt;Driver&gt;org.apache.derby.jdbc.ClientDriver&lt;/Driver&gt;${line.separator}
					&lt;Url&gt;#PREFIX#://#HOST#:#PORT#/#DBHOME##DBNAME#;&lt;/Url&gt;${line.separator}
					&lt;UrlAttributes&gt;${line.separator}
						&lt;Entry&gt;create=true&lt;/Entry&gt;${line.separator}
					&lt;/UrlAttributes&gt;${line.separator}
				&lt;/ConnectionDescription&gt;${line.separator}
			</echo>

			<echo file="@{connectionFilePath}" append="true">
				${line.separator}${line.separator}
				&lt;AvailableDbServices&gt;${line.separator}
					&lt;Server id=&quot;@{connectionId}&quot; dbInfo=&quot;db.connection.info&quot; connectsWith=&quot;@{dbDriver}&quot; hostAddress=&quot;@{dbAddress}&quot; port=&quot;@{dbPort}&quot; /&gt;${line.separator}
				&lt;/AvailableDbServices&gt;${line.separator}
			&lt;/DbConnection&gt;
			</echo>
		</sequential>
	</macrodef>

</project>

Back to the top