use of org.glassfish.deployment.common.GenericAnnotationDetector in project Payara by payara.
the class RarDetector method handles.
/**
* {@inheritDoc}
*/
@Override
public boolean handles(ReadableArchive archive) throws IOException {
boolean handles = false;
try {
if (Util.getURIName(archive.getURI()).endsWith(RAR_EXTENSION)) {
return true;
}
handles = archive.exists(RA_XML);
} catch (IOException ioe) {
// ignore
}
if (!handles) {
GenericAnnotationDetector detector = new GenericAnnotationDetector(connectorAnnotations);
handles = detector.hasAnnotationInArchive(archive);
}
return handles;
}
use of org.glassfish.deployment.common.GenericAnnotationDetector in project Payara by payara.
the class EJBContainerProviderImpl method getRequestedEJBModuleOrLibrary.
/**
* @returns DeploymentElement if this file represents an EJB module or a library.
* Returns null if it's an EJB module which name is not present in the list of requested
* module names.
*/
private DeploymentElement getRequestedEJBModuleOrLibrary(File file, Map<String, Boolean> moduleNames) throws Exception {
DeploymentElement result = null;
String fileName = file.getName();
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("... Testing ... " + fileName);
}
ReadableArchive archive = null;
InputStream is = null;
try {
boolean isEJBModule = false;
String moduleName = DeploymentUtils.getDefaultEEName(fileName);
archive = archiveFactory.openArchive(file);
is = getDeploymentDescriptor(archive);
if (is != null) {
isEJBModule = true;
EjbDeploymentDescriptorFile eddf = new EjbDeploymentDescriptorFile();
eddf.setXMLValidation(false);
EjbBundleDescriptor bundleDesc = (EjbBundleDescriptor) eddf.read(is);
ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
moduleDesc.setArchiveUri(fileName);
moduleName = moduleDesc.getModuleName();
} else {
GenericAnnotationDetector detector = new GenericAnnotationDetector(ejbAnnotations);
isEJBModule = detector.hasAnnotationInArchive(archive);
}
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("... is EJB module: " + isEJBModule);
if (isEJBModule) {
_logger.fine("... is Requested EJB module [" + moduleName + "]: " + (moduleNames.isEmpty() || moduleNames.containsKey(moduleName)));
}
}
if (!isEJBModule || moduleNames.isEmpty()) {
result = new DeploymentElement(file, isEJBModule, moduleName);
} else if (moduleNames.containsKey(moduleName) && !moduleNames.get(moduleName)) {
// Is a requested EJB module and was not found already
result = new DeploymentElement(file, isEJBModule, moduleName);
moduleNames.put(moduleName, true);
}
return result;
} finally {
if (archive != null)
archive.close();
if (is != null)
is.close();
}
}
use of org.glassfish.deployment.common.GenericAnnotationDetector in project Payara by payara.
the class AppClientScanner method doProcess.
/**
* This scanner will scan the given main class for annotation processing.
* The archiveFile and libJarFiles correspond to classpath.
* @param archiveFile
* @param desc
* @param classLoader
*/
private void doProcess(ReadableArchive archive, ApplicationClientDescriptor desc, ClassLoader classLoader) throws IOException {
if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) {
AnnotationUtils.getLogger().fine("archiveFile is " + archive.getURI().toASCIIString());
AnnotationUtils.getLogger().fine("classLoader is " + classLoader);
}
// always add main class
String mainClassName = desc.getMainClassName();
addScanClassName(mainClassName);
// add callback handle if it exist in appclient-client.xml
String callbackHandler = desc.getCallbackHandler();
if (callbackHandler != null && !callbackHandler.trim().equals("")) {
addScanClassName(desc.getCallbackHandler());
}
GenericAnnotationDetector detector = new GenericAnnotationDetector(managedBeanAnnotations);
if (detector.hasAnnotationInArchive(archive)) {
if (archive instanceof FileArchive) {
addScanDirectory(new File(archive.getURI()));
} else if (archive instanceof InputJarArchive) {
/*
* This is during deployment, so use the faster code path using
* the File object.
*/
URI uriToAdd = archive.getURI();
addScanJar(scanJar(uriToAdd));
} else if (archive instanceof MultiReadableArchive) {
/*
* During app client launches, scan the developer's archive
* which is in slot #1, not the facade archive which is in
* slot #0. Also, use URIs instead of File objects because
* during Java Web Start launches we don't have access to
* File objects.
*/
addScanURI(scanURI(((MultiReadableArchive) archive).getURI(1)));
}
}
this.classLoader = classLoader;
// = archive;
this.archiveFile = null;
}
Aggregations