shnulaa

Never deter till tomorrow that which you can do today
posts - 15, comments - 0, trackbacks - 0, articles - 2
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

findejb

Posted on 2010-09-26 16:31 shnulaa 阅读(74) 评论(0)  编辑  收藏
  1package findEjb;
  2
  3import java.util.Iterator;
  4import java.util.Properties;
  5import java.util.Set;
  6
  7import javax.management.ObjectInstance;
  8import javax.management.ObjectName;
  9import javax.naming.Context;
 10import javax.naming.InitialContext;
 11import javax.naming.NameClassPair;
 12import javax.naming.NamingEnumeration;
 13
 14import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
 15
 16public class FindEjb {
 17
 18    /**
 19     * @param args
 20     */

 21    @SuppressWarnings("unchecked")
 22    public static void main(String[] args) throws Throwable {
 23
 24        
 25//        try {
 26//            Class c = Class.forName("java.util.ArrayList");
 27//            Method m[] = c.getDeclaredMethods();
 28//            for (int i = 0; i < m.length; i++)
 29//                System.out.println(m[i].toString());
 30//        } catch (Throwable e) {
 31//            System.err.println(e);
 32//        }
 33
 34        // TODO Auto-generated method stub
 35        Properties props = new Properties();
 36        props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
 37                "org.jnp.interfaces.NamingContextFactory");
 38        props.setProperty(Context.PROVIDER_URL, "192.168.1.83:1099");
 39        props.setProperty(Context.URL_PKG_PREFIXES,
 40                "org.jboss.naming:org.jnp.interfaces");
 41        InitialContext ctx = new InitialContext(props);
 42
 43        NamingEnumeration<NameClassPair> allNameClass = ctx.list("");
 44        
 45        while(allNameClass.hasMoreElements()) {
 46            NameClassPair nameClassPair = allNameClass.nextElement();
 47            System.out.println(nameClassPair.getName() );
 48        }

 49        
 50        RMIAdaptor obj = (RMIAdaptor)ctx.lookup("jmx/rmi/RMIAdaptor");
 51
 52        
 53        Set<ObjectInstance> sets = obj.queryMBeans(nullnull);
 54        Iterator<ObjectInstance> iterator = sets.iterator();
 55        while(iterator.hasNext()) {
 56            System.out.println(iterator.next().getObjectName());
 57        }

 58        
 59        obj.createMBean("org.jboss.deployment.MainDeployer"new ObjectName("11111"));
 60        
 61        System.out.println();
 62//        final JmsTestInterface searchInterface = (JmsTestInterface) ctx
 63//                .lookup("JmsTestEjb/remote");
 64
 65        // /System.out.println(searchInterface.getMessageSize());
 66        // searchInterface.setMaxJmsQueueSize(10L);
 67        // for (int index =0;index< 10; index ++) {
 68        // // searchInterface.sendMessage("");
 69        // }
 70        // System.out.println(searchInterface.receiveMessage("").toString());
 71        // searchInterface.createNewQueue("liuQueue2");
 72        // for (int index =0;index< 10; index ++) {
 73        // searchInterface.sendMessageWithNoRemove();
 74        // }
 75        // searchInterface.testRemoveEntity();
 76        
 77        
 78//        searchInterface.sendMessage(null, "message ");
 79        
 80//        ExecutorService service = Executors.newFixedThreadPool(100);
 81//        service.execute(new Runnable() {
 82//            @Override
 83//            public void run() {
 84//                try {
 85//                    for (int i =0;i<100;i++) {
 86//                        System.out.println("begin to send message by thread " + Thread.currentThread().getName());
 87//                        searchInterface.sendMessage(null, "message " + i);
 88//                        System.out.println("end send message by thread " + Thread.currentThread().getName());
 89//                        try {
 90//                            Thread.sleep(500);
 91//                        } catch (InterruptedException e) {
 92//                        }
 93//                    }
 94//                } catch (Throwable e) {
 95//                    e.printStackTrace();
 96//                }
 97//            }
 98//        });
 99//        service.shutdown();
100
101         
102         
103
104    }

105    
106//    class insertMessageTask implements Runnable {
107//        private JmsTestInterface searchInterface;
108//        public insertMessageTask(JmsTestInterface searchInterface) {
109//            this.searchInterface = searchInterface;
110//        }
111//
112//        @Override
113//        public void run() {
114//            // TODO Auto-generated method stub
115//            
116//            
117//            
118//        }
119//    }
120}

121

只有注册用户登录后才能发表评论。


网站导航: