private String readVersionFromManifest(Class<?> api) throws IOException {
   String className = api.getSimpleName() + ".class";
   URL resource = api.getResource(className);
   log.trace("get resource for {} -> {} -> {}", new Object[] {className, pathOf(api), resource});
   if (resource == null) return null;
   String version = null;
   String classPath = resource.toString();
   if (classPath.startsWith("jar:"))
     version = version(classPath.substring(0, classPath.lastIndexOf("!") + 1));
   if (version == null && classPath.endsWith(pathOf(api) + ".class"))
     version = version(classPath.substring(0, classPath.length() - pathOf(api).length() - 7));
   if (version == null && classPath.contains("/WEB-INF/"))
     version = version(classPath.substring(0, classPath.lastIndexOf("/WEB-INF/")));
   log.debug("version {} for {} from {}.", version, api, classPath);
   return version;
 }
  /**
   * @param <T> the return type
   * @param retvalClass the returned value's {@link Class}
   * @param jndi the JNDI path to the resource
   * @return the resource at the specified {@code jndi} path
   */
  private static <T> T lookup(Class<T> retvalClass, String jndi) {
    try {

      return retvalClass.cast(InitialContext.doLookup(jndi));
    } catch (NamingException ex) {
      throw new IllegalArgumentException(
          "failed to lookup instance of " + retvalClass + " at " + jndi, ex);
    }
  }
 private void updateDB() {
   try {
     // Class.forName("com.inet.ora.OraDriver");
     Class.forName("org.apache.derby.jdbc.ClientDriver");
     //// String url = "jdbc:inetora::wrx.india.sun.com:1521:dbsmpl1";
     String url = "jdbc:derby://localhost:1527/testdb;create=true;";
     java.sql.Connection con = DriverManager.getConnection(url, "dbuser", "dbpassword");
     String qry = "update lifecycle_test1 set status=1";
     con.createStatement().executeUpdate(qry);
     con.close();
   } catch (Exception e) {
     System.out.println("Error:" + e.getMessage());
   }
 }
  public static Message createMessage(Session session, Class messageClazz) throws JMSException {
    if (session == null) {
      throw new JMSException("session cannot be null");
    }
    if (Message.class.isAssignableFrom(messageClazz)) {
      throw new JMSException("cannot create message of type: " + messageClazz.getName());
    }

    if (TextMessage.class.equals(messageClazz)) {
      return session.createTextMessage();
    } else if (StreamMessage.class.equals(messageClazz)) {
      return session.createStreamMessage();
    } else if (MapMessage.class.equals(messageClazz)) {
      return session.createMapMessage();
    } else if (ObjectMessage.class.equals(messageClazz)) {
      return session.createObjectMessage();
    } else if (BytesMessage.class.equals(messageClazz)) {
      return session.createBytesMessage();
    } else if (Message.class.equals(messageClazz)) {
      return session.createMessage();
    } else {
      throw new JMSException("cannot create message of type: " + messageClazz.getName());
    }
  }
 public String getVersion(Class<?> api) {
   log.trace("getVersion for {}", api);
   Package pkg = api.getPackage();
   log.trace("    -> {}/{}", pkg.getImplementationVersion(), pkg.getSpecificationVersion());
   String version = pkg.getSpecificationVersion();
   if (version == null) version = pkg.getImplementationVersion();
   if (version == null) {
     try {
       version = readVersionFromManifest(api);
     } catch (IOException e) {
       log.error("Could not extract version for " + api, e);
       return null;
     }
   }
   return version;
 }
 private String pathOf(Class<?> api) {
   return api.getCanonicalName().replace('.', '/');
 }