September 2008 Archives

1. 가브리엘스 오보에

엔리오 모리코네 지휘

 

 

2. 경기병 서곡

 

3. 브람스 헝가리안 댄스 5번

 

4. 리베르 탱고

 

5. 윌리엄텔 서곡

어릴적 형이 죽도록 틀던.. 이글스의 호텔 캘리포니아(hotel california)이다. 오래된 영상임에도 촌스럽지 않음이 놀랍고... 보컬이 드러머 였다는 것도 좀 놀랍고.. 드러머의 음색도 놀랍다.. 
prototype.js

1. 개요

prototype는 Ajax의 성장에 기여한 라이브러리이다. 샘스테판이 제작하였으며 prototypejs.org에서 다운로드 받을 수 있다.
prototype 라이브러리는 자바스크립트 프로토타입을 기반으로 클래스를 에뮬레이션하는 방법을 제공한다. 또한, 자바스크립트에서 페이지 내의 여러 엘리먼트에 접근하는 유용한 기능을 제공한다. javascript의 실제 동작을 Wrapping하고 있기 때문에 javascript에 익숙하지 않은 개발자에게는 오히려 혼란을 줄 수도 있다.

2. 설치

다운로드 받은 prototype.js 파일을 웹페이지 에서 아래와 같이 코드 하는 것만으로 설치는 끝이다. 물론 해당 경로에 prototype.js를 복사해 두는 것을 잊지 말자.

<script type="text/javascript" src="prototype.js" ></script>

3. 사용

3.1 헬퍼 함수와 스크립트 확장
Prototype에서 제공하는 헬퍼함수는 대부분 $로 시작한다. 가장 자주 사용하는 함수는 $()로 document.getElementById 대신 사용한다. 다만 엘리먼트 리스트를 지정하면, 엘리먼트의 배열을 반환한다.

var theDivs = $('div1', 'div2', div3' );

$F는 폼 필드의 값을 반환한다. $H 함수는 객체를 열거형 Hash로 반환해 준다.
아래 코드는 객체를 prototype의 Hash객체로 변환하고 Hash함수중에 하나인 values를 이용해서 자바스크립트 배열에 저장한다.

var obj = {
partA : one,
partB : two,
partC : three
};
var hashObj = $H(obj);
var arr = hashObj.values();

$R함수는 new ObjectRange(lowerBound, upperBound, excludeBounds) 를 작성하기 위한 짧은 형태이다. ObjectRange의 each 메소드를 이용하여 iterator 로서의 기능을 지원한다.

var range = $R(10, 20, false);
range.each( function(value, index){
alert(value );
});


JMX - MX4J Sample

| 댓글 없음 | 트랙백 없음
JMX(Java Management Extensions)는 프로그래머들에게 자바 어플리케이션의 모니터링과 관리 기능을 제공한다. Java 어플리케이션을 로컬 혹은 원격에서 관리할 수 있도록한다. 
JMX 의 구현체인 MX4J의 Sample코드를 따라 해보자..

RMI MBean Example

RMI 리모트 객체를 MBeans 로서 노출시키는 방법을 설명하고 있다.

JMX를 통하여 이 리모트 객체의 구현체인 서비스를 기동/종료/재기동이 가능하고 기동여부를 확인하고 설정을 변경이 가능하게 될 것이다.


Sample Classes

sample Class는 아래의 5개 클래스로 구성되어 있다. 

Server (리모트 서비스를 구동하는 클래스) 
Client (클라이언트 클래스) 
MyRemoteService (리모트 인터페이스) 
MyRemoteServiceObjectMBean ( management interface) 
MyRemoteServiceObject (리모트 인터페이스를 구현한 the MBean )


설명

MyRemoteServiceObject는 MBean이자 Remote 객체이다.
Client는 이 두 인터페이스를 통해서 접근하게 된다.

리모트 인터페이스인 MyRemoteService는 단 하나의 메소드만 가진다.

public void sayHello( String name );

이것은 Client의 요청을 실행하게 될 것이다.

Management Interface인 MyRemoteSeviceObjectMBean은 3개의 메소드를 가진다.

public void start() 
public void stop() 
public boolean isRunning()


구현체들

Server Class

                  
public class Server
{
   public static void main(String[] args) throws Exception
   {
      MBeanServer server = MBeanServerFactory.createMBeanServer();

      ObjectName name = new ObjectName("examples:type=remote");
      MyRemoteServiceObject remote = new MyRemoteServiceObject();
      server.registerMBean(remote, name);

      MyRemoteServiceObjectMBean managed = (MyRemoteServiceObjectMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, MyRemoteServiceObjectMBean.class, false);
      managed.start();
   }
}
         

MyRemoteServiceObject Class

                  
public class MyRemoteServiceObject extends RemoteServer implements MyRemoteService, MyRemoteServiceObjectMBean
{
   private boolean m_running;

   public MyRemoteServiceObject() throws RemoteException {}

   public void sayHello(String name) throws RemoteException
   {
      System.out.println("Hello, " + name);
   }

   public void start() throws Exception
   {
      if (!m_running)
      {
         UnicastRemoteObject.exportObject(this);
         InitialContext ctx = new InitialContext();
         ctx.rebind(JNDI_NAME, this);
         m_running = true;
         System.out.println("My remote service started successfully");
      }
   }

   public void stop() throws Exception
   {
      if (m_running)
      {
         InitialContext ctx = new InitialContext();
         ctx.unbind(JNDI_NAME);
         UnicastRemoteObject.unexportObject(this, false);
         m_running = false;
         System.out.println("My remote service stopped successfully");
      }
   }

   public boolean isRunning()
   {
      return m_running;
   }
}
               
               


실행 
정가 결혼 축하... 성철씨 화이팅!! 잘 살아 보세..!!!











About This Blog Author

정지범(jibum.jung@gmail.com)

Google AdSense

Clock Link

Developers Works

Creative Commons License
This blog is licensed under a Creative Commons License.