/** * 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(), resourceLink.getFactory(), null); Iterator<String> i = resourceLink.listProperties(); while (i.hasNext()) { String key = i.next().toString(); Object val = resourceLink.getProperty(key); if (val!=null) { StringRefAddr refAddr = new StringRefAddr(key, val.toString()); ref.add(refAddr); } } 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)); } }
/** * Add a resource link for this web application. * * @param resourceLinkName New resource link name */ public String addResourceLink(String resourceLinkName, String global, String name, String type) throws MalformedObjectNameException { NamingResources nresources = getNamingResources(); if (nresources == null) { return null; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink != null) { throw new IllegalArgumentException ("Invalid resource link name - already exists'" + resourceLinkName + "'"); } resourceLink = new ContextResourceLink(); resourceLink.setGlobal(global); resourceLink.setName(resourceLinkName); resourceLink.setType(type); nresources.addResourceLink(resourceLink); // Return the corresponding MBean name return createObjectName(resourceLink).toString(); }
/** * 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) { String msg = MessageFormat.format(rb.getString(LogFacade.BIND_OBJECT_FAILED), e); log(msg); } }
@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); } }
/** * Add a resource link for this web application. * * @param resourceLink New resource link */ public void addResourceLink(ContextResourceLink resourceLink) { if (entries.containsKey(resourceLink.getName())) { return; } else { String value = resourceLink.getType(); if (value == null) { value = ""; } entries.put(resourceLink.getName(), value); } synchronized (resourceLinks) { resourceLink.setNamingResources(this); resourceLinks.put(resourceLink.getName(), resourceLink); } support.firePropertyChange("resourceLink", null, resourceLink); }
crl.setGlobal((String)value); } else if ("description".equals(name)) { crl.setDescription((String)value); } else if ("name".equals(name)) { crl.setName((String)value); } else if ("type".equals(name)) { crl.setType((String)value); } else { crl.setProperty(name, ""+value); NamingResources nr = crl.getNamingResources(); nr.removeResourceLink(crl.getName()); nr.addResourceLink(crl);
return (cl.getGlobal()); } else if ("description".equals(name)) { return (cl.getDescription()); } else if ("name".equals(name)) { return (cl.getName()); } else if ("type".equals(name)) { return (cl.getType()); } else { value = (String) cl.getProperty(name); if (value == null) { throw new AttributeNotFoundException
resourceLinkName + "'"); resourceLink = new ContextResourceLink(); resourceLink.setName(resourceLinkName); resourceLink.setType(type); nresources.addResourceLink(resourceLink);
/** * Create an <code>ObjectName</code> for <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be named * * @exception MalformedObjectNameException if a name cannot be created */ public ObjectName createObjectName(ContextResourceLink resourceLink) throws MalformedObjectNameException { ObjectName name = null; String encodedResourceLinkName = urlEncoder.encode(resourceLink.getName()); Object container = resourceLink.getNamingResources().getContainer(); if (container instanceof Server) { name = new ObjectName(domain + ":type=ResourceLink" + ",resourcetype=Global" + ",name=" + encodedResourceLinkName); } else if (container instanceof Context) { String path = ((Context)container).getPath(); if (path.length() < 1) path = "/"; Host host = (Host) ((Context)container).getParent(); name = new ObjectName(domain + ":type=ResourceLink" + ",resourcetype=Context,path=" + path + ",host=" + host.getName() + ",name=" + encodedResourceLinkName); } return (name); }
/** * Add a resource link for this web application. * * @param resourceLink New resource link */ public void addResourceLink(ContextResourceLink resourceLink) { namingResources.addResourceLink(resourceLink); if (notifyContainerListeners) { fireContainerEvent("addResourceLink", resourceLink.getName()); } }
/** * Add a resource link for this web application. * * @param resourceLink New resource link */ public void addResourceLink(ContextResourceLink resourceLink) { if (entries.contains(resourceLink.getName())) { return; } else { entries.add(resourceLink.getName()); } synchronized (resourceLinks) { resourceLink.setNamingResources(this); resourceLinks.put(resourceLink.getName(), resourceLink); } support.firePropertyChange("resourceLink", null, resourceLink); // Register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.createMBean(resourceLink); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanCreateFail", resourceLink.getName()), e); } } }
/** * Remove any resource link with the specified name. * * @param name Name of the resource link to remove */ public void removeResourceLink(String name) { entries.remove(name); ContextResourceLink resourceLink = null; synchronized (resourceLinks) { resourceLink = (ContextResourceLink) resourceLinks.remove(name); } if (resourceLink != null) { support.firePropertyChange("resourceLink", resourceLink, null); resourceLink.setNamingResources(null); } }
crl.setGlobal((String)value); } else if ("description".equals(name)) { crl.setDescription((String)value); } else if ("name".equals(name)) { crl.setName((String)value); } else if ("type".equals(name)) { crl.setType((String)value); } else { crl.setProperty(name, ""+value); NamingResources nr = crl.getNamingResources(); nr.removeResourceLink(crl.getName()); nr.addResourceLink(crl);
return (cl.getGlobal()); } else if ("description".equals(name)) { return (cl.getDescription()); } else if ("name".equals(name)) { return (cl.getName()); } else if ("type".equals(name)) { return (cl.getType()); } else { value = (String) cl.getProperty(name); if (value == null) { throw new AttributeNotFoundException
/** * Return a String representation of this object. */ @Override public String toString() { StringBuilder sb = new StringBuilder("ContextResourceLink["); sb.append("name="); sb.append(getName()); if (getType() != null) { sb.append(", type="); sb.append(getType()); } if (getGlobal() != null) { sb.append(", global="); sb.append(getGlobal()); } sb.append("]"); return (sb.toString()); }
/** * Add a resource link for this web application. * * @param resourceLink New resource link */ public void addResourceLink(ContextResourceLink resourceLink) { if (entries.containsKey(resourceLink.getName())) { return; } else { String value = resourceLink.getType(); if (value == null) { value = ""; } entries.put(resourceLink.getName(), value); } synchronized (resourceLinks) { resourceLink.setNamingResources(this); resourceLinks.put(resourceLink.getName(), resourceLink); } support.firePropertyChange("resourceLink", null, resourceLink); }
resourceLinkName + "'"); resourceLink = new ContextResourceLink(); resourceLink.setName(resourceLinkName); resourceLink.setType(type); nresources.addResourceLink(resourceLink);
= ObjectName.quote(resourceLink.getName()); Object container = resourceLink.getNamingResources().getContainer(); if (container instanceof Server) { name = new ObjectName(domain + ":type=ResourceLink" +
} catch (Exception e) { log.warn(sm.getString( "namingResources.mbeanCreateFail", crl.getName()), e);