public void closeMQMBeanServerConnection() throws ConnectorRuntimeException { try { if (connector != null) { connector.close(); } } catch (IOException e) { ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } } }
public void createActiveResourceAdapterForEmbeddedRar(String rarModuleName) throws ConnectorRuntimeException { ConnectorDescriptor cdesc = loadConnectorDescriptorForEmbeddedRAR(rarModuleName); String appName = ConnectorAdminServiceUtils.getApplicationName(rarModuleName); String rarFileName = ConnectorAdminServiceUtils .getConnectorModuleName(rarModuleName) + ".rar"; String loc = getResourcesUtil().getApplicationDeployLocation(appName); loc = loc + File.separator + FileUtils.makeFriendlyFilename(rarFileName); String path = null; try { URI uri = new URI(loc); path = uri.getPath(); } catch (URISyntaxException use) { ConnectorRuntimeException cre = new ConnectorRuntimeException("Invalid path [ "+use.getMessage()+" ]"); cre.setStackTrace(use.getStackTrace()); _logger.log(Level.WARNING, cre.getMessage(), cre); throw cre; } // start RA _runtime.createActiveResourceAdapter(cdesc, rarModuleName, path); }
public ConnectorArchivist getConnectorArchvist() throws ConnectorRuntimeException { try{ ArchivistFactory archivistFactory = habitat.getComponent(ArchivistFactory.class); return (ConnectorArchivist)archivistFactory.getArchivist(XModuleType.RAR); }catch(IOException ioe){ _logger.log(Level.WARNING, "unable to get Connector Archivist : ", ioe); ConnectorRuntimeException cre = new ConnectorRuntimeException(ioe.getMessage()); cre.setStackTrace(ioe.getStackTrace()); throw cre; } }
public static String getResourceType(Resource resource) throws ConnectorRuntimeException{ if(resource instanceof JdbcResource){ return ConnectorConstants.RES_TYPE_JDBC; } else if(resource instanceof JdbcConnectionPool){ return ConnectorConstants.RES_TYPE_JCP; } else if (resource instanceof ConnectorResource){ return ConnectorConstants.RES_TYPE_CR; } else if (resource instanceof ConnectorConnectionPool){ return ConnectorConstants.RES_TYPE_CCP; } else if (resource instanceof MailResource){ return ConnectorConstants.RES_TYPE_MAIL; } else if( resource instanceof ExternalJndiResource){ return ConnectorConstants.RES_TYPE_EXTERNAL_JNDI; } else if (resource instanceof CustomResource){ return ConnectorConstants.RES_TYPE_CUSTOM; } else if (resource instanceof AdminObjectResource){ return ConnectorConstants.RES_TYPE_AOR; } else if (resource instanceof ResourceAdapterConfig){ return ConnectorConstants.RES_TYPE_RAC; } else if (resource instanceof WorkSecurityMap){ return ConnectorConstants.RES_TYPE_CWSM; } else { throw new ConnectorRuntimeException("Unknown resource type [ "+resource+" ]"); } }
/** * stop the active resource adapter (runtime) * @param raName resource-adapter name */ public void stopActiveResourceAdapter(String raName) { if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Stopping RA : ", raName); } try { destroyActiveResourceAdapter(raName); } catch (ConnectorRuntimeException cre) { Object params[] = new Object[]{raName, cre.getMessage()}; _logger.log(Level.WARNING, "unable.to.stop.ra", params); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "unable to stop resource adapter [ " + raName + " ]", cre); } } }
/** * check whether the provided location is valid * @param f location where the .rar is present * @throws ConnectorRuntimeException */ private static void validateRARLocation(File f) throws ConnectorRuntimeException { if (!f.exists()) { String i18nMsg = localStrings.getString( "rar_archive_not_found", f); throw new ConnectorRuntimeException(i18nMsg); } }
/** * given the location of .rar (archive / exploded dir), the specified class will be loaded * @param pathToDeployableUnit location of .rar (archive / exploded dir) * @param beanClassName class that has to be loaded * @return loaded class * @throws ConnectorRuntimeException when unable to load the class */ private static Class loadClass(String pathToDeployableUnit, String beanClassName) throws ConnectorRuntimeException { Class cls = null; ClassLoader cl = getClassLoader(pathToDeployableUnit); try { //Only if RA is a 1.5 RAR, we need to get RA JavaBean properties, else //return an empty map. if (beanClassName != null && beanClassName.trim().length() != 0) { cls = cl.loadClass(beanClassName); } return cls; } catch (ClassNotFoundException e) { _logger.info(e.getMessage()); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Unable to find class while trying to read connector" + "descriptor to get resource-adapter properties", e); } ConnectorRuntimeException cre = new ConnectorRuntimeException("unable to find class : " + beanClassName); cre.setStackTrace(e.getStackTrace()); throw cre; } }
/** * Get a wrapper datasource specified by the jdbcjndi name * This API is intended to be used in the DAS. The motivation for having this * API is to provide the CMP backend/ JPA-Java2DB a means of acquiring a connection during * the codegen phase. If a user is trying to deploy an JPA-Java2DB app on a remote server, * without this API, a resource reference has to be present both in the DAS * and the server instance. This makes the deployment more complex for the * user since a resource needs to be forcibly created in the DAS Too. * This API will mitigate this need. * * @param jndiName jndi name of the resource * @return DataSource representing the resource. */ private Object lookupDataSourceInDAS(ResourceInfo resourceInfo) { try{ return connectorResourceAdmService.lookupDataSourceInDAS(resourceInfo); }catch(ConnectorRuntimeException cre){ throw new RuntimeException(cre.getMessage(), cre); } }
private DelegatingClassLoader.ClassFinder getLibrariesClassLoader(final List<URI> appLibs) throws MalformedURLException, ConnectorRuntimeException { try { return (DelegatingClassLoader.ClassFinder) AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { return clh.getAppLibClassFinder(appLibs); } }); } catch (PrivilegedActionException e) { _logger.log(Level.SEVERE, "error.creating.libraries.classloader", e); ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } }
/** * Instantiates the class */ private Object instantiate(Class loadedClass) throws ConnectorRuntimeException { try { return loadedClass.newInstance(); } catch(InstantiationException ie) { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "rardeployment.class_instantiation_error", loadedClass.getName()); } throw new ConnectorRuntimeException( "Could not instantiate class : " + loadedClass.getName()); } catch (IllegalAccessException ie) { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "rardeployment.illegalaccess_error", loadedClass.getName()); } throw new ConnectorRuntimeException( "Couldnot access class : "+loadedClass.getName()); } } }
+ "descriptor to get resource-adapter properties", ioe); ConnectorRuntimeException cre = new ConnectorRuntimeException( "unable to read connector descriptor from : " + file); cre.setStackTrace(ioe.getStackTrace()); throw cre;
public Collection<ConnectorClassFinder> getSystemRARClassLoaders() { try { return getConnectorsClassLoaderUtil().getSystemRARClassLoaders(); } catch (ConnectorRuntimeException cre) { throw new RuntimeException(cre.getMessage(), cre); } }
public PoolType getPoolType(PoolInfo poolInfo) throws ConnectorRuntimeException { ConnectorConnectionPool ccp; try { ccp = getConnectorConnectionPool(poolInfo); } catch (NamingException e) { ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } return getPoolType(ccp); }
/** * Destroys/deletes the Active resource adapter object from the connector * container. Active resource adapter abstracts the rar deployed. * * @param moduleName Name of the rarModule to destroy/delete * @throws ConnectorRuntimeException if the deletion fails */ private void destroyActiveResourceAdapter(String moduleName) throws ConnectorRuntimeException { ResourcesUtil resutil = ResourcesUtil.createInstance(); if (resutil == null) { ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to get ResourcesUtil object"); _logger.log(Level.SEVERE, "rardeployment.resourcesutil_get_failure", moduleName); _logger.log(Level.SEVERE, "", cre); throw cre; } if (!stopAndRemoveActiveResourceAdapter(moduleName)) { ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to remove Active Resource Adapter"); _logger.log(Level.SEVERE, "rardeployment.ra_removal_registry_failure", moduleName); _logger.log(Level.SEVERE, "", cre); throw cre; } unbindConnectorDescriptor(moduleName); }
public Object create(Context ic) throws NamingException { //this is a per-lookup object and once we have the descriptor, //we remove the proxy and bind the descriptor with same jndi-name //hence block synchronization is fine as it blocks only callers //of this particular connector descriptor and also only for first time (initialization) synchronized(this){ if(desc == null){ try { desc = getConnectorRuntime().getConnectorDescriptor(rarName); ic.rebind(jndiName, desc); } catch (ConnectorRuntimeException e) { NamingException ne = new NamingException(e.getMessage()); ne.initCause(e); throw ne; } } } return desc; } }
private void handleException(Exception ex, EnvironmentProperty prop, Object bean) throws ConnectorRuntimeException { logger.log(Level.WARNING, "rardeployment.exception_on_invoke_setter", new Object[]{prop.getName(), getFilteredPropValue(prop), ex.getMessage()}); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Exception while trying to set " + prop.getName() + " and value " + getFilteredPropValue(prop), ex + " on an instance of " + bean.getClass()); } throw(ConnectorRuntimeException) (new ConnectorRuntimeException(ex.getMessage()).initCause(ex)); }
/** * gets the adminObjectInterfaceNames pertaining to a rar. * * @param desc ConnectorDescriptor pertaining to rar. * @return Array of AdminObjectInterface names as Strings * @throws ConnectorRuntimeException if parsing fails */ public String[] getAdminObjectInterfaceNames(ConnectorDescriptor desc) throws ConnectorRuntimeException { if (desc == null) { throw new ConnectorRuntimeException("Invalid arguments"); } Set adminObjectSet = desc.getAdminObjects(); if (adminObjectSet == null || adminObjectSet.size() == 0) { return null; } String[] adminObjectInterfaceNames = new String[adminObjectSet.size()]; Iterator it = adminObjectSet.iterator(); AdminObject aor = null; for (int i = 0; it.hasNext(); ++i) { aor = (AdminObject) it.next(); adminObjectInterfaceNames[i] = aor.getAdminObjectInterface(); } return adminObjectInterfaceNames; }
_logger.log(Level.WARNING, "jdbc.pool_not_reachable", re.getMessage()); String l10nMsg = localStrings.getString("pingpool.cannot_obtain_mcf", poolInfo); ResourceException e = new ResourceException(l10nMsg);
/** * create an empty connection pool * * @param poolInfo pool to be created * @param pt type of pool * @throws ConnectorRuntimeException */ private void createAndAddPool(PoolInfo poolInfo, PoolType pt, Hashtable env) throws ConnectorRuntimeException { PoolManager poolMgr = _runtime.getPoolManager(); try { poolMgr.createEmptyConnectionPool(poolInfo, pt, env); } catch (PoolingException pe) { String i18nMsg = localStrings.getString("ccp_adm.failed_to_create_pool_object"); ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg); cre.initCause(pe); throw cre; } }
/** * {@inheritDoc} */ public boolean hasAdminObject(ConnectorDescriptor desc, String intfName, String className) throws ConnectorRuntimeException { if (desc == null || intfName == null || className == null) { throw new ConnectorRuntimeException("Invalid arguments"); } Set adminObjectSet = desc.getAdminObjects(); if (adminObjectSet == null || adminObjectSet.size() == 0) { return false; } Iterator it = adminObjectSet.iterator(); AdminObject aor = null; for (int i = 0; it.hasNext(); ++i) { aor = (AdminObject) it.next(); if(aor.getAdminObjectInterface().equals(intfName) && aor.getAdminObjectClass().equals(className)){ return true; } } return false; }