[jboss-cvs] JBossAS SVN: r65012 - in trunk/tomcat: src/main/org/jboss/web/jsf/integration/injection and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Sep 3 10:06:55 EDT 2007
Author: remy.maucherat at jboss.com
Date: 2007-09-03 10:06:55 -0400 (Mon, 03 Sep 2007)
New Revision: 65012
Removed:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment2.java
Modified:
trunk/tomcat/.classpath
trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossInjectionProvider.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/ClusteredSingleSignOn.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SSOClusterManager.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SingleSignOnEntry.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java
Log:
- Update to JBoss Web 2.1.0 API.
Modified: trunk/tomcat/.classpath
===================================================================
--- trunk/tomcat/.classpath 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/.classpath 2007-09-03 14:06:55 UTC (rev 65012)
@@ -30,7 +30,6 @@
<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/el-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/jasper-jdt.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/jbossweb.jar" sourcepath="/thirdparty/jboss/web/lib/jbossweb-src.zip"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/web/lib/jbossweb-extras.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/jsp-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/web/lib/servlet-api.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/system-jmx"/>
Modified: trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossInjectionProvider.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossInjectionProvider.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/jsf/integration/injection/JBossInjectionProvider.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -22,25 +22,42 @@
package org.jboss.web.jsf.integration.injection;
-import com.sun.faces.spi.InjectionProvider;
-import com.sun.faces.spi.InjectionProviderException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
-import org.apache.catalina.util.DefaultAnnotationProcessor;
+import javax.naming.NamingException;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.xml.ws.WebServiceRef;
+
import org.jboss.logging.Logger;
+import com.sun.faces.spi.InjectionProvider;
+import com.sun.faces.spi.InjectionProviderException;
+
/**
* Provides interface between JSF RI and Tomcat Catalina for injection of managed beans as
* per JSF 1.2 Spec section 5.4.
*
* @author Stan Silvert
+ * @author Fabien Carrion
+ * @author Remy Maucherat
*/
public class JBossInjectionProvider implements InjectionProvider {
private static final Logger LOG = Logger.getLogger(JBossInjectionProvider.class);
private static final String NAMING_DISABLED = "Injection of naming resources into JSF managed beans disabled.";
private Context namingContext;
- private DefaultAnnotationProcessor annotationProcessor = null;
/**
* Uses the default naming context for injection of resources into managed beans.
@@ -48,7 +65,6 @@
public JBossInjectionProvider() {
try {
this.namingContext = new InitialContext();
- this.annotationProcessor = new DefaultAnnotationProcessor(this.namingContext);
} catch (Exception e) {
LOG.warn(NAMING_DISABLED, e);
}
@@ -69,7 +85,6 @@
}
this.namingContext = namingContext;
- this.annotationProcessor = new DefaultAnnotationProcessor(this.namingContext);
}
/**
@@ -77,7 +92,29 @@
*/
public void invokePreDestroy(Object managedBean) throws InjectionProviderException {
try {
- annotationProcessor.preDestroy(managedBean);
+ Method[] methods = managedBean.getClass().getDeclaredMethods();
+ Method preDestroy = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].isAnnotationPresent(PreDestroy.class)) {
+ if ((preDestroy != null)
+ || (methods[i].getParameterTypes().length != 0)
+ || (Modifier.isStatic(methods[i].getModifiers()))
+ || (methods[i].getExceptionTypes().length > 0)
+ || (!methods[i].getReturnType().getName().equals("void"))) {
+ throw new IllegalArgumentException("Invalid PreDestroy annotation");
+ }
+ preDestroy = methods[i];
+ }
+ }
+
+ // At the end the postconstruct annotated
+ // method is invoked
+ if (preDestroy != null) {
+ boolean accessibility = preDestroy.isAccessible();
+ preDestroy.setAccessible(true);
+ preDestroy.invoke(managedBean);
+ preDestroy.setAccessible(accessibility);
+ }
} catch (Exception e) {
LOG.error("PreDestroy failed on managed bean.", e);
}
@@ -88,7 +125,29 @@
*/
public void invokePostConstruct(Object managedBean) throws InjectionProviderException {
try {
- annotationProcessor.postConstruct(managedBean);
+ Method[] methods = managedBean.getClass().getDeclaredMethods();
+ Method postConstruct = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].isAnnotationPresent(PostConstruct.class)) {
+ if ((postConstruct != null)
+ || (methods[i].getParameterTypes().length != 0)
+ || (Modifier.isStatic(methods[i].getModifiers()))
+ || (methods[i].getExceptionTypes().length > 0)
+ || (!methods[i].getReturnType().getName().equals("void"))) {
+ throw new IllegalArgumentException("Invalid PostConstruct annotation");
+ }
+ postConstruct = methods[i];
+ }
+ }
+
+ // At the end the postconstruct annotated
+ // method is invoked
+ if (postConstruct != null) {
+ boolean accessibility = postConstruct.isAccessible();
+ postConstruct.setAccessible(true);
+ postConstruct.invoke(managedBean);
+ postConstruct.setAccessible(accessibility);
+ }
} catch (Exception e) {
LOG.error("PostConstruct failed on managed bean.", e);
}
@@ -101,12 +160,122 @@
public void inject(Object managedBean) throws InjectionProviderException {
if (this.namingContext != null) {
try {
- annotationProcessor.processAnnotations(managedBean);
+
+ // Initialize fields annotations
+ Field[] fields = managedBean.getClass().getDeclaredFields();
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].isAnnotationPresent(Resource.class)) {
+ Resource annotation = (Resource) fields[i].getAnnotation(Resource.class);
+ lookupFieldResource(namingContext, managedBean, fields[i], annotation.name());
+ }
+ if (fields[i].isAnnotationPresent(EJB.class)) {
+ EJB annotation = (EJB) fields[i].getAnnotation(EJB.class);
+ lookupFieldResource(namingContext, managedBean, fields[i], annotation.name());
+ }
+ if (fields[i].isAnnotationPresent(WebServiceRef.class)) {
+ WebServiceRef annotation =
+ (WebServiceRef) fields[i].getAnnotation(WebServiceRef.class);
+ lookupFieldResource(namingContext, managedBean, fields[i], annotation.name());
+ }
+ if (fields[i].isAnnotationPresent(PersistenceContext.class)) {
+ PersistenceContext annotation =
+ (PersistenceContext) fields[i].getAnnotation(PersistenceContext.class);
+ lookupFieldResource(namingContext, managedBean, fields[i], annotation.name());
+ }
+ if (fields[i].isAnnotationPresent(PersistenceUnit.class)) {
+ PersistenceUnit annotation =
+ (PersistenceUnit) fields[i].getAnnotation(PersistenceUnit.class);
+ lookupFieldResource(namingContext, managedBean, fields[i], annotation.name());
+ }
+ }
+
+ // Initialize methods annotations
+ Method[] methods = managedBean.getClass().getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].isAnnotationPresent(Resource.class)) {
+ Resource annotation = (Resource) methods[i].getAnnotation(Resource.class);
+ lookupMethodResource(namingContext, managedBean, methods[i], annotation.name());
+ }
+ if (methods[i].isAnnotationPresent(EJB.class)) {
+ EJB annotation = (EJB) methods[i].getAnnotation(EJB.class);
+ lookupMethodResource(namingContext, managedBean, methods[i], annotation.name());
+ }
+ if (methods[i].isAnnotationPresent(WebServiceRef.class)) {
+ WebServiceRef annotation =
+ (WebServiceRef) methods[i].getAnnotation(WebServiceRef.class);
+ lookupMethodResource(namingContext, managedBean, methods[i], annotation.name());
+ }
+ if (methods[i].isAnnotationPresent(PersistenceContext.class)) {
+ PersistenceContext annotation =
+ (PersistenceContext) methods[i].getAnnotation(PersistenceContext.class);
+ lookupMethodResource(namingContext, managedBean, methods[i], annotation.name());
+ }
+ if (methods[i].isAnnotationPresent(PersistenceUnit.class)) {
+ PersistenceUnit annotation =
+ (PersistenceUnit) methods[i].getAnnotation(PersistenceUnit.class);
+ lookupMethodResource(namingContext, managedBean, methods[i], annotation.name());
+ }
+ }
+
} catch (Exception e) {
LOG.error("Injection failed on managed bean.", e);
}
}
}
+
+ /**
+ * Inject resources in specified field.
+ */
+ protected static void lookupFieldResource(javax.naming.Context context,
+ Object instance, Field field, String name)
+ throws NamingException, IllegalAccessException {
+ Object lookedupResource = null;
+ boolean accessibility = false;
+
+ if ((name != null) &&
+ (name.length() > 0)) {
+ lookedupResource = context.lookup(name);
+ } else {
+ lookedupResource = context.lookup(instance.getClass().getName() + "/" + field.getName());
+ }
+
+ accessibility = field.isAccessible();
+ field.setAccessible(true);
+ field.set(instance, lookedupResource);
+ field.setAccessible(accessibility);
+ }
+
+
+ /**
+ * Inject resources in specified method.
+ */
+ protected static void lookupMethodResource(javax.naming.Context context,
+ Object instance, Method method, String name)
+ throws NamingException, IllegalAccessException, InvocationTargetException {
+
+ if (!method.getName().startsWith("set")
+ || method.getParameterTypes().length != 1
+ || !method.getReturnType().getName().equals("void")) {
+ throw new IllegalArgumentException("Invalid method resource injection annotation");
+ }
+
+ Object lookedupResource = null;
+ boolean accessibility = false;
+
+ if ((name != null) &&
+ (name.length() > 0)) {
+ lookedupResource = context.lookup(name);
+ } else {
+ lookedupResource =
+ context.lookup(instance.getClass().getName() + "/" + method.getName().substring(3));
+ }
+
+ accessibility = method.isAccessible();
+ method.setAccessible(true);
+ method.invoke(instance, lookedupResource);
+ method.setAccessible(accessibility);
+ }
+
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -42,13 +42,13 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-import org.apache.AnnotationProcessor;
+import org.apache.InstanceManager;
+import org.apache.catalina.core.StandardContext;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.DependencyPolicy;
import org.jboss.ejb3.DeploymentScope;
-import org.jboss.ejb3.JmxDependencyPolicy;
import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
import org.jboss.ejb3.enc.DeploymentPersistenceUnitResolver;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
@@ -86,7 +86,7 @@
* @author adrian at jboss.org
* @version $Revision: 1.17 $
*/
-public class TomcatInjectionContainer extends AbstractJavaEEComponent implements InjectionContainer, AnnotationProcessor
+public class TomcatInjectionContainer extends AbstractJavaEEComponent implements InjectionContainer, InstanceManager
{
private static final Logger log = Logger.getLogger(TomcatInjectionContainer.class);
@@ -140,14 +140,16 @@
protected ClassLoader webLoader;
protected WebApplication appInfo;
protected WebDD webDD;
+ protected org.apache.catalina.Context catalinaContext;
- public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, MainDeployerStructure mainDeployer)
+ public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, org.apache.catalina.Context catalinaContext, MainDeployerStructure mainDeployer)
{
super(new SimpleJavaEEModule(appInfo.getName()));
this.unit = unit;
DeploymentScope deploymentScope = null;
this.appInfo = appInfo;
+ this.catalinaContext = catalinaContext;
persistenceUnitResolver = new DeploymentPersistenceUnitResolver(persistenceUnitDeployments, deploymentScope, ejbContainers);
ejbResolver = new WarEjbResolver(deploymentScope, unit, mainDeployer);
@@ -158,9 +160,46 @@
return webDD;
}
+ public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
+ Class clazz = catalinaContext.getLoader().getClassLoader().loadClass(className);
+ Object instance = clazz.newInstance();
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ processAnnotations(instance);
+ postConstruct(instance);
+ }
+ return instance;
+ }
+
+ public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
+ Class clazz = classLoader.loadClass(className);
+ Object instance = clazz.newInstance();
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ processAnnotations(instance);
+ postConstruct(instance);
+ }
+ return instance;
+ }
+
+ public void newInstance(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException {
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ processAnnotations(instance);
+ postConstruct(instance);
+ }
+ }
+
+ public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException {
+ if (!catalinaContext.getIgnoreAnnotations())
+ {
+ preDestroy(instance);
+ }
+ }
+
public void postConstruct(Object object) throws IllegalAccessException, InvocationTargetException
{
- // ignore for now
+ // ignore for now
}
public void preDestroy(Object object) throws IllegalAccessException, InvocationTargetException
@@ -180,11 +219,16 @@
*/
public void processAnnotations(Object object) throws IllegalAccessException, InvocationTargetException, NamingException
{
- log.debug("**************** Processing annotations for: " + object.getClass().getName());
+ if (log.isTraceEnabled()) {
+ log.trace("**************** Processing annotations for: " + object.getClass().getName());
+ }
Map<AccessibleObject, Injector> injectors = resolvedClassInjections.get(object.getClass().getName());
if (injectors == null)
{
- log.debug("-- there was no prior annotation preprocessing done");
+ if (log.isTraceEnabled())
+ {
+ log.trace("-- there was no prior annotation preprocessing done");
+ }
encInjectors.recordAdded();
// let's assume this is a JSP or some other artifact that cannot be found within XML
injectors = InjectionUtil.processAnnotations(this, handlers, object.getClass());
@@ -202,11 +246,17 @@
}
if (injectors == null || injectors.size() == 0)
{
- log.debug("-- no injectors found: " + injectors);
+ if (log.isTraceEnabled())
+ {
+ log.trace("-- no injectors found: " + injectors);
+ }
return;
}
- log.debug("-- doing injections");
+ if (log.isTraceEnabled())
+ {
+ log.trace("-- doing injections");
+ }
for (Injector injector : injectors.values())
{
injector.inject(object);
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -444,6 +444,11 @@
System.setProperty("catalina.ext.dirs",
(System.getProperty("jboss.server.home.dir")
+ File.separator + "lib"));
+
+ // Strict servlet compliance
+ System.setProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "true");
+ // Delay connector startup
+ System.setProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "true");
String objectNameS = catalinaDomain + ":type=server";
ObjectName objectName = new ObjectName(objectNameS);
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -164,8 +164,6 @@
ClassLoader loader = Thread.currentThread().getContextClassLoader();
metaData.setContextLoader(loader);
- injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), mainDeployer);
-
Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
if (webLoader == null)
webLoader = getWebLoader(webApp.getDeploymentUnit(), metaData, loader, url);
@@ -182,6 +180,8 @@
StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
Registry.getRegistry().registerComponent(context, objectName, config.getContextClassName());
+ injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), context, mainDeployer);
+
// Find and set warInfo file on the context
// If WAR is packed, expand warInfo file to temp folder
String ctxConfig = null;
@@ -199,7 +199,7 @@
resources.setVirtualFile(webApp.getDeploymentUnit().getFile(""));
context.setResources(resources);
- context.setAnnotationProcessor(injectionContainer);
+ context.setInstanceManager(injectionContainer);
context.setDocBase(url.getFile());
context.setConfigFile(ctxConfig);
context.setDefaultContextXml("context.xml");
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment2.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment2.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment2.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -1,675 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.web.tomcat.service.deployers;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.security.CodeSource;
-import java.security.cert.Certificate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-
-import org.apache.catalina.Loader;
-import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.WebMetaData;
-import org.jboss.metadata.serviceref.ServiceRefDelegate;
-import org.jboss.metadata.serviceref.VirtualFileAdaptor;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.naming.NonSerializableFactory;
-import org.jboss.security.AuthorizationManager;
-import org.jboss.security.SecurityUtil;
-import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.web.WebApplication;
-import org.jboss.web.deployers.AbstractWarDeployment;
-import org.jboss.web.tomcat.security.JaccContextValve;
-import org.jboss.web.tomcat.security.RunAsListener;
-import org.jboss.web.tomcat.security.SecurityAssociationValve;
-import org.jboss.web.tomcat.service.TomcatInjectionContainer;
-import org.jboss.web.tomcat.service.WebAppLoader;
-import org.jboss.web.tomcat.service.WebCtxLoader;
-import org.jboss.web.tomcat.service.session.AbstractJBossManager;
-import org.jboss.web.tomcat.service.session.ClusteringNotSupportedException;
-import org.jboss.web.tomcat.service.session.JBossCacheManager;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
-import org.omg.CORBA.ORB;
-
-/**
- * A tomcat web application deployment.
- *
- * @author Scott.Stark at jboss.org
- * @author Costin Manolache
- * @author adrian at jboss.org
- * @version $Revision: 56605 $
- */
-public class TomcatDeployment2 extends AbstractWarDeployment
-{
- private static final Logger log = Logger.getLogger(TomcatDeployment2.class);
-
- /**
- * The name of the war level context configuration descriptor
- */
- private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
-
- private DeployerConfig config;
- private String[] javaVMs = { " jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost" };
- private String serverName = "jboss";
- private HashMap vhostToHostNames = new HashMap();
- private ORB orb = null;
- private TomcatInjectionContainer injectionContainer;
-
- public ORB getORB()
- {
- return orb;
- }
-
- public void setORB(ORB orb)
- {
- this.orb = orb;
- }
-
- @Override
- public void init(Object containerConfig) throws Exception
- {
- this.config = (DeployerConfig)containerConfig;
- super.setJava2ClassLoadingCompliance(config.isJava2ClassLoadingCompliance());
- super.setUnpackWars(config.isUnpackWars());
- super.setLenientEjbLink(config.isLenientEjbLink());
- super.setDefaultSecurityDomain(config.getDefaultSecurityDomain());
- }
-
- @Override
- protected void performDeploy(WebApplication webApp, String warUrl) throws Exception
- {
- // Decode the URL as tomcat can't deal with paths with escape chars
- warUrl = URLDecoder.decode(warUrl, "UTF-8");
- webApp.setDomain(config.getCatalinaDomain());
- WebMetaData metaData = webApp.getMetaData();
- String hostName = null;
- // Get any jboss-web/virtual-hosts
- Iterator vhostNames = metaData.getVirtualHosts();
- // Map the virtual hosts onto the configured hosts
- Iterator hostNames = mapVirtualHosts(vhostNames);
- if (hostNames.hasNext())
- {
- hostName = hostNames.next().toString();
- }
- performDeployInternal(hostName, webApp, warUrl);
- while (hostNames.hasNext())
- {
- String additionalHostName = hostNames.next().toString();
- performDeployInternal(additionalHostName, webApp, warUrl);
- }
- }
-
- protected void performDeployInternal(String hostName, WebApplication webApp, String warUrl) throws Exception
- {
- VFSDeploymentUnit unit = webApp.getDeploymentUnit();
- WebMetaData metaData = webApp.getMetaData();
- String ctxPath = metaData.getContextRoot();
- if (ctxPath.equals("/") || ctxPath.equals("/ROOT") || ctxPath.equals(""))
- {
- log.debug("deploy root context=" + ctxPath);
- ctxPath = "/";
- metaData.setContextRoot(ctxPath);
- }
-
- log.info("deploy, ctxPath=" + ctxPath + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
-
- URL url = new URL(warUrl);
-
- ClassLoader threadContextLoader = Thread.currentThread().getContextClassLoader();
- metaData.setContextLoader(threadContextLoader);
-
- injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), mainDeployer);
-
- Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
- if (webLoader == null)
- webLoader = getWebLoader(webApp.getDeploymentUnit(), threadContextLoader, url);
-
- webApp.setName(url.getPath());
- webApp.setClassLoader(threadContextLoader);
- webApp.setURL(url);
-
- String objectNameS = config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
- + ",J2EEApplication=none,J2EEServer=none";
-
- ObjectName objectName = new ObjectName(objectNameS);
-
- String contextClassName = config.getContextClassName();
- Registry.getRegistry().registerComponent(Class.forName(contextClassName).newInstance(), objectName, contextClassName);
-
- // Find and set warInfo file on the context
- // If WAR is packed, expand warInfo file to temp folder
- String ctxConfig = null;
- try
- {
- // TODO: this should be input metadata
- ctxConfig = findConfig(url);
- }
- catch (IOException e)
- {
- log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
- }
-
- if (injectionContainer != null)
- {
- server.setAttribute(objectName, new Attribute("annotationProcessor", injectionContainer));
- }
-
- server.setAttribute(objectName, new Attribute("docBase", url.getFile()));
-
- server.setAttribute(objectName, new Attribute("configFile", ctxConfig));
-
- server.setAttribute(objectName, new Attribute("defaultContextXml", "context.xml"));
- server.setAttribute(objectName, new Attribute("defaultWebXml", "conf/web.xml"));
- // If there is an alt-dd set it
- if (metaData.getAltDDPath() != null)
- {
- String altPath = metaData.getAltDDPath();
- log.debug("Setting altDDName to: " + altPath);
- server.setAttribute(objectName, new Attribute("altDDName", altPath));
- }
-
- server.setAttribute(objectName, new Attribute("javaVMs", javaVMs));
-
- server.setAttribute(objectName, new Attribute("server", serverName));
-
- server.setAttribute(objectName, new Attribute("saveConfig", Boolean.FALSE));
-
- if (webLoader != null)
- {
- server.setAttribute(objectName, new Attribute("loader", webLoader));
- }
- else
- {
- server.setAttribute(objectName, new Attribute("parentClassLoader", threadContextLoader));
- }
-
- server.setAttribute(objectName, new Attribute("delegate", new Boolean(webApp.getJava2ClassLoadingCompliance())));
-
- String[] jspCP = getCompileClasspath(threadContextLoader);
- StringBuffer classpath = new StringBuffer();
- for (int u = 0; u < jspCP.length; u++)
- {
- String repository = jspCP[u];
- if (repository == null)
- continue;
- if (repository.startsWith("file://"))
- repository = repository.substring(7);
- else if (repository.startsWith("file:"))
- repository = repository.substring(5);
- else continue;
- if (repository == null)
- continue;
- // ok it is a file. Make sure that is is a directory or jar file
- File fp = new File(repository);
- if (!fp.isDirectory())
- {
- // if it is not a directory, try to open it as a zipfile.
- try
- {
- // avoid opening .xml files
- if (fp.getName().toLowerCase().endsWith(".xml"))
- continue;
-
- ZipFile zip = new ZipFile(fp);
- zip.close();
- }
- catch (IOException e)
- {
- continue;
- }
-
- }
- if (u > 0)
- classpath.append(File.pathSeparator);
- classpath.append(repository);
- }
-
- server.setAttribute(objectName, new Attribute("compilerClasspath", classpath.toString()));
-
- // Set the session cookies flag according to metadata
- switch (metaData.getSessionCookies())
- {
- case WebMetaData.SESSION_COOKIES_ENABLED:
- server.setAttribute(objectName, new Attribute("cookies", new Boolean(true)));
- log.debug("Enabling session cookies");
- break;
- case WebMetaData.SESSION_COOKIES_DISABLED:
- server.setAttribute(objectName, new Attribute("cookies", new Boolean(false)));
- log.debug("Disabling session cookies");
- break;
- default:
- log.debug("Using session cookies default setting");
- }
-
- // Add a valve to estalish the JACC context before authorization valves
- Certificate[] certs = null;
- CodeSource cs = new CodeSource(url, certs);
- JaccContextValve jaccValve = new JaccContextValve(metaData, cs);
- server.invoke(objectName, "addValve", new Object[] { jaccValve }, new String[] { "org.apache.catalina.Valve" });
-
- // Pass the metadata to the RunAsListener via a thread local
- RunAsListener.metaDataLocal.set(metaData);
- try
- {
- // Init the container; this will also start it
- server.invoke(objectName, "init", new Object[] {}, new String[] {});
- }
- finally
- {
- RunAsListener.metaDataLocal.set(null);
- }
-
- // make the context class loader known to the WebMetaData, ws4ee needs it
- // to instanciate service endpoint pojos that live in this webapp
- Loader ctxLoader = (Loader)server.getAttribute(objectName, "loader");
- metaData.setContextLoader(ctxLoader.getClassLoader());
-
- // Start it
- server.invoke(objectName, "start", new Object[] {}, new String[] {});
- // Build the ENC
-
- ClassLoader webappClassLoader = webLoader.getClassLoader();
- if (injectionContainer == null)
- {
- super.processEnc(webappClassLoader, webApp);
- }
- else
- {
- Thread currentThread = Thread.currentThread();
- ClassLoader currentLoader = threadContextLoader;
- try
- {
- // Create a java:comp/env environment unique for the web application
- log.debug("Creating ENC using ClassLoader: " + threadContextLoader);
- ClassLoader parent = threadContextLoader.getParent();
- while (parent != null)
- {
- log.debug(".." + parent);
- parent = parent.getParent();
- }
- // TODO: The enc should be an input?
- currentThread.setContextClassLoader(webappClassLoader);
- metaData.setENCLoader(webappClassLoader);
- InitialContext iniCtx = new InitialContext();
- Context envCtx = (Context)iniCtx.lookup("java:comp");
- // Add ORB/UserTransaction
- ORB orb = null;
- try
- {
- ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB");
- orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
- // Bind the orb
- if (orb != null)
- {
- NonSerializableFactory.rebind(envCtx, "ORB", orb);
- log.debug("Bound java:comp/ORB");
- }
- }
- catch (Throwable t)
- {
- log.debug("Unable to retrieve orb" + t.toString());
- }
-
- // JTA links
- envCtx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
- log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
- envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
- log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
-
- envCtx = envCtx.createSubcontext("env");
- injectionContainer.populateEnc(webappClassLoader);
-
- // TODO: this should be bindings in the metadata
- currentThread.setContextClassLoader(webappClassLoader);
- String securityDomain = metaData.getSecurityDomain();
- log.debug("linkSecurityDomain");
- linkSecurityDomain(securityDomain, envCtx);
-
- // Bind <service-ref> elements
- UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
- EnvironmentRefGroup envRefGroup = injectionContainer.getEnvironmentRefGroup();
- for (ServiceRefMetaData sref : metaData.getServiceRefs().values())
- {
- String refName = sref.getServiceRefName();
- ServiceRefMetaData injectedRef = envRefGroup.getServiceRef(refName);
- if (injectedRef == null || injectedRef.isProcessed() == false)
- {
- new ServiceRefDelegate().bindServiceRef(envCtx, refName, vfsRoot, webappClassLoader, sref);
- }
- }
- }
- finally
- {
- currentThread.setContextClassLoader(currentLoader);
- }
- }
-
- // Clustering
- if (metaData.getDistributable())
- {
- // Try to initate clustering, fallback to standard if no clustering is
- // available
- try
- {
- AbstractJBossManager manager = null;
- String managerClassName = config.getManagerClass();
- Class managerClass = Thread.currentThread().getContextClassLoader().loadClass(managerClassName);
- manager = (AbstractJBossManager)managerClass.newInstance();
- String name = "//" + ((hostName == null) ? "localhost" : hostName) + ctxPath;
- manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache());
-
- if (manager instanceof JBossCacheManager)
- {
- String snapshotMode = config.getSnapshotMode();
- int snapshotInterval = config.getSnapshotInterval();
- JBossCacheManager jbcm = (JBossCacheManager)manager;
- jbcm.setSnapshotMode(snapshotMode);
- jbcm.setSnapshotInterval(snapshotInterval);
- }
-
- server.setAttribute(objectName, new Attribute("manager", manager));
-
- log.debug("Enabled clustering support for ctxPath=" + ctxPath);
- }
- catch (ClusteringNotSupportedException e)
- {
- // JBAS-3513 Just log a WARN, not an ERROR
- log.warn("Failed to setup clustering, clustering disabled. ClusteringNotSupportedException: " + e.getMessage());
- }
- catch (NoClassDefFoundError ncdf)
- {
- // JBAS-3513 Just log a WARN, not an ERROR
- log.debug("Classes needed for clustered webapp unavailable", ncdf);
- log.warn("Failed to setup clustering, clustering disabled. NoClassDefFoundError: " + ncdf.getMessage());
- }
- catch (Throwable t)
- {
- // TODO consider letting this through and fail the deployment
- log.error("Failed to setup clustering, clustering disabled. Exception: ", t);
- }
- }
-
- /*
- * Add security association valve after the authorization valves so that
- * the authenticated user may be associated with the request
- * thread/session.
- */
- SecurityAssociationValve valve = new SecurityAssociationValve(metaData, config.getSecurityManagerService());
- valve.setSubjectAttributeName(config.getSubjectAttributeName());
- server.invoke(objectName, "addValve", new Object[] { valve }, new String[] { "org.apache.catalina.Valve" });
-
- /* TODO: Retrieve the state, and throw an exception in case of a failure
- Integer state = (Integer) server.getAttribute(objectName, "state");
- if (state.intValue() != 1)
- {
- throw new DeploymentException("URL " + warUrl + " deployment failed");
- }
- */
-
- webApp.setAppData(objectName);
-
- /*
- * TODO: Create mbeans for the servlets ObjectName servletQuery = new
- * ObjectName (config.getCatalinaDomain() + ":j2eeType=Servlet,WebModule=" +
- * objectName.getKeyProperty("name") + ",*"); Iterator iterator =
- * server.queryMBeans(servletQuery, null).iterator(); while
- * (iterator.hasNext()) {
- * di.mbeans.add(((ObjectInstance)iterator.next()).getObjectName()); }
- */
-
- if (metaData.getSecurityDomain() != null)
- {
- String secDomain = SecurityUtil.unprefixSecurityDomain(metaData.getSecurityDomain());
- // Associate the Context Id with the Security Domain
- String contextID = metaData.getJaccContextID();
-
- //Check if an xacml policy file is present
- URL xacmlPolicyFile = this.config.getXacmlPolicyURL();
- if (xacmlPolicyFile != null)
- {
- AuthorizationManager authzmgr = SecurityUtil.getAuthorizationManager(secDomain);
- if (authzmgr instanceof PolicyRegistration)
- {
- PolicyRegistration xam = (PolicyRegistration)authzmgr;
- xam.registerPolicy(contextID, xacmlPolicyFile);
- }
- }
- }
-
- log.debug("Initialized: " + webApp + " " + objectName);
- }
-
- public Loader getWebLoader(VFSDeploymentUnit unit, ClassLoader loader, URL url) throws MalformedURLException
- {
- Loader webLoader = null;
-
- /*
- * If we are using the jboss class loader we need to augment its path to
- * include the WEB-INF/{lib,classes} dirs or else scoped class loading
- * does not see the war level overrides. The call to setWarURL adds these
- * paths to the deployment UCL.
- */
- ArrayList<URL> classpath = (ArrayList<URL>)unit.getAttachment("org.jboss.web.expandedWarClasspath");
- if (classpath == null)
- {
- try
- {
- VirtualFile classes = unit.getFile("WEB-INF/classes");
- // Tomcat can't handle the vfs urls yet
- URL vfsURL = classes.toURL();
- String vfsurl = vfsURL.toString();
- if (vfsurl.startsWith("vfs"))
- vfsURL = new URL(vfsurl.substring(3));
- classpath = new ArrayList<URL>();
- classpath.add(classes.toURL());
- }
- catch (Exception e)
- {
-
- }
- }
-
- if (config.isUseJBossWebLoader())
- {
- WebCtxLoader jbossLoader = new WebCtxLoader(loader, injectionContainer);
- if (classpath != null)
- jbossLoader.setClasspath(classpath);
- webLoader = jbossLoader;
- }
- else
- {
- String[] pkgs = config.getFilteredPackages();
- WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs, injectionContainer);
- jbossLoader.setDelegate(getJava2ClassLoadingCompliance());
- if (classpath != null)
- jbossLoader.setClasspath(classpath);
- webLoader = jbossLoader;
- }
- return webLoader;
- }
-
- public void setInjectionContainer(TomcatInjectionContainer container)
- {
- this.injectionContainer = container;
- }
-
- /**
- * Called as part of the undeploy() method template to ask the subclass for
- * perform the web container specific undeployment steps.
- */
- protected void performUndeploy(WebApplication warInfo, String warUrl) throws Exception
- {
- if (warInfo == null)
- {
- log.debug("performUndeploy, no WebApplication found for URL " + warUrl);
- return;
- }
-
- log.info("undeploy, ctxPath=" + warInfo.getMetaData().getContextRoot() + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
-
- WebMetaData metaData = warInfo.getMetaData();
- String hostName = null;
- Iterator hostNames = metaData.getVirtualHosts();
- if (hostNames.hasNext())
- {
- hostName = hostNames.next().toString();
- }
- performUndeployInternal(hostName, warUrl, warInfo);
- while (hostNames.hasNext())
- {
- String additionalHostName = hostNames.next().toString();
- performUndeployInternal(additionalHostName, warUrl, warInfo);
- }
-
- }
-
- protected void performUndeployInternal(String hostName, String warUrl, WebApplication warInfo) throws Exception
- {
-
- WebMetaData metaData = warInfo.getMetaData();
- String ctxPath = metaData.getContextRoot();
-
- // TODO: Need to remove the dependency on MBeanServer
- MBeanServer server = MBeanServerLocator.locateJBoss();
- // If the server is gone, all apps were stopped already
- if (server == null)
- return;
-
- ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
- + ",J2EEApplication=none,J2EEServer=none");
-
- if (server.isRegistered(objectName))
- {
- // Contexts should be stopped by the host already
- server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
- }
-
- }
-
- /**
- * Resolve the input virtual host names to the names of the configured Hosts
- * @param vhostNames Iterator<String> for the jboss-web/virtual-host elements
- * @return Iterator<String> of the unique Host names
- * @throws Exception
- */
- protected synchronized Iterator mapVirtualHosts(Iterator vhostNames) throws Exception
- {
- if (vhostToHostNames.size() == 0)
- {
- // Query the configured Host mbeans
- String hostQuery = config.getCatalinaDomain() + ":type=Host,*";
- ObjectName query = new ObjectName(hostQuery);
- Set hosts = server.queryNames(query, null);
- Iterator iter = hosts.iterator();
- while (iter.hasNext())
- {
- ObjectName host = (ObjectName)iter.next();
- String name = host.getKeyProperty("host");
- if (name != null)
- {
- vhostToHostNames.put(name, name);
- String[] aliases = (String[])server.invoke(host, "findAliases", null, null);
- int count = aliases != null ? aliases.length : 0;
- for (int n = 0; n < count; n++)
- {
- vhostToHostNames.put(aliases[n], name);
- }
- }
- }
- }
-
- // Map the virtual host names to the hosts
- HashSet hosts = new HashSet();
- while (vhostNames.hasNext())
- {
- String vhost = (String)vhostNames.next();
- String host = (String)vhostToHostNames.get(vhost);
- if (host == null)
- {
- log.warn("Failed to map vhost: " + vhost);
- // This will cause a new host to be created
- host = vhost;
- }
- hosts.add(host);
- }
- return hosts.iterator();
- }
-
- private String findConfig(URL warURL) throws IOException
- {
- String result = null;
- // See if the warUrl is a dir or a file
- File warFile = new File(warURL.getFile());
- if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
- {
- File webDD = new File(warFile, CONTEXT_CONFIG_FILE);
- if (webDD.exists() == true)
- result = webDD.getAbsolutePath();
- }
- else
- {
- ZipFile zipFile = new ZipFile(warFile);
- ZipEntry entry = zipFile.getEntry(CONTEXT_CONFIG_FILE);
- if (entry != null)
- {
- InputStream zipIS = zipFile.getInputStream(entry);
- byte[] buffer = new byte[512];
- int bytes;
- result = warFile.getAbsolutePath() + "-context.xml";
- FileOutputStream fos = new FileOutputStream(result);
- while ((bytes = zipIS.read(buffer)) > 0)
- {
- fos.write(buffer, 0, bytes);
- }
- zipIS.close();
- fos.close();
- }
- zipFile.close();
- }
- return result;
- }
-
-}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/ClusteredSingleSignOn.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/ClusteredSingleSignOn.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/ClusteredSingleSignOn.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -464,7 +464,7 @@
// Look up the cached Principal associated with this cookie value
if (getContainer().getLogger().isDebugEnabled())
getContainer().getLogger().debug(" Checking for cached principal for " + cookie.getValue());
- SingleSignOnEntry entry = getSingleSignOnEntry(cookie.getValue());
+ JBossSingleSignOnEntry entry = getSingleSignOnEntry(cookie.getValue());
if (entry != null)
{
Principal ssoPrinc = entry.getPrincipal();
@@ -517,10 +517,10 @@
if (getContainer().getLogger().isDebugEnabled())
getContainer().getLogger().debug("Associate sso id " + ssoId + " with session " + session);
- SingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
+ JBossSingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
boolean added = false;
if (sso != null)
- added = sso.addSession(this, session);
+ added = sso.addSession2(this, session);
synchronized (reverse)
{
@@ -589,11 +589,11 @@
reverse.remove(session);
}
- SingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
+ JBossSingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
if (sso == null)
return;
- boolean removed = sso.removeSession(session);
+ boolean removed = sso.removeSession2(session);
// If we changed anything, notify any cluster
if (removed && ssoClusterManager != null)
{
@@ -606,7 +606,7 @@
{
synchronized (cache)
{
- sso = (SingleSignOnEntry) cache.remove(ssoId);
+ sso = (JBossSingleSignOnEntry) cache.remove(ssoId);
}
}
}
@@ -624,10 +624,10 @@
getContainer().getLogger().debug("Deregistering sso id '" + ssoId + "'");
// Look up and remove the corresponding SingleSignOnEntry
- SingleSignOnEntry sso = null;
+ JBossSingleSignOnEntry sso = null;
synchronized (cache)
{
- sso = (SingleSignOnEntry) cache.remove(ssoId);
+ sso = (JBossSingleSignOnEntry) cache.remove(ssoId);
}
if (sso == null)
@@ -675,9 +675,9 @@
*
* @param ssoId Single sign on identifier to look up
*/
- protected SingleSignOnEntry getSingleSignOnEntry(String ssoId)
+ protected JBossSingleSignOnEntry getSingleSignOnEntry(String ssoId)
{
- SingleSignOnEntry sso = localLookup(ssoId);
+ JBossSingleSignOnEntry sso = localLookup(ssoId);
// If we don't have one locally and there is a cluster,
// query the cluster for the SSO
if (sso == null && ssoClusterManager != null)
@@ -725,7 +725,7 @@
boolean reauthenticated = false;
- SingleSignOnEntry entry = getSingleSignOnEntry(ssoId);
+ JBossSingleSignOnEntry entry = getSingleSignOnEntry(ssoId);
if (entry != null && entry.getCanReauthenticate())
{
@@ -792,12 +792,12 @@
" from sso id " + ssoId);
// Get a reference to the SingleSignOn
- SingleSignOnEntry entry = getSingleSignOnEntry(ssoId);
+ JBossSingleSignOnEntry entry = getSingleSignOnEntry(ssoId);
if (entry == null)
return;
// Remove the inactive session from SingleSignOnEntry
- boolean removed = entry.removeSession(session);
+ boolean removed = entry.removeSession2(session);
// If we changed anything, notify any cluster
if (removed && ssoClusterManager != null)
{
@@ -870,11 +870,11 @@
* @return any SingleSignOnEntry associated with the given id, or
* <code>null</code> if there is none.
*/
- SingleSignOnEntry localLookup(String ssoId)
+ JBossSingleSignOnEntry localLookup(String ssoId)
{
synchronized (cache)
{
- return ((SingleSignOnEntry) cache.get(ssoId));
+ return ((JBossSingleSignOnEntry) cache.get(ssoId));
}
}
@@ -902,7 +902,7 @@
synchronized (cache)
{
- cache.put(ssoId, new SingleSignOnEntry(principal, authType,
+ cache.put(ssoId, new JBossSingleSignOnEntry(principal, authType,
username, password));
}
}
@@ -926,7 +926,7 @@
{
boolean shouldBroadcast = false;
- SingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
+ JBossSingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
// Only update if the entry is missing information
if (sso != null)
{
@@ -937,7 +937,7 @@
synchronized (sso)
{
- shouldBroadcast = sso.updateCredentials(principal, authType,
+ shouldBroadcast = sso.updateCredentials2(principal, authType,
username, password);
}
}
@@ -963,7 +963,7 @@
void remoteUpdate(String ssoId, String authType,
String username, String password)
{
- SingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
+ JBossSingleSignOnEntry sso = getSingleSignOnEntry(ssoId);
// Only update if the entry is missing information
if (sso != null && sso.getCanReauthenticate() == false)
{
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SSOClusterManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SSOClusterManager.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SSOClusterManager.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -82,7 +82,7 @@
* found on another cluster node, or <code>null</code> if no
* entry could be found.
*/
- SingleSignOnEntry lookup(String ssoId);
+ JBossSingleSignOnEntry lookup(String ssoId);
/**
* Notifies the cluster of the creation of a new SSO entry.
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SingleSignOnEntry.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SingleSignOnEntry.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/SingleSignOnEntry.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -20,6 +20,7 @@
import org.apache.catalina.Session;
import org.apache.catalina.authenticator.Constants;
import org.apache.catalina.authenticator.SingleSignOn;
+import org.apache.catalina.authenticator.SingleSignOnEntry;
/**
* A class that represents entries in the cache of authenticated users.
@@ -28,40 +29,15 @@
* @version $Revision: 45726 $ $Date: 2006-06-21 21:50:00 +0200 (mer., 21 juin 2006) $
* @see SingleSignOn
*/
-class SingleSignOnEntry
+class JBossSingleSignOnEntry extends SingleSignOnEntry
{
- // ------------------------------------------------------ Instance Fields
- private String authType = null;
-
- private String password = null;
-
- private Principal principal = null;
-
- private Session sessions[] = new Session[0];
-
- private String username = null;
-
- private boolean canReauthenticate = false;
-
- // --------------------------------------------------------- Constructors
-
- /**
- * Creates a new SingleSignOnEntry
- *
- * @param principal the <code>Principal</code> returned by the latest
- * call to <code>Realm.authenticate</code>.
- * @param authType the type of authenticator used (BASIC, CLIENT-CERT,
- * DIGEST or FORM)
- * @param username the username (if any) used for the authentication
- * @param password the password (if any) used for the authentication
- */
- SingleSignOnEntry(Principal principal, String authType,
- String username, String password)
- {
- updateCredentials(principal, authType, username, password);
- }
-
+ public JBossSingleSignOnEntry(Principal principal, String authType,
+ String username, String password)
+ {
+ super(principal, authType, username, password);
+ }
+
// ------------------------------------------------------- Package Methods
/**
@@ -75,7 +51,7 @@
* was not previously associated with this entry);
* <code>false</code> otherwise.
*/
- synchronized boolean addSession(SingleSignOn sso, Session session)
+ synchronized boolean addSession2(SingleSignOn sso, Session session)
{
for (int i = 0; i < sessions.length; i++)
{
@@ -99,7 +75,7 @@
* (i.e. was in fact previously associated with this entry);
* <code>false</code> otherwise.
*/
- synchronized boolean removeSession(Session session)
+ synchronized boolean removeSession2(Session session)
{
if (sessions.length == 0)
return false;
@@ -132,7 +108,7 @@
/**
* Returns the <code>Session</code>s associated with this SSO.
*/
- synchronized Session[] findSessions()
+ public synchronized Session[] findSessions()
{
return (this.sessions);
}
@@ -143,7 +119,7 @@
*
* @return "BASIC", "CLIENT-CERT", "DIGEST", "FORM" or "NONE"
*/
- String getAuthType()
+ public String getAuthType()
{
return (this.authType);
}
@@ -155,7 +131,7 @@
* @return <code>true</code> if <code>getAuthType</code> returns
* "BASIC" or "FORM", <code>false</code> otherwise.
*/
- boolean getCanReauthenticate()
+ public boolean getCanReauthenticate()
{
return (this.canReauthenticate);
}
@@ -167,7 +143,7 @@
* <code>null</code> if the original authentication type
* does not involve a password.
*/
- String getPassword()
+ public String getPassword()
{
return (this.password);
}
@@ -189,7 +165,7 @@
* the local SSO, or <code>null</code> if no authentication
* has been performed yet in this cluster node.
*/
- Principal getPrincipal()
+ public Principal getPrincipal()
{
return (this.principal);
}
@@ -216,12 +192,19 @@
* Gets the username provided by the user as part of the authentication
* process.
*/
- String getUsername()
+ public String getUsername()
{
return (this.username);
}
+ public void updateCredentials(Principal principal, String authType,
+ String username, String password)
+ {
+ updateCredentials2(principal, authType, username, password);
+ }
+
+
/**
* Updates the SingleSignOnEntry to reflect the latest security
* information associated with the caller.
@@ -233,7 +216,7 @@
* @param username the username (if any) used for the authentication
* @param password the password (if any) used for the authentication
*/
- synchronized boolean updateCredentials(Principal principal, String authType,
+ public synchronized boolean updateCredentials2(Principal principal, String authType,
String username, String password)
{
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java 2007-09-03 14:03:36 UTC (rev 65011)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java 2007-09-03 14:06:55 UTC (rev 65012)
@@ -419,14 +419,14 @@
* found on another cluster node, or <code>null</code> if no
* entry could be found.
*/
- public SingleSignOnEntry lookup(String ssoId)
+ public JBossSingleSignOnEntry lookup(String ssoId)
{
if (!checkTreeCacheAvailable())
{
return null;
}
- SingleSignOnEntry entry = null;
+ JBossSingleSignOnEntry entry = null;
// Find the latest credential info from the cluster
Fqn fqn = getCredentialsFqn(ssoId);
try
@@ -434,7 +434,7 @@
SSOCredentials data = (SSOCredentials) getFromTreeCache(fqn);
if (data != null)
{
- entry = new SingleSignOnEntry(null,
+ entry = new JBossSingleSignOnEntry(null,
data.getAuthType(),
data.getUsername(),
data.getPassword());
@@ -688,7 +688,7 @@
return;
}
- SingleSignOnEntry sso = ssoValve.localLookup(ssoId);
+ JBossSingleSignOnEntry sso = ssoValve.localLookup(ssoId);
if (sso == null || sso.getCanReauthenticate())
{
// No reason to update
More information about the jboss-cvs-commits
mailing list