锘??xml version="1.0" encoding="utf-8" standalone="yes"?>99精品在线直播,久草在线免费福利资源,亚洲综合电影http://www.aygfsteel.com/wukerit/archive/2006/09/29/72815.htmlKanITKanITFri, 29 Sep 2006 06:47:00 GMThttp://www.aygfsteel.com/wukerit/archive/2006/09/29/72815.htmlhttp://www.aygfsteel.com/wukerit/comments/72815.htmlhttp://www.aygfsteel.com/wukerit/archive/2006/09/29/72815.html#Feedback0http://www.aygfsteel.com/wukerit/comments/commentRss/72815.htmlhttp://www.aygfsteel.com/wukerit/services/trackbacks/72815.htmlHibernate涓嬌鐢ㄧ殑涓ょ鏌ヨ鏂瑰紡:HQL鏌ヨ鍜屽師鐢烻QL鏌ヨ

package app;

import app.UserInfo;
import java.util.*;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class Test
{

聽/**
聽 * @param args
聽 */
聽public static void main(String[] args)
聽{
聽聽// TODO Auto-generated method stub
聽聽try{
聽聽SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
聽聽Session session = sessionFactory.openSession();
聽聽//HQL鏌ヨ
聽聽//List list = session.createQuery("from UserInfo where username = 'ken'").list();
聽聽Iterator iterator = session.createSQLQuery("select * from TESTUSERINFO").list().iterator();
聽聽//System.out.println(((UserInfo)list.get(0)).getPassword());
聽聽for(;iterator.hasNext(); )
聽聽{
聽聽聽Object[] obj=(Object[])iterator.next();
聽聽聽for(int i=0;i<obj.length;i++)
聽聽聽{
聽聽聽聽System.out.println(obj[i].toString());
聽聽聽}
聽聽}
聽聽/*
聽聽UserInfo user = new UserInfo();
聽聽for (ListIterator iterator = list.listIterator(); iterator.hasNext(); ) {
聽聽聽user = (UserInfo)iterator.next();
聽聽聽聽聽 System.out.println("name: " + user.getUsername());
聽聽}*/
聽聽聽聽聽聽聽 /*user.setUserid("4");
聽聽聽聽聽聽聽 user.setUsername("wukerit");
聽聽聽聽聽聽聽 user.setPassword("password");

聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽 Transaction tx= session.beginTransaction();
聽聽聽聽聽聽聽 session.save(user);
聽聽聽聽聽聽聽 tx.commit();*/
聽聽聽聽聽聽聽 session.close();
聽聽聽聽聽聽聽 sessionFactory.close();
聽聽}
聽聽catch(PropertyNotFoundException err)
聽聽{
聽聽聽err.printStackTrace();
聽聽}
聽聽catch(Exception err)
聽聽{
聽聽聽err.printStackTrace();
聽聽}
聽聽聽聽聽聽聽 //System.out.println("鏂板璩囨枡OK!璜嬪厛鐢∣racle瑙鐪嬬祼鏋滐紒");
聽聽聽 }
}



KanIT 2006-09-29 14:47 鍙戣〃璇勮
]]>
Context瑙i噴http://www.aygfsteel.com/wukerit/archive/2006/08/14/63481.htmlKanITKanITMon, 14 Aug 2006 07:03:00 GMThttp://www.aygfsteel.com/wukerit/archive/2006/08/14/63481.htmlhttp://www.aygfsteel.com/wukerit/comments/63481.htmlhttp://www.aygfsteel.com/wukerit/archive/2006/08/14/63481.html#Feedback0http://www.aygfsteel.com/wukerit/comments/commentRss/63481.htmlhttp://www.aygfsteel.com/wukerit/services/trackbacks/63481.html閭d箞鎬庝箞鐞嗚Вcontext鍛紝鎴栬呰浠涔堟槸context鍛紵涓嬮潰灝變粠鎴戜釜浜虹殑瑙掑害鏉ヨ繘琛岃В閲?/p>

鍒氬垰鎺ヨЕcontext榪欎釜璇嶅ソ鍍忚繕鏄湪鐪嬨奐2EE鎶鏈唴騫曘嬮偅鏈功鐨勬椂鍊欙紝閭d釜鏃跺欏浜庝笂涓嬫枃鐨勭悊瑙e熀鏈笂灝辨槸0錛屽彧鐭ラ亾榪欎釜璇嶈屽凡銆?/p>

濡備粖瀵逛簬context榪欎釜璇嶏紝鍒欐湁浜嗙鎭嶇劧澶ф偀鐨勬劅瑙夈備腑鏂囩炕璇戣搗鏉ュ氨鏄滀笂涓嬫枃鈥濓紝浠庡瓧闈㈡剰鎬濇垜浠氨鍙互寰堟竻妤氱殑鍘葷悊瑙c?/p>

棣栧厛鈥滀笂涓嬧濊〃鐜扮殑鏄竴縐嶆壙涓婂惎涓嬬殑鍏崇郴錛屾槸涓縐嶄粠鍓嶄竴涓簨鐗╀紶閫掔粰鍚庝竴涓簨鐗╃殑榪欎箞涓笢瑗褲傜敤闈㈠悜瀵硅薄璇█鏉ヨ錛屽氨鏄粠涓涓猳bject浼犻掑埌鍙﹀涓涓猳bject鐨勬秷鎭屽凡錛屽彧涓嶈繃榪欎釜message閲岄潰鍖呭惈浜嗕竴浜涘叕鐢ㄧ殑淇℃伅銆?/p>

鍏舵錛屸滄枃鈥濇剰鍛崇潃榪欐槸涓縐嶄俊鎭紝涓緇勬枃瀛楋紝涓浜涘唴瀹廣備篃灝辨槸璇翠粬鍚湁浜嗗叾浠栦簨鐗╂墍闇瑕佺殑淇℃伅銆?/p>

KanIT 2006-08-14 15:03 鍙戣〃璇勮
]]>
Eclipse+MyEclipse+weblogic8寮鍙慐JB鍒濇帰http://www.aygfsteel.com/wukerit/archive/2006/08/09/62529.htmlKanITKanITWed, 09 Aug 2006 03:18:00 GMThttp://www.aygfsteel.com/wukerit/archive/2006/08/09/62529.htmlhttp://www.aygfsteel.com/wukerit/comments/62529.htmlhttp://www.aygfsteel.com/wukerit/archive/2006/08/09/62529.html#Feedback0http://www.aygfsteel.com/wukerit/comments/commentRss/62529.htmlhttp://www.aygfsteel.com/wukerit/services/trackbacks/62529.html涓銆佹棤鐘舵佷細璇滲EAN
鎼炰簡鍑犲勾JAVA浜?鏈榪戠敱浜庡畬鍏ㄤ笉鎳侲JB鎶鏈?琚彇絎戜簡!鎴戞掕屽涔?
浠ヤ笅涓鴻嚜宸變繚鐣欑殑浠g爜,澶ч儴鍒嗘妱琚綉涓婄殑,鍙負鑷繁淇濈暀,鏈涚湅瀹竴絎戣岃繃!
鍏抽敭瀛椾竴:DOMAIN鍩?br />涓篧EBLOGIC綆$悊搴旂敤鐨勬満鍒?鐢╓EBLOGIC鑷甫鐨凜onfiguration Wizard宸ュ叿鐢熸垚,鏍規嵁鍔熻兘涓嶅悓鑳藉垱寤轟笉鍚岀殑宸ヤ綔鍩?
鍏抽敭瀛椾簩:閮ㄧ講
Eclipse+MyEclipse鎻愪緵浜嗘瘮杈冨己澶х殑閮ㄧ講鍔熻兘,榪欓噷蹇界暐鍏?
鍏蜂綋浠g爜濡備笅:
package com.ejb;

import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

/**
聽* XDoclet-based session bean.聽 The class must be declared
聽* public according to the EJB specification.
聽*
聽* To generate the EJB related files to this EJB:
聽*聽聽- Add Standard EJB module to XDoclet project properties
聽*聽聽- Customize XDoclet configuration for your appserver
聽*聽聽- Run XDoclet
聽*
聽* Below are the xdoclet-related tags needed for this EJB.
聽*
聽* @ejb.bean name="HelloWorld"
聽*聽聽聽聽聽聽聽聽聽聽 display-name="Name for HelloWorld"
聽*聽聽聽聽聽聽聽聽聽聽 description="Description for HelloWorld"
聽*聽聽聽聽聽聽聽聽聽聽 jndi-name="ejb/HelloWorld"
聽*聽聽聽聽聽聽聽聽聽聽 type="Stateless"
聽*聽聽聽聽聽聽聽聽聽聽 view-type="remote"
聽*/
public class HelloWorld implements SessionBean {

聽/** The session context */
聽private SessionContext context;
聽private String message = "helloworld!";
聽public HelloWorld() {
聽聽// TODO Auto-generated constructor stub
聽}

聽public void ejbActivate() throws EJBException, RemoteException {
聽聽// TODO Auto-generated method stub

聽}

聽public void ejbPassivate() throws EJBException, RemoteException {
聽聽// TODO Auto-generated method stub

聽}

聽public void ejbRemove() throws EJBException, RemoteException {
聽聽// TODO Auto-generated method stub

聽}

聽/**
聽 * Set the associated session context. The container calls this method
聽 * after the instance creation.
聽 *
聽 * The enterprise bean instance should store the reference to the context
聽 * object in an instance variable.
聽 *
聽 * This method is called with no transaction context.
聽 *
聽 * @throws EJBException Thrown if method fails due to system-level error.
聽 */
聽public void setSessionContext(SessionContext newContext)
聽聽throws EJBException {
聽聽context = newContext;
聽}

/**
* 鑷繁鏂板垱寤虹殑涓氬姟鏂規硶
**/
聽public String getMessage()throws EJBException
聽{
聽聽return this.message;
聽聽//return new String("helloworld!");
聽}
///////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?//////////////////////////////////////////////////////////////////////////
/*
聽* Generated by XDoclet - Do not edit!
聽*/
package com.ejb;

/**
聽* Session layer for HelloWorld.
聽* @xdoclet-generated at ${TODAY}
聽* @copyright The XDoclet Team
聽* @author XDoclet
聽* @version ${version}
聽*/
public class HelloWorldSession
聽聽 extends com.ejb.HelloWorld
聽聽 implements javax.ejb.SessionBean
{
聽聽 public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException
聽聽 {

聽聽聽聽聽 super.ejbActivate();
聽聽 }

聽聽 public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException
聽聽 {
聽聽聽聽聽 super.ejbPassivate();
聽聽 }

聽聽 public void setSessionContext(javax.ejb.SessionContext ctx) throws javax.ejb.EJBException
聽聽 {
聽聽聽聽聽 super.setSessionContext(ctx);
聽聽 }

聽聽 public void unsetSessionContext()
聽聽 {
聽聽 }

聽聽 public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException
聽聽 {
聽聽聽聽聽 super.ejbRemove();
聽聽 }

聽聽 public void ejbCreate() throws javax.ejb.CreateException
聽聽 {
聽聽 }
}
//////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?///////////////////////////////////////////////////////////////////////

/*
聽* Generated by XDoclet - Do not edit!
聽*/
package com.interfaces;

import javax.ejb.EJBException;
import java.rmi.*;

/**
聽* Remote interface for HelloWorld.
聽* @xdoclet-generated at ${TODAY}
聽* @copyright The XDoclet Team
聽* @author XDoclet
聽* @version ${version}
聽*/
public interface HelloWorld
聽聽 extends javax.ejb.EJBObject
{
聽聽 /**
聽聽聽 * An example business method
聽聽聽 * @throws EJBException Thrown if method fails due to system-level error.聽聽聽 */
聽聽 /*public void replaceWithRealBusinessMethod(聽 )
聽聽聽聽聽 throws java.rmi.RemoteException;*/
聽聽 public String getMessage()throws EJBException,RemoteException;
}
//////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?////////////////////////////////////////////////////////////////////////////
/*
聽* Generated by XDoclet - Do not edit!
聽*/
package com.interfaces;

/**
聽* Home interface for HelloWorld.
聽* @xdoclet-generated at ${TODAY}
聽* @copyright The XDoclet Team
聽* @author XDoclet
聽* @version ${version}
聽*/
public interface HelloWorldHome
聽聽 extends javax.ejb.EJBHome
{
聽聽 public static final String COMP_NAME="java:comp/env/ejb/HelloWorld";
聽聽 public static final String JNDI_NAME="ejb/HelloWorld";

聽聽 public com.interfaces.HelloWorld create()
聽聽聽聽聽 throws javax.ejb.CreateException,java.rmi.RemoteException;

}
/////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?////////////////////////////////////////////////////////////////////////////
/*
聽* Generated file - Do not edit!
聽*/
package com.interfaces;

/**
聽* Utility class for HelloWorld.
聽* @xdoclet-generated at ${TODAY}
聽* @copyright The XDoclet Team
聽* @author XDoclet
聽* @version ${version}
聽*/
public class HelloWorldUtil
{
聽聽 /** Cached remote home (EJBHome). Uses lazy loading to obtain its value (loaded by getHome() methods). */
聽聽 private static com.interfaces.HelloWorldHome cachedRemoteHome = null;

聽聽 private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException {
聽聽聽聽聽 // Obtain initial context
聽聽聽聽聽 javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
聽聽聽聽聽 try {
聽聽聽聽聽聽聽聽 Object objRef = initialContext.lookup(jndiName);
聽聽聽聽聽聽聽聽 // only narrow if necessary
聽聽聽聽聽聽聽聽 if (java.rmi.Remote.class.isAssignableFrom(narrowTo))
聽聽聽聽聽聽聽聽聽聽聽 return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
聽聽聽聽聽聽聽聽 else
聽聽聽聽聽聽聽聽聽聽聽 return objRef;
聽聽聽聽聽 } finally {
聽聽聽聽聽聽聽聽 initialContext.close();
聽聽聽聽聽 }
聽聽 }

聽聽 // Home interface lookup methods

聽聽 /**
聽聽聽 * Obtain remote home interface from default initial context
聽聽聽 * @return Home interface for HelloWorld. Lookup using COMP_NAME
聽聽聽 */
聽聽 public static com.interfaces.HelloWorldHome getHome() throws javax.naming.NamingException
聽聽 {
聽聽聽聽聽 if (cachedRemoteHome == null) {
聽聽聽聽聽聽聽聽聽聽聽 cachedRemoteHome = (com.interfaces.HelloWorldHome) lookupHome(null, com.interfaces.HelloWorldHome.COMP_NAME, com.interfaces.HelloWorldHome.class);
聽聽聽聽聽 }
聽聽聽聽聽 return cachedRemoteHome;
聽聽 }

聽聽 /**
聽聽聽 * Obtain remote home interface from parameterised initial context
聽聽聽 * @param environment Parameters to use for creating initial context
聽聽聽 * @return Home interface for HelloWorld. Lookup using COMP_NAME
聽聽聽 */
聽聽 public static com.interfaces.HelloWorldHome getHome( java.util.Hashtable environment ) throws javax.naming.NamingException
聽聽 {
聽聽聽聽聽聽 return (com.interfaces.HelloWorldHome) lookupHome(environment, com.interfaces.HelloWorldHome.COMP_NAME, com.interfaces.HelloWorldHome.class);
聽聽 }

聽聽 /** Cached per JVM server IP. */
聽聽 private static String hexServerIP = null;

聽聽 // initialise the secure random instance
聽聽 private static final java.security.SecureRandom seeder = new java.security.SecureRandom();

聽聽 /**
聽聽聽 * A 32 byte GUID generator (Globally Unique ID). These artificial keys SHOULD <strong>NOT </strong> be seen by the user,
聽聽聽 * not even touched by the DBA but with very rare exceptions, just manipulated by the database and the programs.
聽聽聽 *
聽聽聽 * Usage: Add an id field (type java.lang.String) to your EJB, and add setId(XXXUtil.generateGUID(this)); to the ejbCreate method.
聽聽聽 */
聽聽 public static final String generateGUID(Object o) {
聽聽聽聽聽聽 StringBuffer tmpBuffer = new StringBuffer(16);
聽聽聽聽聽聽 if (hexServerIP == null) {
聽聽聽聽聽聽聽聽聽聽 java.net.InetAddress localInetAddress = null;
聽聽聽聽聽聽聽聽聽聽 try {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 // get the inet address

聽聽聽聽聽聽聽聽聽聽聽聽聽聽 localInetAddress = java.net.InetAddress.getLocalHost();
聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽 catch (java.net.UnknownHostException uhe) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 System.err.println("HelloWorldUtil: Could not get the local IP address using InetAddress.getLocalHost()!");
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 // todo: find better way to get around this...
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 uhe.printStackTrace();
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 return null;
聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽 byte serverIP[] = localInetAddress.getAddress();
聽聽聽聽聽聽聽聽聽聽 hexServerIP = hexFormat(getInt(serverIP), 8);
聽聽聽聽聽聽 }

聽聽聽聽聽聽 String hashcode = hexFormat(System.identityHashCode(o), 8);
聽聽聽聽聽聽 tmpBuffer.append(hexServerIP);
聽聽聽聽聽聽 tmpBuffer.append(hashcode);

聽聽聽聽聽聽 long timeNow聽聽聽聽聽 = System.currentTimeMillis();
聽聽聽聽聽聽 int timeLow聽聽聽聽聽聽 = (int)timeNow & 0xFFFFFFFF;
聽聽聽聽聽聽 int node聽聽聽聽聽聽聽聽聽 = seeder.nextInt();

聽聽聽聽聽聽 StringBuffer guid = new StringBuffer(32);
聽聽聽聽聽聽 guid.append(hexFormat(timeLow, 8));
聽聽聽聽聽聽 guid.append(tmpBuffer.toString());
聽聽聽聽聽聽 guid.append(hexFormat(node, 8));
聽聽聽聽聽聽 return guid.toString();
聽聽 }

聽聽 private static int getInt(byte bytes[]) {
聽聽聽聽聽聽 int i = 0;
聽聽聽聽聽聽 int j = 24;
聽聽聽聽聽聽 for (int k = 0; j >= 0; k++) {
聽聽聽聽聽聽聽聽聽聽 int l = bytes[k] & 0xff;
聽聽聽聽聽聽聽聽聽聽 i += l << j;
聽聽聽聽聽聽聽聽聽聽 j -= 8;
聽聽聽聽聽聽 }
聽聽聽聽聽聽 return i;
聽聽 }

聽聽 private static String hexFormat(int i, int j) {
聽聽聽聽聽聽 String s = Integer.toHexString(i);
聽聽聽聽聽聽 return padHex(s, j) + s;
聽聽 }

聽聽 private static String padHex(String s, int i) {
聽聽聽聽聽聽 StringBuffer tmpBuffer = new StringBuffer();
聽聽聽聽聽聽 if (s.length() < i) {
聽聽聽聽聽聽聽聽聽聽 for (int j = 0; j < i - s.length(); j++) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 tmpBuffer.append('0');
聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽 }
聽聽聽聽聽聽 return tmpBuffer.toString();
聽聽 }
}
////////////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?//////////////////////////////////////////////////////////////////
閰嶇疆鏂囦歡濡備笅錛?br />ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "

<ejb-jar >

聽聽 <description><![CDATA[No Description.]]></description>
聽聽 <display-name>Generated by XDoclet</display-name>

聽聽 <enterprise-beans>

聽聽聽聽聽 <!-- Session Beans -->
聽聽聽聽聽 <session >
聽聽聽聽聽聽聽聽 <description><![CDATA[Description for HelloWorld]]></description>
聽聽聽聽聽聽聽聽 <display-name>Name for HelloWorld</display-name>

聽聽聽聽聽聽聽聽 <ejb-name>HelloWorld</ejb-name>

聽聽聽聽聽聽聽聽 <home>com.interfaces.HelloWorldHome</home>
聽聽聽聽聽聽聽聽 <remote>com.interfaces.HelloWorld</remote>
聽聽聽聽聽聽聽聽 <ejb-class>com.ejb.HelloWorldSession</ejb-class>
聽聽聽聽聽聽聽聽 <session-type>Stateless</session-type>
聽聽聽聽聽聽聽聽 <transaction-type>Container</transaction-type>

聽聽聽聽聽 </session>

聽聽聽聽 <!--
聽聽聽聽聽聽 To add session beans that you have deployment descriptor info for, add
聽聽聽聽聽聽 a file to your XDoclet merge directory called session-beans.xml that contains
聽聽聽聽聽聽 the <session></session> markup for those beans.
聽聽聽聽 -->

聽聽聽聽聽 <!-- Entity Beans -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To add entity beans that you have deployment descriptor info for, add
聽聽聽聽聽聽 a file to your XDoclet merge directory called entity-beans.xml that contains
聽聽聽聽聽聽 the <entity></entity> markup for those beans.
聽聽聽聽 -->

聽聽聽聽聽 <!-- Message Driven Beans -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To add message driven beans that you have deployment descriptor info for, add
聽聽聽聽聽聽 a file to your XDoclet merge directory called message-driven-beans.xml that contains
聽聽聽聽聽聽 the <message-driven></message-driven> markup for those beans.
聽聽聽聽 -->

聽聽 </enterprise-beans>

聽聽 <!-- Relationships -->

聽聽 <!-- Assembly Descriptor -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To specify your own assembly descriptor info here, add a file to your
聽聽聽聽聽聽 XDoclet merge directory called assembly-descriptor.xml that contains
聽聽聽聽聽聽 the <assembly-descriptor></assembly-descriptor> markup.
聽聽聽聽 -->

聽聽 <assembly-descriptor >
聽聽聽聽 <!--
聽聽聽聽聽聽 To specify additional security-role elements, add a file in the merge
聽聽聽聽聽聽 directory called ejb-security-roles.xml that contains them.
聽聽聽聽 -->

聽聽 <!-- method permissions -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To specify additional method-permission elements, add a file in the merge
聽聽聽聽聽聽 directory called ejb-method-permissions.ent that contains them.
聽聽聽聽 -->

聽聽 <!-- transactions -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To specify additional container-transaction elements, add a file in the merge
聽聽聽聽聽聽 directory called ejb-container-transactions.ent that contains them.
聽聽聽聽 -->

聽聽 <!-- finder transactions -->

聽聽 <!-- message destinations -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To specify additional message-destination elements, add a file in the merge
聽聽聽聽聽聽 directory called ejb-message-destinations.ent that contains them.
聽聽聽聽 -->

聽聽 <!-- exclude list -->
聽聽聽聽 <!--
聽聽聽聽聽聽 To specify an exclude-list element, add a file in the merge directory
聽聽聽聽聽聽 called ejb-exclude-list.xml that contains it.
聽聽聽聽 -->
聽聽 </assembly-descriptor>
</ejb-jar>
//////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?//////////////////////////////////////////////////////////////////////////
weblogic-ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "

<weblogic-ejb-jar>
聽<description><![CDATA[Generated by XDoclet]]></description>
聽聽 <weblogic-enterprise-bean>
聽聽聽聽聽 <ejb-name>HelloWorld</ejb-name>
聽聽聽聽聽 <stateless-session-descriptor>
聽聽聽聽聽 </stateless-session-descriptor>
聽聽聽聽聽 <reference-descriptor>
聽聽聽聽聽 </reference-descriptor>

聽聽聽聽聽 <jndi-name>ejb/HelloWorld</jndi-name>
聽聽 </weblogic-enterprise-bean>
<!--
To add enterprise beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called weblogic-enterprise-beans.xml that contains
the <weblogic-enterprise-bean></weblogic-enterprise-bean> markup for those beans.
-->

聽<!--
聽To add a security-role-assignment section, add
聽a file to your XDoclet merge directory called weblogic-security-role-assignment.xml that contains
聽the <security-role-assignment></security-role-assignment> markup.
聽-->聽

聽<!--
聽To add a run-as-role-assignment section, add
聽a file to your XDoclet merge directory called weblogic-run-as-role-assignment.xml that contains
聽the <run-as-role-assignment></run-as-role-assignment> markup.
聽-->
</weblogic-ejb-jar>
////////////////////////////////////////////////////////////////////////鍒嗗壊綰?//////////////////////////////////////////////////////////////////////////////////
鎵撴垚JIA鍖呴儴緗插埌WEBLOGIC鏈嶅姟鍣ㄣ?br />鏈鍚庢槸璋冪敤浠g爜錛?br />package com;

import java.rmi.RemoteException;
import java.util.Properties;

import javax.ejb.CreateException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.interfaces.HelloWorld;
import com.interfaces.HelloWorldHome;
import javax.rmi.PortableRemoteObject;

public class EJBTest {

聽聽聽聽 /**
聽聽聽聽聽 * @param args
聽聽聽聽 */
聽聽聽聽 public static void main(String[] args) throws Exception {
聽聽聽聽聽聽聽聽 // TODO 鑷姩鐢熸垚鏂規硶瀛樻牴
聽聽聽聽聽聽聽聽 Properties properties=new Properties();
聽聽聽聽聽聽聽聽 properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
聽聽聽聽聽聽聽聽 properties.setProperty(Context.PROVIDER_URL,"t3://localhost:7001");
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽 Context context;
聽聽聽聽聽聽聽聽 try {
聽聽聽聽聽聽聽聽聽聽聽聽 context = new InitialContext(properties);
聽聽聽聽聽聽聽聽聽聽聽聽 HelloWorldHome hwh=(HelloWorldHome)context.lookup("ejb/HelloWorld");
聽聽聽聽聽聽聽聽聽聽聽聽 HelloWorld hw=hwh.create();
聽聽聽聽聽聽聽聽聽聽聽聽 String s=hw.getMessage();
聽聽聽聽聽聽聽聽聽聽聽聽 System.out.println(s);
聽聽聽聽聽聽聽聽 } catch (NamingException e) {
聽聽聽聽聽聽聽聽聽聽聽聽 // TODO 鑷姩鐢熸垚 catch 鍧?br />聽聽聽聽聽聽聽聽聽聽聽聽 e.printStackTrace();
聽聽聽聽聽聽聽聽 } catch (RemoteException e) {
聽聽聽聽聽聽聽聽聽聽聽聽 // TODO 鑷姩鐢熸垚 catch 鍧?br />聽聽聽聽聽聽聽聽聽聽聽聽 e.printStackTrace();
聽聽聽聽聽聽聽聽 } catch (CreateException e) {
聽聽聽聽聽聽聽聽聽聽聽聽 // TODO 鑷姩鐢熸垚 catch 鍧?br />聽聽聽聽聽聽聽聽聽聽聽聽 e.printStackTrace();
聽聽聽聽聽聽聽聽 }
聽聽聽 聽 /*Properties properties=new Properties();
聽聽聽聽聽聽聽聽 properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
聽聽聽聽聽聽聽聽 properties.setProperty(Context.PROVIDER_URL,"t3://localhost:7001");
聽聽聽 聽 Context context = new InitialContext(properties);
聽聽聽 聽 Object obj = context.lookup("ejb/HelloWorld");
聽聽聽 聽 HelloWorldHome home = (HelloWorldHome)PortableRemoteObject.narrow(obj,HelloWorldHome.class );
聽聽聽 聽 HelloWorld hello = home.create();
聽聽聽 聽 System.out.println(hello.getMessage());*/
聽聽聽聽 }聽
聽}

閮ㄧ講EJB

1. 聽聽聽聽聽聽聽 MyEclipse >Add and Remove Project Deployments

2. 聽聽聽聽聽聽聽 鐐瑰嚮 add 錛屾坊鍔犻儴緗叉湇鍔″櫒 weblogic 銆?br />
铏界劧鑳戒嬌鐢ㄤ簡錛屼絾榪樻槸鏈夊緢澶氬湴鏂逛笉澶槑鐧姐傛參鎱㈣繘姝ュ挴錛?/p>

KanIT 2006-08-09 11:18 鍙戣〃璇勮
]]>
璇歌憶浜笌IOC鐨勫叧緋?/title><link>http://www.aygfsteel.com/wukerit/archive/2006/07/31/KenIT.html</link><dc:creator>KanIT</dc:creator><author>KanIT</author><pubDate>Mon, 31 Jul 2006 03:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/wukerit/archive/2006/07/31/KenIT.html</guid><wfw:comment>http://www.aygfsteel.com/wukerit/comments/60976.html</wfw:comment><comments>http://www.aygfsteel.com/wukerit/archive/2006/07/31/KenIT.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wukerit/comments/commentRss/60976.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wukerit/services/trackbacks/60976.html</trackback:ping><description><![CDATA[ <p>鐪嬭繃涓夊浗蹇楃殑鏈嬪弸閮界煡閬撲竴鍙ュ悕璦:涓囦簨鍏峰,鍙瑺涓滈.<br />鏈榪戝湪瀛︿範SPRING妗嗘灦鐨勬椂鍊欏姝ゅ張鏈変簡娣卞眰鐨勭悊瑙?<br />鏈榪戝紑鍙戜竴涓嚑鐧句漢鐨勫ぇ欏圭洰,鐢變簬鏌愪簺鍥犵礌,涓嶈兘浣跨敤寮婧愭鏋?鎴戜滑寮鍙戜漢鍛樺晢璁?鍑嗗欏哄簲娼祦,浣跨敤SPRING妗嗘灦鐨勬煇浜涜璁℃濇兂鏉ュ畬鎴愬伐浣?<br />鐢變簬澶у閮芥病鏈夊嚑鐧句漢涓璧峰伐浣滅殑欏圭洰緇忛獙,鎵浠ュ紑濮嬮樁孌墊槸鐥涜嫤鑰屾病鏈夋垚鏁堢殑.鐗瑰埆鍦ㄥ晢璁浉浜掕皟鐢ㄧ殑鎺ュ彛鏃?綆鐩存垚浜嗚浠瘋繕浠風殑鑿滃競鍦?姣忎釜浜虹殑鎯蟲硶,姘村鉤,鍙婅璁¤兘鍔涚殑宸紓).~_~!!!<br />鐧炬棤鑱婅禆涓?璺戝幓寮涓夊浗(浣犱滑鍚典綘浠殑鍚?鎴戜紤鎭厛),鐪嬪埌璇歌憶浜熶笢椋庝竴鑺?紿佺劧鐏墊満涓鍔?榪欎笉灝辨槸SPRING妗嗘灦鐨処OC鎬濇兂涔??鎴戝厛涓囦簨鍏峰鍐嶈,鍙瑺涓滈灝監K!鎯沖埌榪欓噷,蹇冧腑紿冨枩,浜庢槸灝嗛渶瑕佺殑鎺ュ彛鏁版嵁鏁寸悊鍑烘潵鍐欎簡涓猉ML鏂囨。,騫剁敤DTD瀹氫箟,鐩存帴鎵旂粰璋冪敤鎴戠殑瀹朵紮,鎯崇敤鎴戠殑鎺ュ彛涔??鎴戝氨瑕佽繖浜涙暟鎹?浣犵湅鐫鍔炲惂~~!<br />浜庢槸涓嶇浠栨復姹傜殑琛ㄦ儏,鑷繁宸ヤ綔鍘諱篃.閭d釜蹇冮噷鐖藉晩~<br />涓嬮潰鏄竴浜涙ā鎷熶唬鐮?甯屾湜鑳芥湁鐢?<br />/*瀹氫箟渚濊禆娉ㄥ叆鐨勬暟鎹帴鍙?/<br />public interface IOCINTERFACE<br />{<br />聽聽聽//鍙畾涔変竴涓獙璇佹柟娉?楠岃瘉DTD瀹氫箟鐨勬暟鎹?br />聽聽聽public boolean validate();<br />}<br />////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?///////////////////////////////////////////////////////////////////////////////////////<br />/**/<br />class IOCObject implement IOCINTERFACE<br />{<br />聽聽聽//闇瑕佹敞鍏ョ殑鏁版嵁<br />聽聽聽private String username;<br />聽聽聽public void setUsername(String username)<br />聽聽聽{<br />聽聽聽聽聽聽this.username = username;<br />聽聽聽}<br />聽聽聽public String getUsername()<br />聽聽聽{<br />聽聽聽聽聽聽return this.username聽;<br />聽聽聽}<br />聽聽聽//楠岃瘉涓涓嬫槸鍚︽槸鎴戣鐨勬暟鎹?br />聽聽聽public boolean validate()<br />聽聽聽{<br />聽聽聽聽聽聽if(this.username = null)<br />聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽return false;<br />聽聽聽聽聽聽}<br />聽聽聽聽聽聽return true;<br />聽聽聽}<br />}<br />////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?///////////////////////////////////////////////////////////////////////////////////////<br />/*鍐嶅畾涔変竴涓墽琛屾帴鍙?/<br />public interface OPERATION<br />{<br />聽聽聽public void execute();<br />}<br />////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?///////////////////////////////////////////////////////////////////////////////////////<br />class Test implement OPERATION<br />{<br />聽聽聽//瀹氫箟鎿嶄綔瀵硅薄<br />聽聽聽private IOCObject obj;<br />聽聽聽public void Test( IOCObject obj)<br />聽聽聽{<br />聽聽聽聽聽聽this.obj = obj;<br />聽聽聽}<br />聽聽聽public void execute()<br />聽聽聽{<br />聽聽聽聽聽聽if(this.obj.validate)<br />聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽//澶勭悊涓氬姟閫昏緫<br />聽聽聽聽聽聽聽聽聽System.out.println(this.obj.getUsername+"hello!");<br />聽聽聽聽聽聽}<br />聽聽聽聽聽聽else<br />聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽//寮傚父鏃ュ織<br />聽聽聽聽聽聽聽聽聽聽聽聽System.out.println("MB~~~緇欑殑浠涔堟暟鎹晩~~鎴戝徏!")<br />聽聽聽聽聽聽}<br />聽聽聽}<br />}<br />////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?///////////////////////////////////////////////////////////////////////////////////////<br />/*涓囦簨鍏峰浜?鍊熶笢椋庡惂!*/<br />public class Main<br />{<br />聽聽聽public static void main(String[]args)<br />聽聽聽{<br />聽聽聽聽聽聽//鍋氫釜涓滈鍏?br />聽聽聽聽聽聽IOCObject聽obj = new IOCObject聽();<br />聽聽聽聽聽聽obj聽.setUsername("KenIT");<br />聽聽聽聽聽聽//渚濊禆娉ㄥ叆浜?楂樺叴鍟?<br />聽聽聽聽聽聽Test聽test = new Test(ob);<br />聽聽聽聽聽聽//瀹屾垚宸ヤ綔,鎵撳畬鏀跺姛<br />聽聽聽聽聽聽test.execute();<br />聽聽聽}<br />}<br />////////////////////////////////////////////////////////////////////////////////鍒嗗壊綰?///////////////////////////////////////////////////////////////////////////////////////<br />鍥炴兂鏉ュ彂鐜癐OC灝辨槸鎴戜滑鐨勮钁涜佸墠杈堝彂鏄庣殑,灞呯劧.....,鎴戝己鐑堝懠鍚佹敹鐗堟潈紼?<br />涓崕姘戞棌涓囧瞾~~~!</p> <img src ="http://www.aygfsteel.com/wukerit/aggbug/60976.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wukerit/" target="_blank">KanIT</a> 2006-07-31 11:22 <a href="http://www.aygfsteel.com/wukerit/archive/2006/07/31/KenIT.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> 主站蜘蛛池模板: <a href="http://" target="_blank">蕲春县</a>| <a href="http://" target="_blank">玉林市</a>| <a href="http://" target="_blank">富蕴县</a>| <a href="http://" target="_blank">巴马</a>| <a href="http://" target="_blank">广西</a>| <a href="http://" target="_blank">遂昌县</a>| <a href="http://" target="_blank">鄂托克旗</a>| <a href="http://" target="_blank">苗栗市</a>| <a href="http://" target="_blank">大邑县</a>| <a href="http://" target="_blank">拜泉县</a>| <a href="http://" target="_blank">越西县</a>| <a href="http://" target="_blank">天镇县</a>| <a href="http://" target="_blank">罗山县</a>| <a href="http://" target="_blank">吴忠市</a>| <a href="http://" target="_blank">贵南县</a>| <a href="http://" target="_blank">涟源市</a>| <a href="http://" target="_blank">乌鲁木齐市</a>| <a href="http://" target="_blank">读书</a>| <a href="http://" target="_blank">泽州县</a>| <a href="http://" target="_blank">读书</a>| <a href="http://" target="_blank">大方县</a>| <a href="http://" target="_blank">柘城县</a>| <a href="http://" target="_blank">夏津县</a>| <a href="http://" target="_blank">长子县</a>| <a href="http://" target="_blank">达日县</a>| <a href="http://" target="_blank">四川省</a>| <a href="http://" target="_blank">昌乐县</a>| <a href="http://" target="_blank">道真</a>| <a href="http://" target="_blank">江津市</a>| <a href="http://" target="_blank">襄城县</a>| <a href="http://" target="_blank">平山县</a>| <a href="http://" target="_blank">固始县</a>| <a href="http://" target="_blank">华亭县</a>| <a href="http://" target="_blank">信阳市</a>| <a href="http://" target="_blank">保亭</a>| <a href="http://" target="_blank">安达市</a>| <a href="http://" target="_blank">洪湖市</a>| <a href="http://" target="_blank">清涧县</a>| <a href="http://" target="_blank">大厂</a>| <a href="http://" target="_blank">石狮市</a>| <a href="http://" target="_blank">寻乌县</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>