protected Object fromString(String string) { return new AbstractName(URI.create(string)); } }
public void setResourceAdapterModuleAbName(String resourceAdapterModuleName) { this.resourceAdapterModuleAbName = new AbstractName(URI.create(resourceAdapterModuleName)); }
private ConfigurationStore getConfigurationStore(String targetConfigurationStore) throws URISyntaxException, GBeanNotFoundException { if (targetConfigurationStore != null) { AbstractName targetStoreName = new AbstractName(new URI(targetConfigurationStore)); return (ConfigurationStore) kernel.getGBean(targetStoreName); } else { return stores.iterator().next(); } }
public AbstractName createRootName(Artifact artifact, String name, String type) { Map nameMap = new HashMap(); nameMap.put(J2EE_TYPE, type); nameMap.put(J2EE_NAME, name); return new AbstractName(artifact, nameMap, createObjectName(nameMap)); }
private org.apache.servicemix.geronimo.Component getComponentGBean( String compName, Artifact artifactName) throws GBeanNotFoundException { Properties props = new Properties(); props.put("jbiType", "JBIComponent"); props.put("name", compName); org.apache.servicemix.geronimo.Component serviceUnit = (org.apache.servicemix.geronimo.Component) kernel.getGBean(new AbstractName(artifactName, props)); return serviceUnit; }
protected AbstractName buildControllerName(Artifact configId, NodeInfo nodeInfo) { return new AbstractName(configId, Collections.singletonMap("nodeName", nodeInfo.getName())); }
/** * Converts an Artifact to an AbstractName for a configuration. Does not * validate that this is a reasonable or resolved Artifact, or that it * corresponds to an actual Configuration. */ public static AbstractName getConfigurationAbstractName(Artifact configId) throws InvalidConfigException { return new AbstractName(configId, Collections.singletonMap("configurationName", configId.toString()), getConfigurationObjectName(configId)); }
/** * Set MBean attribute value */ public String[] setAttribute(String abstractName, String attribName, String attribValue, String attribType) { String[] result = new String[2]; // return attribute name & result result[0] = attribName; result[1] = "<SUCCESS>"; try { AbstractName aname = new AbstractName(URI.create(abstractName)); Object newAttribValue = createObject(attribValue, attribType); kernel.setAttribute(aname, attribName, newAttribValue); } catch (Exception e) { result[1] = e.toString(); } return result; }
/** * Invoke MBean operation without arguments */ @RemoteMethod public String[] invokeOperNoArgs(String abstractName, String methodName) { String[] result = new String[2]; // return method name & result result[0] = methodName + "()"; try { AbstractName aname = new AbstractName(URI.create(abstractName)); Object res = kernel.invoke(aname, methodName); if (res != null) { result[1] = res.toString(); } else { result[1] = "<null>"; } } catch (Exception e) { result[1] = e.toString(); } return result; }
public AbstractName createSiblingName(AbstractName parentAbstractName, String name, String type) { Map nameMap = new HashMap(parentAbstractName.getName()); nameMap.put(J2EE_TYPE, type); nameMap.put(J2EE_NAME, name); return new AbstractName(parentAbstractName.getArtifact(), nameMap, createObjectName(nameMap)); }
public AbstractName createChildName(AbstractName parentAbstractName, Artifact artifact, String name, String type) { if (name == null) { throw new NullPointerException("No name supplied"); } if (type == null) { throw new NullPointerException("No type supplied"); } Map nameMap = new HashMap(parentAbstractName.getName()); String parentType = (String) nameMap.remove(J2EE_TYPE); String parentName = (String) nameMap.remove(J2EE_NAME); if (parentType == null) { throw new IllegalArgumentException("parent name must have a j2eeType name component"); } if (INVALID_GENERIC_PARENT_TYPE.equals(parentType)) { throw new IllegalArgumentException("You can't create a child of a generic typed gbean"); } nameMap.put(parentType, parentName); nameMap.put(J2EE_TYPE, type); nameMap.put(J2EE_NAME, name); return new AbstractName(artifact, nameMap, createObjectName(nameMap)); }
/** * Return all MBeans that provide stats */ @RemoteMethod public Collection<String[]> getStatsProviderMBeans() { Collection<String[]> result = new ArrayList<String[]>(); Object[] allMBeans = listByPattern("*:*").toArray(); for (int i = 0; i < allMBeans.length; i++) { try { String[] aPair = (String[]) allMBeans[i]; AbstractName abstractName = new AbstractName(URI.create(aPair[0])); boolean isStatisticsProvider = ((Boolean)kernel.getAttribute(abstractName, "statisticsProvider")).booleanValue(); if (isStatisticsProvider) { result.add(aPair); } } catch (Exception e) { // ignore } } return result; }
/** * Return MBean operations */ @RemoteMethod public Collection<Map<String, Object>> getOperations(String abstractName) { Map<String, Map<String, Object>> operations = new TreeMap<String, Map<String, Object>>(); try { AbstractName aname = new AbstractName(URI.create(abstractName)); GBeanInfo gBeaninfo = kernel.getGBeanInfo(aname); Set<GOperationInfo> opers = gBeaninfo.getOperations(); for (Iterator<GOperationInfo> i = opers.iterator(); i.hasNext();) { GOperationInfo operInfo = i.next(); Map<String, Object> operInfoMap = getOperInfoAsMap(operInfo); String operName = (String) operInfoMap.get("name"); operations.put(operName, operInfoMap); } } catch (Exception e) { // GBean not found, just ignore } return operations.values(); }
/** * Invoke MBean operation with arguments */ @RemoteMethod public String[] invokeOperWithArgs(String abstractName, String methodName, String[] args, String[] types) { String[] result = new String[2]; // return method name & result result[0] = methodName + "(...)"; try { Object[] newArgs = processOperArgs(args, types); AbstractName aname = new AbstractName(URI.create(abstractName)); Object res = kernel.invoke(aname, methodName, newArgs, types); if (res != null) { result[1] = res.toString(); } else { result[1] = "<null>"; } } catch (Exception e) { result[1] = e.toString(); } return result; }
public static JMSMessageHelper getMessageHelper(PortletRequest renderRequest, String resourceAdapterModuleName) { String vendorName = null; ResourceAdapterModule module = (ResourceAdapterModule)PortletManager.getManagementHelper(renderRequest).getObject(new AbstractName(URI.create(resourceAdapterModuleName))); if(module != null) { vendorName = module.getVendorName(); } return getJMSMessageHelper(vendorName); }
/** * Return MBean attributes */ @RemoteMethod public Collection<Map<String, String>> getAttributes(String abstractNameString) { Map<String, Map<String, String>> attributes = new TreeMap<String, Map<String, String>>(); try { AbstractName abstractName = new AbstractName(URI.create(abstractNameString)); GBeanInfo gBeanInfo = kernel.getGBeanInfo(abstractName); Set<GAttributeInfo> attrs = gBeanInfo.getAttributes(); for (Iterator<GAttributeInfo> i = attrs.iterator(); i.hasNext();) { GAttributeInfo gAttrInfo = i.next(); String attrName = gAttrInfo.getName(); if (!GBEANINFO_ATTRIB.equals(attrName)) { // Don't include the 'GBeanInfo' attributes Map<String, String> attrInfoMap = getAttrInfoAsMap(abstractName, gAttrInfo); attributes.put(attrName, attrInfoMap); } } } catch (GBeanNotFoundException e) { // GBean not found, just ignore } return attributes.values(); }
private WebModule getWebModule(Configuration config, Configuration child) { try { Map<String, String> query1 = new HashMap<String, String>(); String name = config.getId().getArtifactId(); query1.put("J2EEApplication", config.getId().toString()); query1.put("j2eeType", "WebModule"); query1.put("name", child.getId().getArtifactId().substring(name.length()+1)); AbstractName childName = new AbstractName(config.getAbstractName().getArtifact(), query1); return (WebModule)kernel.getGBean(childName); } catch(Exception h){ // No gbean found, will not happen // Except if module not started, ignored } return null; }
@Override public void setKernel(Kernel kernel) { if(query == null) { try { ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); AbstractName mappedAbstractName = new AbstractName(configurationManager.getArtifactResolver().resolveInClassLoader(gbeanName.getArtifact()), gbeanName.getName()); String osgiJndiName = kernel.getNaming().toOsgiJndiName(mappedAbstractName); query = "(osgi.jndi.service.name=" + osgiJndiName + ')'; } catch (GBeanNotFoundException e) { logger.error("Fail to build the jndi name for " + gbeanName, e); } catch (MissingDependencyException e) { logger.error("Fail to build the jndi name for " + gbeanName, e); } } } }
@Override public void setKernel(Kernel kernel) { if(jndiName == null) { try { ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); AbstractName mappedAbstractName = new AbstractName(configurationManager.getArtifactResolver().resolveInClassLoader(gbeanName.getArtifact()), gbeanName.getName()); String osgiJndiName = kernel.getNaming().toOsgiJndiName(mappedAbstractName); jndiName = prefix + osgiJndiName; } catch (GBeanNotFoundException e) { logger.error("Fail to build the jndi name for " + gbeanName, e); } catch (MissingDependencyException e) { logger.error("Fail to build the jndi name for " + gbeanName, e); } } } }
public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException { AbstractName name = new AbstractName(URI.create(request.getParameter(ABSTRACT_NAME_PARAMETER))); StatisticsProvider pool = (StatisticsProvider) PortletManager.getManagedBean(request, name); ThreadPoolStats stats = (ThreadPoolStats) pool.getStats(); String[] consumers = stats.getThreadConsumers(); ClientStats[] result = new ClientStats[consumers.length]; for (int i = 0; i < result.length; i++) { result[i] = new ClientStats(consumers[i], (int)stats.getCountForConsumer(consumers[i]).getCount()); } request.setAttribute("poolName", name.getName().get(NameFactory.J2EE_NAME)); request.setAttribute("stats", stats); request.setAttribute("consumers", result); }