-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes.txt
650 lines (453 loc) · 20 KB
/
notes.txt
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
userfullstate,
I chose this name before the REST talk
Renamed folder from javacodegeeks_cassandracouserfullstatennect
29 April 2015
Make sure you read this. (Especially customising the port of the endpoint)
https://spring.io/guides/gs/actuator-service/
Wed Apr 29 14:08:32 BST 2015
Also this:
https://spring.io/guides/gs/accessing-data-rest/
spring curl boot get
https://spring.io/guides/gs/accessing-data-rest/
curl GET attempts failed
git done
____________________________________
commandline WORKED!
17:40 pm
29 April 2015
folders are important:
moved filed into folder java (src/main/java)
(also: resources: src/main/resources )
specified the main (removed the laternative main)
then:
mvn clean install
then
java -jar gs-spring-boot-0.1-SNAPSHOT.jar
src/main/java
mvn clean install
java -jar gs-spring-boot-0.1-SNAPSHOT.jar
how to run commandline:
mvn clean install
java -jar target/gs-spring-boot-0.1-SNAPSHOT.jar
todo: junit
ver = 4.12
<scope> = ?
GET could not sen a "long" variable.
However curl url?uid=2 was fine with String.
In fact the GET method was working correctly.
30 April 2015
13:44
//A 'json' is the set of public get*() methods of a POJO.
From stack overflow [David Lotts]: "make sure the POJO you return has get()ers, one for each field."
GET does not work with json input.
Long works (instead of long) in GET.
TODO:
Need to learn: @PathVariable versus @RequestParam
TODO:
@RequestMapping(method=GET, value={"aa","aa/{id}"})
What does this mean?
TODO:
also a usage: curl -H "acceptjson..." "localhost:8080/a/b/getName{a,b}"
___________
We can have (Model model) as the parameters for the "controller" function.
16:18
@RequestMapping(method = RequestMethod.GET)
//Just narrows the http operations! (GET,PUT,POST)
Wrong! This is needed (*). Otherwise: {"timestamp":1430407860455,"status":404,"error":"Not Found","message":"No message available","path":"/userfullstate"}
*: When I use @RequestMapping(url) for the class, and not the function. Otherwise, the the URL is not matches to the Function.
@RequestMapping("/userfullstate")
can be wither for a function or a class.
is
@ResponseBody
optional? (for the function)
Model:
"Primarily designed for adding attributes to the model."
But the object is different each time.
Besides, where is it constructed? Using what parameters?
@NotNull
@Size(max=100)
# MVC
spring.view.prefix=/WEB-INF/jsp/
spring.view.suffix=.jsp
#So will be stored in src/main/webapp/WEB-INF/jsp
#ref url=?
? May 2015
----------
Use Long as argument
9 May 2015
----------
Model can be provided as an arg or as a member of
A model as an arg is constructed at each REST request. (then what is the point?)
Why??? #Q #unresolved
A this.model (in the controller class) is created once. Appears quite early in logs.
Which one is injection then?
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody UserStateSummaryView method_name_does_not_matter
(
@RequestParam(value="uid", required=true) Long uid
,
UserState tempmodel //Constructed each time. Then what's the point? #Q
)
{...}
?
@Resource
/*
Using "@Resource" by itself (without another bean) causes:
Injection of resource dependencies failed;
No qualifying bean of type [sboot.UserState] found for dependency:
expected at least 1 bean which qualifies as autowire candidate
for this dependency.
Dependency annotations:
{@javax.annotation.Resource(
shareable=true, mappedName=, description=, name=, type=class java.lang.Object, lookup=, authenticationType=CONTAINER
)}
Solutions: To make the Bean using:
1-Make a @Configuration class. (very flexible and customisable) (Uses @Bean in a method)
2-define @Component when defining the class (1 instance only).
*/
GameInstance model1; //Todo: rename to GameState
11 May 2015:
------------
`@Service` is a subtype of @Component
@Service: "Service", originally defined by Domain-Driven
* Design (Evans, 2003) as "an operation offered as an interface that stands alone in the
* model, with no encapsulated state." []
`@Controller`
is typically used in combination with annotated handler methods based on the
* {@link org.springframework.web.bind.annotation.RequestMapping} annotation.
`java -ea` enables assert
mvn clean install ;blines ;java -ea -jar target/gs-spring-boot-0.1-SNAPSHOT.jar
Works. 16:25 (compiles without error)
Both @Value and @Bean are required.
Q: How to make a Bean that is Injected in properties of two @Components?
echo;curl localhost:8080/userfullstate?uid=2;echo;echo #exception
echo;curl localhost:8080/userfullstate?uid=7;echo;echo #works fine. cool.
echo;curl localhost:8080/gamestate;echo;echo #empty output
Is UserState a Bean? Or is it part of the GameInstance (getter)
UserState is probably Not a bean. [DesignDecision]
Works!
$ echo;curl localhost:8080/gamestate;echo;echo
{"players":[{"publicName":"Jack","summary":{"summary":"Name:Jack OnApp: false","vlong":5},"privateName":"Jack","onScreen":false}],"playerCount":1}
this.gameinstance= sboot.GameInstance@3e94b979
The getters provide all needed (also the summary and the view).
is* is a getter.
How to define an int (primitive type) getter?
12 May 2015
Specs and Concepts:
Every spec must contain one or more scenarios. []
Every spec can be marked with labels using tags. []
Every scenario has multiple steps.
[http://getgauge.io/documentation/user/current/specifications/scenarios.html]
Specifications are business layer test cases which can also act as your feature documentation.
[http://getgauge.io/documentation/user/current/specifications/README.html]
going for : Mail
On @Bean methods:
A @Bean (method) will be executed once even if called multiple times. (Any @Bean in a @Configuration)
If a @BEan in @Component class, it will be called 3 times ( N+1 times)!
parameters of @Bean methods: are injected.(?)
alternatives to singleton @Beans: sessions scope, request scope.
* A controller should not be void?
I only used a @RequestMapping(...) without @ResponseBody
> Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circular view path [choose]: would dispatch back to the current handler URL [/choose] again. Check your ViewResolver setup!
> (Hint: This may be the result of an unspecified view, due to default view name generation.)
> ] with root cause
@ResponseBody:
Annotation that indicates a method return value should be bound to the web response body.
.. * added on "type level" vs. added on the "method level".
** @see RequestBody
** @see RestController
@RestController = a @Controller class where @RequestMapping methods => @ResponseBody
But is "/choose" a REST Controller?
Works!
>$ curl localhost:8080/choose?uid=7\&choice=1
> 2015-05-12 17:18:20.689 INFO 21077 --- [nio-8080-exec-5] s.e.ChooseOnPushButtonController : User '7' chose 1
The method's return type is "@ResponseBody void"
todo: set the timestamp of last change when "/choose". [works]
@ResponseBody void
git:commit summary:
"the /choose endpoint added and works, java mail sender imported but not used. @ResponseBody void is type annotation. It is required for the endpoint. But is it REST?"
Who sets the timestamp (for the vote/choice)? When is it set?
At frontend? the caller of the rest? The REST method?
How many timestamps should we save?
How many timestamps can exist (in total)?
Port changed:
mvn clean install ;blines ;java -ea -jar target/gs-spring-boot-0.1-SNAPSHOT.jar --server.port=8181 &
Works!
$ curl localhost:8181/choose?uid=7\&choice=7
2015-05-13 13:35:45.876 INFO 28969 --- [nio-8181-exec-5] s.e.ChooseOnPushButtonController : User '7' chose 7 at 2015-05-13T13:35:45.876
private ZonedDateTime lastTimeSet_REST;
private ZonedDateTime lastTimeSet_THIS; //Here, at the UserState object setter
//private ZonedDateTime lastTimeSet_FRONTEND;
//private ZonedDateTime lastTimeSet_RECEIVED_FROM_SERVER;
//private ZonedDateTime lastTimeSet_RECEIVED_FROM_WEBSOCKETS;
this.lastTimeSet_HERE.getChronology() = ?
> The @Resource annotation marks a resource that is needed by the application.
A bean can be injected twice.
But a POJO (that ias not a @Component) cannot use @Property field (if uses, it is not injected).
Security is done by this:
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
Requires an LDAP server: ApacheDS
The ldapAuthentication() method configures (also logs in?)
LDIF = LDIF (LDAP Data Interchange Format)
We put an *ldif file in resources.
Using LDIF is not for production.
Error:
2015-05-13 20:17:14.146 ERROR 5406 --- [ost-startStop-1] o.a.d.s.s.r.DefaultAttributeTypeRegistry : attributeType w/ OID 2.5.4.16 not registered!
This page says just ignore this error:
> DefaultAttributeTypeRegistry : attributeType w/ OID 2.5.4.16 not registered!
https://github.com/bsnyder/spring-security-demo/blob/master/README.md
also:
NormalizationInterceptor : The RDN 'cn=quote\"guy' is not present in the entry
todo: learn about LDAP [Outcome: We will not use LDAP]
LDAP = Lightweight Directory Access Protocol
a layer above the TCP/IP stack.
* https://msdn.microsoft.com/en-us/library/aa367008%28v=vs.85%29.aspx
* ...
Apache Directory Server
http://en.wikipedia.org/wiki/Apache_Directory
LDIF editor
DSML editor
Security ldif error.
I also suspect the version specified ni the in POM
* Tests (Class with *Test suffix) should be in the folder ./src/test/java . This is imposed by Maven and of course setting the test folder by IntellijIdea doesnt matter.
15 May 2015
Security now works:
Based on two things:
http://docs.spring.io/autorepo/docs/spring-security/3.2.0.RELEASE/apidocs/org/springframework/security/config/annotation/web/configuration/EnableWebSecurity.html
( g: @EnableWebSecurity )
and:
https://github.com/spring-guides/gs-securing-web
todo: Difererntiate: SSL, SSH, OAuth, etc
todo: OAuth
Just adding <artifactId>spring-boot-starter-security</artifactId> to maven enables security.
Without the configuration class, (but using the artifact/dependency,) a dialogue box appears. Using configuration, a form appears.
kill -SIGCONT 6549
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
String text = date.toString(formatter);
19 May 2015
mthd(Map<String, Object> model) {}
//Understanding:
// the model is actually an output. It constitutes the "request" (GET/POST) to the page x, where String x is returned.
Question: Is that request a POST or a GET then?
Using import org.springframework.ui.Model;
did not help.
For test:
1- Make sure you use the right dependency.
The package needed is spring-boot-starter-test and NOT spring-test and NOT junit.
static imports. org.hamcrest.Matchers.equalTo ,etc equalTo, content, status. These are methods directly imported!
2- Make sure you instantiate the right class (HomePageController).
3- No need to worry about security. the simple Test works directly with the POJOs.
Simple (Unit) test now works ( https://spring.io/guides/gs/spring-boot/ )
How to skip tests:
mvn -DskipTests=true clean install
Q:
How to set username password.
Why setting manually doesnt work (session).
What is a default security password.
Spring will not remain.
Now AngularJS works.
21:17 pm (19 May 2015)
Next steps:
__________________________________________
Todo:
relate the "you" user to the login one
store previous choices
graph
email
test (damn)
Use Filters : rest-service-cors example. CORS: https://spring.io/guides/gs/rest-service-cors/
rename homapage to About page.
public ip (domain independent , port independent)
push button SENDs information. (Angular JS) [Now almost done]
(page redirects: systematic. No empty page.)
(getting notified: requesting from server to Client's browser) [works using WebSocket]
(session: [based on page1/html] which knows which uid it is. should I add uid to the json object of UserState? try to resist.)
A simple skin.
______________________________________________
21 May 2015
Let's apply this:
https://spring.io/blog/2015/01/12/spring-and-angular-js-a-secure-single-page-application
todo: [In AnguarJS] Don't use Controllers. Just use directives instead.
http://teropa.info/blog/2014/10/24/how-ive-improved-my-angular-apps-by-banning-ng-controller.html
Changing local files immediately applies to the running server jar.
I guess (as for application.properties) because the webserver looks at current directory and can override the jarred files.
This happens for ./public but not for resources/public .
Todo: prevent theme/skin to get jarred (for efficiency).
todo: Continuous integration. (mvn deploy versus install?)
//Apparently beans of the same package can be injected only
@Resource
public time.Classname timer;
__________________________________________
Todo:
a grid panel showing multiple users but one changes.
clicking on the button changes the app page without refreshing. [above: push button SENDs information]
(or instead, now: move to another page (or reload page).) [above: redirect]
graph of previous choices.
AnhularJS filters = ?
adding users to login.
Finish the AngularJS/Security tutorial.
favicon.
href="#" links
The 1 sec ago should disappear (or get updated)
______________________________________________
Bootstrap: Why does the size keep changing?
22 May: going for WebSocket
Docs: https://spring.io/guides/gs/messaging-stomp-websocket/
Todo: Not to forget: EC2, Docker, (*MQ), Cass., JPA, Hibernate
[JMS?]
Todo: continue: email.
todo: https://spring.io/guides/tutorials/spring-security-and-angular-js/
Works.
Warning (js console)
*** SockJS CDN is being retired on Dec 1st *** Please transition to a public CDN. See https://github.com/sockjs/sockjs-client/issues/198 for more information.
/wsckendpoint
/topic/greetings @SendTo and js: stompClient.subscribe('/topic/greetings'...)
/app/hello
where:
/app setApplicationDestinationPrefixes
/topic enableSimpleBroker
/wsckendpoint is @MessageMapping
stompClient.send("/app/hello", content...)
Hence: /app/hello *receives* content from stomp.js
Then ???StompmtStompText is set to it.
>>> SUBSCRIBE
id:sub-0
destination:/topic/greetings >>> SUBSCRIBE
destination:/app/wsckendpoint >>> SEND
//instead of destination:/app/hello
//This name is the same as wsckendpoint
http://localhost:8080/wsckendpoint
Welcome to SockJS!
//Seems to need a default constructor MyStompMessage()
The endpoint wsckendpoint is called by SEND.
greeting() called with (stomp message=null)
Lesson:
//The private member variable of the field name must be of the same name with the getter, otherwise the automatic conversion (constructor) from a "stringified JSON" will not work!
Very good intro to STOMP & WebSockets
https://www.new-bamboo.co.uk/blog/2010/02/10/json-event-based-convention-websockets/
Stayed up 22 May XM
23 May 2015:
12:48am
Todo: WebSockets Security ( + SockJS)
It already uses subscribe, so it will work.
Problem: no queuing. #Requirement negotiation.
Challenge: re-connecting:
Wen briefly disconnected or switched from Wifi to 3G, etc.
connected to server undefined
stomp.js:145
26 May:
Using DB: bean was created (ad hoc).
Test: Did not test (DB sintallation issue)
next: save in DB just at the "choice" operation (threaded instead of queue).
27 May
Combining apppg1.html with bcw_wc.html
https://spring.io/blog/2015/01/12/spring-and-angular-js-a-secure-single-page-application
Error finding angular..
going back to follow:
e.g wro.properties, etc
https://spring.io/blog/2015/01/12/spring-and-angular-js-a-secure-single-page-application
https://github.com/dsyer/spring-security-angular/tree/master/basic
Wro4j = Web Resource Optimizer for Java
CSP (Content Security Policy)
angular-bootstrap.js:15 Uncaught TypeError: window.angular.$$csp is not a function
line 15 angular-bootstrap.js
WARNING: Tried to load angular more than once.
AngularJS version.
todo
*** SockJS CDN is being retired on Dec 1st *** Please transition to a public CDN. See https://github.com/sockjs/sockjs-client/issues/198 for more information.
Uncaught Error: No module: hello
appeared only when I removed the tag ng-app from <html ng-app>
28 May 2015
AngularJS tutorial (yt & printout)
// @SpringBootApplication means if you run its psvm main, you have Everything
//This file contains important AngularJS "controller"s used by the App (ng-controller="getYourStateJs").
//They are not organised as a module. If as a module, each (x) should be set as: angular.module(...).controller(name, THIS )
//Tutorial is fully 1-read now on paper. (Video: not finished yet: 52:03). (Needs to be re-read.)
//Module now used by Angular in App page. [15:00pm?]
//Todo: Use Angular lists (ng-repeat)
//Next: Buttons don't make the page disappear. ng-click (or data-ng-click).
//Todo: last time ago using Angular (jscript)
Todo:
change the formats.
- change the function names for lowerpanel_functname() in bcw-wsock.js
- Angular"ise" the jscripts in bcw_ws.html.
- combine bcw_ws.html with the module js.
- Review (reflect on) all data flows (copiers/converters). [After the Angular-isation]
If data is sent to REST and sent back, does it make sense to have two layers (client-client and client-server-client) of communication?
Slow and fast, REST and Websockets.
//Todo: Make buttons change colour, but using Angular. (Later: number of choices is in a $scope of its own).
[finished the day: 18:20; 28 May 2015]
29 May 2015
todo:
- Finish Spring Boot T.V.
- Finish Angular T.V.
- Re-do those tutorials in Spring.io
Roadmap:
- d3.js or other graphs
- Connect to two types of database (Cassandra + a Hibernate-based DB)
- neo4j graph connection
- authentication users
- "combining" multiple communication layers
- timing, synchronisation, clock synchronisation, disconnection report, reconnecting, latency measurement.
- theme
- App-ification (Cordova, Ionic)
- Other pages: join, join a graph/waiting room, main page, page transition,
- Finishing frameworks
- Whitelabel: yVt, pkr, etc.
29 May 2015
http://192.168.1.92:8080/app/apppg2.html
caused:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080//userfullstate?uid=7. (Reason: CORS header 'Access-Control-Allow-Origin' missing). <unknown>
Don't use localhost. [done]
todo:
remove focus highlight because it's a mobile web app (no use of keyboard?).
repeated tdo: highlight the choice (AngularJS style). Three sources of highlight: 1-Locally, 2-WebSocket reverberation. 3- Server reverb.
todo:
allow multiple clicks on mobile.
todo:
Disable dictionary, etc on mobile (Safari mobile). Similar UX tests on other mobile browsers and on Android,
todo:
keyboard shortcuts for desktop use.
todo:
screen wiggles
Very useful tag to debug CSS:
style="border-style:solid; border-color:red;"
viewport problem
.e #viewport {
margin: 0 auto;
max-width: 600px;
}
#page {
position: relative;
}
Image size:
Should it be adjustable for each user?
Bootstrap: Navbar brand image
fixme:
it does not show the same content after refreshing. (Although it keeps the selection). --> Two types of json records. Why two endpoints are uesd?
fixme:
Sometime the automatic connect does not work.
Solution: reconnect heartbeat.
fixme:
Delay in Websocket communication.
todo:
Test if the broadcast works after leaving the App screen.
solution: Detect if it's disconnected (low latency).
default choice in the broadcast panel. (Will be fixed after Angular-ization)
fixme:
Contents layout after mobile screen rotation.
fixme:
Still downloads [two versions of angularJS] from CDN. (See network panel).
fixme:
Firefox:
This site makes use of a SHA-1 Certificate; it's recommended you use certificates with signature algorithms that use hash functions stronger than SHA-1.
[Learn More]
cleardot.gif
https://developer.mozilla.org/en-US/docs/Security/Weak_Signature_Algorithm
todo: Use colours for buttons. Same colours for bar graphs.
Left to be done for the first phase:
- Need a predefined graph (all-to-all),
- needs to save the choices (a database).
- "Game can be played in a test setting."