Special message to the visitors

In this area you can put any information you would like, such as: special offers, corporate motos, greeting message to the visitors or the business phone number.

This theme comes with detailed instructions on how to customize this area. You can also remove it completely.

Altı Kurşunlu Rus Ruleti

In this post, I covered basic integration of Flex and Spring JMS; summarized the flow of process in general.

Firstly I should explain the technology stack and what I want to do.

1- I need a RIA technology to push data from server to the client. Because I do not want to ask the server periodically if he has something new for him. This is an old-fashioned bullshit. So I will use Flex for user interface.

2- On server side, I want to process the requests asynchronously not to lock the user interface during the process. So, I need the “fire and forget” methodology of the JMS(Java Messaging Service) API. At this point I should emphasize that JMS is just an API to standardize the messaging services. There are plenty of implementations of JMS. I have chosen ActiveMQ because it has a support for:

  • virtual destinations to lower the number of required connections to message broker.
  • message persistance,
  • consumer priority,
  • message grouping,
  • different protocols like TCP,NIO to achieve the message broker and even an embedded one…

3- I want to do a professional job. What does it mean? I really really demand just to do my business and not to struggle with initilization and lifecycle management of the objects and decouple the modules to be able to plug them out when I found a more interesting and “new good-boy of the town” technology. Thus, I used Spring. Spring will initialize my objects, kill them when they are done. All I will do is to order what I want in the application context xml. Spring will do the job. Thanks Spring, love you, call me, my number is five oh five, oh sorry =)

4- The hard part, integrating the client and server side. That means, when client requests something, I need to solve it, send it to the server, the JMS destination, then take the message back and push it to the clients back. Ouucch? Shall I do this all by myself? Dont worry my friend, you will never walk alone. Spring-BlazeDS Integration will handle this all. You will just configure them. You are the boss, the king, the lord… Sorry, I am hooked on my words again. Somebody stop me:)

Well, lets do the job. Because words are cheap, time is too expensive. OK.

The diagram summarizes what we will do. Please look at it and if you are experienced correct me. There may be some misunderstanding of me. Care it, I really worked hard on it. Just for you man, just for you.


SBI-JMS-Flex

On client side, we will use the messaging API of Flex. It has consumers and producers. Producers generate a message and send it to post office called destination. The consumers subscribe to this destination. And wait for it, the clients the consumers that are subscribed to this destination are pushed this message. Wait wait wait… Pushed? Yeaah. Wow… But who do this magic, man? Blaze DS… Thanks to god, -or Adobe- there is this service that pushes the message to the desired consumers back. This is legendary, really.

The magic of the Blaze DS is the message broker. It finds the subscribers that are subscribed to the destination and push the message to them. Consumers do what they want with it. In our project BlazeDS runs on the server-side and it is managed by Spring. So lets first create our Flex mini project and then send our message to the BlazeDS message broker:

		

	
	
	
	

		
		
	
	


		

You see the consumer and producer definitions on line 2 and 3. We gave the same destination parameter to both of them. (This destination is in the ActiveMQ domain, the leftmost object in the diagram) Same client will produce a message and read it back after BlazeDS message broker push it back.

In diagram, you see the AMF channel. It is basically a channel that passes an actionscript object. It has an efficient format to carry the objects -much better than transporting them as XML-

On this AMF channel we transport our actionscript object message to the BlazeDS. So we define two AMF channels and set the channelset of the producer and consumer to this channel set. On the server hand of the channel the message is converted to a Java object and will be sent to the JMS destination. How? We will see it.

I say “message” repeated times. What the hack is that? As you can see, it is the AsyncMessage object. I will not dive into the details of the client side code more.

Going by step by step, everything will be clear. In this step, from Flex side we will request to the web context. And via a servlet request dispatcher, we direct this request to the Spring context. So lets define our dispatcher servlet:

 <servlet>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <!-- Map all *.spring requests to the DispatcherServlet for handling -->
    <servlet-mapping>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>

Ok, we will redirect a request that has a “spring” part to the Spring context. So

http://{HOST}/{PROJECT_NAME}/spring/…

such a request will be redirected to the Spring context. After that, this request should be sent to the AMF channel endpoint. For this, the channel should be configured properly in the Spring context. Remember, we need the “spring” part, then we expand our URI such a way that it consists the channel endpoint part.

I configured the channel part like this:

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="{HOST}/{PROJECT_NAME}/spring/amf" 
 
class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>

So, the request “{HOST}/{PROJECT_NAME}/spring/amf” will be dispatched to the Spring context first and then the AMF channel endpoint.

Now, we are going on following the diagram. The labeled as 3 parts are in BlazeDS domain. BlazeDS has a HTTPFlexSession that controls the flex session and a listener that listens the AMFChannelEndpoint for new messages. We define it in the web.xml as:

<listener>
        <listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>

This listener waits for a message and pass it through the message broker. Between two of them, an interceptor may be allocated. This interceptor may be managed by the Spring. So this interceptor may be registered as a bean in the Spring context:

<flex:message-broker>
        <flex:message-interceptor ref="interceptor"/>
</flex:message-broker>
<bean id="interceptor" class="PaperUpdateMessageProcessor"/>

Here, PaperUpdateMessageProcessor implements org.springframework.flex.core.MessageInterceptor.

As you can see in the diagram, the message coming from the interceptor is pushed to the JMS destination by messagebroker. But while transporting an adapter function should be invoked. This adapter for the MessageService integrates Flex messaging with Java Message Service destinations and configured in the messaging-config.xml with “jms” id:

<adapters>
        <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
        <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
</adapters>

Maven Projesine Internal Bir Proje Eklemek

Maven, dependencyleri repositoryler üzerinden edinmek için kullanılıyor.

Büyük ihtimalle yanlış bir şey yapıyorum ama,

Projemdeki entityleri ayrı bir proje olarak tutup jar olarak eklediğim için Maven’a geçişimden sonra bir dependency olarak gösteriyorum:

Dependency’nin scope’unun system olması önemli. Bunu sistem olarak ekledikten sonra yolunu gösteriyorum.

(Büyük ihtimalle bunu local repository’e eklemenin çok daha profesyonel bir yolu olmalı. Araştıracağım. Zira bu blog kimseye bir şey öğretmek için yazılmıyor. Sadece ileride hangi yollardan geçtiğimi görmek, yanlışlarımı gözüme sokmak, kafama çarpmak için tutuluyor. O yüzden bu yolu bulduğum zaman bu postu da güncelleyeceğim. Bence hepiniz seksi insanlarsınız. Bunun kıymetini bilin.)


            paperify
            entities
            1.0.0
            system
            D:\NetBeansProjects\entities\dist\entities.jar

Atamızın Köpeği Foks

foks, adı üstünde bir köpek, ama tilki gibi böyle, cingöz.
atatürk de bildiğiniz lider.
liderler cingöz olan ne varsa sever. insan da olsa hayvan da. o yüzden foks’u da çok seviyor.

atatürk aynı zamanda bir insan. bu yüzden evine insanlar gidip geliyor. e sevilen biri olduğundan çok fazla misafiri var.
bir ayet inip de “peygamberinizin evine gitmeyin, o yoruluyor, gitmeden haber verin, az kalın” diye uyarmadığı için, atatürk de misafirlerine çok değer verdiğinden onları evinden uzak tutamıyor. gelen misafir saatlerce oturuyor. bir köpeği saatlerce odaya kitleyemeyeceği için atatürk foks’u serbest bırakıyor. bu da, sehpaların altına giriyor, misafirlerin pantolonlarının paçalarını yiyor, kemiriyor, parçalıyor.
bundan mahçup olan atatürk, terzisine bu pantolonların aynısını yaptırıyor ve sahiplerine gönderiyor.

bunu farkeden misafirler başıyor cingözlüğe. eski pantolonlarıyla gidiyor ve paçalarını foks!a yediriyorlar. böyle böyle gardroblarını yeniliyorlar. cingözler. cingöz dedik ya, atatürk bu yüzden onları da seviyor ve sesini çıkartmıyor.

dostlarım, şimdi bir özet çıkartacağım.
hani atatürk’ün yaşamında neredeyse hiç özel mülkiyeti yoktur ya, ha işte bunun iki sebebi vardır:

1- mal düşkünü olmaması ve her şeyini milletine adaması.
2- foks.

buna para mı yeter? yetmez.

Saklan

“Saklan” diye haykırdı.

Etrafını kolaçan etti. Babasının devlet memuriyetinden kalma alışkanlıklarını ve onun da çocukluğunun izini taşıyordu tüm duvarlar: Şampanya rengi ve 3 yaşındaki bir çocuğun kara kalem soyut çalışmaları…

“Saklan, geliyorlar” diye tekrarladı.

Tekrar bakındı etrafına. Bir iz daha taşıyordu tüm odalar, ne olduğunu anlayamadığı, yalnızca minderlerinden kendisine ev yaptığı koltukların gitmiş olduğunu farkettiği o haciz gününden. Hiçbir eşya yoktu evde.

“Saklan çocuk! Çok geç olmadan !”

Kimden saklanacaktı. Neyden saklanacaktı? Başı dönüyordu.

“Çok geç ! ”

Continue reading…

eskilerden bir yazı.

öncelikle sohbet sırasında da dile getirdiğim üzüntümü buraya da aktarmak istiyorum. ali sirmen şöyle bir şey dedi: “ergenekon davası için toplanan delillerde darbe hakkında konuşulduğunu gösteren kayıtlar var. fakat darbeden konuşuluyor olması bir şey ifade etmez. yolsuzlukların yürüyüp gittiği bir ortamda darbeden konuşulması hiç de anormal değildir. diyelim ki konuşuldu, sağlam delillerle ispatlanmadıkça bunun bir yaptırımı olamaz.” sohbetin yapıldığı ortamdakilerin de düşündüğü gibi masumane bir cümle değildi bu. ben “hocam ben bunda bir darbe taraftarlığımı seziyorum” derken arkasını dönüp ters ters bakan, “darbeyi savunduğunu da nereden çıkardın” diye hömküren kişilerin düşündüğü gibi öylesine bir laf da değildir. bir şeyi normal görmek (anormal olmadığını düşünmek) ona hak vermek demektir. evet senin de öyle düşündüğün manasına gelmez ama kesinlikle “hak verdiğin” manasına gelir.


Continue reading…

EAR içerisinde local dosyaları okumak

Normal bir web projesinde iş kolay. Web Content ya da WEB-INF altına istediğimiz dosyayı koyup ona erişebiliyoruz.

EAR projesinde ise;

File f = new File("talha.xml")

dediğimiz zaman application server’ın root’una düşüyoruz. Sittinsene ulaşamayız o dosyaya artık. Bu yüzden önce classloadera erişmemiz ve bunun üzerinde kaynaklara erişmemiz gerekiyor. Bunun için EAR projesinin altındaki web projesindeki(WAR) bir servletin içinde önce class loader’a erişiyoruz ve sonra buradan istediğimiz kaynağı çekiyoruz.

URL url = this.getClass().getClassLoader().getResource("WEB-INF/LimangoExample.xml");

getClassLoader() dediğimiz anda nereye düştüğümüzü görmek için:

this.getClass().getClassLoader().getResource(".")

‘i kullanabiliriz. Bu URL, EAR içindeki WAR projesinin kök dizinini veriyor. getResource içerisinde de istediğimiz dizine gidiyoruz.

Artık bu saatten sonra normal URL okur gibi okuyabiliriz dosyayı:

StringBuffer buffer = new StringBuffer();
BufferedReader in = new BufferedReader(
new InputStreamReader(
url.openStream()));
String inputLine;

while ((inputLine = in.readLine()) != null) {
buffer.append(inputLine);
}
in.close();

Dosyamız XML ise ve işleri biraz kolaylaştırmak istiyorsak JAXB’nin unmarshaller’ını kullanabiliriz okumak için.

Türkiye’de Sarışın Olmak – Lan Ben Neyse

her sarışının kendisini brad pitt veyahut kıvanç tatlıtığ sanması faciasını bir kenara da bıraksak türkiye’de sarışın olmak ve bunun verdiği farklılığı taşıyabilmek tam bir peygamberlik sabrı ister. efendim eğer sarışınsanız sizi beğenecek hatun sayısı türkiye’deki ortalama bir insanınkinin %21′idir. hani şöyle bir hesap yapıyoruz ya, “istanbul’da 100.000 akran hatun olsa, 80.000′inin sevgilisi olsa, kalan 20.000′inin 100′de biri beni sevse kalır 200…” işte bunun %21′ini aldığımızda kalan sayı baya bildiğin 42′dir. yani istanbul’da bizi sevebilecek 42 hatun var. bunların yarısı sizin kıvanç tatlıtuğ’a “ay o kadar da benzemiyormuş”unuzu anlasa kalır 21. istanbul’un yüzölçümüne oranlarsan bunu kendini karaköy’de veya ataşehir’de bulursun.
 

Der Prozess – Franz Kafka

dilimize “dava” adıyla çevrilen franz kafka romanı.

en güzel yanı, ezici bir çoğunluğun bu kitabı “bürokrasinin eleştirisi” olarak algılamasına rağmen çok farklı alegoriler ile ilişkilendirenlerin de olması. ben de kendimce ( kafka’nın yaşamını da göz önünde tutarak ) yaptığım çıkarımları özetledim naçizane.

dava, insanın bir “kul” olarak yargılanışını anlatıyor.


Continue reading…

Bir Mühendisin Namütenahi Zevk Dolu Yaşamı

kendi üzerimden bir genellemeye gidicem şimdi. tümevarasım var.

sosyal hayatta başarılı olmak istiyorsak kendimizi sevdirmeli ve toplumda bizi kabul etmiş insanların varlığını kanıtlayarak bunlara yenilerini eklemeliyiz. değil mi zuzucuklarım?

kendini sevdirdiğini göstermenin en iyi yolu bir sevgiliye sahip olmak.


Continue reading…

allah gecinden versin yarın bir gün kaybedersek kendisini, düşünen bir insanı kaybetmenin vereceği acıyla ardından gözyaşı dökeceğiz. kendisini kaybettikten sonra arkasından eleştirmenin karaktersizlik olduğunu düşündüğümden ve badem gözlü olacağını bildiğimden dolayı hakkında şimdiden bir kaç kelam etmek istiyorum.

“kuran, incil ve tevrat’ın sümer’deki kökeni” adında bir kitap yazmış. bu kitabın 95. sayfasında “…görüldüğü gibi din kitaplarına tanrı sözü olarak giren bu konu ile sümer efsanesi arasında küçümsenemeyecek benzerlikler var” diyerek kutsal kitapların tanrı kelamı olmadığını, sümer mitolojisinden apartılmış hikayeler olduğunu açıkça söylüyor. tamam.


Continue reading…