User: starksm
Date: 01/11/12 11:32:56
Modified: src/main/org/jboss/web Tag: Branch_2_4
AbstractWebContainer.java
AbstractWebContainerMBean.java
Log:
Add support for resource-env-ref to WebMetaData and AbstractWebContainer.
Added an empty importXml(Element) method to AbstractWebContainer so that
subclasses can import arbitrary configuration data.
Revision Changes Path
No revision
No revision
1.4.4.7 +68 -27 jboss/src/main/org/jboss/web/AbstractWebContainer.java
Index: AbstractWebContainer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/web/AbstractWebContainer.java,v
retrieving revision 1.4.4.6
retrieving revision 1.4.4.7
diff -u -r1.4.4.6 -r1.4.4.7
--- AbstractWebContainer.java 2001/11/05 04:09:37 1.4.4.6
+++ AbstractWebContainer.java 2001/11/12 19:32:56 1.4.4.7
@@ -19,6 +19,7 @@
import org.jboss.deployment.DeploymentException;
import org.jboss.metadata.EjbRefMetaData;
import org.jboss.metadata.EnvEntryMetaData;
+import org.jboss.metadata.ResourceEnvRefMetaData;
import org.jboss.metadata.ResourceRefMetaData;
import org.jboss.metadata.WebMetaData;
import org.jboss.naming.Util;
@@ -71,22 +72,22 @@
An outline of the steps for authorizing the user is:
<code>
- // Get the username & required roles from the request context...
- String username = f(request);
- String[] roles = f(request);
- // Get the JBoss security manager from the ENC context
- InitialContext iniCtx = new InitialContext();
- RealmMapping securityMgr = (RealmMapping)
iniCtx.lookup("java:comp/env/security/realmMapping");
- SimplePrincipal principal = new SimplePrincipal(username);
- Set requiredRoles = new HashSet(Arrays.asList(roles));
- if( securityMgr.doesUserHaveRole(principal, requiredRoles) )
- {
- // Indicate the user has the required roles for the web content...
- }
- else
- {
- // Deny access...
- }
+ // Get the username & required roles from the request context...
+ String username = f(request);
+ String[] roles = f(request);
+ // Get the JBoss security manager from the ENC context
+ InitialContext iniCtx = new InitialContext();
+ RealmMapping securityMgr = (RealmMapping)
iniCtx.lookup("java:comp/env/security/realmMapping");
+ SimplePrincipal principal = new SimplePrincipal(username);
+ Set requiredRoles = new HashSet(Arrays.asList(roles));
+ if( securityMgr.doesUserHaveRole(principal, requiredRoles) )
+ {
+ // Indicate the user has the required roles for the web content...
+ }
+ else
+ {
+ // Deny access...
+ }
</code>
The one thing to be aware of is the relationship between the thread context
@@ -114,7 +115,7 @@
@see org.jboss.security.SecurityAssociation;
@author [EMAIL PROTECTED]
-@version $Revision: 1.4.4.6 $
+@version $Revision: 1.4.4.7 $
*/
public abstract class AbstractWebContainer extends ServiceMBeanSupport implements
AbstractWebContainerMBean
{
@@ -190,9 +191,6 @@
thread.setContextClassLoader(warLoader);
WebDescriptorParser webAppParser = new DescriptorParser();
WebApplication warInfo = performDeploy(ctxPath, warUrl, webAppParser);
- ClassLoader loader = warInfo.getClassLoader();
- Element webApp = warInfo.getWebApp();
- Element jbossWeb = warInfo.getJbossWeb();
deploymentMap.put(warUrl, warInfo);
}
catch(DeploymentException e)
@@ -248,6 +246,9 @@
throw new DeploymentException("Error during deploy", e);
}
}
+ /** Called as part of the undeploy() method template to ask the
+ subclass for perform the web container specific undeployment steps.
+ */
protected abstract void performUndeploy(String warUrl) throws Exception;
/** See if a war is deployed.
*/
@@ -275,6 +276,14 @@
return deploymentMap.values().iterator();
}
+ /** This method is invoked to import an arbitrary XML configuration tree.
+ Subclasses should override this method if they support such a configuration
+ capability. This implementation does nothing.
+ */
+ public void importXml(Element config)
+ {
+ }
+
/** This method is invoked from within subclass performDeploy() method
implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().
@@ -312,6 +321,9 @@
Iterator envEntries = metaData.getEnvironmentEntries();
category.debug("addEnvEntries");
addEnvEntries(envEntries, envCtx);
+ Iterator resourceEnvRefs = metaData.getResourceEnvReferences();
+ category.debug("linkResourceEnvRefs");
+ linkResourceEnvRefs(resourceEnvRefs, envCtx);
Iterator resourceRefs = metaData.getResourceReferences();
category.debug("linkResourceRefs");
linkResourceRefs(resourceRefs, envCtx);
@@ -335,13 +347,13 @@
}
}
- protected void linkResourceRefs(Iterator resourceRefs, Context envCtx)
- throws NamingException
- {
- while( resourceRefs.hasNext() )
+ protected void linkResourceEnvRefs(Iterator resourceEnvRefs, Context envCtx)
+ throws NamingException
+ {
+ while( resourceEnvRefs.hasNext() )
{
- ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
- String resourceName = ref.getResourceName();
+ ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData)
resourceEnvRefs.next();
+ String resourceName = ref.getJndiName();
String refName = ref.getRefName();
if( ref.getType().equals("java.net.URL") )
{
@@ -362,6 +374,35 @@
Util.bind(envCtx, refName, new LinkRef(resourceName));
}
}
+ }
+
+ protected void linkResourceRefs(Iterator resourceRefs, Context envCtx)
+ throws NamingException
+ {
+ while( resourceRefs.hasNext() )
+ {
+ ResourceRefMetaData ref = (ResourceRefMetaData) resourceRefs.next();
+ String jndiName = ref.getJndiName();
+ String refName = ref.getRefName();
+ if( ref.getType().equals("java.net.URL") )
+ {
+ try
+ {
+ category.debug("Binding '"+refName+"' to URL: "+jndiName);
+ URL url = new URL(jndiName);
+ Util.bind(envCtx, refName, url);
+ }
+ catch(MalformedURLException e)
+ {
+ throw new NamingException("Malformed URL:"+e.getMessage());
+ }
+ }
+ else
+ {
+ category.debug("Linking '"+refName+"' to JNDI name: "+jndiName);
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ }
}
protected void linkEjbRefs(Iterator ejbRefs, Context envCtx)
@@ -383,7 +424,7 @@
}
/** This creates a java:comp/env/security context that contains a
- securityMgr binding pointing to an EJBSecurityMgr implementation
+ securityMgr binding pointing to an AuthenticationManager implementation
and a realmMapping binding pointing to a RealmMapping implementation.
If the jboss-web.xml descriptor contained a security-domain element
then the bindings are LinkRefs to the jndi name specified by the
1.1.6.2 +9 -4 jboss/src/main/org/jboss/web/AbstractWebContainerMBean.java
Index: AbstractWebContainerMBean.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/web/AbstractWebContainerMBean.java,v
retrieving revision 1.1.6.1
retrieving revision 1.1.6.2
diff -u -r1.1.6.1 -r1.1.6.2
--- AbstractWebContainerMBean.java 2001/11/02 08:42:39 1.1.6.1
+++ AbstractWebContainerMBean.java 2001/11/12 19:32:56 1.1.6.2
@@ -2,20 +2,25 @@
import java.util.Iterator;
+import org.w3c.dom.Element;
+
import org.jboss.deployment.DeploymentException;
/** A template pattern for web container integration into JBoss.
@author [EMAIL PROTECTED]
-@version $Revision: 1.1.6.1 $
+@version $Revision: 1.1.6.2 $
*/
public interface AbstractWebContainerMBean extends org.jboss.util.ServiceMBean
{
- public abstract void deploy(String ctxPath, String warUrl) throws
DeploymentException;
- public abstract void undeploy(String warUrl) throws DeploymentException;
- public abstract boolean isDeployed(String warUrl);
+ public void deploy(String ctxPath, String warUrl) throws DeploymentException;
+ public void undeploy(String warUrl) throws DeploymentException;
+ public boolean isDeployed(String warUrl);
/** Returns the applications deployed by the container factory
@return An Iterator of WebApplication objects for the deployed wars.
*/
public Iterator getDeployedApplications();
+ /** Allow the import of an arbitrary XML configuration tree
+ */
+ public void importXml(Element config);
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development