use of org.glassfish.hk2.classmodel.reflect.Types in project Payara by payara.
the class WeldUtils method getCDIEnablingAnnotations.
/**
* Get the names of any annotation types that are applied to beans, which should enable CDI
* processing even in the absence of a beans.xml descriptor.
*
* @param context The DeploymentContext
*
* @return An array of annotation type names; The array could be empty if none are found.
*/
public static String[] getCDIEnablingAnnotations(DeploymentContext context) {
List<String> result = new ArrayList<String>();
Types types = getTypes(context);
if (types != null) {
Iterator<Type> typesIter = types.getAllTypes().iterator();
while (typesIter.hasNext()) {
Type type = typesIter.next();
if (!(type instanceof AnnotationType)) {
Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
while (annotations.hasNext()) {
AnnotationModel am = annotations.next();
AnnotationType at = am.getType();
if (isCDIEnablingAnnotation(at)) {
if (!result.contains(at.getName())) {
result.add(at.getName());
}
}
}
}
}
}
return result.toArray(new String[result.size()]);
}
use of org.glassfish.hk2.classmodel.reflect.Types in project Payara by payara.
the class DOLUtils method getSniffersForModule.
/**
* get sniffer list for sub modules of an ear application
*/
private static Collection<Sniffer> getSniffersForModule(ServiceLocator habitat, ReadableArchive archive, ModuleDescriptor md, Application app) throws Exception {
ArchiveHandler handler = habitat.getService(ArchiveHandler.class, md.getModuleType().toString());
SnifferManager snifferManager = habitat.getService(SnifferManager.class);
List<URI> classPathURIs = handler.getClassPathURIs(archive);
classPathURIs.addAll(getLibraryJarURIs(app, archive));
Types types = archive.getParentArchive().getExtraData(Types.class);
DeployCommandParameters parameters = archive.getParentArchive().getArchiveMetaData(DeploymentProperties.COMMAND_PARAMS, DeployCommandParameters.class);
Properties appProps = archive.getParentArchive().getArchiveMetaData(DeploymentProperties.APP_PROPS, Properties.class);
ExtendedDeploymentContext context = new DeploymentContextImpl(null, archive, parameters, habitat.<ServerEnvironment>getService(ServerEnvironment.class));
if (appProps != null) {
context.getAppProps().putAll(appProps);
}
context.setArchiveHandler(handler);
context.addTransientAppMetaData(Types.class.getName(), types);
Collection<Sniffer> sniffers = snifferManager.getSniffers(context, classPathURIs, types);
context.postDeployClean(true);
String type = getTypeFromModuleType(md.getModuleType());
Sniffer mainSniffer = null;
for (Sniffer sniffer : sniffers) {
if (sniffer.getModuleType().equals(type)) {
mainSniffer = sniffer;
}
}
// to add the appropriate sniffer
if (mainSniffer == null) {
mainSniffer = snifferManager.getSniffer(type);
sniffers.add(mainSniffer);
}
String[] incompatibleTypes = mainSniffer.getIncompatibleSnifferTypes();
List<String> allIncompatTypes = addAdditionalIncompatTypes(mainSniffer, incompatibleTypes);
List<Sniffer> sniffersToRemove = new ArrayList<Sniffer>();
for (Sniffer sniffer : sniffers) {
for (String incompatType : allIncompatTypes) {
if (sniffer.getModuleType().equals(incompatType)) {
deplLogger.log(Level.WARNING, INCOMPATIBLE_TYPE, new Object[] { type, md.getArchiveUri(), incompatType });
sniffersToRemove.add(sniffer);
}
}
}
sniffers.removeAll(sniffersToRemove);
// store the module sniffer information so we don't need to
// recalculate them later
Hashtable sniffersTable = archive.getParentArchive().getExtraData(Hashtable.class);
if (sniffersTable == null) {
sniffersTable = new Hashtable<String, Collection<Sniffer>>();
archive.getParentArchive().setExtraData(Hashtable.class, sniffersTable);
}
sniffersTable.put(md.getArchiveUri(), sniffers);
return sniffers;
}
use of org.glassfish.hk2.classmodel.reflect.Types in project Payara by payara.
the class GetHabitatInfo method dumpTypes.
private void dumpTypes(StringBuilder sb) {
sb.append("\n\n*********** Sorted List of all Types in the Habitat **************\n\n");
List<ActiveDescriptor<?>> allDescriptors = serviceLocator.getDescriptors(BuilderHelper.allFilter());
HashSet<String> allTypes = new HashSet<String>();
for (ActiveDescriptor<?> aDescriptor : allDescriptors) {
allTypes.add(aDescriptor.getImplementation());
}
Iterator<String> it = allTypes.iterator();
if (// PP (paranoid programmer)
it == null)
return;
SortedSet<String> types = new TreeSet<String>();
while (it.hasNext()) {
types.add(it.next());
}
// now the types are sorted...
it = types.iterator();
for (int i = 1; it.hasNext(); i++) {
sb.append("Type-" + i + ": " + it.next() + "\n");
}
}
use of org.glassfish.hk2.classmodel.reflect.Types in project Payara by payara.
the class JavaEEScanner method initTypes.
protected void initTypes(File file) throws IOException {
ParsingContext context = new ParsingContext.Builder().build();
Parser cp = new Parser(context);
cp.parse(file, null);
try {
cp.awaitTermination();
} catch (InterruptedException e) {
throw new IOException(e);
}
types = cp.getContext().getTypes();
}
use of org.glassfish.hk2.classmodel.reflect.Types in project Payara by payara.
the class WeldUtils method getTypes.
private static Types getTypes(DeploymentContext context) {
String metadataKey = Types.class.getName();
Types types = (Types) context.getTransientAppMetadata().get(metadataKey);
while (types == null) {
context = ((ExtendedDeploymentContext) context).getParentContext();
if (context != null) {
types = (Types) context.getTransientAppMetadata().get(metadataKey);
} else {
break;
}
}
return types;
}
Aggregations