protected Object fromString(String string) { return new AbstractNameQuery(URI.create(string)); } }
/** * N.B. parameter info is supposed to be more specific than this. * This is the opposite of the meaning of Artifact.matches. * * @param info * @return if info is a more specific version of this name query. */ public boolean matches(AbstractNameQuery info) { if (!info.getName().entrySet().containsAll(name.entrySet())) { return false; } if (!info.getInterfaceTypes().containsAll(interfaceTypes)) { return false; } if (artifact == null) { return true; } Artifact otherArtifact = info.getArtifact(); return artifact.matches(otherArtifact); } }
/** * Find the gbeanDatas matching the patterns in this configuration only, ignoring parents. * * @param configuration configuration to look in * @param patterns patterns to look for * @return set of gbeandatas matching one of the patterns from this configuration only, not including parents. */ public LinkedHashSet<GBeanData> findGBeanDatas(Configuration configuration, Set<AbstractNameQuery> patterns) { LinkedHashSet<GBeanData> result = new LinkedHashSet<GBeanData>(); Set<Map.Entry<AbstractName, GBeanData>> gbeanNames = configuration.getGBeans().entrySet(); for (AbstractNameQuery abstractNameQuery : patterns) { Artifact queryArtifact = abstractNameQuery.getArtifact(); // Does this query apply to this configuration if (queryArtifact == null || queryArtifact.matches(configuration.getId())) { // Search the GBeans for (Map.Entry<AbstractName, GBeanData> entry : gbeanNames) { AbstractName abstractName = entry.getKey(); GBeanData gbeanData = entry.getValue(); if (abstractNameQuery.matches(abstractName, gbeanData.getGBeanInfo().getInterfaces())) { result.add(gbeanData); } } } } return result; }
private String isVerifyReference(ReferencePatterns referencePatterns, Configuration configuration) { // we can't verify a resolved reference since it will have a specific artifact already set... // hopefully the deployer won't generate bad resolved references if (referencePatterns.isResolved()) return null; // Do not verify the reference if it has an explicit depenency on another artifact, because it it likely // that the other artifact is not in the "environment" (if it were you wouldn't use the long form) Set<AbstractNameQuery> patterns = referencePatterns.getPatterns(); for (AbstractNameQuery query : patterns) { if (query.getArtifact() != null) return null; } // attempt to find the bean try { configuration.findGBean(patterns); return null; } catch (GBeanNotFoundException e) { //TODO bug!! GERONIMO-3140 Multiple matches may be caused by using an already-loaded configuration rather than reloading one // using the client_artifact_aliases.properties which e.g. remap the server tm to the client tm. if (e.hasMatches()) { return null; } return e.getMessage(); } } }
AbstractNameQuery loginModuleNameQuery = SingleGBeanBuilder.buildAbstractNameQuery(patternType, USE_REFERENCE_INFO); loginModuleReferencePatterns = new ReferencePatterns(loginModuleNameQuery); name = (String) loginModuleNameQuery.getName().get("name"); if (name == null) { throw new DeploymentException("You must specify the name of the login module in the login module ref " + patternType);
public GlobalContextGBean(Kernel kernel) throws NamingException { super("", new AbstractNameQuery(null, Collections.EMPTY_MAP, Context.class.getName()), kernel); }
public static AbstractNameQuery newTypeNameQuery(Artifact artifactId, String jeeType, String name) { Map<String, String> names = new HashMap<String, String>(2); names.put(J2EE_TYPE, jeeType); names.put(J2EE_NAME, name); return new AbstractNameQuery(artifactId, names); } }
private AbstractNameQuery getAbstractNameQuery(String dataSourceString) throws URISyntaxException { if (dataSourceString.indexOf('=') == -1) { dataSourceString = "?name=" + dataSourceString; } AbstractNameQuery dataSourceNameQuery = new AbstractNameQuery(new URI(dataSourceString + "#" + RESOURCE_SOURCE_CLASS_NAME)); return dataSourceNameQuery; }
public static AbstractNameQuery buildAbstractNameQuery(Artifact configId, String module, String name, String type, String moduleType) { Map nameMap = new HashMap(); nameMap.put("name", name); if (type != null) { nameMap.put("j2eeType", type); } if (module != null && moduleType != null) { nameMap.put(moduleType, module); } return new AbstractNameQuery(configId, nameMap); }
public ReferencePatterns(Set<? extends Object> patterns) { this.patterns = new LinkedHashSet<AbstractNameQuery>(); for (Object pattern : patterns) { if (pattern instanceof AbstractName) { AbstractName name = (AbstractName) pattern; this.patterns.add(new AbstractNameQuery(name)); } else if (pattern instanceof AbstractNameQuery) { AbstractNameQuery nameQuery = (AbstractNameQuery) pattern; this.patterns.add(nameQuery); } else { throw new IllegalArgumentException("Unknown pattern type: " + pattern); } } this.abstractName = null; }
public BasicDependencyManager(LifecycleMonitor lifecycleMonitor) throws Exception { assert lifecycleMonitor != null; this.lifecycleMonitor = lifecycleMonitor; lifecycleMonitor.addLifecycleListener(lifecycleListener, new AbstractNameQuery(null, Collections.EMPTY_MAP, Collections.EMPTY_SET)); }
public static boolean isWebApp(Kernel kernel, String configName) { Map filter = new HashMap(); filter.put("j2eeType", "WebModule"); filter.put("name", configName); Set set = kernel.listGBeans(new AbstractNameQuery(null, filter)); return set.size() > 0; }
private static AbstractName getUniquename(String name, String type, Kernel kernel) { Map properties = new HashMap(2); properties.put(NameFactory.J2EE_NAME, name); properties.put(NameFactory.J2EE_TYPE, type); AbstractNameQuery query = new AbstractNameQuery(null, properties); Set results = kernel.listGBeans(query); if (results.isEmpty()) { throw new RuntimeException("No services found with name " + name + " and type " + type); } if (results.size() != 1) { throw new RuntimeException("More than one service was found with name " + name + " and type " + type + ", returns: " + results); } return (AbstractName) results.iterator().next(); }
protected GBeanData getResourceAdapterModuleData() throws GBeanNotFoundException { return CONNECTOR_CONFIGURATION.findGBeanData(new AbstractNameQuery(RESOURCE_ADAPTER_MODULE_NAME)); }
private ManageableAttributeStore getManageableAttributeStore() { Set set = kernel.listGBeans(new AbstractNameQuery(ManageableAttributeStore.class.getName())); for (Iterator iterator = set.iterator(); iterator.hasNext();) { AbstractName abstractName1 = (AbstractName) iterator.next(); try { return (ManageableAttributeStore) kernel.getGBean(abstractName1); } catch (GBeanNotFoundException e) { // ignored... gbean was unregistered } } return null; }
protected AbstractNameQuery createJettyWebAppContextNameQuery(DeploymentContext moduleContext) { String name = moduleContext.getModuleName().getNameProperty(Jsr77Naming.J2EE_NAME); return new AbstractNameQuery(null, Collections.singletonMap(Jsr77Naming.J2EE_NAME, name), Collections.singleton(WebAppContextWrapper.class.getName())); }
public WebAccessLog getAccessLog(WebContainer container) { AbstractNameQuery query = new AbstractNameQuery(TomcatLogManager.class.getName()); Set names = kernel.listGBeans(query); if(names.size() == 0) { return null; } else if(names.size() > 1) { throw new IllegalStateException("Should not be more than one Tomcat access log manager"); } return (WebAccessLog) kernel.getProxyManager().createProxy((AbstractName)names.iterator().next(), TomcatLogManager.class.getClassLoader()); }
public NetworkConnector[] getConnectors() { ProxyManager proxyManager = kernel.getProxyManager(); AbstractNameQuery query = new AbstractNameQuery(ActiveMQConnector.class.getName()); Set names = kernel.listGBeans(query); ActiveMQConnector[] results = new ActiveMQConnector[names.size()]; int i=0; for (Iterator it = names.iterator(); it.hasNext(); i++) { AbstractName name = (AbstractName) it.next(); results[i] = (ActiveMQConnector) proxyManager.createProxy(name, ActiveMQConnector.class.getClassLoader()); } return results; }
protected Collection<ModuleConfigurer> getModuleConfigurers() throws DeploymentManagerCreationException { Collection<ModuleConfigurer> moduleConfigurers = new ArrayList<ModuleConfigurer>(); Set<AbstractName> configurerNames = kernel.listGBeans(new AbstractNameQuery(ModuleConfigurer.class.getName())); for (AbstractName configurerName : configurerNames) { try { ModuleConfigurer configurer = (ModuleConfigurer) kernel.getGBean(configurerName); moduleConfigurers.add(configurer); } catch (GBeanNotFoundException e) { throw (AssertionError)new AssertionError("No gbean found for name returned in query : " + configurerName).initCause(e); } } return moduleConfigurers; }
public Object[] getContainers() { ProxyManager proxyManager = kernel.getProxyManager(); AbstractNameQuery query = new AbstractNameQuery(ActiveMQBroker.class.getName()); Set names = kernel.listGBeans(query); ActiveMQBroker[] results = new ActiveMQBroker[names.size()]; int i=0; for (Iterator it = names.iterator(); it.hasNext(); i++) { AbstractName name = (AbstractName) it.next(); results[i] = (ActiveMQBroker) proxyManager.createProxy(name, ActiveMQBroker.class.getClassLoader()); } return results; }