Ejemplo n.º 1
0
  private PersistenceUnitMetadata getPersistenceUnit(
      final DeploymentUnit deploymentUnit, final String puName)
      throws DeploymentUnitProcessingException {

    PersistenceUnitMetadata pu =
        PersistenceUnitSearch.resolvePersistenceUnitSupplier(deploymentUnit, puName);
    if (null == pu) {
      throw new DeploymentUnitProcessingException(
          MESSAGES.persistenceUnitNotFound(puName, deploymentUnit));
    }
    return pu;
  }
Ejemplo n.º 2
0
 private InjectionSource getPersistenceUnitBindingSource(
     final DeploymentUnit deploymentUnit, final String unitName)
     throws DeploymentUnitProcessingException {
   final String searchName;
   if (isEmpty(unitName)) {
     searchName = null;
   } else {
     searchName = unitName;
   }
   final PersistenceUnitMetadata pu =
       PersistenceUnitSearch.resolvePersistenceUnitSupplier(deploymentUnit, searchName);
   String scopedPuName = pu.getScopedPersistenceUnitName();
   ServiceName puServiceName = getPuServiceName(scopedPuName);
   return new PersistenceUnitInjectionSource(
       puServiceName, deploymentUnit, EntityManagerFactory.class.getName(), pu);
 }
Ejemplo n.º 3
0
  private String getScopedPuName(
      final DeploymentUnit deploymentUnit, final AnnotationInstance annotation)
      throws DeploymentUnitProcessingException {

    final AnnotationValue puName = annotation.value("unitName");
    String scopedPuName;
    String searchName = null; // note:  a null searchName will match the first PU definition found

    if (puName != null) {
      searchName = puName.asString();
    }
    scopedPuName = PersistenceUnitSearch.resolvePersistenceUnitSupplier(deploymentUnit, searchName);
    if (null == scopedPuName) {
      throw new DeploymentUnitProcessingException(
          "Can't find a deployment unit named " + puName.asString() + " at " + deploymentUnit);
    }
    return scopedPuName;
  }
  private PersistenceUnitMetadata getPersistenceUnit(
      final DeploymentUnit deploymentUnit,
      final AnnotationInstance annotation,
      EEModuleClassDescription classDescription)
      throws DeploymentUnitProcessingException {

    final AnnotationValue puName = annotation.value("unitName");
    String searchName = null; // note:  a null searchName will match the first PU definition found

    if (puName != null) {
      searchName = puName.asString();
    }
    PersistenceUnitMetadata pu =
        PersistenceUnitSearch.resolvePersistenceUnitSupplier(deploymentUnit, searchName);
    if (null == pu) {
      classDescription.setInvalid(MESSAGES.persistenceUnitNotFound(searchName, deploymentUnit));
      return null;
    }
    return pu;
  }