red5+hibernate

Application 代码:
package conjs.invoke;

import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.Red5;
import org.red5.server.api.IScope;
import org.red5.server.api.service.IPendingServiceCall;
import org.red5.server.api.service.IPendingServiceCallback;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Application extends ApplicationAdapter implements    IPendingServiceCallback {  
    private static final Log log = LogFactory.getLog(Application.class);
    private conjs.game.dao.IConjsUsersDAO ado = new conjs.game.dao.impl.ConjsUsersDAO();
   
   
    @SuppressWarnings("unchecked")
    @Override
    public boolean connect(IConnection conn, IScope scope, Object[] params) {

        if (params == null || params.length == 0) {
            rejectClient("no pars");
        }
       
       
        if (!super.connect(conn, scope, params)) {
            log.info("super false");
            return false;
        }
       
        log.info("ready.............................................");
   
        //org.red5.io.utils.ObjectMap<String,String> om = (org.red5.io.utils.ObjectMap)params[0];
       
        //log.info(om);
        log.info("params:::::::::::::::::::::::::::::::::::::::"+params[0]);
        //String username = om.get("name");
        //String pwd = om.get("pwd");
        log.info("333333333");
       
   
        int ii=ado.Exits("aa", "aa");
   
        if(ii<=0){
            log.info("usrename and pwd invalidat");
            System.out.print("..............");
            return false;
        }
       
        return true;
    }

   
    @Override
    public void disconnect(IConnection conn, IScope scope) {
        System.out.println("[disconnect]"+conn.getClient().getId());
        super.disconnect(conn, scope);
    }

    public void resultReceived(IPendingServiceCall arg0) {
        IConnection myConn = Red5.getConnectionLocal();
        log.info("ID:" + myConn.getClient().getId() + "锟斤拷锟斤拷值:"
                + arg0.getResult().toString());
    }


   
}



DAO代码:
public int Exits(String userLogin, String pwd) {
        Session s = HibernateSessionFactory.getSession();
        try {
            String queryString = "from Users as model where model.userid=? and model.pwd=?";
            Query q  = s.createQuery(queryString);
            q.setString(0, userLogin);
            q.setString(1, pwd);
            int i = q.list().size();
            log.info("Exits Result:"+i);
            return i;
        } catch (RuntimeException re) {
            throw re;
        }
        finally{
            s.close();
        }
    }

你可能感兴趣的:(DAO,apache,Hibernate)