use of org.glassfish.resources.config.ExternalJndiResource in project Payara by payara.
the class ExternalJndiResourceDeployer method toExternalJndiJavaEEResource.
/**
* Returns a new instance of j2ee external jndi resource from the given
* config bean.
* <p/>
* This method gets called from the external resource
* deployer to convert external-jndi-resource config bean into
* external-jndi j2ee resource.
*
* @param rbean external-jndi-resource config bean
* @param resourceInfo
* @return a new instance of j2ee external jndi resource
*/
public static org.glassfish.resources.api.JavaEEResource toExternalJndiJavaEEResource(ExternalJndiResource rbean, ResourceInfo resourceInfo) {
org.glassfish.resources.beans.ExternalJndiResource jr = new org.glassfish.resources.beans.ExternalJndiResource(resourceInfo);
// jr.setDescription( rbean.getDescription() ); // FIXME: getting error
// sets the enable flag
jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
// sets the jndi look up name
jr.setJndiLookupName(rbean.getJndiLookupName());
// sets the resource type
jr.setResType(rbean.getResType());
// sets the factory class name
jr.setFactoryClass(rbean.getFactoryClass());
// sets the properties
List<Property> properties = rbean.getProperty();
if (properties != null) {
for (Property property : properties) {
ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
jr.addProperty(rp);
}
}
return jr;
}
use of org.glassfish.resources.config.ExternalJndiResource in project Payara by payara.
the class LegacyJmsRecoveryResourceHandler method loadXAResourcesAndItsConnections.
public void loadXAResourcesAndItsConnections(List xaresList, List connList) {
try {
Collection<ExternalJndiResource> jndiResources = resources.getResources(ExternalJndiResource.class);
InitialContext ic = new InitialContext();
for (ExternalJndiResource jndiResource : jndiResources) {
if (isEnabled(jndiResource)) {
try {
ic.lookup(jndiResource.getJndiName());
if (!isJMSConnectionFactory(jndiResource)) {
continue;
}
String jndiName = jndiResource.getJndiName();
Object jmsXAConnectionFactory;
boolean isQueue;
Object objext = ic.lookup(jndiName);
if (!instanceOf(objext, "ConnectionFactory")) {
throw new NamingException(localStrings.getLocalString("recovery.unexpected_objtype", "Unexpected object type " + objext.getClass().getName() + " for " + jndiName, new Object[] { objext.getClass().getName(), jndiName }));
}
jmsXAConnectionFactory = wrapJMSConnectionFactoryObject(objext);
isQueue = instanceOf(objext, "QueueConnectionFactory");
recoverJMSXAResource(xaresList, connList, jmsXAConnectionFactory, isQueue);
// } catch (NamingException ne) {
// If you are here then it is most probably an embedded RAR resource
// So we need to explicitly load that rar and create the resources
} catch (Exception ex) {
_logger.log(Level.SEVERE, JMSLoggerInfo.LOAD_RESOURCES_ERROR, new Object[] { jndiResource.getJndiName() });
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ex.toString(), ex);
}
}
}
}
} catch (NamingException ne) {
_logger.log(Level.SEVERE, JMSLoggerInfo.LOAD_RESOURCES_ERROR, new Object[] { ne.getMessage() });
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ne.toString(), ne);
}
}
}
Aggregations