<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    gembin

    OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

    HBase, Hadoop, ZooKeeper, Cassandra

    Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

    There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

    About Me

     

    [原創(chuàng)] Adding OSGi support to graniteds v1.1.0

    There are sevral steps to OSGify the graniteds v1.1.0

    Step1:
     create a adaptor serlvet which is used to register it in the OSGI env.
     

     1
     package org.granite.adaptor;
     2 
     3 import java.io.DataInputStream;
     4 import java.io.DataOutputStream;
     5 import java.io.IOException;
     6 
     7 import javax.servlet.ServletConfig;
     8 import javax.servlet.ServletException;
     9 import javax.servlet.http.HttpServlet;
    10 import javax.servlet.http.HttpServletRequest;
    11 import javax.servlet.http.HttpServletResponse;
    12 
    13 import org.granite.config.GraniteConfig;
    14 import org.granite.config.flex.ServicesConfig;
    15 import org.granite.context.AMFContextImpl;
    16 import org.granite.context.GraniteContext;
    17 import org.granite.messaging.amf.AMF0Message;
    18 import org.granite.messaging.amf.io.AMF0Deserializer;
    19 import org.granite.messaging.amf.io.AMF0Serializer;
    20 import org.granite.messaging.amf.process.AMF0MessageProcessor;
    21 import org.granite.messaging.webapp.HttpGraniteContext;
    22 
    23 /**
    24  * 
    25  * @author gembin
    26  *
    27  */
    28 public class AMFServiceAdaptor extends HttpServlet {
    29     // for Granite Data Service(GDS)
    30     private GraniteConfig graniteConfig = null;
    31     private ServicesConfig servicesConfig = null;
    32 
    33     public void init(ServletConfig config) {
    34         try {
    35             super.init(config);
    36             graniteConfig = GraniteConfig.loadConfig(getServletContext());
    37             servicesConfig = ServicesConfig.loadConfig(getServletContext());
    38             
    39         } catch (ServletException e) {
    40             e.printStackTrace();
    41         }
    42     }
    43     
    44     public ServicesConfig getServicesConfig(){
    45          return servicesConfig;
    46     }
    47     
    48     protected void doPost(HttpServletRequest request,
    49             HttpServletResponse response) throws ServletException, IOException {
    50         System.out.println("Start Processing AMF Request"+getServicesConfig());
    51         try {
    52             GraniteContext context = HttpGraniteContext.createThreadIntance(
    53                     graniteConfig, servicesConfig, getServletContext(),request,response);
    54          
    55             if (context == null)
    56                 throw new ServletException("GraniteContext not Initialized!!");
    57              
    58             AMFContextImpl amf = (AMFContextImpl) context.getAMFContext();
    59             //Phase1 Deserializing AMF0 request
    60             System.out.println(">>>>> Deserializing AMF0 request from"+request.getRequestURI());
    61             AMF0Deserializer deserializer = new AMF0Deserializer(
    62                     new DataInputStream(request.getInputStream()));
    63             AMF0Message amf0Request = deserializer.getAMFMessage();
    64             
    65             //Phase2 Processing AMF0 request 
    66             System.out.println(">>>>> Processing AMF0 request: " + amf0Request);
    67             AMF0Message amf0Response = AMF0MessageProcessor.process(amf0Request);
    68             System.out.println("<<<<< Returning AMF0 response: " + amf0Response);
    69 
    70             //Phase3 Send back response to the client
    71             response.setContentType(AMF0Message.CONTENT_TYPE);
    72             AMF0Serializer serializer = new AMF0Serializer(new DataOutputStream(response.getOutputStream()));
    73             serializer.serializeMessage(amf0Response);
    74             
    75             System.out.println("End of Processing AMF Request");
    76         } catch (Exception e) {
    77             e.printStackTrace();
    78             throw new ServletException(e);
    79         }
    80     }
    81 
    82 }
    83



    Step2:
       register the servlet in OSGi Container
    HttpContext commonContext = httpService.createDefaultHttpContext();
    Dictionary initparams 
    = new Hashtable();
    initparams.put(
    "servlet-name""AMFMessageServlet");
    httpService.registerServlet(
    "/WebContent/graniteamf/amf",new AMFServiceAdaptor(), initparams, commonContext);

    Step3:
        Ensure the servicesConfigPath(/WEB-INF/flex/services-config.xml) and graniteConfigPath(/WEB-INF/granite/granite-config.xml),otherwise, you need
    modify the source code of ServicesConfig.java and GraniteConfig.java to put the good config files in your project!


    finally:
       you've made it. it's time to create a testService to test it.
    Sample:

      public class UserAuthenticateService{
         public boolean auth(String username,String pwd){
            if (pwd.equals("1234") && username.equals("gembin")) {
                    return true;
             } 
           return false;
         }
      }
      put this service in the service-config.xml
       <services>
            <service
                id="granite-service"
                class="flex.messaging.services.RemotingService"
                messageTypes="flex.messaging.messages.RemotingMessage">
                <destination id="authenticateService">
                    <channels>
                        <channel ref="my-graniteamf"/>
                    </channels>
                    <properties>
                        <scope>session</scope>
                        <source>net.blogjava.gembin.domain.services.security.UserAuthenticateService</source>
                    </properties>
                </destination>
            </service>
        </services>

    For the actionscript part, i just omit it. if you don't know how to use it to communicate to the data service or you have some questions, pls reply.

    Next entry Dynamic DataService registration in OSGi Container for Graniteds v1.1.0

    Enjoy it!!!

    posted on 2008-12-03 23:18 gembin 閱讀(1663) 評(píng)論(2)  編輯  收藏 所屬分類: OSGiFlex

    評(píng)論

    # re: [原創(chuàng)] Adding OSGi support to graniteds v1.1.0 2008-12-05 00:52 Franck Wolff

    Hi,

    Would you like to contribute your code to GraniteDS? I guess other people would be happy to get builtin OSGi support in GDS.

    Regards,
    Franck.

    PS: you'll find my email on GDS site.  回復(fù)  更多評(píng)論   

    # re: [原創(chuàng)] Adding OSGi support to graniteds v1.1.0 2008-12-05 21:30 gembin

    i'm very happy to contribute!
      回復(fù)  更多評(píng)論   

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(6)

    隨筆分類(440)

    隨筆檔案(378)

    文章檔案(6)

    新聞檔案(1)

    相冊(cè)

    收藏夾(9)

    Adobe

    Android

    AS3

    Blog-Links

    Build

    Design Pattern

    Eclipse

    Favorite Links

    Flickr

    Game Dev

    HBase

    Identity Management

    IT resources

    JEE

    Language

    OpenID

    OSGi

    SOA

    Version Control

    最新隨筆

    搜索

    積分與排名

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    free counters
    主站蜘蛛池模板: 亚洲国产婷婷香蕉久久久久久| 国产一级淫片a免费播放口之 | 亚洲Av无码乱码在线znlu| 亚洲精品视频专区| 国产一级淫片a免费播放口之| 久久久久亚洲av毛片大| 亚洲视频一区网站| 色婷婷精品免费视频| 久久久久国产精品免费看| 日本免费高清一本视频| 亚洲一级二级三级不卡| 麻豆一区二区三区蜜桃免费| 18pao国产成视频永久免费| 免费一级毛片在线播放| 亚洲婷婷在线视频| 黄色网页在线免费观看| 四虎成人精品一区二区免费网站| 亚洲αv久久久噜噜噜噜噜| 亚洲1区2区3区精华液| 97精品免费视频| 在线A亚洲老鸭窝天堂| 亚洲AV无码专区在线观看成人| 99在线观看精品免费99| 亚洲中文字幕伊人久久无码| 亚洲一区二区无码偷拍| 无码av免费网站| 亚洲综合区小说区激情区| 亚洲精品国产第一综合99久久| 免费A级毛片无码视频| 国产成人综合亚洲AV第一页| 亚洲av无码成人影院一区| 久草视频在线免费| 亚洲VA中文字幕无码一二三区 | 亚洲一区二区久久| 免费国产污网站在线观看| 亚洲黄片手机免费观看| 亚洲精品日韩一区二区小说| 曰曰鲁夜夜免费播放视频| 亚洲一区二区三区首页| 免费很黄无遮挡的视频毛片| 9久久免费国产精品特黄|