Esempio n. 1
0
 public InputSource resolveEntity(String publicId, String systemId)
     throws SAXException, IOException {
   // check for recognized ids
   if (((publicId != null) && RECOGNIZED_PUBLIC_ID.equals(publicId))
       || ((publicId == null) && (systemId != null) && RECOGNIZED_SYSTEM_ID.equals(systemId))) {
     // Substitute the dtd with the one from
     // com.sun.persistence.support.jdo.dtd, but only if the
     // publicId is equal to RECOGNIZED_PUBLIC_ID or there is no
     // publicID and the systemID is equal to RECOGNIZED_SYSTEM_ID.
     InputStream stream =
         (InputStream)
             AccessController.doPrivileged(
                 new PrivilegedAction() {
                   public Object run() {
                     return getClass()
                         .getClassLoader()
                         .getResourceAsStream("com/sun/persistence/support/jdo.dtd"); // NOI18N
                   }
                 });
     if (stream == null) {
       throw new RuntimeException(
           msg.msg(
               "EXC_MissingJDODTD", // NOI18N
               publicId,
               systemId));
     }
     return new InputSource(new InputStreamReader(stream));
   }
   return null;
 }
  /** {@inheritDoc} */
  @Override
  public void init(
      EjbBundleDescriptor ejbBundleDescriptor, EjbcContext ejbcContext, String bundlePathName)
      throws GeneratorException {
    logger.info(
        i18NHelper.msg(
            "MSG_JDOCodeGeneratorInit", // NOI18N
            JDOCodeGeneratorHelper.getModuleName(ejbBundleDescriptor)));

    this.ejbBundleDescriptor = ejbBundleDescriptor;
    if (ejbBundleDescriptor.containsCMPEntity()) {
      // do the pre EJB 3.0 related stuff here.
      super.init(ejbBundleDescriptor, ejbcContext, bundlePathName);
    }

    if (ejbBundleDescriptor.containsPersistenceEntity()) {
      // now do the EJB 3.0 specific task
      pjl = new PersistenceJarLoader();
      pjl.load(ejbBundleDescriptor);
    }
  }
  /** {@inheritDoc} */
  @Override
  public Collection cleanup() throws GeneratorException {
    logger.info(
        i18NHelper.msg(
            "MSG_JDOCodeGeneratorCleanup", // NOI18N
            JDOCodeGeneratorHelper.getModuleName(ejbBundleDescriptor)));

    Collection result = null;
    if (ejbBundleDescriptor.containsCMPEntity()) {
      // do the pre EJB 3.0 related stuff here.
      result = super.cleanup();
    }
    if (ejbBundleDescriptor.containsPersistenceEntity()) {
      // now do the EJB 3.0 specific task
      pjl.unload();
    }
    // we have nothing to return for 3.0 beans until we integrate
    // enhancer with deployment. So as per the contract,
    // we return an empty collection and not a null collection if
    // we have only 3.0 beans.
    return result == null ? Collections.emptyList() : result;
  }