<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

     

    [原創] Dynamic DataService registration in OSGi Container for Graniteds v1.1.0

    In last entry(Adding OSGi support to graniteds v1.1.0), i talk about the OSGifition of Graniteds. Now i would like to add dynamic registration of Granite DataService by using annotation (@RemoteDestination).


    Step1:
       Define two constants:
      
       public static final String TOPIC_GDS_ADD_SERVICE ="org/granite/ds/add/serviceClass";
       
    public static final String SERVICE_CLASS="serviceClass";
       Then,we modify the org.granite.config.flex.ServicesConfig.java
      
      
    import org.osgi.service.event.Event;
    import org.osgi.service.event.EventHandler;
    public
     class ServicesConfig implements ScannedItemHandler,EventHandler{
         
    //
         
    //
         public void handleEvent(Event event) {
            
    if(event.getTopic().equals(TOPIC_GDS_ADD_SERVICE)){
              Class c
    =(Class) event.getProperty(SERVICE_CLASS);
              
    if(c!=null)
                handleClass(c);
    //this method is already provided by this Class, we just call it
              else
               System.out.println(
    "Class NOT Found!!");
            }
        }
     
      }

    Step2:

       in the AMFServiceAdaptor.java I mentioned in the last entry
      
      
        BundleContext context;
        
    public AMFServiceAdaptor(BundleContext context){
            
    this.context=context;
        }
       
    public void init(ServletConfig config) {
            
    try {
                
    super.init(config);
                graniteConfig 
    = GraniteConfig.loadConfig(getServletContext());
                servicesConfig 
    = ServicesConfig.loadConfig(getServletContext());
                Dictionary
    <String, Object> properties = new Hashtable<String, Object>();
                String[] topics 
    = new String[] { TOPIC_GDS_ADD_SERVICE};
                properties.put(EventConstants.EVENT_TOPIC, topics);
                context.registerService(EventHandler.
    class.getName(), servicesConfig, properties);
            } 
    catch (ServletException e) {
                e.printStackTrace();
            }
        }
      
      
    Step3:
       In the Activator we add:

    Activator.java  
     
      Dictionary<String, Object> properties = new Hashtable<String, Object>();
       properties.put(SERVICE_CLASS, TestService.
    class);
       ServiceReference eventAdminRef 
    = context.getServiceReference(EventAdmin.class.getName());
       
    if (eventAdminRef != null){
           EventAdmin admin
    =context.getService(eventAdminRef);
            
    if(admin!=null){
                admin.sendEvent(
    new Event(TOPIC_GDS_ADD_SERVICE,properties));    
       }
      
    TestService.java

     1 package net.blogjava.gembin.domain.services.test;
     2 
     3 import org.granite.messaging.service.annotations.RemoteDestination;
     4 
     5 
     6 @RemoteDestination(id="testService", service="granite-service",channel="my-graniteamf", scope="session")
     7 public class TestService {
     8    
     9     public void test(){
    10         System.out.println("test it!!!");
    11     }
    12 
    13 }


    Step4:
      Flex Part
     
                    [Bindable]
                    
    private var srv:RemoteObject = null;
                    
    import mx.messaging.ChannelSet;
                    
    import mx.messaging.config.ServerConfig;
                    
    import mx.rpc.remoting.mxml.Operation;
                    
    private function testSend():void{
                        srv 
    = new RemoteObject();
                        srv.endpoint 
    = ServerConfig.getChannel("my-graniteamf").endpoint;
                        srv.destination 
    = "testService"
                        srv.channelSet 
    = new  ChannelSet(); 
                        srv.channelSet.addChannel(ServerConfig.getChannel(
    "my-graniteamf"));
                         var operation:Operation 
    = new Operation();
                         operation.name 
    = "test";
                         operation.addEventListener(FaultEvent.FAULT,handleFault);
                         operation.addEventListener(ResultEvent.RESULT,handleRs);
                         srv.operations 
    = {test: operation};
                         srv.test();
                    }
                    private function handleFault(e:FaultEvent):void{
                        Alert.show(e.toString());
                    }
                    private function handleRs(e:ResultEvent):void{
                        Alert.show(e.toString());
                    }
                    <mx:Button id="Test" label="TestIt" click="
    testSend();"/>

    Screen shot


     
    Conclusion
      
       from this example, you can see it's very easy to add osgi dynamic feathure support in Graniteds.

    Enjoy it!!!


    Next entry Example for GraniteDS v1.2.0 OSGi bundle 

    posted on 2008-12-04 14:51 gembin 閱讀(1693) 評論(0)  編輯  收藏 所屬分類: OSGiFlexActionScript3

    導航

    統計

    常用鏈接

    留言簿(6)

    隨筆分類(440)

    隨筆檔案(378)

    文章檔案(6)

    新聞檔案(1)

    相冊

    收藏夾(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

    最新隨筆

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    free counters
    主站蜘蛛池模板: 亚洲αⅴ无码乱码在线观看性色| 免费99精品国产自在现线| 亚洲av日韩aⅴ无码色老头| 亚洲精品国产成人99久久| 亚洲无码日韩精品第一页| 色www永久免费视频| 18以下岁毛片在免费播放| 成人A毛片免费观看网站| 国产亚洲精品91| 亚洲七久久之综合七久久| 亚洲神级电影国语版| 久久久久久久综合日本亚洲 | 久久亚洲国产精品五月天| 免费一级毛片免费播放| 成人五级毛片免费播放| 91成人免费观看网站| 国产成人久久AV免费| 免费无码一区二区三区蜜桃| 亚洲免费视频一区二区三区| 美女免费视频一区二区| 亚洲精品国产精品| 亚洲大成色www永久网址| 亚洲AV无码乱码在线观看代蜜桃| 久久亚洲AV无码精品色午夜麻豆| 久久久久亚洲AV片无码| 久久亚洲AV无码精品色午夜麻| 亚洲精品卡2卡3卡4卡5卡区| 亚洲情XO亚洲色XO无码| 亚洲精品夜夜夜妓女网| 久久精品国产亚洲AV果冻传媒| 亚洲va中文字幕无码久久| 亚洲AV无码一区东京热久久| 久久精品视频亚洲| 精品亚洲国产成AV人片传媒| 亚洲尹人香蕉网在线视颅| 亚洲精品国产福利片| 亚洲制服在线观看| 亚洲午夜理论片在线观看| 亚洲av中文无码字幕色不卡| 国产精品亚洲一区二区三区| 搜日本一区二区三区免费高清视频|