use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.
the class AppClientContainer method completePreparation.
/**
* Gets the ACC ready so the main class can run.
* This can be followed, immediately or after some time, by either an
* invocation of {@link #launch(java.lang.String[]) or
* by the JVM invoking the client's main method (as would happen during
* a <code>java -jar theClient.jar</code> launch.
*
* @throws java.lang.Exception
*/
private void completePreparation(final Instrumentation inst) throws NamingException, IOException, InstantiationException, IllegalAccessException, InjectionException, ClassNotFoundException, SAXParseException, NoSuchMethodException, UserError {
if (state != State.INSTANTIATED) {
throw new IllegalStateException();
}
/*
* Attach any names defined in the app client. Validate the descriptor
* first, then use it to bind names in the app client. This order is
* important - for example, to set up message destination refs correctly.
*/
client.validateDescriptor();
final ApplicationClientDescriptor desc = client.getDescriptor(classLoader);
componentId = componentEnvManager.bindToComponentNamespace(desc);
/*
* Arrange for cleanup now instead of during launch() because in some use cases
* the JVM will invoke the client's main method itself and launch will
* be skipped.
*/
cleanup = Cleanup.arrangeForShutdownCleanup(logger, habitat, desc);
/*
* Allow pre-destroy handling to work on the main class during clean-up.
*/
cleanup.setInjectionManager(injectionManager, clientMainClassSetting.clientMainClass);
/*
* If this app client contains persistence unit refs, then initialize
* the PU handling.
*/
Collection<? extends PersistenceUnitDescriptor> referencedPUs = desc.findReferencedPUs();
if (referencedPUs != null && !referencedPUs.isEmpty()) {
ProviderContainerContractInfoImpl pcci = new ProviderContainerContractInfoImpl((ACCClassLoader) getClassLoader(), inst, client.getAnchorDir(), connectorRuntime);
for (PersistenceUnitDescriptor puDesc : referencedPUs) {
PersistenceUnitLoader pul = new PersistenceUnitLoader(puDesc, pcci);
desc.addEntityManagerFactory(puDesc.getName(), pul.getEMF());
}
cleanup.setEMFs(pcci.emfs());
}
cleanup.setConnectorRuntime(connectorRuntime);
prepareURLStreamHandling();
// This is required for us to enable interrupt jaxws service
// creation calls
System.setProperty("javax.xml.ws.spi.Provider", "com.sun.enterprise.webservice.spi.ProviderImpl");
// InjectionManager's injectClass will be called from getMainMethod
// Load any managed beans
ManagedBeanManager managedBeanManager = habitat.getService(ManagedBeanManager.class);
managedBeanManager.loadManagedBeans(desc.getApplication());
cleanup.setManagedBeanManager(managedBeanManager);
/**
* We don't really need the main method here but we do need the side-effects.
*/
getMainMethod();
state = State.PREPARED;
}
use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.
the class PersistenceUnitNode method startElement.
@Override
public void startElement(XMLElement element, Attributes attributes) {
if (PersistenceTagNames.PROPERTY.equals(element.getQName())) {
assert (attributes.getLength() == 2);
assert (attributes.getIndex(PersistenceTagNames.PROPERTY_NAME) != -1);
assert (attributes.getIndex(PersistenceTagNames.PROPERTY_VALUE) != -1);
PersistenceUnitDescriptor persistenceUnitDescriptor = (PersistenceUnitDescriptor) getDescriptor();
String propName = attributes.getValue(PersistenceTagNames.PROPERTY_NAME);
String propValue = (String) TranslatedConfigView.getTranslatedValue(attributes.getValue(PersistenceTagNames.PROPERTY_VALUE));
persistenceUnitDescriptor.addProperty(propName, propValue);
return;
}
super.startElement(element, attributes);
}
use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.
the class PUTransactionType method check.
public Result check(Descriptor descriptor) {
ApplicationClientDescriptor appClient = (ApplicationClientDescriptor) descriptor;
Result result = getInitializedResult();
addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
// default status is PASSED
result.setStatus(Result.PASSED);
for (PersistenceUnitsDescriptor pus : appClient.getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) {
for (PersistenceUnitDescriptor nextPU : pus.getPersistenceUnitDescriptors()) {
if ("JTA".equals(nextPU.getTransactionType())) {
result.failed(smh.getLocalString(getClass().getName() + ".puName", "Found a persistence unit by name [ {0} ] in persistence unit root [ {1} ] with JTA transaction type.", new Object[] { nextPU.getName(), nextPU.getPuRoot() }));
}
}
}
for (EntityManagerFactoryReferenceDescriptor emfRef : appClient.getEntityManagerFactoryReferenceDescriptors()) {
String unitName = emfRef.getUnitName();
PersistenceUnitDescriptor nextPU = appClient.findReferencedPU(unitName);
if (nextPU == null)
continue;
if ("JTA".equals(nextPU.getTransactionType())) {
result.failed(smh.getLocalString(getClass().getName() + ".puRefName", "Found a reference to a persistence unit by name [ {0} ] in persistence unit root [ {1} ] with JTA transaction type.", new Object[] { nextPU.getName(), nextPU.getPuRoot() }));
}
}
return result;
}
use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.
the class MappingFileNotFound method check.
public Result check(Descriptor descriptor) {
Result result = getInitializedResult();
result.setStatus(Result.PASSED);
addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
PersistenceUnitDescriptor pu = PersistenceUnitDescriptor.class.cast(descriptor);
List<String> mappingFileNames = new ArrayList<String>(pu.getMappingFiles());
for (String mappingFileName : mappingFileNames) {
if (getVerifierContext().getClassLoader().getResource(mappingFileName) == null) {
result.failed(smh.getLocalString(getClass().getName() + "failed", "Mapping file [ {0} ] specified in persistence.xml does not exist in the application.", new Object[] { mappingFileName }));
}
}
return result;
}
use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.
the class PersistenceUnitCheckMgrImpl method check.
@Override
protected void check(Descriptor descriptor) throws Exception {
PersistenceUnitDescriptor pu = PersistenceUnitDescriptor.class.cast(descriptor);
RootDeploymentDescriptor rootDD = pu.getParent().getParent();
if (rootDD.isApplication()) {
moduleName = Result.APP;
} else {
ModuleDescriptor mdesc = BundleDescriptor.class.cast(rootDD).getModuleDescriptor();
final ArchiveType moduleType = mdesc.getModuleType();
if (moduleType != null && moduleType.equals(DOLUtils.ejbType())) {
moduleName = Result.EJB;
} else if (moduleType != null && moduleType.equals(DOLUtils.warType())) {
moduleName = Result.WEB;
} else if (moduleType != null && moduleType.equals(DOLUtils.carType())) {
moduleName = Result.APPCLIENT;
} else {
throw new RuntimeException(// NOI18N
smh.getLocalString(// NOI18N
getClass().getName() + ".exception", // NOI18N
"Unknown module type : {0}", new Object[] { moduleType }));
}
}
super.check(descriptor);
}
Aggregations