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); }
protected AbstractName addPreHandlerFactory(DeploymentContext moduleContext, GBeanData webModuleData, AbstractName sessionManagerName) throws GBeanAlreadyExistsException { AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), "WADIClusteredPreHandlerFactory", GBeanInfoBuilder.DEFAULT_J2EE_TYPE); GBeanData beanData = new GBeanData(name, WADIClusteredPreHandlerFactory.class); beanData.setReferencePattern(WADIClusteredPreHandlerFactory.GBEAN_REF_WADI_SESSION_MANAGER, sessionManagerName); webModuleData.setReferencePattern(WebAppContextWrapper.GBEAN_REF_PRE_HANDLER_FACTORY, name); moduleContext.addGBean(beanData); return name; }
protected AbstractName addSessionHandlerFactory(DeploymentContext moduleContext, GBeanData webModuleData, AbstractName sessionManagerName) throws GBeanAlreadyExistsException { AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), "ClusteredSessionHandlerFactory", GBeanInfoBuilder.DEFAULT_J2EE_TYPE); GBeanData beanData = new GBeanData(name, ClusteredSessionHandlerFactory.class); beanData.setReferencePattern(ClusteredSessionHandlerFactory.GBEAN_REF_SESSION_MANAGER, sessionManagerName); webModuleData.setReferencePattern(WebAppContextWrapper.GBEAN_REF_SESSION_HANDLER_FACTORY, name); moduleContext.addGBean(beanData); return name; }
private AbstractName addHandlerFactory(DeploymentContext moduleContext, GBeanData webModuleData, AbstractName sessionManagerName) throws GBeanAlreadyExistsException { AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), "ClusteredWebApplicationHandlerFactory", NameFactory.GERONIMO_SERVICE); GBeanData beanData = new GBeanData(name, ClusteredWebApplicationHandlerFactory.GBEAN_INFO); beanData.setReferencePattern(ClusteredWebApplicationHandlerFactory.GBEAN_REF_SESSION_MANAGER, sessionManagerName); webModuleData.setReferencePattern(JettyWebAppContext.GBEAN_REF_WEB_APPLICATION_HANDLER_FACTORY, name); moduleContext.addGBean(beanData); return name; }
private AbstractName addInterceptor(DeploymentContext moduleContext, GBeanData webModuleData, AbstractName sessionManagerName) throws GBeanAlreadyExistsException { AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), "WADIClusteredHandleInterceptor", NameFactory.GERONIMO_SERVICE); GBeanData beanData = new GBeanData(name, WADIClusteredHandleInterceptor.GBEAN_INFO); beanData.setReferencePattern(WADIClusteredHandleInterceptor.GBEAN_REF_WADI_SESSION_MANAGER, sessionManagerName); webModuleData.setReferencePattern(JettyWebAppContext.GBEAN_REF_HANDLE_INTERCEPTOR, name); moduleContext.addGBean(beanData); return name; }
protected void setClusteredServiceHolders(DeploymentContext moduleContext, GBeanData beanData) throws DeploymentException { AbstractName name = newGBeanName(moduleContext, "NetworkConnectorTrackerHolder"); GBeanData serviceHolder = new GBeanData(name, BasicNetworkConnectorTrackerServiceHolder.GBEAN_INFO); addGBean(moduleContext, serviceHolder); beanData.setReferencePattern(BasicWADISessionManager.GBEAN_REF_SERVICE_HOLDERS, name); }
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); }
public AbstractName getConnectorConfiguration(ConnectorType connectorType, List<ConnectorAttribute> connectorAttributes, WebContainer container, String uniqueName) { GBeanInfo gbeanInfo = CONNECTOR_GBEAN_INFOS.get(connectorType); AbstractName containerName = kernel.getAbstractNameFor(container); AbstractName name = kernel.getNaming().createSiblingName(containerName, uniqueName, GBeanInfoBuilder.DEFAULT_J2EE_TYPE); GBeanData gbeanData = new GBeanData(name, gbeanInfo); gbeanData.setAttribute("name", uniqueName); gbeanData.setReferencePattern(ConnectorGBean.CONNECTOR_CONTAINER_REFERENCE, containerName); Map<String, Object> initParams = new HashMap<String, Object>(); for (ConnectorAttribute connectorAttribute : connectorAttributes) { gbeanData.setAttribute(connectorAttribute.getAttributeName(), connectorAttribute.getValue()); initParams.put(connectorAttribute.getAttributeName(), connectorAttribute.getStringValue()); } gbeanData.setAttribute("initParams", initParams); AbstractNameQuery query = new AbstractNameQuery(ServerInfo.class.getName()); Set set = kernel.listGBeans(query); AbstractName serverInfo = (AbstractName) set.iterator().next(); gbeanData.setReferencePattern("ServerInfo", serverInfo); try { kernel.loadGBean(gbeanData, container.getClass().getClassLoader()); kernel.startGBean(name); } catch (Exception e) { log.error("Error when adding new tomcat connector" + uniqueName, e); } return name; }
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; }
private Map getAdminObjectInfoMap(AbstractName validatorName, List<AdminObject> adminObjects, Bundle bundle) throws DeploymentException { Map<String, GBeanData> adminObjectInfos = new HashMap<String, GBeanData>(); for (AdminObject adminObject : adminObjects) { GBeanInfoBuilder adminObjectInfoBuilder = new GBeanInfoBuilder(AdminObjectWrapperGBean.class, new AnnotationGBeanInfoBuilder(AdminObjectWrapperGBean.class).buildGBeanInfo()); String adminObjectClassName = adminObject.getAdminObjectClass(); GBeanData adminObjectGBeanData = setUpDynamicGBeanWithProperties(adminObjectClassName, adminObjectInfoBuilder, adminObject.getConfigProperty(), bundle, Collections.<String>emptySet()); // set the standard properties String adminObjectInterface = adminObject.getAdminObjectInterface(); adminObjectGBeanData.setAttribute("adminObjectInterface", adminObjectInterface); adminObjectGBeanData.setAttribute("adminObjectClass", adminObjectClassName); adminObjectGBeanData.setReferencePattern("ValidatorFactory", validatorName); adminObjectInfos.put(adminObjectInterface, adminObjectGBeanData); } return adminObjectInfos; }
private void addAdminObjectGBeans(List<GBeanData> raBeans, Naming naming, AbstractName jcaResourceName, GBeanData resourceAdapterModuleData, Bundle bundle, AbstractName resourceAdapterAbstractName, GerAdminobjectType[] adminObjects) throws DeploymentException { for (GerAdminobjectType gerAdminObject : adminObjects) { String adminObjectInterface = gerAdminObject.getAdminobjectInterface().trim(); GBeanData adminObjectGBeanData = locateAdminObjectInfo(resourceAdapterModuleData, adminObjectInterface); if (adminObjectGBeanData == null) { throw new DeploymentException("No admin object declared for interface: " + adminObjectInterface); } for (GerAdminobjectInstanceType gerAdminObjectInstance : gerAdminObject.getAdminobjectInstanceArray()) { GBeanData adminObjectInstanceGBeanData = new GBeanData(adminObjectGBeanData); setDynamicGBeanDataAttributes(adminObjectInstanceGBeanData, gerAdminObjectInstance.getConfigPropertySettingArray(), bundle); // add it AbstractName adminObjectAbstractName = naming.createChildName(jcaResourceName, gerAdminObjectInstance.getMessageDestinationName().trim(), NameFactory.JCA_ADMIN_OBJECT); adminObjectInstanceGBeanData.setAbstractName(adminObjectAbstractName); if (resourceAdapterAbstractName != null) { adminObjectInstanceGBeanData.setReferencePattern("ResourceAdapterWrapper", resourceAdapterAbstractName); } Set<String> implementedInterfaces = new HashSet<String>(); implementedInterfaces.add(checkClass(bundle, (String) adminObjectInstanceGBeanData.getAttribute("adminObjectInterface"))); implementedInterfaces.add(checkClass(bundle, (String) adminObjectInstanceGBeanData.getAttribute("adminObjectClass"))); adminObjectInstanceGBeanData.setServiceInterfaces(implementedInterfaces.toArray(new String[implementedInterfaces.size()])); String jndiName = naming.toOsgiJndiName(adminObjectAbstractName); //TODO allow specifying osig jndi name directly, like for connection factories adminObjectInstanceGBeanData.getServiceProperties().put(OSGI_JNDI_SERVICE_NAME, jndiName); raBeans.add(adminObjectInstanceGBeanData); } } }
gbeanData.setReferencePattern(ConnectorGBean.CONNECTOR_CONTAINER_REFERENCE, containerAbstractName); gbeanData.setReferencePattern("ServerInfo", set.iterator().next());
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; }
private Map<String, GBeanData> getActivationSpecInfoMap(AbstractName validatorName, List<MessageListener> messageListeners, Bundle bundle) throws DeploymentException { Map<String, GBeanData> activationSpecInfos = new HashMap<String, GBeanData>(); for (MessageListener messageListener : messageListeners) { String messageListenerInterface = messageListener.getMessageListenerType(); ActivationSpec activationSpec = messageListener.getActivationSpec(); String activationSpecClassName = activationSpec.getActivationSpecClass(); GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(ActivationSpecWrapperGBean.class, new AnnotationGBeanInfoBuilder(ActivationSpecWrapperGBean.class).buildGBeanInfo()); Set<String> ignore = Collections.singleton("resourceAdapter"); setUpDynamicGBean(activationSpecClassName, infoBuilder, ignore, bundle, true); GBeanInfo gbeanInfo = infoBuilder.getBeanInfo(); GBeanData activationSpecInfo = new GBeanData(gbeanInfo); activationSpecInfo.setAttribute("activationSpecClass", activationSpecClassName); activationSpecInfo.setReferencePattern("ValidatorFactory", validatorName); activationSpecInfos.put(messageListenerInterface, activationSpecInfo); } return activationSpecInfos; }
private void addFiltersGBeans(EARContext earContext, EARContext moduleContext, AbstractName moduleName, WebAppType webApp) throws GBeanAlreadyExistsException { FilterType[] filterArray = webApp.getFilterArray(); for (FilterType filterType : filterArray) { String filterName = filterType.getFilterName().getStringValue().trim(); AbstractName filterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER); GBeanData filterData = new GBeanData(filterAbstractName, JettyFilterHolder.GBEAN_INFO); filterData.setAttribute("filterName", filterName); filterData.setAttribute("filterClass", filterType.getFilterClass().getStringValue().trim()); Map<String, String> initParams = new HashMap<String, String>(); ParamValueType[] initParamArray = filterType.getInitParamArray(); for (ParamValueType paramValueType : initParamArray) { initParams.put(paramValueType.getParamName().getStringValue().trim(), paramValueType.getParamValue().getStringValue().trim()); } filterData.setAttribute("initParams", initParams); filterData.setReferencePattern("JettyServletRegistration", moduleName); moduleContext.addGBean(filterData); } }
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); } }
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; }
private void addAdminObjectGBeans(EARContext earContext, AbstractName jcaResourceName, GBeanData resourceAdapterModuleData, ClassLoader cl, AbstractName resourceAdapterAbstractName, GerAdminobjectType[] adminObjects) throws DeploymentException { for (GerAdminobjectType gerAdminObject : adminObjects) { String adminObjectInterface = gerAdminObject.getAdminobjectInterface().trim(); GBeanData adminObjectGBeanData = locateAdminObjectInfo(resourceAdapterModuleData, adminObjectInterface); if (adminObjectGBeanData == null) { throw new DeploymentException("No admin object declared for interface: " + adminObjectInterface); } for (GerAdminobjectInstanceType gerAdminObjectInstance : gerAdminObject.getAdminobjectInstanceArray()) { GBeanData adminObjectInstanceGBeanData = new GBeanData(adminObjectGBeanData); setDynamicGBeanDataAttributes(adminObjectInstanceGBeanData, gerAdminObjectInstance.getConfigPropertySettingArray(), cl); // add it AbstractName adminObjectAbstractName = earContext.getNaming().createChildName(jcaResourceName, gerAdminObjectInstance.getMessageDestinationName().trim(), NameFactory.JCA_ADMIN_OBJECT); adminObjectInstanceGBeanData.setAbstractName(adminObjectAbstractName); if (resourceAdapterAbstractName != null) { adminObjectInstanceGBeanData.setReferencePattern("ResourceAdapterWrapper", resourceAdapterAbstractName); } try { earContext.addGBean(adminObjectInstanceGBeanData); } catch (GBeanAlreadyExistsException e) { throw new DeploymentException("Could not add admin object gbean to context", e); } } } }
private void buildJaccManager(EARContext earContext) throws DeploymentException { if (earContext.isHasSecurity()) { //Be sure to only set once per app earContext.setHasSecurity(false); AbstractName applicationPolicyManagerName = earContext.getNaming().createChildName(earContext.getModuleName(), SecurityNames.JACC_MANAGER, SecurityNames.JACC_MANAGER); //TODO A better way to avoid the multiple invocation on securityBuilder.addGBeans ? try { if (earContext.getGBeanInstance(applicationPolicyManagerName) != null) { return; } } catch (GBeanNotFoundException e1) { } AbstractNameQuery roleMapperDataName = (AbstractNameQuery)earContext.getGeneralData().get(ROLE_MAPPER_DATA_NAME); if (roleMapperDataName == null) { roleMapperDataName = defaultRoleMappingName; EnvironmentBuilder.mergeEnvironments(earContext.getConfiguration().getEnvironment(), defaultEnvironment); } GBeanData jaccBeanData = configureApplicationPolicyManager(applicationPolicyManagerName, earContext.getContextIDToPermissionsMap()); jaccBeanData.setReferencePattern("PrincipalRoleMapper", roleMapperDataName); try { earContext.addGBean(jaccBeanData); earContext.getGeneralData().put(EARContext.JACC_MANAGER_NAME_KEY, jaccBeanData.getAbstractName()); } catch (GBeanAlreadyExistsException e) { throw new DeploymentException("JACC manager gbean already present", e); } } }
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); } }