반응형
반응형
반응형



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


반응형
반응형


이클립스에서 commit 하다 cancel 을 했다.


다시 commit 하려고 하니까 lock 걸려서 진행이 안됨.


보통은 team > cleanup 하면 된다고 한다.


그리고 lock 파일이 있는지 찾아보라고 하는데.. 없다..


결국 직접 svn db 파일을 수정해서 해결.


1. sqlite 클라이언트 다운로드

 - http://sqlitebrowser.org/


2. sqlite 클라이언트 실행해서 DB를 연다.

 - .svn 디렉토리 밑에 wc.db 파일.


3. sql 실행 탭에서 아래 쿼리 실행.

 - DELETE FROM WORK_QUEUE;

 - DELETE FROM WC_LOCK;


4. wc.db 파일 저장.(sqlite 클라이언트 종료)


이제 잘된다....



출처: http://finkle.tistory.com/124


반응형
반응형



ajax 로 array data request 시 서버에서 받는 방법.



var a = [];

a[0] = 1;

a[1] = 2;

a[2] = 3;


$.ajax({


url : "/test.json",

type : "POST",

data: {

'array_data' : a

},

dataType: 'json',

success: function(data) {

},

error: function(data, status, err){

}

});





Spring 에서 요렇게 받을수 있다.

@RequestParam(value = "array_data[]", required = false) List<String> arrayData


sprint 3.x, jquery 1.10.x




반응형
반응형


하이버네이트 native sql  사용.


List<Map<String, Object>> 로 return.

String sql = "SELECT first_name, salary FROM EMPLOYEE";
SQLQuery query = session.createSQLQuery(sql);
query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
List results = query.list();


아래 함수를 사용하지 않을 경우에는 List<Object[]> 로 return.

setResultTransformer()


참조

https://www.tutorialspoint.com/hibernate/hibernate_native_sql.htm


다른 도움 사이트.

https://docs.jboss.org/hibernate/orm/3.3/reference/ko-KR/html/querysql.html



반응형
반응형


@Scheduled(cron="*/5 * * * * *")

Spring 에서 scheduler 를 사용하면 non-daemon thread 로 동작한다.

daemon thread 로 동작하게 할려면 아래와 같이 xml 설정을 해서 사용한다.


<beans:bean id="scheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler">

        <beans:property name="poolSize" value="10" />

        <beans:property name="threadNamePrefix" value="My-Scheduler-"/>

        <beans:property name="waitForTasksToCompleteOnShutdown" value="false" />

        <beans:property name="daemon" value="true" />

    </beans:bean>

    <task:annotation-driven scheduler="scheduler"/>



반응형
반응형




텍스트로 붙여넣으니까 칸이 안 맞아서 이미지로. --;;ㅋ




소스.



import java.nio.Buffer;

import java.nio.IntBuffer;


...


IntBuffer buffer = IntBuffer.allocate(10);


// put

buffer.put(11);

buffer.put(13);


// flip - write 후 read 를 위해 flip

buffer.flip();

while (buffer.hasRemaining()) {

buffer.get();

}


// 처음부터 다시 read 하기 위해 rewind

buffer.rewind();

while (buffer.hasRemaining()) {

buffer.get();

}


// 다시 한번 rewind

buffer.rewind();

buffer.get();


// compact - 읽지 않은 data 를 처음부터 배치시키고 position 이동.

buffer.compact();


buffer.put(15);


buffer.flip();

while (buffer.hasRemaining()) {

buffer.get();

}


// 초기화.

buffer.clear();


buffer.put(15);


// 현재 위치를 mark.

buffer.mark();


buffer.put(19);


// mark 한 position 으로 이동.

buffer.reset();


buffer.get();





반응형
반응형

원문.

http://www.ibm.com/developerworks/library/j-zerocopy/


번역.(이미지가 안 보이니까 원문에서 그림을 보면서 읽으면 됨)

http://highway101.tistory.com/301


반응형

+ Recent posts