use of org.glassfish.hk2.external.org.objectweb.asm.Type in project Payara by payara.
the class ActiveJmsResourceAdapter method updateMDBRuntimeInfo.
/**
* This is the most appropriate time (??) to update the runtime
* info of a 1.3 MDB into 1.4 MDB. <p>
*
* Assumptions : <p>
* 0. Assume it is a 1.3 MDB if no RA mid is specified.
* 1. Use the default system JMS resource adapter. <p>
* 2. The ActivationSpec of the default JMS RA will provide the
* setDestination, setDestinationType, setSubscriptionName methods.
* 3. The jndi-name of the 1.3 MDB is the value for the Destination
* property for the ActivationSpec.
* 4. The ActivationSpec provides setter methods for the properties
* defined in the CF that corresponds to the mdb-connection-factory
* JNDI name.
*
* @param descriptor_
* @param poolDescriptor
* @throws com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
*/
@Override
public void updateMDBRuntimeInfo(EjbMessageBeanDescriptor descriptor_, BeanPoolDescriptor poolDescriptor) throws ConnectorRuntimeException {
String jndiName = descriptor_.getJndiName();
if (jndiName == null || "".equals(jndiName)) {
MessageDestinationDescriptor destDescriptor = descriptor_.getMessageDestination();
if (destDescriptor != null)
jndiName = destDescriptor.getJndiName();
}
String destinationLookup = descriptor_.getActivationConfigValue("destinationLookup");
String destinationProp = descriptor_.getActivationConfigValue("destination");
if (destinationLookup == null && destinationProp == null && (jndiName == null || "".equals(jndiName))) {
if (_logger.isLoggable(Level.SEVERE)) {
_logger.log(Level.SEVERE, JMSLoggerInfo.ERROR_IN_DD);
}
String msg = sm.getString("ajra.error_in_dd");
throw new ConnectorRuntimeException(msg);
}
String resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
descriptor_.setResourceAdapterMid(resourceAdapterMid);
if (destinationLookup == null && destinationProp == null) {
String appName = descriptor_.getApplication().getAppName();
String moduleName = ConnectorsUtil.getModuleName(descriptor_);
JMSDestinationDefinitionDescriptor destination = getJMSDestinationFromDescriptor(jndiName, descriptor_);
String destName = null;
if (isValidDestination(destination)) {
destName = destination.getDestinationName();
} else {
destName = getPhysicalDestinationFromConfiguration(jndiName, appName, moduleName);
}
// 1.3 jndi-name ==> 1.4 setDestination
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION, destName, null));
// XXX Do we really need this???
if (descriptor_.getDestinationType() != null && !"".equals(descriptor_.getDestinationType())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, descriptor_.getDestinationType(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { descriptor_.getDestinationType(), jndiName, descriptor_.getName() });
}
} else if (isValidDestination(destination) && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(destination.getResourceAdapter())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, destination.getInterfaceName(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { destination.getInterfaceName(), destination.getName(), descriptor_.getName() });
}
} else {
/*
* If destination type is not provided by the MDB component
* [typically used by EJB3.0 styled MDBs which create MDBs without
* a destination type activation-config property] and the MDB is for
* the default JMS RA, attempt to infer the destination type by trying
* to find out if there has been any JMS destination resource already
* defined for default JMS RA. This is a best attempt guess and if there
* are no JMS destination resources/admin-objects defined, AS would pass
* the properties as defined by the MDB.
*/
try {
AdminObjectResource aor = (AdminObjectResource) ResourcesUtil.createInstance().getResource(jndiName, appName, moduleName, AdminObjectResource.class);
if (aor != null && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(aor.getResAdapter())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, aor.getResType(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { aor.getResType(), aor.getJndiName(), descriptor_.getName() });
}
}
} catch (Exception e) {
}
}
}
// 1.3 durable-subscription-name == 1.4 setSubscriptionName
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(SUBSCRIPTION_NAME, descriptor_.getDurableSubscriptionName(), null));
String mdbCF = null;
try {
mdbCF = descriptor_.getMdbConnectionFactoryJndiName();
} catch (NullPointerException ne) {
// Dont process connection factory.
}
if (mdbCF != null && !"".equals(mdbCF)) {
setValuesFromConfiguration(mdbCF, descriptor_);
}
if (poolDescriptor != null) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MAXPOOLSIZE, "" + poolDescriptor.getMaxPoolSize(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MINPOOLSIZE, "" + poolDescriptor.getSteadyPoolSize(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZECOUNT, "" + poolDescriptor.getPoolResizeQuantity(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZETIMEOUT, "" + poolDescriptor.getPoolIdleTimeoutInSeconds(), "", "java.lang.Integer"));
/**
* The runtime activation config property holds all the
* vendor specific properties, unfortunately the vendor
* specific way of configuring exception count and the
* standard way of configuring redelivery attempts is
* through the same property REDELIVERYCOUNT . So, we first
* check if the user (MDB assember) has configured a value
* if not we set the one from mdb-container props
* We have to check for both cases here because it has been
* documented as "endpointExceptionRedeliveryAttempts" but
* used in the code as "EndpointExceptionRedeliveryAttempts"
*/
if ((descriptor_.getActivationConfigValue(REDELIVERYCOUNT) == null) && (descriptor_.getActivationConfigValue(LOWERCASE_REDELIVERYCOUNT) == null)) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(REDELIVERYCOUNT, "" + MdbContainerProps.getMaxRuntimeExceptions(), "", "java.lang.Integer"));
}
}
// Set SE/EE specific MQ-RA ActivationSpec properties
try {
boolean clustered = isClustered();
if (_logger.isLoggable(Level.FINE))
logFine("Are we in a Clustered contained ? " + clustered);
if (clustered)
setClusterActivationSpecProperties(descriptor_);
} catch (Exception e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) crex.initCause(e);
}
}
use of org.glassfish.hk2.external.org.objectweb.asm.Type in project Payara by payara.
the class DOLUtils method getModuleType.
/**
* Utility method to retrieve a {@link ArchiveType} from a stringified module type.
* Since {@link ArchiveType} is an extensible abstraction and implementations are plugged in via HK2 service
* registry, this method returns null if HK2 service registry is not setup.
*
* If null is passed to this method, it returns null instead of returning an arbitrary ArchiveType or throwing
* an exception.
*
* @param moduleType String equivalent of the module type being looked up. null is allowed.
* @return the corresponding ArchiveType, null if no such module type exists or HK2 Service registry is not set up
*/
public static ArchiveType getModuleType(String moduleType) {
if (moduleType == null) {
return null;
}
final ServiceLocator services = Globals.getDefaultHabitat();
ArchiveType result = null;
// This method is called without HK2 being setup when dol unit tests are run, so protect against NPE.
if (services != null) {
result = services.getService(ArchiveType.class, moduleType);
}
return result;
}
use of org.glassfish.hk2.external.org.objectweb.asm.Type 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.external.org.objectweb.asm.Type in project Payara by payara.
the class Archivist method processAnnotations.
/**
* Process annotations in a bundle descriptor, the annoation processing
* is dependent on the type of descriptor being passed.
*/
protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDesc, ModuleScanner scanner, ReadableArchive archive) throws AnnotationProcessorException, IOException {
if (scanner == null) {
return null;
}
AnnotatedElementHandler aeHandler = AnnotatedElementHandlerFactory.createAnnotatedElementHandler(bundleDesc);
if (aeHandler == null) {
return null;
}
Parser parser = null;
if (archive.getParentArchive() != null) {
parser = archive.getParentArchive().getExtraData(Parser.class);
} else {
parser = archive.getExtraData(Parser.class);
}
scanner.process(archive, bundleDesc, classLoader, parser);
if (!scanner.getElements().isEmpty()) {
if (((BundleDescriptor) bundleDesc).isDDWithNoAnnotationAllowed()) {
// if we come into this block, it means an old version
// of deployment descriptor has annotation which is not correct
// throw exception in this case
String ddName = getStandardDDFile().getDeploymentDescriptorPath();
String explodedArchiveName = new File(archive.getURI()).getName();
String archiveName = FileUtils.revertFriendlyFilenameExtension(explodedArchiveName);
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.oldDDwithAnnotation", "{0} in archive {1} is of version {2}, which cannot support annotations in an application. Please upgrade the deployment descriptor to be a version supported by Java EE 5.0 (or later).", new Object[] { ddName, archiveName, bundleDesc.getSpecVersion() }));
}
boolean isFullAttribute = false;
if (bundleDesc instanceof BundleDescriptor) {
isFullAttribute = ((BundleDescriptor) bundleDesc).isFullAttribute();
}
AnnotationProcessor ap = annotationFactory.getAnnotationProcessor(isFullAttribute);
ProcessingContext ctx = ap.createContext();
ctx.setArchive(archive);
if (annotationErrorHandler != null) {
ctx.setErrorHandler(annotationErrorHandler);
}
ctx.setProcessingInput(scanner);
ctx.pushHandler(aeHandler);
// Make sure there is a classloader available on the descriptor
// during annotation processing.
ClassLoader originalBundleClassLoader = null;
try {
originalBundleClassLoader = bundleDesc.getClassLoader();
} catch (Exception e) {
// getClassLoader can throw exception if not available
}
// Only set classloader if it's not already set.
if (originalBundleClassLoader == null) {
bundleDesc.setClassLoader(classLoader);
}
try {
return ap.process(ctx);
} finally {
if (originalBundleClassLoader == null) {
bundleDesc.setClassLoader(null);
}
}
}
return null;
}
use of org.glassfish.hk2.external.org.objectweb.asm.Type in project Payara by payara.
the class CompositeUtil method createConstructor.
/**
* This method creates the default constructor for the class. Default values are set for any @Attribute defined with
* a defaultValue.
*/
private void createConstructor(ClassWriter cw, String className, Map<String, Map<String, Object>> properties) {
MethodVisitor method = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
method.visitCode();
method.visitVarInsn(ALOAD, 0);
method.visitMethodInsn(INVOKESPECIAL, "org/glassfish/admin/rest/composite/RestModelImpl", "<init>", "()V");
for (Map.Entry<String, Map<String, Object>> property : properties.entrySet()) {
String fieldName = property.getKey();
String defaultValue = (String) property.getValue().get("defaultValue");
if (defaultValue != null && !defaultValue.isEmpty()) {
setDefaultValue(method, className, fieldName, (Class<?>) property.getValue().get("type"), defaultValue);
}
}
method.visitInsn(RETURN);
method.visitMaxs(1, 1);
method.visitEnd();
}
Aggregations