반응형
반응형
반응형

var obj = {};

// var obj = new Object() 이다.

// Object 도 기본적으로 함수이다. function Object()


// var o = new obj();

// 이렇게는 사용할 수 없다. obj is not constructor.

// constructor 가 있어야만 new 를 통해서 객체를 만들수 있다.

// 따라서 함수만 new 키워드를 사용 할 수 있다.


var a = {a: 1};

// a ---> Object.prototype ---> null


// Error literal object 에는 prototype 을 재정의 할 수 없음.

//a.prototype.getA = function() {

//    return this.a;

//}


// b 의 prototype 이 a 가 된다.

var b = Object.create(a);

// b ---> a ---> Object.prototype ---> null

//console.log(b.a); // 1 (상속됨)


// Error literal object 에는 prototype 을 재정의 할 수 없음.

//b.prototype.getA = function() {

//    return "A";

//}



// 일반 객체에는 prototype 을 정의할 수 없다.

// 그냥 prototype 이라는 속성으로 인식함.

try {

    var p = {

        a: 10,

        b: 20

    }


    // 일반객체에 prototype 을 정의할 수 없음.

    // "prototype" 이라는 속성이 추가 되는 것임.

    // __proto__ 변수에 매핑 되는 것이 아님.

    p.prototype = {

        getA: function () {

            return this.a;

        }

    }


    console.log("p = ", p);

    console.log("p.a = ", p.a);

    console.log("p.__proto__ = ", p.__proto__);

    console.log("p.prototype = ", p.prototype);

    //console.log("p.getA() = ", p.getA()); // p 객체에는 getA 함수가 없음. 프로토타입 체인으로도 찾을 수 없음.

    //console.log("p.prototype.getA() = ", p.prototype.getA()); // p.prototype.getA 함수에서 this 지시자를 사용 할 수 없음.



    // Object.create(p) 이용하여 p1 이라는 새로운 객체 생성.

    // p1.__proto__ = p 이라는 의미가 됨.

    console.log();

    console.log("=================================================");

    console.log("p1 = Object.create(p)");

    var p1 = Object.create(p);


    console.log("p1 = ", p1);

    console.log("p1.__proto__ = ", p1.__proto__);

    console.log("p1.prototype = ", p1.prototype); // "prototype" 이라는 속성.

    console.log("p1.__proto__.__proto__ = ", p1.__proto__.__proto__);


    console.log("p1.a = ", p1.a); // p1.__proto__.a

    //console.log("p1.getA() = ", p1.getA()); // p1, p1__proto__ 객체에 getA 라는 함수는 없다.

    //console.log("p1.prototype.getA() = ", p1.prototype.getA()); // p1__proto__.prototype.getA 함수에서 this 지시자를 사용 할 수 없음.


} catch(err) {

    console.log(err);

}


// prototype 설명 : https://medium.com/@bluesh55/javascript-prototype-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0-f8e67c286b67.

// 함수를 정의하는 순간 Prototype Object 도 생성됨.

// Prototype Object 는 일반적인 객체와 같으며 기본적인 속성으로 constructor 와 __proto__ 를 가지고 있음.

// constructor는 Prototype Object와 같이 생성되었던 함수.

// __proto__는 Prototype Link.

// __proto__는 객체가 생성될 때 조상이었던 함수의 Prototype Object를 가리킴.

// Foo 는 function 객체.

// Foo.__proto__ == Function.prototype. 따라서, F.call() 호출 가능하다.

// Foo.constructor 는 Function. Foo.__proto__ 의 생성자.

function Foo() {

    this.a = 1;

}



// new 키워드로 객체 생성. 생성자 함수 호출. 생성자를 바탕으로 객체를 생성한다.

// foo.__proto__ 은 Foo.prototype 이다.

// foo.__proto__.constructor 는 function Foo() 이다.

// foo.hasOwnProperty("constructor") === false

var foo = new Foo();

console.log("foo.a", foo.a);

// var foo = new Object();

// foo.__proto__ = Foo.prototype;

// Foo.call(foo);



// prototype과 constructor는 부모자식 관계

if(foo.__proto__ === Foo.prototype) {

    console.log("foo.__proto__ === Foo.prototype");

}


if(foo.__proto__.constructor === Foo) {

    console.log("foo.__proto__.constructor === Foo");

}




function Person() {

    this.name = "anonymous";

    this.job = "none";

    this.sayHello = function () {

        console.log("Hello, my name is " + this.name);

    };

}


function Unikys() {

    this.name = "Unikys";

    this.job = "Programmer";

}


// #1.

Unikys.prototype = new Person();

var unikys1 = new Unikys();

unikys1.sayHello();

//unikys1 instanceof Unikys === true, unikys1 의 prototype 과 Unikys 의 prototype 이 같기 때문.

//unikys1 instanceof Person === true

// unikys1.constructor = function Persion()

// constructor 는 객체에 있는 것이 아니라 prototype 에 있는 것. prototype 의 생성자.(Person객체의 생성자 = function Persion()).

// constructor 가 있는 prototype 을 다른 새로운 객체로 덮어씌우게 되면 원래 자기 자신의 contstructor 는 상실하게 됨.

// 따라서 unikys1 이 new Unikys()로 생성했다고 하더라도 constructor 는 Unikys() 가 아니라 prototype 으로 덮어씌운 객체의 constructor 인 Person() 이 된다.



// #2.

var unikys2 = Object.create(Person.prototype);

unikys2.name = "Unikys";

// 부모 함수의 일부 메서드에 위임을하고 새 개체를 만들지 않으려면 Object.create 를 사용하는 것이 좋음.

// 부모 함수에 있는 속성은 사용할 수 없기 때문에 부모 속성을 사용하지 않는 경우에 사용.

// unikys2.sayHello(); // Error.

// unikys2 의 prototype 을 Person.prototype 으로 정의. unikys2.__proto__ === Person.prototype.

// 대신 Person 의 속성들은 사용할 수 없어서 추가로 정의해야 함.(name 등)

// unikys2 instanceof Person === true

// unikys2.constructor === Person. true.



// #3.

var unikys3 = Object.create(Person);

unikys3.name = "Unikys";

//unikys3.sayHello();

// unikys3 의 prototype 을 Person 으로 정의. unikys3.__proto__ === Person

// unikys3.constructor === Person. false.

// unikys3.constructor === Function. true.

// constructor 는 prototype 의 생성자를 가르킨다.

// unikys3 instanceof Person === false

// unikys3 instanceof Function === true

// Person.isPrototypeOf(unikys3) == true




// prototype은 모든 객체가 공유하고 있어서 한 번만 만들어지지만, this에 넣은 것은 객체 하나를 만들 때마다 메소드도 하나씩 만들어지기 때문에 불필요한 메모리 낭비.

Person.prototype.yell = function () {

    console.log("My name is " + this.name);

}


// #4.

// prototype chain 추가.

Unikys.prototype = Object.create(Person.prototype); // Unikys.prototype = Person.prototype; 으로 했을 경우에는 Unikys.prototype 에 속성을 추가하면 Person.prototype 에도 추가가 된다.

// Unikys.prototype.__proto__ === Person.prototype

// Unikys.prototype.constructor === Person

// Unikys.constructor === Function


console.log(Unikys.constructor);

Unikys.prototype.constructor = Unikys;

// Unikys 객체들의 constructor 를 Unikys 로 정의.


var unikys4 = new Unikys();

console.log(unikys4.name);

//unikys4.sayHello();

// unikys4.__proto === Unikys.prototype

// unikys4.constructor === Unikys

// unikys4.hasOwnProperty("constructor") === false

// unikys4.__proto__.hasOwnProperty("constructor") === false

// unikys4.__proto__.hasOwnProperty("yell") === false

// unikys4.__proto__.__proto__.hasOwnProperty("yell") === true



function Vehicle(name, speed) {

    this.name = name;

    this.speed = speed;

}

Vehicle.prototype.drive = function () {

    console.log(this.name + ' runs at ' + this.speed)

};


function Sedan(name, speed, maxSpeed) {

    // Vehicle 생성자에 this와 arguments를 적용하라.

    // Sedan은 매개변수로 name과 speed, maxSpeed. maxSpeed는 Vehicle이 갖고 있지 않기 때문에 무시. maxSpeed 속성을 따로 추가.

    Vehicle.apply(this, arguments)

    this.maxSpeed = maxSpeed;

}


// Sedan.prototype = new Vehicle(); // 이렇게 하면 new Sedan 할때 Vehicle 이 두번 호출 되는 결과가 발생한다. 그리고 Vehicle 의 속성까지도 가지게 된다.

Sedan.prototype = Object.create(Vehicle.prototype);

Sedan.prototype.constructor = Sedan;

Sedan.prototype.boost = function () {

    console.log(this.name + ' boosts its speed at ' + this.maxSpeed);

};

var sonata = new Sedan('sonata', 100, 200);

sonata.drive(); // 'sonata runs at 100'

sonata.boost(); // 'sonata boosts its speed at 200'



printOwnProperties(sonata);



function printOwnProperties(obj) {

    console.log('==============================================');

    console.log('============ Print Own Properties ============');

    console.log('==============================================');

    for (var key in obj) {

        console.log('property       = ' + key);

        console.log('typeof         = ' + (typeof key));

        console.log('hasOwnProperty = ' + (obj.hasOwnProperty(key)));

        console.log('value          = ' + obj[key]);

        console.log('');

    }

}


var c = function() {return a;}



반응형

'프로그래밍 > Javascript' 카테고리의 다른 글

undefined ?  (0) 2021.08.06
javascript containsAll  (1) 2016.11.04
[jquery] hide, show 함수, visibility 속성  (0) 2016.10.28
jquery crossdomain ajax jsonp  (1) 2015.10.30
한글, 영문 check  (0) 2011.12.27
반응형



public class SingletonClass {

private static SingletonClass instance;

private SingletonClass () {}

// thread safe

public static synchronized SingletonClass getInstance () {

if ( instance == null ) {

instance = new SingletonClass();

}

return instance;

}

public void print () {

System.out.println("hashCode : " + instance.hashCode());

}

}



반응형

'프로그래밍 > Java' 카테고리의 다른 글

[Spring Boot] log4jdbc 설정.  (1) 2020.01.16
Rabbit MQ 간단 사용.  (0) 2018.12.21
openfire(xmpp) client  (0) 2018.11.06
openfire 플러그인 개발.  (0) 2018.11.06
openfire  (0) 2018.11.06
반응형


* Spark ( 메신저 클라이언트) - eclipse에서 빌드하기

 

1. 기존 IDE - eclipse , EGit, JDK, Ant

 

2. 소스 download - https://github.com/igniterealtime/Spark.git

 

3. build  - build/build.xml

 

4. run 

1) Run -> Run Configurations 선택

 

2) Java Application -> New  선택

 

(1) Main탭

: Name, Project, Main class를 등록Main class는 Startup를 Search )

 

(2) Calsspath 탭

: src/resources를 등록

 

(3) JRE탭 : 1.8를 선택

 

5. installer - build/installer/spark.install4j

 

설치본의 위치를 변경하는 부분




mysql> grant all privileges on openfire.* to openfire@`%` identified by 'password’ with grant option;

mysql> flush privileges;




어플리케이션.


For Mac OS X

1. Adium

 - https:/​/​www.adium.im

 - Enable XMPP Advanced Features (Default: Off)

 - To enable the XML Console menu run the following command in Terminal: defaults write com.adiumX.adiumX AMXMPPShowAdvanced -bool YES

 - File > [Logged in User] > XML Console.

 - stream 메시지는 안 보이고 stanzas 메시지만 보임.

 - 참조 : https://developer.cisco.com/media/finesseDevGuide4.1/cfin_r_adium-for-mac-os-x.html



2. Spark

 - http://www.igniterealtime.org/downloads/index.jsp




For Windows

1. Gajim

 - https://gajim.org/

 - Actions > Advanced > Show XML Console 메뉴.

 - 근데 가상 windows 에서 잘 안됨. XML Console 은 보이는데 대화창에 대화가 안 보임.ㅠ



반응형

'프로그래밍 > Java' 카테고리의 다른 글

Rabbit MQ 간단 사용.  (0) 2018.12.21
singleton 객체.  (0) 2018.12.06
openfire 플러그인 개발.  (0) 2018.11.06
openfire  (0) 2018.11.06
이클립스에서 svn lock 걸렸을 경우...  (0) 2017.04.07
반응형


플러그인 개발 가이드.

http://download.igniterealtime.org/openfire/docs/latest/documentation/plugin-dev-guide.html



플러그인 디렉토리에 하위 디렉토리를 추가한다.

 - Openfire-3.10.2/src/plugins


 - 다음과 같은 디렉토리 구조로 추가.

   + helloWorld ———————> 플러그인 명.

     + src

       + java ———————> 소스 디렉토리로 지정.

         + com.my.openfire.plugin.test ———————> 패키지 명.

           + HelloWorldPlugin.java

     + web

       + index.html

     + plugin.xml



1. plugin.xml


        <?xml version="1.0" encoding="UTF-8"?>

        <plugin>

            <class>com.my.openfire.plugin.test.HelloWorldPlugin</class>

            <name>HelloWorld</name>

            <description>HelloWorld plugin</description>

            <author>trvoid</author>

            <version>1.0</version>

            <date>05/16/2013</date>

            <url>http://trvoid.blogspot.com</url>

            <minServerVersion>3.0.0</minServerVersion>

            <licenseType>internal</licenseType>


            <adminconsole>

                <tab id="tab-helloworld" name="HelloWorld"

                        description="Click to manage HelloWorld">

                    <sidebar id="sidebar-hello-config" name="Configuration">

                        <item id="hello-intro" name="Introduction" url="index.html" description="Click to view Introduction"/>

                    </sidebar>

                </tab>

            </adminconsole>

        </plugin>



2. HelloWorldPlugin.java


package com.my.openfire.plugin.test;


import org.jivesoftware.openfire.container.Plugin;

import org.jivesoftware.openfire.container.PluginManager;

import org.jivesoftware.openfire.event.SessionEventDispatcher;

import org.jivesoftware.openfire.event.SessionEventListener;

import org.jivesoftware.openfire.session.Session;

import org.jivesoftware.util.JiveGlobals;


import java.io.File;


public class HelloWorldPlugin implements Plugin {

private static String MYOPTION = "값";


public void setMyOption(String value) {

JiveGlobals.setProperty(MYOPTION, value);

}


public String getMyOption() {

return JiveGlobals.getProperty(MYOPTION, "기본값");

}

@Override

public void initializePlugin(PluginManager manager, File pluginDirectory) {

System.out.println("init HelloWorldPlugin.");

System.out.println("add SessionEventListener.");

SessionEventDispatcher.addListener(new MySessionEventListener());

}


@Override

public void destroyPlugin() {

System.out.println("destroy HelloWorldPlugin.");

}

private class MySessionEventListener implements SessionEventListener {

@Override

public void sessionCreated(Session session) {

System.out.println("MySessionEventListener sessionCreated.");

}


@Override

public void sessionDestroyed(Session session) {

System.out.println("MySessionEventListener sessionDestroyed.");

}


@Override

public void anonymousSessionCreated(Session session) {

System.out.println("MySessionEventListener anonymousSessionCreated.");

}


@Override

public void anonymousSessionDestroyed(Session session) {

System.out.println("MySessionEventListener anonymousSessionDestroyed.");

}


@Override

public void resourceBound(Session session) {

System.out.println("MySessionEventListener resourceBound.");

}

}

}



3. index.html


        <html>

            <head>

                <title>HelloWorld</title>

                <meta name="pageID" content="hello-intro"/>

            </head>

            <body>

                <h1>Hello World!</h1>

            </body>

        </html>



4. 전체 플러그인 빌드

 $ ant plugins


5. 하나의 플러그인 빌드

 $ ant -Dplugin=<pluginName> plugin


6. 플러그인 설치

 1) Admin Console의 Plugins 탭으로 이동한다.

 2) "파일 선택" 버튼을 눌러 아래의 위치에서 설치하고자 하는 플러그인 파일을 선택한다.

    openfire_src\target\openfire\plugins


 3) "Upload Plugin" 버튼을 누른다.




반응형

'프로그래밍 > Java' 카테고리의 다른 글

singleton 객체.  (0) 2018.12.06
openfire(xmpp) client  (0) 2018.11.06
openfire  (0) 2018.11.06
이클립스에서 svn lock 걸렸을 경우...  (0) 2017.04.07
ajax 로 array data request 시 서버에서 받는 방법.  (0) 2016.12.05
반응형

xmpp

 - http://www.xmpp.co.kr/node/1

 - http://yolongyi.tistory.com/31

 - http://myeonguni.tistory.com/820



참조

 - https://community.igniterealtime.org/docs/DOC-1020

 - http://printhelloworld.tistory.com/6

 - http://arnosp.tistory.com/6



Openfire 3.10.2


1.오픈파이어 소스 다운로드

- https://github.com/igniterealtime/Openfire/tree/v3.10.2



2. 오픈파이어 압축 해제

 - 압축 해제.

 - Openfire-3.10.2/build/eclipse/ 경로안에 있는 파일 복사하여 Openfire-3.10.2/ 경로에 붙여넣는다.(2개 파일과 1개 폴더)

   - 각각 파일과 폴더 이름을 변경한다 앞에 .을 붙임

     - mv settings .settings

     - mv project .project

     - mv classpath .classpath



???

mysql 설정?

characterEncoding=UTF8



3. 이클립스에서 Openfire-3.10.2를 import한다.

 - General - Existing Projects into Workspace



4. build path 추가.

 - compile 에러 해결.

   - build path 에 jar 추가.

     - build/lib/merge/jetty-servlets.jar

     - build/lib/merge/spdy-http-server.jar

     - 아래 3개의 파일중 하나 추가

       - src/plugins/mucservice/lib/jersey-bundle-1.18.jar

       - src/plugins/restAPI/lib/jersey-bundle-1.18.jar

       - src/plugins/userservice/lib/jersey-bundle-1.18.jar


 - Ant 빌드.

   - build/build.xml


5. Run

 - 실행파일

   : org.jivesoftware.openfire.starter.ServerStarter.java


 - Arguments 탭에 추가.(VM arguments)

   : -DopenfireHome="${workspace_loc:Openfire-3.10.2}/target/openfire


 - Calsspath 탭에 추가.(User Entries)

   - Advanced - Add Folders 메뉴.

   : src/i18n , src/resource/jar , build/lib/dist를 등록



6. installer - build/installer/openfire.install4j

 



log4j 설정.

 - ~/work/lib/log4j.xml


반응형
반응형


package.json 설명.


https://programmingsummaries.tistory.com/385

반응형

'프로그래밍 > nodejs' 카테고리의 다른 글

[nodejs] 버전 업데이트  (0) 2021.07.20
nodejs 설치.  (0) 2020.03.02
반응형



참조 : https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EB%B0%98%EB%B3%B5_%EC%98%88%EC%95%BD%EC%9E%91%EC%97%85_cron,_crond,_crontab




cron 등록.



*   *  *   *  *  수행할 명령어

┬ ┬ ┬ ┬ ┬

│ │ │ │ │

│ │ │ │ │

│ │ │ │ └───────── 요일 (0 - 6) (0:일요일, 1:월요일, 2:화요일, …, 6:토요일)

│ │ │ └───────── 월 (1 - 12)

│ │ └───────── 일 (1 - 31)

│ └───────── 시 (0 - 23)

└───────── 분 (0 - 59)




* * * * * /root/every_1min.sh

→ 매 1분마다 /root/every_1min.sh 를 수행


15,45 * * * * /root/every_30min.sh

→ 매시 15분, 45분에 /root/every_30min.sh 를 수행


*/10 * * * * /root/every_10min.sh

→ 10분마다 /root/every_10min.sh 를 수행


0 2 * * * /root/backup.sh

→ 매일 02:00에/root/backup.sh 를 수행


30 */6 * * * /root/every_6hours.sh

→ 매 6시간마다 수행(00:30, 06:30, 12:30, 18:30)


30 1-23/6 * * * /root/every_6hours.sh

→ 1시부터 매 6시간마다 수행(01:30, 07:30, 13:30, 19:30)


0 8 * * 1-5 /root/weekday.sh

→ 평일(월요일~금요일) 08:00


0 8 * * 0,6 /root/weekend.sh

→ 주말(일요일, 토요일) 08:00

반응형

'OS > Linux' 카테고리의 다른 글

[링크] 파일 권한  (0) 2019.05.09
tcpdump  (2) 2019.02.11
CentOS 버전 정보 확인.  (0) 2018.07.31
쉘 스크립트(shell script) - 예제.  (0) 2016.02.22
환경변수 제거 후 스크립트 실행.  (0) 2016.02.12
반응형


authentication

 - 신분을 확인하는 인증

 - 실체의 신원이나 메시지의 근원지를 확인하기 위한 인증

 - 클라이언트에서는 유저를 인증할 수 있는 각종 정보를 전송하고, 서버는 이를 가지고 유저의 존재성을 확인.

 - 로그IN : 아이디 비밀번호를 아는 사람은 누구나 들어갈 수 있다.


authorization

 - 접근·허가를 결정하는 인가

 - 특정 신분 정보를 제공하는 주체나 실체의 특정 자원에 대한 접근 권한 여부를 결정하는 인가

 - 로그ON : 아이디 비밀번호를 아는 사람이 특정인이라고 간주한다.


certification

 - 어떠한 능력이나 기능에 대해 인정받았음. 일정 기준을 넘었을때 주어지는 것.

 - 인증기관, 심사에 의한 자격을 부여해주는 기관의 인증, 심사의 기준을 통과한 인증


반응형

'Tip & Tech > Information' 카테고리의 다른 글

OSI 7 Layer - network  (0) 2015.08.13
SSL, HTTPS 정리.  (2) 2015.07.10
iptime N604R 공유기에 vpn 기능 추가하기.  (2) 2015.05.12
제로보드 백업  (0) 2014.03.24
유용한 사이트 모음  (0) 2014.03.24
반응형


CentOS 버전 정보 확인하는 방법.



1. cat /etc/*-release | uniq


2. cat /etc/issue


3. rpm -qa centos-release*



반응형

'OS > Linux' 카테고리의 다른 글

tcpdump  (2) 2019.02.11
crontab  (0) 2018.09.12
쉘 스크립트(shell script) - 예제.  (0) 2016.02.22
환경변수 제거 후 스크립트 실행.  (0) 2016.02.12
쉘 스크립트(shell script) - 날짜  (0) 2015.08.21
반응형


맥북에서 메일 콘텐츠 위치.

 - OS X El Capitan


~/Library/Containers/com.apple.mail/Data/Library/Mail Downloads



반응형

+ Recent posts