⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 p2p 是现在java社区最火的一个话题, 看看jxta能给P2p带来什么吧
💻 TXT
字号:
This Source.zip has three application code folders containing .java and .class files and two .jar files as follows:

1. desktop-side_JXTA4JMS
2. mobile-side_JXTA4JMS
3. JMS Test Client
4. Listener.jar
5. JMSTestClient.jar

We now explain execution steps, we followed, to run this JXTA4JMS application. 
Before we try we require Application softwares and need to configure JXTA relay and J2EE server.

------------------------------------------------------------
Software Required and Configuring JXTA Relay and J2EE Server
============================================================

Following is a list of software you would require.
---------------------------------------------------
  1. JXTAShell application (JXTA 2.2.1 or latest)
     Downlaod from "http://download.jxta.org/nightlybuilds/jxtashell.zip".

  2. J2ME Wirless Toolkit 2.1 
     Download from "http://java.sun.com/products/j2mewtoolkit/download-2_1.html".

  3. Jxme library files
     - Download jxme libaray files from "http://http://download.jxta.org/nightlybuilds/jxme.zip".
     - Unzip and get jxta_cldc.jar. You need to add this jxta_cldc.jar file in j2me 
       project you will build.

  4. J2EE Server Ver 1.4
     Download from "http://java.sun.com/".


1. Configuring JXTA Relay/Rendezvous
------------------------------------
Plz. refer to "Configuring JXTA4JMS" section in article to configure JXTA relay.

    Note: For trying JXTA4JMS application we configured JXTA Relay and Rendezvous
    in a single JXTA peer instance. Refer to "Configuring JXTA4JMS" section in the article 
    document to configure single JXTA instance as Rendezovous and Relay as well.


2. Configuring the J2EE Server
------------------------------
       You need to configure J2EE server in order to run JXTA4JMS application in J2EE
       server enviornment.

       To run the JXTA4JMS application inside the J2EE enviornment, we need to include the 
       path to JXTA libraies. Following steps illustrates how to add path to JXTA libraries.

       a- Copy the \lib directory of JXTA shell from X:\jxta2.2.1\ directory to J2EE's 
          \lib directory i.e. X:\Sun\AppServer\lib. Now rename the JXTA shell lib directory
          to jxta.

       b- Now locate the "appclient.bat" file in the X:\Sun\AppServer\bin directory and open it.
          Find the following line in appclient.bat file:

          set CLASSPATH=%JVM_CLASSPATH%;%APPCPATH%

          And then append the following line with the line above:

          ;%AS_INSTALL%\lib\jxta\jxta.jar;%AS_INSTALL%\lib\jxta\log4j.jar;%AS_INSTALL%\lib\
          jxta\jxtasecurity.jar;%AS_INSTALL%\lib\jxta\minimalBC.jar;%AS_INSTALL%\lib\jxta\
          org.mortbay.jetty.jar;%AS_INSTALL%\lib\jxta\jxtaptls.jar;%AS_INSTALL%\lib\jxta\
          javax.servlet.jar;%AS_INSTALL%\lib\jxta\cryptix-asn1.jar;%AS_INSTALL%\lib\jxta\
          cryptix32.jar;%AS_INSTALL%\lib\jxta\bcprov-jdk14.jar


       c- Now we need to assign the permissions to JXTA4JMS application to execute in 
          J2EE server enviornemnt. For the sake of simplicity, we have granted all 
          rights to all applications.

          i). Navigate to the X:\Sun\AppServer\lib\appclient directory. And open
              the "client.policy". Append the following permission as the last line 
              in the file.

              grant{
                  permission java.security.AllPermission;
              };
 
         Now you are done with J2EE server configuration, lets create Connection factory
         and JMS destination objects in admin console.

-----------------------------------------------------
3. Creating ConnectionFactory and Destination resouce 
=====================================================

You need to create JMS Queue Connection and JMS Queues for JMS clients in J2EE Server.

Do the following steps on the machine which is hosting JMS provider.
--------------------------------------------------------------------
       Run the J2EE Admin console from Start menu.

       i)  Select and expand "Java Message Service" node.
       ii) Select "Connection Factory" node and create a new factory named
           "jms/QueueConnectionFactory" and select the Type as 
           "javax.jms.QueueConnectionFactory".

       iii) Now select "Destination Resources" node and select to create two new 
            destination resources named "jms/Bob" and "jms/Alice".
             
            You need to create the "Destination resource" as follows:
            1. JNDI Name  e.g. enter jms/Bob
            2. Type       e.g. select javax.jms.Queue
            3. Resource   e.g. enable the "Enabled" checkbox.
             
            And click to add a property for each destination resource.
            Each property contain Name and Value fields. 

            For adding property for destination resource named "Bob".  
            - Enter "Name" as value to Name field.
            - Enter "Bob" as value to the Value field.

            Repeat the step (iii) for each new destination resource.

       iv)  Now select "Physical Destination" node and create two new physical destinations
            named "Bob" and "Alice" respectively. 

            You need to fill the two fields:
            1. Physical destination name     e.g. enter "Bob" 
               You need to enter the same name you provided in property field under step iii.
               We used "Bob" both for property filed and physical desination name.
            2. Type                          e.g. select "Queue"

            Repeat the step (iv) for each new physical destination.

       Note: The Destinations name (Bob and Alice ) you created in step iii and iv 
             are case sensitive.


Do the following steps on the machines which are hosting JMS Clients.
---------------------------------------------------------------------

       Run the J2EE Admin console from Start menu.

       i)  Select and expand "Java Message Service" node.
       ii) Select "Connection Factory" node and create a new factory named
           "jms/QueueConnectionFactory" and select the Type as 
           "javax.jms.QueueConnectionFactory".

            You need to add one property to connection factory settings. 

            Clicking "Add property" button will display a Name and Value fields pair.
            
            You need to fill above fields as following:
            a. In "Name" field enter "MessageServiceAddressList" as value and
            b. In "Value" field enter "providerMachine" (the network address of the
               machine which is hosting JMS provider.
               as value.
               
            If the J2EE Server machine (which is hosting JMS provider) is listening 
            on port number other then 8080 (e.g. 8090). Then you would need to 
            provide port number alongwith machine address as value to the "Value" 
            field (e.g. "providerMachine:8090").


--------------------------
Steps to Execute JXTA4JMS
==========================
Now you are ready to test the JXTA4JMS application. Inorder to execute JXTA4JMS smoothly, 
you need to add path to the two provided .jar files in your ClassPath. 
This will let .jar files to run as soon as you enter the appclient commands.

Follow the following steps to try JXTA4JMS.

1. Run the J2EE Server:
   You need to run the J2EE server by selecting "Start Default Server" option in 
   Start>Programs>Sun Microsystems menu.

2. Run the JXTA relay:
   You need to run jxta relay we configured earlier in "Configuring JXTA Relay/Rendezvous"
   section. Both the desktop-side JXTA4JMS and mobile-side JXTA4JMS will connect to this JXTA
   instance for messaging.

   To run double click the jxta.exe file located at "X:\jxta2.2.1\shell\jxta.exe" .

3. Run the JMS test client provided as JMSTestClient.jar file. The JMSTestClient.jar takes 
   user name for the Queue it will listen. 
   We run the JMS client for Bob, whose Queue we created in section 3.1 under point iii & iv.

      appclient -client JMSTestClient.jar Bob 

4. Running Listener.jar (desktop-side JXTA4JMS):
   Now you are ready to run Listener.jar. The run command for Listener.jar takes user name 
   and JMS connection factory name. We have passed "Alice" as user name and the 
   connection factory i.e. "jms/QueueConnectionFactory" we created in point (ii) of section 3.1.

   - Open a new commond prompt window and enter the following line.
      appclient -client Router.jar Alice jms/QueueConnectionFactory

   The Listener.jar will prompt with JXTA configuration window. You need to configure
   your JXTA4JMS instance as per instructions given in "Configuring JXTA4JMS" 
   section of the article.

   Note: If Listener.jar didn't start listening for JXTA and JMS messages. Then try to 
         restart Listener.jar and JXTA relay as well (i.e. Step 2 and 4).

5. Run the mobile-side JXTA4JMS:
    1.  Run KToolbar (i.e J2ME Wireless Toolkit) and Create a new project. 
    2.  In project name option give any name, say "MobileSide_JXTA4JMS".
    3.  In midlet class name option write "JXMEMIDlet" as midlet class name 
        for the new project.
    4.  Copy the four .java code files in the "\src" directory of the newly 
        created "MobileSide_JXTA4JMS" project.
    5.  Place the JXME jar file (jxta-cldc.jar, we got earlier in required software section)
        in the '\lib' folder of your project.
    6.  Build the program using the 'Build' button on the toolkit toolbar.
    7.  Now run your MobileSide_JXTA4JMS application using the 'run' button 
        on the toolkit toolbar.
    8.  Pressing 'Launch' button will connect mobile-side JXTA4JMS user with JXTA relay
        executed in step 2 earlier. 
        We have hard coded the JXTA relay URL as "http://localhost:9700" and "Alice" as 
        mobile-side JXTA4JMS user in class named JXMEMIDlet.
       
        This is all done, now you are ready to enjoy JXTA4JMS Messaging.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -