Hey Hey Hey


  • Home

  • Archives

  • Tags

  • Search

Javascript loading issue

Posted on 2017-01-05 |

Basic
http://javascript.info/tutorial/adding-script-html

Issue reason,
$timeout(function(){});

the default timeout will be zero. So the function will be triggerred without any delay.
The function itself is relying on some value to be initialized, so that’s the reason causing the problem. after change it to
$timeout(function(){},3000);
the issue solved.

Read more »

Setup a spring boot application to run on windows as a service

Posted on 2016-12-11 |

Setup a spring boot application to run on windows as a service

Reference links

https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html

https://github.com/kohsuke/winsw/blob/master/doc/installation.md

https://github.com/snicoll-scratches/spring-boot-daemon

Basically, winsw provide a way to make executable to run as a windows service.

Tips,

  1. Check winsw log for the real command being run
  2. Security (run as certain user from the service)

A basic example,

1
2
3
4
5
6
7
8
9
10
11
<service>
<id>myapp</id>
<name>myapp</name>
<description>this service runs myapp solution</description>
<env name="APP_HOME" value="%BASE%"/>
<logpath>%BASE%\logs</logpath>
<logmode>rotate</logmode>

<executable>%BASE%/jre1.8.0_121/bin/java.exe</executable>
<arguments>-Xmx256m -jar %BASE%\myapp.jar -Dlog4j.configuration=%BASE%\config\log4j2.xml --loader.path=%BASE%\config --spring.config.location=%BASE%\config\myapp.properties</arguments>
</service>
Read more »

CORS issue with Mulesoft

Posted on 2016-11-11 |

CORS issue when using mule to serve micro services to frontend

When Angular call Restful API by Mule,

1
2
( cross domain HTTP request )
XMLHttpRequest cannot load http://localhost:8081/iserver/flows. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxxxxxx:8080' is therefore not allowed access.

Related document

http://blogs.mulesoft.com/dev/anypoint-platform-dev/cross-domain-rest-calls-using-cors/

resolution

add response header

name: Access-Control-Allow-Origin

value: Put in the allowed client’s http(s)😕/hostname:port

Read more »

Git cmmand cheet sheet

Posted on 2016-05-05 |

S1, have existing repo and change to use git repo to track the change

with remot repo
$ mkdir /path/to/new_repo
$ cd /path/to/new_repo
$ git --bare init

with existing repo
$ cd /path/to/existing_repo
$ git init
$ vi .gitignroe
$ git add .
$ git commit -m “init”

$ git push --set-upstream /path/to/new_repo mastergit

gitremoteaddorigin/path/tocurrent−existinglibfatal:remoteoriginalreadyexists.git remote add origin /path/tocurrent-existinglib fatal: remote origin already exists. gitremoteaddorigin/path/tocurrent−existinglibfatal:remoteoriginalreadyexists. git remote rm origin
and then add again

Create Developer branch
git branch develop
git checkout develop

follow the flow the develop
https://gist.github.com/yesmeck/4245406

======cancel any change in current branch that not yet being staged (add .) ======
git checkout – .

S2, create a new bare repo remotely and then start from local

git clone /path/to/remote/bare/repo

Read more »

Design Pattern - Factory

Posted on 2016-01-05 |

Factory

1
2
3
4
5
6
7
8
9
10
11
{  
//real case invoking
invokeSharedCode(new BikeFactory());
invokeSharedCode(new CarFactory());
}

//object being created depending on factory type, and behavior is defined in interface also
public static void invokeSharedCode(TransportFactory factory){
Transport transport = factory.create();
System.out.println(transport.drive());
}

core concept

Shared code interface not hardcoded with typeA or typeB,
but typeA and B all extend the same factory and initialization using same function.

After create, we can invoke the same name function provided by typeA or B.

Read more »

Angular Related

Posted on 2015-11-11 |

Env Setup

https://www.npmjs.com/package/http-server

if you’re running node.js http-server is super easy. Install: npm install -g http-server.
After installation cd into your project folder and run http-server -o. -o is to open browser to the page.
Sample cmd,
pathtonode/node pathtohttpserver/http-server [pathtoangularproject] -p port -a address

Compare Strings

https://docs.angularjs.org/api/ng/function/angular.equals

Directory structure best practice

Refer to the offical recommendation
https://github.com/angular/angular-seed/tree/master/app

To debug Angular using Chrome

use AngularJS Batarang.

WARNING: Tried to load angular more than once.

Read more »

Mule flow single threading

Posted on 2015-11-11 |

Sample flow implement single threading

flow client raise a request and will get response instantly.
The request will be processed asycronized (in sequence, 1 thread)

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
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>

<queued-asynchronous-processing-strategy name="allow1Threads" maxThreads="1" doc:name="Queued Asynchronous Processing Strategy"/>
<vm:connector name="VM" validateConnections="true" doc:name="VM">
<vm:queue-profile>
<default-persistent-queue-store/>
</vm:queue-profile>
</vm:connector>
<vm:connector name="VM1" validateConnections="true" doc:name="VM">
<vm:queue-profile>
<default-persistent-queue-store/>
</vm:queue-profile>
</vm:connector>
<flow name="vmtransactionFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/registerTask" doc:name="HTTP"/>
<set-payload value="#[java.util.UUID.randomUUID().toString()]" doc:name="Set Payload"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="TaskQ" connector-ref="VM" doc:name="VM"/>
<logger message="Task Received, #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="vmtransactionFlow1" processingStrategy="allow1Threads">
<vm:inbound-endpoint exchange-pattern="one-way" path="TaskQ" connector-ref="VM" doc:name="VM">
</vm:inbound-endpoint>
<logger message="Started Processing #[payload]" level="INFO" doc:name="Logger"/>
<component class="vmtransaction.demo.ProcessingTask" doc:name="Java"/>
<logger message="finished the sync vm invoke #[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Read more »

Mule flow with groovy script

Posted on 2013-11-11 |
1
2
3
4
5
6
7
8
9
10
11
<flow name="get:/setVariable:api-config">
<set-variable variableName="username" value="" doc:name="username"/>

<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy">
<![CDATA[
String value = 'felipe'
message.setInvocationProperty('username', value)
]]></scripting:script>
</scripting:component>
</flow>
1
2
3
4
//More options of set Value inside Groovy
message.setInvocationProperty('myFlowVariable', 'value') // sets a flow variable, like <set-variable/>
message.setOutboundProperty('myProperty', 'value') // sets an outbound message property, like <set-property/>
message.setProperty('myInboundProperty', 'value', PropertyScope.INBOUND) // sets an inbound property
Read more »
1…1718
Rachel Rui Liu

Rachel Rui Liu

178 posts
193 tags
RSS
GitHub Linkedin
© 2021 Rachel Rui Liu
Powered by Hexo
Theme - NexT.Pisces
0%