/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources)this.resource).findResourceLinks(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for resource " + resourceLinks[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Remove any resource link reference with the specified name. * * @param resourceLinkName Name of the resource link reference to remove */ public void removeResourceLink(String resourceLinkName) { resourceLinkName = ObjectName.unquote(resourceLinkName); NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { throw new IllegalArgumentException ("Invalid resource Link name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); }
/** * Create, register, and return an MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be created or registered */ public static DynamicMBean createMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(resourceLink); ObjectName oname = createObjectName(domain, resourceLink); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
/** * Deregister the MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be deregistered */ public static void destroyMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resourceLink); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources)this.resource).findResourceLinks(); ArrayList results = new ArrayList(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for resource " + resourceLinks[i]); iae.initCause(e); throw iae; } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Return the MBean Names of all the defined resource links for this * application */ public String[] getResourceLinks() { ContextResourceLink[] links = getNamingResources().findResourceLinks(); ArrayList results = new ArrayList(); for (int i = 0; i < links.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), links[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for resource " + links[i]); iae.initCause(e); throw iae; } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Create, register, and return an MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be created or registered */ static DynamicMBean createMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(resourceLink); ObjectName oname = createObjectName(domain, resourceLink); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
/** * Deregister the MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resourceLink); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Set the specified resource link in the naming context. */ public void addResourceLink(ContextResourceLink resourceLink) { // Create a reference to the resource. Reference ref = new ResourceLinkRef (resourceLink.getType(), resourceLink.getGlobal()); javax.naming.Context ctx = "UserTransaction".equals(resourceLink.getName()) ? compCtx : envCtx; try { if (logger.isDebugEnabled()) log.debug(" Adding resource link " + resourceLink.getName()); createSubcontexts(envCtx, resourceLink.getName()); ctx.bind(resourceLink.getName(), ref); } catch (NamingException e) { logger.error(sm.getString("naming.bindFailed", e)); } }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources)this.resource).findResourceLinks(); ArrayList results = new ArrayList(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException ("Cannot create object name for resource " + resourceLinks[i]); } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Remove any resource link reference with the specified name. * * @param resourceLinkName Name of the resource link reference to remove */ public void removeResourceLink(String resourceLinkName) { resourceLinkName = URLDecoder.decode(resourceLinkName); NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { throw new IllegalArgumentException ("Invalid resource Link name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); }
/** * Return the MBean Names of all the defined resource links for this * application */ public String[] getResourceLinks() { ContextResourceLink[] links = getNamingResources().findResourceLinks(); ArrayList results = new ArrayList(); for (int i = 0; i < links.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), links[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException ("Cannot create object name for resource " + links[i]); } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Create, register, and return an MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be created or registered */ public static ModelMBean createMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ModelMBean mbean = managed.createMBean(resourceLink); ObjectName oname = createObjectName(domain, resourceLink); mserver.registerMBean(mbean, oname); return (mbean); }
/** * Deregister the MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be deregistered */ public static void destroyMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resourceLink); mserver.unregisterMBean(oname); }
/** * Set the specified resource link in the naming context. */ public void addResourceLink(ContextResourceLink resourceLink) { // Create a reference to the resource. Reference ref = new ResourceLinkRef (resourceLink.getType(), resourceLink.getGlobal()); // Adding the additional parameters, if any addAdditionalParameters(resourceLink.getNamingResources(), ref, resourceLink.getName()); try { if (debug >= 2) log(" Adding resource link " + resourceLink.getName()); createSubcontexts(envCtx, resourceLink.getName()); envCtx.bind(resourceLink.getName(), ref); } catch (NamingException e) { log(sm.getString("naming.bindFailed", e)); } }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources) this.resource).findResourceLinks(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for resource " + resourceLinks[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Create, register, and return an MBean for this * <code>ContextResourceLink</code> object. * * @param resourceLink * The ContextResourceLink to be managed * * @exception Exception * if an MBean cannot be created or registered */ public static DynamicMBean createMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(resourceLink); ObjectName oname = createObjectName(domain, resourceLink); if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
/** * Deregister the MBean for this <code>ContextResourceLink</code> object. * * @param resourceLink * The ContextResourceLink to be managed * * @exception Exception * if an MBean cannot be deregistered */ public static void destroyMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resourceLink); if (mserver.isRegistered(oname)) mserver.unregisterMBean(oname); }
@Override public void addContextResourceLink(Context context, List<ApplicationResource> resourceList, boolean contextBound) { NamingResources namingResources = context.getNamingResources(); for (ContextResourceLink link : namingResources.findResourceLinks()) { ApplicationResource resource = new ApplicationResource(); logger.debug("reading resourceLink: {}", link.getName()); resource.setApplicationName(context.getName()); resource.setName(link.getName()); resource.setType(link.getType()); resource.setLinkTo(link.getGlobal()); resourceList.add(resource); } }
public void addContextResourceLink(Context context, List resourceList, boolean contextBound) { ContextResourceLink[] resourceLinks = context.getNamingResources().findResourceLinks(); for (int i = 0; i < resourceLinks.length; i++) { ContextResourceLink link = resourceLinks[i]; ApplicationResource resource = new ApplicationResource(); logger.debug("reading resourceLink: " + link.getName()); resource.setApplicationName(context.getName()); resource.setName(link.getName()); resource.setType(link.getType()); resource.setLinkTo(link.getGlobal()); // lookupResource(resource, contextBound, false); resourceList.add(resource); } }