[CHANGE] Downcase all platform names
[ohcount] / ruby / gestalt / java_definitions.rb
1 module Ohcount
2         module Gestalt
3
4                 define_java_jar do
5       find_filenames /([^\\^\/]*\.jar)/i, :name_from_match => 1
6                 end
7
8     define_java_import do
9       find_java_imports
10     end
11
12                 # Java Application Servers
13
14                 define_platform 'glassfish' do
15                         _and do
16                                 gestalt(:platform, 'java')
17                                 _or do
18                                         find_filenames /\b(sun\-web|sun\-ejb\-jar|sun\-application(\-client))\.xml\b/
19                                         maven_dependency /^org.glassfish\b/
20                                 end
21                         end
22                 end
23
24                 define_platform 'jboss' do
25                         _and do
26                                 gestalt(:platform, 'java')
27                                 _or do
28                                         find_filenames /\bjboss(\-app|cmp\-jdbc|\-web|\-build|\-client)\.xml\b/
29                                         maven_dependency /^org.jboss\b/
30                                 end
31                         end
32                 end
33
34                 define_platform 'weblogic' do
35                         _and do
36                                 gestalt(:platform, 'java')
37                                 _or do
38                                         find_filenames /\bweblogic(\-ejb\-jar|\-ra|\-application|\-cmp\-rdbms\jar)\.xml\b/
39                                         maven_plugin /^org\.codehaus\.mojo\b/, /^weblogic\-maven\-plugin\b/
40                                 end
41                         end
42                 end
43
44                 define_platform 'jonas' do
45                         _and do
46                                 gestalt(:platform, 'java')
47                                 find_filenames /\bjonas\-ejb\-jar\.xml\b/
48                         end
49                 end
50
51                 define_platform 'websphere' do
52                         _and do
53                                 gestalt(:platform, 'java')
54                                 find_filenames /\bibm\-(application|web|webservices|webservicesclient)\-.+\.xmi$/
55                         end
56                 end
57
58                 define_platform 'tomcat' do
59                         _and do
60                                 gestalt(:platform, 'java')
61                                 _or do
62                                         java_import /^org\.apache\.tomcat\b/
63                                         maven_dependency /^org\.apache\.tomcat\b/
64                                 end
65                         end
66                 end
67
68                 define_platform 'appserver' do
69                         _or do
70                                 gestalt(:platform, 'glassfish')
71                                 gestalt(:platform, 'jboss')
72                                 gestalt(:platform, 'weblogic')
73                                 gestalt(:platform, 'tomcat')
74                                 gestalt(:platform, 'jonas')
75                                 gestalt(:platform, 'websphere')
76                         end
77                 end
78
79                 define_platform 'ejb2' do
80                         _and do
81                                 gestalt(:platform, 'java')
82                                 _or do
83                                         find_filenames /(.+\-)ejb\-jar\.xml\b/
84                                         java_keywords 'EJBHome', 'EJBRemote', 'SessionBean'
85                                 end
86                         end
87                 end
88
89                 # Caution! The EJB platform definitions are senstive to their order -- do not reorder!
90                 # The gestalt engine iterates over definitions in the order they are defined.
91                 #
92                 # First, look for the subset of new features that definitely indicate EJB 3.1
93                 define_platform 'ejb3.1' do
94                         _and do
95                                 gestalt(:platform, 'java')
96                                 _or do
97                                         java_keywords '@Schedule', '@Singleton', '@Asynchronous'
98                                         java_keywords /@EJB\(.*\bmappedName\s*=\s*"java:(global|app|module)\/.+".*\)/
99                                         java_keywords /\blookup\(\s*"java:(global|app|module)\/.+"\s*\)/
100                                 end
101                         end
102                 end
103                 # Next, look for the basic attributes that can mean either EJB 3.0 or 3.1
104                 define_platform 'ejb3+' do
105                         _and do
106                                 gestalt(:platform, 'java')
107                                 _or do
108                                         gestalt(:platform, 'ejb3.1')
109                                         java_keywords '@EJB', '@Stateless', '@Statefull', '@Entity', '@Remote', '@Local', '@BusinessMethod'
110                                         java_import /^javax\.persistence\b/
111                                 end
112                         end
113                 end
114                 # Finally, if we found EJB3+ and not EJB 3.1, then you must be using EJB 3.0 only.
115                 define_platform 'ejb3.0' do
116                         _and do
117                                 gestalt(:platform, 'ejb3+')
118                                 _not { gestalt(:platform, 'ejb3.1') }
119                         end
120                 end
121
122                 define_platform 'servlet' do
123                         _and do
124                                 gestalt(:platform, 'java')
125                                 _or do
126                                         java_import /^javax\.servlet\b/
127                                         maven_dependency /^javax\.servlet\b/
128                                 end
129                         end
130                 end
131
132                 define_platform 'struts' do
133                         _and do
134                                 gestalt(:platform, 'java')
135                                 _or do
136                                         filenames('\bstruts(\-config)?\.xml$', '\bstruts\.jar$')
137                                         java_import /^org\.apache\.struts\b/
138                                         maven_dependency /^org\.apache\.struts\b/
139                                 end
140                         end
141                 end
142
143     define_platform 'springframework' do
144       _and do
145         gestalt(:platform,'java')
146                                 _or do
147                                         filenames('spring\.jar$')
148                                         java_import /^org\.springframework\b/
149                                         maven_dependency /^org\.springframework\b/
150                                 end
151       end
152     end
153
154                 define_platform 'jsf' do
155                         _and do
156                                 gestalt(:platform, 'java')
157                                 _or do
158                                         java_import /^javax\.faces\b/
159                                         maven_dependency /^javax\.faces\b/
160                                 end
161                         end
162                 end
163
164                 define_platform 'googlewebtoolkit' do
165                         _and do
166                                 gestalt(:platform, 'java')
167                                 java_import /^com\.google\.gwt\b/
168                         end
169                 end
170
171                 # Java Persistence Frameworks
172
173                 define_platform 'hibernate' do
174                         _and do
175                                 gestalt(:platform, 'java')
176                                 _or do
177                                         filenames '\bhibernate\d\.jar$'
178                                         java_import /^org\.hibernate\b/
179                                         maven_dependency 'org.hibernate'
180                                 end
181                         end
182                 end
183
184                 define_platform 'jpa' do
185                         _and do
186                                 gestalt(:platform, 'java')
187                                 java_import /^javax\.persistence\b/
188                         end
189                 end
190
191                 define_platform 'toplink' do
192                         _and do
193                                 gestalt(:platform, 'java')
194                                 java_import /^oracle\.toplink\b/
195                         end
196                 end
197
198                 define_platform 'castor' do
199                         _and do
200                                 gestalt(:platform, 'java')
201                                 java_import /^org\.exolab\.castor\b/
202                         end
203                 end
204
205                 define_platform 'db4o' do
206                         _and do
207                                 gestalt(:platform, 'java')
208                                 java_import /^com\.db4o\b/
209                         end
210                 end
211
212                 # Java Enterprise Service Buses
213
214                 define_platform 'openesb' do
215                         _and do
216                                 gestalt(:platform, 'java')
217                                 java_import /^org\.openesb\b/
218                         end
219                 end
220
221                 define_platform 'muleesb' do
222                         _and do
223                                 gestalt(:platform, 'java')
224                                 java_import /^org\.mule\b/
225                         end
226                 end
227
228                 define_platform 'servicemix' do
229                         _and do
230                                 gestalt(:platform, 'java')
231                                 _or do
232                                         java_import /^org\.apache\.servicemix\b/
233                                         maven_dependency /^org.apache.servicemix\b/
234                                 end
235                         end
236                 end
237
238                 define_platform 'jbossesb' do
239                         _and do
240                                 gestalt(:platform, 'java')
241                                 java_import /^org\.jboss\.soa\.esb\b/
242                         end
243                 end
244
245                 define_platform 'openesb' do
246                         _and do
247                                 gestalt(:platform, 'java')
248                                 java_import /^org\.openesb\b/
249                         end
250                 end
251
252                 # Other Java Technologies
253
254                 define_platform 'opensso' do
255                         _and do
256                                 gestalt(:platform, 'java')
257                                 _or do
258                                         filenames '\bopensso\.war$'
259                                         java_import /^com\.sun\.identity\.(authentication|agents)\b/
260                                 end
261                         end
262                 end
263
264                 define_platform 'maven' do
265                         _and do
266                                 gestalt(:platform, 'java')
267                                 find_filenames /\bpom\.xml$/
268                         end
269                 end
270
271         end
272 end