ข้ามไปที่เนื้อหาหลัก

บทความ

กำลังแสดงโพสต์ที่มีป้ายกำกับ glassfish

JMS tutorial

1. ให้ JMS ใช้คนละ thread กับ glassfish Configuration -> Java Message Service, set JMS service to "LOCAL" rather than "EMBEDDED." restart glassfish server. ลอง ping เด๊ะ dsin@dsin-laptop:~/glassfish$ ~/glassfish/bin/asadmin jms-ping JMS Ping Status = RUNNING Command jms-ping executed successfully. 2. create new CF - JNDI name - type javax.jms.ConnectionFactory คือ อะไรก็ได้ create new DS - JNDI name - Physical destination name - type javax.jms.Queue : point-to-point Test first create new java project - project name Add external JARs glassfish/lib/javaee.jar glassfish/lib/appserv-rt.jar glassfish/lib/appserv-admin.jar glassfish/lib/install/applications/jmsra/imqjmsra.jar สร้าง jUnit test - JUnit 4 test - package - name public class ReqReplyTest extends TestCase { private static final String CONNECTION_FACTORY_NAME = "jms/ConnectionFactory"; private static final String REQUEST_QUEUE_NAME = "jms/RequestQueue"; // ที่ config ใน jndi private stat...

EJB development ด้วย Glassfish Server -- Part 3 EJB3Unit ( Unit Testing EJB3 Modules )

ตัวอย่าง EJB3Unit ไปดู doc และ ตัวอย่างได้จาก Ejb3Unit homepage หรือ download Ejb3UnitSampleProject-2.0.0-RC-1.zip how to import existing project in eclipse วิธี1 จะก็อป jar ไฟล์เข้าโปรเจคเองก็ได้ วิธี2 จะ Properties > Java Build Path > libraries > Add External JARs ก็ได้ โดยโหลดจาก ejb3unit-jars.zip extract ไฟล์ก่อนแล้วค่อย add นะ ย้ำ จากนั้นลองรัน Run As -> [Junit icon] Execute all ejb3 unit tests. มันจะรัน 31 tests ผ่านโดยไม่มี errors สร้าง new project เพื่อ test EJBs ของคุณ ejbunit สร้าง on top of Junit ( ใช้ javaSE ) ไม่ต้อง export ก่อนรันเทส ejbunit จะ simulate environment ทำ Part 2 ให้ work ก่อน เพราะว่านี่จะทำต่อจาก Part 2 ( Eclipse/EJB/GlassFish/JPA ) ตอนนี้ก็มี Project titan-ejb ที่มี EJB module targeted for GlassFish - มี entities Cabin, Customer, และ Phone - มี stateless session bean ชื่อว่า TravelAgentBean และมี remote interface - สร้าง new Java project ชื่อ titan-tests add the external JARs for Ejb3Unit ให้เรียบร้อย - บอก Eclipse ให้ reference unit test p...

EJB development ด้วย Glassfish Server -- Part 2 ( Create a project )

สร้าง project สำหรับ EJB module สร้าง EJB project ชื่อว่า titan-ejb เลือก Target Runtime : Glassfish คลิกขวาที่ Project ติ๊ก JPA facet, และ configure JPA facet ให้ใช้ connection profile ที่สร้างไว้แล้ว >>>>>>>>>>>>>>>>>>> วิธีสร้าง JPA Entity: - คลิกขวาที่ Project Explorer - New->Class ชื่อ com.titan.domain.Cabin implement java.io.Serializable [ Serializable คือ สามารถ convert class to String แล้วส่งไปที่ network ได้ ] วิธีสร้าง implement class บน eclipse มันก็จะสร้างฟังก์ชั่นโบ๋ๆ มาให้ package com.titan.domain; import java.io.Serializable; public class Cabin implements Serializable { } - Add the fields static final long serialVersionUID = 1L; private int id; private String name; private int deckLevel; private int shipId; private int bedCount; - สร้าง getters and setters สำหรับ id, name, deckLevel, shipId, and bedCount. [ ใน eclipse ง่ายมาก ไปที่ Source > Generate setters and getters ( หรือ คลิกขวาตรงที่เขียนโค้ด So...

EJB development ด้วย Glassfish Server -- Part 1 ( how to setup )

IDE : Eclipse Application Server : Glassfish ORM : Oracle Toplink implementaion of JPA ( ORM ตัวอื่น เช่น Entity EJB POJO, Hibernate JPA interface [ RedHat maintains it ] ) RDMBS : Derby [ build in มากับ Glassfish ] ( RDBMS ตัวอื่นเช่น HSQLDB [ Native Java RDBMS, good for testing, any RDBMS is supported ] ) other tools log4j : loggin features for Java hibernate-ejb3 : JPA face on Hibernate 1. ลง JDK 1.6 วิธีเลือก version ของ Java บน ubuntu 2. ลง eclipse เขาบอกว่า ถ้าเรามี Aptana กับ C/C++ dev plugin install อยู่แล้วจะมีปัญหากับ Glassfish ฉะนั้น ลงใหม่ซะ วิธีลง eclipse 3. ลง glassfish - โหลดมา - unpack jar $ java -Xmx256M -jar Desktop/glassfish-installer-v2.1-b60e-linux.jar NOTE : เหมือนว่า ถ้า jar file ไม่เอาไว้ที่ Desktop มันจะเน่าเวลา start domain อ่ะ ตามนี้ เอาไว้ที่อื่น dsin@dsin-laptop:/media/disk/AIT/Software Architecture/glassfish$ ./bin/asadmin start-domain Starting Domain domain1, please wait. Default Log location is /media/disk/AIT/Software Architecture/glassfish/domains/d...