WebSphere Message Broker バージョン 8.0.0.5 オペレーティング・システム: AIX、HP-Itanium、Linux、Solaris、Windows、z/OS

製品の最新バージョンについては、IBM Integration Bus バージョン 9.0 をご覧ください。

Enterprise Java Bean の呼び出し

JavaCompute ノードから Enterprise Java™ Bean (EJB) を呼び出すことができます。

始める前に:
以下の例は、JavaCompute ノードから EJB を呼び出す方法を示しています。
public class CallAckNoAckEJB_JavaCompute extends MbJavaComputeNode { 

		 public void evaluate(MbMessageAssembly inAssembly) throws MbException { 
                MbOutputTerminal out = getOutputTerminal("out"); 
                MbOutputTerminal alt = getOutputTerminal("alternate"); 

                MbMessage inMessage = inAssembly.getMessage(); 

                // create new message 
                MbMessage outMessage = new MbMessage(inMessage); 
                MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly,outMessage); 

                try { 
                        // ---------------------------------------------------------- 
                        // Add user code below 
                
                        String response = null; 
                        String responseMessage = null; 
                                                
                        Properties properties = new Properties(); 
                        properties.put(Context.PROVIDER_URL, "iiop://localhost:2809"); 
                        properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.
WsnInitialContextFactory"); 
                
                        try { 
                            
                        		 Context initialContext = new InitialContext(properties); 
                                Object obj = initialContext.lookup("ejb/com/acme/ejbs/AckNoAckHome"); 
                                AckNoAckHome ejbHome = (AckNoAckHome)javax.rmi.PortableRemoteObject.
narrow(obj,AckNoAckHome.class); 
                                
                                AckNoAck ackNoAck = ejbHome.create(); 
                                responseMessage = ackNoAck.getAck(); 
                                response = "Ack"; 
                        } catch(Exception e) { 
                                responseMessage = e.getMessage(); 
                                response = "NoAck"; 
                        } 

                        MbElement cursor = outMessage.getRootElement().getFirstElementByPath("/XML/AckNoAck"); 
                        cursor.createElementAsLastChild(MbElement.TYPE_NAME,"Response",null); 
                        cursor.getLastChild().createElementAsLastChild(MbElement.TYPE_NAME,response,null); 
                        cursor.getLastChild().getLastChild().createElementAsLastChild(MbElement.TYPE_VALUE,null,
responseMessage); 
                                                
                        // End of user code 
                        // ---------------------------------------------------------- 

                        // The following should only be changed 
                        // if not propagating message to the 'out' terminal 
                        out.propagate(outAssembly); 

                } finally { 
                        // clear the outMessage 
                        outMessage.clearMessage(); 
                } 
		 } 
} 
特記事項 | 商標 | ダウンロード | ライブラリー | サポート | フィードバック

Copyright IBM Corporation 1999, 2014Copyright IBM Corporation 1999, 2014.

        
        最終更新:
        
        最終更新: 2015-02-28 17:45:52


タスク・トピックタスク・トピック | バージョン 8.0.0.5 | ac37120_