자바·JSP2012. 9. 25. 20:52

Java Application은 각각 별도의 jvm process로 동작하므로 상호 통신 및 정보를 주고받기에 여러가지 에로사항이 있다. 그로 인해 현재 동일한 프로그램이 실행되고 있는지를 체크하는 방법이 여러가지가 편법(?)으로 사용되고 있는데, 그 중 몇 가지를 나열해 보자면

1. Database Flag 값 변경.
2. 환경설정 파일 변경 혹은 파일 생성 후 락.
3. 임의의 사용하지 않는 port 할당.

 우선 2번은

      // lock 을 시도합니다.
      lock = channel.tryLock();

      // lock이 null이라는 것은 다른 JVM에서 이미 파일의 lock을 획득했다는 것입니다. 따라서 채널을 종료하고
      // 예외를 발생시켜 runnable의 값을 false로 유지시킵니다.
      if (lock == null) {
        channel.close();
        throw new Exception();
      }

이런 식으로 사용이 가능하다.

 

또 3번은

        try {
            isRun = new DatagramSocket(1103);
        } catch (SocketException e) {
            throw new MonitoringException();
        }

이런 식으로 사용이 가능하겠다.

Posted by 미랭군

<mx:ColumnSeries id="secondSeries" xField="date" yField="name" interactive="false">
   
</mx:ColumnSeries>

'플렉스·플래시·액션스크립트3' 카테고리의 다른 글

BlazeDS와 Tomcat7 최신 버젼 호환성  (0) 2012.11.06
amf 통신 시 규약  (0) 2012.10.29
컬럼챠트에 평균 라인 긋기  (0) 2012.09.18
Event Model의 이해  (0) 2012.08.10
UIComponent Lifecycle  (0) 2012.08.08
Posted by 미랭군


Main.mxml


<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” >

<mx:Script>

import mx.collections.ArrayCollection;


[Bindable]

public var dataCollection:ArrayCollection = new ArrayCollection([

{Month: "Jan", planned: 2000, actual:1856, average:1790 },

{Month: "Feb", planned: 1590, actual:1624, average:1790},

{Month: "Mar", planned: 1820, actual:1832,average:1790},

{Month: "Apr", planned: 1450, actual:1524, average:1790},

{Month: "May", planned: 1775, actual:1695, average:1790}]);

</mx:Script>


<mx:Panel>

<mx:ColumnChart id=”myChart” dataProvider=”{dataCollection}”

showDataTips=”true”>

<mx:horizontalAxis>

<mx:CategoryAxis dataProvider=”{dataCollection}”

categoryField=”Month”/>

</mx:horizontalAxis>

<mx:series>

<mx:ColumnSeries xField=”Month” yField=”planned” displayName=”Planned”/>

<mx:ColumnSeries xField=”Month” yField=”actual” displayName=”Actual”/>

<mx:ColumnSeries xField=”Month” yField=”average” displayName=”Average”

itemRenderer=”AverageLineRenderer”/>

</mx:series>

</mx:ColumnChart>

</mx:Panel>

</mx:Application>


AverageLineRenderer.as


package

{

import flash.display.Graphics;

import mx.charts.ChartItem;

import mx.charts.series.items.ColumnSeriesItem;

import mx.charts.series.items.LineSeriesItem;

import mx.controls.Label;

import mx.core.IDataRenderer;

import mx.core.UIComponent;


public class AverageLineRenderer extends UIComponent implements IDataRenderer

{

private var _chartItem:ChartItem;

private var _label:Label; // A label to place on the top of the column.


public function AverageLineRenderer():void

{

super();


// Add the label

_label = new Label();

addChild(_label);

_label.setStyle(“color”,0×000000);

}


public function get data():Object

{

return _chartItem;

}


public function set data(value:Object):void

{

if(value is ColumnSeriesItem)

{

_chartItem = value as ColumnSeriesItem;


if(_chartItem != null)

{

// Assigns the yValue to the label

if (ColumnSeriesItem(_chartItem).yValue!=null)

_label.text = “Average: ” + ColumnSeriesItem(_chartItem).yValue.toString();

else

_label.text=”";

}

}

}


override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

{


if ( _chartItem.index == 0) // Do it only for the first chartItem

{

super.updateDisplayList(unscaledWidth, unscaledHeight);


var g:Graphics = graphics;

g.clear();

g.beginFill(0xFF0000); // Red line, you can select your own color

// Draw the line across the chart. This is actually a rectangle with height 1.

g.drawRect(-20,0,this.parent.width+20, 1);

g.endFill();

//Place the label

_label.setActualSize(_label.getExplicitOrMeasuredWidth(),_label.getExplicitOrMeasuredHeight());

_label.move(unscaledWidth ,-15);

}


}

}

}

Posted by 미랭군