Package de.danet.an.util.logging

Examples of de.danet.an.util.logging.RequestScope


     * @throws ImportException if the input is not a correct.
     * @ejb.interface-method view-type="remote"
     */
    public List importProcessDefinitions(String processDefinitions)
  throws ImportException {
        RequestScope scope = RequestLog.enterScope
            (this, "importProcessDefinitions",
             new Object[] { processDefinitions });
        List res = null;
        try {
            res = importProcessDefinitions
            (new InputSource(new StringReader(processDefinitions)));
        } finally {
            scope.leave (res);
        }
        return res;
    }
View Full Code Here


     * @throws ImportException if the input is not a correct.
     * @ejb.interface-method view-type="remote"
     */
    public List importProcessDefinitions(byte[] processDefinitions)
  throws ImportException {
        RequestScope scope = RequestLog.enterScope
            (this, "importProcessDefinitions",
             new Object[] { processDefinitions });
        List res = null;
        try {
            res = importProcessDefinitions
      (new InputSource(new ByteArrayInputStream(processDefinitions)));
        } finally {
            scope.leave (res);
        }
        return res;
    }
View Full Code Here

     * (formally) invalid ids.
     * @ejb.interface-method view-type="remote"
     */
    public void removeProcessDefinition(String packageId, String processId)
  throws InvalidKeyException {
        RequestScope scope = RequestLog.enterScope
            (this, "removeProcessDefinition",
             new Object[] { packageId, processId });
        try {
            prepareForRemoval(packageId, processId);
            PreparedStatement prepStmt = null;
            Connection con = null;
            ResultSet rs = null;
            try {
                String processType = packageId + "/" + processId;
                uncacheDefinition (processType);
                con = ds.getConnection();
                prepStmt = con.prepareStatement
                    ("SELECT XPDLREF FROM PROCESSDEFINITION "
                     + "WHERE PACKAGEID = ? AND PROCESSID = ?");
                prepStmt.setString(1, packageId);
                prepStmt.setString(2, processId);
                rs = prepStmt.executeQuery();
                if(!rs.next()) {
                    return;
                }
                long xpdlId = rs.getLong(1);
                rs.close();
                rs = null;
                prepStmt.close();
                prepStmt = null;
                // remove process definition from the database
                prepStmt = con.prepareStatement
                    ("DELETE FROM PROCESSDEFINITION "
                     + "WHERE PACKAGEID = ? AND PROCESSID = ?");
                prepStmt.setString(1, packageId);
                prepStmt.setString(2, processId);
                prepStmt.executeUpdate();
                removeXpdlIfOrphaned(xpdlId);
            } finally {
                JDBCUtil.closeAll (rs, prepStmt, con);
      }
  } catch (SQLException e) {
      throw new EJBException(e);
        } finally {
            scope.leave ();
        }
    }
View Full Code Here

     * the given ids exists.
     * @ejb.interface-method view-type="remote"
     */
    public ProcessDefinition lookupProcessDefinition
  (String packageId, String processId) throws InvalidKeyException {
        RequestScope scope = RequestLog.enterScope
            (this, "lookupProcessDefinition",
             new Object[] { packageId, processId });
        ProcessDefinition res = null;
        try {
            res = lookupProcessDefinitionInfo
                (packageId, processId).processDefinition;
        } finally {
            scope.leave (res);
        }
        return res;
    }
View Full Code Here

     * @ejb.interface-method view-type="local"
     * @ejb.transaction type="RequiresNew"
     */
    public ProcessDefinitionInfo lookupProcessDefinitionInfo
  (String packageId, String processId) throws InvalidKeyException {
        RequestScope scope = RequestLog.enterScope
            (this, "lookupProcessDefinitionInfo",
             new Object[] { packageId, processId });
  ProcessDefinitionInfo processDefinitionInfo = null;
  try {
       Connection con = null;
      PreparedStatement prepStmt = null;
      ResultSet rs = null;
      try {
    String processType = packageId + "/" + processId;
    con = ds.getConnection();
    prepStmt = con.prepareStatement
        ("SELECT DBID, ENABLED, XPDLREF FROM PROCESSDEFINITION "
         + "WHERE PACKAGEID = ? AND PROCESSID = ?");
    prepStmt.setString(1, packageId);
    prepStmt.setString(2, processId);
    rs = prepStmt.executeQuery();
    if(!rs.next()) {
        // cleanup cache as a side effect
        uncacheDefinition (processType);
        throw new InvalidKeyException
      ("No process with packageId/processId = "+ processType);
    }
    long dbid = rs.getLong(1);
    boolean enabled = (rs.getString(2).charAt(0) == 'T');
                Long xpdlRef = JDBCUtil.getLong(rs, 3);
                synchronized (processDefinitionInfoCache) {
                    processDefinitionInfo = (ProcessDefinitionInfo)
                        processDefinitionInfoCache.get(new Long(dbid));
                    if (processDefinitionInfo != null) {
                        if (processDefinitionInfo.dbid != dbid) {
                            uncacheDefinition(processType);
                            processDefinitionInfo = null;
                        }
                    }
                }
    if (processDefinitionInfo != null) {
        processDefinitionInfo.enabled = enabled;
        if (logger.isDebugEnabled ()) {
      logger.debug
          ("found (" + processDefinitionInfo
           .processDefinition.packageId()
           + "/" + processDefinitionInfo
           .processDefinition.processId() + ") "
           + "in cache");
        }
        return processDefinitionInfo;
    }
                rs.close();
                rs = null;
                prepStmt.close();
                prepStmt = null;
                String xpdl = null;
                // For backward compatibility allow xpdlref to be null
                if (xpdlRef != null) {
                    prepStmt = new UniversalPrepStmt
                        (con, "SELECT XPDL FROM XPDLARCHIVE WHERE DBID = ?");
                    prepStmt.setLong(1, xpdlRef.longValue());
                    rs = prepStmt.executeQuery();
                    if (rs.next()) {
                        xpdl = JDBCUtil.getString(ds, rs, 1);
                    }
                } else {
                    prepStmt = new UniversalPrepStmt
                        (con, "SELECT XPDL FROM PROCESSDEFINITION "
                         + "WHERE DBID = ?");
                    prepStmt.setLong(1, dbid);
                    rs = prepStmt.executeQuery();
                    if (rs.next()) {
                        xpdl = JDBCUtil.getString(ds, rs, 1);
                    }
                }
    processDefinitionInfo = new ProcessDefinitionInfo
        (dbid, xpdlRef,
         new DefaultProcessDefinition (xpdl), enabled);
    cacheDefinition(processDefinitionInfo);
    return processDefinitionInfo;
      } finally {
    JDBCUtil.closeAll (rs, prepStmt, con);
      }
  } catch (SQLException se) {
      throw new EJBException(se);
  } catch (IOException ioe) {
      throw new EJBException(ioe);
  } catch (ImportException pe) {
      throw new EJBException(pe);
  } finally {
      scope.leave (processDefinitionInfo);
  }
    }
View Full Code Here

     * the given ids exists.
     * @ejb.interface-method view-type="remote"
     */
    public boolean isEnabled(String packageId, String processId)
  throws InvalidKeyException {
        RequestScope scope = RequestLog.enterScope
            (this, "isEnabled", new Object[] { packageId, processId });
  boolean enabled = false;
  Connection con = null;
  ResultSet rs = null;
  PreparedStatement prepStmt = null;
  try {
      con = ds.getConnection();
      prepStmt = con.prepareStatement
    ("SELECT ENABLED FROM PROCESSDEFINITION "
    + "WHERE PACKAGEID = ? AND PROCESSID = ?");
      prepStmt.setString(1, packageId);
      prepStmt.setString(2, processId);
      rs = prepStmt.executeQuery();
      if(!rs.next()) {
    ctx.setRollbackOnly();
                throw new InvalidKeyException
        ("No process with packageId/processId = "
         + packageId + "/" + processId);
      }
      if (rs.getString(1).charAt(0) == 'T') {
    enabled = true;
      }
      return enabled;
  } catch (SQLException se) {
      throw new EJBException(se);
  } finally {
      try {
    JDBCUtil.closeAll (rs, prepStmt, con);
      } catch (SQLException e) {
    throw new EJBException(e);
      }
      scope.leave(new Boolean (enabled));
  }
    }
View Full Code Here

     * @ejb.interface-method view-type="remote"
     */
    public void setEnabled
  (String packageId, String processId, boolean enabled)
  throws InvalidKeyException {
        RequestScope scope = RequestLog.enterScope
            (this, "setEnabled",
             new Object[] { packageId, processId, new Boolean (enabled) });
  Connection con = null;
  PreparedStatement prepStmt = null;
  try {
      con = ds.getConnection();
      prepStmt = con.prepareStatement
    ("UPDATE PROCESSDEFINITION SET ENABLED = ? "
     + "WHERE PACKAGEID = ? AND PROCESSID = ?");
      if (enabled) {
    prepStmt.setString(1, "T");
      } else {
    prepStmt.setString(1, "F");
      }
      prepStmt.setString(2, packageId);
      prepStmt.setString(3, processId);
      int rowCount = prepStmt.executeUpdate();
      if (rowCount == 0) {
                ctx.setRollbackOnly();
    throw new InvalidKeyException
        ("No process with packageId/processId = "
         + packageId + "/" + processId);
      }

  } catch (SQLException se) {
      throw new EJBException(se);
  } finally {
      try {
    JDBCUtil.closeAll (null, prepStmt, con);
      } catch (SQLException e) {
    throw new EJBException(e);
      }
      scope.leave();
  }
    } 
View Full Code Here

TOP

Related Classes of de.danet.an.util.logging.RequestScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.