private AbstractName addDefaultFiltersGBeans(EARContext earContext, EARContext moduleContext, AbstractName moduleName, AbstractName previous) throws GBeanNotFoundException, GBeanAlreadyExistsException { for (Object defaultFilter : defaultFilters) { GBeanData filterGBeanData = getGBeanData(kernel, defaultFilter); String filterName = (String) filterGBeanData.getAttribute("filterName"); AbstractName defaultFilterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER); filterGBeanData.setAbstractName(defaultFilterAbstractName); filterGBeanData.setReferencePattern("JettyServletRegistration", moduleName); moduleContext.addGBean(filterGBeanData); //add a mapping to /* GBeanData filterMappingGBeanData = new GBeanData(JettyFilterMapping.GBEAN_INFO); if (previous != null) { filterMappingGBeanData.addDependency(previous); } filterMappingGBeanData.setReferencePattern("JettyServletRegistration", moduleName); String urlPattern = "/*"; filterMappingGBeanData.setAttribute("urlPattern", urlPattern); AbstractName filterMappingName = earContext.getNaming().createChildName(defaultFilterAbstractName, urlPattern, NameFactory.URL_WEB_FILTER_MAPPING); filterMappingGBeanData.setAbstractName(filterMappingName); previous = filterMappingName; filterMappingGBeanData.setAttribute("requestDispatch", TRUE); filterMappingGBeanData.setAttribute("forwardDispatch", TRUE); filterMappingGBeanData.setAttribute("includeDispatch", TRUE); filterMappingGBeanData.setAttribute("errorDispatch", FALSE); filterMappingGBeanData.setReferencePattern("Filter", defaultFilterAbstractName); moduleContext.addGBean(filterMappingGBeanData); } return previous; }
private void configureHosts(EARContext earContext, JettyWebAppType jettyWebApp, GBeanData webModuleData) throws GBeanAlreadyExistsException { String[] hosts = jettyWebApp.getHostArray(); for (int i = 0; i < hosts.length; i++) { hosts[i] = hosts[i].trim(); } String[] virtualHosts = jettyWebApp.getVirtualHostArray(); for (int i = 0; i < virtualHosts.length; i++) { virtualHosts[i] = virtualHosts[i].trim(); } if (hosts.length > 0 || virtualHosts.length > 0) { //use name same as module AbstractName hostName = earContext.getNaming().createChildName(webModuleData.getAbstractName(), "Host", "Host"); GBeanData hostData = new GBeanData(hostName, Host.GBEAN_INFO); hostData.setAttribute("hosts", hosts); hostData.setAttribute("virtualHosts", virtualHosts); earContext.addGBean(hostData); webModuleData.setReferencePattern("Host", hostName); } }
public void setReferencePattern(String name, AbstractNameQuery pattern) { setReferencePatterns(name, Collections.singleton(pattern)); }
protected GBeanData configureApplicationPolicyManager(AbstractName applicationPolicyManagerName, Map<String, ComponentPermissions> contextIDToPermissionsMap) { GBeanData jaccBeanData = new GBeanData(applicationPolicyManagerName, ApplicationPolicyConfigurationManager.GBEAN_INFO); jaccBeanData.setAttribute("contextIdToPermissionsMap", contextIDToPermissionsMap); return jaccBeanData; }
private void respectExcludeUnlistedClasses(GBeanData gbeanData) { boolean excludeUnlistedClasses = (Boolean) gbeanData.getAttribute("excludeUnlistedClasses"); if (excludeUnlistedClasses) { gbeanData.clearAttribute("jarFileUrls"); } }
private void addDependencies(LinkedHashSet<GBeanData> dependencies, GBeanData webModuleData) { for (GBeanData dependency : dependencies) { AbstractName dependencyName = dependency.getAbstractName(); webModuleData.addDependency(dependencyName); log.debug("Dependency on " + dependencyName); } }
protected GBeanData buildControllerGBean(Artifact configId, NodeInfo nodeInfo, Artifact slaveConfigId) { AbstractName controllerName = buildControllerName(configId, nodeInfo); GBeanData gbean = new GBeanData(controllerName, BasicClusterConfigurationController.class); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT, slaveConfigId); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START, Boolean.TRUE); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME, nodeInfo.getName()); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_START_CONF_UPON_START, Boolean.TRUE); gbean.setReferencePattern(BasicClusterConfigurationController.GBEAN_REF_CLUSTER_INFO, clusterInfoName); return gbean; }
protected void addNetworkConnectorMonitor(DeploymentContext moduleContext, AbstractName sessionManagerName) throws DeploymentException { AbstractName name = newGBeanName(moduleContext, "NetworkConnectorMonitor"); GBeanData networkConnectorMonitor = new GBeanData(name, NetworkConnectorMonitor.GBEAN_INFO); networkConnectorMonitor.setReferencePattern(NetworkConnectorMonitor.GBEAN_REF_NETWORK_CONNECTORS, defaultNetworkConnectorName); networkConnectorMonitor.setReferencePattern(NetworkConnectorMonitor.GBEAN_REF_EJB_DEP_ID_ACCESSOR, new AbstractNameQuery(ClusteredStatefulDeployment.class.getName())); networkConnectorMonitor.setReferencePattern(NetworkConnectorMonitor.GBEAN_REF_WADI_SESSION_MANAGER, sessionManagerName); addGBean(moduleContext, networkConnectorMonitor); }
GBeanData ejbWebServiceGBean = new GBeanData(ejbWebServiceName, this.wsGBeanInfo); ejbWebServiceGBean.setAttribute("ejbName", ejbName); ejbWebServiceGBean.setAttribute("ejbClass", bean.ejbClass); ejbWebServiceGBean.setAttribute("virtualHosts", virtualHosts); ejbWebServiceGBean.setReferencePattern("ConfigurationFactory", new AbstractNameQuery(null, Collections.singletonMap("name", wsSecurity.getSecurityRealmName().trim()), ConfigurationFactory.class.getName())); String authMethod = wsSecurity.getAuthMethod().value(); ejbWebServiceGBean.setAttribute("authMethod", authMethod); if (wsSecurity.getRealmName() != null) { ejbWebServiceGBean.setAttribute("realmName", wsSecurity.getRealmName().trim()); ejbWebServiceGBean.setAttribute("policyContextID", policyContextID); ejbWebServiceGBean.setAttribute("properties", properties); ejbWebServiceGBean.addDependency(module.getModuleName()); ReferencePatterns patterns = this.wsGBeanData.getReferencePatterns("WebServiceContainer"); if (patterns != null) { ejbWebServiceGBean.setReferencePatterns("WebServiceContainer", patterns); ejbWebServiceGBean.setReferencePattern("EjbDeployment", sessionName); ejbWebServiceGBean.clearAttribute("ejbName"); ejbWebServiceGBean.clearAttribute("ejbClass");
public void doStart() throws Exception { String threadName = (String)this.name.getName().get("name"); this.executorServiceName = kernel.getNaming().createRootName(name.getArtifact(), threadName, ManagedConstants.MANAGED_EXECUTOR_SERVICE); GBeanData executorServiceData = new GBeanData(this.executorServiceName, ServerManagedExecutorServiceGBean.getGBeanInfo()); executorServiceData.setAttribute("contextHandlers", this.contextHandlerClasses); executorServiceData.setAttribute("minPoolSize", this.minPoolSize); executorServiceData.setAttribute("maxPoolSize", this.maxPoolSize); executorServiceData.setAttribute("keepAliveTime", this.keepAliveTime); executorServiceData.setAttribute("queueCapacity", this.queueCapacity); GBeanData wrapperData = kernel.getGBeanData(this.name); executorServiceData.setReferencePatterns("threadFactory", wrapperData.getReferencePatterns("threadFactory")); addGBeanKernel(this.executorServiceName, executorServiceData); this.executorServiceGBean = (ServerManagedExecutorServiceGBean)kernel.getGBean(this.executorServiceName); this.executorServiceGBean.verifyObjectName(); }
static void preprocessGBeanData(AbstractName configurationName, Configuration configuration, GBeanData gbeanData) throws InvalidConfigException { if (log.isDebugEnabled()) { log.debug("resolving dependencies for " + gbeanData.getAbstractName()); for (Iterator references = gbeanData.getReferencesNames().iterator(); references.hasNext();) { String referenceName = (String) references.next(); GReferenceInfo referenceInfo = gbeanData.getGBeanInfo().getReference(referenceName); if (referenceInfo == null) { throw new InvalidConfigException("No reference named " + referenceName + " in gbean " + gbeanData.getAbstractName()); ReferencePatterns referencePatterns = gbeanData.getReferencePatterns(referenceName); AbstractName abstractName; try { throw new InvalidConfigException("Unable to resolve reference \"" + referenceName + "\" in gbean " + gbeanData.getAbstractName() + " to a gbean matching the pattern " + referencePatterns, e); gbeanData.setReferencePatterns(referenceName, new ReferencePatterns(abstractName)); for (Iterator dependencyIterator = gbeanData.getDependencies().iterator(); dependencyIterator.hasNext();) { ReferencePatterns referencePatterns = (ReferencePatterns) dependencyIterator.next(); AbstractName abstractName; throw new InvalidConfigException("Unable to resolve dependency in gbean " + gbeanData.getAbstractName(), e); gbeanData.setDependencies(newDependencies); GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl"); if (attribute != null && attribute.getType().equals("java.net.URL")) { try {
private GBeanData configureDefaultServlet(Object defaultServlet, EARContext earContext, AbstractName moduleName, Set knownServletMappings, EARContext moduleContext) throws GBeanNotFoundException, GBeanAlreadyExistsException { GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet); AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName, (String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET); servletGBeanData.setAbstractName(defaultServletObjectName); servletGBeanData.setReferencePattern("JettyServletRegistration", moduleName); Set<String> defaultServletMappings = new HashSet<String>((Collection<String>) servletGBeanData.getAttribute("servletMappings")); defaultServletMappings.removeAll(knownServletMappings); servletGBeanData.setAttribute("servletMappings", defaultServletMappings); moduleContext.addGBean(servletGBeanData); return servletGBeanData; }
try { if (authType.isSetConfigProvider()) { authConfigProviderData = new GBeanData(providerName, AuthConfigProviderGBean.class); final XmlCursor xmlCursor = authType.getConfigProvider().newCursor(); try { StringWriter out = new StringWriter(); JaspiXmlUtil.writeConfigProvider(configProviderType, out); authConfigProviderData.setAttribute("config", out.toString()); } finally { xmlCursor.dispose(); authConfigProviderData = new GBeanData(providerName, ServerAuthConfigGBean.class); final XmlCursor xmlCursor = authType.getServerAuthConfig().newCursor(); try { StringWriter out = new StringWriter(); JaspiXmlUtil.writeServerAuthConfig(serverAuthConfigType, out); authConfigProviderData.setAttribute("config", out.toString()); } finally { xmlCursor.dispose(); authConfigProviderData = new GBeanData(providerName, ServerAuthContextGBean.class); final XmlCursor xmlCursor = authType.getServerAuthContext().newCursor(); try { StringWriter out = new StringWriter(); JaspiXmlUtil.writeServerAuthContext(serverAuthContextType, out); authConfigProviderData.setAttribute("config", out.toString());
public void setApplicationManagedSecurityResources(Set applicationManagedSecurityResources) { gbean.setAttribute("applicationManagedSecurityResources", applicationManagedSecurityResources); } }
protected Configuration load(ConfigurationData configurationData, LinkedHashSet resolvedParentIds, Map loadedConfigurations) throws InvalidConfigException { Artifact configurationId = configurationData.getId(); AbstractName configurationName = Configuration.getConfigurationAbstractName(configurationId); GBeanData gbeanData = new GBeanData(configurationName, Configuration.GBEAN_INFO); gbeanData.setAttribute("configurationData", configurationData); gbeanData.setAttribute("configurationResolver", new ConfigurationResolver(configurationData, repositories, getArtifactResolver())); gbeanData.setAttribute("managedAttributeStore", attributeStore); parentNames.add(parentName); gbeanData.addDependencies(parentNames); gbeanData.setReferencePatterns("Parents", parentNames);
private void configureSecurityRealm(EARContext earContext, WebAppType webApp, JettyWebAppType jettyWebApp, GBeanData webModuleData) throws DeploymentException { AbstractName moduleName = webModuleData.getAbstractName(); if (earContext.getSecurityConfiguration() == null) { throw new DeploymentException("You have specified a <security-realm-name> for the webapp " + moduleName + " but no <security> configuration (role mapping) is supplied in the Geronimo plan for the web application (or the Geronimo plan for the EAR if the web app is in an EAR)"); } String securityRealmName = jettyWebApp.getSecurityRealmName().trim(); webModuleData.setReferencePattern("ConfigurationFactory", new AbstractNameQuery(null, Collections.singletonMap("name", securityRealmName), ConfigurationFactory.class.getName())); webModuleData.setReferencePattern("RunAsSource", (AbstractNameQuery)earContext.getGeneralData().get(ROLE_MAPPER_DATA_NAME)); /** * TODO - go back to commented version when possible. */ String policyContextID = moduleName.toString().replaceAll("[, :]", "_"); //String policyContextID = webModuleName.getCanonicalName(); webModuleData.setAttribute("policyContextID", policyContextID); ComponentPermissions componentPermissions = buildSpecSecurityConfig(webApp); earContext.addSecurityContext(policyContextID, componentPermissions); }
private Map getManagedConnectionFactoryInfoMap(AbstractName validatorName, List<ConnectionDefinition> connectionDefinitions, Bundle bundle) throws DeploymentException { Map<String, GBeanData> managedConnectionFactoryInfos = new HashMap<String, GBeanData>(); for (ConnectionDefinition connectionDefinition : connectionDefinitions) { GBeanInfoBuilder managedConnectionFactoryInfoBuilder = new GBeanInfoBuilder(ManagedConnectionFactoryWrapper.class, ManagedConnectionFactoryWrapperGBean.GBEAN_INFO); String managedConnectionfactoryClassName = connectionDefinition.getManagedConnectionFactoryClass(); Set<String> ignore = new HashSet<String>(); ignore.add("ResourceAdapter"); ignore.add("LogWriter"); GBeanData managedConnectionFactoryGBeanData = setUpDynamicGBeanWithProperties(managedConnectionfactoryClassName, managedConnectionFactoryInfoBuilder, connectionDefinition.getConfigProperty(), bundle, ignore); // set the standard properties String connectionfactoryInterface = connectionDefinition.getConnectionFactoryInterface(); managedConnectionFactoryGBeanData.setAttribute("managedConnectionFactoryClass", managedConnectionfactoryClassName); managedConnectionFactoryGBeanData.setAttribute("connectionFactoryInterface", connectionfactoryInterface); managedConnectionFactoryGBeanData.setAttribute("connectionFactoryImplClass", connectionDefinition.getConnectionFactoryImplClass()); managedConnectionFactoryGBeanData.setAttribute("connectionInterface", connectionDefinition.getConnectionInterface()); managedConnectionFactoryGBeanData.setAttribute("connectionImplClass", connectionDefinition.getConnectionImplClass()); managedConnectionFactoryGBeanData.setReferencePattern("ValidatorFactory", validatorName); managedConnectionFactoryInfos.put(connectionfactoryInterface, managedConnectionFactoryGBeanData); } return managedConnectionFactoryInfos; }
protected void replaceByClusteredDeploymentGBean(EARContext earContext, EjbModule ejbModule, AbstractName sessionManagerName, EnterpriseBean enterpriseBean) throws DeploymentException { AbstractName name = beanNameBuilder.createEjbName(earContext, ejbModule, enterpriseBean); GBeanData beanInstance; try { beanInstance = earContext.getGBeanInstance(name); earContext.removeGBean(name); } catch (GBeanNotFoundException e) { throw new DeploymentException("No GBean [" + name + "]", e); } GBeanData clusteredDeploymentGBean = new GBeanData(beanInstance); clusteredDeploymentGBean.setGBeanInfo(new GBeanData(ClusteredStatefulDeployment.class).getGBeanInfo()); clusteredDeploymentGBean.setReferencePattern(ClusteredStatefulDeployment.GBEAN_REF_SESSION_MANAGER, sessionManagerName); try { earContext.addGBean(clusteredDeploymentGBean); } catch (GBeanAlreadyExistsException e) { throw new DeploymentException("See nested", e); } }
public void setXmlAttribute(String name, XmlObject xmlObject, XmlObject enclosing) throws DeploymentException { String namespace = xmlObject.getDomNode().getNamespaceURI(); XmlAttributeBuilder builder = (XmlAttributeBuilder) xmlAttributeBuilderMap.get(namespace); if (builder == null) { throw new DeploymentException("No attribute builder deployed for namespace: " + namespace); } GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name); if (attribute == null) { throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName()); } String type = attribute.getType(); Object value = builder.getValue(xmlObject, enclosing, type, bundle); gbean.setAttribute(name, value); }
private GBeanData locateResourceAdapterGBeanData(GBeanData resourceAdapterModuleData) throws DeploymentException { GBeanData data = (GBeanData) resourceAdapterModuleData.getAttribute("resourceAdapterGBeanData"); if (data == null) { throw new DeploymentException("No resource adapter info found for resource adapter module: " + resourceAdapterModuleData.getAbstractName()); } return data; }