コード例 #1
0
ファイル: RecordManager.java プロジェクト: gyuu/MiniSQL
  public void selectRecord(String tableName, ArrayList<Condition> conditions)
      throws TableNotFoundException {
    Table table = cm.getTable(tableName);
    if (table == null) throw new TableNotFoundException(tableName);
    Data selectResult = new Data();

    for (int blockOffset = 0; blockOffset < table.blockNum; blockOffset++) {
      BufferNode bn = bm.getBufferNode(table.name + ".table", blockOffset);
      byte[] block = bn.data;
      int recordNum = getRecordNum(block);
      int recordIndex = 0;
      int accessedRecordNum = 0;

      while (accessedRecordNum < recordNum) {
        int pos = getPositionFromIndex(table, recordIndex);
        if (block[pos] == EMPTY) { // record is empty, skip
          recordIndex++;
          continue;
        }

        byte[] recordBytes = bn.getBytes(pos + 1, table.totalLength);
        if (matchAllCond(table, recordBytes, conditions)) {
          byte[] bytes = bn.getBytes(pos + 1, table.totalLength);
          selectResult.add(new Row(bytesToString(table, bytes)));
        }
        recordIndex++;
        accessedRecordNum++;
      }
    }

    displaySelectResult(table, selectResult);
  }
コード例 #2
0
ファイル: TransientSpace.java プロジェクト: eMerchantPay/jPOS
 public void out(Object key, Object value) {
   List listeners;
   synchronized (this) {
     Data data = (Data) map.get(key);
     if (data == null) map.put(key, (data = new Data()));
     data.add(value);
     this.notifyAll();
     listeners = data.getListeners();
   }
   if (listeners != null) {
     Iterator iter = listeners.iterator();
     while (iter.hasNext()) {
       ((SpaceListener) iter.next()).notify(key, value);
     }
   }
 }
コード例 #3
0
  public void deploy(BeanContext beanContext) throws OpenEJBException {
    Data data = new Data(beanContext);
    beanContext.setContainerData(data);

    beanContext.set(EJBContext.class, this.sessionContext);

    // Create stats interceptor
    StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
    beanContext.addSystemInterceptor(stats);

    MBeanServer server = LocalMBeanServer.get();

    ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
    jmxName.set("J2EEServer", "openejb");
    jmxName.set("J2EEApplication", null);
    jmxName.set("EJBModule", beanContext.getModuleID());
    jmxName.set("SingletonSessionBean", beanContext.getEjbName());
    jmxName.set("j2eeType", "");
    jmxName.set("name", beanContext.getEjbName());

    // register the invocation stats interceptor
    try {
      ObjectName objectName = jmxName.set("j2eeType", "Invocations").build();
      server.registerMBean(new ManagedMBean(stats), objectName);
      data.add(objectName);
    } catch (Exception e) {
      logger.error("Unable to register MBean ", e);
    }

    try {
      final Context context = beanContext.getJndiEnc();
      context.bind("comp/EJBContext", sessionContext);
      context.bind("comp/WebServiceContext", webServiceContext);
      context.bind("comp/TimerService", new TimerServiceWrapper());
    } catch (NamingException e) {
      throw new OpenEJBException("Failed to bind EJBContext/WebServiceContext/TimerService", e);
    }
  }