Author: bdaw
Date: 2007-08-23 04:04:55 -0400 (Thu, 23 Aug 2007)
New Revision: 8046
Removed:
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
Modified:
branches/JBoss_Portal_Branch_2_6/core/build.xml
Log:
outps... fix the build
Modified: branches/JBoss_Portal_Branch_2_6/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-08-23 06:49:51 UTC (rev 8045)
+++ branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-08-23 08:04:55 UTC (rev 8046)
@@ -133,6 +133,7 @@
<path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portal-portlet-federation.classpath"/>
<path refid="jboss.portal-identity.classpath"/>
+ <path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-theme.classpath"/>
<path refid="jboss.portal-security.classpath"/>
Deleted:
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-08-23
06:49:51 UTC (rev 8045)
+++
branches/JBoss_Portal_Branch_2_6/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-08-23
08:04:55 UTC (rev 8046)
@@ -1,619 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.portal.identity;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.jems.as.system.JBossServiceModelMBean;
-import org.jboss.portal.jems.as.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.IdentityContext;
-import org.jboss.portal.identity.IdentityContextImpl;
-import org.jboss.portal.identity.IdentityServiceController;
-import org.jboss.portal.identity.event.IdentityEventBroadcaster;
-import org.jboss.portal.identity.event.IdentityEvent;
-import org.jboss.portal.identity.config.metadata.IdentityConfigurationMetaData;
-import org.jboss.portal.identity.config.metadata.ModuleMetaData;
-import org.jboss.portal.identity.config.metadata.ConfigOptionMetaData;
-import org.jboss.portal.identity.config.metadata.OptionsMetaData;
-import org.jboss.portal.identity.config.metadata.OptionsGroupMetaData;
-import org.jboss.portal.identity.config.metadata.OptionsGroupOptionMetaData;
-import org.jboss.portal.identity.config.metadata.DatasourceMetaData;
-import org.jboss.portal.identity.config.metadata.ConfigurationParser;
-import org.jboss.portal.identity.service.IdentityModuleService;
-import org.jboss.portal.identity.service.IdentityConfigurationService;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-
-import javax.management.ObjectName;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class IdentityServiceControllerImpl extends AbstractJBossService implements
IdentityServiceController {
- private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(IdentityServiceControllerImpl.class);
-
- private String jndiName;
-
- protected JNDI.Binding jndiBinding;
-
- private IdentityContext identityContext;
-
- private boolean registerMBeans = true;
-
- private String configFile;
-
- private String defaultConfigFile;
-
- private IdentityEventBroadcaster identityEventBroadcaster;
-
- /**
- * .
- */
- protected Kernel kernel;
-
- /**
- * .
- */
- protected List beans;
-
-
-
- protected void startService() throws Exception
- {
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- //initialize microcontainer stuff
- try
- {
- BasicBootstrap bootstrap = new BasicBootstrap();
- bootstrap.run();
- kernel = bootstrap.getKernel();
- beans = new ArrayList();
- }
- catch (Exception e)
- {
- throw new IdentityException(e);
- }
-
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
-
- //parse config files
- IdentityConfigurationMetaData meta =
ConfigurationParser.parseIdentityConfiguration(configFile);
- IdentityConfigurationMetaData defaultMeta =
ConfigurationParser.parseIdentityConfiguration(defaultConfigFile);
-
- KernelControllerContext identityKernelContext;
- try
- {
- AbstractBeanMetaData contextBMD = new AbstractBeanMetaData(
- "portal:identity=IdentityContext",
- IdentityContextImpl.class.getName());
- beans.add(contextBMD);
- identityKernelContext = kernel.getController().install(contextBMD);
- identityContext = (IdentityContext)identityKernelContext.getTarget();
-
- }
- catch (Throwable throwable)
- {
- throw new IdentityException("Unable to install
IdentityContext",throwable);
- }
-
-
- // IdentityEventBroadcaster
- IdentityEventBroadcaster broadcaster = identityEventBroadcaster;
- if(broadcaster == null)
- {
- broadcaster = new IdentityEventBroadcaster()
- {
- public void fireEvent(IdentityEvent event)
- {
- // Noop
- }
- };
- }
-
- //
- try
- {
- identityContext.register(broadcaster,
IdentityContext.TYPE_IDENTITY_EVENT_BROADCASTER);
- }
- catch (Throwable throwable)
- {
- throw new IdentityException("Unable to install
IdentityEventBroadcaster", throwable);
- }
-
-
- //create detault modules set
-
- //Map[implementation] --> Map[Type] --> ModuleMetaData
- Map defaultImplementations = new HashMap();
-
- //update modules data with defaults
- try
- {
- List defaultModules = defaultMeta.getModules().getModules();
- for (Iterator iterator = defaultModules.iterator(); iterator.hasNext();)
- {
- ModuleMetaData module = (ModuleMetaData)iterator.next();
-
- //check if defaults contains all information
- if (module.getType() == null ||
- module.getImplementation() == null ||
- //module.getJNDIName() == null ||
- module.getServiceName() == null ||
- module.getConfig() == null)
- {
- throw new IdentityException("Default module configuration must be
complete");
- }
-
- //store them as maps for different implementations
- String implType = module.getImplementation();
- Map implementation;
- if (defaultImplementations.containsKey(implType))
- {
- implementation = (Map)defaultImplementations.get(implType);
- }
- else
- {
- implementation = new HashMap();
- }
-
- //store per implementation
- implementation.put(module.getType(), module);
- defaultImplementations.put(implType, implementation);
- }
- }
- catch (Exception e)
- {
- throw new IdentityException("Error during processing default configuration
file", e);
- }
-
- //map default datasources by name
- Map defaultDatasources = new HashMap();
- for (Iterator iterator = defaultMeta.getDatasources().getDatasources().iterator();
iterator.hasNext();)
- {
- DatasourceMetaData ds = (DatasourceMetaData)iterator.next();
- defaultDatasources.put(ds.getName(), ds);
-
- }
-
- //process the list of modules, instantiate them, configure them, tide them
- try
- {
- List datasources = meta.getDatasources().getDatasources();
- List modules = meta.getModules().getModules();
-
- //inject configuration service
- IdentityConfigurationService configuration = new
IdentityConfigurationService(meta.getOptions());
- configuration.setIdentityContext(identityContext);
-
- //TODO:set proper jndiName and serviceName
- configuration.start();
-
- //update options with defaults
- updateOptionsWithDefaults(configuration, defaultMeta.getOptions());
-
- //process datasources
- for (Iterator iterator = datasources.iterator(); iterator.hasNext();)
- {
- DatasourceMetaData ds = (DatasourceMetaData)iterator.next();
- if (log.isDebugEnabled()) log.debug("processing datasource: " +
ds.getName() + "/" + ds.getClassName());
- log.info("Installing datasourc: " + ds.getName());
- updateDatasourceWithDefaults(ds, defaultDatasources);
-
- //generate initial options
- Map configOptions = ds.getConfig().getOptions();
- Map optionMap = new HashMap();
- for (Iterator iterator1 = configOptions.keySet().iterator();
iterator1.hasNext();)
- {
- String optionName = (String)iterator1.next();
- ConfigOptionMetaData option =
(ConfigOptionMetaData)configOptions.get(optionName);
- optionMap.put(optionName, option.getValue());
- }
-
- //instantiate the module
- //IdentityModuleService moduleService = null;
-
-
- if (ds.getClassName() == null)
- {
- throw new IdentityException("Class name not found for datasource
type: " + ds.getName() + " wrong configuration");
- }
-
- /*try
- {
- moduleService =
(IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
- }
- catch (Exception e)
- {
- throw new IdentityException("Unable to instantiate the class: "
+ module.getClassName() );
- }*/
-
- //instantiate datasource using MC
- String entryName = "portal:identity=Datasource,type=" +
ds.getName();
- AbstractBeanMetaData dsBMD = new AbstractBeanMetaData(entryName,
- ds.getClassName());
- //AbstractPropertyMetaData propertyBMD = new
AbstractPropertyMetaData("identityContext", identityContext);
- //moduleBMD.addProperty(propertyBMD);
-
- //initiate parameters from <config>
- for (Iterator iterator1 = optionMap.keySet().iterator();
iterator1.hasNext();)
- {
- String propertyKey = (String)iterator1.next();
- String propertyValue = (String)optionMap.get(propertyKey);
- if (log.isDebugEnabled()) log.debug("adding parameter: " +
propertyKey + " ; " + propertyValue);
- AbstractPropertyMetaData propertyBMD = new
AbstractPropertyMetaData(propertyKey, propertyValue);
- dsBMD.addProperty(propertyBMD);
- }
-
- // Installation
- beans.add(dsBMD);
- KernelControllerContext controllerContext =
kernel.getController().install(dsBMD);
- Object datasource = controllerContext.getTarget();
-
- //make a part of identityContext
- //moduleService.setIdentityContext(identityContext);
-
- //register as an mbean
- if (isRegisterMBeans() && (ds.getServiceName() != null))
- {
- //getServer().registerMBean(moduleService, new
ObjectName(module.getServiceName()));
- JBossServiceModelMBean mbean = new JBossServiceModelMBean(datasource);
- //serviceName = new ObjectName("portal:container=WebApp,id=" +
portletAppMD.getId());
- //mbeanServer.registerMBean(mbean, serviceName);
- getServer().registerMBean(mbean, new ObjectName(ds.getServiceName()));
-
- }
-
-
- }
-
-
-
- //process modules for instantiation
- for (Iterator iterator = modules.iterator(); iterator.hasNext();)
- {
-
- ModuleMetaData module = (ModuleMetaData)iterator.next();
- log.info("Processing module: " + module.getType() + "/" +
module.getImplementation());// + "/" + module.getClassName());
-
- updateModuleWithDefaults(module, defaultImplementations);
-
- //generate initial options
- Map configOptions = module.getConfig().getOptions();
- Map optionMap = new HashMap();
- for (Iterator iterator1 = configOptions.keySet().iterator();
iterator1.hasNext();)
- {
- String optionName = (String)iterator1.next();
- ConfigOptionMetaData option =
(ConfigOptionMetaData)configOptions.get(optionName);
- optionMap.put(optionName, option.getValue());
- }
-
- //instantiate the module
- //IdentityModuleService moduleService = null;
-
-
- if (module.getClassName() == null)
- {
- throw new IdentityException("Class name not found for module type:
" + module.getType() + " wrong configuration");
- }
-
- /*try
- {
- moduleService =
(IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
- }
- catch (Exception e)
- {
- throw new IdentityException("Unable to instantiate the class: "
+ module.getClassName() );
- }*/
-
- //instantiate module using MC
- String entryName = "portal:identity=Module,type=" +
module.getType();
- AbstractBeanMetaData moduleBMD = new AbstractBeanMetaData(entryName,
- module.getClassName());
- AbstractPropertyMetaData propertyBMD = new
AbstractPropertyMetaData("identityContext", identityContext);
- moduleBMD.addProperty(propertyBMD);
-
- //initiate parameters from <config>
- for (Iterator iterator1 = optionMap.keySet().iterator();
iterator1.hasNext();)
- {
- String propertyKey = (String)iterator1.next();
- String propertyValue = (String)optionMap.get(propertyKey);
- if (log.isDebugEnabled()) log.debug("adding parameter: " +
propertyKey + " ; " + propertyValue);
- propertyBMD = new AbstractPropertyMetaData(propertyKey, propertyValue);
- moduleBMD.addProperty(propertyBMD);
- }
-
- //make the type from name
- propertyBMD = new AbstractPropertyMetaData("moduleType",
module.getType());
- moduleBMD.addProperty(propertyBMD);
-
-
- // Installation
- beans.add(moduleBMD);
- KernelControllerContext controllerContext =
kernel.getController().install(moduleBMD);
- Object moduleService = (IdentityModuleService)controllerContext.getTarget();
-
- //make a part of identityContext
- //moduleService.setIdentityContext(identityContext);
-
- //register as an mbean
- if (isRegisterMBeans() && (module.getServiceName() != null))
- {
- //getServer().registerMBean(moduleService, new
ObjectName(module.getServiceName()));
- JBossServiceModelMBean mbean = new JBossServiceModelMBean(moduleService);
- //serviceName = new ObjectName("portal:container=WebApp,id=" +
portletAppMD.getId());
- //mbeanServer.registerMBean(mbean, serviceName);
- getServer().registerMBean(mbean, new
ObjectName(module.getServiceName()));
-
- }
- }
-
-
- }
- catch (Throwable e)
- {
- throw new IdentityException("Cannot initiate identity modules: ", e);
- }
- }
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- }
-
-
-
-
- /**
- * updates module with proper defaults
- *
- * @param module
- * @param defaultModules
- */
- private void updateModuleWithDefaults(ModuleMetaData module, Map defaultModules)
- {
- if (module.getImplementation() == null)
- {
- return;
- }
- if (!defaultModules.containsKey(module.getImplementation()))
- {
- return;
- }
- Map modules = (Map)defaultModules.get(module.getImplementation());
- if (!modules.containsKey(module.getType()))
- {
- return;
- }
- ModuleMetaData def = (ModuleMetaData)modules.get(module.getType());
-
- if (module.getClassName() == null)
- {
- module.setClassName(def.getClassName());
- }
- if (module.getServiceName() == null)
- {
- module.setServiceName(def.getServiceName());
- }
-
- //now check if config options are overwritten
- if (module.getConfig() == null)
- {
- module.setConfig(def.getConfig());
- }
- else
- {
- Map moduleOptions = module.getConfig().getOptions();
- if (moduleOptions == null)
- {
- return;
- }
- Map defOptions = def.getConfig().getOptions();
-
- for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- if (!moduleOptions.containsKey(key))
- {
- ConfigOptionMetaData o = (ConfigOptionMetaData)defOptions.get(key);
- module.getConfig().addOption(o);
- }
- }
- }
- }
-
- /**
- * updates module with proper defaults
- */
- private void updateDatasourceWithDefaults(DatasourceMetaData ds, Map defaultDS)
- {
- if (ds.getName() == null)
- {
- return;
- }
- if (!defaultDS.containsKey(ds.getName()))
- {
- return;
- }
- DatasourceMetaData def = (DatasourceMetaData)defaultDS.get(ds.getName());
- if (ds.getClassName() == null)
- {
- ds.setClassName(def.getClassName());
- }
- if (ds.getServiceName() == null)
- {
- ds.setServiceName(def.getServiceName());
- }
-
- //now check if config options are overwritten
- if (ds.getConfig() == null)
- {
- ds.setConfig(def.getConfig());
- }
- else
- {
- Map dsOptions = ds.getConfig().getOptions();
- if (dsOptions == null)
- {
- return;
- }
- Map defOptions = def.getConfig().getOptions();
-
- for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- if (!dsOptions.containsKey(key))
- {
- ConfigOptionMetaData o = (ConfigOptionMetaData)defOptions.get(key);
- ds.getConfig().addOption(o);
- }
- }
- }
- }
-
- /**
- * Check current options and update them with defaults if not exists;
- *
- * @param config
- * @param defaults
- */
- private void updateOptionsWithDefaults(IdentityConfigurationService config,
OptionsMetaData defaults)
- {
- //Map newGroups = new HashMap();
- Map groups = defaults.getGroups();
- for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
- {
- String groupKey = (String)iterator.next();
-
- OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
-
- if (config.getOptions(groupKey) == null)
- {
- config.setOptions(groupKey, new HashMap());
- }
-
- //Map newOptions = new HashMap();
- Map options = group.getOptions();
- for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
- {
- String optionKey = (String)iterator1.next();
-
- OptionsGroupOptionMetaData option =
(OptionsGroupOptionMetaData)options.get(optionKey);
-
- if (config.getValues(groupKey, optionKey) == null)
- {
-
- //config.setValues(groupKey, optionKey, new HashSet());
- config.setValues(groupKey, optionKey, option.getValues());
- }
-
-
- }
- }
-
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
-
- public String getConfigFile()
- {
- return configFile;
- }
-
- public void setConfigFile(String configFile)
- {
- this.configFile = configFile;
- }
-
- public String getDefaultConfigFile()
- {
- return defaultConfigFile;
- }
-
- public void setDefaultConfigFile(String defaultConfigFile)
- {
- this.defaultConfigFile = defaultConfigFile;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public JNDI.Binding getJndiBinding()
- {
- return jndiBinding;
- }
-
- public void setJndiBinding(JNDI.Binding jndiBinding)
- {
- this.jndiBinding = jndiBinding;
- }
-
- public boolean isRegisterMBeans()
- {
- return registerMBeans;
- }
-
- public void setRegisterMBeans(boolean registerMBeans)
- {
- this.registerMBeans = registerMBeans;
- }
-
- public IdentityEventBroadcaster getIdentityEventBroadcaster()
- {
- return identityEventBroadcaster;
- }
-
- public void setIdentityEventBroadcaster(IdentityEventBroadcaster
identityEventBroadcaster)
- {
- this.identityEventBroadcaster = identityEventBroadcaster;
- }
-}