/** * {@inheritDoc} */ public Activation getActivation(String uniqueId) throws NotFoundException { if (uniqueId == null) throw new IllegalArgumentException("UniqueId is null"); if (uniqueId.trim().equals("")) throw new IllegalArgumentException("UniqueId is empty"); if (!activations.containsKey(uniqueId)) throw new NotFoundException(bundle.keyNotRegistered(uniqueId)); return activations.get(uniqueId); }
@Override protected void registerResourceAdapterToMDR(URL url, File root, Connector cmd, Activation activation) throws org.jboss.jca.core.spi.mdr.AlreadyExistsException { ((RAConfiguration) getConfiguration()).getMetadataRepository(). registerResourceAdapter(url.toExternalForm(), root, cmd, activation); }
/** * {@inheritDoc} */ public void registerResourceAdapter(String uniqueId, File root, Connector md, Activation a) throws AlreadyExistsException { if (uniqueId == null) throw new IllegalArgumentException("UniqueId is null"); if (uniqueId.trim().equals("")) throw new IllegalArgumentException("UniqueId is empty"); if (root == null) throw new IllegalArgumentException("Root is null"); if (md == null) throw new IllegalArgumentException("Connector is null"); // The Activation metadata object can be null if (raTemplates.containsKey(uniqueId)) throw new AlreadyExistsException(bundle.keyNotRegistered(uniqueId)); raTemplates.put(uniqueId, md); raRoots.put(uniqueId, root); activations.put(uniqueId, a); }
@Override protected javax.resource.spi.ResourceAdapter createRa(String uniqueId, ClassLoader cl) throws NotFoundException, Exception, DeployException { Connector md = mdr.getResourceAdapter(uniqueId); ResourceAdapter ra = md.getResourceadapter(); List<? extends ConfigProperty> l = new ArrayList<ConfigProperty>(); javax.resource.spi.ResourceAdapter rar = (javax.resource.spi.ResourceAdapter)initAndInject(ra.getResourceadapterClass(), l, cl); return rar; }
/** * Get the bean validation groups * @param id The MDR identifier * @return The groups; <code>null</code> if none were found */ private Set<String> getBeanValidationGroups(String id) { if (id == null || id.equals("")) return null; try { Activation a = mdr.getActivation(id); if (a != null && a.getBeanValidationGroups() != null && a.getBeanValidationGroups().size() > 0) { Set<String> groups = new HashSet<String>(); for (String group : a.getBeanValidationGroups()) { groups.add(group); } return groups; } } catch (Throwable t) { log.debugf(t, "Exception while loading ironjacamar.xml: %s", id); } return null; }
@Override public String[] bindAdminObject(URL url, String deployment, Object ao) throws Throwable { JndiStrategy js = ((RAConfiguration) getConfiguration()).getJndiStrategy().clone(); String[] result = js.bindAdminObjects(deployment, new Object[]{ao}); ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url.toExternalForm(), ao.getClass().getName(), result[0]); log.infof("Bound admin object under: %s", result[0]); return result; }
/** * Stop */ @Override public void stop() { super.stop(); if (mdr != null) { try { mdr.unregisterResourceAdapter(deployment.toExternalForm()); } catch (Throwable t) { log.warn("Exception during unregistering deployment in the metadata repository", t); } } }
/** * Is the resource adapter a 1.6 archive * @param id The MDR identifier * @return True if 1.6; otherwise false */ private boolean is16(String id) { if (id == null || id.equals("")) return false; try { Connector raXml = mdr.getResourceAdapter(id); if (raXml != null) { return (raXml.getVersion() == Version.V_16 || raXml.getVersion() == Version.V_17); } } catch (Throwable t) { log.debugf(t, "Exception while loading ra.xml: %s", id); } return false; }
/** * {@inheritDoc} */ public File getRoot(String uniqueId) throws NotFoundException { if (uniqueId == null) throw new IllegalArgumentException("UniqueId is null"); if (uniqueId.trim().equals("")) throw new IllegalArgumentException("UniqueId is empty"); if (!raRoots.containsKey(uniqueId)) throw new NotFoundException(bundle.keyNotRegistered(uniqueId)); return raRoots.get(uniqueId); }
@Override public String[] bindAdminObject(URL url, String deployment, Object ao, String jndi) throws Throwable { JndiStrategy js = ((RAConfiguration) getConfiguration()).getJndiStrategy().clone(); String[] result = js.bindAdminObjects(deployment, new Object[]{ao}, new String[]{jndi}); ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url.toExternalForm(), ao.getClass().getName(), jndi); log.infof("Bound admin object under: %s", jndi); return result; }
/** * Stop */ @Override public void stop() { super.stop(); if (mdr != null) { try { mdr.unregisterResourceAdapter(deployment.toExternalForm()); } catch (Throwable t) { log.warn("Exception during unregistering deployment in the metadata repository", t); } } } }
/** * Get the product name for the resource adapter * @param id The MDR identifier * @return The value */ private String getProductName(String id) { if (id == null || id.equals("")) return ""; try { Connector raXml = mdr.getResourceAdapter(id); if (raXml != null && !XsdString.isNull(raXml.getEisType())) { return raXml.getEisType().getValue(); } } catch (Throwable t) { log.debugf(t, "Exception while loading ra.xml: %s", id); } return ""; }
/** * {@inheritDoc} */ public void unregisterResourceAdapter(String uniqueId) throws NotFoundException { if (uniqueId == null) throw new IllegalArgumentException("UniqueId is null"); if (uniqueId.trim().equals("")) throw new IllegalArgumentException("UniqueId is empty"); if (!raTemplates.containsKey(uniqueId)) throw new NotFoundException(bundle.keyNotRegistered(uniqueId)); raTemplates.remove(uniqueId); raRoots.remove(uniqueId); activations.remove(uniqueId); }
@Override public String[] bindConnectionFactory(URL url, String deployment, Object cf) throws Throwable { JndiStrategy js = ((RAConfiguration) getConfiguration()).getJndiStrategy().clone(); String[] result = js.bindConnectionFactories(deployment, new Object[]{cf}); ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url.toExternalForm(), cf.getClass().getName(), result[0]); log.infof("Bound connection factory under: %s", result[0]); return result; }
/** * Get the product version for the resource adapter * @param id The MDR identifier * @return The value */ private String getProductVersion(String id) { if (id == null || id.equals("")) return ""; try { Connector raXml = mdr.getResourceAdapter(id); if (raXml != null) { if (!XsdString.isNull(raXml.getResourceadapterVersion())) return raXml.getResourceadapterVersion().getValue(); } } catch (Throwable t) { log.debugf(t, "Exception while loading ra.xml: %s", id); } return ""; }
/** * {@inheritDoc} */ public Map<String, List<String>> getJndiMappings(String uniqueId) throws NotFoundException { if (uniqueId == null) throw new IllegalArgumentException("UniqueId is null"); if (uniqueId.trim().equals("")) throw new IllegalArgumentException("UniqueId is empty"); if (!jndiMappings.containsKey(uniqueId)) throw new NotFoundException(bundle.keyNotRegistered(uniqueId)); Map<String, List<String>> mappings = jndiMappings.get(uniqueId); if (mappings == null) return Collections.unmodifiableMap(new HashMap<String, List<String>>(0)); return Collections.unmodifiableMap(mappings); }
@Override public String[] bindConnectionFactory(URL url, String deployment, Object cf, String jndi) throws Throwable { JndiStrategy js = ((RAConfiguration) getConfiguration()).getJndiStrategy().clone(); String[] result = js.bindConnectionFactories(deployment, new Object[]{cf}, new String[]{jndi}); ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url.toExternalForm(), cf.getClass().getName(), jndi); log.infof("Bound connection factory under: %s", jndi); return result; }
@Override protected ManagedConnectionFactory createMcf(XaDataSource ds, String uniqueId, ClassLoader cl) throws NotFoundException, Exception, DeployException { Merger merger = new Merger(); Connector md = mdr.getResourceAdapter(uniqueId); md = merger.mergeConnectorAndDs(ds, md); // Get the first connection definition as there is only one ResourceAdapter ra = md.getResourceadapter(); List<ConnectionDefinition> cds = ra.getOutboundResourceadapter().getConnectionDefinitions(); ConnectionDefinition cd = cds.get(0); // ManagedConnectionFactory ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass() .getValue(), cd.getConfigProperties(), cl); initAndInjectClassLoaderPlugin(mcf, ds); return mcf; }
/** * {@inheritDoc} */ public Connector getResourceAdapter(String uniqueId) throws NotFoundException { if (uniqueId == null) throw new IllegalArgumentException("UniqueId is null"); if (uniqueId.trim().equals("")) throw new IllegalArgumentException("UniqueId is empty"); if (!raTemplates.containsKey(uniqueId)) throw new NotFoundException(bundle.keyNotRegistered(uniqueId)); Connector md = raTemplates.get(uniqueId); // Always return a copy as the caller may make changes to it return (Connector)md.copy(); }
@Override protected ManagedConnectionFactory createMcf(DataSource ds, String uniqueId, ClassLoader cl) throws NotFoundException, Exception, DeployException { Merger merger = new Merger(); Connector md = mdr.getResourceAdapter(uniqueId); md = merger.mergeConnectorAndDs(ds, md); // Get the first connection definition as there is only one ResourceAdapter ra = md.getResourceadapter(); List<ConnectionDefinition> cds = ra.getOutboundResourceadapter().getConnectionDefinitions(); ConnectionDefinition cd = cds.get(0); // ManagedConnectionFactory ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cd.getManagedConnectionFactoryClass() .getValue(), cd.getConfigProperties(), cl); initAndInjectClassLoaderPlugin(mcf, ds); return mcf; }