[jboss-cvs] JBossAS SVN: r81068 - in trunk/server: src/bin and 24 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 10:14:36 EST 2008
Author: dimitris at jboss.org
Date: 2008-11-14 10:14:35 -0500 (Fri, 14 Nov 2008)
New Revision: 81068
Modified:
trunk/server/pom.xml
trunk/server/src/bin/README-service.txt
trunk/server/src/bin/jboss_init_redhat.sh
trunk/server/src/bin/jboss_init_suse.sh
trunk/server/src/bin/service.bat
trunk/server/src/bin/shutdown.bat
trunk/server/src/bin/shutdown.sh
trunk/server/src/docs/images/Entity_container_call.gif
trunk/server/src/docs/images/confgui.gif
trunk/server/src/docs/images/jawsgui.gif
trunk/server/src/docs/images/jbossgui.gif
trunk/server/src/etc/conf/default/aop.xml
trunk/server/src/etc/conf/default/bindings.xml
trunk/server/src/etc/conf/default/bootstrap-minimal.xml
trunk/server/src/etc/conf/default/bootstrap-norepo.xml
trunk/server/src/etc/conf/default/bootstrap.xml
trunk/server/src/etc/conf/default/classloader.xml
trunk/server/src/etc/conf/default/deployers.xml
trunk/server/src/etc/conf/default/initialize.xml
trunk/server/src/etc/conf/default/jboss-log4j.xml
trunk/server/src/etc/conf/default/jmx.xml
trunk/server/src/etc/conf/default/profile-repository.xml
trunk/server/src/etc/conf/default/profile.xml
trunk/server/src/etc/conf/default/security.xml
trunk/server/src/etc/conf/web/jboss-service.xml
trunk/server/src/etc/conf/web/jmx-invoker-service.xml
trunk/server/src/etc/deployers/directory-deployer-jboss-beans.xml
trunk/server/src/etc/deployers/ear-deployer-jboss-beans.xml
trunk/server/src/main/org/jboss/client/AppClientLauncher.java
trunk/server/src/main/org/jboss/client/AppClientMain.java
trunk/server/src/main/org/jboss/client/ReflectionLauncher.java
trunk/server/src/main/org/jboss/deployment/AltAnnotationMetaDataDeployer.java
trunk/server/src/main/org/jboss/deployment/AnnotatedClassFilter.java
trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java
trunk/server/src/main/org/jboss/deployment/EARStructure.java
trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java
trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java
trunk/server/src/main/org/jboss/deployment/EarLibExcludeDeployer.java
trunk/server/src/main/org/jboss/deployment/EarSecurityDeployer.java
trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java
trunk/server/src/main/org/jboss/deployment/EjbParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/EjbParsingDeployerMBean.java
trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java
trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/JBossWebAppParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/JaccCommitDeployer.java
trunk/server/src/main/org/jboss/deployment/JaccInitializationDeployer.java
trunk/server/src/main/org/jboss/deployment/LegacyWebXmlLessDeployer.java
trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
trunk/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
trunk/server/src/main/org/jboss/deployment/WebAppParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyItem.java
trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
trunk/server/src/main/org/jboss/deployment/plugin/LegacyEjb3JndiPolicy.java
trunk/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
trunk/server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
trunk/server/src/main/org/jboss/deployment/security/EarJaccPolicy.java
trunk/server/src/main/org/jboss/deployment/security/EarPolicyConfigurationFacade.java
trunk/server/src/main/org/jboss/deployment/security/EjbJaccPolicy.java
trunk/server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
trunk/server/src/main/org/jboss/deployment/security/JaccPolicy.java
trunk/server/src/main/org/jboss/deployment/security/JaccPolicyMBean.java
trunk/server/src/main/org/jboss/deployment/security/JaccPolicyUtil.java
trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacade.java
trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacadeMBean.java
trunk/server/src/main/org/jboss/deployment/security/WarJaccPolicy.java
trunk/server/src/main/org/jboss/deployment/security/WarPolicyConfigurationFacade.java
trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatistics.java
trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatisticsMBean.java
trunk/server/src/main/org/jboss/ejb/EJB2UserTransactionProvider.java
trunk/server/src/main/org/jboss/ejb/EJBPermissionMapping.java
trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java
trunk/server/src/main/org/jboss/ejb/EjbUtil50.java
trunk/server/src/main/org/jboss/ejb/deployers/CreateDestination.java
trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationDeployer.java
trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationFactory.java
trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationMatcher.java
trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java
trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployerMBean.java
trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployment.java
trunk/server/src/main/org/jboss/ejb/deployers/EjbSecurityDeployer.java
trunk/server/src/main/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java
trunk/server/src/main/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java
trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java
trunk/server/src/main/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
trunk/server/src/main/org/jboss/ejb/plugins/security/SecurityActions.java
trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePluginExt.java
trunk/server/src/main/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java
trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializablePolicy.java
trunk/server/src/main/org/jboss/jmx/connector/invoker/serializablepolicy/StripModelMBeanInfoPolicy.java
trunk/server/src/main/org/jboss/naming/JndiBinder.java
trunk/server/src/main/org/jboss/proxy/SecurityActions.java
trunk/server/src/main/org/jboss/verifier/event/EventGeneratorSupport.java
trunk/server/src/main/org/jboss/verifier/event/Library.java
trunk/server/src/main/org/jboss/web/WebClassLoaderFactory.java
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java
trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
trunk/server/src/main/org/jboss/web/deployers/WARStructure.java
trunk/server/src/main/org/jboss/web/deployers/WarDeployment.java
trunk/server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
trunk/server/src/main/org/jboss/web/deployers/WebModule.java
trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java
Log:
fix svn properties
Property changes on: trunk/server/pom.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/bin/README-service.txt
===================================================================
--- trunk/server/src/bin/README-service.txt 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/bin/README-service.txt 2008-11-14 15:14:35 UTC (rev 81068)
@@ -9,7 +9,7 @@
To learn more about the JBoss Web Native connectors see:
http://www.jboss.org/jbossweb/native.html
-$Id:$
+$Id$
---------------------------------------------------------------------
The JBoss(R)* app server is Copyright 2000-2008, Red Hat Middleware LLC
and individual contributors, and is licensed under the GNU LGPL.
Property changes on: trunk/server/src/bin/README-service.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/bin/jboss_init_redhat.sh
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: trunk/server/src/bin/jboss_init_suse.sh
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: trunk/server/src/bin/service.bat
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/bin/shutdown.bat
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: trunk/server/src/bin/shutdown.sh
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: trunk/server/src/docs/images/Entity_container_call.gif
___________________________________________________________________
Name: svn:mime-type
- application/octet-stream
+ image/gif
Property changes on: trunk/server/src/docs/images/confgui.gif
___________________________________________________________________
Name: svn:mime-type
- application/octet-stream
+ image/gif
Property changes on: trunk/server/src/docs/images/jawsgui.gif
___________________________________________________________________
Name: svn:mime-type
- application/octet-stream
+ image/gif
Property changes on: trunk/server/src/docs/images/jbossgui.gif
___________________________________________________________________
Name: svn:mime-type
- application/octet-stream
+ image/gif
Property changes on: trunk/server/src/etc/conf/default/aop.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/bindings.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/bootstrap-minimal.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/bootstrap-norepo.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/bootstrap.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/classloader.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/deployers.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/initialize.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/jboss-log4j.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/jmx.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/profile-repository.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/profile.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/default/security.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/web/jboss-service.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/conf/web/jmx-invoker-service.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/etc/deployers/directory-deployer-jboss-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/directory-deployer-jboss-beans.xml 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/etc/deployers/directory-deployer-jboss-beans.xml 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Legacy directory structure - JBAS-5900.
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- Disabled by default, due to performance impact -->
- <!--<bean name="DirectoryStructure" class="org.jboss.deployers.vfs.plugins.structure.dir.DirectoryStructure"/>-->
-
-</deployment>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Legacy directory structure - JBAS-5900.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Disabled by default, due to performance impact -->
+ <!--<bean name="DirectoryStructure" class="org.jboss.deployers.vfs.plugins.structure.dir.DirectoryStructure"/>-->
+
+</deployment>
Property changes on: trunk/server/src/etc/deployers/directory-deployer-jboss-beans.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/etc/deployers/ear-deployer-jboss-beans.xml
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Modified: trunk/server/src/main/org/jboss/client/AppClientLauncher.java
===================================================================
--- trunk/server/src/main/org/jboss/client/AppClientLauncher.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/client/AppClientLauncher.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,44 +1,44 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.client;
-
-/**
- * An interface for launching a javaee client application
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public interface AppClientLauncher
-{
- /**
- * Launch a javaee client application.
- *
- * @param clientClass - the class whose main(String[]) will be invoked
- * @param clientName - the client name that maps to the server side JNDI ENC.
- * May be null indicating the name should be taken from the client jar
- * descriptors/annotations.
- * @param args - the args to pass to main method
- * @throws Throwable
- */
- public void launch(String clientClass, String clientName, String[] args)
- throws Throwable;
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.client;
+
+/**
+ * An interface for launching a javaee client application
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface AppClientLauncher
+{
+ /**
+ * Launch a javaee client application.
+ *
+ * @param clientClass - the class whose main(String[]) will be invoked
+ * @param clientName - the client name that maps to the server side JNDI ENC.
+ * May be null indicating the name should be taken from the client jar
+ * descriptors/annotations.
+ * @param args - the args to pass to main method
+ * @throws Throwable
+ */
+ public void launch(String clientClass, String clientName, String[] args)
+ throws Throwable;
+}
Property changes on: trunk/server/src/main/org/jboss/client/AppClientLauncher.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/client/AppClientMain.java
===================================================================
--- trunk/server/src/main/org/jboss/client/AppClientMain.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/client/AppClientMain.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,222 +1,222 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.client;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Properties;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.jboss.logging.Logger;
-import org.jboss.naming.client.java.javaURLContextFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A java Main used to launch java ee app clients.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class AppClientMain
-{
- // logging support
- private static final Logger log = Logger.getLogger(AppClientMain.class);
-
- /** The name of the client class whose main(String[]) should be launched */
- public static final String JBOSS_CLIENT_PARAM = "-jbossclient";
- /** The name of the javaee client context used to identify the server side ENC */
- public static final String J2EE_CLIENT_PARAM = "-"+javaURLContextFactory.J2EE_CLIENT_NAME_PROP;
- /** Comma separated list of AppClientLauncher implementation classes */
- public static final String LAUNCHERS_PARAM = "-launchers";
- /** The default list of launchers */
- public static String[] DEFAULT_LAUNCHERS = {ReflectionLauncher.class.getName()};
-
- /**
- * The main entry
- */
- public static void main(String[] args)
- throws Exception
- {
- log.debug("System Properties");
- Properties sysprops = System.getProperties();
- for (Object key : sysprops.keySet())
- log.debug(" " + key + "=" + sysprops.getProperty((String) key));
-
- // read the client class from args
- String clientClass = null;
- String clientName = null;
- ArrayList<String> newArgs = new ArrayList<String>();
- String[] launchers = DEFAULT_LAUNCHERS;
- for (int i = 0; i < args.length; i++)
- {
- String arg = args[i];
- log.debug("arg=" + arg);
-
- if( arg.equals(JBOSS_CLIENT_PARAM) )
- {
- clientClass = args[i+1];
- i ++;
- }
- else if( arg.equals(J2EE_CLIENT_PARAM) )
- {
- /* Set the j2ee.client system property so the AppContextFactory
- sees what name the client app JNDI enc is bound under
- */
- clientName = args[i+1];
- System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName);
- log.info(javaURLContextFactory.J2EE_CLIENT_NAME_PROP + "=" + clientName);
- i ++;
- }
- else if( arg.equals(LAUNCHERS_PARAM) )
- {
- launchers = args[i+1].split(",");
- log.info(LAUNCHERS_PARAM + "=" + args[i+1]);
- i ++;
- }
- else
- {
- newArgs.add(args[i]);
- }
- }
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if( loader == null )
- loader = AppClientMain.class.getClassLoader();
- // Look for a manifest Main-Class
- if (clientClass == null)
- {
- clientClass = getMainClassName(loader);
- throw new IllegalArgumentException("Neither a Main-Class was found in the manifest, "
- +"nor was a " + JBOSS_CLIENT_PARAM + " specified");
- }
- // If J2EE_CLIENT_NAME_PROP was not specified, look in the jar descriptors
- if (clientName == null)
- {
- clientName = getClientName(loader);
- }
-
- String[] mainArgs = new String [newArgs.size()];
- newArgs.toArray(mainArgs);
-
- // Try each launcher in the order specified
- for(String launcherName : launchers)
- {
- try
- {
- Class<AppClientLauncher> launcherClass = (Class<AppClientLauncher>) loader.loadClass(launcherName);
- AppClientLauncher launcher = launcherClass.newInstance();
- launcher.launch(clientClass, clientName, mainArgs);
- break;
- }
- catch(Throwable t)
- {
- log.warn("Failed to launch using: "+launcherName, t);
- }
- }
- }
-
- /**
- *
- * @param loader - class loader used to load descriptors as resources
- * @return
- */
- private static String getClientName(ClassLoader loader)
- throws Exception
- {
- String clientName = null;
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- // Try META-INF/application-client.xml application-client at id first
- URL appXmlURL = loader.getResource("META-INF/application-client.xml");
- if( appXmlURL != null )
- {
- InputStream is = appXmlURL.openStream();
- Document appXml = builder.parse(is);
- is.close();
- Element root = appXml.getDocumentElement();
- clientName = root.getAttribute("id");
- if( clientName != null )
- return clientName;
- }
-
- // Try META-INF/jboss-client.xml jndi-name
- URL jbossXmlURL = loader.getResource("META-INF/jboss-client.xml");
- if( appXmlURL != null )
- {
- InputStream is = jbossXmlURL.openStream();
- Document jbossXml = builder.parse(is);
- is.close();
- Element root = jbossXml.getDocumentElement();
- NodeList children = root.getChildNodes();
- for(int n = 0; n < children.getLength(); n ++)
- {
- Node node = children.item(n);
- if( node.getLocalName().equals("jndi-name") )
- {
- clientName = node.getNodeValue();
- return clientName;
- }
- }
- }
- // TODO: annotations on main class
- return null;
- }
-
- /**
- * Check the jar manifest for a Main-Class value.
- *
- * @param loader
- * @return Main-Class value or null if none exists.
- * @throws Exception
- */
- private static String getMainClassName(ClassLoader loader)
- throws Exception
- {
- URL mfURL = loader.getResource("META-INF/MANIFEST.MF");
- if(mfURL == null)
- {
- return null;
- }
-
- InputStream is = mfURL.openStream();
- Manifest mf;
- try
- {
- mf = new Manifest(is);
- }
- finally
- {
- is.close();
- }
- Attributes attrs = mf.getMainAttributes();
- String mainClassName = attrs.getValue(Attributes.Name.MAIN_CLASS);
- return mainClassName;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.client;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.naming.client.java.javaURLContextFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A java Main used to launch java ee app clients.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class AppClientMain
+{
+ // logging support
+ private static final Logger log = Logger.getLogger(AppClientMain.class);
+
+ /** The name of the client class whose main(String[]) should be launched */
+ public static final String JBOSS_CLIENT_PARAM = "-jbossclient";
+ /** The name of the javaee client context used to identify the server side ENC */
+ public static final String J2EE_CLIENT_PARAM = "-"+javaURLContextFactory.J2EE_CLIENT_NAME_PROP;
+ /** Comma separated list of AppClientLauncher implementation classes */
+ public static final String LAUNCHERS_PARAM = "-launchers";
+ /** The default list of launchers */
+ public static String[] DEFAULT_LAUNCHERS = {ReflectionLauncher.class.getName()};
+
+ /**
+ * The main entry
+ */
+ public static void main(String[] args)
+ throws Exception
+ {
+ log.debug("System Properties");
+ Properties sysprops = System.getProperties();
+ for (Object key : sysprops.keySet())
+ log.debug(" " + key + "=" + sysprops.getProperty((String) key));
+
+ // read the client class from args
+ String clientClass = null;
+ String clientName = null;
+ ArrayList<String> newArgs = new ArrayList<String>();
+ String[] launchers = DEFAULT_LAUNCHERS;
+ for (int i = 0; i < args.length; i++)
+ {
+ String arg = args[i];
+ log.debug("arg=" + arg);
+
+ if( arg.equals(JBOSS_CLIENT_PARAM) )
+ {
+ clientClass = args[i+1];
+ i ++;
+ }
+ else if( arg.equals(J2EE_CLIENT_PARAM) )
+ {
+ /* Set the j2ee.client system property so the AppContextFactory
+ sees what name the client app JNDI enc is bound under
+ */
+ clientName = args[i+1];
+ System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName);
+ log.info(javaURLContextFactory.J2EE_CLIENT_NAME_PROP + "=" + clientName);
+ i ++;
+ }
+ else if( arg.equals(LAUNCHERS_PARAM) )
+ {
+ launchers = args[i+1].split(",");
+ log.info(LAUNCHERS_PARAM + "=" + args[i+1]);
+ i ++;
+ }
+ else
+ {
+ newArgs.add(args[i]);
+ }
+ }
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if( loader == null )
+ loader = AppClientMain.class.getClassLoader();
+ // Look for a manifest Main-Class
+ if (clientClass == null)
+ {
+ clientClass = getMainClassName(loader);
+ throw new IllegalArgumentException("Neither a Main-Class was found in the manifest, "
+ +"nor was a " + JBOSS_CLIENT_PARAM + " specified");
+ }
+ // If J2EE_CLIENT_NAME_PROP was not specified, look in the jar descriptors
+ if (clientName == null)
+ {
+ clientName = getClientName(loader);
+ }
+
+ String[] mainArgs = new String [newArgs.size()];
+ newArgs.toArray(mainArgs);
+
+ // Try each launcher in the order specified
+ for(String launcherName : launchers)
+ {
+ try
+ {
+ Class<AppClientLauncher> launcherClass = (Class<AppClientLauncher>) loader.loadClass(launcherName);
+ AppClientLauncher launcher = launcherClass.newInstance();
+ launcher.launch(clientClass, clientName, mainArgs);
+ break;
+ }
+ catch(Throwable t)
+ {
+ log.warn("Failed to launch using: "+launcherName, t);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param loader - class loader used to load descriptors as resources
+ * @return
+ */
+ private static String getClientName(ClassLoader loader)
+ throws Exception
+ {
+ String clientName = null;
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ // Try META-INF/application-client.xml application-client at id first
+ URL appXmlURL = loader.getResource("META-INF/application-client.xml");
+ if( appXmlURL != null )
+ {
+ InputStream is = appXmlURL.openStream();
+ Document appXml = builder.parse(is);
+ is.close();
+ Element root = appXml.getDocumentElement();
+ clientName = root.getAttribute("id");
+ if( clientName != null )
+ return clientName;
+ }
+
+ // Try META-INF/jboss-client.xml jndi-name
+ URL jbossXmlURL = loader.getResource("META-INF/jboss-client.xml");
+ if( appXmlURL != null )
+ {
+ InputStream is = jbossXmlURL.openStream();
+ Document jbossXml = builder.parse(is);
+ is.close();
+ Element root = jbossXml.getDocumentElement();
+ NodeList children = root.getChildNodes();
+ for(int n = 0; n < children.getLength(); n ++)
+ {
+ Node node = children.item(n);
+ if( node.getLocalName().equals("jndi-name") )
+ {
+ clientName = node.getNodeValue();
+ return clientName;
+ }
+ }
+ }
+ // TODO: annotations on main class
+ return null;
+ }
+
+ /**
+ * Check the jar manifest for a Main-Class value.
+ *
+ * @param loader
+ * @return Main-Class value or null if none exists.
+ * @throws Exception
+ */
+ private static String getMainClassName(ClassLoader loader)
+ throws Exception
+ {
+ URL mfURL = loader.getResource("META-INF/MANIFEST.MF");
+ if(mfURL == null)
+ {
+ return null;
+ }
+
+ InputStream is = mfURL.openStream();
+ Manifest mf;
+ try
+ {
+ mf = new Manifest(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ Attributes attrs = mf.getMainAttributes();
+ String mainClassName = attrs.getValue(Attributes.Name.MAIN_CLASS);
+ return mainClassName;
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/client/AppClientMain.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/client/ReflectionLauncher.java
===================================================================
--- trunk/server/src/main/org/jboss/client/ReflectionLauncher.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/client/ReflectionLauncher.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,79 +1,79 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.client;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import org.jboss.logging.Logger;
-import org.jboss.naming.client.java.javaURLContextFactory;
-
-/**
- * A AppClientLauncher implementation that simply looks for a static main
- * method on the
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class ReflectionLauncher
- implements AppClientLauncher
-{
- private static Logger log = Logger.getLogger(ReflectionLauncher.class);
-
- /**
- * Launch a javaee client application.
- *
- * @param clientClass - the class whose main(String[]) will be invoked
- * @param clientName - the client name that maps to the server side JNDI ENC.
- * May be null indicating the name should be taken from the client jar
- * descriptors/annotations.
- * @param args - the args to pass to main method
- * @throws Throwable
- */
- public void launch(String clientClass, String clientName, String[] args)
- throws Throwable
- {
- try
- {
- System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName);
- // invoke the client class
- Class cl = Class.forName(clientClass);
- Method main = cl.getDeclaredMethod("main", new Class[]{String[].class});
- Object[] mainArgs = {args};
- if( Modifier.isStatic(main.getModifiers()) )
- {
- main.invoke(null, mainArgs);
- }
- else
- {
- Object client = cl.newInstance();
- main.invoke(client, mainArgs);
- }
- log.debug("Client invoker success.");
- }
- catch (InvocationTargetException e)
- {
- throw e.getTargetException();
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.client;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.jboss.logging.Logger;
+import org.jboss.naming.client.java.javaURLContextFactory;
+
+/**
+ * A AppClientLauncher implementation that simply looks for a static main
+ * method on the
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ReflectionLauncher
+ implements AppClientLauncher
+{
+ private static Logger log = Logger.getLogger(ReflectionLauncher.class);
+
+ /**
+ * Launch a javaee client application.
+ *
+ * @param clientClass - the class whose main(String[]) will be invoked
+ * @param clientName - the client name that maps to the server side JNDI ENC.
+ * May be null indicating the name should be taken from the client jar
+ * descriptors/annotations.
+ * @param args - the args to pass to main method
+ * @throws Throwable
+ */
+ public void launch(String clientClass, String clientName, String[] args)
+ throws Throwable
+ {
+ try
+ {
+ System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName);
+ // invoke the client class
+ Class cl = Class.forName(clientClass);
+ Method main = cl.getDeclaredMethod("main", new Class[]{String[].class});
+ Object[] mainArgs = {args};
+ if( Modifier.isStatic(main.getModifiers()) )
+ {
+ main.invoke(null, mainArgs);
+ }
+ else
+ {
+ Object client = cl.newInstance();
+ main.invoke(client, mainArgs);
+ }
+ log.debug("Client invoker success.");
+ }
+ catch (InvocationTargetException e)
+ {
+ throw e.getTargetException();
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/client/ReflectionLauncher.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/AltAnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AltAnnotationMetaDataDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/AltAnnotationMetaDataDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,218 +1,218 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.annotation.Resources;
-import javax.annotation.security.DeclareRoles;
-import javax.annotation.security.DenyAll;
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
-import javax.annotation.security.RunAs;
-import javax.ejb.ApplicationException;
-import javax.ejb.EJB;
-import javax.ejb.EJBs;
-import javax.ejb.Init;
-import javax.ejb.Local;
-import javax.ejb.LocalHome;
-import javax.ejb.MessageDriven;
-import javax.ejb.PostActivate;
-import javax.ejb.PrePassivate;
-import javax.ejb.Remote;
-import javax.ejb.RemoteHome;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.ejb.Stateless;
-import javax.ejb.Timeout;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionManagement;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.ExcludeClassInterceptors;
-import javax.interceptor.ExcludeDefaultInterceptors;
-import javax.interceptor.Interceptors;
-import javax.persistence.Entity;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContexts;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-
-import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
-import org.jboss.deployers.spi.annotations.Element;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A POST_CLASSLOADER deployer which generates metadata from annotations.
- * Alternative option to its super class.
- *
- * @author Ales.Justin at jboss.org
- */
-public class AltAnnotationMetaDataDeployer extends AnnotationMetaDataDeployer
-{
- private Set<Class<? extends Annotation>> annotationOnClass = new HashSet<Class<? extends Annotation>>();
- private Set<Class<? extends Annotation>> annotationOnMethod = new HashSet<Class<? extends Annotation>>();
- private Set<Class<? extends Annotation>> annotationOnField = new HashSet<Class<? extends Annotation>>();
-
- public AltAnnotationMetaDataDeployer()
- {
- super();
- setInput(AnnotationEnvironment.class);
- // add annotations AnnotationMetaDataDeployer scans
- addAnnotationClass(Stateful.class);
- addAnnotationClass(Remove.class);
- addAnnotationClass(PostActivate.class);
- addAnnotationClass(PrePassivate.class);
- addAnnotationClass(Local.class);
- addAnnotationClass(LocalHome.class);
- addAnnotationClass(Remote.class);
- addAnnotationClass(RemoteHome.class);
- addAnnotationClass(Init.class);
- addAnnotationClass(Timeout.class);
- addAnnotationClass(AroundInvoke.class);
- addAnnotationClass(TransactionManagement.class);
- addAnnotationClass(TransactionAttribute.class);
- addAnnotationClass(RunAs.class);
- addAnnotationClass(DeclareRoles.class);
- addAnnotationClass(DenyAll.class);
- addAnnotationClass(RolesAllowed.class);
- addAnnotationClass(PermitAll.class);
- addAnnotationClass(Interceptors.class);
- addAnnotationClass(ExcludeClassInterceptors.class);
- addAnnotationClass(ExcludeDefaultInterceptors.class);
- addAnnotationClass(Resource.class);
- addAnnotationClass(Resources.class);
- addAnnotationClass(EJB.class);
- addAnnotationClass(EJBs.class);
- addAnnotationClass(PersistenceContext.class);
- addAnnotationClass(PersistenceContexts.class);
- addAnnotationClass(PostConstruct.class);
- addAnnotationClass(PreDestroy.class);
- addAnnotationClass(WebServiceRef.class);
- addAnnotationClass(WebServiceRefs.class);
- addAnnotationClass(Stateless.class);
- addAnnotationClass(MessageDriven.class);
- addAnnotationClass(Entity.class);
- addAnnotationClass(ApplicationException.class);
- }
-
- @SuppressWarnings("unchecked")
- protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, List<VirtualFile> classpath) throws IOException
- {
- AnnotationEnvironment env = unit.getAttachment(AnnotationEnvironment.class);
- if (env == null)
- {
- if (log.isTraceEnabled())
- log.trace("Cannot scan classes, missing AnnotationEnvironment as attachment: " + unit.getName());
- return Collections.emptySet();
- }
-
- Set<Class<?>> classes = new HashSet<Class<?>>();
- for(Class<? extends Annotation> annotation : annotationOnClass)
- {
- Class<Annotation> annotationClass = (Class<Annotation>)annotation;
- Set<Element<Annotation, Class<?>>> elements = env.classIsAnnotatedWith(annotationClass);
- for(Element<Annotation, Class<?>> elt : elements)
- classes.add(elt.getOwner());
- }
- for(Class<? extends Annotation> annotation : annotationOnMethod)
- {
- Class<Annotation> annotationClass = (Class<Annotation>)annotation;
- Set<Element<Annotation, Method>> elements = env.classHasMethodAnnotatedWith(annotationClass);
- for(Element<Annotation, Method> elt : elements)
- classes.add(elt.getOwner());
- }
- for(Class<? extends Annotation> annotation : annotationOnField)
- {
- Class<Annotation> annotationClass = (Class<Annotation>)annotation;
- Set<Element<Annotation, Field>> elements = env.classHasFieldAnnotatedWith(annotationClass);
- for(Element<Annotation, Field> elt : elements)
- classes.add(elt.getOwner());
- }
-
- if(log.isTraceEnabled() && classes.isEmpty() == false)
- log.trace("Annotated classes: " + classes);
-
- return classes;
- }
-
- /**
- * Cleanup annotation classes.
- */
- public void stop()
- {
- annotationOnClass.clear();
- annotationOnMethod.clear();
- annotationOnField.clear();
- }
-
- /**
- * Add annotation to matching set.
- *
- * @param annotation the annotation class
- */
- public void addAnnotationClass(Class<? extends Annotation> annotation)
- {
- Target target = annotation.getAnnotation(Target.class);
- if (target == null)
- {
- log.info("Annotation " + annotation + " has not @Target.");
- return;
- }
- ElementType[] types = target.value();
- if (types == null || types.length == 0)
- {
- log.info("Null or empty types on annotation's @Target: " + annotation);
- return;
- }
- for(ElementType type : types)
- {
- boolean used = false; // no need for duplicates
- if (type == ElementType.TYPE)
- {
- annotationOnClass.add(annotation);
- used = true;
- }
- if (used == false && type == ElementType.METHOD)
- {
- annotationOnMethod.add(annotation);
- used = true;
- }
- if (used == false && type == ElementType.FIELD)
- {
- annotationOnField.add(annotation);
- }
- }
- }
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.annotation.security.RunAs;
+import javax.ejb.ApplicationException;
+import javax.ejb.EJB;
+import javax.ejb.EJBs;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.MessageDriven;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionManagement;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.persistence.Entity;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContexts;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
+import org.jboss.deployers.spi.annotations.Element;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A POST_CLASSLOADER deployer which generates metadata from annotations.
+ * Alternative option to its super class.
+ *
+ * @author Ales.Justin at jboss.org
+ */
+public class AltAnnotationMetaDataDeployer extends AnnotationMetaDataDeployer
+{
+ private Set<Class<? extends Annotation>> annotationOnClass = new HashSet<Class<? extends Annotation>>();
+ private Set<Class<? extends Annotation>> annotationOnMethod = new HashSet<Class<? extends Annotation>>();
+ private Set<Class<? extends Annotation>> annotationOnField = new HashSet<Class<? extends Annotation>>();
+
+ public AltAnnotationMetaDataDeployer()
+ {
+ super();
+ setInput(AnnotationEnvironment.class);
+ // add annotations AnnotationMetaDataDeployer scans
+ addAnnotationClass(Stateful.class);
+ addAnnotationClass(Remove.class);
+ addAnnotationClass(PostActivate.class);
+ addAnnotationClass(PrePassivate.class);
+ addAnnotationClass(Local.class);
+ addAnnotationClass(LocalHome.class);
+ addAnnotationClass(Remote.class);
+ addAnnotationClass(RemoteHome.class);
+ addAnnotationClass(Init.class);
+ addAnnotationClass(Timeout.class);
+ addAnnotationClass(AroundInvoke.class);
+ addAnnotationClass(TransactionManagement.class);
+ addAnnotationClass(TransactionAttribute.class);
+ addAnnotationClass(RunAs.class);
+ addAnnotationClass(DeclareRoles.class);
+ addAnnotationClass(DenyAll.class);
+ addAnnotationClass(RolesAllowed.class);
+ addAnnotationClass(PermitAll.class);
+ addAnnotationClass(Interceptors.class);
+ addAnnotationClass(ExcludeClassInterceptors.class);
+ addAnnotationClass(ExcludeDefaultInterceptors.class);
+ addAnnotationClass(Resource.class);
+ addAnnotationClass(Resources.class);
+ addAnnotationClass(EJB.class);
+ addAnnotationClass(EJBs.class);
+ addAnnotationClass(PersistenceContext.class);
+ addAnnotationClass(PersistenceContexts.class);
+ addAnnotationClass(PostConstruct.class);
+ addAnnotationClass(PreDestroy.class);
+ addAnnotationClass(WebServiceRef.class);
+ addAnnotationClass(WebServiceRefs.class);
+ addAnnotationClass(Stateless.class);
+ addAnnotationClass(MessageDriven.class);
+ addAnnotationClass(Entity.class);
+ addAnnotationClass(ApplicationException.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, List<VirtualFile> classpath) throws IOException
+ {
+ AnnotationEnvironment env = unit.getAttachment(AnnotationEnvironment.class);
+ if (env == null)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Cannot scan classes, missing AnnotationEnvironment as attachment: " + unit.getName());
+ return Collections.emptySet();
+ }
+
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ for(Class<? extends Annotation> annotation : annotationOnClass)
+ {
+ Class<Annotation> annotationClass = (Class<Annotation>)annotation;
+ Set<Element<Annotation, Class<?>>> elements = env.classIsAnnotatedWith(annotationClass);
+ for(Element<Annotation, Class<?>> elt : elements)
+ classes.add(elt.getOwner());
+ }
+ for(Class<? extends Annotation> annotation : annotationOnMethod)
+ {
+ Class<Annotation> annotationClass = (Class<Annotation>)annotation;
+ Set<Element<Annotation, Method>> elements = env.classHasMethodAnnotatedWith(annotationClass);
+ for(Element<Annotation, Method> elt : elements)
+ classes.add(elt.getOwner());
+ }
+ for(Class<? extends Annotation> annotation : annotationOnField)
+ {
+ Class<Annotation> annotationClass = (Class<Annotation>)annotation;
+ Set<Element<Annotation, Field>> elements = env.classHasFieldAnnotatedWith(annotationClass);
+ for(Element<Annotation, Field> elt : elements)
+ classes.add(elt.getOwner());
+ }
+
+ if(log.isTraceEnabled() && classes.isEmpty() == false)
+ log.trace("Annotated classes: " + classes);
+
+ return classes;
+ }
+
+ /**
+ * Cleanup annotation classes.
+ */
+ public void stop()
+ {
+ annotationOnClass.clear();
+ annotationOnMethod.clear();
+ annotationOnField.clear();
+ }
+
+ /**
+ * Add annotation to matching set.
+ *
+ * @param annotation the annotation class
+ */
+ public void addAnnotationClass(Class<? extends Annotation> annotation)
+ {
+ Target target = annotation.getAnnotation(Target.class);
+ if (target == null)
+ {
+ log.info("Annotation " + annotation + " has not @Target.");
+ return;
+ }
+ ElementType[] types = target.value();
+ if (types == null || types.length == 0)
+ {
+ log.info("Null or empty types on annotation's @Target: " + annotation);
+ return;
+ }
+ for(ElementType type : types)
+ {
+ boolean used = false; // no need for duplicates
+ if (type == ElementType.TYPE)
+ {
+ annotationOnClass.add(annotation);
+ used = true;
+ }
+ if (used == false && type == ElementType.METHOD)
+ {
+ annotationOnMethod.add(annotation);
+ used = true;
+ }
+ if (used == false && type == ElementType.FIELD)
+ {
+ annotationOnField.add(annotation);
+ }
+ }
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/AltAnnotationMetaDataDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/AnnotatedClassFilter.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AnnotatedClassFilter.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/AnnotatedClassFilter.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,226 +1,226 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.VirtualFileVisitor;
-import org.jboss.virtual.VisitorAttributes;
-
-/**
- * A VirtualFileVisitor that traverses unit root and determines the
- * class files that are annotated.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class AnnotatedClassFilter implements VirtualFileVisitor
-{
- private static Logger log = Logger.getLogger(AnnotatedClassFilter.class);
- private ClassLoader loader;
- private int rootLength;
- private HashSet<String> childPaths = new HashSet<String>();
- private HashMap<VirtualFile, Class<?>> pathToClasses = new HashMap<VirtualFile, Class<?>>();
- private String clientClassName;
-
- public AnnotatedClassFilter(VFSDeploymentUnit unit, ClassLoader loader, VirtualFile classpathRoot)
- {
- this(unit, loader, classpathRoot, "");
- }
- public AnnotatedClassFilter(VFSDeploymentUnit unit, ClassLoader loader,
- VirtualFile classpathRoot, String clientClassName)
- {
- this.loader = loader;
- this.clientClassName = clientClassName;
-
- // Work out the root length. If there is a root, we need to add one to jump across the next /
- String rootName = classpathRoot.getPathName();
- rootLength = rootName.length();
- if (rootLength > 0)
- rootLength += 1;
- List<DeploymentUnit> children = unit.getChildren();
- if(children != null)
- {
- for(DeploymentUnit cu : children)
- {
- String path = cu.getName();
- childPaths.add(path);
- }
- }
- }
-
- public Map<VirtualFile, Class<?>> getAnnotatedClasses()
- {
- return pathToClasses;
- }
-
- public VisitorAttributes getAttributes()
- {
- VisitorAttributes attributes = new VisitorAttributes();
- attributes.setIncludeRoot(true);
- attributes.setRecurseFilter(new NoChildFilter());
- return attributes;
- }
-
- public void visit(VirtualFile file)
- {
- try
- {
- if(file.isLeaf())
- {
- accepts(file);
- }
- }
- catch (IOException e)
- {
- throw new Error("Error visiting " + file, e);
- }
- }
-
- public boolean accepts(VirtualFile file)
- {
- boolean accepts = file.getPathName().endsWith(".class");
- if(accepts)
- {
- accepts = false;
- String className = null;
- try
- {
- className = getClassName(file);
- Class<?> c = loader.loadClass(className);
- boolean hasAnnotations = hasAnnotations(c);
- boolean includeClass = false;
- if(clientClassName != null)
- {
- includeClass = className.equals(clientClassName) && hasAnnotations;
- }
- else
- {
- includeClass = hasAnnotations;
- }
-
- if(includeClass)
- {
- pathToClasses.put(file, c);
- accepts = true;
- }
- }
- catch(NoClassDefFoundError ignored)
- {
- log.debug("Incomplete class: "+className+", NCDFE: "+ignored);
- }
- catch(Exception ignored)
- {
- if(log.isTraceEnabled())
- log.trace("Failed to load class: "+className, ignored);
- }
- }
- return accepts;
- }
-
- protected String getFilePath(VirtualFile file)
- {
- String path = null;
- try
- {
- path = file.toURI().toString();
- }
- catch(Exception e)
- {
- }
- return path;
- }
-
- /**
- * Search the classpaths for the root of this file.
- *
- * @param classFile the class file
- * @return fqn class name
- * @throws IOException for any error
- */
- protected String getClassName(VirtualFile classFile) throws IOException
- {
- String pathName = classFile.getPathName();
- String name = pathName.substring(rootLength, pathName.length()-6);
- name = name.replace('/', '.');
- return name;
- }
-
- /**
- * Completely scan a class for annotations
- * @param cls
- * @return true if the class has annotations, false otherwise
- */
- protected boolean hasAnnotations(Class<?> cls)
- {
- if(cls == null)
- return false;
-
- // Note: this also returns true if super class has annotations
- if(cls.getAnnotations().length > 0)
- return true;
-
- for(Method m : cls.getDeclaredMethods())
- {
- if(m.getAnnotations().length > 0)
- return true;
- }
-
- for(Field f : cls.getDeclaredFields())
- {
- if(f.getAnnotations().length > 0)
- return true;
- }
-
- return hasAnnotations(cls.getSuperclass());
- }
-
- class NoChildFilter implements VirtualFileFilter
- {
- public boolean accepts(VirtualFile file)
- {
- String path = getFilePath(file);
- boolean accepts = false;
- try
- {
- accepts = file.isLeaf() == false && childPaths.contains(path) == false;
- }
- catch(Exception e)
- {
- }
- return accepts;
- }
-
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * A VirtualFileVisitor that traverses unit root and determines the
+ * class files that are annotated.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class AnnotatedClassFilter implements VirtualFileVisitor
+{
+ private static Logger log = Logger.getLogger(AnnotatedClassFilter.class);
+ private ClassLoader loader;
+ private int rootLength;
+ private HashSet<String> childPaths = new HashSet<String>();
+ private HashMap<VirtualFile, Class<?>> pathToClasses = new HashMap<VirtualFile, Class<?>>();
+ private String clientClassName;
+
+ public AnnotatedClassFilter(VFSDeploymentUnit unit, ClassLoader loader, VirtualFile classpathRoot)
+ {
+ this(unit, loader, classpathRoot, "");
+ }
+ public AnnotatedClassFilter(VFSDeploymentUnit unit, ClassLoader loader,
+ VirtualFile classpathRoot, String clientClassName)
+ {
+ this.loader = loader;
+ this.clientClassName = clientClassName;
+
+ // Work out the root length. If there is a root, we need to add one to jump across the next /
+ String rootName = classpathRoot.getPathName();
+ rootLength = rootName.length();
+ if (rootLength > 0)
+ rootLength += 1;
+ List<DeploymentUnit> children = unit.getChildren();
+ if(children != null)
+ {
+ for(DeploymentUnit cu : children)
+ {
+ String path = cu.getName();
+ childPaths.add(path);
+ }
+ }
+ }
+
+ public Map<VirtualFile, Class<?>> getAnnotatedClasses()
+ {
+ return pathToClasses;
+ }
+
+ public VisitorAttributes getAttributes()
+ {
+ VisitorAttributes attributes = new VisitorAttributes();
+ attributes.setIncludeRoot(true);
+ attributes.setRecurseFilter(new NoChildFilter());
+ return attributes;
+ }
+
+ public void visit(VirtualFile file)
+ {
+ try
+ {
+ if(file.isLeaf())
+ {
+ accepts(file);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new Error("Error visiting " + file, e);
+ }
+ }
+
+ public boolean accepts(VirtualFile file)
+ {
+ boolean accepts = file.getPathName().endsWith(".class");
+ if(accepts)
+ {
+ accepts = false;
+ String className = null;
+ try
+ {
+ className = getClassName(file);
+ Class<?> c = loader.loadClass(className);
+ boolean hasAnnotations = hasAnnotations(c);
+ boolean includeClass = false;
+ if(clientClassName != null)
+ {
+ includeClass = className.equals(clientClassName) && hasAnnotations;
+ }
+ else
+ {
+ includeClass = hasAnnotations;
+ }
+
+ if(includeClass)
+ {
+ pathToClasses.put(file, c);
+ accepts = true;
+ }
+ }
+ catch(NoClassDefFoundError ignored)
+ {
+ log.debug("Incomplete class: "+className+", NCDFE: "+ignored);
+ }
+ catch(Exception ignored)
+ {
+ if(log.isTraceEnabled())
+ log.trace("Failed to load class: "+className, ignored);
+ }
+ }
+ return accepts;
+ }
+
+ protected String getFilePath(VirtualFile file)
+ {
+ String path = null;
+ try
+ {
+ path = file.toURI().toString();
+ }
+ catch(Exception e)
+ {
+ }
+ return path;
+ }
+
+ /**
+ * Search the classpaths for the root of this file.
+ *
+ * @param classFile the class file
+ * @return fqn class name
+ * @throws IOException for any error
+ */
+ protected String getClassName(VirtualFile classFile) throws IOException
+ {
+ String pathName = classFile.getPathName();
+ String name = pathName.substring(rootLength, pathName.length()-6);
+ name = name.replace('/', '.');
+ return name;
+ }
+
+ /**
+ * Completely scan a class for annotations
+ * @param cls
+ * @return true if the class has annotations, false otherwise
+ */
+ protected boolean hasAnnotations(Class<?> cls)
+ {
+ if(cls == null)
+ return false;
+
+ // Note: this also returns true if super class has annotations
+ if(cls.getAnnotations().length > 0)
+ return true;
+
+ for(Method m : cls.getDeclaredMethods())
+ {
+ if(m.getAnnotations().length > 0)
+ return true;
+ }
+
+ for(Field f : cls.getDeclaredFields())
+ {
+ if(f.getAnnotations().length > 0)
+ return true;
+ }
+
+ return hasAnnotations(cls.getSuperclass());
+ }
+
+ class NoChildFilter implements VirtualFileFilter
+ {
+ public boolean accepts(VirtualFile file)
+ {
+ String path = getFilePath(file);
+ boolean accepts = false;
+ try
+ {
+ accepts = file.isLeaf() == false && childPaths.contains(path) == false;
+ }
+ catch(Exception e)
+ {
+ }
+ return accepts;
+ }
+
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/AnnotatedClassFilter.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,327 +1,327 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.io.IOException;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.annotation.creator.client.ApplicationClient5MetaDataCreator;
-import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
-import org.jboss.metadata.annotation.creator.web.Web25MetaDataCreator;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
-import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.metadata.web.spec.Web25MetaData;
-import org.jboss.metadata.web.spec.WebMetaData;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A POST_CLASSLOADER deployer which generates metadata from
- * annotations
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class AnnotationMetaDataDeployer extends AbstractDeployer
-{
- public static final String EJB_ANNOTATED_ATTACHMENT_NAME = "annotated."+EjbJarMetaData.class.getName();
- public static final String CLIENT_ANNOTATED_ATTACHMENT_NAME = "annotated."+ApplicationClientMetaData.class.getName();
- public static final String WEB_ANNOTATED_ATTACHMENT_NAME = "annotated."+WebMetaData.class.getName();
-
- private boolean metaDataCompleteIsDefault = false;
-
- public AnnotationMetaDataDeployer()
- {
- setStage(DeploymentStages.POST_CLASSLOADER);
- addInput(EjbJarMetaData.class);
- addInput(WebMetaData.class);
- addInput(ApplicationClientMetaData.class);
- addOutput(EJB_ANNOTATED_ATTACHMENT_NAME);
- addOutput(CLIENT_ANNOTATED_ATTACHMENT_NAME);
- addOutput(WEB_ANNOTATED_ATTACHMENT_NAME);
- }
-
- public boolean isMetaDataCompleteIsDefault()
- {
- return metaDataCompleteIsDefault;
- }
- public void setMetaDataCompleteIsDefault(boolean metaDataCompleteIsDefault)
- {
- this.metaDataCompleteIsDefault = metaDataCompleteIsDefault;
- }
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- if (unit instanceof VFSDeploymentUnit == false)
- return;
-
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
- deploy(vfsDeploymentUnit);
- }
-
- public void undeploy(DeploymentUnit unit)
- {
- if (unit instanceof VFSDeploymentUnit == false)
- return;
-
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
- undeploy(vfsDeploymentUnit);
- }
-
- /**
- * Process the
- *
- * @param unit the unit
- * @throws DeploymentException for any error
- */
- protected void deploy(VFSDeploymentUnit unit)
- throws DeploymentException
- {
- /* Ignore any spec metadata complete deployments. This expects that a
- deployment unit only represents one of the client, ejb or web
- deployments and its metadata completeness applies to the unit in terms
- of whether annotations should be scanned for.
- */
- boolean isComplete = this.isMetaDataCompleteIsDefault();
- EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class);
- if(ejbJarMetaData != null && ejbJarMetaData instanceof EjbJar3xMetaData)
- {
- isComplete |= ((EjbJar3xMetaData) ejbJarMetaData).isMetadataComplete();
- }
- else if(ejbJarMetaData != null)
- {
- // Any ejb-jar.xml 2.1 or earlier deployment is metadata complete
- isComplete = true;
- }
- WebMetaData webMetaData = unit.getAttachment(WebMetaData.class);
- if(webMetaData != null && webMetaData instanceof Web25MetaData)
- {
- isComplete |= ((Web25MetaData)webMetaData).isMetadataComplete();
- }
- else if(webMetaData != null)
- {
- // Any web.xml 2.4 or earlier deployment is metadata complete
- isComplete = true;
- }
- ApplicationClientMetaData clientMetaData = unit.getAttachment(ApplicationClientMetaData.class);
- if(clientMetaData != null)
- isComplete |= clientMetaData.isMetadataComplete();
-
- if(isComplete)
- {
- log.debug("Deployment is metadata-complete, skipping annotation processing"
- + ", ejbJarMetaData="+ejbJarMetaData
- + ", jbossWebMetaData="+webMetaData
- + ", jbossClientMetaData="+clientMetaData
- + ", metaDataCompleteIsDefault="+metaDataCompleteIsDefault
- );
- return;
- }
-
- VirtualFile root = unit.getRoot();
- boolean isLeaf = true;
- try
- {
- isLeaf = root.isLeaf();
- }
- catch(IOException ignore)
- {
- }
- if(isLeaf == true)
- return;
-
- List<VirtualFile> classpath = unit.getClassPath();
- if(classpath == null || classpath.isEmpty())
- return;
-
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Deploying annotations for unit: " + unit + ", classpath: " + classpath);
-
- try
- {
- processMetaData(unit, webMetaData, clientMetaData, classpath);
- }
- catch (Exception e)
- {
- throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);
- }
- }
-
- /**
- * Process metadata.
- *
- * @param unit the deployment unit
- * @param webMetaData the web metadata
- * @param clientMetaData the client metadata
- * @param classpath the classpath
- * @throws DeploymentException for any error
- */
- protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
- {
- String mainClassName = getMainClassName(unit);
- Collection<Class<?>> classes = getClasses(unit, mainClassName, classpath);
- if (classes.size() > 0)
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- if (webMetaData != null)
- processJBossWebMetaData(unit, finder, classes);
- else if (clientMetaData != null || mainClassName != null)
- processJBossClientMetaData(unit, finder, classes);
- else
- processJBossMetaData(unit, finder, classes);
- }
- }
-
- /**
- * Get the classes we want to scan.
- *
- * @param unit the deployment unit
- * @param mainClassName the main class name
- * @param classpath the classpath
- * @return possible classes containing metadata annotations
- * @throws IOException for any error
- */
- protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, List<VirtualFile> classpath) throws IOException
- {
- Map<VirtualFile, Class<?>> classpathClasses = new HashMap<VirtualFile, Class<?>>();
- for(VirtualFile path : classpath)
- {
- AnnotatedClassFilter classVisitor = new AnnotatedClassFilter(unit, unit.getClassLoader(), path, mainClassName);
- path.visit(classVisitor);
- Map<VirtualFile, Class<?>> classes = classVisitor.getAnnotatedClasses();
- if(classes != null && classes.size() > 0)
- {
- if(log.isTraceEnabled())
- log.trace("Annotated classes: " + classes);
- classpathClasses.putAll(classes);
- }
- }
- return classpathClasses.values();
- }
-
- /**
- * Undeploy a vfs deployment
- *
- * @param unit the unit
- */
- protected void undeploy(VFSDeploymentUnit unit)
- {
- // Nothing
- }
-
- /**
- * Process annotations.
- *
- * @param unit the deployment unit
- * @param finder the annotation finder
- * @param classes the candidate classes
- */
- protected void processJBossMetaData(VFSDeploymentUnit unit,
- AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
- {
- // Create the metadata model from the annotations
- JBoss50Creator creator = new JBoss50Creator(finder);
- JBossMetaData annotationMetaData = creator.create(classes);
- if(annotationMetaData != null)
- unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class);
- }
-
- /**
- * Process annotations.
- *
- * @param unit the deployment unit
- * @param finder the annotation finder
- * @param classes the candidate classes
- */
- protected void processJBossWebMetaData(VFSDeploymentUnit unit,
- AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
- {
- Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
- WebMetaData annotationMetaData = creator.create(classes);
- if(annotationMetaData != null)
- unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
- }
-
- /**
- * Process annotations.
- *
- * @param unit the deployment unit
- * @param finder the annotation finder
- * @param classes the candidate classes
- */
- protected void processJBossClientMetaData(VFSDeploymentUnit unit,
- AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
- {
- ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder);
- ApplicationClientMetaData annotationMetaData = creator.create(classes);
- if(annotationMetaData != null)
- unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class);
- }
-
- /**
- * Get main class from manifest.
- *
- * @param unit the deployment unit
- * @return main class name
- * @throws IOException for any error
- */
- protected String getMainClassName(VFSDeploymentUnit unit)
- throws IOException
- {
- VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
- if (log.isTraceEnabled())
- log.trace("parsing " + file);
-
- if(file == null)
- {
- return null;
- }
-
- try
- {
- Manifest mf = VFSUtils.readManifest(file);
- Attributes attrs = mf.getMainAttributes();
- return attrs.getValue(Attributes.Name.MAIN_CLASS);
- }
- finally
- {
- file.close();
- }
- }
-}
-
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.io.IOException;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.annotation.creator.client.ApplicationClient5MetaDataCreator;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.creator.web.Web25MetaDataCreator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.web.spec.Web25MetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A POST_CLASSLOADER deployer which generates metadata from
+ * annotations
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class AnnotationMetaDataDeployer extends AbstractDeployer
+{
+ public static final String EJB_ANNOTATED_ATTACHMENT_NAME = "annotated."+EjbJarMetaData.class.getName();
+ public static final String CLIENT_ANNOTATED_ATTACHMENT_NAME = "annotated."+ApplicationClientMetaData.class.getName();
+ public static final String WEB_ANNOTATED_ATTACHMENT_NAME = "annotated."+WebMetaData.class.getName();
+
+ private boolean metaDataCompleteIsDefault = false;
+
+ public AnnotationMetaDataDeployer()
+ {
+ setStage(DeploymentStages.POST_CLASSLOADER);
+ addInput(EjbJarMetaData.class);
+ addInput(WebMetaData.class);
+ addInput(ApplicationClientMetaData.class);
+ addOutput(EJB_ANNOTATED_ATTACHMENT_NAME);
+ addOutput(CLIENT_ANNOTATED_ATTACHMENT_NAME);
+ addOutput(WEB_ANNOTATED_ATTACHMENT_NAME);
+ }
+
+ public boolean isMetaDataCompleteIsDefault()
+ {
+ return metaDataCompleteIsDefault;
+ }
+ public void setMetaDataCompleteIsDefault(boolean metaDataCompleteIsDefault)
+ {
+ this.metaDataCompleteIsDefault = metaDataCompleteIsDefault;
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ deploy(vfsDeploymentUnit);
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ undeploy(vfsDeploymentUnit);
+ }
+
+ /**
+ * Process the
+ *
+ * @param unit the unit
+ * @throws DeploymentException for any error
+ */
+ protected void deploy(VFSDeploymentUnit unit)
+ throws DeploymentException
+ {
+ /* Ignore any spec metadata complete deployments. This expects that a
+ deployment unit only represents one of the client, ejb or web
+ deployments and its metadata completeness applies to the unit in terms
+ of whether annotations should be scanned for.
+ */
+ boolean isComplete = this.isMetaDataCompleteIsDefault();
+ EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class);
+ if(ejbJarMetaData != null && ejbJarMetaData instanceof EjbJar3xMetaData)
+ {
+ isComplete |= ((EjbJar3xMetaData) ejbJarMetaData).isMetadataComplete();
+ }
+ else if(ejbJarMetaData != null)
+ {
+ // Any ejb-jar.xml 2.1 or earlier deployment is metadata complete
+ isComplete = true;
+ }
+ WebMetaData webMetaData = unit.getAttachment(WebMetaData.class);
+ if(webMetaData != null && webMetaData instanceof Web25MetaData)
+ {
+ isComplete |= ((Web25MetaData)webMetaData).isMetadataComplete();
+ }
+ else if(webMetaData != null)
+ {
+ // Any web.xml 2.4 or earlier deployment is metadata complete
+ isComplete = true;
+ }
+ ApplicationClientMetaData clientMetaData = unit.getAttachment(ApplicationClientMetaData.class);
+ if(clientMetaData != null)
+ isComplete |= clientMetaData.isMetadataComplete();
+
+ if(isComplete)
+ {
+ log.debug("Deployment is metadata-complete, skipping annotation processing"
+ + ", ejbJarMetaData="+ejbJarMetaData
+ + ", jbossWebMetaData="+webMetaData
+ + ", jbossClientMetaData="+clientMetaData
+ + ", metaDataCompleteIsDefault="+metaDataCompleteIsDefault
+ );
+ return;
+ }
+
+ VirtualFile root = unit.getRoot();
+ boolean isLeaf = true;
+ try
+ {
+ isLeaf = root.isLeaf();
+ }
+ catch(IOException ignore)
+ {
+ }
+ if(isLeaf == true)
+ return;
+
+ List<VirtualFile> classpath = unit.getClassPath();
+ if(classpath == null || classpath.isEmpty())
+ return;
+
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Deploying annotations for unit: " + unit + ", classpath: " + classpath);
+
+ try
+ {
+ processMetaData(unit, webMetaData, clientMetaData, classpath);
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);
+ }
+ }
+
+ /**
+ * Process metadata.
+ *
+ * @param unit the deployment unit
+ * @param webMetaData the web metadata
+ * @param clientMetaData the client metadata
+ * @param classpath the classpath
+ * @throws DeploymentException for any error
+ */
+ protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
+ {
+ String mainClassName = getMainClassName(unit);
+ Collection<Class<?>> classes = getClasses(unit, mainClassName, classpath);
+ if (classes.size() > 0)
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ if (webMetaData != null)
+ processJBossWebMetaData(unit, finder, classes);
+ else if (clientMetaData != null || mainClassName != null)
+ processJBossClientMetaData(unit, finder, classes);
+ else
+ processJBossMetaData(unit, finder, classes);
+ }
+ }
+
+ /**
+ * Get the classes we want to scan.
+ *
+ * @param unit the deployment unit
+ * @param mainClassName the main class name
+ * @param classpath the classpath
+ * @return possible classes containing metadata annotations
+ * @throws IOException for any error
+ */
+ protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, List<VirtualFile> classpath) throws IOException
+ {
+ Map<VirtualFile, Class<?>> classpathClasses = new HashMap<VirtualFile, Class<?>>();
+ for(VirtualFile path : classpath)
+ {
+ AnnotatedClassFilter classVisitor = new AnnotatedClassFilter(unit, unit.getClassLoader(), path, mainClassName);
+ path.visit(classVisitor);
+ Map<VirtualFile, Class<?>> classes = classVisitor.getAnnotatedClasses();
+ if(classes != null && classes.size() > 0)
+ {
+ if(log.isTraceEnabled())
+ log.trace("Annotated classes: " + classes);
+ classpathClasses.putAll(classes);
+ }
+ }
+ return classpathClasses.values();
+ }
+
+ /**
+ * Undeploy a vfs deployment
+ *
+ * @param unit the unit
+ */
+ protected void undeploy(VFSDeploymentUnit unit)
+ {
+ // Nothing
+ }
+
+ /**
+ * Process annotations.
+ *
+ * @param unit the deployment unit
+ * @param finder the annotation finder
+ * @param classes the candidate classes
+ */
+ protected void processJBossMetaData(VFSDeploymentUnit unit,
+ AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
+ {
+ // Create the metadata model from the annotations
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ JBossMetaData annotationMetaData = creator.create(classes);
+ if(annotationMetaData != null)
+ unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class);
+ }
+
+ /**
+ * Process annotations.
+ *
+ * @param unit the deployment unit
+ * @param finder the annotation finder
+ * @param classes the candidate classes
+ */
+ protected void processJBossWebMetaData(VFSDeploymentUnit unit,
+ AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
+ {
+ Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
+ WebMetaData annotationMetaData = creator.create(classes);
+ if(annotationMetaData != null)
+ unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
+ }
+
+ /**
+ * Process annotations.
+ *
+ * @param unit the deployment unit
+ * @param finder the annotation finder
+ * @param classes the candidate classes
+ */
+ protected void processJBossClientMetaData(VFSDeploymentUnit unit,
+ AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
+ {
+ ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder);
+ ApplicationClientMetaData annotationMetaData = creator.create(classes);
+ if(annotationMetaData != null)
+ unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class);
+ }
+
+ /**
+ * Get main class from manifest.
+ *
+ * @param unit the deployment unit
+ * @return main class name
+ * @throws IOException for any error
+ */
+ protected String getMainClassName(VFSDeploymentUnit unit)
+ throws IOException
+ {
+ VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+ if (log.isTraceEnabled())
+ log.trace("parsing " + file);
+
+ if(file == null)
+ {
+ return null;
+ }
+
+ try
+ {
+ Manifest mf = VFSUtils.readManifest(file);
+ Attributes attrs = mf.getMainAttributes();
+ return attrs.getValue(Attributes.Name.MAIN_CLASS);
+ }
+ finally
+ {
+ file.close();
+ }
+ }
+}
+
Property changes on: trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,115 +1,115 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.util.List;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-import org.jboss.metadata.ear.spec.EarMetaData;
-import org.jboss.metadata.ear.spec.ModuleMetaData;
-import org.jboss.metadata.ear.spec.ModulesMetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.metadata.web.spec.WebMetaData;
-import org.jboss.virtual.VirtualFile;
-
-
-/**
- * An SchemaResolverDeployer for translating application.xml descriptors into
- * Ear50MetaData instances.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision:$
- */
-public class AppParsingDeployer extends SchemaResolverDeployer<EarMetaData>
-{
- public AppParsingDeployer()
- {
- super(EarMetaData.class);
- setName("application.xml");
- }
-
- /**
- * Get the virtual file path for the application descriptor in the
- * DeploymentContext.getMetaDataPath.
- *
- * @return the current virtual file path for the application descriptor
- */
- public String getAppXmlPath()
- {
- return getName();
- }
-
- /**
- * Set the virtual file path for the application descriptor in the
- * DeploymentContext.getMetaDataLocation. The standard path is application.xml
- * to be found in the META-INF metdata path.
- *
- * @param appXmlPath - new virtual file path for the application descriptor
- */
- public void setAppXmlPath(String appXmlPath)
- {
- setName(appXmlPath);
- }
-
- protected EarMetaData parse(VFSDeploymentUnit unit, VirtualFile file, EarMetaData root) throws Exception
- {
- EarMetaData ear = super.parse(unit,file, root);
- List<DeploymentUnit> children = unit.getChildren();
- ModulesMetaData modules = ear.getModules();
- if(children != null && modules != null)
- {
- for(DeploymentUnit child : children)
- {
- String moduleName = child.getSimpleName();
- ModuleMetaData module = modules.get(moduleName);
- if(module != null && module.getAlternativeDD() != null)
- {
- VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD());
- if(altDDFile == null)
- throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName());
-
- String attachmentName;
- if(module.getType() == ModuleMetaData.ModuleType.Ejb)
- attachmentName = EjbJarMetaData.class.getName();
- else if(module.getType() == ModuleMetaData.ModuleType.Web)
- attachmentName = WebMetaData.class.getName();
- else if(module.getType() == ModuleMetaData.ModuleType.Client)
- attachmentName = ApplicationClientMetaData.class.getName();
- else if(module.getType() == ModuleMetaData.ModuleType.Connector)
- attachmentName = "org.jboss.resource.metadata.ConnectorMetaData";
- else
- throw new IllegalStateException("Expected module types in an EAR are ejb, web, java and connector but got " + module.getType() + " for " + child.getName() + " in " + unit.getName());
-
- child.addAttachment(attachmentName + ".altDD", altDDFile);
- if(log.isTraceEnabled())
- log.trace("attached alt-dd " + altDDFile + " for module " + child.getSimpleName());
- }
- }
- }
-
- return ear;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+import org.jboss.metadata.ear.spec.EarMetaData;
+import org.jboss.metadata.ear.spec.ModuleMetaData;
+import org.jboss.metadata.ear.spec.ModulesMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.virtual.VirtualFile;
+
+
+/**
+ * An SchemaResolverDeployer for translating application.xml descriptors into
+ * Ear50MetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision:$
+ */
+public class AppParsingDeployer extends SchemaResolverDeployer<EarMetaData>
+{
+ public AppParsingDeployer()
+ {
+ super(EarMetaData.class);
+ setName("application.xml");
+ }
+
+ /**
+ * Get the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataPath.
+ *
+ * @return the current virtual file path for the application descriptor
+ */
+ public String getAppXmlPath()
+ {
+ return getName();
+ }
+
+ /**
+ * Set the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataLocation. The standard path is application.xml
+ * to be found in the META-INF metdata path.
+ *
+ * @param appXmlPath - new virtual file path for the application descriptor
+ */
+ public void setAppXmlPath(String appXmlPath)
+ {
+ setName(appXmlPath);
+ }
+
+ protected EarMetaData parse(VFSDeploymentUnit unit, VirtualFile file, EarMetaData root) throws Exception
+ {
+ EarMetaData ear = super.parse(unit,file, root);
+ List<DeploymentUnit> children = unit.getChildren();
+ ModulesMetaData modules = ear.getModules();
+ if(children != null && modules != null)
+ {
+ for(DeploymentUnit child : children)
+ {
+ String moduleName = child.getSimpleName();
+ ModuleMetaData module = modules.get(moduleName);
+ if(module != null && module.getAlternativeDD() != null)
+ {
+ VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD());
+ if(altDDFile == null)
+ throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName());
+
+ String attachmentName;
+ if(module.getType() == ModuleMetaData.ModuleType.Ejb)
+ attachmentName = EjbJarMetaData.class.getName();
+ else if(module.getType() == ModuleMetaData.ModuleType.Web)
+ attachmentName = WebMetaData.class.getName();
+ else if(module.getType() == ModuleMetaData.ModuleType.Client)
+ attachmentName = ApplicationClientMetaData.class.getName();
+ else if(module.getType() == ModuleMetaData.ModuleType.Connector)
+ attachmentName = "org.jboss.resource.metadata.ConnectorMetaData";
+ else
+ throw new IllegalStateException("Expected module types in an EAR are ejb, web, java and connector but got " + module.getType() + " for " + child.getName() + " in " + unit.getName());
+
+ child.addAttachment(attachmentName + ".altDD", altDDFile);
+ if(log.isTraceEnabled())
+ log.trace("attached alt-dd " + altDDFile + " for module " + child.getSimpleName());
+ }
+ }
+ }
+
+ return ear;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,105 +1,105 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-
-//$Id$
-
-/**
- * EAR Deployer that can be used for initialization
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @author adrian at jboss.org
- * @since Dec 6, 2006
- * @version $Revision$
- */
-public class EARInitializingDeployer extends AbstractSimpleRealDeployer<JBossAppMetaData>
-{
- /**
- * Create a new EARInitializingDeployer.
- */
- public EARInitializingDeployer()
- {
- super(JBossAppMetaData.class);
- setOutput(PolicyConfiguration.class);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, JBossAppMetaData deployment) throws DeploymentException
- {
- //Perform JACC Policy Configuration
- String contextID = shortNameFromDeploymentName(unit.getSimpleName());
- PolicyConfigurationFactory pcFactory = null;
- try
- {
- pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
- unit.addAttachment(PolicyConfiguration.class, pc);
- }
- catch (PolicyContextException e)
- {
- throw new DeploymentException("PolicyContextException generated in deploy", e);
- }
- catch(Exception e)
- {
- throw new DeploymentException("Exception generated in deploy", e);
- }
-
- }
-
- @Override
- public void undeploy(DeploymentUnit unit, JBossAppMetaData deployment)
- {
- //Perform JACC cleanup for the EAR
- unit.removeAttachment(PolicyConfiguration.class);
- }
-
-
- /**
- * A utility method that takes a deployment unit name and strips it down to the base ear
- * name without the .ear suffix.
- * @param name - the DeploymentUnit name.
- * @return the short name
- */
- public static String shortNameFromDeploymentName(String name)
- {
- String shortName = name.trim();
- String[] parts = name.split("/|\\.|\\!");
- if( parts.length > 1 )
- {
- // If it ends in .war, use the previous part
- if( parts[parts.length-1].equals("ear") )
- shortName = parts[parts.length-2];
- // else use the last part
- else
- shortName = parts[parts.length-1];
- }
- return shortName;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+
+//$Id$
+
+/**
+ * EAR Deployer that can be used for initialization
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @author adrian at jboss.org
+ * @since Dec 6, 2006
+ * @version $Revision$
+ */
+public class EARInitializingDeployer extends AbstractSimpleRealDeployer<JBossAppMetaData>
+{
+ /**
+ * Create a new EARInitializingDeployer.
+ */
+ public EARInitializingDeployer()
+ {
+ super(JBossAppMetaData.class);
+ setOutput(PolicyConfiguration.class);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, JBossAppMetaData deployment) throws DeploymentException
+ {
+ //Perform JACC Policy Configuration
+ String contextID = shortNameFromDeploymentName(unit.getSimpleName());
+ PolicyConfigurationFactory pcFactory = null;
+ try
+ {
+ pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
+ unit.addAttachment(PolicyConfiguration.class, pc);
+ }
+ catch (PolicyContextException e)
+ {
+ throw new DeploymentException("PolicyContextException generated in deploy", e);
+ }
+ catch(Exception e)
+ {
+ throw new DeploymentException("Exception generated in deploy", e);
+ }
+
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, JBossAppMetaData deployment)
+ {
+ //Perform JACC cleanup for the EAR
+ unit.removeAttachment(PolicyConfiguration.class);
+ }
+
+
+ /**
+ * A utility method that takes a deployment unit name and strips it down to the base ear
+ * name without the .ear suffix.
+ * @param name - the DeploymentUnit name.
+ * @return the short name
+ */
+ public static String shortNameFromDeploymentName(String name)
+ {
+ String shortName = name.trim();
+ String[] parts = name.split("/|\\.|\\!");
+ if( parts.length > 1 )
+ {
+ // If it ends in .war, use the previous part
+ if( parts[parts.length-1].equals("ear") )
+ shortName = parts[parts.length-2];
+ // else use the last part
+ else
+ shortName = parts[parts.length-1];
+ }
+ return shortName;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/EARInitializingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EARStructure.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EARStructure.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EARStructure.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,460 +1,460 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.metadata.ear.jboss.ServiceModuleMetaData;
-import org.jboss.metadata.ear.spec.AbstractModule;
-import org.jboss.metadata.ear.spec.ConnectorModuleMetaData;
-import org.jboss.metadata.ear.spec.EarMetaData;
-import org.jboss.metadata.ear.spec.EjbModuleMetaData;
-import org.jboss.metadata.ear.spec.JavaModuleMetaData;
-import org.jboss.metadata.ear.spec.ModuleMetaData;
-import org.jboss.metadata.ear.spec.ModulesMetaData;
-import org.jboss.metadata.ear.spec.WebModuleMetaData;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
-
-/**
- * Structure deployer for EARs.
- *
- * @author Bill Burke
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision$
- */
-public class EARStructure extends AbstractVFSStructureDeployer
-{
- /**
- * The default ear/lib filter
- */
- public static final VirtualFileFilter DEFAULT_EAR_LIB_FILTER = new SuffixMatchFilter(".jar");
-
- /**
- * The ear/lib filter
- */
- private VirtualFileFilter earLibFilter = DEFAULT_EAR_LIB_FILTER;
- /** The schema resolver used to determine which schema to use for application.xml/jboss-app.xml */
- private SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
- /** unmarshaller factory */
- UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
- /** The root in classpath flag */
- private boolean includeEarRootInClasspath = true;
- /** The ear child context comparator */
- private String comparatorClassName;
- /** whether to validate deployment descriptors */
- private boolean useValidation = true;
-
- /**
- * Set the relative order to 1000 by default
- */
- public EARStructure()
- {
- setRelativeOrder(1000);
- }
-
- /**
- * Get the earLibFilter.
- *
- * @return the earLibFilter.
- */
- public VirtualFileFilter getEarLibFilter()
- {
- return earLibFilter;
- }
-
- /**
- * Set the earLibFilter.
- *
- * @param earLibFilter the earLibFilter.
- * @throws IllegalArgumentException for a null filter
- */
- public void setEarLibFilter(VirtualFileFilter earLibFilter)
- {
- if (earLibFilter == null)
- throw new IllegalArgumentException("Null filter");
- this.earLibFilter = earLibFilter;
- }
-
- /**
- * Get the schema resolver
- * @return the schema resolver
- */
- public SchemaBindingResolver getResolver()
- {
- return resolver;
- }
- /**
- * Set the schema resolver
- * @param resolver the schema resolver
- */
- public void setResolver(SchemaBindingResolver resolver)
- {
- this.resolver = resolver;
- }
-
- public boolean determineStructure(StructureContext structureContext) throws DeploymentException
- {
- ContextInfo context;
- boolean valid;
- boolean trace = log.isTraceEnabled();
- VirtualFile file = structureContext.getFile();
- try
- {
- if (file.isLeaf() == true || file.getName().endsWith(".ear") == false)
- return false;
-
- context = createContext(structureContext, "META-INF");
- context.setComparatorClassName(comparatorClassName);
-
- VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml");
- VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml");
- VirtualFile lib;
-
- boolean scan = true;
-
- Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
- unmarshaller.setValidation(useValidation);
- EarMetaData specMetaData = null;
- JBossAppMetaData appMetaData = null;
- if (applicationXml != null)
- {
- InputStream in = applicationXml.openStream();
- try
- {
- specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver);
- }
- finally
- {
- in.close();
- }
- scan = false;
- }
- if (jbossAppXml != null)
- {
- InputStream in = jbossAppXml.openStream();
- try
- {
- appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver);
- }
- finally
- {
- in.close();
- }
- }
- // Need a metadata instance and there will not be one if there are no descriptors
- if (appMetaData == null)
- {
- appMetaData = new JBossAppMetaData();
- }
- // Create the merged view
- appMetaData.merge(appMetaData, specMetaData);
-
- String libDir = appMetaData.getLibraryDirectory();
- if (libDir == null || libDir.length() > 0)
- {
- if (libDir == null)
- libDir = "lib";
-
- // Add the ear lib contents to the classpath
- if(trace)
- log.trace("Checking for ear lib directory: "+libDir);
- try
- {
- lib = file.getChild(libDir);
- if (lib != null)
- {
- if(trace)
- log.trace("Found ear lib directory: "+lib);
- List<VirtualFile> archives = lib.getChildren(earLibFilter);
- for (VirtualFile archive : archives)
- {
- addClassPath(structureContext, archive, true, true, context);
- try
- {
- // add any jars with persistence.xml as a deployment
- if (archive.getChild("META-INF/persistence.xml") != null)
- {
- log.trace(archive.getName() + " in ear lib directory has persistence units");
- if (structureContext.determineChildStructure(archive) == false)
- {
- throw new RuntimeException(archive.getName()
- + " in lib directory has persistence.xml but is not a recognized deployment, .ear: "
- + file.getName());
- }
- }
- else if (trace)
- log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml");
-
- }
- catch(IOException e)
- {
- // TODO - should we throw this fwd?
- log.warn("Exception searching for META-INF/persistence.xml in " + archive.getPathName() + ", " + e);
- }
- }
- }
- else if (trace)
- log.trace("No lib directory in ear archive.");
- }
- catch (IOException e)
- {
- // TODO - should we throw this fwd?
- log.warn("Exception while searching for lib dir: " + e);
- }
- }
- else if (trace)
- {
- log.trace("Ignoring library directory, got empty library-directory element.");
- }
-
- // Add the ear manifest locations?
- addClassPath(structureContext, file, includeEarRootInClasspath, true, context);
-
- // TODO: need to scan for annotationss
- if( scan )
- {
- scanEar(file, appMetaData);
- }
-
- // Create subdeployments for the ear modules
- ModulesMetaData modules = appMetaData.getModules();
- if(modules != null)
- {
- for (ModuleMetaData mod : modules)
- {
- String fileName = mod.getFileName();
- if (fileName != null && (fileName = fileName.trim()).length() > 0)
- {
- if (log.isTraceEnabled())
- log.trace("Checking application.xml module: " + fileName);
-
- try
- {
- VirtualFile module = file.getChild(fileName);
- if (module == null)
- {
- throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.getName());
- }
- // Ask the deployers to analyze this
- if(structureContext.determineChildStructure(module) == false)
- {
- throw new RuntimeException(fileName
- + " module listed in application.xml is not a recognized deployment, .ear: "
- + file.getName());
- }
- }
- catch (IOException e)
- {
- throw new RuntimeException("Exception looking for " + fileName + " module listed in application.xml, .ear " + file.getName(), e);
- }
- }
- }
- }
- valid = true;
- }
- catch(Exception e)
- {
- throw new RuntimeException("Error determining structure: " + file.getName(), e);
- }
-
- return valid;
- }
-
- /**
- For an ear without an application.xml, determine modules via:
- a. All ear modules with an extension of .war are considered web modules. The
- context root of the web module is the name of the file relative to the root
- of the application package, with the .war extension removed.
- b. All ear modules with extension of .rar are considered resource adapters.
- c. A directory named lib is considered to be the library directory, as
- described in Section�EE.8.2.1, �Bundled Libraries.�
- d. For all ear modules with a filename extension of .jar, but not in the lib
- directory, do the following:
- i. If the JAR file contains a META-INF/MANIFEST.MF file with a Main-Class
- attribute, or contains a META-INF/application-client.xml file, consider the
- jar file to be an application client module.
- ii. If the JAR file contains a META-INF/ejb-jar.xml file, or contains any
- class with an EJB component annotation (Stateless, etc.), consider the JAR
- file to be an EJB module.
- iii. All other JAR files are ignored unless referenced by a JAR file
- discovered above using one of the JAR file reference mechanisms such as the
- Class-Path header in a manifest file.
- * TODO: rewrite using vfs
- */
- private void scanEar(VirtualFile root, JBossAppMetaData appMetaData) throws IOException
- {
- List<VirtualFile> archives = root.getChildren();
- if (archives != null)
- {
- String earPath = root.getPathName();
- ModulesMetaData modules = appMetaData.getModules();
- if (modules == null)
- {
- modules = new ModulesMetaData();
- appMetaData.setModules(modules);
- }
- for (VirtualFile vfArchive : archives)
- {
- String filename = earRelativePath(earPath, vfArchive.getPathName());
- // Check if the module already exists, i.e. it is declared in jboss-app.xml
- ModuleMetaData moduleMetaData = appMetaData.getModule(filename);
- int type = typeFromSuffix(filename, vfArchive);
- if (type >= 0 && moduleMetaData == null)
- {
- moduleMetaData = new ModuleMetaData();
- AbstractModule module = null;
- switch(type)
- {
- case J2eeModuleMetaData.EJB:
- module = new EjbModuleMetaData();
- break;
- case J2eeModuleMetaData.CLIENT:
- module = new JavaModuleMetaData();
- break;
- case J2eeModuleMetaData.CONNECTOR:
- module = new ConnectorModuleMetaData();
- break;
- case J2eeModuleMetaData.SERVICE:
- case J2eeModuleMetaData.HAR:
- module = new ServiceModuleMetaData();
- break;
- case J2eeModuleMetaData.WEB:
- module = new WebModuleMetaData();
- break;
- }
- module.setFileName(filename);
- moduleMetaData.setValue(module);
- modules.add(moduleMetaData);
- }
- }
- }
- }
-
- private int typeFromSuffix(String path, VirtualFile archive)
- throws IOException
- {
- int type = -1;
- if( path.endsWith(".war") )
- type = J2eeModuleMetaData.WEB;
- else if( path.endsWith(".rar") )
- type = J2eeModuleMetaData.CONNECTOR;
- else if( path.endsWith(".har") )
- type = J2eeModuleMetaData.HAR;
- else if( path.endsWith(".sar") )
- type = J2eeModuleMetaData.SERVICE;
- else if( path.endsWith(".jar") )
- {
- // Look for a META-INF/application-client.xml
- VirtualFile mfFile = getMetaDataFile(archive, "META-INF/MANIFEST.MF");
- VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml");
- VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml");
- VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml");
-
- if( clientXml != null )
- {
- type = J2eeModuleMetaData.CLIENT;
- }
- else if( mfFile != null )
- {
- Manifest mf = VFSUtils.readManifest(mfFile);
- Attributes attrs = mf.getMainAttributes();
- if( attrs.containsKey(Attributes.Name.MAIN_CLASS) )
- {
- type = J2eeModuleMetaData.CLIENT;
- }
- else
- {
- // TODO: scan for annotations. Assume EJB for now
- type = J2eeModuleMetaData.EJB;
- }
- }
- else if( ejbXml != null || jbossXml != null )
- {
- type = J2eeModuleMetaData.EJB;
- }
- else
- {
- // TODO: scan for annotations. Assume EJB for now
- type = J2eeModuleMetaData.EJB;
- }
- }
-
- return type;
- }
-
- private String earRelativePath(String earPath, String pathName)
- {
- StringBuilder tmp = new StringBuilder(pathName);
- tmp.delete(0, earPath.length());
- return tmp.toString();
- }
-
- private VirtualFile getMetaDataFile(VirtualFile file, String path)
- {
- VirtualFile metaFile = null;
- try
- {
- metaFile = file.getChild(path);
- }
- catch(IOException ignored)
- {
- }
- return metaFile;
- }
-
- public void setIncludeEarRootInClasspath(boolean includeEarRootInClasspath)
- {
- this.includeEarRootInClasspath = includeEarRootInClasspath;
- }
-
- public void setComparatorClassName(String comparatorClassName)
- {
- this.comparatorClassName = comparatorClassName;
- }
-
- public void setUseValidation(boolean validateXml)
- {
- this.useValidation = validateXml;
- }
-
- public boolean isUseValidation()
- {
- return useValidation;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ear.jboss.ServiceModuleMetaData;
+import org.jboss.metadata.ear.spec.AbstractModule;
+import org.jboss.metadata.ear.spec.ConnectorModuleMetaData;
+import org.jboss.metadata.ear.spec.EarMetaData;
+import org.jboss.metadata.ear.spec.EjbModuleMetaData;
+import org.jboss.metadata.ear.spec.JavaModuleMetaData;
+import org.jboss.metadata.ear.spec.ModuleMetaData;
+import org.jboss.metadata.ear.spec.ModulesMetaData;
+import org.jboss.metadata.ear.spec.WebModuleMetaData;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * Structure deployer for EARs.
+ *
+ * @author Bill Burke
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+public class EARStructure extends AbstractVFSStructureDeployer
+{
+ /**
+ * The default ear/lib filter
+ */
+ public static final VirtualFileFilter DEFAULT_EAR_LIB_FILTER = new SuffixMatchFilter(".jar");
+
+ /**
+ * The ear/lib filter
+ */
+ private VirtualFileFilter earLibFilter = DEFAULT_EAR_LIB_FILTER;
+ /** The schema resolver used to determine which schema to use for application.xml/jboss-app.xml */
+ private SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+ /** unmarshaller factory */
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ /** The root in classpath flag */
+ private boolean includeEarRootInClasspath = true;
+ /** The ear child context comparator */
+ private String comparatorClassName;
+ /** whether to validate deployment descriptors */
+ private boolean useValidation = true;
+
+ /**
+ * Set the relative order to 1000 by default
+ */
+ public EARStructure()
+ {
+ setRelativeOrder(1000);
+ }
+
+ /**
+ * Get the earLibFilter.
+ *
+ * @return the earLibFilter.
+ */
+ public VirtualFileFilter getEarLibFilter()
+ {
+ return earLibFilter;
+ }
+
+ /**
+ * Set the earLibFilter.
+ *
+ * @param earLibFilter the earLibFilter.
+ * @throws IllegalArgumentException for a null filter
+ */
+ public void setEarLibFilter(VirtualFileFilter earLibFilter)
+ {
+ if (earLibFilter == null)
+ throw new IllegalArgumentException("Null filter");
+ this.earLibFilter = earLibFilter;
+ }
+
+ /**
+ * Get the schema resolver
+ * @return the schema resolver
+ */
+ public SchemaBindingResolver getResolver()
+ {
+ return resolver;
+ }
+ /**
+ * Set the schema resolver
+ * @param resolver the schema resolver
+ */
+ public void setResolver(SchemaBindingResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+
+ public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+ {
+ ContextInfo context;
+ boolean valid;
+ boolean trace = log.isTraceEnabled();
+ VirtualFile file = structureContext.getFile();
+ try
+ {
+ if (file.isLeaf() == true || file.getName().endsWith(".ear") == false)
+ return false;
+
+ context = createContext(structureContext, "META-INF");
+ context.setComparatorClassName(comparatorClassName);
+
+ VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml");
+ VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml");
+ VirtualFile lib;
+
+ boolean scan = true;
+
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ unmarshaller.setValidation(useValidation);
+ EarMetaData specMetaData = null;
+ JBossAppMetaData appMetaData = null;
+ if (applicationXml != null)
+ {
+ InputStream in = applicationXml.openStream();
+ try
+ {
+ specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver);
+ }
+ finally
+ {
+ in.close();
+ }
+ scan = false;
+ }
+ if (jbossAppXml != null)
+ {
+ InputStream in = jbossAppXml.openStream();
+ try
+ {
+ appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver);
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+ // Need a metadata instance and there will not be one if there are no descriptors
+ if (appMetaData == null)
+ {
+ appMetaData = new JBossAppMetaData();
+ }
+ // Create the merged view
+ appMetaData.merge(appMetaData, specMetaData);
+
+ String libDir = appMetaData.getLibraryDirectory();
+ if (libDir == null || libDir.length() > 0)
+ {
+ if (libDir == null)
+ libDir = "lib";
+
+ // Add the ear lib contents to the classpath
+ if(trace)
+ log.trace("Checking for ear lib directory: "+libDir);
+ try
+ {
+ lib = file.getChild(libDir);
+ if (lib != null)
+ {
+ if(trace)
+ log.trace("Found ear lib directory: "+lib);
+ List<VirtualFile> archives = lib.getChildren(earLibFilter);
+ for (VirtualFile archive : archives)
+ {
+ addClassPath(structureContext, archive, true, true, context);
+ try
+ {
+ // add any jars with persistence.xml as a deployment
+ if (archive.getChild("META-INF/persistence.xml") != null)
+ {
+ log.trace(archive.getName() + " in ear lib directory has persistence units");
+ if (structureContext.determineChildStructure(archive) == false)
+ {
+ throw new RuntimeException(archive.getName()
+ + " in lib directory has persistence.xml but is not a recognized deployment, .ear: "
+ + file.getName());
+ }
+ }
+ else if (trace)
+ log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml");
+
+ }
+ catch(IOException e)
+ {
+ // TODO - should we throw this fwd?
+ log.warn("Exception searching for META-INF/persistence.xml in " + archive.getPathName() + ", " + e);
+ }
+ }
+ }
+ else if (trace)
+ log.trace("No lib directory in ear archive.");
+ }
+ catch (IOException e)
+ {
+ // TODO - should we throw this fwd?
+ log.warn("Exception while searching for lib dir: " + e);
+ }
+ }
+ else if (trace)
+ {
+ log.trace("Ignoring library directory, got empty library-directory element.");
+ }
+
+ // Add the ear manifest locations?
+ addClassPath(structureContext, file, includeEarRootInClasspath, true, context);
+
+ // TODO: need to scan for annotationss
+ if( scan )
+ {
+ scanEar(file, appMetaData);
+ }
+
+ // Create subdeployments for the ear modules
+ ModulesMetaData modules = appMetaData.getModules();
+ if(modules != null)
+ {
+ for (ModuleMetaData mod : modules)
+ {
+ String fileName = mod.getFileName();
+ if (fileName != null && (fileName = fileName.trim()).length() > 0)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Checking application.xml module: " + fileName);
+
+ try
+ {
+ VirtualFile module = file.getChild(fileName);
+ if (module == null)
+ {
+ throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.getName());
+ }
+ // Ask the deployers to analyze this
+ if(structureContext.determineChildStructure(module) == false)
+ {
+ throw new RuntimeException(fileName
+ + " module listed in application.xml is not a recognized deployment, .ear: "
+ + file.getName());
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Exception looking for " + fileName + " module listed in application.xml, .ear " + file.getName(), e);
+ }
+ }
+ }
+ }
+ valid = true;
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException("Error determining structure: " + file.getName(), e);
+ }
+
+ return valid;
+ }
+
+ /**
+ For an ear without an application.xml, determine modules via:
+ a. All ear modules with an extension of .war are considered web modules. The
+ context root of the web module is the name of the file relative to the root
+ of the application package, with the .war extension removed.
+ b. All ear modules with extension of .rar are considered resource adapters.
+ c. A directory named lib is considered to be the library directory, as
+ described in Section�EE.8.2.1, �Bundled Libraries.�
+ d. For all ear modules with a filename extension of .jar, but not in the lib
+ directory, do the following:
+ i. If the JAR file contains a META-INF/MANIFEST.MF file with a Main-Class
+ attribute, or contains a META-INF/application-client.xml file, consider the
+ jar file to be an application client module.
+ ii. If the JAR file contains a META-INF/ejb-jar.xml file, or contains any
+ class with an EJB component annotation (Stateless, etc.), consider the JAR
+ file to be an EJB module.
+ iii. All other JAR files are ignored unless referenced by a JAR file
+ discovered above using one of the JAR file reference mechanisms such as the
+ Class-Path header in a manifest file.
+ * TODO: rewrite using vfs
+ */
+ private void scanEar(VirtualFile root, JBossAppMetaData appMetaData) throws IOException
+ {
+ List<VirtualFile> archives = root.getChildren();
+ if (archives != null)
+ {
+ String earPath = root.getPathName();
+ ModulesMetaData modules = appMetaData.getModules();
+ if (modules == null)
+ {
+ modules = new ModulesMetaData();
+ appMetaData.setModules(modules);
+ }
+ for (VirtualFile vfArchive : archives)
+ {
+ String filename = earRelativePath(earPath, vfArchive.getPathName());
+ // Check if the module already exists, i.e. it is declared in jboss-app.xml
+ ModuleMetaData moduleMetaData = appMetaData.getModule(filename);
+ int type = typeFromSuffix(filename, vfArchive);
+ if (type >= 0 && moduleMetaData == null)
+ {
+ moduleMetaData = new ModuleMetaData();
+ AbstractModule module = null;
+ switch(type)
+ {
+ case J2eeModuleMetaData.EJB:
+ module = new EjbModuleMetaData();
+ break;
+ case J2eeModuleMetaData.CLIENT:
+ module = new JavaModuleMetaData();
+ break;
+ case J2eeModuleMetaData.CONNECTOR:
+ module = new ConnectorModuleMetaData();
+ break;
+ case J2eeModuleMetaData.SERVICE:
+ case J2eeModuleMetaData.HAR:
+ module = new ServiceModuleMetaData();
+ break;
+ case J2eeModuleMetaData.WEB:
+ module = new WebModuleMetaData();
+ break;
+ }
+ module.setFileName(filename);
+ moduleMetaData.setValue(module);
+ modules.add(moduleMetaData);
+ }
+ }
+ }
+ }
+
+ private int typeFromSuffix(String path, VirtualFile archive)
+ throws IOException
+ {
+ int type = -1;
+ if( path.endsWith(".war") )
+ type = J2eeModuleMetaData.WEB;
+ else if( path.endsWith(".rar") )
+ type = J2eeModuleMetaData.CONNECTOR;
+ else if( path.endsWith(".har") )
+ type = J2eeModuleMetaData.HAR;
+ else if( path.endsWith(".sar") )
+ type = J2eeModuleMetaData.SERVICE;
+ else if( path.endsWith(".jar") )
+ {
+ // Look for a META-INF/application-client.xml
+ VirtualFile mfFile = getMetaDataFile(archive, "META-INF/MANIFEST.MF");
+ VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml");
+ VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml");
+ VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml");
+
+ if( clientXml != null )
+ {
+ type = J2eeModuleMetaData.CLIENT;
+ }
+ else if( mfFile != null )
+ {
+ Manifest mf = VFSUtils.readManifest(mfFile);
+ Attributes attrs = mf.getMainAttributes();
+ if( attrs.containsKey(Attributes.Name.MAIN_CLASS) )
+ {
+ type = J2eeModuleMetaData.CLIENT;
+ }
+ else
+ {
+ // TODO: scan for annotations. Assume EJB for now
+ type = J2eeModuleMetaData.EJB;
+ }
+ }
+ else if( ejbXml != null || jbossXml != null )
+ {
+ type = J2eeModuleMetaData.EJB;
+ }
+ else
+ {
+ // TODO: scan for annotations. Assume EJB for now
+ type = J2eeModuleMetaData.EJB;
+ }
+ }
+
+ return type;
+ }
+
+ private String earRelativePath(String earPath, String pathName)
+ {
+ StringBuilder tmp = new StringBuilder(pathName);
+ tmp.delete(0, earPath.length());
+ return tmp.toString();
+ }
+
+ private VirtualFile getMetaDataFile(VirtualFile file, String path)
+ {
+ VirtualFile metaFile = null;
+ try
+ {
+ metaFile = file.getChild(path);
+ }
+ catch(IOException ignored)
+ {
+ }
+ return metaFile;
+ }
+
+ public void setIncludeEarRootInClasspath(boolean includeEarRootInClasspath)
+ {
+ this.includeEarRootInClasspath = includeEarRootInClasspath;
+ }
+
+ public void setComparatorClassName(String comparatorClassName)
+ {
+ this.comparatorClassName = comparatorClassName;
+ }
+
+ public void setUseValidation(boolean validateXml)
+ {
+ this.useValidation = validateXml;
+ }
+
+ public boolean isUseValidation()
+ {
+ return useValidation;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/EARStructure.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,99 +1,99 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.ExportAll;
-import org.jboss.classloading.spi.version.Version;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-
-/**
- * EarClassLoaderDeployer.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
- at JMX(name="jboss.j2ee:service=EARClassLoaderDeployer", exposedInterface=EarClassLoaderDeployerMBean.class)
-public class EarClassLoaderDeployer extends AbstractSimpleRealDeployer<JBossAppMetaData> implements EarClassLoaderDeployerMBean
-{
- /** Whether to isolated ear deployments */
- private boolean isolated = false;
-
- /**
- * @return whether ear deployments should be isolated
- */
- public boolean isIsolated()
- {
- return isolated;
- }
-
- /**
- * @param isolated whether ear deployments should be isolated
- */
- public void setIsolated(boolean isolated)
- {
- this.isolated = isolated;
- }
-
- /**
- * Create a new EarClassLoaderDeployer.
- */
- public EarClassLoaderDeployer()
- {
- super(JBossAppMetaData.class);
- setOutput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, JBossAppMetaData metaData) throws DeploymentException
- {
- ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
- if (classLoadingMetaData != null)
- return;
-
- LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
- if (lrmd != null)
- {
- ClassLoadingMetaData clmd = LoaderRepositoryMetaDataHelper.create(unit, lrmd);
- // For isolated automatically create the classloader in a new domain
- if (clmd == null && isolated)
- {
- String domain = EARDeployment.getJMXName(metaData, unit) + ",extension=LoaderRepository";
- classLoadingMetaData = new ClassLoadingMetaData();
- classLoadingMetaData.setName(unit.getName());
- classLoadingMetaData.setDomain(domain);
- classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY);
- classLoadingMetaData.setImportAll(true);
- classLoadingMetaData.setVersion(Version.DEFAULT_VERSION);
- classLoadingMetaData.setJ2seClassLoadingCompliance(false);
- }
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+
+/**
+ * EarClassLoaderDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at JMX(name="jboss.j2ee:service=EARClassLoaderDeployer", exposedInterface=EarClassLoaderDeployerMBean.class)
+public class EarClassLoaderDeployer extends AbstractSimpleRealDeployer<JBossAppMetaData> implements EarClassLoaderDeployerMBean
+{
+ /** Whether to isolated ear deployments */
+ private boolean isolated = false;
+
+ /**
+ * @return whether ear deployments should be isolated
+ */
+ public boolean isIsolated()
+ {
+ return isolated;
+ }
+
+ /**
+ * @param isolated whether ear deployments should be isolated
+ */
+ public void setIsolated(boolean isolated)
+ {
+ this.isolated = isolated;
+ }
+
+ /**
+ * Create a new EarClassLoaderDeployer.
+ */
+ public EarClassLoaderDeployer()
+ {
+ super(JBossAppMetaData.class);
+ setOutput(ClassLoadingMetaData.class);
+ setStage(DeploymentStages.POST_PARSE);
+ setTopLevelOnly(true);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, JBossAppMetaData metaData) throws DeploymentException
+ {
+ ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+ if (classLoadingMetaData != null)
+ return;
+
+ LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
+ if (lrmd != null)
+ {
+ ClassLoadingMetaData clmd = LoaderRepositoryMetaDataHelper.create(unit, lrmd);
+ // For isolated automatically create the classloader in a new domain
+ if (clmd == null && isolated)
+ {
+ String domain = EARDeployment.getJMXName(metaData, unit) + ",extension=LoaderRepository";
+ classLoadingMetaData = new ClassLoadingMetaData();
+ classLoadingMetaData.setName(unit.getName());
+ classLoadingMetaData.setDomain(domain);
+ classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY);
+ classLoadingMetaData.setImportAll(true);
+ classLoadingMetaData.setVersion(Version.DEFAULT_VERSION);
+ classLoadingMetaData.setJ2seClassLoadingCompliance(false);
+ }
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,52 +1,52 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* 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.deployment;
-
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-
-/**
- * EarClassLoaderDeployerMBean.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface EarClassLoaderDeployerMBean
-{
- /** The default ObjectName */
- ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.j2ee:service=EARClassLoaderDeployer");
-
- /**
- * Return true if ears should be isolated by default
- *
- * @return whether ears should be isolated
- */
- boolean isIsolated();
-
- /**
- * Set whether ears should isolated
- *
- * @param isolated true for isolated ears
- */
- void setIsolated(boolean isolated);
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.deployment;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+
+/**
+ * EarClassLoaderDeployerMBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EarClassLoaderDeployerMBean
+{
+ /** The default ObjectName */
+ ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.j2ee:service=EARClassLoaderDeployer");
+
+ /**
+ * Return true if ears should be isolated by default
+ *
+ * @return whether ears should be isolated
+ */
+ boolean isIsolated();
+
+ /**
+ * Set whether ears should isolated
+ *
+ * @param isolated true for isolated ears
+ */
+ void setIsolated(boolean isolated);
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EarLibExcludeDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EarLibExcludeDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EarLibExcludeDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,91 +1,91 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.net.URL;
-
-import org.jboss.classloading.spi.visitor.ResourceContext;
-import org.jboss.classloading.spi.visitor.ResourceFilter;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Exclude ear's lib from AnnotationEnvironmentDeployer / OptAnnotationMetaDataDeployer processing.
- *
- * @author Ales.Justin at jboss.org
- */
-public class EarLibExcludeDeployer extends AbstractSimpleVFSRealDeployer<JBossAppMetaData>
-{
- public EarLibExcludeDeployer()
- {
- super(JBossAppMetaData.class);
- setStage(DeploymentStages.POST_CLASSLOADER);
- setOutputs(ResourceFilter.class.getName() + ".recurse");
- setTopLevelOnly(true);
- }
-
- public void deploy(VFSDeploymentUnit unit, JBossAppMetaData jBossAppMetaData) throws DeploymentException
- {
- try
- {
- VirtualFile root = unit.getRoot();
- String libDir = jBossAppMetaData.getLibraryDirectory();
- if (libDir == null || libDir.length() == 0) // take 'lib' even on empty
- libDir = "lib";
- VirtualFile lib = root.getChild(libDir);
- if (lib != null)
- {
- ResourceFilter recurseFilter = new UrlExcludeResourceFilter(lib.toURL());
- unit.addAttachment(ResourceFilter.class.getName() + ".recurse", recurseFilter, ResourceFilter.class);
- log.debug("Excluding ear's lib directory: " + lib);
- }
- }
- catch (Exception e)
- {
- throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e);
- }
- }
-
- /**
- * Do exclude based on url.
- */
- private class UrlExcludeResourceFilter implements ResourceFilter
- {
- private URL url;
-
- private UrlExcludeResourceFilter(URL url)
- {
- if (url == null)
- throw new IllegalArgumentException("Null url");
- this.url = url;
- }
-
- public boolean accepts(ResourceContext rc)
- {
- return url.equals(rc.getUrl()) == false;
- }
- }
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.net.URL;
+
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Exclude ear's lib from AnnotationEnvironmentDeployer / OptAnnotationMetaDataDeployer processing.
+ *
+ * @author Ales.Justin at jboss.org
+ */
+public class EarLibExcludeDeployer extends AbstractSimpleVFSRealDeployer<JBossAppMetaData>
+{
+ public EarLibExcludeDeployer()
+ {
+ super(JBossAppMetaData.class);
+ setStage(DeploymentStages.POST_CLASSLOADER);
+ setOutputs(ResourceFilter.class.getName() + ".recurse");
+ setTopLevelOnly(true);
+ }
+
+ public void deploy(VFSDeploymentUnit unit, JBossAppMetaData jBossAppMetaData) throws DeploymentException
+ {
+ try
+ {
+ VirtualFile root = unit.getRoot();
+ String libDir = jBossAppMetaData.getLibraryDirectory();
+ if (libDir == null || libDir.length() == 0) // take 'lib' even on empty
+ libDir = "lib";
+ VirtualFile lib = root.getChild(libDir);
+ if (lib != null)
+ {
+ ResourceFilter recurseFilter = new UrlExcludeResourceFilter(lib.toURL());
+ unit.addAttachment(ResourceFilter.class.getName() + ".recurse", recurseFilter, ResourceFilter.class);
+ log.debug("Excluding ear's lib directory: " + lib);
+ }
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e);
+ }
+ }
+
+ /**
+ * Do exclude based on url.
+ */
+ private class UrlExcludeResourceFilter implements ResourceFilter
+ {
+ private URL url;
+
+ private UrlExcludeResourceFilter(URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("Null url");
+ this.url = url;
+ }
+
+ public boolean accepts(ResourceContext rc)
+ {
+ return url.equals(rc.getUrl()) == false;
+ }
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/EarLibExcludeDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EarSecurityDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EarSecurityDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EarSecurityDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,59 +1,59 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-import org.jboss.deployment.security.AbstractSecurityDeployer;
-import org.jboss.deployment.security.EarJaccPolicy;
-import org.jboss.deployment.security.EarPolicyConfigurationFacade;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-
-//$Id$
-
-/**
- * Security Deployer for ear
- * @author Anil.Saldhana at redhat.com
- * @since Feb 17, 2008
- * @version $Revision$
- */
-public class EarSecurityDeployer extends AbstractSecurityDeployer<JBossAppMetaData>
-{
-
- @Override
- protected ServiceMetaData getServiceMetaData()
- {
- ServiceMetaData subjaccPolicy = new ServiceMetaData();
- subjaccPolicy.setCode(EarPolicyConfigurationFacade.class.getName());
- return subjaccPolicy;
- }
-
- @Override
- protected Class<JBossAppMetaData> getMetaDataClassType()
- {
- return JBossAppMetaData.class;
- }
-
- protected String getJaccPolicyName()
- {
- return EarJaccPolicy.class.getName();
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+import org.jboss.deployment.security.AbstractSecurityDeployer;
+import org.jboss.deployment.security.EarJaccPolicy;
+import org.jboss.deployment.security.EarPolicyConfigurationFacade;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+//$Id$
+
+/**
+ * Security Deployer for ear
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 17, 2008
+ * @version $Revision$
+ */
+public class EarSecurityDeployer extends AbstractSecurityDeployer<JBossAppMetaData>
+{
+
+ @Override
+ protected ServiceMetaData getServiceMetaData()
+ {
+ ServiceMetaData subjaccPolicy = new ServiceMetaData();
+ subjaccPolicy.setCode(EarPolicyConfigurationFacade.class.getName());
+ return subjaccPolicy;
+ }
+
+ @Override
+ protected Class<JBossAppMetaData> getMetaDataClassType()
+ {
+ return JBossAppMetaData.class;
+ }
+
+ protected String getJaccPolicyName()
+ {
+ return EarJaccPolicy.class.getName();
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/EarSecurityDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,62 +1,62 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-
-/**
- * EjbClassLoaderDeployer.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class EjbClassLoaderDeployer extends AbstractSimpleRealDeployer<JBossMetaData>
-{
- /**
- * Create a new EjbClassLoaderDeployer.
- */
- public EjbClassLoaderDeployer()
- {
- super(JBossMetaData.class);
- setOutput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, JBossMetaData metaData) throws DeploymentException
- {
- ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
- if (classLoadingMetaData != null)
- return;
-
- LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
- if (lrmd != null)
- LoaderRepositoryMetaDataHelper.create(unit, lrmd);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * EjbClassLoaderDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EjbClassLoaderDeployer extends AbstractSimpleRealDeployer<JBossMetaData>
+{
+ /**
+ * Create a new EjbClassLoaderDeployer.
+ */
+ public EjbClassLoaderDeployer()
+ {
+ super(JBossMetaData.class);
+ setOutput(ClassLoadingMetaData.class);
+ setStage(DeploymentStages.POST_PARSE);
+ setTopLevelOnly(true);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, JBossMetaData metaData) throws DeploymentException
+ {
+ ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+ if (classLoadingMetaData != null)
+ return;
+
+ LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
+ if (lrmd != null)
+ LoaderRepositoryMetaDataHelper.create(unit, lrmd);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EjbParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EjbParsingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EjbParsingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,49 +1,49 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-
-/**
- * An SchemaResolverDeployer for translating ejb-jar.xml descriptors into
- * EjbJarMetaData instances.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision$
- */
- at SuppressWarnings("deprecation")
- at JMX(name="jboss.ejb:service=EjbParsingDeployer", exposedInterface=EjbParsingDeployerMBean.class)
-public class EjbParsingDeployer extends SchemaResolverDeployer<EjbJarMetaData> implements EjbParsingDeployerMBean
-{
- /**
- * Create a new EjbParsingDeployer.
- */
- public EjbParsingDeployer()
- {
- super(EjbJarMetaData.class);
- setName("ejb-jar.xml");
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+
+/**
+ * An SchemaResolverDeployer for translating ejb-jar.xml descriptors into
+ * EjbJarMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+ at SuppressWarnings("deprecation")
+ at JMX(name="jboss.ejb:service=EjbParsingDeployer", exposedInterface=EjbParsingDeployerMBean.class)
+public class EjbParsingDeployer extends SchemaResolverDeployer<EjbJarMetaData> implements EjbParsingDeployerMBean
+{
+ /**
+ * Create a new EjbParsingDeployer.
+ */
+ public EjbParsingDeployer()
+ {
+ super(EjbJarMetaData.class);
+ setName("ejb-jar.xml");
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/EjbParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/EjbParsingDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EjbParsingDeployerMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/EjbParsingDeployerMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,81 +1,81 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-/**
- * EjbParsingDeployerMBean.
- *
- * FIXME create MBean interfaces for deployers for implementations to extend
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface EjbParsingDeployerMBean
-{
- /**
- * Get the name.
- *
- * @return the name.
- */
- String getName();
-
- /**
- * Get the suffix.
- *
- * @return the suffix.
- */
- String getSuffix();
-
- /**
- * Get the includeDeploymentFile.
- *
- * @return the includeDeploymentFile.
- */
- boolean isIncludeDeploymentFile();
-
- /**
- * Get the useSchemaValidation.
- *
- * @return the useSchemaValidation.
- */
- boolean isUseSchemaValidation();
-
- /**
- * Set the useSchemaValidation.
- *
- * @param useSchemaValidation the useSchemaValidation.
- */
- void setUseSchemaValidation(boolean useSchemaValidation);
-
- /**
- * Get the useValidation.
- *
- * @return the useValidation.
- */
- boolean isUseValidation();
-
- /**
- * Set the useValidation.
- *
- * @param useValidation the useValidation.
- */
- void setUseValidation(boolean useValidation);
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+/**
+ * EjbParsingDeployerMBean.
+ *
+ * FIXME create MBean interfaces for deployers for implementations to extend
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EjbParsingDeployerMBean
+{
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ String getName();
+
+ /**
+ * Get the suffix.
+ *
+ * @return the suffix.
+ */
+ String getSuffix();
+
+ /**
+ * Get the includeDeploymentFile.
+ *
+ * @return the includeDeploymentFile.
+ */
+ boolean isIncludeDeploymentFile();
+
+ /**
+ * Get the useSchemaValidation.
+ *
+ * @return the useSchemaValidation.
+ */
+ boolean isUseSchemaValidation();
+
+ /**
+ * Set the useSchemaValidation.
+ *
+ * @param useSchemaValidation the useSchemaValidation.
+ */
+ void setUseSchemaValidation(boolean useSchemaValidation);
+
+ /**
+ * Get the useValidation.
+ *
+ * @return the useValidation.
+ */
+ boolean isUseValidation();
+
+ /**
+ * Set the useValidation.
+ *
+ * @param useValidation the useValidation.
+ */
+ void setUseValidation(boolean useValidation);
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/EjbParsingDeployerMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,143 +1,143 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.metadata.ear.spec.EarMetaData;
-
-/**
- * An ObjectModelFactoryDeployer for translating jboss-app.xml descriptors into
- * JBossAppMetaData instances.
- *
- * @author Scott.Stark at jboss.org
- * @author Anil.Saldhana at redhat.com
- * @author adrian at jboss.org
- * @version $Revision$
- */
- at JMX(name="jboss.j2ee:service=EARDeployer", exposedInterface=JBossAppParsingDeployerMBean.class)
-public class JBossAppParsingDeployer extends SchemaResolverDeployer<JBossAppMetaData> implements JBossAppParsingDeployerMBean
-{
- private boolean callByValue = false;
-
- private String unauthenticatedIdentity = null;
-
- /**
- * Create a new JBossAppParsingDeployer.
- */
- public JBossAppParsingDeployer()
- {
- super(JBossAppMetaData.class);
- //setInput(JBoss50Aporg.jboss.metadata.ear.spec.EarMetaDatapMetaData.class);
- setName("jboss-app.xml");
- }
-
- /**
- * Get the virtual file path for the application descriptor in the
- * DeploymentContext.getMetaDataPath.
- *
- * @return the current virtual file path for the application descriptor
- */
- public String getAppXmlPath()
- {
- return getName();
- }
- /**
- * Set the virtual file path for the application descriptor in the
- * DeploymentContext.getMetaDataLocation. The standard path is jboss-app.xml
- * to be found in the META-INF metdata path.
- *
- * @param appXmlPath - new virtual file path for the application descriptor
- */
- public void setAppXmlPath(String appXmlPath)
- {
- setName(appXmlPath);
- }
-
- /**
- * @return whether ear deployments should be call by value
- */
- public boolean isCallByValue()
- {
- return callByValue;
- }
-
- /**
- * @param callByValue whether ear deployments should be call by value
- */
- public void setCallByValue(boolean callByValue)
- {
- this.callByValue = callByValue;
- }
-
- /**
- * Obtain an unauthenticated identity
- *
- * @return the unauthenticated identity
- */
- public String getUnauthenticatedIdentity()
- {
- return unauthenticatedIdentity;
- }
-
- /**
- * Specify an unauthenticated identity
- * @param unauthenticatedIdentity
- */
- public void setUnauthenticatedIdentity(String unauthenticatedIdentity)
- {
- this.unauthenticatedIdentity = unauthenticatedIdentity;
- }
-
-
- // FIXME This should all be in a seperate deployer
- @Override
- protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
- {
- super.createMetaData(unit, name, suffix);
- EarMetaData specMetaData = unit.getAttachment(EarMetaData.class);
- JBossAppMetaData metaData = unit.getAttachment(JBossAppMetaData.class);
- if(specMetaData == null && metaData == null)
- return;
-
- // If there no JBossMetaData was created from a jboss-app.xml, create one
- if (metaData == null)
- metaData = new JBossAppMetaData();
-
- // Create a merged view
- JBossAppMetaData mergedMetaData = new JBossAppMetaData();
- mergedMetaData.merge(metaData, specMetaData);
- // Set the merged as the output
- unit.getTransientManagedObjects().addAttachment(JBossAppMetaData.class, mergedMetaData);
- // Keep the raw parsed metadata as well
- unit.addAttachment("Raw"+JBossAppMetaData.class.getName(), metaData, JBossAppMetaData.class);
- // Pass the ear callByValue setting
- if (isCallByValue())
- unit.addAttachment("EAR.callByValue", Boolean.TRUE, Boolean.class);
- //Pass the unauthenticated identity
- if (this.unauthenticatedIdentity != null)
- unit.addAttachment("EAR.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ear.spec.EarMetaData;
+
+/**
+ * An ObjectModelFactoryDeployer for translating jboss-app.xml descriptors into
+ * JBossAppMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Anil.Saldhana at redhat.com
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+ at JMX(name="jboss.j2ee:service=EARDeployer", exposedInterface=JBossAppParsingDeployerMBean.class)
+public class JBossAppParsingDeployer extends SchemaResolverDeployer<JBossAppMetaData> implements JBossAppParsingDeployerMBean
+{
+ private boolean callByValue = false;
+
+ private String unauthenticatedIdentity = null;
+
+ /**
+ * Create a new JBossAppParsingDeployer.
+ */
+ public JBossAppParsingDeployer()
+ {
+ super(JBossAppMetaData.class);
+ //setInput(JBoss50Aporg.jboss.metadata.ear.spec.EarMetaDatapMetaData.class);
+ setName("jboss-app.xml");
+ }
+
+ /**
+ * Get the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataPath.
+ *
+ * @return the current virtual file path for the application descriptor
+ */
+ public String getAppXmlPath()
+ {
+ return getName();
+ }
+ /**
+ * Set the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataLocation. The standard path is jboss-app.xml
+ * to be found in the META-INF metdata path.
+ *
+ * @param appXmlPath - new virtual file path for the application descriptor
+ */
+ public void setAppXmlPath(String appXmlPath)
+ {
+ setName(appXmlPath);
+ }
+
+ /**
+ * @return whether ear deployments should be call by value
+ */
+ public boolean isCallByValue()
+ {
+ return callByValue;
+ }
+
+ /**
+ * @param callByValue whether ear deployments should be call by value
+ */
+ public void setCallByValue(boolean callByValue)
+ {
+ this.callByValue = callByValue;
+ }
+
+ /**
+ * Obtain an unauthenticated identity
+ *
+ * @return the unauthenticated identity
+ */
+ public String getUnauthenticatedIdentity()
+ {
+ return unauthenticatedIdentity;
+ }
+
+ /**
+ * Specify an unauthenticated identity
+ * @param unauthenticatedIdentity
+ */
+ public void setUnauthenticatedIdentity(String unauthenticatedIdentity)
+ {
+ this.unauthenticatedIdentity = unauthenticatedIdentity;
+ }
+
+
+ // FIXME This should all be in a seperate deployer
+ @Override
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
+ {
+ super.createMetaData(unit, name, suffix);
+ EarMetaData specMetaData = unit.getAttachment(EarMetaData.class);
+ JBossAppMetaData metaData = unit.getAttachment(JBossAppMetaData.class);
+ if(specMetaData == null && metaData == null)
+ return;
+
+ // If there no JBossMetaData was created from a jboss-app.xml, create one
+ if (metaData == null)
+ metaData = new JBossAppMetaData();
+
+ // Create a merged view
+ JBossAppMetaData mergedMetaData = new JBossAppMetaData();
+ mergedMetaData.merge(metaData, specMetaData);
+ // Set the merged as the output
+ unit.getTransientManagedObjects().addAttachment(JBossAppMetaData.class, mergedMetaData);
+ // Keep the raw parsed metadata as well
+ unit.addAttachment("Raw"+JBossAppMetaData.class.getName(), metaData, JBossAppMetaData.class);
+ // Pass the ear callByValue setting
+ if (isCallByValue())
+ unit.addAttachment("EAR.callByValue", Boolean.TRUE, Boolean.class);
+ //Pass the unauthenticated identity
+ if (this.unauthenticatedIdentity != null)
+ unit.addAttachment("EAR.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,34 +1,34 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-/**
- * JBossAppParsingDeployerMBean.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface JBossAppParsingDeployerMBean
-{
- boolean isCallByValue();
- void setCallByValue(boolean callByValue);
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+/**
+ * JBossAppParsingDeployerMBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface JBossAppParsingDeployerMBean
+{
+ boolean isCallByValue();
+ void setCallByValue(boolean callByValue);
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,149 +1,149 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.net.URL;
-
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.ApplicationMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * An ObjectModelFactoryDeployer for translating jboss.xml descriptors into
- * JBossMetaData instances.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision:$
- */
- at SuppressWarnings("deprecation")
-public class JBossEjbParsingDeployer extends SchemaResolverDeployer<JBossMetaData>
-{
- private JBossMetaData standardMetaData;
- /** URL to standardjboss.xml */
- private URL standardJBossXmlPath;
- /** Whether a missing standardjboss.xml should be ignored */
- private boolean ignoreMissingStandardJBossXml = false;
-
- /**
- * Create a new JBossEjbParsingDeployer.
- */
- public JBossEjbParsingDeployer()
- {
- // Output the jboss.xml metadata
- super(JBossMetaData.class);
- setName("jboss.xml");
-
- // Optional ejb-jar.xml metadata
- addInput(EjbJarMetaData.class);
- // Output the legacy jboss ejb metadata
- addOutput(ApplicationMetaData.class.getName());
- // Output the standardjboss.xml metadata
- addOutput("standardjboss.xml");
- }
-
- public URL getStandardJBossXmlPath()
- {
- return standardJBossXmlPath;
- }
- public void setStandardJBossXmlPath(URL standardJBossXmlPath)
- {
- this.standardJBossXmlPath = standardJBossXmlPath;
- }
-
-
- public boolean isIgnoreMissingStandardJBossXml()
- {
- return ignoreMissingStandardJBossXml;
- }
- public void setIgnoreMissingStandardJBossXml(
- boolean ignoreMissingStandardJBossXml)
- {
- this.ignoreMissingStandardJBossXml = ignoreMissingStandardJBossXml;
- }
-
- // FIXME This should not be here
- @Override
- protected void createMetaData(DeploymentUnit unit, String name, String suffix)
- throws DeploymentException
- {
- super.createMetaData(unit, name, suffix);
-
- JBossMetaData jbossMetaData = unit.getAttachment(getOutput());
- EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class);
- if (ejbJarMetaData != null || jbossMetaData != null)
- {
- // Save this as a transient(non-managed) attachment
- JBossMetaData stdMetaData = getStandardMetaData();
- if(stdMetaData != null)
- unit.addAttachment("standardjboss.xml", stdMetaData);
-
- if (jbossMetaData != null)
- {
- // For legacy - but its totally redundant????
- ApplicationMetaData amd = new ApplicationMetaData(jbossMetaData);
- unit.addAttachment(ApplicationMetaData.class, amd);
- }
- }
- }
-
- private JBossMetaData getStandardMetaData() throws DeploymentException
- {
- if (standardMetaData == null)
- {
- try
- {
- if(standardJBossXmlPath == null)
- {
- // Use default server conf/standardjboss.xml location
- String configPath = System.getProperty(ServerConfig.SERVER_CONFIG_URL);
- if(configPath == null )
- {
- if(ignoreMissingStandardJBossXml == false)
- throw new DeploymentException("standardjboss.xml not specified and "+ServerConfig.SERVER_CONFIG_URL+" does not exist");
- return null;
- }
- URL configUrl = new URL(configPath);
- standardJBossXmlPath = new URL(configUrl, "standardjboss.xml");
- }
-
- VirtualFile stdJBoss = VFS.getCachedFile(standardJBossXmlPath);
- if (stdJBoss == null && ignoreMissingStandardJBossXml == false)
- {
- throw new DeploymentException("standardjboss.xml not found in config dir: " + standardJBossXmlPath);
- }
- standardMetaData = super.parse(stdJBoss);
- }
- catch (Exception ex)
- {
- DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
- }
- }
- return standardMetaData;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.ApplicationMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * An ObjectModelFactoryDeployer for translating jboss.xml descriptors into
+ * JBossMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision:$
+ */
+ at SuppressWarnings("deprecation")
+public class JBossEjbParsingDeployer extends SchemaResolverDeployer<JBossMetaData>
+{
+ private JBossMetaData standardMetaData;
+ /** URL to standardjboss.xml */
+ private URL standardJBossXmlPath;
+ /** Whether a missing standardjboss.xml should be ignored */
+ private boolean ignoreMissingStandardJBossXml = false;
+
+ /**
+ * Create a new JBossEjbParsingDeployer.
+ */
+ public JBossEjbParsingDeployer()
+ {
+ // Output the jboss.xml metadata
+ super(JBossMetaData.class);
+ setName("jboss.xml");
+
+ // Optional ejb-jar.xml metadata
+ addInput(EjbJarMetaData.class);
+ // Output the legacy jboss ejb metadata
+ addOutput(ApplicationMetaData.class.getName());
+ // Output the standardjboss.xml metadata
+ addOutput("standardjboss.xml");
+ }
+
+ public URL getStandardJBossXmlPath()
+ {
+ return standardJBossXmlPath;
+ }
+ public void setStandardJBossXmlPath(URL standardJBossXmlPath)
+ {
+ this.standardJBossXmlPath = standardJBossXmlPath;
+ }
+
+
+ public boolean isIgnoreMissingStandardJBossXml()
+ {
+ return ignoreMissingStandardJBossXml;
+ }
+ public void setIgnoreMissingStandardJBossXml(
+ boolean ignoreMissingStandardJBossXml)
+ {
+ this.ignoreMissingStandardJBossXml = ignoreMissingStandardJBossXml;
+ }
+
+ // FIXME This should not be here
+ @Override
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix)
+ throws DeploymentException
+ {
+ super.createMetaData(unit, name, suffix);
+
+ JBossMetaData jbossMetaData = unit.getAttachment(getOutput());
+ EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class);
+ if (ejbJarMetaData != null || jbossMetaData != null)
+ {
+ // Save this as a transient(non-managed) attachment
+ JBossMetaData stdMetaData = getStandardMetaData();
+ if(stdMetaData != null)
+ unit.addAttachment("standardjboss.xml", stdMetaData);
+
+ if (jbossMetaData != null)
+ {
+ // For legacy - but its totally redundant????
+ ApplicationMetaData amd = new ApplicationMetaData(jbossMetaData);
+ unit.addAttachment(ApplicationMetaData.class, amd);
+ }
+ }
+ }
+
+ private JBossMetaData getStandardMetaData() throws DeploymentException
+ {
+ if (standardMetaData == null)
+ {
+ try
+ {
+ if(standardJBossXmlPath == null)
+ {
+ // Use default server conf/standardjboss.xml location
+ String configPath = System.getProperty(ServerConfig.SERVER_CONFIG_URL);
+ if(configPath == null )
+ {
+ if(ignoreMissingStandardJBossXml == false)
+ throw new DeploymentException("standardjboss.xml not specified and "+ServerConfig.SERVER_CONFIG_URL+" does not exist");
+ return null;
+ }
+ URL configUrl = new URL(configPath);
+ standardJBossXmlPath = new URL(configUrl, "standardjboss.xml");
+ }
+
+ VirtualFile stdJBoss = VFS.getCachedFile(standardJBossXmlPath);
+ if (stdJBoss == null && ignoreMissingStandardJBossXml == false)
+ {
+ throw new DeploymentException("standardjboss.xml not found in config dir: " + standardJBossXmlPath);
+ }
+ standardMetaData = super.parse(stdJBoss);
+ }
+ catch (Exception ex)
+ {
+ DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
+ }
+ }
+ return standardMetaData;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/JBossWebAppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossWebAppParsingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/JBossWebAppParsingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,114 +1,114 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.spec.WebMetaData;
-
-/**
- * An ObjectModelFactoryDeployer for translating jboss-web.xml descriptors into
- * WebMetaData instances.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision:$
- */
-public class JBossWebAppParsingDeployer extends SchemaResolverDeployer<JBossWebMetaData>
-{
- /**
- * Create a new JBossWebAppParsingDeployer.
- */
- public JBossWebAppParsingDeployer()
- {
- super(JBossWebMetaData.class);
- setInput(WebMetaData.class);
- setName("jboss-web.xml");
- }
-
- /**
- * Get the virtual file path for the jboss-web descriptor in the
- * DeploymentContext.getMetaDataPath.
- *
- * @return the current virtual file path for the web-app descriptor
- */
- public String getWebXmlPath()
- {
- return getName();
- }
- /**
- * Set the virtual file path for the jboss-web descriptor in the
- * DeploymentContext.getMetaDataLocation. The standard path is jboss-web.xml
- * to be found in the WEB-INF metdata path.
- *
- * @param webXmlPath - new virtual file path for the web-app descriptor
- */
- public void setWebXmlPath(String webXmlPath)
- {
- setName(webXmlPath);
- }
-
- @Override
- protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
- {
- super.createMetaData(unit, name, suffix);
- // Merge the spec metadata
- WebMetaData specMetaData = unit.getAttachment(WebMetaData.class);
- JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
- if(specMetaData == null && metaData == null)
- return;
-
- // If there no JBossWebMetaData was created from a jboss-web.xml, create one
- if (metaData == null)
- {
- metaData = new JBossWebMetaData();
- }
- // Create a merged view
- JBossWebMetaData mergedMetaData = new JBossWebMetaData();
- mergedMetaData.merge(metaData, specMetaData);
- // Set the merged as the output
- unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedMetaData);
- // Keep the raw parsed metadata as well
- unit.addAttachment("Raw"+JBossWebMetaData.class.getName(), metaData, JBossWebMetaData.class);
- }
-
- /**
- * Make sure we always have a JBossWebMetaData object attached, even if there is no jboss-web.xml
- * in the deployment
- */
- @Override
- protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException
- {
- super.createMetaData(unit, name, suffix, key);
-
- WebMetaData wmd = unit.getTransientManagedObjects().getAttachment(WebMetaData.class);
- JBossWebMetaData result = unit.getTransientManagedObjects().getAttachment(getOutput());
- if (result == null && wmd != null)
- {
- result = new JBossWebMetaData();
- result.merge(null, wmd);
- unit.getTransientManagedObjects().addAttachment(key, result, getOutput());
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+
+/**
+ * An ObjectModelFactoryDeployer for translating jboss-web.xml descriptors into
+ * WebMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision:$
+ */
+public class JBossWebAppParsingDeployer extends SchemaResolverDeployer<JBossWebMetaData>
+{
+ /**
+ * Create a new JBossWebAppParsingDeployer.
+ */
+ public JBossWebAppParsingDeployer()
+ {
+ super(JBossWebMetaData.class);
+ setInput(WebMetaData.class);
+ setName("jboss-web.xml");
+ }
+
+ /**
+ * Get the virtual file path for the jboss-web descriptor in the
+ * DeploymentContext.getMetaDataPath.
+ *
+ * @return the current virtual file path for the web-app descriptor
+ */
+ public String getWebXmlPath()
+ {
+ return getName();
+ }
+ /**
+ * Set the virtual file path for the jboss-web descriptor in the
+ * DeploymentContext.getMetaDataLocation. The standard path is jboss-web.xml
+ * to be found in the WEB-INF metdata path.
+ *
+ * @param webXmlPath - new virtual file path for the web-app descriptor
+ */
+ public void setWebXmlPath(String webXmlPath)
+ {
+ setName(webXmlPath);
+ }
+
+ @Override
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
+ {
+ super.createMetaData(unit, name, suffix);
+ // Merge the spec metadata
+ WebMetaData specMetaData = unit.getAttachment(WebMetaData.class);
+ JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class);
+ if(specMetaData == null && metaData == null)
+ return;
+
+ // If there no JBossWebMetaData was created from a jboss-web.xml, create one
+ if (metaData == null)
+ {
+ metaData = new JBossWebMetaData();
+ }
+ // Create a merged view
+ JBossWebMetaData mergedMetaData = new JBossWebMetaData();
+ mergedMetaData.merge(metaData, specMetaData);
+ // Set the merged as the output
+ unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedMetaData);
+ // Keep the raw parsed metadata as well
+ unit.addAttachment("Raw"+JBossWebMetaData.class.getName(), metaData, JBossWebMetaData.class);
+ }
+
+ /**
+ * Make sure we always have a JBossWebMetaData object attached, even if there is no jboss-web.xml
+ * in the deployment
+ */
+ @Override
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException
+ {
+ super.createMetaData(unit, name, suffix, key);
+
+ WebMetaData wmd = unit.getTransientManagedObjects().getAttachment(WebMetaData.class);
+ JBossWebMetaData result = unit.getTransientManagedObjects().getAttachment(getOutput());
+ if (result == null && wmd != null)
+ {
+ result = new JBossWebMetaData();
+ result.merge(null, wmd);
+ unit.getTransientManagedObjects().addAttachment(key, result, getOutput());
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/JBossWebAppParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/JaccCommitDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JaccCommitDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/JaccCommitDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,72 +1,72 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * Second phase of JACC Policy deployment. If the DU has a policy attachment
- * link it to any parent PC and then commit it.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 57082 $
- */
-public class JaccCommitDeployer extends AbstractRealDeployer
-{
- /**
- * Create a new JaccCommitDeployer.
- */
- public JaccCommitDeployer()
- {
- setInput(PolicyConfiguration.class);
- }
-
- public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException
- {
- PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class);
- if (pc == null)
- return;
-
- DeploymentUnit parent = unit.getParent();
- if (parent == null)
- throw new IllegalStateException("Unit has not parent: " + unit);
- PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class);
- try
- {
- if (parentPc != null && pc != parentPc)
- {
- parentPc.linkConfiguration(pc);
- }
- pc.commit();
- }
- catch (PolicyContextException e)
- {
- throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e);
- }
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Second phase of JACC Policy deployment. If the DU has a policy attachment
+ * link it to any parent PC and then commit it.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision: 57082 $
+ */
+public class JaccCommitDeployer extends AbstractRealDeployer
+{
+ /**
+ * Create a new JaccCommitDeployer.
+ */
+ public JaccCommitDeployer()
+ {
+ setInput(PolicyConfiguration.class);
+ }
+
+ public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException
+ {
+ PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class);
+ if (pc == null)
+ return;
+
+ DeploymentUnit parent = unit.getParent();
+ if (parent == null)
+ throw new IllegalStateException("Unit has not parent: " + unit);
+ PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class);
+ try
+ {
+ if (parentPc != null && pc != parentPc)
+ {
+ parentPc.linkConfiguration(pc);
+ }
+ pc.commit();
+ }
+ catch (PolicyContextException e)
+ {
+ throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e);
+ }
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/JaccCommitDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/JaccInitializationDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JaccInitializationDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/JaccInitializationDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,89 +1,89 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment;
-
-import java.util.Set;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * Create a JACC policy if the DeploymentUnit contains a named attachment
- * for example, if it contains org.jboss.metadata.ear.spec.EarMetaData.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 57082 $
- */
-public class JaccInitializationDeployer extends AbstractRealDeployer
-{
- /**
- * Create a new JaccInitializationDeployer.
- */
- public JaccInitializationDeployer()
- {
- setOutput(PolicyConfiguration.class);
- }
-
- private Set<String> acceptedAttachments;
-
- public Set<String> getAcceptedAttachments()
- {
- return acceptedAttachments;
- }
-
- public void setAcceptedAttachments(Set<String> acceptedAttachments)
- {
- this.acceptedAttachments = acceptedAttachments;
- }
-
- public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException
- {
- boolean accepted = false;
- for (String accept : acceptedAttachments)
- {
- if (unit.isAttachmentPresent(accept))
- {
- accepted = true;
- break;
- }
- }
- if (accepted == false)
- return;
-
- String contextID = unit.getName();
- PolicyConfiguration pc = null;
- try
- {
- PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- pc = pcFactory.getPolicyConfiguration(contextID, true);
- }
- catch (Exception e)
- {
- throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e);
- }
- unit.addAttachment(PolicyConfiguration.class, pc);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment;
+
+import java.util.Set;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Create a JACC policy if the DeploymentUnit contains a named attachment
+ * for example, if it contains org.jboss.metadata.ear.spec.EarMetaData.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision: 57082 $
+ */
+public class JaccInitializationDeployer extends AbstractRealDeployer
+{
+ /**
+ * Create a new JaccInitializationDeployer.
+ */
+ public JaccInitializationDeployer()
+ {
+ setOutput(PolicyConfiguration.class);
+ }
+
+ private Set<String> acceptedAttachments;
+
+ public Set<String> getAcceptedAttachments()
+ {
+ return acceptedAttachments;
+ }
+
+ public void setAcceptedAttachments(Set<String> acceptedAttachments)
+ {
+ this.acceptedAttachments = acceptedAttachments;
+ }
+
+ public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException
+ {
+ boolean accepted = false;
+ for (String accept : acceptedAttachments)
+ {
+ if (unit.isAttachmentPresent(accept))
+ {
+ accepted = true;
+ break;
+ }
+ }
+ if (accepted == false)
+ return;
+
+ String contextID = unit.getName();
+ PolicyConfiguration pc = null;
+ try
+ {
+ PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ pc = pcFactory.getPolicyConfiguration(contextID, true);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e);
+ }
+ unit.addAttachment(PolicyConfiguration.class, pc);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/JaccInitializationDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/LegacyWebXmlLessDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/LegacyWebXmlLessDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/LegacyWebXmlLessDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,63 +1,63 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.spec.WebMetaData;
-
-/**
- * Support jsp's w/o web.xml.
- * See JBAS-6062 for more details.
- *
- * @author ales.justin at jboss.org
- */
-public class LegacyWebXmlLessDeployer extends AbstractDeployer
-{
- public LegacyWebXmlLessDeployer()
- {
- addInput(WebMetaData.class);
- addInput(JBossWebMetaData.class);
- setOutput(JBossWebMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- }
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- if (unit.getSimpleName().endsWith(".war"))
- {
- if (unit.isAttachmentPresent(JBossWebMetaData.class))
- return;
-
- // only care about true deployments
- if (unit instanceof VFSDeploymentUnit == false)
- return;
-
- log.debug("Web archive doesn't contain web.xml: " + unit.getName());
- unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, new JBossWebMetaData());
- }
- }
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+
+/**
+ * Support jsp's w/o web.xml.
+ * See JBAS-6062 for more details.
+ *
+ * @author ales.justin at jboss.org
+ */
+public class LegacyWebXmlLessDeployer extends AbstractDeployer
+{
+ public LegacyWebXmlLessDeployer()
+ {
+ addInput(WebMetaData.class);
+ addInput(JBossWebMetaData.class);
+ setOutput(JBossWebMetaData.class);
+ setStage(DeploymentStages.POST_PARSE);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if (unit.getSimpleName().endsWith(".war"))
+ {
+ if (unit.isAttachmentPresent(JBossWebMetaData.class))
+ return;
+
+ // only care about true deployments
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ log.debug("Web archive doesn't contain web.xml: " + unit.getName());
+ unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, new JBossWebMetaData());
+ }
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/LegacyWebXmlLessDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,158 +1,158 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* 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.deployment;
-
-import java.util.Set;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.common.jboss.LoaderRepositoryConfigMetaData;
-import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.mx.server.ServerConstants;
-import org.jboss.system.deployers.LoaderRepositoryConfigHelper;
-
-/**
- * LoaderRepositoryMetaDataHelper.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class LoaderRepositoryMetaDataHelper
-{
- /**
- * Populate the deployment's classloading metadata from a loader repository metadata
- * with parent delegation false.
- *
- * @param unit the deployment unit
- * @param loaderMetaData the loader meta data
- * @return the classloading metadata
- * @throws DeploymentException for any error
- */
- public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException
- {
- return create(unit, loaderMetaData, false);
- }
-
- /**
- * Populate the deployment's classloading metadata from a loader repository metadata
- *
- * @param unit the deployment unit
- * @param loaderMetaData the loader repository metadata
- * @param parentDelegation the default value for parent delegation
- * @return the classloading metadata
- * @throws DeploymentException for any error
- */
- public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException
- {
- if (unit == null)
- throw new IllegalArgumentException("Null unit");
-
- ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class);
- if (clmd != null)
- return clmd;
-
- clmd = create(unit.getName(), loaderMetaData, parentDelegation);
- if (clmd != null)
- unit.addAttachment(ClassLoadingMetaData.class, clmd);
- return clmd;
- }
-
- /**
- * Create classloading metadata from a loader repository metadata
- * with parent delegation false
- *
- * @param deploymentName the deployment name
- * @param loaderMetaData the loader repository metadata
- * @return the classloading metadata
- * @throws DeploymentException for any error
- */
- public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException
- {
- return create(deploymentName, loaderMetaData, false);
- }
-
- /**
- * Create classloading metadata from a loader repository metadata
- *
- * @param deploymentName the deployment name
- * @param loaderMetaData the loader repository metadata
- * @param parentDelegation the default value for parent delegation
- * @return the classloading metadata
- * @throws DeploymentException for any error
- */
- public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException
- {
- if (deploymentName == null)
- throw new IllegalArgumentException("Null deployment name");
- if (loaderMetaData == null)
- throw new IllegalArgumentException("Null loader repository metadata");
-
-
- LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig();
-
- repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass();
- if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0)
- repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS;
-
- // Get the object name of the repository
- String name = loaderMetaData.getName();
- if (name != null)
- {
- try
- {
- repositoryConfig.repositoryName = new ObjectName(name.trim());
- }
- catch (MalformedObjectNameException e)
- {
- throw new DeploymentException("Loader repository name is malformed: " + name, e);
- }
- }
-
- StringBuilder configData = new StringBuilder();
- Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig();
- if (children != null)
- {
- for (LoaderRepositoryConfigMetaData child : children)
- {
- // This looks stupid? Why inside a loop?
- String parserClassName = child.getConfigParserClass();
- if (parserClassName == null || parserClassName.length() == 0)
- repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS;
- else
- repositoryConfig.configParserClassName = parserClassName;
-
- // Append all config
- String childConfig = child.getConfig();
- if (childConfig != null)
- configData.append(childConfig);
- }
- }
- repositoryConfig.repositoryConfig = configData.toString().trim();
-
- return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation);
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.deployment;
+
+import java.util.Set;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.common.jboss.LoaderRepositoryConfigMetaData;
+import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.mx.server.ServerConstants;
+import org.jboss.system.deployers.LoaderRepositoryConfigHelper;
+
+/**
+ * LoaderRepositoryMetaDataHelper.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoaderRepositoryMetaDataHelper
+{
+ /**
+ * Populate the deployment's classloading metadata from a loader repository metadata
+ * with parent delegation false.
+ *
+ * @param unit the deployment unit
+ * @param loaderMetaData the loader meta data
+ * @return the classloading metadata
+ * @throws DeploymentException for any error
+ */
+ public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException
+ {
+ return create(unit, loaderMetaData, false);
+ }
+
+ /**
+ * Populate the deployment's classloading metadata from a loader repository metadata
+ *
+ * @param unit the deployment unit
+ * @param loaderMetaData the loader repository metadata
+ * @param parentDelegation the default value for parent delegation
+ * @return the classloading metadata
+ * @throws DeploymentException for any error
+ */
+ public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException
+ {
+ if (unit == null)
+ throw new IllegalArgumentException("Null unit");
+
+ ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class);
+ if (clmd != null)
+ return clmd;
+
+ clmd = create(unit.getName(), loaderMetaData, parentDelegation);
+ if (clmd != null)
+ unit.addAttachment(ClassLoadingMetaData.class, clmd);
+ return clmd;
+ }
+
+ /**
+ * Create classloading metadata from a loader repository metadata
+ * with parent delegation false
+ *
+ * @param deploymentName the deployment name
+ * @param loaderMetaData the loader repository metadata
+ * @return the classloading metadata
+ * @throws DeploymentException for any error
+ */
+ public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException
+ {
+ return create(deploymentName, loaderMetaData, false);
+ }
+
+ /**
+ * Create classloading metadata from a loader repository metadata
+ *
+ * @param deploymentName the deployment name
+ * @param loaderMetaData the loader repository metadata
+ * @param parentDelegation the default value for parent delegation
+ * @return the classloading metadata
+ * @throws DeploymentException for any error
+ */
+ public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException
+ {
+ if (deploymentName == null)
+ throw new IllegalArgumentException("Null deployment name");
+ if (loaderMetaData == null)
+ throw new IllegalArgumentException("Null loader repository metadata");
+
+
+ LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig();
+
+ repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass();
+ if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0)
+ repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS;
+
+ // Get the object name of the repository
+ String name = loaderMetaData.getName();
+ if (name != null)
+ {
+ try
+ {
+ repositoryConfig.repositoryName = new ObjectName(name.trim());
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new DeploymentException("Loader repository name is malformed: " + name, e);
+ }
+ }
+
+ StringBuilder configData = new StringBuilder();
+ Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig();
+ if (children != null)
+ {
+ for (LoaderRepositoryConfigMetaData child : children)
+ {
+ // This looks stupid? Why inside a loop?
+ String parserClassName = child.getConfigParserClass();
+ if (parserClassName == null || parserClassName.length() == 0)
+ repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS;
+ else
+ repositoryConfig.configParserClassName = parserClassName;
+
+ // Append all config
+ String childConfig = child.getConfig();
+ if (childConfig != null)
+ configData.append(childConfig);
+ }
+ }
+ repositoryConfig.repositoryConfig = configData.toString().trim();
+
+ return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,202 +1,202 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
-import org.jboss.deployers.spi.annotations.Element;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.annotation.creator.AbstractCreator;
-import org.jboss.metadata.annotation.creator.AnnotationContext;
-import org.jboss.metadata.annotation.creator.client.ApplicationClient5MetaDataCreator;
-import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
-import org.jboss.metadata.annotation.creator.web.Web25MetaDataCreator;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
-import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.metadata.web.spec.WebMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A POST_CLASSLOADER deployer which generates metadata from annotations.
- * Optimized option to its super class.
- *
- * @author Ales.Justin at jboss.org
- */
-public class OptAnnotationMetaDataDeployer extends AnnotationMetaDataDeployer
-{
- public OptAnnotationMetaDataDeployer()
- {
- super();
- setInput(AnnotationEnvironment.class);
- }
-
- protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
- {
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- if(webMetaData != null)
- {
- processJBossWebMetaData(unit, finder);
- }
- else if (clientMetaData != null)
- {
- String mainClassName = getMainClassName(unit);
- if(mainClassName != null)
- processJBossClientMetaData(unit, finder, mainClassName);
- }
- else
- {
- String mainClassName = getMainClassName(unit);
- if (mainClassName != null)
- processJBossClientMetaData(unit, finder, mainClassName);
- else
- processJBossMetaData(unit, finder);
- }
- }
-
- /**
- * Process jboss web meta data.
- *
- * @param unit the deployment unit
- * @param finder the finder
- */
- protected void processJBossWebMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
- {
- Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
- Collection<Class<?>> classes = getClasses(unit, creator);
- WebMetaData annotationMetaData = creator.create(classes);
- if(annotationMetaData != null)
- unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
- }
-
- /**
- * Process jboss app client meta data.
- *
- * @param unit the deployment unit
- * @param finder the finder
- * @param mainClassName the main class name
- * @throws ClassNotFoundException for any error
- */
- protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, String mainClassName) throws ClassNotFoundException
- {
- ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder, mainClassName);
- Collection<Class<?>> classes = new ArrayList<Class<?>>(1);
- Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName);
- classes.add(mainClass);
- ApplicationClientMetaData annotationMetaData = creator.create(classes);
- if(annotationMetaData != null)
- unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class);
- }
-
- /**
- * Process jboss meta data.
- *
- * @param unit the deployment unit
- * @param finder the finder
- */
- protected void processJBossMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
- {
- // Create the metadata model from the annotations
- EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class);
- JBoss50Creator creator = new JBoss50Creator(ejbJarMetaData, unit.getClassLoader(), finder);
- Collection<Class<?>> classes = getClasses(unit, creator);
- JBossMetaData annotationMetaData = creator.create(classes);
- if(annotationMetaData != null)
- unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class);
- }
-
- /**
- * Get the classes for creator to process.
- *
- * @param unit the deployment unit
- * @param creator the creator
- * @return classes to process
- */
- @SuppressWarnings("unchecked")
- protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, AbstractCreator creator)
- {
- boolean trace = log.isTraceEnabled();
-
- AnnotationEnvironment env = unit.getAttachment(AnnotationEnvironment.class);
- if (env == null)
- {
- if (trace)
- log.trace("Cannot scan classes, missing AnnotationEnvironment as attachment: " + unit.getName());
-
- return Collections.emptySet();
- }
-
- String creatorInfo = creator.toString();
- AnnotationContext context = creator.getAnnotationContext();
- Set<Class<?>> classes = new HashSet<Class<?>>();
-
- Collection<Class<? extends Annotation>> typeAnnotations = context.getTypeAnnotations();
- if (trace)
- log.trace("Creator: " + creatorInfo + ", type annotations: " + typeAnnotations);
- for(Class<? extends Annotation> annotation : typeAnnotations)
- {
- Class<Annotation> annotationClass = (Class<Annotation>)annotation;
- Set<Element<Annotation, Class<?>>> elements = env.classIsAnnotatedWith(annotationClass);
- for(Element<Annotation, Class<?>> elt : elements)
- classes.add(elt.getOwner());
- }
-
- Collection<Class<? extends Annotation>> methodAnnotations = context.getMethodAnnotations();
- if (trace)
- log.trace("Creator: " + creatorInfo + ", method annotations: " + methodAnnotations);
- for(Class<? extends Annotation> annotation : methodAnnotations)
- {
- Class<Annotation> annotationClass = (Class<Annotation>)annotation;
- Set<Element<Annotation, Method>> elements = env.classHasMethodAnnotatedWith(annotationClass);
- for(Element<Annotation, Method> elt : elements)
- classes.add(elt.getOwner());
- }
-
- Collection<Class<? extends Annotation>> fieldAnnotations = context.getFieldAnnotations();
- if (trace)
- log.trace("Creator: " + creatorInfo + ", field annotations: " + fieldAnnotations);
- for(Class<? extends Annotation> annotation : fieldAnnotations)
- {
- Class<Annotation> annotationClass = (Class<Annotation>)annotation;
- Set<Element<Annotation, Field>> elements = env.classHasFieldAnnotatedWith(annotationClass);
- for(Element<Annotation, Field> elt : elements)
- classes.add(elt.getOwner());
- }
-
- if (trace)
- log.trace("Annotated classes [" + unit.getName() + ", " + creatorInfo + "]: " + classes);
-
- return classes;
- }
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
+import org.jboss.deployers.spi.annotations.Element;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.annotation.creator.AbstractCreator;
+import org.jboss.metadata.annotation.creator.AnnotationContext;
+import org.jboss.metadata.annotation.creator.client.ApplicationClient5MetaDataCreator;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.creator.web.Web25MetaDataCreator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A POST_CLASSLOADER deployer which generates metadata from annotations.
+ * Optimized option to its super class.
+ *
+ * @author Ales.Justin at jboss.org
+ */
+public class OptAnnotationMetaDataDeployer extends AnnotationMetaDataDeployer
+{
+ public OptAnnotationMetaDataDeployer()
+ {
+ super();
+ setInput(AnnotationEnvironment.class);
+ }
+
+ protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ if(webMetaData != null)
+ {
+ processJBossWebMetaData(unit, finder);
+ }
+ else if (clientMetaData != null)
+ {
+ String mainClassName = getMainClassName(unit);
+ if(mainClassName != null)
+ processJBossClientMetaData(unit, finder, mainClassName);
+ }
+ else
+ {
+ String mainClassName = getMainClassName(unit);
+ if (mainClassName != null)
+ processJBossClientMetaData(unit, finder, mainClassName);
+ else
+ processJBossMetaData(unit, finder);
+ }
+ }
+
+ /**
+ * Process jboss web meta data.
+ *
+ * @param unit the deployment unit
+ * @param finder the finder
+ */
+ protected void processJBossWebMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
+ {
+ Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
+ Collection<Class<?>> classes = getClasses(unit, creator);
+ WebMetaData annotationMetaData = creator.create(classes);
+ if(annotationMetaData != null)
+ unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
+ }
+
+ /**
+ * Process jboss app client meta data.
+ *
+ * @param unit the deployment unit
+ * @param finder the finder
+ * @param mainClassName the main class name
+ * @throws ClassNotFoundException for any error
+ */
+ protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, String mainClassName) throws ClassNotFoundException
+ {
+ ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder, mainClassName);
+ Collection<Class<?>> classes = new ArrayList<Class<?>>(1);
+ Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName);
+ classes.add(mainClass);
+ ApplicationClientMetaData annotationMetaData = creator.create(classes);
+ if(annotationMetaData != null)
+ unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class);
+ }
+
+ /**
+ * Process jboss meta data.
+ *
+ * @param unit the deployment unit
+ * @param finder the finder
+ */
+ protected void processJBossMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
+ {
+ // Create the metadata model from the annotations
+ EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class);
+ JBoss50Creator creator = new JBoss50Creator(ejbJarMetaData, unit.getClassLoader(), finder);
+ Collection<Class<?>> classes = getClasses(unit, creator);
+ JBossMetaData annotationMetaData = creator.create(classes);
+ if(annotationMetaData != null)
+ unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class);
+ }
+
+ /**
+ * Get the classes for creator to process.
+ *
+ * @param unit the deployment unit
+ * @param creator the creator
+ * @return classes to process
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, AbstractCreator creator)
+ {
+ boolean trace = log.isTraceEnabled();
+
+ AnnotationEnvironment env = unit.getAttachment(AnnotationEnvironment.class);
+ if (env == null)
+ {
+ if (trace)
+ log.trace("Cannot scan classes, missing AnnotationEnvironment as attachment: " + unit.getName());
+
+ return Collections.emptySet();
+ }
+
+ String creatorInfo = creator.toString();
+ AnnotationContext context = creator.getAnnotationContext();
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ Collection<Class<? extends Annotation>> typeAnnotations = context.getTypeAnnotations();
+ if (trace)
+ log.trace("Creator: " + creatorInfo + ", type annotations: " + typeAnnotations);
+ for(Class<? extends Annotation> annotation : typeAnnotations)
+ {
+ Class<Annotation> annotationClass = (Class<Annotation>)annotation;
+ Set<Element<Annotation, Class<?>>> elements = env.classIsAnnotatedWith(annotationClass);
+ for(Element<Annotation, Class<?>> elt : elements)
+ classes.add(elt.getOwner());
+ }
+
+ Collection<Class<? extends Annotation>> methodAnnotations = context.getMethodAnnotations();
+ if (trace)
+ log.trace("Creator: " + creatorInfo + ", method annotations: " + methodAnnotations);
+ for(Class<? extends Annotation> annotation : methodAnnotations)
+ {
+ Class<Annotation> annotationClass = (Class<Annotation>)annotation;
+ Set<Element<Annotation, Method>> elements = env.classHasMethodAnnotatedWith(annotationClass);
+ for(Element<Annotation, Method> elt : elements)
+ classes.add(elt.getOwner());
+ }
+
+ Collection<Class<? extends Annotation>> fieldAnnotations = context.getFieldAnnotations();
+ if (trace)
+ log.trace("Creator: " + creatorInfo + ", field annotations: " + fieldAnnotations);
+ for(Class<? extends Annotation> annotation : fieldAnnotations)
+ {
+ Class<Annotation> annotationClass = (Class<Annotation>)annotation;
+ Set<Element<Annotation, Field>> elements = env.classHasFieldAnnotatedWith(annotationClass);
+ for(Element<Annotation, Field> elt : elements)
+ classes.add(elt.getOwner());
+ }
+
+ if (trace)
+ log.trace("Annotated classes [" + unit.getName() + ", " + creatorInfo + "]: " + classes);
+
+ return classes;
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/WebAppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/WebAppParsingDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/WebAppParsingDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,65 +1,65 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployment;
-
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.web.spec.WebMetaData;
-
-/**
- * An ObjectModelFactoryDeployer for translating web.xml descriptors into
- * WebMetaData instances.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision:$
- */
-public class WebAppParsingDeployer extends SchemaResolverDeployer<WebMetaData>
-{
- public WebAppParsingDeployer()
- {
- super(WebMetaData.class);
- setName("web.xml");
- }
-
- /**
- * Get the virtual file path for the web-app descriptor in the
- * DeploymentContext.getMetaDataPath.
- *
- * @return the current virtual file path for the web-app descriptor
- */
- public String getWebXmlPath()
- {
- return getName();
- }
- /**
- * Set the virtual file path for the web-app descriptor in the
- * DeploymentContext.getMetaDataLocation. The standard path is web.xml
- * to be found in the WEB-INF metdata path.
- *
- * @param webXmlPath - new virtual file path for the web-app descriptor
- */
- public void setWebXmlPath(String webXmlPath)
- {
- setName(webXmlPath);
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment;
+
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.web.spec.WebMetaData;
+
+/**
+ * An ObjectModelFactoryDeployer for translating web.xml descriptors into
+ * WebMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision:$
+ */
+public class WebAppParsingDeployer extends SchemaResolverDeployer<WebMetaData>
+{
+ public WebAppParsingDeployer()
+ {
+ super(WebMetaData.class);
+ setName("web.xml");
+ }
+
+ /**
+ * Get the virtual file path for the web-app descriptor in the
+ * DeploymentContext.getMetaDataPath.
+ *
+ * @return the current virtual file path for the web-app descriptor
+ */
+ public String getWebXmlPath()
+ {
+ return getName();
+ }
+ /**
+ * Set the virtual file path for the web-app descriptor in the
+ * DeploymentContext.getMetaDataLocation. The standard path is web.xml
+ * to be found in the WEB-INF metdata path.
+ *
+ * @param webXmlPath - new virtual file path for the web-app descriptor
+ */
+ public void setWebXmlPath(String webXmlPath)
+ {
+ setName(webXmlPath);
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/WebAppParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyItem.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyItem.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyItem.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,81 +1,81 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment.dependency;
-
-import org.jboss.dependency.plugins.AbstractDependencyItem;
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class ContainerDependencyItem extends AbstractDependencyItem
- implements DependencyItem
-{
- /**
- * Create a dependency on a container.
- *
- * @param containerName - the name of the target container the item depends on
- * @param componentID - the
- * @param whenRequired
- */
- public ContainerDependencyItem(Object containerName,
- String componentID, ControllerState whenRequired)
- {
- super(componentID, containerName, whenRequired, null);
- }
-
- @Override
- public boolean resolve(Controller controller)
- {
- boolean resolved = super.resolve(controller);
- setResolved(resolved);
- return isResolved();
- }
-
- @Override
- public void toString(JBossStringBuilder buffer)
- {
- super.toString(buffer);
- buffer.append(" depend=").append(getName());
- }
-
- @Override
- public void toShortString(JBossStringBuilder buffer)
- {
- buffer.append(getName()).append(" depend ").append(getName());
- }
-
- @Override
- public String toHumanReadableString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("JndiDepends: '");
- builder.append(getName());
- builder.append("'");
- return builder.toString();
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.dependency;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ContainerDependencyItem extends AbstractDependencyItem
+ implements DependencyItem
+{
+ /**
+ * Create a dependency on a container.
+ *
+ * @param containerName - the name of the target container the item depends on
+ * @param componentID - the
+ * @param whenRequired
+ */
+ public ContainerDependencyItem(Object containerName,
+ String componentID, ControllerState whenRequired)
+ {
+ super(componentID, containerName, whenRequired, null);
+ }
+
+ @Override
+ public boolean resolve(Controller controller)
+ {
+ boolean resolved = super.resolve(controller);
+ setResolved(resolved);
+ return isResolved();
+ }
+
+ @Override
+ public void toString(JBossStringBuilder buffer)
+ {
+ super.toString(buffer);
+ buffer.append(" depend=").append(getName());
+ }
+
+ @Override
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(getName()).append(" depend ").append(getName());
+ }
+
+ @Override
+ public String toHumanReadableString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("JndiDepends: '");
+ builder.append(getName());
+ builder.append("'");
+ return builder.toString();
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyItem.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,218 +1,218 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment.dependency;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
-import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
-import org.jboss.util.JBossObject;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * Metadata for an endpoint container and its dependencies on other endpoints.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class ContainerDependencyMetaData extends JBossObject
-{
- private static final long serialVersionUID = 1L;
-
- private static final Logger log = Logger
- .getLogger(ContainerDependencyMetaData.class);
-
- /** The unique name of the deployment root */
- private String deploymentRootName;
- /** The deployment relative path name */
- private String deploymentPath;
- /** The id of the component in the deployment */
- private String componentName;
-
- private Set<String> jndiNames = new HashSet<String>();
-
- /** The jndi name of the container */
- private String containerName;
-
- /** The injection targets this bean container has */
- private Set<ResourceInjectionTargetMetaData> targets = new HashSet<ResourceInjectionTargetMetaData>();
- /** The jndi lookups this bean container has */
- private Set<JndiDependencyMetaData> jndiDepends = new HashSet<JndiDependencyMetaData>();
- /** The jndi names for other container this container depends on */
- private Set<String> jndiAliasDepends = new HashSet<String>();
- /** The jndi binding policy associated with the bean deployment */
- private DefaultJndiBindingPolicy jndiPolicy;
- /** Is this an ejb3 endpoint */
- private boolean isEjb3X;
- private EjbDeploymentSummary unitSummary;
-
- /**
- *
- * @param containerName - the jndi name of the container
- * @param componentName - the unique vfs/component-name id
- * @param deploymentPath - the vfs relative path of the component deployment
- */
- public ContainerDependencyMetaData(String containerName, String componentName, String deploymentPath)
- {
- this.containerName = containerName;
- this.componentName = componentName;
- this.deploymentPath = deploymentPath;
- this.addJndiName(containerName);
- }
-
- public String getComponentName()
- {
- return componentName;
- }
- public String getComponentID()
- {
- return deploymentPath + "#" + componentName;
- }
- public String getDeploymentPath()
- {
- return deploymentPath;
- }
-
- public String getDeploymentRootName()
- {
- return deploymentRootName;
- }
- public void setDeploymentRootName(String deploymentRootName)
- {
- this.deploymentRootName = deploymentRootName;
- }
-
- public String getContainerName()
- {
- return containerName;
- }
-
- public JBossEnterpriseBeanMetaData getBeanMetaData()
- {
- return this.unitSummary.getBeanMD();
- }
-
- public EjbDeploymentSummary getUnitSummary()
- {
- return unitSummary;
- }
- public void setUnitSummary(EjbDeploymentSummary unitSummary)
- {
- this.unitSummary = unitSummary;
- }
-
- public boolean isEjb3X()
- {
- return isEjb3X;
- }
- public void setEjb3X(boolean isEjb3X)
- {
- this.isEjb3X = isEjb3X;
- }
-
- public void addDependency(ContainerDependencyMetaData endpointCDMD)
- {
- jndiAliasDepends.add(endpointCDMD.getContainerName());
- }
-
- public void addInjectionTargets(Set<ResourceInjectionTargetMetaData> injectionTargets)
- {
- log.info("addInjectionTargets, " + injectionTargets);
- this.targets.addAll(injectionTargets);
- }
-
- public Set<ResourceInjectionTargetMetaData> getInjectionTargets()
- {
- return this.targets;
- }
-
- public void addJndiDependency(JndiDependencyMetaData jdmd)
- {
- log.info("addJndiDependency, " + jdmd);
- jndiDepends.add(jdmd);
- }
-
- public Set<JndiDependencyMetaData> getJndiDepends()
- {
- return this.jndiDepends;
- }
- public void addJndiName(String jndiName)
- {
- jndiNames.add(jndiName);
- }
- public Set<String> getJndiNames()
- {
- return jndiNames;
- }
-
- public String toShortString()
- {
- JBossStringBuilder buffer = new JBossStringBuilder();
- toShortString(buffer);
- return buffer.toString();
- }
-
- public void toShortString(JBossStringBuilder buffer)
- {
- buffer.append(containerName);
- }
- @Override
- protected int getHashCode()
- {
- // TODO Auto-generated method stub
- return super.getHashCode();
- }
-
- @Override
- protected String toStringImplementation()
- {
- StringBuilder tmp = new StringBuilder("ContainerDependencyMetaData(");
- tmp.append("deploymentPath=");
- tmp.append(deploymentPath);
- tmp.append(",componentName=");
- tmp.append(this.componentName);
- tmp.append(",containerName=");
- tmp.append(this.containerName);
- tmp.append(",jndiNames=");
- tmp.append(this.jndiNames);
- tmp.append(",jndiAliasDepends=");
- tmp.append(this.jndiAliasDepends);
- tmp.append(",targets=");
- tmp.append(this.targets);
- tmp.append(",jndiDepends=");
- tmp.append(this.jndiDepends);
- tmp.append(")");
- return tmp.toString();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- // TODO Auto-generated method stub
- return super.equals(obj);
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Metadata for an endpoint container and its dependencies on other endpoints.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ContainerDependencyMetaData extends JBossObject
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log = Logger
+ .getLogger(ContainerDependencyMetaData.class);
+
+ /** The unique name of the deployment root */
+ private String deploymentRootName;
+ /** The deployment relative path name */
+ private String deploymentPath;
+ /** The id of the component in the deployment */
+ private String componentName;
+
+ private Set<String> jndiNames = new HashSet<String>();
+
+ /** The jndi name of the container */
+ private String containerName;
+
+ /** The injection targets this bean container has */
+ private Set<ResourceInjectionTargetMetaData> targets = new HashSet<ResourceInjectionTargetMetaData>();
+ /** The jndi lookups this bean container has */
+ private Set<JndiDependencyMetaData> jndiDepends = new HashSet<JndiDependencyMetaData>();
+ /** The jndi names for other container this container depends on */
+ private Set<String> jndiAliasDepends = new HashSet<String>();
+ /** The jndi binding policy associated with the bean deployment */
+ private DefaultJndiBindingPolicy jndiPolicy;
+ /** Is this an ejb3 endpoint */
+ private boolean isEjb3X;
+ private EjbDeploymentSummary unitSummary;
+
+ /**
+ *
+ * @param containerName - the jndi name of the container
+ * @param componentName - the unique vfs/component-name id
+ * @param deploymentPath - the vfs relative path of the component deployment
+ */
+ public ContainerDependencyMetaData(String containerName, String componentName, String deploymentPath)
+ {
+ this.containerName = containerName;
+ this.componentName = componentName;
+ this.deploymentPath = deploymentPath;
+ this.addJndiName(containerName);
+ }
+
+ public String getComponentName()
+ {
+ return componentName;
+ }
+ public String getComponentID()
+ {
+ return deploymentPath + "#" + componentName;
+ }
+ public String getDeploymentPath()
+ {
+ return deploymentPath;
+ }
+
+ public String getDeploymentRootName()
+ {
+ return deploymentRootName;
+ }
+ public void setDeploymentRootName(String deploymentRootName)
+ {
+ this.deploymentRootName = deploymentRootName;
+ }
+
+ public String getContainerName()
+ {
+ return containerName;
+ }
+
+ public JBossEnterpriseBeanMetaData getBeanMetaData()
+ {
+ return this.unitSummary.getBeanMD();
+ }
+
+ public EjbDeploymentSummary getUnitSummary()
+ {
+ return unitSummary;
+ }
+ public void setUnitSummary(EjbDeploymentSummary unitSummary)
+ {
+ this.unitSummary = unitSummary;
+ }
+
+ public boolean isEjb3X()
+ {
+ return isEjb3X;
+ }
+ public void setEjb3X(boolean isEjb3X)
+ {
+ this.isEjb3X = isEjb3X;
+ }
+
+ public void addDependency(ContainerDependencyMetaData endpointCDMD)
+ {
+ jndiAliasDepends.add(endpointCDMD.getContainerName());
+ }
+
+ public void addInjectionTargets(Set<ResourceInjectionTargetMetaData> injectionTargets)
+ {
+ log.info("addInjectionTargets, " + injectionTargets);
+ this.targets.addAll(injectionTargets);
+ }
+
+ public Set<ResourceInjectionTargetMetaData> getInjectionTargets()
+ {
+ return this.targets;
+ }
+
+ public void addJndiDependency(JndiDependencyMetaData jdmd)
+ {
+ log.info("addJndiDependency, " + jdmd);
+ jndiDepends.add(jdmd);
+ }
+
+ public Set<JndiDependencyMetaData> getJndiDepends()
+ {
+ return this.jndiDepends;
+ }
+ public void addJndiName(String jndiName)
+ {
+ jndiNames.add(jndiName);
+ }
+ public Set<String> getJndiNames()
+ {
+ return jndiNames;
+ }
+
+ public String toShortString()
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ toShortString(buffer);
+ return buffer.toString();
+ }
+
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(containerName);
+ }
+ @Override
+ protected int getHashCode()
+ {
+ // TODO Auto-generated method stub
+ return super.getHashCode();
+ }
+
+ @Override
+ protected String toStringImplementation()
+ {
+ StringBuilder tmp = new StringBuilder("ContainerDependencyMetaData(");
+ tmp.append("deploymentPath=");
+ tmp.append(deploymentPath);
+ tmp.append(",componentName=");
+ tmp.append(this.componentName);
+ tmp.append(",containerName=");
+ tmp.append(this.containerName);
+ tmp.append(",jndiNames=");
+ tmp.append(this.jndiNames);
+ tmp.append(",jndiAliasDepends=");
+ tmp.append(this.jndiAliasDepends);
+ tmp.append(",targets=");
+ tmp.append(this.targets);
+ tmp.append(",jndiDepends=");
+ tmp.append(this.jndiDepends);
+ tmp.append(")");
+ return tmp.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ // TODO Auto-generated method stub
+ return super.equals(obj);
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/plugin/LegacyEjb3JndiPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/plugin/LegacyEjb3JndiPolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/plugin/LegacyEjb3JndiPolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,163 +1,163 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.deployment.plugin;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
-
-/**
- * DefaultJndiBindingPolicy that uses the old ejb3 binding name conventions
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class LegacyEjb3JndiPolicy
- implements DefaultJndiBindingPolicy
-{
- private static Logger log = Logger.getLogger(LegacyEjb3JndiPolicy.class);
- private String baseJndiName;
-
- public LegacyEjb3JndiPolicy()
- {
- }
- public LegacyEjb3JndiPolicy(String baseJndiName)
- {
- this.baseJndiName = baseJndiName;
- }
-
- public String getBaseJndiName()
- {
- return baseJndiName;
- }
- public void setBaseJndiName(String baseJndiName)
- {
- this.baseJndiName = baseJndiName;
- }
-
- public String getDefaultLocalHomeJndiName(EjbDeploymentSummary summary)
- {
- return baseJndiName + "/" + KnownInterfaces.LOCAL_HOME;
- }
-
- public String getDefaultLocalJndiName(EjbDeploymentSummary summary)
- {
- return baseJndiName + "/" + KnownInterfaces.LOCAL;
- }
-
- public String getDefaultRemoteHomeJndiName(EjbDeploymentSummary summary)
- {
- return baseJndiName + "/" + KnownInterfaces.HOME;
- }
-
- public String getDefaultRemoteJndiName(EjbDeploymentSummary summary)
- {
- return baseJndiName + "/" + KnownInterfaces.REMOTE;
- }
-
- public String getJndiName(EjbDeploymentSummary summary)
- {
- return baseJndiName;
- }
-
- public String getJndiName(EjbDeploymentSummary summary, String iface,
- KnownInterfaceType ifaceType)
- {
- JBossEnterpriseBeanMetaData beanMD = summary.getBeanMD();
- baseJndiName = beanMD.getMappedName();
- if(baseJndiName == null)
- baseJndiName = beanMD.determineJndiName();
- String jndiName = null;
- String localJndiName = beanMD.getLocalJndiName();
- boolean is3x = beanMD.getJBossMetaData().isEJB3x();
- boolean hasJndiName = false;
- if(beanMD.isSession())
- {
- JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
- String givenJndiName = sbeanMD.getJndiName();
- if(givenJndiName != null && givenJndiName.trim().length() > 0)
- hasJndiName = true;
- }
- String appName = summary.getDeploymentScopeBaseName();
- if(appName == null)
- appName = "";
- else
- appName += "/";
-
- String ejbName = beanMD.getEjbName();
- switch(ifaceType)
- {
- case BUSINESS_LOCAL:
- if(localJndiName == null)
- jndiName = appName + ejbName + "/local";
- else
- jndiName = localJndiName;
- break;
- case BUSINESS_REMOTE:
- if(hasJndiName == false)
- jndiName = appName + ejbName + "/remote";
- else
- jndiName = baseJndiName;
- break;
- case LOCAL_HOME:
- if(is3x)
- {
- // TODO: Not really, hopefully no one uses this
- log.warn("Requested ejb3 local home for bean: "+beanMD.getEjbName());
- jndiName = ejbName + "/localHome";
- }
- else
- jndiName = beanMD.determineLocalJndiName();
- break;
- case REMOTE_HOME:
- if(is3x)
- {
- if (!hasJndiName)
- {
- jndiName = ejbName + "/home";
- }
- else
- {
- jndiName = baseJndiName;
- // ejb3-core 0.1.0 behavior
- //jndiName = baseJndiName + "Home";
- }
- }
- else
- {
- jndiName = baseJndiName;
- }
- break;
- case UNKNOWN:
- if(iface != null)
- log.warn("UKNOWN iface seen: "+iface+", for bean: "+beanMD.getEjbName());
- jndiName = baseJndiName;
- break;
- }
- return jndiName;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.plugin;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
+
+/**
+ * DefaultJndiBindingPolicy that uses the old ejb3 binding name conventions
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class LegacyEjb3JndiPolicy
+ implements DefaultJndiBindingPolicy
+{
+ private static Logger log = Logger.getLogger(LegacyEjb3JndiPolicy.class);
+ private String baseJndiName;
+
+ public LegacyEjb3JndiPolicy()
+ {
+ }
+ public LegacyEjb3JndiPolicy(String baseJndiName)
+ {
+ this.baseJndiName = baseJndiName;
+ }
+
+ public String getBaseJndiName()
+ {
+ return baseJndiName;
+ }
+ public void setBaseJndiName(String baseJndiName)
+ {
+ this.baseJndiName = baseJndiName;
+ }
+
+ public String getDefaultLocalHomeJndiName(EjbDeploymentSummary summary)
+ {
+ return baseJndiName + "/" + KnownInterfaces.LOCAL_HOME;
+ }
+
+ public String getDefaultLocalJndiName(EjbDeploymentSummary summary)
+ {
+ return baseJndiName + "/" + KnownInterfaces.LOCAL;
+ }
+
+ public String getDefaultRemoteHomeJndiName(EjbDeploymentSummary summary)
+ {
+ return baseJndiName + "/" + KnownInterfaces.HOME;
+ }
+
+ public String getDefaultRemoteJndiName(EjbDeploymentSummary summary)
+ {
+ return baseJndiName + "/" + KnownInterfaces.REMOTE;
+ }
+
+ public String getJndiName(EjbDeploymentSummary summary)
+ {
+ return baseJndiName;
+ }
+
+ public String getJndiName(EjbDeploymentSummary summary, String iface,
+ KnownInterfaceType ifaceType)
+ {
+ JBossEnterpriseBeanMetaData beanMD = summary.getBeanMD();
+ baseJndiName = beanMD.getMappedName();
+ if(baseJndiName == null)
+ baseJndiName = beanMD.determineJndiName();
+ String jndiName = null;
+ String localJndiName = beanMD.getLocalJndiName();
+ boolean is3x = beanMD.getJBossMetaData().isEJB3x();
+ boolean hasJndiName = false;
+ if(beanMD.isSession())
+ {
+ JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
+ String givenJndiName = sbeanMD.getJndiName();
+ if(givenJndiName != null && givenJndiName.trim().length() > 0)
+ hasJndiName = true;
+ }
+ String appName = summary.getDeploymentScopeBaseName();
+ if(appName == null)
+ appName = "";
+ else
+ appName += "/";
+
+ String ejbName = beanMD.getEjbName();
+ switch(ifaceType)
+ {
+ case BUSINESS_LOCAL:
+ if(localJndiName == null)
+ jndiName = appName + ejbName + "/local";
+ else
+ jndiName = localJndiName;
+ break;
+ case BUSINESS_REMOTE:
+ if(hasJndiName == false)
+ jndiName = appName + ejbName + "/remote";
+ else
+ jndiName = baseJndiName;
+ break;
+ case LOCAL_HOME:
+ if(is3x)
+ {
+ // TODO: Not really, hopefully no one uses this
+ log.warn("Requested ejb3 local home for bean: "+beanMD.getEjbName());
+ jndiName = ejbName + "/localHome";
+ }
+ else
+ jndiName = beanMD.determineLocalJndiName();
+ break;
+ case REMOTE_HOME:
+ if(is3x)
+ {
+ if (!hasJndiName)
+ {
+ jndiName = ejbName + "/home";
+ }
+ else
+ {
+ jndiName = baseJndiName;
+ // ejb3-core 0.1.0 behavior
+ //jndiName = baseJndiName + "Home";
+ }
+ }
+ else
+ {
+ jndiName = baseJndiName;
+ }
+ break;
+ case UNKNOWN:
+ if(iface != null)
+ log.warn("UKNOWN iface seen: "+iface+", for bean: "+beanMD.getEjbName());
+ jndiName = baseJndiName;
+ break;
+ }
+ return jndiName;
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/plugin/LegacyEjb3JndiPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,163 +1,163 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.deployment.plugin;
-
-import java.util.Map;
-
-import org.jboss.deployment.dependency.ContainerDependencyMetaData;
-import org.jboss.deployment.spi.DeploymentEndpointResolver;
-import org.jboss.deployment.spi.EndpointInfo;
-import org.jboss.deployment.spi.EndpointType;
-import org.jboss.logging.Logger;
-
-/**
- * A DeploymentEndpointResolver implementation that relies on the endpoint
- * map produced by the MappedReferenceMetaDataResolverDeployer
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class MappedDeploymentEndpointResolver implements
- DeploymentEndpointResolver
-{
- private static Logger log = Logger.getLogger(MappedDeploymentEndpointResolver.class);
- /** The deployment wide reference map */
- private Map<String, ContainerDependencyMetaData> endpointMap;
- private Map<String, String> endpointAlternateMap;
-
- public MappedDeploymentEndpointResolver(Map<String, ContainerDependencyMetaData> endpointMap,
- Map<String, String> endpointAlternateMap,
- String unitPath)
- {
- this.endpointMap = endpointMap;
- this.endpointAlternateMap = endpointAlternateMap;
- }
-
- /**
- * @param businessIntf
- * @param type -
- * @param vfsContext - The path of the unit this resolver is associated with. Used as the
- * starting point for link resolution.
- *
- */
- public EndpointInfo getEndpointInfo(Class businessIntf, String type, String vfsContext)
- {
- // First look for a unit specific mapping
- String altKey = "ejb/" + vfsContext + "@" + businessIntf.getName();
- String key = this.endpointAlternateMap.get(altKey);
- if(key == null)
- {
- // Look for a top level binding
- altKey = "ejb@" + businessIntf.getName();
- key = this.endpointAlternateMap.get(altKey);
- }
- EndpointInfo info = null;
- if(key != null)
- {
- ContainerDependencyMetaData cdmd = endpointMap.get(key);
- info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type);
- }
- return info;
- }
-
- /*
-
- * @see org.jboss.deployment.spi.DeploymentEndpointResolver#getEndpointInfo(java.lang.String, org.jboss.deployment.spi.EndpointType)
- * @see EndpointType
- */
- public EndpointInfo getEndpointInfo(String ref, String type, String vfsContext)
- {
- String prefix = type;
- // Parse the ref to obtain the path and endpoint name
- String unitPath = vfsContext;
- String endpointName = ref;
- if (ref.indexOf('#') != -1)
- {
- // <ejb-link> is of the form relative-path/file.jar#Bean
- String path = ref.substring(0, ref.indexOf('#'));
- // resolve any ../* prefix
- if(path.startsWith("../"))
- {
- String[] deploymentPaths = unitPath.split("/");
- int count = 0;
- while(path.startsWith("../"))
- {
- path = path.substring(3);
- count ++;
- }
- // build the relative path from the root
- String rootPath = "";
- for(int n = 0; n < (deploymentPaths.length - count); n ++)
- rootPath += deploymentPaths + "/";
- unitPath = rootPath + path;
- }
- else
- {
- unitPath = path;
- }
- //
- // Get the endpoint name
- endpointName = ref.substring(ref.indexOf('#') + 1);
- }
-
- EndpointInfo info = null;
- String key = prefix + "/" + unitPath +"#" + endpointName;
- ContainerDependencyMetaData cdmd = endpointMap.get(key);
- if(cdmd != null)
- {
- info = new EndpointInfo(unitPath, endpointName, type);
- return info;
- }
-
- // It could not be found in the unit itself, let's search globally
- if(ref.indexOf('#') == -1)
- {
- // See MappedReferenceMetaDataResolverDeployer.mapEjbs
- if(type.equals(EndpointType.EJB))
- {
- key = "ejb/" + ref;
- }
- else if(type.equals(EndpointType.MessageDestination))
- {
- key = "message-destination/" + ref;
- }
-
- String ejbCompID = endpointAlternateMap.get(key);
- if(ejbCompID != null)
- {
- cdmd = endpointMap.get(ejbCompID);
- if(cdmd == null)
- throw new IllegalStateException("endpoint mapping is corrupt, can't find '" + ejbCompID + "' in " + endpointMap);
- info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type);
- return info;
- }
- }
- else
- {
- log.debug("Failed to find mapping for ref: "+ref+" path: "+vfsContext);
- if(log.isTraceEnabled())
- log.trace("Available keys: "+endpointMap.keySet());
- }
- return info;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.plugin;
+
+import java.util.Map;
+
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.deployment.spi.EndpointInfo;
+import org.jboss.deployment.spi.EndpointType;
+import org.jboss.logging.Logger;
+
+/**
+ * A DeploymentEndpointResolver implementation that relies on the endpoint
+ * map produced by the MappedReferenceMetaDataResolverDeployer
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MappedDeploymentEndpointResolver implements
+ DeploymentEndpointResolver
+{
+ private static Logger log = Logger.getLogger(MappedDeploymentEndpointResolver.class);
+ /** The deployment wide reference map */
+ private Map<String, ContainerDependencyMetaData> endpointMap;
+ private Map<String, String> endpointAlternateMap;
+
+ public MappedDeploymentEndpointResolver(Map<String, ContainerDependencyMetaData> endpointMap,
+ Map<String, String> endpointAlternateMap,
+ String unitPath)
+ {
+ this.endpointMap = endpointMap;
+ this.endpointAlternateMap = endpointAlternateMap;
+ }
+
+ /**
+ * @param businessIntf
+ * @param type -
+ * @param vfsContext - The path of the unit this resolver is associated with. Used as the
+ * starting point for link resolution.
+ *
+ */
+ public EndpointInfo getEndpointInfo(Class businessIntf, String type, String vfsContext)
+ {
+ // First look for a unit specific mapping
+ String altKey = "ejb/" + vfsContext + "@" + businessIntf.getName();
+ String key = this.endpointAlternateMap.get(altKey);
+ if(key == null)
+ {
+ // Look for a top level binding
+ altKey = "ejb@" + businessIntf.getName();
+ key = this.endpointAlternateMap.get(altKey);
+ }
+ EndpointInfo info = null;
+ if(key != null)
+ {
+ ContainerDependencyMetaData cdmd = endpointMap.get(key);
+ info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type);
+ }
+ return info;
+ }
+
+ /*
+
+ * @see org.jboss.deployment.spi.DeploymentEndpointResolver#getEndpointInfo(java.lang.String, org.jboss.deployment.spi.EndpointType)
+ * @see EndpointType
+ */
+ public EndpointInfo getEndpointInfo(String ref, String type, String vfsContext)
+ {
+ String prefix = type;
+ // Parse the ref to obtain the path and endpoint name
+ String unitPath = vfsContext;
+ String endpointName = ref;
+ if (ref.indexOf('#') != -1)
+ {
+ // <ejb-link> is of the form relative-path/file.jar#Bean
+ String path = ref.substring(0, ref.indexOf('#'));
+ // resolve any ../* prefix
+ if(path.startsWith("../"))
+ {
+ String[] deploymentPaths = unitPath.split("/");
+ int count = 0;
+ while(path.startsWith("../"))
+ {
+ path = path.substring(3);
+ count ++;
+ }
+ // build the relative path from the root
+ String rootPath = "";
+ for(int n = 0; n < (deploymentPaths.length - count); n ++)
+ rootPath += deploymentPaths + "/";
+ unitPath = rootPath + path;
+ }
+ else
+ {
+ unitPath = path;
+ }
+ //
+ // Get the endpoint name
+ endpointName = ref.substring(ref.indexOf('#') + 1);
+ }
+
+ EndpointInfo info = null;
+ String key = prefix + "/" + unitPath +"#" + endpointName;
+ ContainerDependencyMetaData cdmd = endpointMap.get(key);
+ if(cdmd != null)
+ {
+ info = new EndpointInfo(unitPath, endpointName, type);
+ return info;
+ }
+
+ // It could not be found in the unit itself, let's search globally
+ if(ref.indexOf('#') == -1)
+ {
+ // See MappedReferenceMetaDataResolverDeployer.mapEjbs
+ if(type.equals(EndpointType.EJB))
+ {
+ key = "ejb/" + ref;
+ }
+ else if(type.equals(EndpointType.MessageDestination))
+ {
+ key = "message-destination/" + ref;
+ }
+
+ String ejbCompID = endpointAlternateMap.get(key);
+ if(ejbCompID != null)
+ {
+ cdmd = endpointMap.get(ejbCompID);
+ if(cdmd == null)
+ throw new IllegalStateException("endpoint mapping is corrupt, can't find '" + ejbCompID + "' in " + endpointMap);
+ info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type);
+ return info;
+ }
+ }
+ else
+ {
+ log.debug("Failed to find mapping for ref: "+ref+" path: "+vfsContext);
+ if(log.isTraceEnabled())
+ log.trace("Available keys: "+endpointMap.keySet());
+ }
+ return info;
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,259 +1,259 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import java.util.ArrayList;
-
-import javax.management.ObjectName;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.javaee.support.IdMetaData;
-import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.system.metadata.ServiceAttributeMetaData;
-import org.jboss.system.metadata.ServiceConstructorMetaData;
-import org.jboss.system.metadata.ServiceDependencyMetaData;
-import org.jboss.system.metadata.ServiceDependencyValueMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Abstract Security Deployer Sets up the top level JaccPolicy service beans
- *
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public abstract class AbstractSecurityDeployer<T extends IdMetaData> extends AbstractDeployer
-{
- private static final String JACC_ATTACHMENT_NAME = "jboss.jacc";
-
- private static final String BASE_OBJECT_NAME = "jboss.jacc:service=jacc,id=";
-
- private static final String XACML_POLICY_FILE_NAME = "jboss-xacml-policy.xml";
-
- private static final String ACL_POLICY_FILE_NAME = "jboss-acl-policy.xml";
-
- private PolicyRegistration policyRegistration;
-
- /**
- *
- * @return
- */
- public PolicyRegistration getPolicyRegistration()
- {
- return this.policyRegistration;
- }
-
- /**
- *
- * @param policyRegistration
- */
- public void setPolicyRegistration(PolicyRegistration policyRegistration)
- {
- this.policyRegistration = policyRegistration;
- }
-
- public AbstractSecurityDeployer()
- {
- setStage(DeploymentStages.POST_CLASSLOADER);
- setInput(getMetaDataClassType());
- setOutput(ServiceMetaData.class);
- addOutput(JACC_ATTACHMENT_NAME);
- }
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- T metaData = unit.getAttachment(getMetaDataClassType());
-
- if (metaData == null)
- return;
-
- String contextId = unit.getSimpleName();
-
- // Is the war the top level deployment?
- // DeploymentUnit topUnit = unit.getTopLevel();
- if (unit.getParent() == null || getParentJaccPolicyBean(unit) == null)
- {
- createTopLevelServiceBeanWithMetaData(contextId, unit, metaData);
- }
- else
- {
- ServiceMetaData subjaccPolicy = getServiceMetaData();
-
- String deploymentName = unit.getSimpleName();
-
- try
- {
- subjaccPolicy.setObjectName(new ObjectName(getObjectName(unit)));
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- // Provide a constructor for the service bean
- ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData();
- serviceConstructor.setSignature(new String[]{String.class.getName(), getMetaDataClassType().getName()});
- serviceConstructor.setParameters(new Object[]{deploymentName, metaData});
- subjaccPolicy.setConstructor(serviceConstructor);
-
- ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
- services.add(subjaccPolicy);
- unit.addAttachment(JACC_ATTACHMENT_NAME, subjaccPolicy, ServiceMetaData.class);
-
- // Add a dependence into the parent JaccPolicy
- ServiceMetaData parentServiceMetaData = this.getParentJaccPolicyBean(unit);
- if (parentServiceMetaData != null)
- {
- ServiceDependencyMetaData serviceDependencyMetaData = new ServiceDependencyMetaData();
- serviceDependencyMetaData.setIDependOnObjectName(subjaccPolicy.getObjectName());
- parentServiceMetaData.addDependency(serviceDependencyMetaData);
-
- // Add an attribute in the parent service
- ServiceAttributeMetaData serviceAttributeMetaData = new ServiceAttributeMetaData();
- serviceAttributeMetaData.setName("PolicyConfigurationFacadeMBean");
- ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData();
- dependencyValue.setDependency(subjaccPolicy.getObjectName().toString());
- dependencyValue.setProxyType("attribute");
- serviceAttributeMetaData.setValue(dependencyValue);
- parentServiceMetaData.addAttribute(serviceAttributeMetaData);
- }
- }
-
- // if policy registration has been set, check the deployments for XACML and ACL configuration files.
- if (this.policyRegistration != null)
- {
- VFSDeploymentUnit deploymentUnit = (VFSDeploymentUnit) unit;
- try
- {
- VirtualFile xacmlFile = deploymentUnit.getMetaDataFile(XACML_POLICY_FILE_NAME);
- if (xacmlFile != null)
- {
- this.policyRegistration.registerPolicy(contextId, PolicyRegistration.XACML, xacmlFile.toURL());
- }
- VirtualFile aclPolicyFile = deploymentUnit.getMetaDataFile(ACL_POLICY_FILE_NAME);
- if (aclPolicyFile != null)
- {
- this.policyRegistration.registerPolicy(contextId, PolicyRegistration.ACL, aclPolicyFile.toURL());
- }
- }
- catch (Exception e)
- {
- super.log.debug("Fail to process security configuration file", e);
- }
- }
- }
-
- @Override
- public void undeploy(DeploymentUnit unit)
- {
- unit.removeAttachment(JACC_ATTACHMENT_NAME);
- // unregister any XACML or ACL policies associated with the deployment unit.
- String contextId = unit.getSimpleName();
- if (this.policyRegistration != null)
- {
- this.policyRegistration.deRegisterPolicy(contextId, PolicyRegistration.XACML);
- this.policyRegistration.deRegisterPolicy(contextId, PolicyRegistration.ACL);
- }
- }
-
- private void createTopLevelServiceBeanWithMetaData(String contextId, DeploymentUnit unit, T deployment)
- {
- // Provide a constructor for the service bean
- ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData();
- serviceConstructor.setSignature(new String[]{String.class.getName(), this.getMetaDataClassType().getName(),
- Boolean.class.getName()});
- serviceConstructor.setParameters(new Object[]{contextId, deployment, Boolean.TRUE});
- createJaccPolicyBean(serviceConstructor, unit);
- }
-
- private void createJaccPolicyBean(ServiceConstructorMetaData serviceConstructor, DeploymentUnit unit)
- {
- // Create a Service Bean for the JACC Policy
- ServiceMetaData jaccPolicy = new ServiceMetaData();
- jaccPolicy.setCode(getJaccPolicyName());
- try
- {
- jaccPolicy.setObjectName(new ObjectName(getObjectName(unit)));
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- // Provide a constructor for the service bean
- jaccPolicy.setConstructor(serviceConstructor);
- ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
- services.add(jaccPolicy);
-
- unit.addAttachment(JACC_ATTACHMENT_NAME, jaccPolicy, ServiceMetaData.class);
- }
-
- private ServiceMetaData getParentJaccPolicyBean(DeploymentUnit childDU)
- {
- DeploymentUnit parentDU = childDU.getParent();
-
- while (parentDU != null)
- {
- ServiceMetaData parentJacc = (ServiceMetaData) parentDU.getAttachment(JACC_ATTACHMENT_NAME);
- if (parentJacc != null)
- return parentJacc;
- parentDU = parentDU.getParent();
- }
- return null;
- }
-
- /**
- * Get the name of the JaccPolicy subclass (EjbJaccPolicy,WebJaccPolicy etc)
- *
- * @return
- */
- protected abstract String getJaccPolicyName();
-
- /**
- * Return the type of metadata
- *
- * @return
- */
- protected abstract Class<T> getMetaDataClassType();
-
- /**
- * Get the top level service bean meta data
- *
- * @return
- */
- protected abstract ServiceMetaData getServiceMetaData();
-
- /**
- * Qualify the object name with parent name just to avoid conflicts with deployments with the same name in multiple
- * archives
- */
- private String getObjectName(DeploymentUnit unit)
- {
- String deploymentName = unit.getName();
- DeploymentUnit parentDU = unit.getParent();
- String parentDeploymentName = parentDU != null ? ",parent=\"" + parentDU.getSimpleName() + "\"" : "";
- return BASE_OBJECT_NAME + "\"" + deploymentName + "\"" + parentDeploymentName;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import java.util.ArrayList;
+
+import javax.management.ObjectName;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.javaee.support.IdMetaData;
+import org.jboss.security.authorization.PolicyRegistration;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Abstract Security Deployer Sets up the top level JaccPolicy service beans
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public abstract class AbstractSecurityDeployer<T extends IdMetaData> extends AbstractDeployer
+{
+ private static final String JACC_ATTACHMENT_NAME = "jboss.jacc";
+
+ private static final String BASE_OBJECT_NAME = "jboss.jacc:service=jacc,id=";
+
+ private static final String XACML_POLICY_FILE_NAME = "jboss-xacml-policy.xml";
+
+ private static final String ACL_POLICY_FILE_NAME = "jboss-acl-policy.xml";
+
+ private PolicyRegistration policyRegistration;
+
+ /**
+ *
+ * @return
+ */
+ public PolicyRegistration getPolicyRegistration()
+ {
+ return this.policyRegistration;
+ }
+
+ /**
+ *
+ * @param policyRegistration
+ */
+ public void setPolicyRegistration(PolicyRegistration policyRegistration)
+ {
+ this.policyRegistration = policyRegistration;
+ }
+
+ public AbstractSecurityDeployer()
+ {
+ setStage(DeploymentStages.POST_CLASSLOADER);
+ setInput(getMetaDataClassType());
+ setOutput(ServiceMetaData.class);
+ addOutput(JACC_ATTACHMENT_NAME);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ T metaData = unit.getAttachment(getMetaDataClassType());
+
+ if (metaData == null)
+ return;
+
+ String contextId = unit.getSimpleName();
+
+ // Is the war the top level deployment?
+ // DeploymentUnit topUnit = unit.getTopLevel();
+ if (unit.getParent() == null || getParentJaccPolicyBean(unit) == null)
+ {
+ createTopLevelServiceBeanWithMetaData(contextId, unit, metaData);
+ }
+ else
+ {
+ ServiceMetaData subjaccPolicy = getServiceMetaData();
+
+ String deploymentName = unit.getSimpleName();
+
+ try
+ {
+ subjaccPolicy.setObjectName(new ObjectName(getObjectName(unit)));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ // Provide a constructor for the service bean
+ ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData();
+ serviceConstructor.setSignature(new String[]{String.class.getName(), getMetaDataClassType().getName()});
+ serviceConstructor.setParameters(new Object[]{deploymentName, metaData});
+ subjaccPolicy.setConstructor(serviceConstructor);
+
+ ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+ services.add(subjaccPolicy);
+ unit.addAttachment(JACC_ATTACHMENT_NAME, subjaccPolicy, ServiceMetaData.class);
+
+ // Add a dependence into the parent JaccPolicy
+ ServiceMetaData parentServiceMetaData = this.getParentJaccPolicyBean(unit);
+ if (parentServiceMetaData != null)
+ {
+ ServiceDependencyMetaData serviceDependencyMetaData = new ServiceDependencyMetaData();
+ serviceDependencyMetaData.setIDependOnObjectName(subjaccPolicy.getObjectName());
+ parentServiceMetaData.addDependency(serviceDependencyMetaData);
+
+ // Add an attribute in the parent service
+ ServiceAttributeMetaData serviceAttributeMetaData = new ServiceAttributeMetaData();
+ serviceAttributeMetaData.setName("PolicyConfigurationFacadeMBean");
+ ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData();
+ dependencyValue.setDependency(subjaccPolicy.getObjectName().toString());
+ dependencyValue.setProxyType("attribute");
+ serviceAttributeMetaData.setValue(dependencyValue);
+ parentServiceMetaData.addAttribute(serviceAttributeMetaData);
+ }
+ }
+
+ // if policy registration has been set, check the deployments for XACML and ACL configuration files.
+ if (this.policyRegistration != null)
+ {
+ VFSDeploymentUnit deploymentUnit = (VFSDeploymentUnit) unit;
+ try
+ {
+ VirtualFile xacmlFile = deploymentUnit.getMetaDataFile(XACML_POLICY_FILE_NAME);
+ if (xacmlFile != null)
+ {
+ this.policyRegistration.registerPolicy(contextId, PolicyRegistration.XACML, xacmlFile.toURL());
+ }
+ VirtualFile aclPolicyFile = deploymentUnit.getMetaDataFile(ACL_POLICY_FILE_NAME);
+ if (aclPolicyFile != null)
+ {
+ this.policyRegistration.registerPolicy(contextId, PolicyRegistration.ACL, aclPolicyFile.toURL());
+ }
+ }
+ catch (Exception e)
+ {
+ super.log.debug("Fail to process security configuration file", e);
+ }
+ }
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit)
+ {
+ unit.removeAttachment(JACC_ATTACHMENT_NAME);
+ // unregister any XACML or ACL policies associated with the deployment unit.
+ String contextId = unit.getSimpleName();
+ if (this.policyRegistration != null)
+ {
+ this.policyRegistration.deRegisterPolicy(contextId, PolicyRegistration.XACML);
+ this.policyRegistration.deRegisterPolicy(contextId, PolicyRegistration.ACL);
+ }
+ }
+
+ private void createTopLevelServiceBeanWithMetaData(String contextId, DeploymentUnit unit, T deployment)
+ {
+ // Provide a constructor for the service bean
+ ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData();
+ serviceConstructor.setSignature(new String[]{String.class.getName(), this.getMetaDataClassType().getName(),
+ Boolean.class.getName()});
+ serviceConstructor.setParameters(new Object[]{contextId, deployment, Boolean.TRUE});
+ createJaccPolicyBean(serviceConstructor, unit);
+ }
+
+ private void createJaccPolicyBean(ServiceConstructorMetaData serviceConstructor, DeploymentUnit unit)
+ {
+ // Create a Service Bean for the JACC Policy
+ ServiceMetaData jaccPolicy = new ServiceMetaData();
+ jaccPolicy.setCode(getJaccPolicyName());
+ try
+ {
+ jaccPolicy.setObjectName(new ObjectName(getObjectName(unit)));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ // Provide a constructor for the service bean
+ jaccPolicy.setConstructor(serviceConstructor);
+ ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+ services.add(jaccPolicy);
+
+ unit.addAttachment(JACC_ATTACHMENT_NAME, jaccPolicy, ServiceMetaData.class);
+ }
+
+ private ServiceMetaData getParentJaccPolicyBean(DeploymentUnit childDU)
+ {
+ DeploymentUnit parentDU = childDU.getParent();
+
+ while (parentDU != null)
+ {
+ ServiceMetaData parentJacc = (ServiceMetaData) parentDU.getAttachment(JACC_ATTACHMENT_NAME);
+ if (parentJacc != null)
+ return parentJacc;
+ parentDU = parentDU.getParent();
+ }
+ return null;
+ }
+
+ /**
+ * Get the name of the JaccPolicy subclass (EjbJaccPolicy,WebJaccPolicy etc)
+ *
+ * @return
+ */
+ protected abstract String getJaccPolicyName();
+
+ /**
+ * Return the type of metadata
+ *
+ * @return
+ */
+ protected abstract Class<T> getMetaDataClassType();
+
+ /**
+ * Get the top level service bean meta data
+ *
+ * @return
+ */
+ protected abstract ServiceMetaData getServiceMetaData();
+
+ /**
+ * Qualify the object name with parent name just to avoid conflicts with deployments with the same name in multiple
+ * archives
+ */
+ private String getObjectName(DeploymentUnit unit)
+ {
+ String deploymentName = unit.getName();
+ DeploymentUnit parentDU = unit.getParent();
+ String parentDeploymentName = parentDU != null ? ",parent=\"" + parentDU.getSimpleName() + "\"" : "";
+ return BASE_OBJECT_NAME + "\"" + deploymentName + "\"" + parentDeploymentName;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/security/AbstractSecurityDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/EarJaccPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/EarJaccPolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/EarJaccPolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,57 +1,57 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-
-//$Id$
-
-/**
- * Top level Jacc Policy for EARs
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public class EarJaccPolicy extends JaccPolicy<JBossAppMetaData>
-{
- public EarJaccPolicy(String id)
- {
- super(id);
- }
-
-
- public EarJaccPolicy(String id, JBossAppMetaData metaData, Boolean standaloneDeployment)
- {
- super(id, metaData, standaloneDeployment);
- }
-
-
- @Override
- protected void createPermissions(JBossAppMetaData metaData,
- PolicyConfiguration policyConfiguration) throws PolicyContextException
- {
- //nothing to do here
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+
+//$Id$
+
+/**
+ * Top level Jacc Policy for EARs
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public class EarJaccPolicy extends JaccPolicy<JBossAppMetaData>
+{
+ public EarJaccPolicy(String id)
+ {
+ super(id);
+ }
+
+
+ public EarJaccPolicy(String id, JBossAppMetaData metaData, Boolean standaloneDeployment)
+ {
+ super(id, metaData, standaloneDeployment);
+ }
+
+
+ @Override
+ protected void createPermissions(JBossAppMetaData metaData,
+ PolicyConfiguration policyConfiguration) throws PolicyContextException
+ {
+ //nothing to do here
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/EarJaccPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/EarPolicyConfigurationFacade.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/EarPolicyConfigurationFacade.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/EarPolicyConfigurationFacade.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,51 +1,51 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-
-//$Id$
-
-/**
- * A facade for constructing Permissions into the PolicyConfiguration
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public class EarPolicyConfigurationFacade<T extends JBossAppMetaData>
-extends PolicyConfigurationFacade<JBossAppMetaData>
-{
- public EarPolicyConfigurationFacade(String id, T md)
- {
- super(id, md);
- }
-
- @Override
- protected void createPermissions(JBossAppMetaData metaData,
- PolicyConfiguration policyConfiguration) throws PolicyContextException
- {
- return; //No need for permissions
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+
+//$Id$
+
+/**
+ * A facade for constructing Permissions into the PolicyConfiguration
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public class EarPolicyConfigurationFacade<T extends JBossAppMetaData>
+extends PolicyConfigurationFacade<JBossAppMetaData>
+{
+ public EarPolicyConfigurationFacade(String id, T md)
+ {
+ super(id, md);
+ }
+
+ @Override
+ protected void createPermissions(JBossAppMetaData metaData,
+ PolicyConfiguration policyConfiguration) throws PolicyContextException
+ {
+ return; //No need for permissions
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/EarPolicyConfigurationFacade.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/EjbJaccPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/EjbJaccPolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/EjbJaccPolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,63 +1,63 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.ejb.EJBPermissionMapping;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-
-//$Id$
-
-/**
- * Top level Jacc Policy for EJBs
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public class EjbJaccPolicy<T extends JBossMetaData> extends JaccPolicy<JBossMetaData>
-{
- public EjbJaccPolicy(String id)
- {
- super(id);
- }
-
- public EjbJaccPolicy(String id, JBossMetaData metaData, Boolean standaloneDeployment)
- {
- super(id, metaData, standaloneDeployment);
- }
-
- @Override
- protected void createPermissions(JBossMetaData metaData, PolicyConfiguration policyConfiguration)
- throws PolicyContextException
- {
- JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans();
- for(JBossEnterpriseBeanMetaData jBossEnterpriseBeanMetaData : beans)
- {
- EJBPermissionMapping.createPermissions(jBossEnterpriseBeanMetaData,
- policyConfiguration);
- }
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.ejb.EJBPermissionMapping;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+//$Id$
+
+/**
+ * Top level Jacc Policy for EJBs
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public class EjbJaccPolicy<T extends JBossMetaData> extends JaccPolicy<JBossMetaData>
+{
+ public EjbJaccPolicy(String id)
+ {
+ super(id);
+ }
+
+ public EjbJaccPolicy(String id, JBossMetaData metaData, Boolean standaloneDeployment)
+ {
+ super(id, metaData, standaloneDeployment);
+ }
+
+ @Override
+ protected void createPermissions(JBossMetaData metaData, PolicyConfiguration policyConfiguration)
+ throws PolicyContextException
+ {
+ JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans();
+ for(JBossEnterpriseBeanMetaData jBossEnterpriseBeanMetaData : beans)
+ {
+ EJBPermissionMapping.createPermissions(jBossEnterpriseBeanMetaData,
+ policyConfiguration);
+ }
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/EjbJaccPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,60 +1,60 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.ejb.EJBPermissionMapping;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaDataWrapper;
-
-//$Id$
-
-/**
- * A facade for constructing Permissions into the PolicyConfiguration
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public class EjbPolicyConfigurationFacade<T extends JBossMetaData>
-extends PolicyConfigurationFacade<JBossMetaData>
-{
- public EjbPolicyConfigurationFacade(String id, T md)
- {
- super(id, md);
- }
-
- @Override
- protected void createPermissions(JBossMetaData metaData,
- PolicyConfiguration policyConfiguration) throws PolicyContextException
- {
- JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans();
- for(JBossEnterpriseBeanMetaData jBossEnterpriseBeanMetaData : beans)
- {
- EJBPermissionMapping.createPermissions(jBossEnterpriseBeanMetaData,
- policyConfiguration);
- }
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.ejb.EJBPermissionMapping;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaDataWrapper;
+
+//$Id$
+
+/**
+ * A facade for constructing Permissions into the PolicyConfiguration
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public class EjbPolicyConfigurationFacade<T extends JBossMetaData>
+extends PolicyConfigurationFacade<JBossMetaData>
+{
+ public EjbPolicyConfigurationFacade(String id, T md)
+ {
+ super(id, md);
+ }
+
+ @Override
+ protected void createPermissions(JBossMetaData metaData,
+ PolicyConfiguration policyConfiguration) throws PolicyContextException
+ {
+ JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans();
+ for(JBossEnterpriseBeanMetaData jBossEnterpriseBeanMetaData : beans)
+ {
+ EJBPermissionMapping.createPermissions(jBossEnterpriseBeanMetaData,
+ policyConfiguration);
+ }
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/JaccPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/JaccPolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/JaccPolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,197 +1,197 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import java.security.Policy;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.support.IdMetaData;
-
-
-/**
- * A Service Bean representing the JACC Policy for the top level deployment
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @since Dec 11, 2006
- * @version $Revision$
- */
-public class JaccPolicy<T extends IdMetaData> implements JaccPolicyMBean
-{
- private static Logger log = Logger.getLogger(JaccPolicy.class);
- private boolean trace = log.isTraceEnabled();
-
- private PolicyConfiguration parentPC = null;
- private String contextID = null;
-
- private T metaData;
-
- private Boolean standaloneDeployment = Boolean.FALSE;
-
- private List<PolicyConfigurationFacadeMBean> children = new ArrayList<PolicyConfigurationFacadeMBean>();
-
-
- /**
- * Ctr
- * @param id Jacc Context Id for the top level deployment
- * @throws IllegalArgumentException if id passed is null
- */
- public JaccPolicy(String id)
- {
- if(id == null)
- throw new IllegalArgumentException("Jacc Context Id passed is null");
- this.contextID = id;
- }
-
- public JaccPolicy(String id, T metaData, Boolean standaloneDeployment)
- {
- this(id);
- this.metaData = metaData;
- this.standaloneDeployment = standaloneDeployment;
- }
-
- /**
- * @see JaccPolicyMBean#create()
- */
- public void create()
- {
- try
- {
- createPolicyConfiguration();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- if(this.standaloneDeployment == Boolean.TRUE)
- {
- try
- {
- if (metaData != null)
- createPermissions(metaData,parentPC);
- else
- log.warn("Cannot create permissions with 'null' metaData for id=" + contextID);
- }
- catch (PolicyContextException e)
- {
-
- throw new RuntimeException("Cannot create permissions:",e);
- }
- }
- if(trace)
- log.trace("create():" + this.contextID);
- }
-
- /**
- * @see JaccPolicyMBean#destroy()
- */
- public void destroy()
- {
- if(trace)
- log.trace("destroy:" + this.contextID);
- parentPC= null;
- }
-
- /**
- * @see JaccPolicyMBean#start()
- */
- public void start()
- {
- //All the sub deployments have started
- try
- {
- //Let us link all the policy configurations
- for(PolicyConfigurationFacadeMBean pcfm:children)
- {
- /** The idea is that if any of the linking policy configuration
- * have committed (i.e. they are in a inService state), then they
- * cannot be linked. So we bring them to the open state by getting
- * the policy configuration from the factory and then we commit.
- */
- String jaccContextIdChild = pcfm.getJaccContextID();
-
- PolicyConfigurationFactory policyConfigurationFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- PolicyConfiguration pcChild = policyConfigurationFactory.getPolicyConfiguration(jaccContextIdChild, false);
- if(pcChild != null)
- {
- parentPC.linkConfiguration(pcChild);
- //Commit the linked PC
- pcChild.commit();
- }
- }
- parentPC.commit();
- // Allow the policy to incorporate the policy configs
- Policy.getPolicy().refresh();
- }
- catch (Exception e)
- {
- log.error("Cannot commit Parent Policy Configuration:",e);
- }
- if(trace)
- log.trace("start():" + this.contextID);
- }
-
- /**
- * @see JaccPolicyMBean#stop()
- */
- public void stop()
- {
- try
- {
- //The linked PCs will delete themselves via the PolicyConfigurationFacade
- this.parentPC.delete();
- }
- catch (PolicyContextException e)
- {
- throw new RuntimeException(e);
- }
- if(trace)
- log.trace("stop():" + this.contextID);
- }
-
- /**
- * @see JaccPolicyMBean#setPolicyConfigurationFacadeMBean(PolicyConfigurationFacadeMBean)
- */
- public void setPolicyConfigurationFacadeMBean(PolicyConfigurationFacadeMBean mbeanName)
- {
- this.children.add(mbeanName);
- }
-
- private void createPolicyConfiguration() throws PolicyContextException, ClassNotFoundException
- {
- if(parentPC == null)
- {
- PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- parentPC = pcf.getPolicyConfiguration(contextID, false);
- }
- }
-
- protected void createPermissions(T metaData, PolicyConfiguration policyConfiguration)
- throws PolicyContextException
- {
- throw new RuntimeException("Need to override");
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.support.IdMetaData;
+
+
+/**
+ * A Service Bean representing the JACC Policy for the top level deployment
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Dec 11, 2006
+ * @version $Revision$
+ */
+public class JaccPolicy<T extends IdMetaData> implements JaccPolicyMBean
+{
+ private static Logger log = Logger.getLogger(JaccPolicy.class);
+ private boolean trace = log.isTraceEnabled();
+
+ private PolicyConfiguration parentPC = null;
+ private String contextID = null;
+
+ private T metaData;
+
+ private Boolean standaloneDeployment = Boolean.FALSE;
+
+ private List<PolicyConfigurationFacadeMBean> children = new ArrayList<PolicyConfigurationFacadeMBean>();
+
+
+ /**
+ * Ctr
+ * @param id Jacc Context Id for the top level deployment
+ * @throws IllegalArgumentException if id passed is null
+ */
+ public JaccPolicy(String id)
+ {
+ if(id == null)
+ throw new IllegalArgumentException("Jacc Context Id passed is null");
+ this.contextID = id;
+ }
+
+ public JaccPolicy(String id, T metaData, Boolean standaloneDeployment)
+ {
+ this(id);
+ this.metaData = metaData;
+ this.standaloneDeployment = standaloneDeployment;
+ }
+
+ /**
+ * @see JaccPolicyMBean#create()
+ */
+ public void create()
+ {
+ try
+ {
+ createPolicyConfiguration();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ if(this.standaloneDeployment == Boolean.TRUE)
+ {
+ try
+ {
+ if (metaData != null)
+ createPermissions(metaData,parentPC);
+ else
+ log.warn("Cannot create permissions with 'null' metaData for id=" + contextID);
+ }
+ catch (PolicyContextException e)
+ {
+
+ throw new RuntimeException("Cannot create permissions:",e);
+ }
+ }
+ if(trace)
+ log.trace("create():" + this.contextID);
+ }
+
+ /**
+ * @see JaccPolicyMBean#destroy()
+ */
+ public void destroy()
+ {
+ if(trace)
+ log.trace("destroy:" + this.contextID);
+ parentPC= null;
+ }
+
+ /**
+ * @see JaccPolicyMBean#start()
+ */
+ public void start()
+ {
+ //All the sub deployments have started
+ try
+ {
+ //Let us link all the policy configurations
+ for(PolicyConfigurationFacadeMBean pcfm:children)
+ {
+ /** The idea is that if any of the linking policy configuration
+ * have committed (i.e. they are in a inService state), then they
+ * cannot be linked. So we bring them to the open state by getting
+ * the policy configuration from the factory and then we commit.
+ */
+ String jaccContextIdChild = pcfm.getJaccContextID();
+
+ PolicyConfigurationFactory policyConfigurationFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration pcChild = policyConfigurationFactory.getPolicyConfiguration(jaccContextIdChild, false);
+ if(pcChild != null)
+ {
+ parentPC.linkConfiguration(pcChild);
+ //Commit the linked PC
+ pcChild.commit();
+ }
+ }
+ parentPC.commit();
+ // Allow the policy to incorporate the policy configs
+ Policy.getPolicy().refresh();
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot commit Parent Policy Configuration:",e);
+ }
+ if(trace)
+ log.trace("start():" + this.contextID);
+ }
+
+ /**
+ * @see JaccPolicyMBean#stop()
+ */
+ public void stop()
+ {
+ try
+ {
+ //The linked PCs will delete themselves via the PolicyConfigurationFacade
+ this.parentPC.delete();
+ }
+ catch (PolicyContextException e)
+ {
+ throw new RuntimeException(e);
+ }
+ if(trace)
+ log.trace("stop():" + this.contextID);
+ }
+
+ /**
+ * @see JaccPolicyMBean#setPolicyConfigurationFacadeMBean(PolicyConfigurationFacadeMBean)
+ */
+ public void setPolicyConfigurationFacadeMBean(PolicyConfigurationFacadeMBean mbeanName)
+ {
+ this.children.add(mbeanName);
+ }
+
+ private void createPolicyConfiguration() throws PolicyContextException, ClassNotFoundException
+ {
+ if(parentPC == null)
+ {
+ PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ parentPC = pcf.getPolicyConfiguration(contextID, false);
+ }
+ }
+
+ protected void createPermissions(T metaData, PolicyConfiguration policyConfiguration)
+ throws PolicyContextException
+ {
+ throw new RuntimeException("Need to override");
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/JaccPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/JaccPolicyMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/JaccPolicyMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/JaccPolicyMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,45 +1,45 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-
-//$Id$
-
-/**
- * Service contract for the JaccPolicy
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @since Dec 11, 2006
- * @version $Revision$
- */
-public interface JaccPolicyMBean
-{
- public void create();
- public void destroy();
- public void start();
- public void stop();
-
- /**
- * Inject a child PolicyConfiguration facade
- * @param pcfm
- */
- public void setPolicyConfigurationFacadeMBean(PolicyConfigurationFacadeMBean pcfm);
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+
+//$Id$
+
+/**
+ * Service contract for the JaccPolicy
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Dec 11, 2006
+ * @version $Revision$
+ */
+public interface JaccPolicyMBean
+{
+ public void create();
+ public void destroy();
+ public void start();
+ public void stop();
+
+ /**
+ * Inject a child PolicyConfiguration facade
+ * @param pcfm
+ */
+ public void setPolicyConfigurationFacadeMBean(PolicyConfigurationFacadeMBean pcfm);
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/JaccPolicyMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/JaccPolicyUtil.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/JaccPolicyUtil.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/JaccPolicyUtil.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,141 +1,141 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb.EJBPermissionMapping;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.web.WebPermissionMapping;
-
-//$Id$
-
-/**
- * Static class with common methods used for jacc deployment processing
- *
- * TODO: Remove this class when the MC has the util methods
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @author adrian at jboss.org
- * @since Dec 11, 2006
- * @version $Revision$
- */
-public class JaccPolicyUtil
-{
- public static String IGNORE_ME_NAME = "org.jboss.deployment.security.ignoreMe";
-
- /**
- * Given a deployment unit, get all the deployments underneath
- * that are valid Jacc deployments (ejbs,wars)
- * @param unit
- * @param ignoreSuffix (ignore "xml","beans", "deployer" etc)
- * @return
- */
- public static List<String> getJaccDeployments(VFSDeploymentUnit unit,
- Collection<String> ignoreSuffix)
- {
- ArrayList<String> list = new ArrayList<String>();
- List<VFSDeploymentUnit> children = unit.getVFSChildren();
- for (VFSDeploymentUnit child: children)
- {
- String childName = child.getSimpleName();
- boolean tobeIgnored = false;
- //Go through the ignore list
- if (ignoreSuffix != null)
- {
- for(String ignoreStr: ignoreSuffix)
- {
- tobeIgnored = false;
- if(childName.endsWith(ignoreStr))
- {
- tobeIgnored = true;
- break;
- }
- }
- }
- //Check if it is a "jar" file, then it must be ejb deployment to consider
- if(childName.endsWith("jar") && !tobeIgnored
- && !isEJBDeployment(child))
- continue;
- if(!tobeIgnored)
- list.add(childName);
- }
- return list;
- }
-
- //TODO:Replace with ejb3 deployment logic
- public static boolean isEJBDeployment(VFSDeploymentUnit du)
- {
- // TODO: this is temporary EJB3 logic
- Boolean ignoreMe = du.getAttachment(IGNORE_ME_NAME, Boolean.class);
- if(ignoreMe != null && ignoreMe)
- return false;
- boolean ejbxml = du.getMetaDataFile("ejb-jar.xml") != null;
- boolean jbossxml = du.getMetaDataFile("jboss.xml") != null;
- return ejbxml || jbossxml;
- }
-
- /**
- * Create the JACC Permissions and add to the policy configuration passed
- * @param policyConfiguration
- * @param metadata
- * @throws PolicyContextException
- */
- public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata)
- throws PolicyContextException
- {
- if(metadata == null)
- throw new IllegalArgumentException("Meta Data is null");
- if(policyConfiguration == null)
- throw new IllegalArgumentException("Policy Configuration is null");
-
- if(metadata instanceof JBossWebMetaData)
- {
- JBossWebMetaData wmd = (JBossWebMetaData)metadata;
- WebPermissionMapping.createPermissions(wmd, policyConfiguration);
- }
- else if(metadata instanceof JBossEnterpriseBeanMetaData)
- {
- JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata;
- EJBPermissionMapping.createPermissions(bmd, policyConfiguration);
- }
- else if(metadata instanceof JBossMetaData)
- {
- JBossMetaData jmd = (JBossMetaData)metadata;
- JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans();
- for(JBossEnterpriseBeanMetaData bmd : beans)
- {
- EJBPermissionMapping.createPermissions(bmd, policyConfiguration);
- }
- }
- else
- throw new IllegalStateException("Unknown metadata");
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb.EJBPermissionMapping;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.web.WebPermissionMapping;
+
+//$Id$
+
+/**
+ * Static class with common methods used for jacc deployment processing
+ *
+ * TODO: Remove this class when the MC has the util methods
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @author adrian at jboss.org
+ * @since Dec 11, 2006
+ * @version $Revision$
+ */
+public class JaccPolicyUtil
+{
+ public static String IGNORE_ME_NAME = "org.jboss.deployment.security.ignoreMe";
+
+ /**
+ * Given a deployment unit, get all the deployments underneath
+ * that are valid Jacc deployments (ejbs,wars)
+ * @param unit
+ * @param ignoreSuffix (ignore "xml","beans", "deployer" etc)
+ * @return
+ */
+ public static List<String> getJaccDeployments(VFSDeploymentUnit unit,
+ Collection<String> ignoreSuffix)
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ List<VFSDeploymentUnit> children = unit.getVFSChildren();
+ for (VFSDeploymentUnit child: children)
+ {
+ String childName = child.getSimpleName();
+ boolean tobeIgnored = false;
+ //Go through the ignore list
+ if (ignoreSuffix != null)
+ {
+ for(String ignoreStr: ignoreSuffix)
+ {
+ tobeIgnored = false;
+ if(childName.endsWith(ignoreStr))
+ {
+ tobeIgnored = true;
+ break;
+ }
+ }
+ }
+ //Check if it is a "jar" file, then it must be ejb deployment to consider
+ if(childName.endsWith("jar") && !tobeIgnored
+ && !isEJBDeployment(child))
+ continue;
+ if(!tobeIgnored)
+ list.add(childName);
+ }
+ return list;
+ }
+
+ //TODO:Replace with ejb3 deployment logic
+ public static boolean isEJBDeployment(VFSDeploymentUnit du)
+ {
+ // TODO: this is temporary EJB3 logic
+ Boolean ignoreMe = du.getAttachment(IGNORE_ME_NAME, Boolean.class);
+ if(ignoreMe != null && ignoreMe)
+ return false;
+ boolean ejbxml = du.getMetaDataFile("ejb-jar.xml") != null;
+ boolean jbossxml = du.getMetaDataFile("jboss.xml") != null;
+ return ejbxml || jbossxml;
+ }
+
+ /**
+ * Create the JACC Permissions and add to the policy configuration passed
+ * @param policyConfiguration
+ * @param metadata
+ * @throws PolicyContextException
+ */
+ public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata)
+ throws PolicyContextException
+ {
+ if(metadata == null)
+ throw new IllegalArgumentException("Meta Data is null");
+ if(policyConfiguration == null)
+ throw new IllegalArgumentException("Policy Configuration is null");
+
+ if(metadata instanceof JBossWebMetaData)
+ {
+ JBossWebMetaData wmd = (JBossWebMetaData)metadata;
+ WebPermissionMapping.createPermissions(wmd, policyConfiguration);
+ }
+ else if(metadata instanceof JBossEnterpriseBeanMetaData)
+ {
+ JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata;
+ EJBPermissionMapping.createPermissions(bmd, policyConfiguration);
+ }
+ else if(metadata instanceof JBossMetaData)
+ {
+ JBossMetaData jmd = (JBossMetaData)metadata;
+ JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans();
+ for(JBossEnterpriseBeanMetaData bmd : beans)
+ {
+ EJBPermissionMapping.createPermissions(bmd, policyConfiguration);
+ }
+ }
+ else
+ throw new IllegalStateException("Unknown metadata");
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/security/JaccPolicyUtil.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacade.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacade.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacade.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,132 +1,132 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.support.IdMetaData;
-
-
-/**
- * A facade for the JACC Policy Configuration
- * for deployments that are not the top level deployments
- * (Eg: WARs, EJB-Jars sitting inside EAR deployments)
- * @author Anil.Saldhana at redhat.com
- * @since Apr 23, 2007
- * @version $Revision$
- */
-public abstract class PolicyConfigurationFacade<T extends IdMetaData>
-implements PolicyConfigurationFacadeMBean
-{
- protected static Logger log = Logger.getLogger(PolicyConfigurationFacade.class);
- protected boolean trace = log.isTraceEnabled();
- private String jaccContextId;
- private PolicyConfiguration policyConfiguration;
- private T metaData;
-
- public PolicyConfigurationFacade(String id, T md)
- {
- if(id == null)
- throw new IllegalArgumentException("Context ID is null");
- if(md == null)
- throw new IllegalArgumentException("Meta Data is null");
- this.jaccContextId = id;
- this.metaData = md;
- }
-
- public void create()
- {
- try
- {
- PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- policyConfiguration = pcf.getPolicyConfiguration(this.jaccContextId, false);
-
- createPermissions(metaData, policyConfiguration);
- }
- catch (ClassNotFoundException e)
- {
- new RuntimeException(e);
- }
- catch (PolicyContextException e)
- {
- new RuntimeException(e);
- }
- if(trace)
- log.trace("Create:contextID=" + this.jaccContextId);
- }
-
- public void destroy()
- {
- if(trace)
- log.trace("destroy : " + this.jaccContextId);
- this.policyConfiguration = null;
- }
-
- public void start()
- {
- if(trace)
- log.trace("Start : contextId=" + this.jaccContextId);
- }
-
- public void stop()
- {
- try
- {
- this.policyConfiguration.delete();
- }
- catch (PolicyContextException e)
- {
- new RuntimeException(e);
- }
- if(trace)
- log.trace("stop : " + this.jaccContextId);
- }
-
- /**
- * @see PolicyConfigurationFacadeMBean#getPolicyConfiguration()
- */
- public PolicyConfiguration getPolicyConfiguration()
- {
- return this.policyConfiguration;
- }
-
- /**
- * @see PolicyConfigurationFacadeMBean#getJaccContextID()
- */
- public String getJaccContextID()
- {
- return this.jaccContextId;
- }
-
- /**
- * Subclasses should override to create the Jacc Permissions
- * in the PolicyConfiguration
- * @param metaData
- * @param policyConfiguration
- * @throws PolicyContextException
- */
- protected abstract void createPermissions(T metaData,
- PolicyConfiguration policyConfiguration) throws PolicyContextException;
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.support.IdMetaData;
+
+
+/**
+ * A facade for the JACC Policy Configuration
+ * for deployments that are not the top level deployments
+ * (Eg: WARs, EJB-Jars sitting inside EAR deployments)
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 23, 2007
+ * @version $Revision$
+ */
+public abstract class PolicyConfigurationFacade<T extends IdMetaData>
+implements PolicyConfigurationFacadeMBean
+{
+ protected static Logger log = Logger.getLogger(PolicyConfigurationFacade.class);
+ protected boolean trace = log.isTraceEnabled();
+ private String jaccContextId;
+ private PolicyConfiguration policyConfiguration;
+ private T metaData;
+
+ public PolicyConfigurationFacade(String id, T md)
+ {
+ if(id == null)
+ throw new IllegalArgumentException("Context ID is null");
+ if(md == null)
+ throw new IllegalArgumentException("Meta Data is null");
+ this.jaccContextId = id;
+ this.metaData = md;
+ }
+
+ public void create()
+ {
+ try
+ {
+ PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ policyConfiguration = pcf.getPolicyConfiguration(this.jaccContextId, false);
+
+ createPermissions(metaData, policyConfiguration);
+ }
+ catch (ClassNotFoundException e)
+ {
+ new RuntimeException(e);
+ }
+ catch (PolicyContextException e)
+ {
+ new RuntimeException(e);
+ }
+ if(trace)
+ log.trace("Create:contextID=" + this.jaccContextId);
+ }
+
+ public void destroy()
+ {
+ if(trace)
+ log.trace("destroy : " + this.jaccContextId);
+ this.policyConfiguration = null;
+ }
+
+ public void start()
+ {
+ if(trace)
+ log.trace("Start : contextId=" + this.jaccContextId);
+ }
+
+ public void stop()
+ {
+ try
+ {
+ this.policyConfiguration.delete();
+ }
+ catch (PolicyContextException e)
+ {
+ new RuntimeException(e);
+ }
+ if(trace)
+ log.trace("stop : " + this.jaccContextId);
+ }
+
+ /**
+ * @see PolicyConfigurationFacadeMBean#getPolicyConfiguration()
+ */
+ public PolicyConfiguration getPolicyConfiguration()
+ {
+ return this.policyConfiguration;
+ }
+
+ /**
+ * @see PolicyConfigurationFacadeMBean#getJaccContextID()
+ */
+ public String getJaccContextID()
+ {
+ return this.jaccContextId;
+ }
+
+ /**
+ * Subclasses should override to create the Jacc Permissions
+ * in the PolicyConfiguration
+ * @param metaData
+ * @param policyConfiguration
+ * @throws PolicyContextException
+ */
+ protected abstract void createPermissions(T metaData,
+ PolicyConfiguration policyConfiguration) throws PolicyContextException;
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacade.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacadeMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacadeMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacadeMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,53 +1,53 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-
-//$Id$
-
-/**
- * MBean interface for the Policy Configuration facade service bean
- * @author Anil.Saldhana at redhat.com
- * @since Apr 23, 2007
- * @version $Revision$
- */
-public interface PolicyConfigurationFacadeMBean
-{
- public void create();
- public void destroy();
- public void start();
- public void stop();
-
- /**
- * Get the JACC Context ID
- * @return
- */
- public String getJaccContextID();
-
- /**
- * Get the PolicyConfiguration created by
- * this facade
- * @return
- */
- public PolicyConfiguration getPolicyConfiguration();
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+
+//$Id$
+
+/**
+ * MBean interface for the Policy Configuration facade service bean
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 23, 2007
+ * @version $Revision$
+ */
+public interface PolicyConfigurationFacadeMBean
+{
+ public void create();
+ public void destroy();
+ public void start();
+ public void stop();
+
+ /**
+ * Get the JACC Context ID
+ * @return
+ */
+ public String getJaccContextID();
+
+ /**
+ * Get the PolicyConfiguration created by
+ * this facade
+ * @return
+ */
+ public PolicyConfiguration getPolicyConfiguration();
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/security/PolicyConfigurationFacadeMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/WarJaccPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/WarJaccPolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/WarJaccPolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,57 +1,57 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.web.WebPermissionMapping;
-
-//$Id$
-
-/**
- * Top level Jacc Policy For WARs
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public class WarJaccPolicy extends JaccPolicy<JBossWebMetaData>
-{
- public WarJaccPolicy(String id)
- {
- super(id);
- }
-
- public WarJaccPolicy(String id, JBossWebMetaData metaData, Boolean standaloneDeployment)
- {
- super(id, metaData, standaloneDeployment);
- }
-
- @Override
- protected void createPermissions(JBossWebMetaData metaData,
- PolicyConfiguration policyConfiguration)
- throws PolicyContextException
- {
- WebPermissionMapping.createPermissions(metaData, policyConfiguration);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.web.WebPermissionMapping;
+
+//$Id$
+
+/**
+ * Top level Jacc Policy For WARs
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public class WarJaccPolicy extends JaccPolicy<JBossWebMetaData>
+{
+ public WarJaccPolicy(String id)
+ {
+ super(id);
+ }
+
+ public WarJaccPolicy(String id, JBossWebMetaData metaData, Boolean standaloneDeployment)
+ {
+ super(id, metaData, standaloneDeployment);
+ }
+
+ @Override
+ protected void createPermissions(JBossWebMetaData metaData,
+ PolicyConfiguration policyConfiguration)
+ throws PolicyContextException
+ {
+ WebPermissionMapping.createPermissions(metaData, policyConfiguration);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/security/WarJaccPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/security/WarPolicyConfigurationFacade.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/WarPolicyConfigurationFacade.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/security/WarPolicyConfigurationFacade.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,53 +1,53 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
-
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.web.WebPermissionMapping;
-
-
-/**
- * A facade for constructing web Jacc Permissions
- * into the PolicyConfiguration for the enclosing deployments
- * in the top level deployment
- * @author Anil.Saldhana at redhat.com
- * @since Feb 18, 2008
- * @version $Revision$
- */
-public class WarPolicyConfigurationFacade<T extends JBossWebMetaData>
-extends PolicyConfigurationFacade<JBossWebMetaData>
-{
- public WarPolicyConfigurationFacade(String id, T md)
- {
- super(id, md);
- }
-
- @Override
- protected void createPermissions(JBossWebMetaData metaData,
- PolicyConfiguration policyConfiguration) throws PolicyContextException
- {
- WebPermissionMapping.createPermissions(metaData, policyConfiguration);
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.web.WebPermissionMapping;
+
+
+/**
+ * A facade for constructing web Jacc Permissions
+ * into the PolicyConfiguration for the enclosing deployments
+ * in the top level deployment
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 18, 2008
+ * @version $Revision$
+ */
+public class WarPolicyConfigurationFacade<T extends JBossWebMetaData>
+extends PolicyConfigurationFacade<JBossWebMetaData>
+{
+ public WarPolicyConfigurationFacade(String id, T md)
+ {
+ super(id, md);
+ }
+
+ @Override
+ protected void createPermissions(JBossWebMetaData metaData,
+ PolicyConfiguration policyConfiguration) throws PolicyContextException
+ {
+ WebPermissionMapping.createPermissions(metaData, policyConfiguration);
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/security/WarPolicyConfigurationFacade.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatistics.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatistics.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatistics.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,109 +1,109 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.vfs;
-
-import java.util.Collections;
-import java.util.Date;
-
-import org.jboss.virtual.spi.VFSContext;
-import org.jboss.virtual.spi.cache.CacheStatistics;
-import org.jboss.virtual.spi.cache.VFSCache;
-import org.jboss.virtual.spi.cache.VFSCacheFactory;
-
-/**
- * Simple vfs cache statistics.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class VFSCacheStatistics implements VFSCacheStatisticsMBean
-{
- private CacheStatistics statistics;
-
- public String listCachedContexts()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("<table><tr><th>VFSContext - root URI</th></tr>");
- for (VFSContext context : getStatistics().getCachedContexts())
- {
- builder.append("<tr>");
- builder.append("<td>").append(context.getRootURI()).append("</td>");
- builder.append("</tr>");
- }
- builder.append("</table>");
- return builder.toString();
- }
-
- public int size()
- {
- return getStatistics().size();
- }
-
- public Date lastInsert()
- {
- long lastInsert = getStatistics().lastInsert();
- return (lastInsert > 0) ? new Date(lastInsert) : null;
- }
-
- public String cacheToString()
- {
- return getStatistics().toString();
- }
-
- private CacheStatistics getStatistics()
- {
- if (statistics == null)
- {
- VFSCache cache = VFSCacheFactory.getInstance();
- if (cache instanceof CacheStatistics)
- {
- statistics = CacheStatistics.class.cast(cache);
- }
- else
- {
- statistics = new CacheStatistics()
- {
- public Iterable<VFSContext> getCachedContexts()
- {
- return Collections.emptySet();
- }
-
- public int size()
- {
- return -1;
- }
-
- public long lastInsert()
- {
- return -1;
- }
- };
- }
- }
- return statistics;
- }
-
- @Override
- public String toString()
- {
- return "Noop Cache / Statistics";
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.vfs;
+
+import java.util.Collections;
+import java.util.Date;
+
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.cache.CacheStatistics;
+import org.jboss.virtual.spi.cache.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCacheFactory;
+
+/**
+ * Simple vfs cache statistics.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSCacheStatistics implements VFSCacheStatisticsMBean
+{
+ private CacheStatistics statistics;
+
+ public String listCachedContexts()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<table><tr><th>VFSContext - root URI</th></tr>");
+ for (VFSContext context : getStatistics().getCachedContexts())
+ {
+ builder.append("<tr>");
+ builder.append("<td>").append(context.getRootURI()).append("</td>");
+ builder.append("</tr>");
+ }
+ builder.append("</table>");
+ return builder.toString();
+ }
+
+ public int size()
+ {
+ return getStatistics().size();
+ }
+
+ public Date lastInsert()
+ {
+ long lastInsert = getStatistics().lastInsert();
+ return (lastInsert > 0) ? new Date(lastInsert) : null;
+ }
+
+ public String cacheToString()
+ {
+ return getStatistics().toString();
+ }
+
+ private CacheStatistics getStatistics()
+ {
+ if (statistics == null)
+ {
+ VFSCache cache = VFSCacheFactory.getInstance();
+ if (cache instanceof CacheStatistics)
+ {
+ statistics = CacheStatistics.class.cast(cache);
+ }
+ else
+ {
+ statistics = new CacheStatistics()
+ {
+ public Iterable<VFSContext> getCachedContexts()
+ {
+ return Collections.emptySet();
+ }
+
+ public int size()
+ {
+ return -1;
+ }
+
+ public long lastInsert()
+ {
+ return -1;
+ }
+ };
+ }
+ }
+ return statistics;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Noop Cache / Statistics";
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatistics.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatisticsMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatisticsMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatisticsMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,58 +1,58 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployment.vfs;
-
-import java.util.Date;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public interface VFSCacheStatisticsMBean
-{
- /**
- * List cached contexts.
- *
- * @return the cached contexts table
- */
- String listCachedContexts();
-
- /**
- * Get cache size.
- *
- * @return the cache size.
- */
- int size();
-
- /**
- * Get last insert timestamp.
- *
- * @return the last insert timestamp
- */
- Date lastInsert();
-
- /**
- * Get cache impl to string info.
- *
- * @return cache to string info
- */
- String cacheToString();
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployment.vfs;
+
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface VFSCacheStatisticsMBean
+{
+ /**
+ * List cached contexts.
+ *
+ * @return the cached contexts table
+ */
+ String listCachedContexts();
+
+ /**
+ * Get cache size.
+ *
+ * @return the cache size.
+ */
+ int size();
+
+ /**
+ * Get last insert timestamp.
+ *
+ * @return the last insert timestamp
+ */
+ Date lastInsert();
+
+ /**
+ * Get cache impl to string info.
+ *
+ * @return cache to string info
+ */
+ String cacheToString();
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/deployment/vfs/VFSCacheStatisticsMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/EJB2UserTransactionProvider.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/EJB2UserTransactionProvider.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/EJB2UserTransactionProvider.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,65 +1,65 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* 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.ejb;
-
-import org.jboss.tm.usertx.UserTransactionProvider;
-import org.jboss.tm.usertx.UserTransactionRegistry;
-
-/**
- * EJB2UserTransactionProvider.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class EJB2UserTransactionProvider implements UserTransactionProvider
-{
- /** The singleton */
- private static EJB2UserTransactionProvider singleton = new EJB2UserTransactionProvider();
-
- /** The registry */
- private volatile UserTransactionRegistry registry;
-
- /**
- * Get the singleton
- *
- * @return the singleton
- */
- public static EJB2UserTransactionProvider getSingleton()
- {
- return singleton;
- }
-
- public void setTransactionRegistry(UserTransactionRegistry registry)
- {
- this.registry = registry;
- }
-
- /**
- * Fire the user transaction started event
- */
- void userTransactionStarted()
- {
- UserTransactionRegistry registry = this.registry;
- if (registry != null)
- registry.userTransactionStarted();
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.ejb;
+
+import org.jboss.tm.usertx.UserTransactionProvider;
+import org.jboss.tm.usertx.UserTransactionRegistry;
+
+/**
+ * EJB2UserTransactionProvider.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EJB2UserTransactionProvider implements UserTransactionProvider
+{
+ /** The singleton */
+ private static EJB2UserTransactionProvider singleton = new EJB2UserTransactionProvider();
+
+ /** The registry */
+ private volatile UserTransactionRegistry registry;
+
+ /**
+ * Get the singleton
+ *
+ * @return the singleton
+ */
+ public static EJB2UserTransactionProvider getSingleton()
+ {
+ return singleton;
+ }
+
+ public void setTransactionRegistry(UserTransactionRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ /**
+ * Fire the user transaction started event
+ */
+ void userTransactionStarted()
+ {
+ UserTransactionRegistry registry = this.registry;
+ if (registry != null)
+ registry.userTransactionStarted();
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/EJB2UserTransactionProvider.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/EJBPermissionMapping.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/EJBPermissionMapping.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/EJBPermissionMapping.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,141 +1,141 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.jacc.EJBMethodPermission;
-import javax.security.jacc.EJBRoleRefPermission;
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.spec.ExcludeListMetaData;
-import org.jboss.metadata.ejb.spec.MethodInterfaceType;
-import org.jboss.metadata.ejb.spec.MethodPermissionMetaData;
-import org.jboss.metadata.ejb.spec.MethodPermissionsMetaData;
-import org.jboss.metadata.ejb.spec.MethodsMetaData;
-import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData;
-
-//$Id$
-
-/**
- * Utility class to create the EJB Permissions from the metadata available
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @since Dec 12, 2006
- * @version $Revision$
- */
-public class EJBPermissionMapping
-{
-
- public static void createPermissions(JBossEnterpriseBeanMetaData bean, PolicyConfiguration pc)
- throws PolicyContextException
- {
- // Process the method-permission MethodMetaData
- MethodPermissionsMetaData perms = bean.getMethodPermissions();
- if (perms != null)
- for (MethodPermissionMetaData perm : perms)
- {
- MethodsMetaData methods = perm.getMethods();
- if (methods != null)
- for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods)
- {
- String[] params =
- {};
- if (mmd.getMethodParams() != null)
- params = mmd.getMethodParams().toArray(params);
- else
- params = null;
- String methodName = mmd.getMethodName();
- if (methodName != null && methodName.equals("*"))
- methodName = null;
- MethodInterfaceType miType = mmd.getMethodIntf();
- String iface = miType != null ? miType.name() : null;
- EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params);
- if (perm.getUnchecked() != null)
- {
- pc.addToUncheckedPolicy(p);
- }
- else
- {
- Set<String> roles = perm.getRoles();
- Iterator riter = roles.iterator();
- while (riter.hasNext())
- {
- String role = (String) riter.next();
- pc.addToRole(role, p);
- }
- }
- }
- }
-
- // Process the exclude-list MethodMetaData
- ExcludeListMetaData excluded = bean.getExcludeList();
- if (excluded != null)
- {
- MethodsMetaData methods = excluded.getMethods();
- if (methods != null)
- for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods)
- {
- String[] params =
- {};
- if (mmd.getMethodParams() != null)
- params = mmd.getMethodParams().toArray(params);
- else
- params = null;
- String methodName = mmd.getMethodName();
- if (methodName != null && methodName.equals("*"))
- methodName = null;
- MethodInterfaceType miType = mmd.getMethodIntf();
- String iface = miType != null ? miType.name() : null;
- EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params);
- pc.addToExcludedPolicy(p);
- }
- }
-
- // Process the security-role-ref SecurityRoleRefMetaData
- SecurityRoleRefsMetaData refs = bean.getSecurityRoleRefs();
- if (refs != null)
- for (org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData ref : refs)
- {
- EJBRoleRefPermission p = new EJBRoleRefPermission(bean.getEjbName(), ref.getRoleName());
- pc.addToRole(ref.getRoleLink(), p);
- }
-
- /* Special handling of stateful session bean getEJBObject due how the
- stateful session handles acquire the proxy by sending an invocation to
- the ejb container.
- */
- if (bean.isSession())
- {
- JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData) bean;
- if (smd.isStateful())
- {
- EJBMethodPermission p = new EJBMethodPermission(bean.getEjbName(), "getEJBObject", "Home", null);
- pc.addToUncheckedPolicy(p);
- }
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.security.jacc.EJBMethodPermission;
+import javax.security.jacc.EJBRoleRefPermission;
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.ExcludeListMetaData;
+import org.jboss.metadata.ejb.spec.MethodInterfaceType;
+import org.jboss.metadata.ejb.spec.MethodPermissionMetaData;
+import org.jboss.metadata.ejb.spec.MethodPermissionsMetaData;
+import org.jboss.metadata.ejb.spec.MethodsMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData;
+
+//$Id$
+
+/**
+ * Utility class to create the EJB Permissions from the metadata available
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Dec 12, 2006
+ * @version $Revision$
+ */
+public class EJBPermissionMapping
+{
+
+ public static void createPermissions(JBossEnterpriseBeanMetaData bean, PolicyConfiguration pc)
+ throws PolicyContextException
+ {
+ // Process the method-permission MethodMetaData
+ MethodPermissionsMetaData perms = bean.getMethodPermissions();
+ if (perms != null)
+ for (MethodPermissionMetaData perm : perms)
+ {
+ MethodsMetaData methods = perm.getMethods();
+ if (methods != null)
+ for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods)
+ {
+ String[] params =
+ {};
+ if (mmd.getMethodParams() != null)
+ params = mmd.getMethodParams().toArray(params);
+ else
+ params = null;
+ String methodName = mmd.getMethodName();
+ if (methodName != null && methodName.equals("*"))
+ methodName = null;
+ MethodInterfaceType miType = mmd.getMethodIntf();
+ String iface = miType != null ? miType.name() : null;
+ EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params);
+ if (perm.getUnchecked() != null)
+ {
+ pc.addToUncheckedPolicy(p);
+ }
+ else
+ {
+ Set<String> roles = perm.getRoles();
+ Iterator riter = roles.iterator();
+ while (riter.hasNext())
+ {
+ String role = (String) riter.next();
+ pc.addToRole(role, p);
+ }
+ }
+ }
+ }
+
+ // Process the exclude-list MethodMetaData
+ ExcludeListMetaData excluded = bean.getExcludeList();
+ if (excluded != null)
+ {
+ MethodsMetaData methods = excluded.getMethods();
+ if (methods != null)
+ for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods)
+ {
+ String[] params =
+ {};
+ if (mmd.getMethodParams() != null)
+ params = mmd.getMethodParams().toArray(params);
+ else
+ params = null;
+ String methodName = mmd.getMethodName();
+ if (methodName != null && methodName.equals("*"))
+ methodName = null;
+ MethodInterfaceType miType = mmd.getMethodIntf();
+ String iface = miType != null ? miType.name() : null;
+ EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params);
+ pc.addToExcludedPolicy(p);
+ }
+ }
+
+ // Process the security-role-ref SecurityRoleRefMetaData
+ SecurityRoleRefsMetaData refs = bean.getSecurityRoleRefs();
+ if (refs != null)
+ for (org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData ref : refs)
+ {
+ EJBRoleRefPermission p = new EJBRoleRefPermission(bean.getEjbName(), ref.getRoleName());
+ pc.addToRole(ref.getRoleLink(), p);
+ }
+
+ /* Special handling of stateful session bean getEJBObject due how the
+ stateful session handles acquire the proxy by sending an invocation to
+ the ejb container.
+ */
+ if (bean.isSession())
+ {
+ JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData) bean;
+ if (smd.isStateful())
+ {
+ EJBMethodPermission p = new EJBMethodPermission(bean.getEjbName(), "getEJBObject", "Home", null);
+ pc.addToUncheckedPolicy(p);
+ }
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/EJBPermissionMapping.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,34 +1,34 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.ejb;
-
-/**
- * An empty pojo class used to register the ejb2 container jndi name supplies
- * with the mc. Will be expanded in the future.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class Ejb2xMCContainer
-{
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ejb;
+
+/**
+ * An empty pojo class used to register the ejb2 container jndi name supplies
+ * with the mc. Will be expanded in the future.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Ejb2xMCContainer
+{
+
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/Ejb2xMCContainer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/main/org/jboss/ejb/EjbUtil50.java
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestination.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/CreateDestination.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/CreateDestination.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,112 +1,112 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-/**
- * CreateDestination.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class CreateDestination
-{
- /** The matcher */
- private CreateDestinationMatcher matcher;
-
- /** The factory */
- private CreateDestinationFactory factory;
-
- /**
- * Create a new CreateDestination.
- */
- public CreateDestination()
- {
- }
-
- /**
- * Create a new CreateDestination.
- *
- * @param matcher the matcher
- * @param factory the factory
- * @throws IllegalArgumentException for a null parameter
- */
- public CreateDestination(CreateDestinationMatcher matcher, CreateDestinationFactory factory)
- {
- if (matcher == null)
- throw new IllegalArgumentException("Null matcher");
- if (factory == null)
- throw new IllegalArgumentException("Null factory");
- this.matcher = matcher;
- this.factory = factory;
- }
-
- /**
- * Get the matcher.
- *
- * @return the matcher.
- */
- public CreateDestinationMatcher getMatcher()
- {
- return matcher;
- }
-
- /**
- * Set the matcher.
- *
- * @param matcher the matcher.
- */
- public void setMatcher(CreateDestinationMatcher matcher)
- {
- this.matcher = matcher;
- }
-
- /**
- * Get the factory.
- *
- * @return the factory.
- */
- public CreateDestinationFactory getFactory()
- {
- return factory;
- }
-
- /**
- * Set the factory.
- *
- * @param factory the factory.
- */
- public void setFactory(CreateDestinationFactory factory)
- {
- this.factory = factory;
- }
-
- /**
- * Validate the parameters
- */
- public void create()
- {
- if (matcher == null)
- throw new IllegalStateException("No matcher has been set");
- if (factory == null)
- throw new IllegalStateException("No factory has been set");
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+/**
+ * CreateDestination.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CreateDestination
+{
+ /** The matcher */
+ private CreateDestinationMatcher matcher;
+
+ /** The factory */
+ private CreateDestinationFactory factory;
+
+ /**
+ * Create a new CreateDestination.
+ */
+ public CreateDestination()
+ {
+ }
+
+ /**
+ * Create a new CreateDestination.
+ *
+ * @param matcher the matcher
+ * @param factory the factory
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public CreateDestination(CreateDestinationMatcher matcher, CreateDestinationFactory factory)
+ {
+ if (matcher == null)
+ throw new IllegalArgumentException("Null matcher");
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+ this.matcher = matcher;
+ this.factory = factory;
+ }
+
+ /**
+ * Get the matcher.
+ *
+ * @return the matcher.
+ */
+ public CreateDestinationMatcher getMatcher()
+ {
+ return matcher;
+ }
+
+ /**
+ * Set the matcher.
+ *
+ * @param matcher the matcher.
+ */
+ public void setMatcher(CreateDestinationMatcher matcher)
+ {
+ this.matcher = matcher;
+ }
+
+ /**
+ * Get the factory.
+ *
+ * @return the factory.
+ */
+ public CreateDestinationFactory getFactory()
+ {
+ return factory;
+ }
+
+ /**
+ * Set the factory.
+ *
+ * @param factory the factory.
+ */
+ public void setFactory(CreateDestinationFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ /**
+ * Validate the parameters
+ */
+ public void create()
+ {
+ if (matcher == null)
+ throw new IllegalStateException("No matcher has been set");
+ if (factory == null)
+ throw new IllegalStateException("No factory has been set");
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestination.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,218 +1,218 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-
-/**
- * CreateDestinationDeployer.
- *
- * FIXME This should be a component deployer but the ejb deployment is currently componentised
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class CreateDestinationDeployer extends AbstractSimpleRealDeployer<JBossMetaData>
-{
- /** The factories */
- private List<CreateDestination> factories = new CopyOnWriteArrayList<CreateDestination>();
-
- /**
- * Create a new CreateDestinationDeployer.
- */
- public CreateDestinationDeployer()
- {
- super(JBossMetaData.class);
- setOutput(JBossMetaData.class);
- setOutput(ServiceMetaData.class);
- setOutput(KernelDeployment.class);
- }
-
- /**
- * Add a create destination
- *
- * @param factory the factory
- * @throws IllegalArgumentException for a null factory
- */
- public void addCreateDestination(CreateDestination factory)
- {
- if (factory == null)
- throw new IllegalArgumentException("Null factory");
- factories.add(factory);
- }
-
- /**
- * Remove a create destination
- *
- * @param factory the factory
- * @throws IllegalArgumentException for a null factory
- */
- public void removeCreateDestination(CreateDestination factory)
- {
- if (factory == null)
- throw new IllegalArgumentException("Null factory");
- factories.add(factory);
- }
-
- public void deploy(DeploymentUnit unit, JBossMetaData deployment) throws DeploymentException
- {
- if (factories.isEmpty())
- return;
-
- JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans();
- if (beans != null && beans.isEmpty() == false)
- {
- ArrayList<JBossMessageDrivenBeanMetaData> deployed = new ArrayList<JBossMessageDrivenBeanMetaData>();
- for (JBossEnterpriseBeanMetaData bean : beans)
- {
- if (bean.isMessageDriven())
- {
- try
- {
- JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) bean;
- if (isCreateDestination(unit, messageDriven))
- {
- deploy(unit, messageDriven);
- deployed.add(messageDriven);
- }
- }
- catch (Exception e)
- {
- if (deployed.isEmpty() == false)
- {
- for (JBossMessageDrivenBeanMetaData messageDriven : deployed)
- {
- try
- {
- undeploy(unit, messageDriven);
- }
- catch (Exception t)
- {
- log.warn("Error undeploying destination: " + messageDriven.getName(), t);
- }
- }
- }
- throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e);
- }
- }
- }
- }
- }
-
- public void undeploy(DeploymentUnit unit, JBossMetaData deployment)
- {
- if (factories.isEmpty())
- return;
-
- JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans();
- if (beans != null && beans.isEmpty() == false)
- {
- for (JBossEnterpriseBeanMetaData bean : beans)
- {
- if (bean.isMessageDriven())
- {
- try
- {
- JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) bean;
- if (isCreateDestination(unit, messageDriven))
- undeploy(unit, messageDriven);
- }
- catch (Exception e)
- {
- log.warn("Error undeploying destination" + bean.getName(), e);
- }
- }
- }
- }
- }
-
- /**
- * Deploy a message driven bean
- *
- * @param unit the deployment unit
- * @param mdb the mdb
- * @throws DeploymentException for any error
- */
- protected void deploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
- {
- for (CreateDestination createDestination : factories)
- {
- if (createDestination.getMatcher().isMatch(unit, mdb))
- {
- Object attachment = createDestination.getFactory().create(unit, mdb);
- if (attachment != null)
- {
- unit.addAttachment(getAttachmentName(unit, mdb), attachment);
- return;
- }
- }
- }
- }
-
- /**
- * Undeploy a message driven bean
- *
- * @param unit the deployment unit
- * @param mdb the mdb
- * @throws DeploymentException for any error
- */
- protected void undeploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
- {
- unit.removeAttachment(getAttachmentName(unit, mdb));
- }
-
- /**
- * Whether we should create a destination for this MDB
- *
- * @param unit the deployment unit
- * @param mdb the message driven metadata
- * @return true to create a destination
- * @throws DeploymentException for any error
- */
- protected boolean isCreateDestination(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
- {
- return mdb.isCreateDestination();
- }
-
- /**
- * Get the attachment name
- *
- * @param unit the unit
- * @param mdb the mdb
- * @return the attachment name
- */
- protected String getAttachmentName(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb)
- {
- return mdb.getName() + "##Create_Destination";
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * CreateDestinationDeployer.
+ *
+ * FIXME This should be a component deployer but the ejb deployment is currently componentised
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CreateDestinationDeployer extends AbstractSimpleRealDeployer<JBossMetaData>
+{
+ /** The factories */
+ private List<CreateDestination> factories = new CopyOnWriteArrayList<CreateDestination>();
+
+ /**
+ * Create a new CreateDestinationDeployer.
+ */
+ public CreateDestinationDeployer()
+ {
+ super(JBossMetaData.class);
+ setOutput(JBossMetaData.class);
+ setOutput(ServiceMetaData.class);
+ setOutput(KernelDeployment.class);
+ }
+
+ /**
+ * Add a create destination
+ *
+ * @param factory the factory
+ * @throws IllegalArgumentException for a null factory
+ */
+ public void addCreateDestination(CreateDestination factory)
+ {
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+ factories.add(factory);
+ }
+
+ /**
+ * Remove a create destination
+ *
+ * @param factory the factory
+ * @throws IllegalArgumentException for a null factory
+ */
+ public void removeCreateDestination(CreateDestination factory)
+ {
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+ factories.add(factory);
+ }
+
+ public void deploy(DeploymentUnit unit, JBossMetaData deployment) throws DeploymentException
+ {
+ if (factories.isEmpty())
+ return;
+
+ JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans();
+ if (beans != null && beans.isEmpty() == false)
+ {
+ ArrayList<JBossMessageDrivenBeanMetaData> deployed = new ArrayList<JBossMessageDrivenBeanMetaData>();
+ for (JBossEnterpriseBeanMetaData bean : beans)
+ {
+ if (bean.isMessageDriven())
+ {
+ try
+ {
+ JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) bean;
+ if (isCreateDestination(unit, messageDriven))
+ {
+ deploy(unit, messageDriven);
+ deployed.add(messageDriven);
+ }
+ }
+ catch (Exception e)
+ {
+ if (deployed.isEmpty() == false)
+ {
+ for (JBossMessageDrivenBeanMetaData messageDriven : deployed)
+ {
+ try
+ {
+ undeploy(unit, messageDriven);
+ }
+ catch (Exception t)
+ {
+ log.warn("Error undeploying destination: " + messageDriven.getName(), t);
+ }
+ }
+ }
+ throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e);
+ }
+ }
+ }
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit, JBossMetaData deployment)
+ {
+ if (factories.isEmpty())
+ return;
+
+ JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans();
+ if (beans != null && beans.isEmpty() == false)
+ {
+ for (JBossEnterpriseBeanMetaData bean : beans)
+ {
+ if (bean.isMessageDriven())
+ {
+ try
+ {
+ JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) bean;
+ if (isCreateDestination(unit, messageDriven))
+ undeploy(unit, messageDriven);
+ }
+ catch (Exception e)
+ {
+ log.warn("Error undeploying destination" + bean.getName(), e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Deploy a message driven bean
+ *
+ * @param unit the deployment unit
+ * @param mdb the mdb
+ * @throws DeploymentException for any error
+ */
+ protected void deploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
+ {
+ for (CreateDestination createDestination : factories)
+ {
+ if (createDestination.getMatcher().isMatch(unit, mdb))
+ {
+ Object attachment = createDestination.getFactory().create(unit, mdb);
+ if (attachment != null)
+ {
+ unit.addAttachment(getAttachmentName(unit, mdb), attachment);
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * Undeploy a message driven bean
+ *
+ * @param unit the deployment unit
+ * @param mdb the mdb
+ * @throws DeploymentException for any error
+ */
+ protected void undeploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
+ {
+ unit.removeAttachment(getAttachmentName(unit, mdb));
+ }
+
+ /**
+ * Whether we should create a destination for this MDB
+ *
+ * @param unit the deployment unit
+ * @param mdb the message driven metadata
+ * @return true to create a destination
+ * @throws DeploymentException for any error
+ */
+ protected boolean isCreateDestination(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
+ {
+ return mdb.isCreateDestination();
+ }
+
+ /**
+ * Get the attachment name
+ *
+ * @param unit the unit
+ * @param mdb the mdb
+ * @return the attachment name
+ */
+ protected String getAttachmentName(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb)
+ {
+ return mdb.getName() + "##Create_Destination";
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationFactory.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationFactory.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,45 +1,45 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
-
-/**
- * CreateDestinationFactory.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface CreateDestinationFactory
-{
- /**
- * Return the attachment to create the destination
- *
- * @param unit the unit
- * @param mdb the mdb
- * @return the attachment
- * @throws DeploymentException for any error
- */
- Object create(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException;
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+
+/**
+ * CreateDestinationFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CreateDestinationFactory
+{
+ /**
+ * Return the attachment to create the destination
+ *
+ * @param unit the unit
+ * @param mdb the mdb
+ * @return the attachment
+ * @throws DeploymentException for any error
+ */
+ Object create(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException;
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationMatcher.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationMatcher.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationMatcher.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,45 +1,45 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
-
-/**
- * CreateDestinationMatcher.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface CreateDestinationMatcher
-{
- /**
- * Return true if it is a match
- *
- * @param unit the unit
- * @param mdb the mdb
- * @return true if this is a match
- * @throws DeploymentException for any error
- */
- boolean isMatch(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException;
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+
+/**
+ * CreateDestinationMatcher.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CreateDestinationMatcher
+{
+ /**
+ * Return true if it is a match
+ *
+ * @param unit the unit
+ * @param mdb the mdb
+ * @return true if this is a match
+ * @throws DeploymentException for any error
+ */
+ boolean isMatch(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException;
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/CreateDestinationMatcher.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,455 +1,455 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.ejb.deployers;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
-import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
-import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.DemandMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
-import org.jboss.deployment.dependency.ContainerDependencyMetaData;
-import org.jboss.ejb.Ejb2xMCContainer;
-import org.jboss.ejb.EjbModule;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.metadata.ApplicationMetaData;
-import org.jboss.metadata.ejb.jboss.ContainerConfigurationMetaData;
-import org.jboss.metadata.ejb.jboss.InvokerProxyBindingMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.system.metadata.ServiceAttributeMetaData;
-import org.jboss.system.metadata.ServiceConstructorMetaData;
-import org.jboss.system.metadata.ServiceDependencyMetaData;
-import org.jboss.system.metadata.ServiceDependencyValueMetaData;
-import org.jboss.system.metadata.ServiceInjectionValueMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-
-/**
- * A real deployer that translates JBossMetaData into ServiceMetaData for
- * the ejb module service mbeans.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision$
- */
- at JMX(name="jboss.ejb:service=EJBDeployer", exposedInterface=EjbDeployerMBean.class)
-public class EjbDeployer extends AbstractSimpleVFSRealDeployer<JBossMetaData> implements EjbDeployerMBean
-{
- /** */
- private String transactionManagerServiceName;
- /** Class loading web server name */
- private String webServiceName;
- /** The CachedConnectionManager service used by the CachedConnectionInterceptor */
- private String ccmServiceName;
- /** The ejb timer service */
- private String timerServiceName;
-
- private boolean callByValue;
-
- private String unauthenticatedIdentity = null;
- private String securityManagementName;
- private String securityContextClassName;
- private String defaultSecurityDomain;
-
- /**
- * Inject Policy Registration Bean Name
- */
- private String policyRegistrationName;
-
- /**
- * Create a new EjbDeployer.
- */
- public EjbDeployer()
- {
- super(JBossMetaData.class);
- setOutput(ServiceMetaData.class);
- setOutput(EjbDeployment.class);
- setOutput(KernelDeployment.class);
- }
-
- public String getTransactionManagerServiceName()
- {
- return transactionManagerServiceName;
- }
-
- public void setTransactionManagerServiceName(
- String transactionManagerServiceName)
- {
- this.transactionManagerServiceName = transactionManagerServiceName;
- }
-
- public String getWebServiceName()
- {
- return webServiceName;
- }
-
- public void setWebServiceName(String webServiceName)
- {
- this.webServiceName = webServiceName;
- }
-
- public String getCachedConnectionManagerName()
- {
- return ccmServiceName;
- }
-
- public void setCachedConnectionManagerName(String ccmServiceName)
- {
- this.ccmServiceName = ccmServiceName;
- }
-
- public String getTimerService()
- {
- return timerServiceName;
- }
-
- public void setTimerServiceName(String timerServiceName)
- {
- this.timerServiceName = timerServiceName;
- }
-
-
- public boolean isCallByValue()
- {
- return callByValue;
- }
-
- public void setCallByValue(boolean callByValue)
- {
- this.callByValue = callByValue;
- }
-
- /**
- * Obtain an unauthenticated identity
- *
- * @return the unauthenticated identity
- */
- public String getUnauthenticatedIdentity()
- {
- return unauthenticatedIdentity;
- }
-
- /**
- * Specify an unauthenticated identity
- * @param unauthenticatedIdentity
- */
- public void setUnauthenticatedIdentity(String unauthenticatedIdentity)
- {
- this.unauthenticatedIdentity = unauthenticatedIdentity;
- }
-
- public void setDefaultSecurityDomain(String defaultSecurityDomain)
- {
- this.defaultSecurityDomain = defaultSecurityDomain;
- }
-
- public void setSecurityManagementName(String sm)
- {
- this.securityManagementName = sm;
- }
-
- public void setSecurityContextClassName(String securityContextClassName)
- {
- this.securityContextClassName = securityContextClassName;
- }
-
- /**
- * Get the PolicyRegistration Name
- * @return
- */
- public String getPolicyRegistration()
- {
- return policyRegistrationName;
- }
-
- /**
- * Set the Policy Registration Bean Name
- * @param policyRegistration
- */
- public void setPolicyRegistrationName(String policyRegistration)
- {
- this.policyRegistrationName = policyRegistration;
- }
-
- @Override
- public void deploy(VFSDeploymentUnit unit, JBossMetaData deployment)
- throws DeploymentException
- {
- // TODO: use BeanVerifier to validate the metadata in the DDs
-
- // If it is a deployment with ejbVersion unknown or 3
- if (!deployment.isEJB2x() && !deployment.isEJB1x())
- return; // let EJB3 deployer handle this
-
- ServiceMetaData ejbModule = new ServiceMetaData();
- ejbModule.setCode(EjbModule.class.getName());
-
-
- // Build an escaped JMX name including deployment shortname
- ObjectName moduleObjectName = null;
- try
- {
- moduleObjectName = this.getObjectName(unit, deployment);
- }
- catch(MalformedObjectNameException e)
- {
- throw new DeploymentException("Failed to create EJB module " + unit.getName() +
- ": malformed EjbModule name", e);
- }
-
- ejbModule.setObjectName(moduleObjectName);
-
- ServiceConstructorMetaData ctor = new ServiceConstructorMetaData();
- ctor.setSignature(
- new String[]{VFSDeploymentUnit.class.getName(), ApplicationMetaData.class.getName()}
- );
- ApplicationMetaData legacyMD = new ApplicationMetaData(deployment);
- ctor.setParameters(new Object[]{unit, legacyMD});
- ejbModule.setConstructor(ctor);
-
- // set attributes
- List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
- // Transaction manager
- ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
- attr.setName("TransactionManagerFactory");
- ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData();
- dependencyValue.setDependency(getTransactionManagerServiceName());
- dependencyValue.setProxyType("attribute");
- attr.setValue(dependencyValue);
- attrs.add(attr);
- // Security management
- attr = new ServiceAttributeMetaData();
- attr.setName("SecurityManagement");
- ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(securityManagementName);
- attr.setValue(injectionValue);
- attrs.add(attr);
- //Policy Registration
- attr = new ServiceAttributeMetaData();
- attr.setName("PolicyRegistration");
- ServiceInjectionValueMetaData prInjectionValue = new ServiceInjectionValueMetaData(policyRegistrationName);
- attr.setValue(prInjectionValue);
- attrs.add(attr);
- // Add injection of the WebServiceName
- String wsName = getWebServiceName();
- if (wsName != null)
- {
- ServiceAttributeMetaData ws = new ServiceAttributeMetaData();
- ws.setName("WebServiceName");
- ServiceDependencyValueMetaData wsDepends = new ServiceDependencyValueMetaData();
- wsDepends.setDependency(wsName);
- ws.setValue(wsDepends);
- attrs.add(ws);
- }
- // Injection of the TimerService
- ServiceAttributeMetaData tms = new ServiceAttributeMetaData();
- ServiceDependencyValueMetaData tmsDepends = new ServiceDependencyValueMetaData();
- tms.setName("TimerService");
- tmsDepends.setDependency(timerServiceName);
- tmsDepends.setProxyType("attribute");
- tms.setValue(tmsDepends);
- attrs.add(tms);
-
- ejbModule.setAttributes(attrs);
-
- List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
- // CCM for CachedConnectionInterceptor dependency
- // TODO: this should be injected directly to the interceptor
- if( ccmServiceName != null && ccmServiceName.length() > 0 )
- {
- ServiceDependencyMetaData ccm = new ServiceDependencyMetaData();
- ccm.setIDependOn(ccmServiceName);
- dependencies.add(ccm);
- }
- // Add dependencies on the invoker services in use
- JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans();
- Iterator<JBossEnterpriseBeanMetaData> beansIter = beans.iterator();
- HashSet<String> invokerNames = new HashSet<String>();
- HashSet<String> beanDepends = new HashSet<String>();
- // Process ContainerDependencyMetaData
- VFSDeploymentUnit topUnit = unit.getTopLevel();
- Map<String, ContainerDependencyMetaData> endpoints = (Map<String, ContainerDependencyMetaData>) topUnit.getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY);
- if(endpoints == null)
- log.warn(unit+" has no ContainerDependencyMetaData attachment");
- String vfsPath = unit.getRelativePath();
- ArrayList<BeanMetaData> mcBeanMD = new ArrayList<BeanMetaData>();
- while( beansIter.hasNext() )
- {
- JBossEnterpriseBeanMetaData bmd = beansIter.next();
- Set<String> depends = bmd.getDepends();
- if (depends != null)
- beanDepends.addAll(depends);
- String configName = bmd.getConfigurationName();
- ContainerConfigurationMetaData cmd = bmd.determineContainerConfiguration();
- Set<String> invokers = cmd.getInvokerProxyBindingNames();
- if(invokers != null)
- for(String iname : invokers)
- {
- InvokerProxyBindingMetaData imd = deployment.getInvokerProxyBinding(iname);
- if (imd == null)
- throw new DeploymentException("Failed to locate invoker: "+iname);
- String invokerName = imd.getInvokerMBean();
- if( invokerName.equalsIgnoreCase("default") )
- {
- // TODO: JBAS-4306 hack to ingore the invalid default invoker-mbean
- continue;
- }
- if( invokerNames.contains(invokerName) == false )
- {
- invokerNames.add(invokerName);
- ServiceDependencyMetaData invoker = new ServiceDependencyMetaData();
- invoker.setIDependOn(invokerName);
- dependencies.add(invoker);
- }
- }
-
- // Create mc beans that declare the container ejb jndi name supplies
- if(endpoints != null)
- {
- String ejbKey = "ejb/" + vfsPath + "#" + bmd.getEjbName();
- ContainerDependencyMetaData cdmd = endpoints.get(ejbKey);
- if(cdmd != null)
- {
- // Create the metadata for the bean to install
- String mcname = ejbKey + ",uid"+System.identityHashCode(bmd);
- BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(mcname, Ejb2xMCContainer.class.getName());
- for(String jndiName : cdmd.getJndiNames())
- {
- String supplyName = "jndi:" + jndiName;
- builder.addSupply(supplyName);
- }
-
- BeanMetaData mcbmd = builder.getBeanMetaData();
- log.info("installing bean: " + mcname);
- log.info(" with dependencies:");
- log.info(" and supplies:");
- for(SupplyMetaData smd : mcbmd.getSupplies())
- {
- log.info("\t" + smd.getSupply());
- }
- mcBeanMD.add(mcbmd);
- }
- }
- }
-
- // Add any declared dependencies
- /* TODO: this is too coarse as bean to bean depends are being pulled up to the module level
- and an ejb module cannot depend on the beans it creates. The ejb deployer needs to
- be refactored into a component based deployer.
- */
- try
- {
- for(String depend : beanDepends)
- {
- ObjectName n = new ObjectName(depend);
- ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
- sdmd.setIDependOn(n.toString());
- dependencies.add(sdmd);
- }
- }
- catch(MalformedObjectNameException e)
- {
- throw new DeploymentException(e);
- }
- ejbModule.setDependencies(dependencies);
-
- unit.addAttachment("EjbServiceMetaData", ejbModule, ServiceMetaData.class);
- // Create a kernel deployment for the module mc beans
- AbstractKernelDeployment akd = new AbstractKernelDeployment();
- akd.setName(ejbModule.getObjectName().getCanonicalName()+"Beans");
- akd.setBeans(mcBeanMD);
- unit.addAttachment(KernelDeployment.class, akd);
-
- // Pass the ejb callByValue setting
- if (callByValue)
- unit.addAttachment("EJB.callByValue", Boolean.TRUE, Boolean.class);
- //Pass the unauthenticated identity
- if(this.unauthenticatedIdentity != null)
- unit.addAttachment("EJB.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class);
- //Pass the SecurityContextClassName
- if(this.securityContextClassName != null)
- unit.addAttachment("EJB.securityContextClassName", securityContextClassName, String.class);
- //Pass the Default SecurityDomain
- if(this.defaultSecurityDomain != null)
- unit.addAttachment("EJB.defaultSecurityDomain", defaultSecurityDomain, String.class);
- }
-
- @Override
- public void undeploy(VFSDeploymentUnit unit, JBossMetaData deployment)
- {
- }
-
- /**
- * Get the object name of the ServiceMetaData instance associated with
- * the EjbModule. This uses the pattern:
- * "jboss.j2ee:service=EjbModule,module="+unit.getSimpleName()
- *
- * @param unit the deployment unit
- * @param metaData - the ejb jar metaData
- * @return "jboss.j2ee:service=EjbModule,module="+unit.getSimpleName()
- * @throws MalformedObjectNameException
- */
- protected ObjectName getObjectName(VFSDeploymentUnit unit, JBossMetaData metaData)
- throws MalformedObjectNameException
- {
- String name = metaData.getJmxName();
- if( name == null )
- {
- String unitShortName = unit.getName();
- if (unitShortName.endsWith("/"))
- {
- unitShortName = unitShortName.substring(0, unitShortName.length() - 1);
- }
-
- if(unitShortName.endsWith("!"))
- {
- unitShortName = unitShortName.substring(0, unitShortName.length() - 1);
- }
-
- unitShortName = unitShortName.substring(unitShortName.lastIndexOf("/") + 1);
- //
- unitShortName = ObjectName.quote(unitShortName);
- name = EjbModule.BASE_EJB_MODULE_NAME + ",module=" + unitShortName;
- }
-
- return new ObjectName(name);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.ejb.deployers;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.ejb.Ejb2xMCContainer;
+import org.jboss.ejb.EjbModule;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.ApplicationMetaData;
+import org.jboss.metadata.ejb.jboss.ContainerConfigurationMetaData;
+import org.jboss.metadata.ejb.jboss.InvokerProxyBindingMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+import org.jboss.system.metadata.ServiceInjectionValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * A real deployer that translates JBossMetaData into ServiceMetaData for
+ * the ejb module service mbeans.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+ at JMX(name="jboss.ejb:service=EJBDeployer", exposedInterface=EjbDeployerMBean.class)
+public class EjbDeployer extends AbstractSimpleVFSRealDeployer<JBossMetaData> implements EjbDeployerMBean
+{
+ /** */
+ private String transactionManagerServiceName;
+ /** Class loading web server name */
+ private String webServiceName;
+ /** The CachedConnectionManager service used by the CachedConnectionInterceptor */
+ private String ccmServiceName;
+ /** The ejb timer service */
+ private String timerServiceName;
+
+ private boolean callByValue;
+
+ private String unauthenticatedIdentity = null;
+ private String securityManagementName;
+ private String securityContextClassName;
+ private String defaultSecurityDomain;
+
+ /**
+ * Inject Policy Registration Bean Name
+ */
+ private String policyRegistrationName;
+
+ /**
+ * Create a new EjbDeployer.
+ */
+ public EjbDeployer()
+ {
+ super(JBossMetaData.class);
+ setOutput(ServiceMetaData.class);
+ setOutput(EjbDeployment.class);
+ setOutput(KernelDeployment.class);
+ }
+
+ public String getTransactionManagerServiceName()
+ {
+ return transactionManagerServiceName;
+ }
+
+ public void setTransactionManagerServiceName(
+ String transactionManagerServiceName)
+ {
+ this.transactionManagerServiceName = transactionManagerServiceName;
+ }
+
+ public String getWebServiceName()
+ {
+ return webServiceName;
+ }
+
+ public void setWebServiceName(String webServiceName)
+ {
+ this.webServiceName = webServiceName;
+ }
+
+ public String getCachedConnectionManagerName()
+ {
+ return ccmServiceName;
+ }
+
+ public void setCachedConnectionManagerName(String ccmServiceName)
+ {
+ this.ccmServiceName = ccmServiceName;
+ }
+
+ public String getTimerService()
+ {
+ return timerServiceName;
+ }
+
+ public void setTimerServiceName(String timerServiceName)
+ {
+ this.timerServiceName = timerServiceName;
+ }
+
+
+ public boolean isCallByValue()
+ {
+ return callByValue;
+ }
+
+ public void setCallByValue(boolean callByValue)
+ {
+ this.callByValue = callByValue;
+ }
+
+ /**
+ * Obtain an unauthenticated identity
+ *
+ * @return the unauthenticated identity
+ */
+ public String getUnauthenticatedIdentity()
+ {
+ return unauthenticatedIdentity;
+ }
+
+ /**
+ * Specify an unauthenticated identity
+ * @param unauthenticatedIdentity
+ */
+ public void setUnauthenticatedIdentity(String unauthenticatedIdentity)
+ {
+ this.unauthenticatedIdentity = unauthenticatedIdentity;
+ }
+
+ public void setDefaultSecurityDomain(String defaultSecurityDomain)
+ {
+ this.defaultSecurityDomain = defaultSecurityDomain;
+ }
+
+ public void setSecurityManagementName(String sm)
+ {
+ this.securityManagementName = sm;
+ }
+
+ public void setSecurityContextClassName(String securityContextClassName)
+ {
+ this.securityContextClassName = securityContextClassName;
+ }
+
+ /**
+ * Get the PolicyRegistration Name
+ * @return
+ */
+ public String getPolicyRegistration()
+ {
+ return policyRegistrationName;
+ }
+
+ /**
+ * Set the Policy Registration Bean Name
+ * @param policyRegistration
+ */
+ public void setPolicyRegistrationName(String policyRegistration)
+ {
+ this.policyRegistrationName = policyRegistration;
+ }
+
+ @Override
+ public void deploy(VFSDeploymentUnit unit, JBossMetaData deployment)
+ throws DeploymentException
+ {
+ // TODO: use BeanVerifier to validate the metadata in the DDs
+
+ // If it is a deployment with ejbVersion unknown or 3
+ if (!deployment.isEJB2x() && !deployment.isEJB1x())
+ return; // let EJB3 deployer handle this
+
+ ServiceMetaData ejbModule = new ServiceMetaData();
+ ejbModule.setCode(EjbModule.class.getName());
+
+
+ // Build an escaped JMX name including deployment shortname
+ ObjectName moduleObjectName = null;
+ try
+ {
+ moduleObjectName = this.getObjectName(unit, deployment);
+ }
+ catch(MalformedObjectNameException e)
+ {
+ throw new DeploymentException("Failed to create EJB module " + unit.getName() +
+ ": malformed EjbModule name", e);
+ }
+
+ ejbModule.setObjectName(moduleObjectName);
+
+ ServiceConstructorMetaData ctor = new ServiceConstructorMetaData();
+ ctor.setSignature(
+ new String[]{VFSDeploymentUnit.class.getName(), ApplicationMetaData.class.getName()}
+ );
+ ApplicationMetaData legacyMD = new ApplicationMetaData(deployment);
+ ctor.setParameters(new Object[]{unit, legacyMD});
+ ejbModule.setConstructor(ctor);
+
+ // set attributes
+ List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
+ // Transaction manager
+ ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
+ attr.setName("TransactionManagerFactory");
+ ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData();
+ dependencyValue.setDependency(getTransactionManagerServiceName());
+ dependencyValue.setProxyType("attribute");
+ attr.setValue(dependencyValue);
+ attrs.add(attr);
+ // Security management
+ attr = new ServiceAttributeMetaData();
+ attr.setName("SecurityManagement");
+ ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(securityManagementName);
+ attr.setValue(injectionValue);
+ attrs.add(attr);
+ //Policy Registration
+ attr = new ServiceAttributeMetaData();
+ attr.setName("PolicyRegistration");
+ ServiceInjectionValueMetaData prInjectionValue = new ServiceInjectionValueMetaData(policyRegistrationName);
+ attr.setValue(prInjectionValue);
+ attrs.add(attr);
+ // Add injection of the WebServiceName
+ String wsName = getWebServiceName();
+ if (wsName != null)
+ {
+ ServiceAttributeMetaData ws = new ServiceAttributeMetaData();
+ ws.setName("WebServiceName");
+ ServiceDependencyValueMetaData wsDepends = new ServiceDependencyValueMetaData();
+ wsDepends.setDependency(wsName);
+ ws.setValue(wsDepends);
+ attrs.add(ws);
+ }
+ // Injection of the TimerService
+ ServiceAttributeMetaData tms = new ServiceAttributeMetaData();
+ ServiceDependencyValueMetaData tmsDepends = new ServiceDependencyValueMetaData();
+ tms.setName("TimerService");
+ tmsDepends.setDependency(timerServiceName);
+ tmsDepends.setProxyType("attribute");
+ tms.setValue(tmsDepends);
+ attrs.add(tms);
+
+ ejbModule.setAttributes(attrs);
+
+ List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
+ // CCM for CachedConnectionInterceptor dependency
+ // TODO: this should be injected directly to the interceptor
+ if( ccmServiceName != null && ccmServiceName.length() > 0 )
+ {
+ ServiceDependencyMetaData ccm = new ServiceDependencyMetaData();
+ ccm.setIDependOn(ccmServiceName);
+ dependencies.add(ccm);
+ }
+ // Add dependencies on the invoker services in use
+ JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans();
+ Iterator<JBossEnterpriseBeanMetaData> beansIter = beans.iterator();
+ HashSet<String> invokerNames = new HashSet<String>();
+ HashSet<String> beanDepends = new HashSet<String>();
+ // Process ContainerDependencyMetaData
+ VFSDeploymentUnit topUnit = unit.getTopLevel();
+ Map<String, ContainerDependencyMetaData> endpoints = (Map<String, ContainerDependencyMetaData>) topUnit.getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY);
+ if(endpoints == null)
+ log.warn(unit+" has no ContainerDependencyMetaData attachment");
+ String vfsPath = unit.getRelativePath();
+ ArrayList<BeanMetaData> mcBeanMD = new ArrayList<BeanMetaData>();
+ while( beansIter.hasNext() )
+ {
+ JBossEnterpriseBeanMetaData bmd = beansIter.next();
+ Set<String> depends = bmd.getDepends();
+ if (depends != null)
+ beanDepends.addAll(depends);
+ String configName = bmd.getConfigurationName();
+ ContainerConfigurationMetaData cmd = bmd.determineContainerConfiguration();
+ Set<String> invokers = cmd.getInvokerProxyBindingNames();
+ if(invokers != null)
+ for(String iname : invokers)
+ {
+ InvokerProxyBindingMetaData imd = deployment.getInvokerProxyBinding(iname);
+ if (imd == null)
+ throw new DeploymentException("Failed to locate invoker: "+iname);
+ String invokerName = imd.getInvokerMBean();
+ if( invokerName.equalsIgnoreCase("default") )
+ {
+ // TODO: JBAS-4306 hack to ingore the invalid default invoker-mbean
+ continue;
+ }
+ if( invokerNames.contains(invokerName) == false )
+ {
+ invokerNames.add(invokerName);
+ ServiceDependencyMetaData invoker = new ServiceDependencyMetaData();
+ invoker.setIDependOn(invokerName);
+ dependencies.add(invoker);
+ }
+ }
+
+ // Create mc beans that declare the container ejb jndi name supplies
+ if(endpoints != null)
+ {
+ String ejbKey = "ejb/" + vfsPath + "#" + bmd.getEjbName();
+ ContainerDependencyMetaData cdmd = endpoints.get(ejbKey);
+ if(cdmd != null)
+ {
+ // Create the metadata for the bean to install
+ String mcname = ejbKey + ",uid"+System.identityHashCode(bmd);
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(mcname, Ejb2xMCContainer.class.getName());
+ for(String jndiName : cdmd.getJndiNames())
+ {
+ String supplyName = "jndi:" + jndiName;
+ builder.addSupply(supplyName);
+ }
+
+ BeanMetaData mcbmd = builder.getBeanMetaData();
+ log.info("installing bean: " + mcname);
+ log.info(" with dependencies:");
+ log.info(" and supplies:");
+ for(SupplyMetaData smd : mcbmd.getSupplies())
+ {
+ log.info("\t" + smd.getSupply());
+ }
+ mcBeanMD.add(mcbmd);
+ }
+ }
+ }
+
+ // Add any declared dependencies
+ /* TODO: this is too coarse as bean to bean depends are being pulled up to the module level
+ and an ejb module cannot depend on the beans it creates. The ejb deployer needs to
+ be refactored into a component based deployer.
+ */
+ try
+ {
+ for(String depend : beanDepends)
+ {
+ ObjectName n = new ObjectName(depend);
+ ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
+ sdmd.setIDependOn(n.toString());
+ dependencies.add(sdmd);
+ }
+ }
+ catch(MalformedObjectNameException e)
+ {
+ throw new DeploymentException(e);
+ }
+ ejbModule.setDependencies(dependencies);
+
+ unit.addAttachment("EjbServiceMetaData", ejbModule, ServiceMetaData.class);
+ // Create a kernel deployment for the module mc beans
+ AbstractKernelDeployment akd = new AbstractKernelDeployment();
+ akd.setName(ejbModule.getObjectName().getCanonicalName()+"Beans");
+ akd.setBeans(mcBeanMD);
+ unit.addAttachment(KernelDeployment.class, akd);
+
+ // Pass the ejb callByValue setting
+ if (callByValue)
+ unit.addAttachment("EJB.callByValue", Boolean.TRUE, Boolean.class);
+ //Pass the unauthenticated identity
+ if(this.unauthenticatedIdentity != null)
+ unit.addAttachment("EJB.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class);
+ //Pass the SecurityContextClassName
+ if(this.securityContextClassName != null)
+ unit.addAttachment("EJB.securityContextClassName", securityContextClassName, String.class);
+ //Pass the Default SecurityDomain
+ if(this.defaultSecurityDomain != null)
+ unit.addAttachment("EJB.defaultSecurityDomain", defaultSecurityDomain, String.class);
+ }
+
+ @Override
+ public void undeploy(VFSDeploymentUnit unit, JBossMetaData deployment)
+ {
+ }
+
+ /**
+ * Get the object name of the ServiceMetaData instance associated with
+ * the EjbModule. This uses the pattern:
+ * "jboss.j2ee:service=EjbModule,module="+unit.getSimpleName()
+ *
+ * @param unit the deployment unit
+ * @param metaData - the ejb jar metaData
+ * @return "jboss.j2ee:service=EjbModule,module="+unit.getSimpleName()
+ * @throws MalformedObjectNameException
+ */
+ protected ObjectName getObjectName(VFSDeploymentUnit unit, JBossMetaData metaData)
+ throws MalformedObjectNameException
+ {
+ String name = metaData.getJmxName();
+ if( name == null )
+ {
+ String unitShortName = unit.getName();
+ if (unitShortName.endsWith("/"))
+ {
+ unitShortName = unitShortName.substring(0, unitShortName.length() - 1);
+ }
+
+ if(unitShortName.endsWith("!"))
+ {
+ unitShortName = unitShortName.substring(0, unitShortName.length() - 1);
+ }
+
+ unitShortName = unitShortName.substring(unitShortName.lastIndexOf("/") + 1);
+ //
+ unitShortName = ObjectName.quote(unitShortName);
+ name = EjbModule.BASE_EJB_MODULE_NAME + ",module=" + unitShortName;
+ }
+
+ return new ObjectName(name);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployerMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployerMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,80 +1,80 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-
-/**
- * EJBDeployerMBean.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface EjbDeployerMBean
-{
- /** The default ObjectName */
- ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.ejb:service=EJBDeployer");
-
- /**
- * Whether ear deployments should be call by value
- */
- void setCallByValue(boolean callByValue);
- boolean isCallByValue();
-
- /**
- * Enables/disables the application bean verification upon deployment.
- void setVerifyDeployments(boolean verify);
- boolean getVerifyDeployments();
- */
-
- /**
- * Enables/disables the verbose mode on the verifier.
- void setVerifierVerbose(boolean verbose);
- boolean getVerifierVerbose();
- */
-
- /**
- * Enables/disables the strict mode on the verifier.
- void setStrictVerifier(boolean strictVerifier);
- boolean getStrictVerifier();
- */
-
- /**
- * Enables/disables the metrics interceptor for containers.
- void setMetricsEnabled(boolean enable);
- boolean isMetricsEnabled();
- */
-
- /**
- * The dynamic class loading simple web server name.
- */
- void setWebServiceName(String webServiceName);
- String getWebServiceName();
-
- /**
- * The TransactionManagerServiceName.
- */
- void setTransactionManagerServiceName(String transactionManagerServiceName);
- String getTransactionManagerServiceName();
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+
+/**
+ * EJBDeployerMBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EjbDeployerMBean
+{
+ /** The default ObjectName */
+ ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.ejb:service=EJBDeployer");
+
+ /**
+ * Whether ear deployments should be call by value
+ */
+ void setCallByValue(boolean callByValue);
+ boolean isCallByValue();
+
+ /**
+ * Enables/disables the application bean verification upon deployment.
+ void setVerifyDeployments(boolean verify);
+ boolean getVerifyDeployments();
+ */
+
+ /**
+ * Enables/disables the verbose mode on the verifier.
+ void setVerifierVerbose(boolean verbose);
+ boolean getVerifierVerbose();
+ */
+
+ /**
+ * Enables/disables the strict mode on the verifier.
+ void setStrictVerifier(boolean strictVerifier);
+ boolean getStrictVerifier();
+ */
+
+ /**
+ * Enables/disables the metrics interceptor for containers.
+ void setMetricsEnabled(boolean enable);
+ boolean isMetricsEnabled();
+ */
+
+ /**
+ * The dynamic class loading simple web server name.
+ */
+ void setWebServiceName(String webServiceName);
+ String getWebServiceName();
+
+ /**
+ * The TransactionManagerServiceName.
+ */
+ void setTransactionManagerServiceName(String transactionManagerServiceName);
+ String getTransactionManagerServiceName();
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployerMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/EjbDeployment.java
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/EjbSecurityDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/EjbSecurityDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/EjbSecurityDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,65 +1,65 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-import org.jboss.deployment.security.AbstractSecurityDeployer;
-import org.jboss.deployment.security.EjbJaccPolicy;
-import org.jboss.deployment.security.EjbPolicyConfigurationFacade;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-
-
-/**
- * Security Deployer for ejb-jar
- * @author Anil.Saldhana at redhat.com
- * @since Feb 17, 2008
- * @version $Revision$
- */
-public class EjbSecurityDeployer
-extends AbstractSecurityDeployer<JBossMetaData>
-{
- public EjbSecurityDeployer()
- {
- super();
- addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
- }
-
- @Override
- protected ServiceMetaData getServiceMetaData()
- {
- ServiceMetaData serviceMetaData = new ServiceMetaData();
- serviceMetaData.setCode(EjbPolicyConfigurationFacade.class.getName());
- return serviceMetaData;
- }
-
- @Override
- protected Class<JBossMetaData> getMetaDataClassType()
- {
- return JBossMetaData.class;
- }
-
- @Override
- protected String getJaccPolicyName()
- {
- return EjbJaccPolicy.class.getName();
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import org.jboss.deployment.security.AbstractSecurityDeployer;
+import org.jboss.deployment.security.EjbJaccPolicy;
+import org.jboss.deployment.security.EjbPolicyConfigurationFacade;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+
+/**
+ * Security Deployer for ejb-jar
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 17, 2008
+ * @version $Revision$
+ */
+public class EjbSecurityDeployer
+extends AbstractSecurityDeployer<JBossMetaData>
+{
+ public EjbSecurityDeployer()
+ {
+ super();
+ addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
+ }
+
+ @Override
+ protected ServiceMetaData getServiceMetaData()
+ {
+ ServiceMetaData serviceMetaData = new ServiceMetaData();
+ serviceMetaData.setCode(EjbPolicyConfigurationFacade.class.getName());
+ return serviceMetaData;
+ }
+
+ @Override
+ protected Class<JBossMetaData> getMetaDataClassType()
+ {
+ return JBossMetaData.class;
+ }
+
+ @Override
+ protected String getJaccPolicyName()
+ {
+ return EjbJaccPolicy.class.getName();
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/EjbSecurityDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,125 +1,125 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
-
-/**
- * SimpleCreateDestinationMatcher.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class SimpleCreateDestinationMatcher implements CreateDestinationMatcher
-{
- /** The message listener class */
- private String messageListener;
-
- /** The resource adapter name */
- private String rarName;
-
- /** Whether we are the default matcher */
- private boolean defaultMatcher;
-
- /**
- * Get the messageListener.
- *
- * @return the messageListener.
- */
- public String getMessageListener()
- {
- return messageListener;
- }
-
- /**
- * Set the messageListener.
- *
- * @param messageListener the messageListener.
- */
- public void setMessageListener(String messageListener)
- {
- this.messageListener = messageListener;
- }
-
- /**
- * Get the rarName.
- *
- * @return the rarName.
- */
- public String getRarName()
- {
- return rarName;
- }
-
- /**
- * Set the rarName.
- *
- * @param rarName the rarName.
- */
- public void setRarName(String rarName)
- {
- this.rarName = rarName;
- }
-
- /**
- * Get the defaultMatcher.
- *
- * @return the defaultMatcher.
- */
- public boolean isDefault()
- {
- return defaultMatcher;
- }
-
- /**
- * Set the defaultMatcher.
- *
- * @param defaultMatcher the defaultMatcher.
- */
- public void setDefault(boolean defaultMatcher)
- {
- this.defaultMatcher = defaultMatcher;
- }
-
- public boolean isMatch(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
- {
- if (noMatch(messageListener, mdb.getMessagingType(), isDefault()))
- return false;
- if (noMatch(rarName, mdb.getResourceAdapterName(), isDefault()))
- return false;
- return true;
- }
-
- protected static boolean noMatch(String check, String parameter, boolean defaultMatch)
- {
- if (check != null)
- {
- if (parameter == null)
- return defaultMatch == false;
- parameter = parameter.trim();
- return check.equals(parameter) == false;
- }
- return false;
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.ejb.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+
+/**
+ * SimpleCreateDestinationMatcher.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleCreateDestinationMatcher implements CreateDestinationMatcher
+{
+ /** The message listener class */
+ private String messageListener;
+
+ /** The resource adapter name */
+ private String rarName;
+
+ /** Whether we are the default matcher */
+ private boolean defaultMatcher;
+
+ /**
+ * Get the messageListener.
+ *
+ * @return the messageListener.
+ */
+ public String getMessageListener()
+ {
+ return messageListener;
+ }
+
+ /**
+ * Set the messageListener.
+ *
+ * @param messageListener the messageListener.
+ */
+ public void setMessageListener(String messageListener)
+ {
+ this.messageListener = messageListener;
+ }
+
+ /**
+ * Get the rarName.
+ *
+ * @return the rarName.
+ */
+ public String getRarName()
+ {
+ return rarName;
+ }
+
+ /**
+ * Set the rarName.
+ *
+ * @param rarName the rarName.
+ */
+ public void setRarName(String rarName)
+ {
+ this.rarName = rarName;
+ }
+
+ /**
+ * Get the defaultMatcher.
+ *
+ * @return the defaultMatcher.
+ */
+ public boolean isDefault()
+ {
+ return defaultMatcher;
+ }
+
+ /**
+ * Set the defaultMatcher.
+ *
+ * @param defaultMatcher the defaultMatcher.
+ */
+ public void setDefault(boolean defaultMatcher)
+ {
+ this.defaultMatcher = defaultMatcher;
+ }
+
+ public boolean isMatch(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
+ {
+ if (noMatch(messageListener, mdb.getMessagingType(), isDefault()))
+ return false;
+ if (noMatch(rarName, mdb.getResourceAdapterName(), isDefault()))
+ return false;
+ return true;
+ }
+
+ protected static boolean noMatch(String check, String parameter, boolean defaultMatch)
+ {
+ if (check != null)
+ {
+ if (parameter == null)
+ return defaultMatch == false;
+ parameter = parameter.trim();
+ return check.equals(parameter) == false;
+ }
+ return false;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,115 +1,115 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins;
-
-import java.lang.reflect.Method;
-
-import javax.ejb.Handle;
-
-import org.jboss.ejb.Container;
-import org.jboss.ejb.EnterpriseContext;
-import org.jboss.ejb.StatefulSessionContainer;
-import org.jboss.invocation.Invocation;
-import org.jboss.logging.Logger;
-
-//$Id$
-
-/**
- * Interceptor that handles security aspects after the security checks
- * have been made. Example: setting the principal on the EnterpriseContext
- *
- * This interceptor is needed because the security interceptor happens after
- * the instance interceptor in the case of SFSB due to the reason that
- * security exceptions need to invalidate the session.
- *
- * Note: This interceptor has to follow the SFSB instance interceptor in the
- * call path as it obtains the enterprise context from the invocation
- *
- * JIRA Reference: JBAS-3976
- *
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @since Jan 10, 2007
- * @version $Revision$
- */
-public class StatefulSessionSecurityInterceptor extends AbstractInterceptor
-{
- /** Instance logger. */
- protected Logger log = Logger.getLogger(this.getClass());
-
- protected StatefulSessionContainer container;
-
- //Public -------------------------------------------------------
-
- public void setContainer(Container container)
- {
- this.container = (StatefulSessionContainer)container;
- }
-
- public Container getContainer()
- {
- return container;
- }
-
- public Object invoke(Invocation mi) throws Exception
- {
- EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext();
- if(ctx == null)
- throw new IllegalStateException("EJBContext is null");
-
- //Set the current security information
- ctx.setPrincipal(mi.getPrincipal());
-
- try
- {
- // Invoke through interceptors
- return getNext().invoke(mi);
- }
- finally
- {
- }
- }
-
- public Object invokeHome(Invocation mi) throws Exception
- {
- Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]);
-
- //Invocation on the handle, we don't need a bean instance
- if (getEJBObject.equals(mi.getMethod()))
- return getNext().invokeHome(mi);
-
- EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext();
- if(ctx == null)
- throw new IllegalStateException("EJBContext is null");
-
- //Set the current security information
- ctx.setPrincipal(mi.getPrincipal());
-
- try
- {
- // Invoke through interceptors
- return getNext().invokeHome(mi);
- }
- finally
- {
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins;
+
+import java.lang.reflect.Method;
+
+import javax.ejb.Handle;
+
+import org.jboss.ejb.Container;
+import org.jboss.ejb.EnterpriseContext;
+import org.jboss.ejb.StatefulSessionContainer;
+import org.jboss.invocation.Invocation;
+import org.jboss.logging.Logger;
+
+//$Id$
+
+/**
+ * Interceptor that handles security aspects after the security checks
+ * have been made. Example: setting the principal on the EnterpriseContext
+ *
+ * This interceptor is needed because the security interceptor happens after
+ * the instance interceptor in the case of SFSB due to the reason that
+ * security exceptions need to invalidate the session.
+ *
+ * Note: This interceptor has to follow the SFSB instance interceptor in the
+ * call path as it obtains the enterprise context from the invocation
+ *
+ * JIRA Reference: JBAS-3976
+ *
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Jan 10, 2007
+ * @version $Revision$
+ */
+public class StatefulSessionSecurityInterceptor extends AbstractInterceptor
+{
+ /** Instance logger. */
+ protected Logger log = Logger.getLogger(this.getClass());
+
+ protected StatefulSessionContainer container;
+
+ //Public -------------------------------------------------------
+
+ public void setContainer(Container container)
+ {
+ this.container = (StatefulSessionContainer)container;
+ }
+
+ public Container getContainer()
+ {
+ return container;
+ }
+
+ public Object invoke(Invocation mi) throws Exception
+ {
+ EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext();
+ if(ctx == null)
+ throw new IllegalStateException("EJBContext is null");
+
+ //Set the current security information
+ ctx.setPrincipal(mi.getPrincipal());
+
+ try
+ {
+ // Invoke through interceptors
+ return getNext().invoke(mi);
+ }
+ finally
+ {
+ }
+ }
+
+ public Object invokeHome(Invocation mi) throws Exception
+ {
+ Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]);
+
+ //Invocation on the handle, we don't need a bean instance
+ if (getEJBObject.equals(mi.getMethod()))
+ return getNext().invokeHome(mi);
+
+ EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext();
+ if(ctx == null)
+ throw new IllegalStateException("EJBContext is null");
+
+ //Set the current security information
+ ctx.setPrincipal(mi.getPrincipal());
+
+ try
+ {
+ // Invoke through interceptors
+ return getNext().invokeHome(mi);
+ }
+ finally
+ {
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,497 +1,497 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc.bridge;
-
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.security.Principal;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.lang.reflect.UndeclaredThrowableException;
-
-import javax.security.auth.Subject;
-import javax.security.jacc.PolicyContext;
-import javax.security.jacc.PolicyContextException;
-
-import org.jboss.security.RunAs;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextFactory;
-import org.jboss.security.SecurityContextAssociation;
-
-
-/** A collection of privileged actions for this package
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @author Anil.Saldhana at redhat.com
- * @version $Revison: $
- */
-class SecurityActions
-{
-
- interface RunAsIdentityActions
- {
- RunAsIdentityActions PRIVILEGED = new RunAsIdentityActions()
- {
- private final PrivilegedAction peekAction = new PrivilegedAction()
- {
- public Object run()
- {
- //return SecurityAssociation.peekRunAsIdentity();
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- return sc.getOutgoingRunAs();
- }
- };
-
- private final PrivilegedAction popAction = new PrivilegedAction()
- {
- public Object run()
- {
- //return SecurityAssociation.popRunAsIdentity();
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- RunAs ra = sc.getOutgoingRunAs();
- sc.setOutgoingRunAs(null);
- return ra;
- }
- };
-
- public RunAs peek()
- {
- return (RunAs)AccessController.doPrivileged(peekAction);
- }
-
- public void push(final RunAs id)
- {
- AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- //SecurityAssociation.pushRunAsIdentity((RunAsIdentity)id);
- SecurityContext sa = SecurityContextAssociation.getSecurityContext();
- if(sa == null)
- throw new IllegalStateException("Security Context is null to push runas");
- sa.setOutgoingRunAs(id);
- return null;
- }
- }
- );
- }
-
- public RunAs pop()
- {
- return (RunAs)AccessController.doPrivileged(popAction);
- }
- };
-
- RunAsIdentityActions NON_PRIVILEGED = new RunAsIdentityActions()
- {
- public RunAs peek()
- {
- //return SecurityAssociation.peekRunAsIdentity();
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- return sc.getOutgoingRunAs();
- }
-
- public void push(RunAs id)
- {
- //SecurityAssociation.pushRunAsIdentity(id);
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null to push runas");
- sc.setOutgoingRunAs(id);
- }
-
- public RunAs pop()
- {
- //Pop the RAI
- // return SecurityAssociation.popRunAsIdentity();
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- RunAs ra = null;
- ra = sc.getOutgoingRunAs();
- sc.setOutgoingRunAs(null);
- return ra;
- }
- };
-
- RunAs peek();
-
- void push(RunAs id);
-
- RunAs pop();
- }
-
-
-
- interface PolicyContextActions
- {
- /** The JACC PolicyContext key for the current Subject */
- static final String SUBJECT_CONTEXT_KEY = "javax.security.auth.Subject.container";
- PolicyContextActions PRIVILEGED = new PolicyContextActions()
- {
- private final PrivilegedExceptionAction exAction = new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
- }
- };
- public Subject getContextSubject()
- throws PolicyContextException
- {
- try
- {
- return (Subject) AccessController.doPrivileged(exAction);
- }
- catch(PrivilegedActionException e)
- {
- Exception ex = e.getException();
- if( ex instanceof PolicyContextException )
- throw (PolicyContextException) ex;
- else
- throw new UndeclaredThrowableException(ex);
- }
- }
- };
-
- PolicyContextActions NON_PRIVILEGED = new PolicyContextActions()
- {
- public Subject getContextSubject()
- throws PolicyContextException
- {
- return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
- }
- };
-
- Subject getContextSubject()
- throws PolicyContextException;
- }
-
- static ClassLoader getContextClassLoader()
- {
- return TCLAction.UTIL.getContextClassLoader();
- }
-
- static void setContextClassLoader(ClassLoader loader)
- {
- TCLAction.UTIL.setContextClassLoader(loader);
- }
-
-
-
- static RunAs peekRunAsIdentity()
- {
- if(System.getSecurityManager() == null)
- {
- return RunAsIdentityActions.NON_PRIVILEGED.peek();
- }
- else
- {
- return RunAsIdentityActions.PRIVILEGED.peek();
- }
- }
-
- static void pushRunAsIdentity(RunAs principal)
- {
- if(System.getSecurityManager() == null)
- {
- RunAsIdentityActions.NON_PRIVILEGED.push(principal);
- }
- else
- {
- RunAsIdentityActions.PRIVILEGED.push(principal);
- }
- }
-
- static RunAs popRunAsIdentity()
- {
- if(System.getSecurityManager() == null)
- {
- return RunAsIdentityActions.NON_PRIVILEGED.pop();
- }
- else
- {
- return RunAsIdentityActions.PRIVILEGED.pop();
- }
- }
-
-
- static Subject getContextSubject()
- throws PolicyContextException
- {
- if(System.getSecurityManager() == null)
- {
- return PolicyContextActions.NON_PRIVILEGED.getContextSubject();
- }
- else
- {
- return PolicyContextActions.PRIVILEGED.getContextSubject();
- }
- }
-
- interface TCLAction
- {
- class UTIL
- {
- static TCLAction getTCLAction()
- {
- return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
- }
-
- static ClassLoader getContextClassLoader()
- {
- return getTCLAction().getContextClassLoader();
- }
-
- static ClassLoader getContextClassLoader(Thread thread)
- {
- return getTCLAction().getContextClassLoader(thread);
- }
-
- static void setContextClassLoader(ClassLoader cl)
- {
- getTCLAction().setContextClassLoader(cl);
- }
-
- static void setContextClassLoader(Thread thread, ClassLoader cl)
- {
- getTCLAction().setContextClassLoader(thread, cl);
- }
- }
-
- TCLAction NON_PRIVILEGED = new TCLAction()
- {
- public ClassLoader getContextClassLoader()
- {
- return Thread.currentThread().getContextClassLoader();
- }
-
- public ClassLoader getContextClassLoader(Thread thread)
- {
- return thread.getContextClassLoader();
- }
-
- public void setContextClassLoader(ClassLoader cl)
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- public void setContextClassLoader(Thread thread, ClassLoader cl)
- {
- thread.setContextClassLoader(cl);
- }
- };
-
- TCLAction PRIVILEGED = new TCLAction()
- {
- private final PrivilegedAction getTCLPrivilegedAction = new PrivilegedAction()
- {
- public Object run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- };
-
- public ClassLoader getContextClassLoader()
- {
- return (ClassLoader)AccessController.doPrivileged(getTCLPrivilegedAction);
- }
-
- public ClassLoader getContextClassLoader(final Thread thread)
- {
- return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- return thread.getContextClassLoader();
- }
- });
- }
-
- public void setContextClassLoader(final ClassLoader cl)
- {
- AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
- return null;
- }
- }
- );
- }
-
- public void setContextClassLoader(final Thread thread, final ClassLoader cl)
- {
- AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- thread.setContextClassLoader(cl);
- return null;
- }
- }
- );
- }
- };
-
- ClassLoader getContextClassLoader();
-
- ClassLoader getContextClassLoader(Thread thread);
-
- void setContextClassLoader(ClassLoader cl);
-
- void setContextClassLoader(Thread thread, ClassLoader cl);
- }
-
-
-
- static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain)
- throws PrivilegedActionException
- {
- AccessController.doPrivileged(new PrivilegedExceptionAction(){
-
- public Object run() throws Exception
- {
- SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain);
- SecurityContextAssociation.setSecurityContext(sc);
- return null;
- }});
- }
-
- static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain,
- final Subject subject) throws PrivilegedActionException
- {
- AccessController.doPrivileged(new PrivilegedExceptionAction(){
-
- public Object run() throws Exception
- {
- SecurityContext sc = SecurityContextFactory.createSecurityContext(domain);
- sc.getUtil().createSubjectInfo(p, cred, subject);
- SecurityContextAssociation.setSecurityContext(sc);
- return null;
- }});
- }
-
- static void clearSecurityContext()
- {
- AccessController.doPrivileged(new PrivilegedAction(){
-
- public Object run()
- {
- SecurityContextAssociation.setSecurityContext(null);
- return null;
- }});
- }
-
- static SecurityContext getSecurityContext()
- {
- return (SecurityContext)AccessController.doPrivileged(new PrivilegedAction(){
- public Object run()
- {
- return SecurityContextAssociation.getSecurityContext();
- }
- });
- }
-
- static Exception getContextException()
- {
- return (Exception)AccessController.doPrivileged(new PrivilegedAction()
- {
- static final String EX_KEY = "org.jboss.security.exception";
- public Object run()
- {
- SecurityContext sc = getSecurityContext();
- return sc.getData().get(EX_KEY);
- }
- });
- }
-
- static void pushSubjectContext(final Principal p, final Object cred, final Subject s)
- {
- AccessController.doPrivileged(new PrivilegedAction(){
-
- public Object run()
- {
- SecurityContext sc = getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- sc.getUtil().createSubjectInfo(p, cred, s);
- return null;
- }}
- );
- }
-
- static void popSubjectContext()
- {
- AccessController.doPrivileged(new PrivilegedAction(){
-
- public Object run()
- {
- SecurityContext sc = getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- Principal p = sc.getUtil().getUserPrincipal();
- Object cred = sc.getUtil().getCredential();
- sc.getUtil().createSubjectInfo(p, cred,null);
- return null;
- }}
- );
- }
-
- static void pushCallerRunAsIdentity(final RunAs ra)
- {
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run()
- {
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- sc.setIncomingRunAs(ra);
- return null;
- }
- });
- }
-
- static void popCallerRunAsIdentity()
- {
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run()
- {
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- sc.setIncomingRunAs(null);
- return null;
- }
- });
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc.bridge;
+
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
+import java.security.Principal;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.security.auth.Subject;
+import javax.security.jacc.PolicyContext;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.security.RunAs;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextFactory;
+import org.jboss.security.SecurityContextAssociation;
+
+
+/** A collection of privileged actions for this package
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @author Anil.Saldhana at redhat.com
+ * @version $Revison: $
+ */
+class SecurityActions
+{
+
+ interface RunAsIdentityActions
+ {
+ RunAsIdentityActions PRIVILEGED = new RunAsIdentityActions()
+ {
+ private final PrivilegedAction peekAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ //return SecurityAssociation.peekRunAsIdentity();
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ return sc.getOutgoingRunAs();
+ }
+ };
+
+ private final PrivilegedAction popAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ //return SecurityAssociation.popRunAsIdentity();
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ RunAs ra = sc.getOutgoingRunAs();
+ sc.setOutgoingRunAs(null);
+ return ra;
+ }
+ };
+
+ public RunAs peek()
+ {
+ return (RunAs)AccessController.doPrivileged(peekAction);
+ }
+
+ public void push(final RunAs id)
+ {
+ AccessController.doPrivileged(
+ new PrivilegedAction()
+ {
+ public Object run()
+ {
+ //SecurityAssociation.pushRunAsIdentity((RunAsIdentity)id);
+ SecurityContext sa = SecurityContextAssociation.getSecurityContext();
+ if(sa == null)
+ throw new IllegalStateException("Security Context is null to push runas");
+ sa.setOutgoingRunAs(id);
+ return null;
+ }
+ }
+ );
+ }
+
+ public RunAs pop()
+ {
+ return (RunAs)AccessController.doPrivileged(popAction);
+ }
+ };
+
+ RunAsIdentityActions NON_PRIVILEGED = new RunAsIdentityActions()
+ {
+ public RunAs peek()
+ {
+ //return SecurityAssociation.peekRunAsIdentity();
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ return sc.getOutgoingRunAs();
+ }
+
+ public void push(RunAs id)
+ {
+ //SecurityAssociation.pushRunAsIdentity(id);
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null to push runas");
+ sc.setOutgoingRunAs(id);
+ }
+
+ public RunAs pop()
+ {
+ //Pop the RAI
+ // return SecurityAssociation.popRunAsIdentity();
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ RunAs ra = null;
+ ra = sc.getOutgoingRunAs();
+ sc.setOutgoingRunAs(null);
+ return ra;
+ }
+ };
+
+ RunAs peek();
+
+ void push(RunAs id);
+
+ RunAs pop();
+ }
+
+
+
+ interface PolicyContextActions
+ {
+ /** The JACC PolicyContext key for the current Subject */
+ static final String SUBJECT_CONTEXT_KEY = "javax.security.auth.Subject.container";
+ PolicyContextActions PRIVILEGED = new PolicyContextActions()
+ {
+ private final PrivilegedExceptionAction exAction = new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
+ }
+ };
+ public Subject getContextSubject()
+ throws PolicyContextException
+ {
+ try
+ {
+ return (Subject) AccessController.doPrivileged(exAction);
+ }
+ catch(PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ if( ex instanceof PolicyContextException )
+ throw (PolicyContextException) ex;
+ else
+ throw new UndeclaredThrowableException(ex);
+ }
+ }
+ };
+
+ PolicyContextActions NON_PRIVILEGED = new PolicyContextActions()
+ {
+ public Subject getContextSubject()
+ throws PolicyContextException
+ {
+ return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
+ }
+ };
+
+ Subject getContextSubject()
+ throws PolicyContextException;
+ }
+
+ static ClassLoader getContextClassLoader()
+ {
+ return TCLAction.UTIL.getContextClassLoader();
+ }
+
+ static void setContextClassLoader(ClassLoader loader)
+ {
+ TCLAction.UTIL.setContextClassLoader(loader);
+ }
+
+
+
+ static RunAs peekRunAsIdentity()
+ {
+ if(System.getSecurityManager() == null)
+ {
+ return RunAsIdentityActions.NON_PRIVILEGED.peek();
+ }
+ else
+ {
+ return RunAsIdentityActions.PRIVILEGED.peek();
+ }
+ }
+
+ static void pushRunAsIdentity(RunAs principal)
+ {
+ if(System.getSecurityManager() == null)
+ {
+ RunAsIdentityActions.NON_PRIVILEGED.push(principal);
+ }
+ else
+ {
+ RunAsIdentityActions.PRIVILEGED.push(principal);
+ }
+ }
+
+ static RunAs popRunAsIdentity()
+ {
+ if(System.getSecurityManager() == null)
+ {
+ return RunAsIdentityActions.NON_PRIVILEGED.pop();
+ }
+ else
+ {
+ return RunAsIdentityActions.PRIVILEGED.pop();
+ }
+ }
+
+
+ static Subject getContextSubject()
+ throws PolicyContextException
+ {
+ if(System.getSecurityManager() == null)
+ {
+ return PolicyContextActions.NON_PRIVILEGED.getContextSubject();
+ }
+ else
+ {
+ return PolicyContextActions.PRIVILEGED.getContextSubject();
+ }
+ }
+
+ interface TCLAction
+ {
+ class UTIL
+ {
+ static TCLAction getTCLAction()
+ {
+ return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
+ }
+
+ static ClassLoader getContextClassLoader()
+ {
+ return getTCLAction().getContextClassLoader();
+ }
+
+ static ClassLoader getContextClassLoader(Thread thread)
+ {
+ return getTCLAction().getContextClassLoader(thread);
+ }
+
+ static void setContextClassLoader(ClassLoader cl)
+ {
+ getTCLAction().setContextClassLoader(cl);
+ }
+
+ static void setContextClassLoader(Thread thread, ClassLoader cl)
+ {
+ getTCLAction().setContextClassLoader(thread, cl);
+ }
+ }
+
+ TCLAction NON_PRIVILEGED = new TCLAction()
+ {
+ public ClassLoader getContextClassLoader()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ public ClassLoader getContextClassLoader(Thread thread)
+ {
+ return thread.getContextClassLoader();
+ }
+
+ public void setContextClassLoader(ClassLoader cl)
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ public void setContextClassLoader(Thread thread, ClassLoader cl)
+ {
+ thread.setContextClassLoader(cl);
+ }
+ };
+
+ TCLAction PRIVILEGED = new TCLAction()
+ {
+ private final PrivilegedAction getTCLPrivilegedAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ };
+
+ public ClassLoader getContextClassLoader()
+ {
+ return (ClassLoader)AccessController.doPrivileged(getTCLPrivilegedAction);
+ }
+
+ public ClassLoader getContextClassLoader(final Thread thread)
+ {
+ return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return thread.getContextClassLoader();
+ }
+ });
+ }
+
+ public void setContextClassLoader(final ClassLoader cl)
+ {
+ AccessController.doPrivileged(
+ new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ }
+ );
+ }
+
+ public void setContextClassLoader(final Thread thread, final ClassLoader cl)
+ {
+ AccessController.doPrivileged(
+ new PrivilegedAction()
+ {
+ public Object run()
+ {
+ thread.setContextClassLoader(cl);
+ return null;
+ }
+ }
+ );
+ }
+ };
+
+ ClassLoader getContextClassLoader();
+
+ ClassLoader getContextClassLoader(Thread thread);
+
+ void setContextClassLoader(ClassLoader cl);
+
+ void setContextClassLoader(Thread thread, ClassLoader cl);
+ }
+
+
+
+ static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain)
+ throws PrivilegedActionException
+ {
+ AccessController.doPrivileged(new PrivilegedExceptionAction(){
+
+ public Object run() throws Exception
+ {
+ SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain);
+ SecurityContextAssociation.setSecurityContext(sc);
+ return null;
+ }});
+ }
+
+ static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain,
+ final Subject subject) throws PrivilegedActionException
+ {
+ AccessController.doPrivileged(new PrivilegedExceptionAction(){
+
+ public Object run() throws Exception
+ {
+ SecurityContext sc = SecurityContextFactory.createSecurityContext(domain);
+ sc.getUtil().createSubjectInfo(p, cred, subject);
+ SecurityContextAssociation.setSecurityContext(sc);
+ return null;
+ }});
+ }
+
+ static void clearSecurityContext()
+ {
+ AccessController.doPrivileged(new PrivilegedAction(){
+
+ public Object run()
+ {
+ SecurityContextAssociation.setSecurityContext(null);
+ return null;
+ }});
+ }
+
+ static SecurityContext getSecurityContext()
+ {
+ return (SecurityContext)AccessController.doPrivileged(new PrivilegedAction(){
+ public Object run()
+ {
+ return SecurityContextAssociation.getSecurityContext();
+ }
+ });
+ }
+
+ static Exception getContextException()
+ {
+ return (Exception)AccessController.doPrivileged(new PrivilegedAction()
+ {
+ static final String EX_KEY = "org.jboss.security.exception";
+ public Object run()
+ {
+ SecurityContext sc = getSecurityContext();
+ return sc.getData().get(EX_KEY);
+ }
+ });
+ }
+
+ static void pushSubjectContext(final Principal p, final Object cred, final Subject s)
+ {
+ AccessController.doPrivileged(new PrivilegedAction(){
+
+ public Object run()
+ {
+ SecurityContext sc = getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ sc.getUtil().createSubjectInfo(p, cred, s);
+ return null;
+ }}
+ );
+ }
+
+ static void popSubjectContext()
+ {
+ AccessController.doPrivileged(new PrivilegedAction(){
+
+ public Object run()
+ {
+ SecurityContext sc = getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ Principal p = sc.getUtil().getUserPrincipal();
+ Object cred = sc.getUtil().getCredential();
+ sc.getUtil().createSubjectInfo(p, cred,null);
+ return null;
+ }}
+ );
+ }
+
+ static void pushCallerRunAsIdentity(final RunAs ra)
+ {
+ AccessController.doPrivileged(new PrivilegedAction(){
+ public Object run()
+ {
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ sc.setIncomingRunAs(ra);
+ return null;
+ }
+ });
+ }
+
+ static void popCallerRunAsIdentity()
+ {
+ AccessController.doPrivileged(new PrivilegedAction(){
+ public Object run()
+ {
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ sc.setIncomingRunAs(null);
+ return null;
+ }
+ });
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,148 +1,148 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc2.keygen;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.ejb.EntityEnterpriseContext;
-import org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil;
-import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCFieldBridge;
-import org.jboss.ejb.plugins.cmp.jdbc2.CreateCommand;
-import org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2;
-import org.jboss.ejb.plugins.cmp.jdbc2.PersistentContext;
-import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMPFieldBridge2;
-import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCEntityBridge2;
-import org.jboss.logging.Logger;
-
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.ejb.CreateException;
-import javax.ejb.DuplicateKeyException;
-
-/**
- * Abstract create command
- * @author <a href="mailto:jep at worldleaguesports.com">Jesper Pedersen</a>
- * @version <tt>$Revision: 57209 $</tt>
- */
-public abstract class AbstractCreateCommand
- implements CreateCommand
-{
- protected JDBCEntityBridge2 entityBridge;
- protected Logger log;
- protected JDBCCMPFieldBridge2 pkField;
- protected String pkSql;
-
- public void init(JDBCStoreManager2 manager) throws DeploymentException
- {
- this.entityBridge = (JDBCEntityBridge2)manager.getEntityBridge();
- this.log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName());
-
- final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields();
- if(pkFields.length > 1)
- {
- throw new DeploymentException("This entity-command cannot be used with composite primary keys!");
- }
-
- this.pkField = (JDBCCMPFieldBridge2) pkFields[0];
- this.pkSql = "";
- }
-
- public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException
- {
- Object pk;
- PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
- if(ctx.getId() == null)
- {
- Connection con = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- if(log.isDebugEnabled())
- {
- log.debug("executing sql: " + pkSql);
- }
-
- con = entityBridge.getDataSource().getConnection();
- ps = con.prepareStatement(pkSql);
- rs = ps.executeQuery();
-
- if(!rs.next())
- {
- throw new CreateException("pk-sql " + pkSql + " returned no results!");
- }
-
- pk = pkField.loadArgumentResults(rs, 1);
- pctx.setFieldValue(pkField.getRowIndex(), pk);
- pk = entityBridge.extractPrimaryKeyFromInstance(ctx);
- }
- catch(SQLException e)
- {
- log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e);
- throw new CreateException("Failed to execute pk sql: " + e.getMessage() +
- ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState());
- }
- finally
- {
- JDBCUtil.safeClose(rs);
- JDBCUtil.safeClose(ps);
- JDBCUtil.safeClose(con);
- }
-
- if(pk == null)
- {
- log.error("Primary key for created instance is null.");
- throw new CreateException("Primary key for created instance is null.");
- }
-
- pctx.setPk(pk);
- }
- else
- {
- // insert-after-ejb-post-create
- try
- {
- pctx.flush();
- }
- catch(SQLException e)
- {
- if("23000".equals(e.getSQLState()))
- {
- throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId());
- }
- else
- {
- throw new CreateException("Failed to create instance: pk=" +
- ctx.getId() +
- ", state=" +
- e.getSQLState() +
- ", msg=" + e.getMessage());
- }
- }
- pk = ctx.getId();
- }
- return pk;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc2.keygen;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.ejb.EntityEnterpriseContext;
+import org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil;
+import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCFieldBridge;
+import org.jboss.ejb.plugins.cmp.jdbc2.CreateCommand;
+import org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2;
+import org.jboss.ejb.plugins.cmp.jdbc2.PersistentContext;
+import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMPFieldBridge2;
+import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCEntityBridge2;
+import org.jboss.logging.Logger;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.ejb.CreateException;
+import javax.ejb.DuplicateKeyException;
+
+/**
+ * Abstract create command
+ * @author <a href="mailto:jep at worldleaguesports.com">Jesper Pedersen</a>
+ * @version <tt>$Revision: 57209 $</tt>
+ */
+public abstract class AbstractCreateCommand
+ implements CreateCommand
+{
+ protected JDBCEntityBridge2 entityBridge;
+ protected Logger log;
+ protected JDBCCMPFieldBridge2 pkField;
+ protected String pkSql;
+
+ public void init(JDBCStoreManager2 manager) throws DeploymentException
+ {
+ this.entityBridge = (JDBCEntityBridge2)manager.getEntityBridge();
+ this.log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName());
+
+ final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields();
+ if(pkFields.length > 1)
+ {
+ throw new DeploymentException("This entity-command cannot be used with composite primary keys!");
+ }
+
+ this.pkField = (JDBCCMPFieldBridge2) pkFields[0];
+ this.pkSql = "";
+ }
+
+ public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException
+ {
+ Object pk;
+ PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
+ if(ctx.getId() == null)
+ {
+ Connection con = null;
+ PreparedStatement ps = null;
+ ResultSet rs = null;
+ try
+ {
+ if(log.isDebugEnabled())
+ {
+ log.debug("executing sql: " + pkSql);
+ }
+
+ con = entityBridge.getDataSource().getConnection();
+ ps = con.prepareStatement(pkSql);
+ rs = ps.executeQuery();
+
+ if(!rs.next())
+ {
+ throw new CreateException("pk-sql " + pkSql + " returned no results!");
+ }
+
+ pk = pkField.loadArgumentResults(rs, 1);
+ pctx.setFieldValue(pkField.getRowIndex(), pk);
+ pk = entityBridge.extractPrimaryKeyFromInstance(ctx);
+ }
+ catch(SQLException e)
+ {
+ log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e);
+ throw new CreateException("Failed to execute pk sql: " + e.getMessage() +
+ ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState());
+ }
+ finally
+ {
+ JDBCUtil.safeClose(rs);
+ JDBCUtil.safeClose(ps);
+ JDBCUtil.safeClose(con);
+ }
+
+ if(pk == null)
+ {
+ log.error("Primary key for created instance is null.");
+ throw new CreateException("Primary key for created instance is null.");
+ }
+
+ pctx.setPk(pk);
+ }
+ else
+ {
+ // insert-after-ejb-post-create
+ try
+ {
+ pctx.flush();
+ }
+ catch(SQLException e)
+ {
+ if("23000".equals(e.getSQLState()))
+ {
+ throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId());
+ }
+ else
+ {
+ throw new CreateException("Failed to create instance: pk=" +
+ ctx.getId() +
+ ", state=" +
+ e.getSQLState() +
+ ", msg=" + e.getMessage());
+ }
+ }
+ pk = ctx.getId();
+ }
+ return pk;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,55 +1,55 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc2.keygen;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.ejb.plugins.cmp.jdbc.SQLUtil;
-import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData;
-import org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2;
-
-/**
- * Create command for Hypersonic that generated keys using an IDENTITY column.
- *
- * @author <a href="mailto:jep at worldleaguesports.com">Jesper Pedersen</a>
- * @version $Revision: 57209 $
- */
-public class HsqldbCreateCommand
- extends AbstractCreateCommand
-{
-
- public void init(JDBCStoreManager2 manager) throws DeploymentException
- {
- super.init(manager);
-
- JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand();
- pkSql = metadata.getAttribute("pk-sql");
- if(pkSql == null)
- {
- pkSql = "CALL IDENTITY()";
- }
-
- if(log.isDebugEnabled())
- {
- log.debug("entity-command generate pk sql: " + pkSql);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc2.keygen;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.ejb.plugins.cmp.jdbc.SQLUtil;
+import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData;
+import org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2;
+
+/**
+ * Create command for Hypersonic that generated keys using an IDENTITY column.
+ *
+ * @author <a href="mailto:jep at worldleaguesports.com">Jesper Pedersen</a>
+ * @version $Revision: 57209 $
+ */
+public class HsqldbCreateCommand
+ extends AbstractCreateCommand
+{
+
+ public void init(JDBCStoreManager2 manager) throws DeploymentException
+ {
+ super.init(manager);
+
+ JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand();
+ pkSql = metadata.getAttribute("pk-sql");
+ if(pkSql == null)
+ {
+ pkSql = "CALL IDENTITY()";
+ }
+
+ if(log.isDebugEnabled())
+ {
+ log.debug("entity-command generate pk sql: " + pkSql);
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,57 +1,57 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc2.keygen;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.ejb.plugins.cmp.jdbc.SQLUtil;
-import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData;
-import org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2;
-
-/**
- * PostgreSQL create command
- * @author <a href="mailto:jep at worldleaguesports.com">Jesper Pedersen</a>
- * @version <tt>$Revision: 57209 $</tt>
- */
-public class PostgreSQLCreateCommand
- extends AbstractCreateCommand
-{
-
- public void init(JDBCStoreManager2 manager) throws DeploymentException
- {
- super.init(manager);
-
- JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand();
- String sequence = metadata.getAttribute("sequence");
- if (sequence == null) {
- sequence = entityBridge.getQualifiedTableName()
- + '_' + SQLUtil.getColumnNamesClause(pkField, new StringBuffer(20))
- + "_seq";
- }
-
- pkSql = "SELECT nextval('" + sequence + "')";
-
- if(log.isDebugEnabled())
- {
- log.debug("entity-command generate pk sql: " + pkSql);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.cmp.jdbc2.keygen;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.ejb.plugins.cmp.jdbc.SQLUtil;
+import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData;
+import org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2;
+
+/**
+ * PostgreSQL create command
+ * @author <a href="mailto:jep at worldleaguesports.com">Jesper Pedersen</a>
+ * @version <tt>$Revision: 57209 $</tt>
+ */
+public class PostgreSQLCreateCommand
+ extends AbstractCreateCommand
+{
+
+ public void init(JDBCStoreManager2 manager) throws DeploymentException
+ {
+ super.init(manager);
+
+ JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand();
+ String sequence = metadata.getAttribute("sequence");
+ if (sequence == null) {
+ sequence = entityBridge.getQualifiedTableName()
+ + '_' + SQLUtil.getColumnNamesClause(pkField, new StringBuffer(20))
+ + "_seq";
+ }
+
+ pkSql = "SELECT nextval('" + sequence + "')";
+
+ if(log.isDebugEnabled())
+ {
+ log.debug("entity-command generate pk sql: " + pkSql);
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,170 +1,170 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.security;
-
-import java.lang.reflect.Method;
-
-import javax.ejb.TimedObject;
-import javax.ejb.Timer;
-
-import org.jboss.ejb.Container;
-import org.jboss.ejb.plugins.AbstractInterceptor;
-import org.jboss.invocation.Invocation;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityIdentity;
-
-
-/**
- * Interceptor that performs the initialization required for
- * the security interceptor. This interceptor performs
- * Security Context establishment and other initialization required
- * - The Outgoing run-as from the security context is pushed to incoming run-as
- * - For EJB Local Invocations, the security context is obtained from the
- * SecurityContextAssocation threadlocal and placed on the invocation.
- * @author Anil.Saldhana at redhat.com
- * @since Apr 30, 2007
- * @version $Revision$
- */
-public class PreSecurityInterceptor extends AbstractInterceptor
-{
- private String securityDomain = null;
-
- private String timedObjectMethod = null;
-
- @Override
- public void setContainer(Container container)
- {
- super.setContainer(container);
- if (container != null)
- {
- AuthenticationManager am = container.getSecurityManager();
- if(am != null)
- {
- securityDomain = am.getSecurityDomain();
- }
- }
- try
- {
- timedObjectMethod = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class})
- .getName();
- }
- catch (Exception e)
- {
- log.trace("Exception in creating TimedObject method:",e);
- }
- }
-
- @Override
- public Object invoke(Invocation mi) throws Exception
- {
- boolean isInvoke = true;
- return this.process(mi, isInvoke);
- }
-
- @Override
- public Object invokeHome(Invocation mi) throws Exception
- {
- boolean isInvoke = false;
- return this.process(mi, isInvoke);
- }
-
- private Object process(Invocation mi, boolean isInvoke) throws Exception
- {
- //No Security in the absence of SecurityDomain
- if(securityDomain == null)
- {
- if(isInvoke)
- return getNext().invoke(mi);
- else
- return getNext().invokeHome(mi);
- }
-
- log.trace("process:isInvoke="+isInvoke + " bean="+ container.getServiceName());
- SecurityIdentity si = null;
- Method m = mi.getMethod();
- boolean isEjbTimeOutMethod = m!= null && m.getName().equals(timedObjectMethod);
- //For local ejb invocations
- if(mi.isLocal() && !isEjbTimeOutMethod)
- {
- log.trace("True mi.isLocal() && !isEjbTimeOutMethod");
- //Cache the security context
- SecurityContext sc = SecurityActions.getSecurityContext();
- if(sc != null)
- si = SecurityActions.getSecurityIdentity(sc);
-
- SecurityActions.setSecurityManagement(sc, container.getSecurityManagement());
-
- log.trace("SecurityIdentity="+SecurityActions.trace(si));
- //Set the security context on the invocation
- mi.setSecurityContext(sc);
- }
- else
- {
- log.trace("False mi.isLocal() && !isEjbTimeOutMethod");
- establishSecurityContext(mi);
- }
-
- try
- {
- //Establish the run-as on the SC as the caller SC
- SecurityContext currentSC = SecurityActions.getSecurityContext();
- SecurityActions.pushCallerRunAsIdentity(currentSC.getOutgoingRunAs());
- log.trace("Going to the SecurityInterceptor with SC="+SecurityActions.trace(currentSC));
- if(isInvoke)
- return getNext().invoke(mi);
- else
- return getNext().invokeHome(mi);
- }
- finally
- {
- SecurityActions.popCallerRunAsIdentity();
- if(mi.isLocal() && si != null)
- SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si);
- log.trace("Exit process():isInvoke="+isInvoke);
- }
- }
-
- private void establishSecurityContext(Invocation mi) throws Exception
- {
- //For Local EJB invocations, the security context needs
- //to be obtained from the thread local. For remote ejb
- //invocations, the SC is obtained in the invocation
- SecurityContext sc = mi.getSecurityContext();
- SecurityContext newSC = SecurityActions.createAndSetSecurityContext(securityDomain,
- container.getSecurityContextClassName());
-
- if(sc != null)
- {
- //Get the run-as, principal, cred etc from the invocation and set it on the context
- SecurityActions.setSecurityIdentity(newSC, SecurityActions.getSecurityIdentity(sc));
- }
- else
- {
- //Local EJB Invocation or some one created the Invocation object on the server side
- mi.setSecurityContext(newSC);
- }
- //Set the SecurityManagement on the context
- SecurityActions.setSecurityManagement(newSC, container.getSecurityManagement());
- log.trace("establishSecurityIdentity:SecCtx="+SecurityActions.trace(newSC));
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.security;
+
+import java.lang.reflect.Method;
+
+import javax.ejb.TimedObject;
+import javax.ejb.Timer;
+
+import org.jboss.ejb.Container;
+import org.jboss.ejb.plugins.AbstractInterceptor;
+import org.jboss.invocation.Invocation;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityIdentity;
+
+
+/**
+ * Interceptor that performs the initialization required for
+ * the security interceptor. This interceptor performs
+ * Security Context establishment and other initialization required
+ * - The Outgoing run-as from the security context is pushed to incoming run-as
+ * - For EJB Local Invocations, the security context is obtained from the
+ * SecurityContextAssocation threadlocal and placed on the invocation.
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 30, 2007
+ * @version $Revision$
+ */
+public class PreSecurityInterceptor extends AbstractInterceptor
+{
+ private String securityDomain = null;
+
+ private String timedObjectMethod = null;
+
+ @Override
+ public void setContainer(Container container)
+ {
+ super.setContainer(container);
+ if (container != null)
+ {
+ AuthenticationManager am = container.getSecurityManager();
+ if(am != null)
+ {
+ securityDomain = am.getSecurityDomain();
+ }
+ }
+ try
+ {
+ timedObjectMethod = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class})
+ .getName();
+ }
+ catch (Exception e)
+ {
+ log.trace("Exception in creating TimedObject method:",e);
+ }
+ }
+
+ @Override
+ public Object invoke(Invocation mi) throws Exception
+ {
+ boolean isInvoke = true;
+ return this.process(mi, isInvoke);
+ }
+
+ @Override
+ public Object invokeHome(Invocation mi) throws Exception
+ {
+ boolean isInvoke = false;
+ return this.process(mi, isInvoke);
+ }
+
+ private Object process(Invocation mi, boolean isInvoke) throws Exception
+ {
+ //No Security in the absence of SecurityDomain
+ if(securityDomain == null)
+ {
+ if(isInvoke)
+ return getNext().invoke(mi);
+ else
+ return getNext().invokeHome(mi);
+ }
+
+ log.trace("process:isInvoke="+isInvoke + " bean="+ container.getServiceName());
+ SecurityIdentity si = null;
+ Method m = mi.getMethod();
+ boolean isEjbTimeOutMethod = m!= null && m.getName().equals(timedObjectMethod);
+ //For local ejb invocations
+ if(mi.isLocal() && !isEjbTimeOutMethod)
+ {
+ log.trace("True mi.isLocal() && !isEjbTimeOutMethod");
+ //Cache the security context
+ SecurityContext sc = SecurityActions.getSecurityContext();
+ if(sc != null)
+ si = SecurityActions.getSecurityIdentity(sc);
+
+ SecurityActions.setSecurityManagement(sc, container.getSecurityManagement());
+
+ log.trace("SecurityIdentity="+SecurityActions.trace(si));
+ //Set the security context on the invocation
+ mi.setSecurityContext(sc);
+ }
+ else
+ {
+ log.trace("False mi.isLocal() && !isEjbTimeOutMethod");
+ establishSecurityContext(mi);
+ }
+
+ try
+ {
+ //Establish the run-as on the SC as the caller SC
+ SecurityContext currentSC = SecurityActions.getSecurityContext();
+ SecurityActions.pushCallerRunAsIdentity(currentSC.getOutgoingRunAs());
+ log.trace("Going to the SecurityInterceptor with SC="+SecurityActions.trace(currentSC));
+ if(isInvoke)
+ return getNext().invoke(mi);
+ else
+ return getNext().invokeHome(mi);
+ }
+ finally
+ {
+ SecurityActions.popCallerRunAsIdentity();
+ if(mi.isLocal() && si != null)
+ SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si);
+ log.trace("Exit process():isInvoke="+isInvoke);
+ }
+ }
+
+ private void establishSecurityContext(Invocation mi) throws Exception
+ {
+ //For Local EJB invocations, the security context needs
+ //to be obtained from the thread local. For remote ejb
+ //invocations, the SC is obtained in the invocation
+ SecurityContext sc = mi.getSecurityContext();
+ SecurityContext newSC = SecurityActions.createAndSetSecurityContext(securityDomain,
+ container.getSecurityContextClassName());
+
+ if(sc != null)
+ {
+ //Get the run-as, principal, cred etc from the invocation and set it on the context
+ SecurityActions.setSecurityIdentity(newSC, SecurityActions.getSecurityIdentity(sc));
+ }
+ else
+ {
+ //Local EJB Invocation or some one created the Invocation object on the server side
+ mi.setSecurityContext(newSC);
+ }
+ //Set the SecurityManagement on the context
+ SecurityActions.setSecurityManagement(newSC, container.getSecurityManagement());
+ log.trace("establishSecurityIdentity:SecCtx="+SecurityActions.trace(newSC));
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/plugins/security/SecurityActions.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/security/SecurityActions.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/plugins/security/SecurityActions.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,179 +1,179 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.security;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import org.jboss.security.ISecurityManagement;
-import org.jboss.security.RunAs;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityIdentity;
-import org.jboss.security.SecurityContextFactory;
-import org.jboss.security.SecurityContextAssociation;
-
-/**
- * Privileged Blocks
- * @author Anil.Saldhana at redhat.com
- * @since Apr 30, 2007
- * @version $Revision$
- */
-class SecurityActions
-{
- static SecurityContext createAndSetSecurityContext(final String domain,
- final String fqnClassName) throws PrivilegedActionException
- {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>()
- {
- public SecurityContext run() throws Exception
- {
- SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName);
- setSecurityContext(sc);
- return sc;
- }}
- );
- }
-
- static SecurityContext getSecurityContext()
- {
- return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
- {
- public SecurityContext run()
- {
- return SecurityContextAssociation.getSecurityContext();
- }}
- );
- }
-
- static void pushCallerRunAsIdentity(final RunAs ra)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>(){
- public Object run()
- {
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- sc.setIncomingRunAs(ra);
- return null;
- }
- });
- }
-
-
- static void popCallerRunAsIdentity()
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>(){
- public Object run()
- {
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- throw new IllegalStateException("Security Context is null");
- sc.setIncomingRunAs(null);
- return null;
- }
- });
- }
-
- static void setSecurityContext(final SecurityContext sc)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- SecurityContextAssociation.setSecurityContext(sc);
- return null;
- }}
- );
- }
-
- static void setSecurityIdentity(final SecurityContext sc,
- final SecurityIdentity si)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- sc.getUtil().setSecurityIdentity(si);
- return null;
- }}
- );
- }
-
- static SecurityIdentity getSecurityIdentity(final SecurityContext sc)
- {
- return AccessController.doPrivileged(new PrivilegedAction<SecurityIdentity>()
- {
- public SecurityIdentity run()
- {
- return sc.getUtil().getSecurityIdentity();
- }
- });
- }
-
- static void setSecurityManagement(final SecurityContext sc, final ISecurityManagement sm)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- sc.setSecurityManagement(sm);
- return null;
- }}
- );
- }
-
- static String trace(final SecurityContext sc)
- {
- return AccessController.doPrivileged(new PrivilegedAction<String>()
- {
- public String run()
- {
- StringBuilder sb = new StringBuilder();
- sb.append(" Principal = " + sc.getUtil().getUserPrincipal());
- sb.append(" Subject:"+sc.getUtil().getSubject());
- sb.append(" Incoming run as:"+sc.getIncomingRunAs());
- sb.append(" Outgoing run as:"+sc.getOutgoingRunAs());
- return sb.toString();
- }
- }
- );
- }
-
- static String trace(final SecurityIdentity si)
- {
- return AccessController.doPrivileged(new PrivilegedAction<String>()
- {
- public String run()
- {
- StringBuilder sb = new StringBuilder();
- sb.append(" Principal = " + si.getPrincipal());
- sb.append(" Subject:"+si.getSubject());
- sb.append(" Incoming run as:"+si.getIncomingRunAs());
- sb.append(" Outgoing run as:"+si.getOutgoingRunAs());
- return sb.toString();
- }
- }
- );
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.plugins.security;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.RunAs;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityIdentity;
+import org.jboss.security.SecurityContextFactory;
+import org.jboss.security.SecurityContextAssociation;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 30, 2007
+ * @version $Revision$
+ */
+class SecurityActions
+{
+ static SecurityContext createAndSetSecurityContext(final String domain,
+ final String fqnClassName) throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>()
+ {
+ public SecurityContext run() throws Exception
+ {
+ SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName);
+ setSecurityContext(sc);
+ return sc;
+ }}
+ );
+ }
+
+ static SecurityContext getSecurityContext()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
+ {
+ public SecurityContext run()
+ {
+ return SecurityContextAssociation.getSecurityContext();
+ }}
+ );
+ }
+
+ static void pushCallerRunAsIdentity(final RunAs ra)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>(){
+ public Object run()
+ {
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ sc.setIncomingRunAs(ra);
+ return null;
+ }
+ });
+ }
+
+
+ static void popCallerRunAsIdentity()
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>(){
+ public Object run()
+ {
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc == null)
+ throw new IllegalStateException("Security Context is null");
+ sc.setIncomingRunAs(null);
+ return null;
+ }
+ });
+ }
+
+ static void setSecurityContext(final SecurityContext sc)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ SecurityContextAssociation.setSecurityContext(sc);
+ return null;
+ }}
+ );
+ }
+
+ static void setSecurityIdentity(final SecurityContext sc,
+ final SecurityIdentity si)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ sc.getUtil().setSecurityIdentity(si);
+ return null;
+ }}
+ );
+ }
+
+ static SecurityIdentity getSecurityIdentity(final SecurityContext sc)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<SecurityIdentity>()
+ {
+ public SecurityIdentity run()
+ {
+ return sc.getUtil().getSecurityIdentity();
+ }
+ });
+ }
+
+ static void setSecurityManagement(final SecurityContext sc, final ISecurityManagement sm)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ sc.setSecurityManagement(sm);
+ return null;
+ }}
+ );
+ }
+
+ static String trace(final SecurityContext sc)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" Principal = " + sc.getUtil().getUserPrincipal());
+ sb.append(" Subject:"+sc.getUtil().getSubject());
+ sb.append(" Incoming run as:"+sc.getIncomingRunAs());
+ sb.append(" Outgoing run as:"+sc.getOutgoingRunAs());
+ return sb.toString();
+ }
+ }
+ );
+ }
+
+ static String trace(final SecurityIdentity si)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" Principal = " + si.getPrincipal());
+ sb.append(" Subject:"+si.getSubject());
+ sb.append(" Incoming run as:"+si.getIncomingRunAs());
+ sb.append(" Outgoing run as:"+si.getOutgoingRunAs());
+ return sb.toString();
+ }
+ }
+ );
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/plugins/security/SecurityActions.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePluginExt.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePluginExt.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePluginExt.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,44 +1,44 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb.txtimer;
-
-// $Id: DatabasePersistencePlugin.java 57209 2006-09-26 12:21:57Z dimitris at jboss.org $
-
-import java.sql.SQLException;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-/**
- * An extension of DatabasePersistencePlugin that allows setting of the
- * timers table name during initialization.
- *
- * @author Dimitris.Andreadis at jboss.org
- * @version $Revision: 57209 $
- */
-public interface DatabasePersistencePluginExt extends DatabasePersistencePlugin
-{
- /**
- * Initialize the plugin and set also the timers tablename
- */
- void init(MBeanServer server, ObjectName dataSource, String tableName) throws SQLException;
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb.txtimer;
+
+// $Id: DatabasePersistencePlugin.java 57209 2006-09-26 12:21:57Z dimitris at jboss.org $
+
+import java.sql.SQLException;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * An extension of DatabasePersistencePlugin that allows setting of the
+ * timers table name during initialization.
+ *
+ * @author Dimitris.Andreadis at jboss.org
+ * @version $Revision: 57209 $
+ */
+public interface DatabasePersistencePluginExt extends DatabasePersistencePlugin
+{
+ /**
+ * Initialize the plugin and set also the timers tablename
+ */
+ void init(MBeanServer server, ObjectName dataSource, String tableName) throws SQLException;
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePluginExt.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java
===================================================================
--- trunk/server/src/main/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,88 +1,88 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker;
-
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.jboss.logging.Logger;
-import org.jboss.security.SimplePrincipal;
-
-//$Id: ExternalizableRolesAuthorization.java 44771 2006-05-10 20:35:14Z asaldhana $
-
-/**
- * JBAS-3203: Delegate for Authorization Interceptor for RMIAdaptor should have roles configurable
- * Authorization Delegate used by the AuthorizationInterceptor
- * that gets its predefined roles from a properties file
- * @see org.jboss.jmx.connector.invoker.AuthorizationInterceptor
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @since May 10, 2006
- * @version $Revision: 44771 $
- */
-public class ExternalizableRolesAuthorization extends RolesAuthorization
-{
- private static Logger log = Logger.getLogger(ExternalizableRolesAuthorization.class);
- private boolean trace = log.isTraceEnabled();
-
- public ExternalizableRolesAuthorization()
- {
- //Load the roles from a properties file
- Properties props = new Properties();
- try
- {
- props.load(getTCL().getResourceAsStream("jmxinvoker-roles.properties"));
- this.setRequiredRoles(getSetOfRoles(props.getProperty("roles")));
- }
- catch (Exception e)
- {
- log.error("Error reading roles from jmxinvoker-roles.properties:",e);
- }
- }
-
- /**
- * Get a HashSet of roles as SimplePrincipal
- *
- * @param assignedRoles a comma seperated list of roles
- * @return
- */
- private HashSet getSetOfRoles(String assignedRoles)
- {
- if(trace)
- log.trace("AssignedRolesString="+assignedRoles);
- HashSet set = new HashSet();
- StringTokenizer st = new StringTokenizer(assignedRoles,",");
- while(st.hasMoreTokens())
- {
- String aRole = st.nextToken();
- set.add(new SimplePrincipal(aRole));
- }
- if(trace)
- log.trace("roles set="+set);
- return set;
- }
-
- private ClassLoader getTCL()
- {
- return Thread.currentThread().getContextClassLoader();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.SimplePrincipal;
+
+//$Id: ExternalizableRolesAuthorization.java 44771 2006-05-10 20:35:14Z asaldhana $
+
+/**
+ * JBAS-3203: Delegate for Authorization Interceptor for RMIAdaptor should have roles configurable
+ * Authorization Delegate used by the AuthorizationInterceptor
+ * that gets its predefined roles from a properties file
+ * @see org.jboss.jmx.connector.invoker.AuthorizationInterceptor
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since May 10, 2006
+ * @version $Revision: 44771 $
+ */
+public class ExternalizableRolesAuthorization extends RolesAuthorization
+{
+ private static Logger log = Logger.getLogger(ExternalizableRolesAuthorization.class);
+ private boolean trace = log.isTraceEnabled();
+
+ public ExternalizableRolesAuthorization()
+ {
+ //Load the roles from a properties file
+ Properties props = new Properties();
+ try
+ {
+ props.load(getTCL().getResourceAsStream("jmxinvoker-roles.properties"));
+ this.setRequiredRoles(getSetOfRoles(props.getProperty("roles")));
+ }
+ catch (Exception e)
+ {
+ log.error("Error reading roles from jmxinvoker-roles.properties:",e);
+ }
+ }
+
+ /**
+ * Get a HashSet of roles as SimplePrincipal
+ *
+ * @param assignedRoles a comma seperated list of roles
+ * @return
+ */
+ private HashSet getSetOfRoles(String assignedRoles)
+ {
+ if(trace)
+ log.trace("AssignedRolesString="+assignedRoles);
+ HashSet set = new HashSet();
+ StringTokenizer st = new StringTokenizer(assignedRoles,",");
+ while(st.hasMoreTokens())
+ {
+ String aRole = st.nextToken();
+ set.add(new SimplePrincipal(aRole));
+ }
+ if(trace)
+ log.trace("roles set="+set);
+ return set;
+ }
+
+ private ClassLoader getTCL()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializableInterceptor.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializableInterceptor.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,100 +1,100 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker;
-
-import org.jboss.invocation.MarshalledInvocation;
-import org.jboss.mx.interceptor.AbstractInterceptor;
-import org.jboss.mx.server.Invocation;
-
-/**
- * An interceptor that validates the Serializability of responses,
- * using plugable policies.
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @author <a href="mailto:fabcipriano at yahoo.com.br">Fabiano C. de Oliveira</a>
- * @version $Revision: 57209 $
- */
-public class SerializableInterceptor extends AbstractInterceptor
-{
- /** The plugable policy to use */
- private SerializablePolicy policy = new NoopPolicy();
-
- /**
- * Configure a SerializablePolicy class
- */
- public void setPolicyClass(String policyClass) throws Exception
- {
- try
- {
- // try to load the policy Class
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass);
- policy = (SerializablePolicy)clazz.newInstance();
- }
- catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException
- {
- // policy class not found. Make a second try using
- // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix
- // for the "standard" reponse policies provided with jboss.
- // If that fails, too, rethrow the original exception.
- try
- {
- policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass;
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass);
- policy = (SerializablePolicy)clazz.newInstance();
- }
- catch (Exception inner)
- {
- throw e;
- }
- }
- }
-
- public Object invoke(Invocation invocation) throws Throwable
- {
- // Invoke the next in the sequence
- Object result = invocation.nextInterceptor().invoke(invocation);
-
- // If the invocation was an 'invoke(MarshalledInvocation)'
- // filter the result using the plugable policy
- if ("invoke".equals(invocation.getName()))
- {
- Object[] args = invocation.getArgs();
- if ((args.length == 1) && (args[0] instanceof MarshalledInvocation))
- {
- MarshalledInvocation mi = (MarshalledInvocation) args[0];
- result = policy.filter(mi, result);
- }
- }
- return result;
- }
-
- /**
- * A noop serializable policy
- */
- public class NoopPolicy implements SerializablePolicy
- {
- public Object filter(MarshalledInvocation input, Object result) throws Throwable
- {
- return result;
- }
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker;
+
+import org.jboss.invocation.MarshalledInvocation;
+import org.jboss.mx.interceptor.AbstractInterceptor;
+import org.jboss.mx.server.Invocation;
+
+/**
+ * An interceptor that validates the Serializability of responses,
+ * using plugable policies.
+ *
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="mailto:fabcipriano at yahoo.com.br">Fabiano C. de Oliveira</a>
+ * @version $Revision: 57209 $
+ */
+public class SerializableInterceptor extends AbstractInterceptor
+{
+ /** The plugable policy to use */
+ private SerializablePolicy policy = new NoopPolicy();
+
+ /**
+ * Configure a SerializablePolicy class
+ */
+ public void setPolicyClass(String policyClass) throws Exception
+ {
+ try
+ {
+ // try to load the policy Class
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass);
+ policy = (SerializablePolicy)clazz.newInstance();
+ }
+ catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException
+ {
+ // policy class not found. Make a second try using
+ // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix
+ // for the "standard" reponse policies provided with jboss.
+ // If that fails, too, rethrow the original exception.
+ try
+ {
+ policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass;
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass);
+ policy = (SerializablePolicy)clazz.newInstance();
+ }
+ catch (Exception inner)
+ {
+ throw e;
+ }
+ }
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ // Invoke the next in the sequence
+ Object result = invocation.nextInterceptor().invoke(invocation);
+
+ // If the invocation was an 'invoke(MarshalledInvocation)'
+ // filter the result using the plugable policy
+ if ("invoke".equals(invocation.getName()))
+ {
+ Object[] args = invocation.getArgs();
+ if ((args.length == 1) && (args[0] instanceof MarshalledInvocation))
+ {
+ MarshalledInvocation mi = (MarshalledInvocation) args[0];
+ result = policy.filter(mi, result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * A noop serializable policy
+ */
+ public class NoopPolicy implements SerializablePolicy
+ {
+ public Object filter(MarshalledInvocation input, Object result) throws Throwable
+ {
+ return result;
+ }
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializablePolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializablePolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializablePolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,36 +1,36 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker;
-
-import org.jboss.invocation.MarshalledInvocation;
-
-/**
- * A serializable policy that filters results to avoid Serialization problems.
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @author <a href="mailto:fabcipriano at yahoo.com.br">Fabiano C. de Oliveira</a>
- * @version $Revision: 57209 $
- */
-public interface SerializablePolicy
-{
- public Object filter(MarshalledInvocation input, Object result) throws Throwable;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker;
+
+import org.jboss.invocation.MarshalledInvocation;
+
+/**
+ * A serializable policy that filters results to avoid Serialization problems.
+ *
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="mailto:fabcipriano at yahoo.com.br">Fabiano C. de Oliveira</a>
+ * @version $Revision: 57209 $
+ */
+public interface SerializablePolicy
+{
+ public Object filter(MarshalledInvocation input, Object result) throws Throwable;
+}
Property changes on: trunk/server/src/main/org/jboss/jmx/connector/invoker/SerializablePolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/jmx/connector/invoker/serializablepolicy/StripModelMBeanInfoPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/jmx/connector/invoker/serializablepolicy/StripModelMBeanInfoPolicy.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/jmx/connector/invoker/serializablepolicy/StripModelMBeanInfoPolicy.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,73 +1,73 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker.serializablepolicy;
-
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.modelmbean.ModelMBeanInfo;
-
-import org.jboss.invocation.MarshalledInvocation;
-import org.jboss.jmx.connector.invoker.SerializablePolicy;
-
-/**
- * A policy that converts ModelMBeanInfo to MBeanInfo.
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @author <a href="mailto:fabcipriano at yahoo.com.br">Fabiano C. de Oliveira</a>
- * @version $Revision: 57209 $
- */
-public class StripModelMBeanInfoPolicy implements SerializablePolicy
-{
- public Object filter(MarshalledInvocation input, Object result) throws Throwable
- {
- if ("getMBeanInfo".equals(input.getMethod().getName()) && (result instanceof ModelMBeanInfo))
- {
- MBeanInfo info = (MBeanInfo)result;
-
- result = new MBeanInfo(
- info.getClassName(),
- info.getDescription(),
- deepCopy(info.getAttributes()), // Strip the Descriptors
- info.getConstructors(),
- info.getOperations(),
- info.getNotifications());
- }
- return result;
- }
-
- private MBeanAttributeInfo[] deepCopy(MBeanAttributeInfo[] attrs)
- {
- MBeanAttributeInfo[] copy = new MBeanAttributeInfo[attrs.length];
- for (int i = 0; i < attrs.length; i++)
- {
- MBeanAttributeInfo attr = attrs[i];
- copy[i] = new MBeanAttributeInfo(
- attr.getName(),
- attr.getType(),
- attr.getDescription(),
- attr.isReadable(),
- attr.isWritable(),
- attr.isIs());
- }
- return copy;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jmx.connector.invoker.serializablepolicy;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.modelmbean.ModelMBeanInfo;
+
+import org.jboss.invocation.MarshalledInvocation;
+import org.jboss.jmx.connector.invoker.SerializablePolicy;
+
+/**
+ * A policy that converts ModelMBeanInfo to MBeanInfo.
+ *
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="mailto:fabcipriano at yahoo.com.br">Fabiano C. de Oliveira</a>
+ * @version $Revision: 57209 $
+ */
+public class StripModelMBeanInfoPolicy implements SerializablePolicy
+{
+ public Object filter(MarshalledInvocation input, Object result) throws Throwable
+ {
+ if ("getMBeanInfo".equals(input.getMethod().getName()) && (result instanceof ModelMBeanInfo))
+ {
+ MBeanInfo info = (MBeanInfo)result;
+
+ result = new MBeanInfo(
+ info.getClassName(),
+ info.getDescription(),
+ deepCopy(info.getAttributes()), // Strip the Descriptors
+ info.getConstructors(),
+ info.getOperations(),
+ info.getNotifications());
+ }
+ return result;
+ }
+
+ private MBeanAttributeInfo[] deepCopy(MBeanAttributeInfo[] attrs)
+ {
+ MBeanAttributeInfo[] copy = new MBeanAttributeInfo[attrs.length];
+ for (int i = 0; i < attrs.length; i++)
+ {
+ MBeanAttributeInfo attr = attrs[i];
+ copy[i] = new MBeanAttributeInfo(
+ attr.getName(),
+ attr.getType(),
+ attr.getDescription(),
+ attr.isReadable(),
+ attr.isWritable(),
+ attr.isIs());
+ }
+ return copy;
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/jmx/connector/invoker/serializablepolicy/StripModelMBeanInfoPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/naming/JndiBinder.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/JndiBinder.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/naming/JndiBinder.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,107 +1,107 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.naming;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Hashtable;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 56518 $
- */
-public class JndiBinder
-{
- private String bindTo;
- private Object target;
- private boolean serializable;
- private Hashtable properties;
-
- public void setBindTo(String bindTo)
- {
- this.bindTo = bindTo;
- }
-
- public void setTarget(Object target)
- {
- this.target = target;
- }
-
- public void setSerializable(boolean serializable)
- {
- this.serializable = serializable;
- }
-
- public void setJndiProperties(Hashtable properties)
- {
- this.properties = properties;
- }
-
- public void start() throws Exception
- {
- InitialContext ctx1 = null;
- if (properties != null)
- {
- ctx1 = new InitialContext(properties);
- }
- else ctx1 = new InitialContext();
- InitialContext ctx = ctx1;
-
- try
- {
- if (serializable)
- {
- Util.rebind(ctx, bindTo, target);
- }
- else
- {
- NonSerializableFactory.rebind(ctx, bindTo, target);
- }
- } catch (NamingException e)
- {
- NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo);
- namingException.setRootCause(e);
- throw namingException;
- }
- }
-
- public void stop() throws Exception
- {
- InitialContext ctx1 = null;
- if (properties != null)
- {
- ctx1 = new InitialContext(properties);
- }
- else ctx1 = new InitialContext();
- InitialContext ctx = ctx1;
- if (serializable)
- {
- Util.unbind(ctx, bindTo);
- }
- else
- {
- NonSerializableFactory.unbind(bindTo);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.naming;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Hashtable;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 56518 $
+ */
+public class JndiBinder
+{
+ private String bindTo;
+ private Object target;
+ private boolean serializable;
+ private Hashtable properties;
+
+ public void setBindTo(String bindTo)
+ {
+ this.bindTo = bindTo;
+ }
+
+ public void setTarget(Object target)
+ {
+ this.target = target;
+ }
+
+ public void setSerializable(boolean serializable)
+ {
+ this.serializable = serializable;
+ }
+
+ public void setJndiProperties(Hashtable properties)
+ {
+ this.properties = properties;
+ }
+
+ public void start() throws Exception
+ {
+ InitialContext ctx1 = null;
+ if (properties != null)
+ {
+ ctx1 = new InitialContext(properties);
+ }
+ else ctx1 = new InitialContext();
+ InitialContext ctx = ctx1;
+
+ try
+ {
+ if (serializable)
+ {
+ Util.rebind(ctx, bindTo, target);
+ }
+ else
+ {
+ NonSerializableFactory.rebind(ctx, bindTo, target);
+ }
+ } catch (NamingException e)
+ {
+ NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo);
+ namingException.setRootCause(e);
+ throw namingException;
+ }
+ }
+
+ public void stop() throws Exception
+ {
+ InitialContext ctx1 = null;
+ if (properties != null)
+ {
+ ctx1 = new InitialContext(properties);
+ }
+ else ctx1 = new InitialContext();
+ InitialContext ctx = ctx1;
+ if (serializable)
+ {
+ Util.unbind(ctx, bindTo);
+ }
+ else
+ {
+ NonSerializableFactory.unbind(bindTo);
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/naming/JndiBinder.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/proxy/SecurityActions.java
===================================================================
--- trunk/server/src/main/org/jboss/proxy/SecurityActions.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/proxy/SecurityActions.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,262 +1,262 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.proxy;
-
-import java.security.AccessController;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import org.jboss.security.RunAs;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextFactory;
-import org.jboss.security.SecurityContextAssociation;
-
-
-/**
- * Interface defining the Privileged Blocks
- * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
- * @since Mar 5, 2007
- * @version $Revision$
- */
-interface SecurityActions
-{
- class UTIL
- {
- static SecurityActions getSecurityActions()
- {
- return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
- }
- }
-
- SecurityActions NON_PRIVILEGED = new SecurityActions()
- {
- public Principal getPrincipal()
- {
- Principal p = null;
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc != null)
- {
- p = sc.getUtil().getUserPrincipal();
- }
- if(p == null && SecurityContextAssociation.isClient())
- p = SecurityAssociation.getPrincipal();
- return p;
- }
-
- public Object getCredential()
- {
- //return SecurityAssociation.getCredential();
- Object cred = null;
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc != null)
- {
- cred = sc.getUtil().getCredential();
- }
- if(cred == null && SecurityContextAssociation.isClient())
- cred = SecurityAssociation.getCredential();
- return cred;
- }
-
- public RunAs getCallerRunAsIdentity()
- {
- RunAs rai = null;
- //Pluck the run-as identity from the existing SC if any
- SecurityContext existingSC = getSecurityContext();
- if(existingSC != null)
- {
- rai = existingSC.getOutgoingRunAs();
- }
- return rai;
- }
-
- public SecurityContext getSecurityContext()
- {
- return SecurityContextAssociation.getSecurityContext();
- }
-
- public void setSecurityContext(SecurityContext sc)
- {
- SecurityContextAssociation.setSecurityContext(sc);
- }
-
- public SecurityContext createSecurityContext(Principal p, Object cred,
- String sdomain) throws Exception
- {
- return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain);
- }
-
- public void setIncomingRunAs(SecurityContext sc, RunAs incomingRunAs)
- {
- sc.setOutgoingRunAs(incomingRunAs);
- }
-
- public void setOutgoingRunAs(SecurityContext sc, RunAs outgoingRunAs)
- {
- sc.setOutgoingRunAs(outgoingRunAs);
- }
- };
-
- SecurityActions PRIVILEGED = new SecurityActions()
- {
- private final PrivilegedAction getPrincipalAction = new PrivilegedAction()
- {
- public Object run()
- {
- //return SecurityAssociation.getPrincipal();
- Principal p = null;
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc != null)
- {
- p = sc.getUtil().getUserPrincipal();
- }
- return p;
- }
- };
-
- private final PrivilegedAction getCredentialAction = new PrivilegedAction()
- {
- public Object run()
- {
- //return SecurityAssociation.getCredential();
- Object cred = null;
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc != null)
- {
- cred = sc.getUtil().getCredential();
- }
- return cred;
- }
- };
-
- private final PrivilegedAction getSecurityContextAction = new PrivilegedAction()
- {
- public Object run()
- {
- return SecurityContextAssociation.getSecurityContext();
- }
- };
-
- public Principal getPrincipal()
- {
- return (Principal)AccessController.doPrivileged(getPrincipalAction);
- }
-
- public Object getCredential()
- {
- return AccessController.doPrivileged(getCredentialAction);
- }
-
- public RunAs getCallerRunAsIdentity()
- {
- return (RunAs)AccessController.doPrivileged(new PrivilegedAction(){
-
- public Object run()
- {
- RunAs rai = null;
- //Pluck the run-as identity from the existing SC if any
- SecurityContext existingSC = getSecurityContext();
- if(existingSC != null)
- {
- rai = existingSC.getOutgoingRunAs();
- }
- return rai;
- }});
-
- }
-
- public SecurityContext getSecurityContext()
- {
- return (SecurityContext) AccessController.doPrivileged(getSecurityContextAction);
- }
-
- public void setSecurityContext(final SecurityContext sc)
- {
- AccessController.doPrivileged(new PrivilegedAction(){
-
- public Object run()
- {
- SecurityContextAssociation.setSecurityContext(sc);
- return null;
- }});
- }
-
- public SecurityContext createSecurityContext(final Principal p, final Object cred,
- final String sdomain) throws PrivilegedActionException
- {
- return (SecurityContext) AccessController.doPrivileged(new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain);
- }
-
- });
- }
-
- public void setIncomingRunAs(final SecurityContext sc, final RunAs incomingRunAs)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>(){
-
- public Object run()
- {
- sc.setIncomingRunAs(incomingRunAs);
- return null;
- }
- });
-
-
- }
-
- public void setOutgoingRunAs(final SecurityContext sc, final RunAs outgoingRunAs)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>(){
-
- public Object run()
- {
- sc.setOutgoingRunAs(outgoingRunAs);
- return null;
- }
- });
-
- }
- };
-
- Principal getPrincipal();
-
- Object getCredential();
-
- RunAs getCallerRunAsIdentity();
-
- SecurityContext createSecurityContext( Principal p, Object cred,
- String sdomain) throws Exception;
-
- SecurityContext getSecurityContext();
-
- void setSecurityContext(SecurityContext sc);
-
- public void setIncomingRunAs(SecurityContext sc, RunAs incomingRunAs);
-
- void setOutgoingRunAs(SecurityContext sc, RunAs outgoingRunAs);
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.proxy;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.security.RunAs;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextFactory;
+import org.jboss.security.SecurityContextAssociation;
+
+
+/**
+ * Interface defining the Privileged Blocks
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Mar 5, 2007
+ * @version $Revision$
+ */
+interface SecurityActions
+{
+ class UTIL
+ {
+ static SecurityActions getSecurityActions()
+ {
+ return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
+ }
+ }
+
+ SecurityActions NON_PRIVILEGED = new SecurityActions()
+ {
+ public Principal getPrincipal()
+ {
+ Principal p = null;
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc != null)
+ {
+ p = sc.getUtil().getUserPrincipal();
+ }
+ if(p == null && SecurityContextAssociation.isClient())
+ p = SecurityAssociation.getPrincipal();
+ return p;
+ }
+
+ public Object getCredential()
+ {
+ //return SecurityAssociation.getCredential();
+ Object cred = null;
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc != null)
+ {
+ cred = sc.getUtil().getCredential();
+ }
+ if(cred == null && SecurityContextAssociation.isClient())
+ cred = SecurityAssociation.getCredential();
+ return cred;
+ }
+
+ public RunAs getCallerRunAsIdentity()
+ {
+ RunAs rai = null;
+ //Pluck the run-as identity from the existing SC if any
+ SecurityContext existingSC = getSecurityContext();
+ if(existingSC != null)
+ {
+ rai = existingSC.getOutgoingRunAs();
+ }
+ return rai;
+ }
+
+ public SecurityContext getSecurityContext()
+ {
+ return SecurityContextAssociation.getSecurityContext();
+ }
+
+ public void setSecurityContext(SecurityContext sc)
+ {
+ SecurityContextAssociation.setSecurityContext(sc);
+ }
+
+ public SecurityContext createSecurityContext(Principal p, Object cred,
+ String sdomain) throws Exception
+ {
+ return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain);
+ }
+
+ public void setIncomingRunAs(SecurityContext sc, RunAs incomingRunAs)
+ {
+ sc.setOutgoingRunAs(incomingRunAs);
+ }
+
+ public void setOutgoingRunAs(SecurityContext sc, RunAs outgoingRunAs)
+ {
+ sc.setOutgoingRunAs(outgoingRunAs);
+ }
+ };
+
+ SecurityActions PRIVILEGED = new SecurityActions()
+ {
+ private final PrivilegedAction getPrincipalAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ //return SecurityAssociation.getPrincipal();
+ Principal p = null;
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc != null)
+ {
+ p = sc.getUtil().getUserPrincipal();
+ }
+ return p;
+ }
+ };
+
+ private final PrivilegedAction getCredentialAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ //return SecurityAssociation.getCredential();
+ Object cred = null;
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if(sc != null)
+ {
+ cred = sc.getUtil().getCredential();
+ }
+ return cred;
+ }
+ };
+
+ private final PrivilegedAction getSecurityContextAction = new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return SecurityContextAssociation.getSecurityContext();
+ }
+ };
+
+ public Principal getPrincipal()
+ {
+ return (Principal)AccessController.doPrivileged(getPrincipalAction);
+ }
+
+ public Object getCredential()
+ {
+ return AccessController.doPrivileged(getCredentialAction);
+ }
+
+ public RunAs getCallerRunAsIdentity()
+ {
+ return (RunAs)AccessController.doPrivileged(new PrivilegedAction(){
+
+ public Object run()
+ {
+ RunAs rai = null;
+ //Pluck the run-as identity from the existing SC if any
+ SecurityContext existingSC = getSecurityContext();
+ if(existingSC != null)
+ {
+ rai = existingSC.getOutgoingRunAs();
+ }
+ return rai;
+ }});
+
+ }
+
+ public SecurityContext getSecurityContext()
+ {
+ return (SecurityContext) AccessController.doPrivileged(getSecurityContextAction);
+ }
+
+ public void setSecurityContext(final SecurityContext sc)
+ {
+ AccessController.doPrivileged(new PrivilegedAction(){
+
+ public Object run()
+ {
+ SecurityContextAssociation.setSecurityContext(sc);
+ return null;
+ }});
+ }
+
+ public SecurityContext createSecurityContext(final Principal p, final Object cred,
+ final String sdomain) throws PrivilegedActionException
+ {
+ return (SecurityContext) AccessController.doPrivileged(new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain);
+ }
+
+ });
+ }
+
+ public void setIncomingRunAs(final SecurityContext sc, final RunAs incomingRunAs)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>(){
+
+ public Object run()
+ {
+ sc.setIncomingRunAs(incomingRunAs);
+ return null;
+ }
+ });
+
+
+ }
+
+ public void setOutgoingRunAs(final SecurityContext sc, final RunAs outgoingRunAs)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>(){
+
+ public Object run()
+ {
+ sc.setOutgoingRunAs(outgoingRunAs);
+ return null;
+ }
+ });
+
+ }
+ };
+
+ Principal getPrincipal();
+
+ Object getCredential();
+
+ RunAs getCallerRunAsIdentity();
+
+ SecurityContext createSecurityContext( Principal p, Object cred,
+ String sdomain) throws Exception;
+
+ SecurityContext getSecurityContext();
+
+ void setSecurityContext(SecurityContext sc);
+
+ public void setIncomingRunAs(SecurityContext sc, RunAs incomingRunAs);
+
+ void setOutgoingRunAs(SecurityContext sc, RunAs outgoingRunAs);
+}
Property changes on: trunk/server/src/main/org/jboss/proxy/SecurityActions.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/verifier/event/EventGeneratorSupport.java
===================================================================
--- trunk/server/src/main/org/jboss/verifier/event/EventGeneratorSupport.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/verifier/event/EventGeneratorSupport.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,278 +1,278 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.gjt.lindfors.util; Taken from Juha Lindfors implementation as stated in
-package org.jboss.verifier.event;
-
-/*
- * Class org.jboss.verifier.event.EventGeneratorSupport (refer Class org.gjt.lindfors.util.EventGeneratorSupport at gjt.org)
- * Copyright (C) 1999 Juha Lindfors
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * This package and its source code is available at www.gjt.org
- * $Id: EventGeneratorSupport.java,v 1.4 2007/12/06 11:31:15 csaldanh at redhat.com Exp $
- *
- * You can reach the author by sending email to jpl at gjt.org or
- * directly to jplindfo at helsinki.fi.
- */
-
-// standard imports
-import java.util.*;
-import java.awt.*;
-import java.io.*;
-
-// dependencies to non-standard packages and classes
-
-
-
-/**
- * Support class for objects implementing the
- * {@link org.gjt.lindfors.util.EventGenerator EventGenerator} interface.
- * Contains implementations for addListener, removeListener, and hasListeners.
- *
- * <p>
- *
- * Every effort has been made to try to achieve thread-safety in
- * EventGeneratorSupport class. Of course, this doesn't mean
- * nasty race conditions and dead locks don't exist. I'm just
- * not aware of them :)
- *
- * <p>
- *
- * For more detailed documentation, refer to the
- * <a href="http://www.gjt.org/%7ejpl/org_gjt_lindfors_util/index.html">
- *
- * Util Library Tutorial
- *
- * </a> and
- *
- * <a href="http://www.gjt.org/%7ejpl/org_gjt_lindfors_util/specs/index.html">
- *
- * Util Library Specifications
- *
- * </a>. See Also:
- *
- * <a href="http://www.artima.com/designtechniques/index.html">
- *
- * The Event Generator Idiom
- *
- * </a> by Bill Venners.
- *
- *
- * @see org.gjt.lindfors.util.EventGenerator
- *
- * @author Juha Lindfors
- * @version $Revision: 1.4 $
- * @since JDK1.1
- */
-public abstract class EventGeneratorSupport implements Serializable, Cloneable{
-
- /*
- * [TODO] Implement different algorithms for listener notification. Use the
- * one implemented in this class as default, and implement high
- * performance notifications. Use strategy pattern to allow any
- * number of algorithms to be added.
- *
- * [TODO] write performance tests to compare the implementations
- *
- * [TODO] Could use Doug Lea's latch implementation here. Prettier than
- * using a mutex :P
- *
- * [TODO] The use of this class could be used as an example of bridge.
- * Also, the concrete implementations usually act as adapters (not
- * allowing just any listener to be added, but a specific type).
- * Can subclassing be used as an adapter pattern?
- */
-
- /**
- * Vector for storing the registered listeners. Vector will use lazy
- * instantiation and will be constructed only upon request. To ensure
- * proper behaviour in a multi-threaded environment, use the private
- * getListInstance method any time you need a reference to this vector.
- */
- private transient Vector list = null;
-
- /**
- * Clone of listener list. This clone is used as a snapshot of the listener
- * list. The clone is updated every time a listener is either registered
- * or unregistered. This way we can avoid cloning the listener list for
- * the getListeners method call which is usually called by the event
- * firing methods. Since we don't have to clone the listener list for every
- * event notification, we gain a significantly better performance.
- */
- private transient Vector clone = null;
-
- /**
- * Mutex lock for instantiating the listener collection.
- */
- private transient final boolean[] MUTEX = new boolean[0];
-
-
- /**
- * Always use this method to get a reference to listener collection.
- * This guarantees thread safety.
- */
- private Vector getListInstance() {
- synchronized (MUTEX) {
- if (list == null) {
- list = new Vector();
- clone = (Vector)list.clone();
- }
- }
- return list;
- }
-
- /**
- * Constructs support object.
- */
- public EventGeneratorSupport() {}
-
-
- /**
- * Checks if any registered listeners exist.
- *
- * @return true if one or more listeners exist, false otherwise
- */
- public boolean hasListeners() {
- if (list == null) // lazy list, not instantiated
- return false;
-
- if (list.size() == 0) // instantiated but empty
- return false;
-
- return true;
- }
-
-
- /**
- * Returns the listeners registered to this object.
- *
- * @return enumeration of registered listener objects
- */
- protected Enumeration getListeners() {
- if (list == null)
- return new Enumeration() {
-
- public boolean hasMoreElements() {
- return false;
- }
-
- public Object nextElement() {
- return null;
- }
- };
-
- Vector v = (Vector)list.clone();
- return v.elements();
- }
-
- /**
- * Registers a new listener to this object. Duplicate listeners are
- * discarded.
- *
- * <p>
- *
- * This method is marked as protected and is supposed to be used only by
- * the concrete implementations of generator support classes. The concrete
- * subclasses must ensure only the correct type of listeners are allowed
- * to register, as this method allows any listener to be added, therefore
- * not being type safe.
- *
- * @param listener the listener object
- */
- protected void addListener(EventListener listener) {
- synchronized (MUTEX) {
- Vector v = getListInstance();
- if (!v.contains(listener))
- v.addElement(listener);
- }
- }
-
- /**
- * Unregisters a listener from this object. It is safe to attempt to
- * unregister non-existant listeners.
- *
- * @param listener the listener object
- */
- protected void removeListener(EventListener listener) {
- if (list != null) {
- list.removeElement(listener);
- }
- }
-
- /**
- * Returns a string representation of this EventGeneratorSupport object.
- *
- * <p>
- *
- * The output will be similar to the following form:<br>
- * <pre>
- * EventGeneratorSupport[Registered Listeners=1]
- * </pre>
- */
- public String toString() {
- int count;
-
- // don't want to instantiate listener just to tell it has zero elements
- if (list == null)
- count = 0;
- else count = getListInstance().size();
-
- return Library.getClassName(this) + "[Registered Listeners=" + count + "]";
- }
-
- /**
- * [PENDING]
- */
- public Component toComponent() {
- // [FIXME] this exception class has disappeared!
- //throw new UnsupportedOperationException("not implemented yet.");
- return null;
- }
-
- /**
- * [PENDING]
- */
- public Object clone() {
- // [FIXME] this exception class has disappeared!
- //throw new UnsupportedOperationException("not implemented yet.");
- return null;
- }
-
-}
-
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.gjt.lindfors.util; Taken from Juha Lindfors implementation as stated in
+package org.jboss.verifier.event;
+
+/*
+ * Class org.jboss.verifier.event.EventGeneratorSupport (refer Class org.gjt.lindfors.util.EventGeneratorSupport at gjt.org)
+ * Copyright (C) 1999 Juha Lindfors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * This package and its source code is available at www.gjt.org
+ * $Id: EventGeneratorSupport.java,v 1.4 2007/12/06 11:31:15 csaldanh at redhat.com Exp $
+ *
+ * You can reach the author by sending email to jpl at gjt.org or
+ * directly to jplindfo at helsinki.fi.
+ */
+
+// standard imports
+import java.util.*;
+import java.awt.*;
+import java.io.*;
+
+// dependencies to non-standard packages and classes
+
+
+
+/**
+ * Support class for objects implementing the
+ * {@link org.gjt.lindfors.util.EventGenerator EventGenerator} interface.
+ * Contains implementations for addListener, removeListener, and hasListeners.
+ *
+ * <p>
+ *
+ * Every effort has been made to try to achieve thread-safety in
+ * EventGeneratorSupport class. Of course, this doesn't mean
+ * nasty race conditions and dead locks don't exist. I'm just
+ * not aware of them :)
+ *
+ * <p>
+ *
+ * For more detailed documentation, refer to the
+ * <a href="http://www.gjt.org/%7ejpl/org_gjt_lindfors_util/index.html">
+ *
+ * Util Library Tutorial
+ *
+ * </a> and
+ *
+ * <a href="http://www.gjt.org/%7ejpl/org_gjt_lindfors_util/specs/index.html">
+ *
+ * Util Library Specifications
+ *
+ * </a>. See Also:
+ *
+ * <a href="http://www.artima.com/designtechniques/index.html">
+ *
+ * The Event Generator Idiom
+ *
+ * </a> by Bill Venners.
+ *
+ *
+ * @see org.gjt.lindfors.util.EventGenerator
+ *
+ * @author Juha Lindfors
+ * @version $Revision: 1.4 $
+ * @since JDK1.1
+ */
+public abstract class EventGeneratorSupport implements Serializable, Cloneable{
+
+ /*
+ * [TODO] Implement different algorithms for listener notification. Use the
+ * one implemented in this class as default, and implement high
+ * performance notifications. Use strategy pattern to allow any
+ * number of algorithms to be added.
+ *
+ * [TODO] write performance tests to compare the implementations
+ *
+ * [TODO] Could use Doug Lea's latch implementation here. Prettier than
+ * using a mutex :P
+ *
+ * [TODO] The use of this class could be used as an example of bridge.
+ * Also, the concrete implementations usually act as adapters (not
+ * allowing just any listener to be added, but a specific type).
+ * Can subclassing be used as an adapter pattern?
+ */
+
+ /**
+ * Vector for storing the registered listeners. Vector will use lazy
+ * instantiation and will be constructed only upon request. To ensure
+ * proper behaviour in a multi-threaded environment, use the private
+ * getListInstance method any time you need a reference to this vector.
+ */
+ private transient Vector list = null;
+
+ /**
+ * Clone of listener list. This clone is used as a snapshot of the listener
+ * list. The clone is updated every time a listener is either registered
+ * or unregistered. This way we can avoid cloning the listener list for
+ * the getListeners method call which is usually called by the event
+ * firing methods. Since we don't have to clone the listener list for every
+ * event notification, we gain a significantly better performance.
+ */
+ private transient Vector clone = null;
+
+ /**
+ * Mutex lock for instantiating the listener collection.
+ */
+ private transient final boolean[] MUTEX = new boolean[0];
+
+
+ /**
+ * Always use this method to get a reference to listener collection.
+ * This guarantees thread safety.
+ */
+ private Vector getListInstance() {
+ synchronized (MUTEX) {
+ if (list == null) {
+ list = new Vector();
+ clone = (Vector)list.clone();
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Constructs support object.
+ */
+ public EventGeneratorSupport() {}
+
+
+ /**
+ * Checks if any registered listeners exist.
+ *
+ * @return true if one or more listeners exist, false otherwise
+ */
+ public boolean hasListeners() {
+ if (list == null) // lazy list, not instantiated
+ return false;
+
+ if (list.size() == 0) // instantiated but empty
+ return false;
+
+ return true;
+ }
+
+
+ /**
+ * Returns the listeners registered to this object.
+ *
+ * @return enumeration of registered listener objects
+ */
+ protected Enumeration getListeners() {
+ if (list == null)
+ return new Enumeration() {
+
+ public boolean hasMoreElements() {
+ return false;
+ }
+
+ public Object nextElement() {
+ return null;
+ }
+ };
+
+ Vector v = (Vector)list.clone();
+ return v.elements();
+ }
+
+ /**
+ * Registers a new listener to this object. Duplicate listeners are
+ * discarded.
+ *
+ * <p>
+ *
+ * This method is marked as protected and is supposed to be used only by
+ * the concrete implementations of generator support classes. The concrete
+ * subclasses must ensure only the correct type of listeners are allowed
+ * to register, as this method allows any listener to be added, therefore
+ * not being type safe.
+ *
+ * @param listener the listener object
+ */
+ protected void addListener(EventListener listener) {
+ synchronized (MUTEX) {
+ Vector v = getListInstance();
+ if (!v.contains(listener))
+ v.addElement(listener);
+ }
+ }
+
+ /**
+ * Unregisters a listener from this object. It is safe to attempt to
+ * unregister non-existant listeners.
+ *
+ * @param listener the listener object
+ */
+ protected void removeListener(EventListener listener) {
+ if (list != null) {
+ list.removeElement(listener);
+ }
+ }
+
+ /**
+ * Returns a string representation of this EventGeneratorSupport object.
+ *
+ * <p>
+ *
+ * The output will be similar to the following form:<br>
+ * <pre>
+ * EventGeneratorSupport[Registered Listeners=1]
+ * </pre>
+ */
+ public String toString() {
+ int count;
+
+ // don't want to instantiate listener just to tell it has zero elements
+ if (list == null)
+ count = 0;
+ else count = getListInstance().size();
+
+ return Library.getClassName(this) + "[Registered Listeners=" + count + "]";
+ }
+
+ /**
+ * [PENDING]
+ */
+ public Component toComponent() {
+ // [FIXME] this exception class has disappeared!
+ //throw new UnsupportedOperationException("not implemented yet.");
+ return null;
+ }
+
+ /**
+ * [PENDING]
+ */
+ public Object clone() {
+ // [FIXME] this exception class has disappeared!
+ //throw new UnsupportedOperationException("not implemented yet.");
+ return null;
+ }
+
+}
+
+
Property changes on: trunk/server/src/main/org/jboss/verifier/event/EventGeneratorSupport.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/verifier/event/Library.java
===================================================================
--- trunk/server/src/main/org/jboss/verifier/event/Library.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/verifier/event/Library.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,85 +1,85 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.verifier.event;
-
-/*
- * Class org.jboss.verifier.event.Library (refer Class org.gjt.lindfors.util.Library at www.gjt.org)
- * Copyright (C) 1999 Juha Lindfors
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * This package and its source code is available at www.jboss.org
- * $Id: Library.java 3217 2007-12-06 11:28:57Z csaldanh at redhat.com $
- *
- * You can reach the author by sending email to jpl at gjt.org or
- * directly to jplindfo at helsinki.fi.
- */
-
-
-/**
- * Collection of miscellaneous utility methods.
- * <p>
- * For more detailed documentation, refer to the
- * <a href="http://www.gjt.org/%7ejpl/org_gjt_lindfors_util/index.html">
- * Util Library Developer's Guide</a>
- *
- * @author Juha Lindfors
- * @version $Revision: 1.1 $
- * @since JDK1.1
- */
-public class Library {
-
- private Library() {}
-
- /**
- * Returns the class name of an object. This method returns only the
- * name of the class, not a fully qualified class name with package
- * information. For fully qualified class name, use
- * <code>getClass().getName()</code>.
- *
- * @param obj object whose class name is wanted
- *
- * @return object's class name, without package information
- *
- * @see java.lang.Object#getClass()
- */
- public static String getClassName(Object obj) {
- String str = obj.getClass().getName();
- int index = str.lastIndexOf('.');
- return str.substring(index+1);
- }
-}
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.verifier.event;
+
+/*
+ * Class org.jboss.verifier.event.Library (refer Class org.gjt.lindfors.util.Library at www.gjt.org)
+ * Copyright (C) 1999 Juha Lindfors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * This package and its source code is available at www.jboss.org
+ * $Id: Library.java 3217 2007-12-06 11:28:57Z csaldanh at redhat.com $
+ *
+ * You can reach the author by sending email to jpl at gjt.org or
+ * directly to jplindfo at helsinki.fi.
+ */
+
+
+/**
+ * Collection of miscellaneous utility methods.
+ * <p>
+ * For more detailed documentation, refer to the
+ * <a href="http://www.gjt.org/%7ejpl/org_gjt_lindfors_util/index.html">
+ * Util Library Developer's Guide</a>
+ *
+ * @author Juha Lindfors
+ * @version $Revision: 1.1 $
+ * @since JDK1.1
+ */
+public class Library {
+
+ private Library() {}
+
+ /**
+ * Returns the class name of an object. This method returns only the
+ * name of the class, not a fully qualified class name with package
+ * information. For fully qualified class name, use
+ * <code>getClass().getName()</code>.
+ *
+ * @param obj object whose class name is wanted
+ *
+ * @return object's class name, without package information
+ *
+ * @see java.lang.Object#getClass()
+ */
+ public static String getClassName(Object obj) {
+ String str = obj.getClass().getName();
+ int index = str.lastIndexOf('.');
+ return str.substring(index+1);
+ }
+}
+
Property changes on: trunk/server/src/main/org/jboss/verifier/event/Library.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/web/WebClassLoaderFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/web/WebClassLoaderFactory.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/WebClassLoaderFactory.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,43 +1,43 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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;
-
-import java.lang.reflect.Constructor;
-
-import javax.management.ObjectName;
-
-import org.jboss.classloading.spi.RealClassLoader;
-
-/**
- * WebClassLoaderFactory.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class WebClassLoaderFactory
-{
- public static WebClassLoader createWebClassLoader(Class<?> webClassLoaderClass, ObjectName containerName, RealClassLoader parent) throws Exception
- {
- Constructor constructor = webClassLoaderClass.getConstructor(new Class[]{ObjectName.class, RealClassLoader.class});
- return (WebClassLoader) constructor.newInstance(new Object[]{containerName, parent});
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.lang.reflect.Constructor;
+
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.RealClassLoader;
+
+/**
+ * WebClassLoaderFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebClassLoaderFactory
+{
+ public static WebClassLoader createWebClassLoader(Class<?> webClassLoaderClass, ObjectName containerName, RealClassLoader parent) throws Exception
+ {
+ Constructor constructor = webClassLoaderClass.getConstructor(new Class[]{ObjectName.class, RealClassLoader.class});
+ return (WebClassLoader) constructor.newInstance(new Object[]{containerName, parent});
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/web/WebClassLoaderFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,732 +1,732 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployers;
-
-import java.io.File;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AttachmentLocator;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
-import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.metadata.ear.spec.ModuleMetaData;
-import org.jboss.metadata.ear.spec.WebModuleMetaData;
-import org.jboss.metadata.web.jboss.ClassLoadingMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.spec.WebMetaData;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.system.metadata.ServiceAttributeMetaData;
-import org.jboss.system.metadata.ServiceConstructorMetaData;
-import org.jboss.system.metadata.ServiceDependencyMetaData;
-import org.jboss.system.metadata.ServiceInjectionValueMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-import org.jboss.system.server.ServerConfigLocator;
-import org.jboss.util.file.Files;
-import org.jboss.util.file.JarUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.web.WebApplication;
-
-/** A template pattern class for web container integration into JBoss. This class
- * should be subclassed by web container providers wishing to integrate their
- * container into a JBoss server. The sole method to implement is:
- * {@link #getDeployment(DeploymentUnit, WebMetaData)}. This is called from
- * within {@linkplain #deploy(DeploymentUnit, WebMetaData)} to translate the
- * WebMetaData into a AbstractWarDeployment bean that will be passed to the
- * {@link org.jboss.system.deployers.ServiceDeployer} by creating ServiceMetaData
- * for the AbstractWarDeployment in
- * {@link #deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment)}
- *
- * The output of this deployer is a ServiceMetaData attachment. When this is
- * translated into a service instance by the ServiceDeployer, the
- * AbstractWarDeployment start/stop trigger the actual deployment/undeployment of
- * the web application.
- *
- * @see org.jboss.web.deployers.AbstractWarDeployment
- *
- * @author Scott.Stark at jboss.org
- * @author Christoph.Jung at infor.de
- * @author Thomas.Diesler at arcor.de
- * @author adrian at jboss.org
- * @version $Revision: 55985 $
- */
-public abstract class AbstractWarDeployer extends AbstractSimpleVFSRealDeployer<JBossWebMetaData>
-{
- public static final String DEPLOYER = "org.jboss.web.AbstractWebContainer.deployer";
- public static final String WEB_APP = "org.jboss.web.AbstractWebContainer.webApp";
- public static final String WEB_MODULE = "org.jboss.web.AbstractWebContainer.webModule";
- public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
-
- /** A mapping of deployed warUrl strings to the WebApplication object */
- protected HashMap deploymentMap = new HashMap();
- /** The parent class loader first model flag */
- protected boolean java2ClassLoadingCompliance = false;
- /** A flag indicating if war archives should be unpacked */
- protected boolean unpackWars = true;
- /** A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
- */
- protected boolean acceptNonWarDirs = false;
-
- /** If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name) */
- protected boolean lenientEjbLink = false;
-
- /** The default security-domain name to use */
- protected String defaultSecurityDomain = "java:/jaas/other";
- /** The request attribute name under which the JAAS Subject is store */
- private String subjectAttributeName = null;
- /** Legacy support for MBeanServer */
- private MBeanServer server;
- private MainDeployerStructure mainDeployer;
-
- private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
-
- /**
- * Create a new AbstractWarDeployer.
- */
- public AbstractWarDeployer()
- {
- super(JBossWebMetaData.class);
- setOutput(ServiceMetaData.class);
- setOutput(WarDeployment.class);
- }
-
- /** Get the flag indicating if the normal Java2 parent first class loading
- * model should be used over the servlet 2.3 web container first model.
- * @return true for parent first, false for the servlet 2.3 model
- * @jmx:managed-attribute
- */
- public boolean getJava2ClassLoadingCompliance()
- {
- return java2ClassLoadingCompliance;
- }
-
- /** Set the flag indicating if the normal Java2 parent first class loading
- * model should be used over the servlet 2.3 web container first model.
- * @param flag true for parent first, false for the servlet 2.3 model
- * @jmx:managed-attribute
- */
- public void setJava2ClassLoadingCompliance(boolean flag)
- {
- java2ClassLoadingCompliance = flag;
- }
-
- /** Set the flag indicating if war archives should be unpacked. This may
- * need to be set to false as long extraction paths under deploy can
- * show up as deployment failures on some platforms.
- *
- * @jmx:managed-attribute
- * @return true is war archives should be unpacked
- */
- public boolean getUnpackWars()
- {
- return unpackWars;
- }
-
- /** Get the flag indicating if war archives should be unpacked. This may
- * need to be set to false as long extraction paths under deploy can
- * show up as deployment failures on some platforms.
- *
- * @jmx:managed-attribute
- * @param flag , true is war archives should be unpacked
- */
- public void setUnpackWars(boolean flag)
- {
- this.unpackWars = flag;
- }
-
- /**
- * Get the flag indicating if local dirs with WEB-INF/web.xml should be
- * treated as wars
- * @return true if local dirs with WEB-INF/web.xml should be treated as wars
- * @jmx.managed-attribute
- */
- public boolean getAcceptNonWarDirs()
- {
- return acceptNonWarDirs;
- }
-
- /**
- * Set the flag indicating if local dirs with WEB-INF/web.xml should be
- * treated as wars
- * @param flag - true if local dirs with WEB-INF/web.xml should be treated as wars
- * @jmx.managed-attribute
- */
- public void setAcceptNonWarDirs(boolean flag)
- {
- this.acceptNonWarDirs = flag;
- }
-
- /**
- * Get the flag indicating if ejb-link errors should be ignored
- * in favour of trying the jndi-name in jboss-web.xml
- * @return the LenientEjbLink flag
- *
- * @jmx:managed-attribute
- */
- public boolean getLenientEjbLink()
- {
- return lenientEjbLink;
- }
-
- /**
- * Set the flag indicating if ejb-link errors should be ignored
- * in favour of trying the jndi-name in jboss-web.xml
- *
- * @jmx:managed-attribute
- */
- public void setLenientEjbLink(boolean flag)
- {
- lenientEjbLink = flag;
- }
-
- /** Get the default security domain implementation to use if a war
- * does not declare a security-domain.
- *
- * @return jndi name of the security domain binding to use.
- * @jmx:managed-attribute
- */
- public String getDefaultSecurityDomain()
- {
- return defaultSecurityDomain;
- }
-
- /** Set the default security domain implementation to use if a war
- * does not declare a security-domain.
- *
- * @param defaultSecurityDomain - jndi name of the security domain binding
- * to use.
- * @jmx:managed-attribute
- */
- public void setDefaultSecurityDomain(String defaultSecurityDomain)
- {
- this.defaultSecurityDomain = defaultSecurityDomain;
- }
-
- @Inject
- public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
- {
- this.persistenceUnitDependencyResolver = resolver;
- }
-
- /** Get the session attribute number under which the caller Subject is stored
- * @jmx:managed-attribute
- */
- public String getSubjectAttributeName()
- {
- return subjectAttributeName;
- }
-
- /** Set the session attribute number under which the caller Subject is stored
- * @jmx:managed-attribute
- */
- public void setSubjectAttributeName(String subjectAttributeName)
- {
- this.subjectAttributeName = subjectAttributeName;
- }
-
- public void start() throws Exception
- {
- // TODO: remove dependency on jmx
- this.server = MBeanServerLocator.locateJBoss();
- }
-
- public void stop() throws Exception
- {
-
- }
-
- /**
- * Get the AbstractWarDeployment bean for the deployment metadata. Subclasses
- * override this method to provide a AbstractWarDeployment bean whose
- * start/stop will control the deployment/undeployment of the web
- * application.
- *
- * @param unit - the deployment unit
- * @param metaData - the input web application metadata
- * @return the AbstractWarDeployment for the input WebMetaData
- * @throws Exception - thrown on any failure
- */
- public abstract AbstractWarDeployment getDeployment(VFSDeploymentUnit unit, JBossWebMetaData metaData) throws Exception;
-
- /**
- * Deploy a web app based on the WebMetaData. This calls
- * {@link #getDeployment(VFSDeploymentUnit, WebMetaData)} to obtain an
- * AbstractWarDeployment bean that is wrapped in a ServiceMetaData by
- * deployWebModule.
- *
- * This will set the WebMetaData.contextRoot if it has not been set based
- * on the war deployment name.
- *
- * @see #deployWebModule(VFSDeploymentUnit, WebMetaData, AbstractWarDeployment)
- * @see #buildWebContext(VFSDeploymentUnit, String, String, WebMetaData)
- *
- * @param unit - the war for the deployment
- * @param metaData - the metadata for the deployment
- */
- @Override
- public void deploy(VFSDeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
- {
- log.debug("Begin deploy, " + metaData);
-
- // Merge any settings from the ear level
- JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class);
- if (earMetaData != null)
- {
- String path = unit.getRelativePath();
- ModuleMetaData webModule = earMetaData.getModule(path);
- if (webModule != null)
- {
- // Check for a context-root setting
- String contextRoot = metaData.getContextRoot();
- if (contextRoot == null)
- {
- WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue();
- contextRoot = wmodule.getContextRoot();
- metaData.setContextRoot(contextRoot);
- }
-
- // Add any alt-dd setting
- metaData.setAlternativeDD(webModule.getAlternativeDD());
- }
-
- // Merge security domain/roles
- if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null)
- metaData.setSecurityDomain(earMetaData.getSecurityDomain());
- // TODO
- metaData.mergeSecurityRoles(earMetaData.getSecurityRoles());
- }
-
- try
- {
- /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since
- * the vfs deals with the distinction between a true directory, the only way we can tell from
- * this level of the api is to look for a url that ends in '/'. Here we assume that the name is
- * the root url.
- */
- String warName = unit.getName();
-
- /**
- * Ignore the jacc policy service bean
- */
- if (warName.startsWith("jboss:") && warName.contains("id="))
- return;
-
- URL expWarUrl = unit.getRoot().toURL();
- if (warName.endsWith("/") == false
- || warName.endsWith("!/") == true) // Hack for jar urls being exposed
- {
- if (warName.startsWith("jar:"))
- {
- if (warName.endsWith("!/"))
- warName = warName.substring(4, warName.length() - 2);
- else
- warName = warName.substring(4, warName.length());
- }
- URL warURL = new URL(warName);
- ServerConfig config = ServerConfigLocator.locate();
- String prefix = warURL.getFile();
- int lastSlash = prefix.lastIndexOf('/');
- if (lastSlash > 0)
- prefix = prefix.substring(lastSlash + 1);
- int dotWar = prefix.lastIndexOf(".war");
- if (dotWar > 0)
- prefix = prefix.substring(0, dotWar);
-
- File expWarFile = File.createTempFile(prefix, "-exp.war", config.getServerTempDeployDir());
- expWarFile.delete();
- if (expWarFile.mkdir() == false)
- throw new DeploymentException("Was unable to mkdir: " + expWarFile);
- log.debug("Unpacking war to: " + expWarFile);
- VirtualFile root = unit.getRoot();
- InputStream is = root.openStream();
- try
- {
- JarUtils.unjar(is, expWarFile);
- }
- finally
- {
- is.close();
- }
- expWarUrl = expWarFile.toURL();
-
- // Map
- VirtualFile warVF = unit.getRoot();
- String warPathName = warVF.getPathName();
- if (warPathName.endsWith("/") == false)
- warPathName += "/";
- List<VirtualFile> classpathVFs = unit.getClassPath();
- if (classpathVFs != null)
- {
- ArrayList<URL> classpath = new ArrayList<URL>();
- for (VirtualFile vf : classpathVFs)
- {
- try
- {
- String path = vf.getPathName();
- if (path.startsWith(warPathName))
- {
- path = path.substring(warPathName.length());
- URL pathURL = new URL(expWarUrl, path);
- classpath.add(pathURL);
- }
- else
- {
- log.debug("Ignoring path element: " + vf);
- }
- }
- catch (Exception e)
- {
- log.debug("Ignoring path element: " + vf, e);
- }
- }
- unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
- }
-
- // Indicate that an expanded URL exists
- unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
- }
-
- // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
- String altDDPath = metaData.getAlternativeDD();
- if (altDDPath != null)
- {
- // First see if this is already a war local dd
- VirtualFile altDD = unit.getMetaDataFile(altDDPath);
- if (altDD == null)
- {
- // Pass absolute paths through
- File file = new File(altDDPath);
- if (!file.exists() || !file.isAbsolute())
- {
- // Should be an relative to the top deployment
- VFSDeploymentUnit topUnit = unit.getTopLevel();
- if (topUnit == unit)
- throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
- altDD = topUnit.getFile(altDDPath);
- if (altDD == null)
- throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
- File webInf = new File(expWarUrl.toURI());
- File altDDFile = new File(webInf, "WEB-INF/" + altDD.getName());
- log.debug("Copying the altDD to: " + altDDFile);
- Files.copy(altDD.toURL(), altDDFile);
- metaData.setAlternativeDD(altDDFile.getAbsolutePath());
- }
- }
- }
-
- ClassLoadingMetaData classLoading = metaData.getClassLoading();
- if (classLoading == null)
- classLoading = new ClassLoadingMetaData();
- // pass in the java2ClassLoadingCompliance if it was not set at the war level
- if (classLoading.wasJava2ClassLoadingComplianceSet() == false)
- classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
- metaData.setClassLoading(classLoading);
-
- // Build the context root if its not been set or is specified at the ear
- String webContext = metaData.getContextRoot();
- webContext = buildWebContext(webContext, warName, metaData, unit);
- metaData.setContextRoot(webContext);
-
- AbstractWarDeployment deployment = getDeployment(unit, metaData);
- deployment.setMainDeployer(mainDeployer);
- // TODO: until deployment is a MC bean
- deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
- deployWebModule(unit, metaData, deployment);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Failed to create web module", e);
- }
- }
-
- /**
- * Cleanup war deployer specifics.
- */
- @Override
- public void undeploy(VFSDeploymentUnit unit, JBossWebMetaData metaData)
- {
- try
- {
- // Delete any expanded war
- URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
- if (warURL != null)
- {
- File war = new File(warURL.toURI());
- Files.delete(war);
- }
- }
- catch (Exception e)
- {
- log.debug("Failed to remove expanded war", e);
- }
- /* Clear class loader refs
- metaData.setContextLoader(null);
- metaData.setResourceClassLoader(null);
- metaData.setENCLoader(null);
- */
- }
-
- public void addDeployedApp(String warURL, WebApplication webApp)
- {
- deploymentMap.put(warURL, webApp);
- }
-
- /** Get the WebApplication object for a deployed war.
- @param warUrl the war url string as originally passed to deploy().
- @return The WebApplication created during the deploy step if the
- warUrl is valid, null if no such deployment exists.
- */
- public WebApplication getDeployedApp(String warUrl)
- {
- WebApplication appInfo = (WebApplication)deploymentMap.get(warUrl);
- return appInfo;
- }
-
- public WebApplication removeDeployedApp(String warURL)
- {
- WebApplication appInfo = (WebApplication)deploymentMap.remove(warURL);
- return appInfo;
- }
-
- /** Returns the applications deployed by the web container subclasses.
- @jmx:managed-attribute
- @return An Iterator of WebApplication objects for the deployed wars.
- */
- public Iterator getDeployedApplications()
- {
- return deploymentMap.values().iterator();
- }
-
- /** A utility method that uses reflection to access a URL[] getURLs method
- * so that non-URLClassLoader class loaders that support this method can
- * provide info.
- */
- public static URL[] getClassLoaderURLs(ClassLoader cl)
- {
- URL[] urls = {};
- try
- {
- Class returnType = urls.getClass();
- Class[] parameterTypes = {};
- Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
- if (returnType.isAssignableFrom(getURLs.getReturnType()))
- {
- Object[] args = {};
- urls = (URL[])getURLs.invoke(cl, args);
- }
- if (urls == null || urls.length == 0)
- {
- getURLs = cl.getClass().getMethod("getAllURLs", parameterTypes);
- if (returnType.isAssignableFrom(getURLs.getReturnType()))
- {
- Object[] args = {};
- urls = (URL[])getURLs.invoke(cl, args);
- }
- }
- }
- catch (Exception ignore)
- {
- }
- return urls;
- }
-
- /** This method creates a context-root string from either the
- WEB-INF/jboss-web.xml context-root element is one exists, or the
- filename portion of the warURL. It is called if the deployment
- webContext value is null which indicates a standalone war deployment.
- A war name of ROOT.war is handled as a special case of a war that
- should be installed as the default web context.
- @param ctxPath - war level context-root
- @param warName -
- */
- protected String buildWebContext(String ctxPath, String warName, JBossWebMetaData metaData, VFSDeploymentUnit unit)
- {
- // Build a war root context from the war name if one was not specified
- String webContext = ctxPath;
-
- // Build the context from the deployment name
- if (webContext == null)
- {
- // Build the context from the war name, strip the .war suffix
- webContext = warName;
- webContext = webContext.replace('\\', '/');
- if (webContext.endsWith("/"))
- webContext = webContext.substring(0, webContext.length() - 1);
- int prefix = webContext.lastIndexOf('/');
- if (prefix > 0)
- webContext = webContext.substring(prefix + 1);
- int suffix = webContext.lastIndexOf(".war");
- if (suffix > 0)
- webContext = webContext.substring(0, suffix);
- // Strip any '<int-value>.' prefix
- int index = 0;
- for (; index < webContext.length(); index++)
- {
- char c = webContext.charAt(index);
- if (Character.isDigit(c) == false && c != '.')
- break;
- }
- webContext = webContext.substring(index);
- }
-
- // Servlet containers are anal about the web context starting with '/'
- if (webContext.length() > 0 && webContext.charAt(0) != '/')
- webContext = "/" + webContext;
- // And also the default root context must be an empty string, not '/'
- else if (webContext.equals("/"))
- webContext = "";
- return webContext;
- }
-
- /**
- * TODO: The use of an MBeanServer needs to be removed
- * @return
- */
- @Deprecated
- protected MBeanServer getServer()
- {
- return server;
- }
-
- public MainDeployerStructure getMainDeployer()
- {
- return mainDeployer;
- }
-
- public void setMainDeployer(MainDeployerStructure mainDeployer)
- {
- this.mainDeployer = mainDeployer;
- }
-
- /**
- * Get the object name of the ServiceMetaData instance associated with
- * the WebMetaData. This uses the pattern:
- * "jboss.web.deployment:war="+metaData.getContextRoot()
- *
- * @param metaData - the web app metaData
- * @return "jboss.web.deployment:war="+metaData.getContextRoot();
- */
- protected String getObjectName(JBossWebMetaData metaData)
- {
- String ctxPath = metaData.getContextRoot();
- // The ctx path value cannot be empty in the object name
- if (ctxPath == null || ctxPath.length() == 0)
- ctxPath = "/";
- String objectName = "jboss.web.deployment:war=" + ctxPath;
- return objectName;
- }
-
- /**
- * Called by deploy first to create a ServiceMetaData instance that wraps the
- * AbstractWarDeployment bean and then attach it to the deployment unit. The
- * presence of the ServiceMetaData attachment makes the deployment unit
- * "relevant" to the deployers that handle mbean services.
- *
- * @param unit - the deployment unit
- * @param metaData - the web app metadata passed to deploy
- * @param deployment - the web app deployment bean created by getDeployment
- * @throws Exception
- */
- protected void deployWebModule(VFSDeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
- {
- log.debug("deployWebModule: " + unit.getName());
- try
- {
- ServiceMetaData webModule = new ServiceMetaData();
- String name = getObjectName(metaData);
- ObjectName objectName = new ObjectName(name);
- webModule.setObjectName(objectName);
- webModule.setCode(WebModule.class.getName());
- // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
- ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
- constructor.setSignature(new String[] { VFSDeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
- constructor.setParameters(new Object[] { unit, this, deployment });
- webModule.setConstructor(constructor);
-
- List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
-
- ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
- attr.setName("SecurityManagement");
- ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
- attr.setValue(injectionValue);
- attrs.add(attr);
-
- ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData();
- attrPR.setName("PolicyRegistration");
- ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName());
- attrPR.setValue(injectionValuePR);
- attrs.add(attrPR);
-
- ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
- attrKernel.setName("Kernel");
- ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
- attrKernel.setValue(injectionValueKernel);
- attrs.add(attrKernel);
-
- webModule.setAttributes(attrs);
-
- // Dependencies...Still have old jmx names here
- Collection<String> depends = metaData.getDepends();
- List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
- if (depends != null && depends.isEmpty() == false)
- {
- if (log.isTraceEnabled())
- log.trace(name + " has dependencies: " + depends);
-
- for (String iDependOn : depends)
- {
- ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
- sdmd.setIDependOn(iDependOn);
- dependencies.add(sdmd);
- }
- }
- webModule.setDependencies(dependencies);
-
- // Here's where a bit of magic happens. By attaching the ServiceMetaData
- // to the deployment, we now make the deployment "relevant" to
- // deployers that use ServiceMetaData as an input (e.g. the
- // org.jboss.system.deployers.ServiceDeployer). Those deployers
- // can now take over deploying the web module.
-
- unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
- }
- catch (Exception e)
- {
- throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployers;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AttachmentLocator;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ear.spec.ModuleMetaData;
+import org.jboss.metadata.ear.spec.WebModuleMetaData;
+import org.jboss.metadata.web.jboss.ClassLoadingMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceInjectionValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.server.ServerConfigLocator;
+import org.jboss.util.file.Files;
+import org.jboss.util.file.JarUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.web.WebApplication;
+
+/** A template pattern class for web container integration into JBoss. This class
+ * should be subclassed by web container providers wishing to integrate their
+ * container into a JBoss server. The sole method to implement is:
+ * {@link #getDeployment(DeploymentUnit, WebMetaData)}. This is called from
+ * within {@linkplain #deploy(DeploymentUnit, WebMetaData)} to translate the
+ * WebMetaData into a AbstractWarDeployment bean that will be passed to the
+ * {@link org.jboss.system.deployers.ServiceDeployer} by creating ServiceMetaData
+ * for the AbstractWarDeployment in
+ * {@link #deployWebModule(DeploymentUnit, WebMetaData, AbstractWarDeployment)}
+ *
+ * The output of this deployer is a ServiceMetaData attachment. When this is
+ * translated into a service instance by the ServiceDeployer, the
+ * AbstractWarDeployment start/stop trigger the actual deployment/undeployment of
+ * the web application.
+ *
+ * @see org.jboss.web.deployers.AbstractWarDeployment
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Christoph.Jung at infor.de
+ * @author Thomas.Diesler at arcor.de
+ * @author adrian at jboss.org
+ * @version $Revision: 55985 $
+ */
+public abstract class AbstractWarDeployer extends AbstractSimpleVFSRealDeployer<JBossWebMetaData>
+{
+ public static final String DEPLOYER = "org.jboss.web.AbstractWebContainer.deployer";
+ public static final String WEB_APP = "org.jboss.web.AbstractWebContainer.webApp";
+ public static final String WEB_MODULE = "org.jboss.web.AbstractWebContainer.webModule";
+ public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+
+ /** A mapping of deployed warUrl strings to the WebApplication object */
+ protected HashMap deploymentMap = new HashMap();
+ /** The parent class loader first model flag */
+ protected boolean java2ClassLoadingCompliance = false;
+ /** A flag indicating if war archives should be unpacked */
+ protected boolean unpackWars = true;
+ /** A flag indicating if local dirs with WEB-INF/web.xml should be treated as wars
+ */
+ protected boolean acceptNonWarDirs = false;
+
+ /** If true, ejb-links that don't resolve don't cause an error (fallback to jndi-name) */
+ protected boolean lenientEjbLink = false;
+
+ /** The default security-domain name to use */
+ protected String defaultSecurityDomain = "java:/jaas/other";
+ /** The request attribute name under which the JAAS Subject is store */
+ private String subjectAttributeName = null;
+ /** Legacy support for MBeanServer */
+ private MBeanServer server;
+ private MainDeployerStructure mainDeployer;
+
+ private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+ /**
+ * Create a new AbstractWarDeployer.
+ */
+ public AbstractWarDeployer()
+ {
+ super(JBossWebMetaData.class);
+ setOutput(ServiceMetaData.class);
+ setOutput(WarDeployment.class);
+ }
+
+ /** Get the flag indicating if the normal Java2 parent first class loading
+ * model should be used over the servlet 2.3 web container first model.
+ * @return true for parent first, false for the servlet 2.3 model
+ * @jmx:managed-attribute
+ */
+ public boolean getJava2ClassLoadingCompliance()
+ {
+ return java2ClassLoadingCompliance;
+ }
+
+ /** Set the flag indicating if the normal Java2 parent first class loading
+ * model should be used over the servlet 2.3 web container first model.
+ * @param flag true for parent first, false for the servlet 2.3 model
+ * @jmx:managed-attribute
+ */
+ public void setJava2ClassLoadingCompliance(boolean flag)
+ {
+ java2ClassLoadingCompliance = flag;
+ }
+
+ /** Set the flag indicating if war archives should be unpacked. This may
+ * need to be set to false as long extraction paths under deploy can
+ * show up as deployment failures on some platforms.
+ *
+ * @jmx:managed-attribute
+ * @return true is war archives should be unpacked
+ */
+ public boolean getUnpackWars()
+ {
+ return unpackWars;
+ }
+
+ /** Get the flag indicating if war archives should be unpacked. This may
+ * need to be set to false as long extraction paths under deploy can
+ * show up as deployment failures on some platforms.
+ *
+ * @jmx:managed-attribute
+ * @param flag , true is war archives should be unpacked
+ */
+ public void setUnpackWars(boolean flag)
+ {
+ this.unpackWars = flag;
+ }
+
+ /**
+ * Get the flag indicating if local dirs with WEB-INF/web.xml should be
+ * treated as wars
+ * @return true if local dirs with WEB-INF/web.xml should be treated as wars
+ * @jmx.managed-attribute
+ */
+ public boolean getAcceptNonWarDirs()
+ {
+ return acceptNonWarDirs;
+ }
+
+ /**
+ * Set the flag indicating if local dirs with WEB-INF/web.xml should be
+ * treated as wars
+ * @param flag - true if local dirs with WEB-INF/web.xml should be treated as wars
+ * @jmx.managed-attribute
+ */
+ public void setAcceptNonWarDirs(boolean flag)
+ {
+ this.acceptNonWarDirs = flag;
+ }
+
+ /**
+ * Get the flag indicating if ejb-link errors should be ignored
+ * in favour of trying the jndi-name in jboss-web.xml
+ * @return the LenientEjbLink flag
+ *
+ * @jmx:managed-attribute
+ */
+ public boolean getLenientEjbLink()
+ {
+ return lenientEjbLink;
+ }
+
+ /**
+ * Set the flag indicating if ejb-link errors should be ignored
+ * in favour of trying the jndi-name in jboss-web.xml
+ *
+ * @jmx:managed-attribute
+ */
+ public void setLenientEjbLink(boolean flag)
+ {
+ lenientEjbLink = flag;
+ }
+
+ /** Get the default security domain implementation to use if a war
+ * does not declare a security-domain.
+ *
+ * @return jndi name of the security domain binding to use.
+ * @jmx:managed-attribute
+ */
+ public String getDefaultSecurityDomain()
+ {
+ return defaultSecurityDomain;
+ }
+
+ /** Set the default security domain implementation to use if a war
+ * does not declare a security-domain.
+ *
+ * @param defaultSecurityDomain - jndi name of the security domain binding
+ * to use.
+ * @jmx:managed-attribute
+ */
+ public void setDefaultSecurityDomain(String defaultSecurityDomain)
+ {
+ this.defaultSecurityDomain = defaultSecurityDomain;
+ }
+
+ @Inject
+ public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
+ {
+ this.persistenceUnitDependencyResolver = resolver;
+ }
+
+ /** Get the session attribute number under which the caller Subject is stored
+ * @jmx:managed-attribute
+ */
+ public String getSubjectAttributeName()
+ {
+ return subjectAttributeName;
+ }
+
+ /** Set the session attribute number under which the caller Subject is stored
+ * @jmx:managed-attribute
+ */
+ public void setSubjectAttributeName(String subjectAttributeName)
+ {
+ this.subjectAttributeName = subjectAttributeName;
+ }
+
+ public void start() throws Exception
+ {
+ // TODO: remove dependency on jmx
+ this.server = MBeanServerLocator.locateJBoss();
+ }
+
+ public void stop() throws Exception
+ {
+
+ }
+
+ /**
+ * Get the AbstractWarDeployment bean for the deployment metadata. Subclasses
+ * override this method to provide a AbstractWarDeployment bean whose
+ * start/stop will control the deployment/undeployment of the web
+ * application.
+ *
+ * @param unit - the deployment unit
+ * @param metaData - the input web application metadata
+ * @return the AbstractWarDeployment for the input WebMetaData
+ * @throws Exception - thrown on any failure
+ */
+ public abstract AbstractWarDeployment getDeployment(VFSDeploymentUnit unit, JBossWebMetaData metaData) throws Exception;
+
+ /**
+ * Deploy a web app based on the WebMetaData. This calls
+ * {@link #getDeployment(VFSDeploymentUnit, WebMetaData)} to obtain an
+ * AbstractWarDeployment bean that is wrapped in a ServiceMetaData by
+ * deployWebModule.
+ *
+ * This will set the WebMetaData.contextRoot if it has not been set based
+ * on the war deployment name.
+ *
+ * @see #deployWebModule(VFSDeploymentUnit, WebMetaData, AbstractWarDeployment)
+ * @see #buildWebContext(VFSDeploymentUnit, String, String, WebMetaData)
+ *
+ * @param unit - the war for the deployment
+ * @param metaData - the metadata for the deployment
+ */
+ @Override
+ public void deploy(VFSDeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
+ {
+ log.debug("Begin deploy, " + metaData);
+
+ // Merge any settings from the ear level
+ JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class);
+ if (earMetaData != null)
+ {
+ String path = unit.getRelativePath();
+ ModuleMetaData webModule = earMetaData.getModule(path);
+ if (webModule != null)
+ {
+ // Check for a context-root setting
+ String contextRoot = metaData.getContextRoot();
+ if (contextRoot == null)
+ {
+ WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue();
+ contextRoot = wmodule.getContextRoot();
+ metaData.setContextRoot(contextRoot);
+ }
+
+ // Add any alt-dd setting
+ metaData.setAlternativeDD(webModule.getAlternativeDD());
+ }
+
+ // Merge security domain/roles
+ if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null)
+ metaData.setSecurityDomain(earMetaData.getSecurityDomain());
+ // TODO
+ metaData.mergeSecurityRoles(earMetaData.getSecurityRoles());
+ }
+
+ try
+ {
+ /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since
+ * the vfs deals with the distinction between a true directory, the only way we can tell from
+ * this level of the api is to look for a url that ends in '/'. Here we assume that the name is
+ * the root url.
+ */
+ String warName = unit.getName();
+
+ /**
+ * Ignore the jacc policy service bean
+ */
+ if (warName.startsWith("jboss:") && warName.contains("id="))
+ return;
+
+ URL expWarUrl = unit.getRoot().toURL();
+ if (warName.endsWith("/") == false
+ || warName.endsWith("!/") == true) // Hack for jar urls being exposed
+ {
+ if (warName.startsWith("jar:"))
+ {
+ if (warName.endsWith("!/"))
+ warName = warName.substring(4, warName.length() - 2);
+ else
+ warName = warName.substring(4, warName.length());
+ }
+ URL warURL = new URL(warName);
+ ServerConfig config = ServerConfigLocator.locate();
+ String prefix = warURL.getFile();
+ int lastSlash = prefix.lastIndexOf('/');
+ if (lastSlash > 0)
+ prefix = prefix.substring(lastSlash + 1);
+ int dotWar = prefix.lastIndexOf(".war");
+ if (dotWar > 0)
+ prefix = prefix.substring(0, dotWar);
+
+ File expWarFile = File.createTempFile(prefix, "-exp.war", config.getServerTempDeployDir());
+ expWarFile.delete();
+ if (expWarFile.mkdir() == false)
+ throw new DeploymentException("Was unable to mkdir: " + expWarFile);
+ log.debug("Unpacking war to: " + expWarFile);
+ VirtualFile root = unit.getRoot();
+ InputStream is = root.openStream();
+ try
+ {
+ JarUtils.unjar(is, expWarFile);
+ }
+ finally
+ {
+ is.close();
+ }
+ expWarUrl = expWarFile.toURL();
+
+ // Map
+ VirtualFile warVF = unit.getRoot();
+ String warPathName = warVF.getPathName();
+ if (warPathName.endsWith("/") == false)
+ warPathName += "/";
+ List<VirtualFile> classpathVFs = unit.getClassPath();
+ if (classpathVFs != null)
+ {
+ ArrayList<URL> classpath = new ArrayList<URL>();
+ for (VirtualFile vf : classpathVFs)
+ {
+ try
+ {
+ String path = vf.getPathName();
+ if (path.startsWith(warPathName))
+ {
+ path = path.substring(warPathName.length());
+ URL pathURL = new URL(expWarUrl, path);
+ classpath.add(pathURL);
+ }
+ else
+ {
+ log.debug("Ignoring path element: " + vf);
+ }
+ }
+ catch (Exception e)
+ {
+ log.debug("Ignoring path element: " + vf, e);
+ }
+ }
+ unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
+ }
+
+ // Indicate that an expanded URL exists
+ unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
+ }
+
+ // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
+ String altDDPath = metaData.getAlternativeDD();
+ if (altDDPath != null)
+ {
+ // First see if this is already a war local dd
+ VirtualFile altDD = unit.getMetaDataFile(altDDPath);
+ if (altDD == null)
+ {
+ // Pass absolute paths through
+ File file = new File(altDDPath);
+ if (!file.exists() || !file.isAbsolute())
+ {
+ // Should be an relative to the top deployment
+ VFSDeploymentUnit topUnit = unit.getTopLevel();
+ if (topUnit == unit)
+ throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
+ altDD = topUnit.getFile(altDDPath);
+ if (altDD == null)
+ throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
+ File webInf = new File(expWarUrl.toURI());
+ File altDDFile = new File(webInf, "WEB-INF/" + altDD.getName());
+ log.debug("Copying the altDD to: " + altDDFile);
+ Files.copy(altDD.toURL(), altDDFile);
+ metaData.setAlternativeDD(altDDFile.getAbsolutePath());
+ }
+ }
+ }
+
+ ClassLoadingMetaData classLoading = metaData.getClassLoading();
+ if (classLoading == null)
+ classLoading = new ClassLoadingMetaData();
+ // pass in the java2ClassLoadingCompliance if it was not set at the war level
+ if (classLoading.wasJava2ClassLoadingComplianceSet() == false)
+ classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
+ metaData.setClassLoading(classLoading);
+
+ // Build the context root if its not been set or is specified at the ear
+ String webContext = metaData.getContextRoot();
+ webContext = buildWebContext(webContext, warName, metaData, unit);
+ metaData.setContextRoot(webContext);
+
+ AbstractWarDeployment deployment = getDeployment(unit, metaData);
+ deployment.setMainDeployer(mainDeployer);
+ // TODO: until deployment is a MC bean
+ deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
+ deployWebModule(unit, metaData, deployment);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Failed to create web module", e);
+ }
+ }
+
+ /**
+ * Cleanup war deployer specifics.
+ */
+ @Override
+ public void undeploy(VFSDeploymentUnit unit, JBossWebMetaData metaData)
+ {
+ try
+ {
+ // Delete any expanded war
+ URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+ if (warURL != null)
+ {
+ File war = new File(warURL.toURI());
+ Files.delete(war);
+ }
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to remove expanded war", e);
+ }
+ /* Clear class loader refs
+ metaData.setContextLoader(null);
+ metaData.setResourceClassLoader(null);
+ metaData.setENCLoader(null);
+ */
+ }
+
+ public void addDeployedApp(String warURL, WebApplication webApp)
+ {
+ deploymentMap.put(warURL, webApp);
+ }
+
+ /** Get the WebApplication object for a deployed war.
+ @param warUrl the war url string as originally passed to deploy().
+ @return The WebApplication created during the deploy step if the
+ warUrl is valid, null if no such deployment exists.
+ */
+ public WebApplication getDeployedApp(String warUrl)
+ {
+ WebApplication appInfo = (WebApplication)deploymentMap.get(warUrl);
+ return appInfo;
+ }
+
+ public WebApplication removeDeployedApp(String warURL)
+ {
+ WebApplication appInfo = (WebApplication)deploymentMap.remove(warURL);
+ return appInfo;
+ }
+
+ /** Returns the applications deployed by the web container subclasses.
+ @jmx:managed-attribute
+ @return An Iterator of WebApplication objects for the deployed wars.
+ */
+ public Iterator getDeployedApplications()
+ {
+ return deploymentMap.values().iterator();
+ }
+
+ /** A utility method that uses reflection to access a URL[] getURLs method
+ * so that non-URLClassLoader class loaders that support this method can
+ * provide info.
+ */
+ public static URL[] getClassLoaderURLs(ClassLoader cl)
+ {
+ URL[] urls = {};
+ try
+ {
+ Class returnType = urls.getClass();
+ Class[] parameterTypes = {};
+ Method getURLs = cl.getClass().getMethod("getURLs", parameterTypes);
+ if (returnType.isAssignableFrom(getURLs.getReturnType()))
+ {
+ Object[] args = {};
+ urls = (URL[])getURLs.invoke(cl, args);
+ }
+ if (urls == null || urls.length == 0)
+ {
+ getURLs = cl.getClass().getMethod("getAllURLs", parameterTypes);
+ if (returnType.isAssignableFrom(getURLs.getReturnType()))
+ {
+ Object[] args = {};
+ urls = (URL[])getURLs.invoke(cl, args);
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+ return urls;
+ }
+
+ /** This method creates a context-root string from either the
+ WEB-INF/jboss-web.xml context-root element is one exists, or the
+ filename portion of the warURL. It is called if the deployment
+ webContext value is null which indicates a standalone war deployment.
+ A war name of ROOT.war is handled as a special case of a war that
+ should be installed as the default web context.
+ @param ctxPath - war level context-root
+ @param warName -
+ */
+ protected String buildWebContext(String ctxPath, String warName, JBossWebMetaData metaData, VFSDeploymentUnit unit)
+ {
+ // Build a war root context from the war name if one was not specified
+ String webContext = ctxPath;
+
+ // Build the context from the deployment name
+ if (webContext == null)
+ {
+ // Build the context from the war name, strip the .war suffix
+ webContext = warName;
+ webContext = webContext.replace('\\', '/');
+ if (webContext.endsWith("/"))
+ webContext = webContext.substring(0, webContext.length() - 1);
+ int prefix = webContext.lastIndexOf('/');
+ if (prefix > 0)
+ webContext = webContext.substring(prefix + 1);
+ int suffix = webContext.lastIndexOf(".war");
+ if (suffix > 0)
+ webContext = webContext.substring(0, suffix);
+ // Strip any '<int-value>.' prefix
+ int index = 0;
+ for (; index < webContext.length(); index++)
+ {
+ char c = webContext.charAt(index);
+ if (Character.isDigit(c) == false && c != '.')
+ break;
+ }
+ webContext = webContext.substring(index);
+ }
+
+ // Servlet containers are anal about the web context starting with '/'
+ if (webContext.length() > 0 && webContext.charAt(0) != '/')
+ webContext = "/" + webContext;
+ // And also the default root context must be an empty string, not '/'
+ else if (webContext.equals("/"))
+ webContext = "";
+ return webContext;
+ }
+
+ /**
+ * TODO: The use of an MBeanServer needs to be removed
+ * @return
+ */
+ @Deprecated
+ protected MBeanServer getServer()
+ {
+ return server;
+ }
+
+ public MainDeployerStructure getMainDeployer()
+ {
+ return mainDeployer;
+ }
+
+ public void setMainDeployer(MainDeployerStructure mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
+
+ /**
+ * Get the object name of the ServiceMetaData instance associated with
+ * the WebMetaData. This uses the pattern:
+ * "jboss.web.deployment:war="+metaData.getContextRoot()
+ *
+ * @param metaData - the web app metaData
+ * @return "jboss.web.deployment:war="+metaData.getContextRoot();
+ */
+ protected String getObjectName(JBossWebMetaData metaData)
+ {
+ String ctxPath = metaData.getContextRoot();
+ // The ctx path value cannot be empty in the object name
+ if (ctxPath == null || ctxPath.length() == 0)
+ ctxPath = "/";
+ String objectName = "jboss.web.deployment:war=" + ctxPath;
+ return objectName;
+ }
+
+ /**
+ * Called by deploy first to create a ServiceMetaData instance that wraps the
+ * AbstractWarDeployment bean and then attach it to the deployment unit. The
+ * presence of the ServiceMetaData attachment makes the deployment unit
+ * "relevant" to the deployers that handle mbean services.
+ *
+ * @param unit - the deployment unit
+ * @param metaData - the web app metadata passed to deploy
+ * @param deployment - the web app deployment bean created by getDeployment
+ * @throws Exception
+ */
+ protected void deployWebModule(VFSDeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception
+ {
+ log.debug("deployWebModule: " + unit.getName());
+ try
+ {
+ ServiceMetaData webModule = new ServiceMetaData();
+ String name = getObjectName(metaData);
+ ObjectName objectName = new ObjectName(name);
+ webModule.setObjectName(objectName);
+ webModule.setCode(WebModule.class.getName());
+ // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
+ ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
+ constructor.setSignature(new String[] { VFSDeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() });
+ constructor.setParameters(new Object[] { unit, this, deployment });
+ webModule.setConstructor(constructor);
+
+ List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>();
+
+ ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
+ attr.setName("SecurityManagement");
+ ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName());
+ attr.setValue(injectionValue);
+ attrs.add(attr);
+
+ ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData();
+ attrPR.setName("PolicyRegistration");
+ ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName());
+ attrPR.setValue(injectionValuePR);
+ attrs.add(attrPR);
+
+ ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData();
+ attrKernel.setName("Kernel");
+ ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME);
+ attrKernel.setValue(injectionValueKernel);
+ attrs.add(attrKernel);
+
+ webModule.setAttributes(attrs);
+
+ // Dependencies...Still have old jmx names here
+ Collection<String> depends = metaData.getDepends();
+ List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
+ if (depends != null && depends.isEmpty() == false)
+ {
+ if (log.isTraceEnabled())
+ log.trace(name + " has dependencies: " + depends);
+
+ for (String iDependOn : depends)
+ {
+ ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
+ sdmd.setIDependOn(iDependOn);
+ dependencies.add(sdmd);
+ }
+ }
+ webModule.setDependencies(dependencies);
+
+ // Here's where a bit of magic happens. By attaching the ServiceMetaData
+ // to the deployment, we now make the deployment "relevant" to
+ // deployers that use ServiceMetaData as an input (e.g. the
+ // org.jboss.system.deployers.ServiceDeployer). Those deployers
+ // can now take over deploying the web module.
+
+ unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class);
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,86 +1,86 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployers;
-
-/**
- * MBean interface.
- * @see org.jboss.web.AbstractWebDeployer
- */
-public interface AbstractWarDeployerMBean
-{
-
- /**
- * Get the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.
- * @return true for parent first, false for the servlet 2.3 model
- */
- boolean getJava2ClassLoadingCompliance() ;
-
- /**
- * Set the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.
- * @param flag true for parent first, false for the servlet 2.3 model
- */
- void setJava2ClassLoadingCompliance(boolean flag) ;
-
- /**
- * Set the flag indicating if war archives should be unpacked. This may need to be set to false as long extraction paths under deploy can show up as deployment failures on some platforms.
- * @return true is war archives should be unpacked */
- boolean getUnpackWars() ;
-
- /**
- * Get the flag indicating if war archives should be unpacked. This may need to be set to false as long extraction paths under deploy can show up as deployment failures on some platforms.
- * @param flag , true is war archives should be unpacked */
- void setUnpackWars(boolean flag) ;
-
- /**
- * Get the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
- * @return the LenientEjbLink flag
- */
- boolean getLenientEjbLink() ;
-
- /**
- * Set the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
- */
- void setLenientEjbLink(boolean flag) ;
-
- /**
- * Get the default security domain implementation to use if a war does not declare a security-domain.
- * @return jndi name of the security domain binding to use.
- */
- java.lang.String getDefaultSecurityDomain() ;
-
- /**
- * Set the default security domain implementation to use if a war does not declare a security-domain.
- * @param defaultSecurityDomain - jndi name of the security domain binding to use.
- */
- void setDefaultSecurityDomain(java.lang.String defaultSecurityDomain) ;
-
- /**
- * Get the session attribute number under which the caller Subject is stored
- */
- java.lang.String getSubjectAttributeName() ;
-
- /**
- * Set the session attribute number under which the caller Subject is stored
- */
- void setSubjectAttributeName(java.lang.String subjectAttributeName) ;
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployers;
+
+/**
+ * MBean interface.
+ * @see org.jboss.web.AbstractWebDeployer
+ */
+public interface AbstractWarDeployerMBean
+{
+
+ /**
+ * Get the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.
+ * @return true for parent first, false for the servlet 2.3 model
+ */
+ boolean getJava2ClassLoadingCompliance() ;
+
+ /**
+ * Set the flag indicating if the normal Java2 parent first class loading model should be used over the servlet 2.3 web container first model.
+ * @param flag true for parent first, false for the servlet 2.3 model
+ */
+ void setJava2ClassLoadingCompliance(boolean flag) ;
+
+ /**
+ * Set the flag indicating if war archives should be unpacked. This may need to be set to false as long extraction paths under deploy can show up as deployment failures on some platforms.
+ * @return true is war archives should be unpacked */
+ boolean getUnpackWars() ;
+
+ /**
+ * Get the flag indicating if war archives should be unpacked. This may need to be set to false as long extraction paths under deploy can show up as deployment failures on some platforms.
+ * @param flag , true is war archives should be unpacked */
+ void setUnpackWars(boolean flag) ;
+
+ /**
+ * Get the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
+ * @return the LenientEjbLink flag
+ */
+ boolean getLenientEjbLink() ;
+
+ /**
+ * Set the flag indicating if ejb-link errors should be ignored in favour of trying the jndi-name in jboss-web.xml
+ */
+ void setLenientEjbLink(boolean flag) ;
+
+ /**
+ * Get the default security domain implementation to use if a war does not declare a security-domain.
+ * @return jndi name of the security domain binding to use.
+ */
+ java.lang.String getDefaultSecurityDomain() ;
+
+ /**
+ * Set the default security domain implementation to use if a war does not declare a security-domain.
+ * @param defaultSecurityDomain - jndi name of the security domain binding to use.
+ */
+ void setDefaultSecurityDomain(java.lang.String defaultSecurityDomain) ;
+
+ /**
+ * Get the session attribute number under which the caller Subject is stored
+ */
+ java.lang.String getSubjectAttributeName() ;
+
+ /**
+ * Set the session attribute number under which the caller Subject is stored
+ */
+ void setSubjectAttributeName(java.lang.String subjectAttributeName) ;
+
+}
Property changes on: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployerMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,981 +1,981 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployers;
-
-// $Id: $
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NamingException;
-
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb.EjbUtil50;
-import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.EJBLocalReferenceMetaData;
-import org.jboss.metadata.javaee.spec.EJBLocalReferencesMetaData;
-import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.EJBReferencesMetaData;
-import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
-import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData;
-import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
-import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
-import org.jboss.metadata.serviceref.ServiceReferenceHandler;
-import org.jboss.metadata.serviceref.VirtualFileAdaptor;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.naming.NonSerializableFactory;
-import org.jboss.naming.Util;
-import org.jboss.security.ISecurityManagement;
-import org.jboss.security.SecurityConstants;
-import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.web.WebApplication;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.omg.CORBA.ORB;
-
-/**
-An abstract web app deployment bean. Subclasses implement:
-
-- init(Object) to initialize from the deployment configuration java bean passed
-in from the AbstractWarDeployer instance.
-- performDeploy(WebApplication webApp, String warUrl) to translate the
-WebApplication data into a running web application. This is called when the
-AbstractWarDeployment is started.
-- performUndeploy(WebApplication webApp, String warUrl) to remove the application
-corresponding to the WebApplication data. This is called when the
-AbstractWarDeployment is stopped.
-
-The one thing to be aware of is the relationship between the thread context
-class loader and the JNDI ENC context. Any method that attempts to access
-the JNDI ENC context must have the ClassLoader in the WebApplication returned
-from the {@link #performDeploy(WebApplication, String, WebDescriptorParser) performDeploy} as its thread
-context ClassLoader or else the lookup for java:comp/env will fail with a
-name not found exception, or worse, it will receive some other web application
-ENC context.
-TODO: the enc should be managed outside of the container without relying
-on the TCL behavior.
-
- at author Scott.Stark at jboss.org
- at author Anil.Saldhana at redhat.com
- at author adrian at jboss.org
- at version $Revision: 57455 $
-*/
-public abstract class AbstractWarDeployment
-{
- public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
- protected Logger log;
-
- protected MBeanServer server;
- protected MainDeployerStructure mainDeployer;
- // servlet context attributes
- protected Kernel kernel;
- protected DeploymentUnit unit;
-
- /**
- * The parent class loader first model flag
- */
- protected boolean java2ClassLoadingCompliance = false;
- /**
- * A flag indicating if war archives should be unpacked
- */
- protected boolean unpackWars = true;
- /**
- * If true, ejb-links that don't resolve don't cause an error (fallback to
- * jndi-name)
- */
- protected boolean lenientEjbLink = false;
-
- /**
- * The default security-domain name to use
- */
- protected String defaultSecurityDomain;
-
- /** The Security PolicyRegistration Name **/
- protected String policyRegistrationName;
-
- /** The Security PolicyRegistration **/
- protected PolicyRegistration policyRegistration;
-
- /** The security management name */
- protected String securityManagementName;
-
- /** The security management */
- protected ISecurityManagement securityManagement;
-
- private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
-
- public AbstractWarDeployment()
- {
- log = Logger.getLogger(getClass());
- }
-
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
- public void setDeploymentUnit(DeploymentUnit unit)
- {
- this.unit = unit;
- }
-
- /**
- * Utility method that builds a string url based on the ServerConfig.SERVER_HOME_URL system
- * property and the input url. If the input url is under the SERVER_HOME_URL, the SERVER_HOME_URL
- * prefix is replaced with ".../".
- * @param warUrl
- * @return the possibly shorted war url string.
- */
- public static String shortWarUrlFromServerHome(String warUrl)
- {
- String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
-
- if (warUrl == null || serverHomeUrl == null)
- return warUrl;
-
- if (warUrl.startsWith(serverHomeUrl))
- return ".../" + warUrl.substring(serverHomeUrl.length());
- else
- return warUrl;
- }
-
- /**
- * Initialize the deployment using an instance specific configuration object.
- * @param containerConfig
- * @throws Exception
- */
- public abstract void init(Object containerConfig) throws Exception;
-
- public MBeanServer getServer()
- {
- return server;
- }
-
- public void setServer(MBeanServer server)
- {
- this.server = server;
- }
-
- public MainDeployerStructure getMainDeployer()
- {
- return mainDeployer;
- }
-
- public void setMainDeployer(MainDeployerStructure mainDeployer)
- {
- this.mainDeployer = mainDeployer;
- }
-
- /**
- * Get the flag indicating if the normal Java2 parent first class loading
- * model should be used over the servlet 2.3 web container first model.
- * @return true for parent first, false for the servlet 2.3 model
- * @jmx.managed-attribute
- */
- public boolean getJava2ClassLoadingCompliance()
- {
- return java2ClassLoadingCompliance;
- }
-
- /**
- * Set the flag indicating if the normal Java2 parent first class loading
- * model should be used over the servlet 2.3 web container first model.
- * @param flag true for parent first, false for the servlet 2.3 model
- * @jmx.managed-attribute
- */
- public void setJava2ClassLoadingCompliance(boolean flag)
- {
- java2ClassLoadingCompliance = flag;
- }
-
- /**
- * Get the flag indicating if war archives should be unpacked. This may need
- * to be set to false as long extraction paths under deploy can show up as
- * deployment failures on some platforms.
- * @return true is war archives should be unpacked
- * @jmx.managed-attribute
- */
- public boolean getUnpackWars()
- {
- return unpackWars;
- }
-
- /**
- * Get the flag indicating if war archives should be unpacked. This may need
- * to be set to false as long extraction paths under deploy can show up as
- * deployment failures on some platforms.
- * @param flag , true is war archives should be unpacked
- * @jmx.managed-attribute
- */
- public void setUnpackWars(boolean flag)
- {
- this.unpackWars = flag;
- }
-
- /**
- * Get the flag indicating if ejb-link errors should be ignored in favour of
- * trying the jndi-name in jboss-web.xml
- * @return a <code>boolean</code> value
- * @jmx.managed-attribute
- */
- public boolean getLenientEjbLink()
- {
- return lenientEjbLink;
- }
-
- /**
- * Set the flag indicating if ejb-link errors should be ignored in favour of
- * trying the jndi-name in jboss-web.xml
- * @jmx.managed-attribute
- */
- public void setLenientEjbLink(boolean flag)
- {
- lenientEjbLink = flag;
- }
-
- /**
- * Get the default security domain implementation to use if a war does not
- * declare a security-domain.
- * @return jndi name of the security domain binding to use.
- * @jmx.managed-attribute
- */
- public String getDefaultSecurityDomain()
- {
- if(defaultSecurityDomain == null)
- throw new IllegalStateException("Default Security Domain is null");
- return defaultSecurityDomain;
- }
-
- /**
- * Set the default security domain implementation to use if a war does not
- * declare a security-domain.
- * @param defaultSecurityDomain - jndi name of the security domain binding to
- * use.
- * @jmx.managed-attribute
- */
- public void setDefaultSecurityDomain(String defaultSecurityDomain)
- {
- this.defaultSecurityDomain = defaultSecurityDomain;
- }
-
- protected PersistenceUnitDependencyResolver getPersistenceUnitDependencyResolver()
- {
- return persistenceUnitDependencyResolver;
- }
-
- @Inject
- public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
- {
- this.persistenceUnitDependencyResolver = resolver;
- }
-
- /**
- * Get the Policy Registration Name
- * @return
- */
- public String getPolicyRegistrationName()
- {
- return policyRegistrationName;
- }
-
- /**
- * Set the Policy Registration Name
- * @param policyRegistrationName
- */
- public void setPolicyRegistrationName(String policyRegistrationName)
- {
- this.policyRegistrationName = policyRegistrationName;
- }
-
- /**
- * Get the PolicyRegistration Bean
- * @return
- */
- public PolicyRegistration getPolicyRegistration()
- {
- return policyRegistration;
- }
-
- /**
- * Set the PolicyRegistration Bean
- * @param policyRegistration
- */
- public void setPolicyRegistration(PolicyRegistration policyRegistration)
- {
- this.policyRegistration = policyRegistration;
- }
-
- /**
- * Get the securityManagement.
- *
- * @return the securityManagement.
- */
- public String getSecurityManagementName()
- {
- return securityManagementName;
- }
-
- /**
- * Set the securityManagement.
- *
- * @param securityManagement the securityManagement.
- */
- public void setSecurityManagementName(String securityManagement)
- {
- this.securityManagementName = securityManagement;
- }
-
- /**
- * Get the securityManagement.
- *
- * @return the securityManagement.
- */
- public ISecurityManagement getSecurityManagement()
- {
- return securityManagement;
- }
-
- /**
- * Set the securityManagement.
- *
- * @param securityManagement the securityManagement.
- */
- public void setSecurityManagement(ISecurityManagement securityManagement)
- {
- this.securityManagement = securityManagement;
- }
-
- /**
- * A template pattern implementation of the deploy() method. This method
- * calls the {@link #performDeploy(WebApplication, String,
- * WebDescriptorParser) performDeploy()} method to perform the container
- * specific deployment steps and registers the returned WebApplication in the
- * deployment map. The steps performed are:
- *
- * ClassLoader appClassLoader = thread.getContextClassLoader();
- * URLClassLoader warLoader = URLClassLoader.newInstance(empty,
- * appClassLoader); thread.setContextClassLoader(warLoader);
- * WebDescriptorParser webAppParser = ...; WebMetaData metaData =
- * di.metaData; // Create JACC permissions, contextID, etc. ...
- * WebApplication warInfo = new WebApplication(metaData);
- * performDeploy(warInfo, warUrl, webAppParser); deploymentMap.put(warUrl,
- * warInfo); thread.setContextClassLoader(appClassLoader);
- *
- * The subclass performDeploy() implementation needs to invoke
- * processEnc(loader, warInfo) to have the JNDI
- * java:comp/env namespace setup before any web app component can access this
- * namespace.
- *
- * Also, an MBean for each servlet deployed should be created and its JMX
- * ObjectName placed into the DeploymentInfo.mbeans list so that the JSR77
- * layer can create the approriate model view. The servlet MBean needs to
- * provide access to the min, max and total time in milliseconds. Expose this
- * information via MinServiceTime, MaxServiceTime and TotalServiceTime
- * attributes to integrate seemlessly with the JSR77 factory layer.
- * @param unit The deployment info that contains the context-root element value
- * from the J2EE application/module/web application.xml descriptor. This may
- * be null if war was is not being deployed as part of an enterprise
- * application. It also contains the URL of the web application war.
- */
- public synchronized WebApplication start(VFSDeploymentUnit unit, JBossWebMetaData metaData)
- throws Exception
- {
- Thread thread = Thread.currentThread();
- ClassLoader appClassLoader = thread.getContextClassLoader();
- WebApplication webApp = null;
- try
- {
- // Create a classloader for the war to ensure a unique ENC
- // TODO: this should be handled by the WarClassLoaderDeployer
- /*
- VirtualFile root = unit.getRoot();
- URL[] empty = {root.toURL()};
- URLClassLoader warLoader = URLClassLoader.newInstance(empty, unit.getClassLoader());
- */
- ClassLoader warLoader = unit.getClassLoader();
- thread.setContextClassLoader(warLoader);
- String webContext = metaData.getContextRoot();
-
- // Get the war URL
- // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
- URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
- if (warURL == null)
- warURL = unit.getRoot().toURL();
-
- // Strip any jar: url syntax. This should be be handled by the vfs
- String warURLString = warURL.toString();
- if( warURLString.startsWith("jar:") )
- warURLString = warURLString.substring(4, warURLString.length()-2);
-
- log.debug("webContext: " + webContext);
- log.debug("warURL: " + warURLString);
-
- // Register the permissions with the JACC layer
- String contextID = metaData.getJaccContextID();
- if( contextID == null )
- contextID = unit.getSimpleName();
- metaData.setJaccContextID(contextID);
-
- webApp = new WebApplication(metaData);
- webApp.setClassLoader(warLoader);
- webApp.setDeploymentUnit(unit);
- performDeploy(webApp, warURLString);
- }
- finally
- {
- thread.setContextClassLoader(appClassLoader);
- }
- return webApp;
- }
-
- /**
- * A template pattern implementation of the undeploy() method. This method
- * calls the {@link #performUndeploy(String, WebApplication)
- * performUndeploy()} method to perform the container specific undeployment
- * steps and unregisters the the warUrl from the deployment map.
- */
- public synchronized void stop(DeploymentUnit di, WebApplication webApp)
- throws Exception
- {
- URL warURL = webApp.getURL();
- String warUrl = warURL.toString();
- performUndeploy(webApp, warUrl);
- }
-
- /**
- * This method is called by the start() method template and must be
- * overriden by subclasses to perform the web container specific deployment
- * steps.
- * @param webApp The web application information context. This contains the
- * metadata such as the context-root element value from the J2EE
- * application/module/web application.xml descriptor and virtual-host.
- * @param warUrl The string for the URL of the web application war.
- */
- protected abstract void performDeploy(WebApplication webApp, String warUrl) throws Exception;
- /**
- * Called as part of the stop() method template to ask the subclass for
- * perform the web container specific undeployment steps.
- * @param webApp The web application information context. This contains the
- * metadata such as the context-root element value from the J2EE
- * application/module/web application.xml descriptor and virtual-host.
- * @param warUrl The string for the URL of the web application war.
- */
- protected abstract void performUndeploy(WebApplication webApp, String warUrl)
- throws Exception;
-
- /**
- * This method is invoked from within subclass performDeploy() method
- * implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().
- * @param loader the ClassLoader for the web application. May not be null.
- * @param metaData the WebMetaData from the WebApplication object passed to
- * the performDeploy method.
- */
- protected void processEnc(ClassLoader loader, WebApplication webApp)
- throws Exception
- {
- if(loader == null)
- throw new IllegalArgumentException("Classloader passed to process ENC refs is null");
- log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
- InitialContext iniCtx = new InitialContext();
- Context envCtx = null;
- Thread currentThread = Thread.currentThread();
- ClassLoader currentLoader = currentThread.getContextClassLoader();
- JBossWebMetaData metaData = webApp.getMetaData();
- try
- {
- // Create a java:comp/env environment unique for the web application
- log.debug("Creating ENC using ClassLoader: " + loader);
- ClassLoader parent = loader.getParent();
- while (parent != null)
- {
- log.debug(".." + parent);
- parent = parent.getParent();
- }
- // TODO: The enc should be an input?
- currentThread.setContextClassLoader(loader);
- //webApp.setENCLoader(loader);
- envCtx = (Context) iniCtx.lookup("java:comp");
-
- // TODO: inject the ORB
- 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());
- }
-
- // TODO: injection, Add a link to the global transaction manager
- envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
- log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
- envCtx = envCtx.createSubcontext("env");
- processEncReferences(webApp, envCtx);
- }
- finally
- {
- currentThread.setContextClassLoader(currentLoader);
- }
-
- String securityDomain = metaData.getSecurityDomain();
- log.debug("linkSecurityDomain");
- linkSecurityDomain(securityDomain, envCtx);
- log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
- }
-
- protected void processEncReferences(WebApplication webApp, Context envCtx)
- throws ClassNotFoundException, NamingException
- {
- VFSDeploymentUnit unit = webApp.getDeploymentUnit();
- JBossWebMetaData metaData = webApp.getMetaData();
- EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries();
- log.debug("addEnvEntries");
- addEnvEntries(envEntries, envCtx);
- ResourceEnvironmentReferencesMetaData resourceEnvRefs = metaData.getResourceEnvironmentReferences();
- log.debug("linkResourceEnvRefs");
- linkResourceEnvRefs(resourceEnvRefs, envCtx);
- ResourceReferencesMetaData resourceRefs = metaData.getResourceReferences();
- log.debug("linkResourceRefs");
- linkResourceRefs(resourceRefs, envCtx);
- log.debug("linkMessageDestinationRefs");
- MessageDestinationReferencesMetaData msgRefs = metaData.getMessageDestinationReferences();
- linkMessageDestinationRefs(unit, msgRefs, envCtx);
- EJBReferencesMetaData ejbRefs = metaData.getEjbReferences();
- log.debug("linkEjbRefs");
- linkEjbRefs(unit, ejbRefs, envCtx);
- EJBLocalReferencesMetaData ejbLocalRefs = metaData.getEjbLocalReferences();
- log.debug("linkEjbLocalRefs");
- linkEjbLocalRefs(unit, ejbLocalRefs, envCtx);
- log.debug("linkServiceRefs");
- ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences();
- linkServiceRefs(unit, serviceRefs, envCtx);
- }
-
- private void linkServiceRefs(VFSDeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
- {
- ClassLoader loader = unit.getClassLoader();
- UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
- for(ServiceReferenceMetaData sref : serviceRefs)
- {
- String refName = sref.getServiceRefName();
- new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
- }
- }
-
- protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx)
- throws ClassNotFoundException, NamingException
- {
- for (EnvironmentEntryMetaData entry : envEntries)
- {
- log.debug("Binding env-entry: " + entry.getName() + " of type: " +
- entry.getType() + " to value:" + entry.getValue());
- bindEnvEntry(envCtx, entry);
- }
- }
-
- protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx)
- throws NamingException
- {
- for(ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs)
- {
- String resourceName = ref.getJndiName();
- String refName = ref.getResourceEnvRefName();
- if (ref.getType().equals("java.net.URL"))
- {
- try
- {
- log.debug("Binding '" + refName + "' to URL: " + resourceName);
- URL url = new URL(resourceName);
- Util.bind(envCtx, refName, url);
- }
- catch (MalformedURLException e)
- {
- throw new NamingException("Malformed URL:" + e.getMessage());
- }
- }
- else if (resourceName != null)
- {
- log.debug("Linking '" + refName + "' to JNDI name: " + resourceName);
- Util.bind(envCtx, refName, new LinkRef(resourceName));
- }
- else
- {
- throw new NamingException("resource-env-ref: " + refName
- + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
- }
- }
- }
-
- protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx)
- throws NamingException
- {
- for(ResourceReferenceMetaData ref : resourceRefs)
- {
- String jndiName = ref.getJndiName();
- String refName = ref.getResourceName();
- if (ref.getType().equals("java.net.URL"))
- {
- try
- {
- String resURL = ref.getResUrl();
- if (resURL != null)
- {
- log.debug("Binding '" + refName + "' to URL: " + resURL);
- URL url = new URL(resURL);
- Util.bind(envCtx, refName, url);
- }
- else
- {
- log.debug("Linking '" + refName + "' to URL: " + resURL);
- LinkRef urlLink = new LinkRef(jndiName);
- Util.bind(envCtx, refName, urlLink);
- }
- }
- catch (MalformedURLException e)
- {
- throw new NamingException("Malformed URL:" + e.getMessage());
- }
- }
- else if (jndiName != null)
- {
- log.debug("Linking '" + refName + "' to JNDI name: " + jndiName);
- Util.bind(envCtx, refName, new LinkRef(jndiName));
- }
- else
- {
- throw new NamingException("resource-ref: " + refName
- + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
- }
- }
- }
-
- protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx)
- throws NamingException
- {
- for(MessageDestinationReferenceMetaData ref : msgRefs)
- {
- String refName = ref.getName();
- String jndiName = ref.getJndiName();
- String link = ref.getLink();
- if (link != null)
- {
- if (jndiName == null)
- {
- MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link);
- if (messageDestination == null)
- throw new NamingException("message-destination-ref '" + refName +
- "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml");
- else
- {
- String linkJNDIName = messageDestination.getJndiName();
- if (linkJNDIName == null)
- log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml");
- else
- jndiName = linkJNDIName;
- }
- }
- else
- log.warn("message-destination-ref '" + refName +
- "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml");
- }
- else if (jndiName == null)
- throw new NamingException("message-destination-ref '" + refName +
- "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml");
- Util.bind(envCtx, refName, new LinkRef(jndiName));
- }
- }
-
- protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx)
- throws NamingException
- {
- for(EJBReferenceMetaData ejb : ejbRefs)
- {
- String name = ejb.getName();
- String linkName = ejb.getLink();
- String jndiName = null;
-
- //use ejb-link if it is specified
- if (linkName != null)
- {
- jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName);
-
- //if flag does not allow misconfigured ejb-links, it is an error
- if ((jndiName == null) && !(getLenientEjbLink()))
- throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
- }
-
-
- //fall through to the jndiName
- if (jndiName == null)
- {
- jndiName = ejb.getJndiName();
- if (jndiName == null)
- throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml");
- }
-
- log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName);
- Util.bind(envCtx, name, new LinkRef(jndiName));
- }
- }
-
- protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx)
- throws NamingException
- {
- for(EJBLocalReferenceMetaData ejb : ejbLocalRefs)
- {
- String name = ejb.getName();
- String linkName = ejb.getLink();
- String jndiName = null;
-
- //use the ejb-link field if it is specified
- if (linkName != null)
- {
- jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName);
-
- //if flag does not allow misconfigured ejb-links, it is an error
- if ((jndiName == null) && !(getLenientEjbLink()))
- throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
- }
-
-
- if (jndiName == null)
- {
- jndiName = ejb.getJndiName();
- if (jndiName == null)
- {
- String msg = null;
- if (linkName == null)
- {
- msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and "
- + "no local-jndi-name in jboss-web.xml";
- }
- else
- {
- msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '"
- + linkName + "' failed to resolve to an ejb with a LocalHome";
- }
- throw new NamingException(msg);
- }
- }
-
- log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName);
- Util.bind(envCtx, name, new LinkRef(jndiName));
- }
- }
-
- /**
- * This creates a java:comp/env/security context that contains a 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 security-domain
- * element. If there was no security-domain element then the bindings are to
- * NullSecurityManager instance which simply allows all access.
- */
- protected void linkSecurityDomain(String securityDomain, Context envCtx)
- throws NamingException
- {
- if (securityDomain == null)
- {
- securityDomain = getDefaultSecurityDomain();
- log.debug("No security-domain given, using default: " + securityDomain);
- }
-
- //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
- if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
- securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain;
-
- log.debug("Linking security/securityMgr to JNDI name: " + securityDomain);
- Util.bind(envCtx, "security/securityMgr", new LinkRef(securityDomain));
- Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain+"/realmMapping"));
- Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain+"/authorizationMgr"));
- Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain));
- Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
- }
-
- /**
- * A utility method that searches the given loader for the resources:
- * "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd",
- * and "javax/ejb/EJBHome.class" and returns an array of URL strings. Any
- * jar: urls are reduced to the underlying <url> portion of the
- * 'jar:<url>!/{entry}' construct.
- */
- public String[] getStandardCompileClasspath(ClassLoader loader)
- {
- String[] jspResources = {
- "javax/servlet/resources/web-app_2_3.dtd",
- "org/apache/jasper/resources/jsp12.dtd",
- "javax/ejb/EJBHome.class"
- };
- ArrayList tmp = new ArrayList();
- for (int j = 0; j < jspResources.length; j++)
- {
- URL rsrcURL = loader.getResource(jspResources[j]);
- if (rsrcURL != null)
- {
- String url = rsrcURL.toExternalForm();
- if (rsrcURL.getProtocol().equals("jar"))
- {
- // Parse the jar:<url>!/{entry} URL
- url = url.substring(4);
- int seperator = url.indexOf('!');
- url = url.substring(0, seperator);
- }
- tmp.add(url);
- }
- else
- {
- log.warn("Failed to fin jsp rsrc: " + jspResources[j]);
- }
- }
- log.trace("JSP StandardCompileClasspath: " + tmp);
- String[] cp = new String[tmp.size()];
- tmp.toArray(cp);
- return cp;
- }
-
- /**
- * A utility method that walks up the ClassLoader chain starting at the given
- * loader and queries each ClassLoader for a 'URL[] getURLs()' method from
- * which a complete classpath of URL strings is built.
- */
- public String[] getCompileClasspath(ClassLoader loader)
- {
- HashSet tmp = new HashSet();
- ClassLoader cl = loader;
- while (cl != null)
- {
- URL[] urls = AbstractWarDeployer.getClassLoaderURLs(cl);
- addURLs(tmp, urls);
- cl = cl.getParent();
- }
- try
- {
- URL[] globalUrls = (URL[]) server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY,
- "URLs");
- addURLs(tmp, globalUrls);
- }
- catch (Exception e)
- {
- log.warn("Could not get global URL[] from default loader repository!", e);
- } // end of try-catch
- log.trace("JSP CompileClasspath: " + tmp);
- String[] cp = new String[tmp.size()];
- tmp.toArray(cp);
- return cp;
- }
-
- private void addURLs(Set urlSet, URL[] urls)
- {
- for (int u = 0; u < urls.length; u++)
- {
- URL url = urls[u];
- urlSet.add(url.toExternalForm());
- }
- }
-
- public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry)
- throws ClassNotFoundException, NamingException
- {
- ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader();
- Class type = loader.loadClass(entry.getType());
- if (type == String.class)
- {
- Util.bind(ctx, entry.getName(), entry.getValue());
- }
- else if (type == Integer.class)
- {
- Util.bind(ctx, entry.getName(), new Integer(entry.getValue()));
- }
- else if (type == Long.class)
- {
- Util.bind(ctx, entry.getName(), new Long(entry.getValue()));
- }
- else if (type == Double.class)
- {
- Util.bind(ctx, entry.getName(), new Double(entry.getValue()));
- }
- else if (type == Float.class)
- {
- Util.bind(ctx, entry.getName(), new Float(entry.getValue()));
- }
- else if (type == Byte.class)
- {
- Util.bind(ctx, entry.getName(), new Byte(entry.getValue()));
- }
- else if (type == Character.class)
- {
- Object value = null;
- String input = entry.getValue();
- if (input == null || input.length() == 0)
- {
- value = new Character((char) 0);
- }
- else
- {
- value = new Character(input.charAt(0));
- }
- Util.bind(ctx, entry.getName(), value);
- }
- else if (type == Short.class)
- {
- Util.bind(ctx, entry.getName(), new Short(entry.getValue()));
- }
- else if (type == Boolean.class)
- {
- Util.bind(ctx, entry.getName(), new Boolean(entry.getValue()));
- }
- else
- {
- // Default to a String type
- Util.bind(ctx, entry.getName(), entry.getValue());
- }
- }
-}
-
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployers;
+
+// $Id: $
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.LinkRef;
+import javax.naming.NamingException;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb.EjbUtil50;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EJBLocalReferenceMetaData;
+import org.jboss.metadata.javaee.spec.EJBLocalReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
+import org.jboss.metadata.serviceref.ServiceReferenceHandler;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.naming.NonSerializableFactory;
+import org.jboss.naming.Util;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.SecurityConstants;
+import org.jboss.security.authorization.PolicyRegistration;
+import org.jboss.web.WebApplication;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.omg.CORBA.ORB;
+
+/**
+An abstract web app deployment bean. Subclasses implement:
+
+- init(Object) to initialize from the deployment configuration java bean passed
+in from the AbstractWarDeployer instance.
+- performDeploy(WebApplication webApp, String warUrl) to translate the
+WebApplication data into a running web application. This is called when the
+AbstractWarDeployment is started.
+- performUndeploy(WebApplication webApp, String warUrl) to remove the application
+corresponding to the WebApplication data. This is called when the
+AbstractWarDeployment is stopped.
+
+The one thing to be aware of is the relationship between the thread context
+class loader and the JNDI ENC context. Any method that attempts to access
+the JNDI ENC context must have the ClassLoader in the WebApplication returned
+from the {@link #performDeploy(WebApplication, String, WebDescriptorParser) performDeploy} as its thread
+context ClassLoader or else the lookup for java:comp/env will fail with a
+name not found exception, or worse, it will receive some other web application
+ENC context.
+TODO: the enc should be managed outside of the container without relying
+on the TCL behavior.
+
+ at author Scott.Stark at jboss.org
+ at author Anil.Saldhana at redhat.com
+ at author adrian at jboss.org
+ at version $Revision: 57455 $
+*/
+public abstract class AbstractWarDeployment
+{
+ public static final String ERROR = "org.jboss.web.AbstractWebContainer.error";
+ protected Logger log;
+
+ protected MBeanServer server;
+ protected MainDeployerStructure mainDeployer;
+ // servlet context attributes
+ protected Kernel kernel;
+ protected DeploymentUnit unit;
+
+ /**
+ * The parent class loader first model flag
+ */
+ protected boolean java2ClassLoadingCompliance = false;
+ /**
+ * A flag indicating if war archives should be unpacked
+ */
+ protected boolean unpackWars = true;
+ /**
+ * If true, ejb-links that don't resolve don't cause an error (fallback to
+ * jndi-name)
+ */
+ protected boolean lenientEjbLink = false;
+
+ /**
+ * The default security-domain name to use
+ */
+ protected String defaultSecurityDomain;
+
+ /** The Security PolicyRegistration Name **/
+ protected String policyRegistrationName;
+
+ /** The Security PolicyRegistration **/
+ protected PolicyRegistration policyRegistration;
+
+ /** The security management name */
+ protected String securityManagementName;
+
+ /** The security management */
+ protected ISecurityManagement securityManagement;
+
+ private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+ public AbstractWarDeployment()
+ {
+ log = Logger.getLogger(getClass());
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public void setDeploymentUnit(DeploymentUnit unit)
+ {
+ this.unit = unit;
+ }
+
+ /**
+ * Utility method that builds a string url based on the ServerConfig.SERVER_HOME_URL system
+ * property and the input url. If the input url is under the SERVER_HOME_URL, the SERVER_HOME_URL
+ * prefix is replaced with ".../".
+ * @param warUrl
+ * @return the possibly shorted war url string.
+ */
+ public static String shortWarUrlFromServerHome(String warUrl)
+ {
+ String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
+
+ if (warUrl == null || serverHomeUrl == null)
+ return warUrl;
+
+ if (warUrl.startsWith(serverHomeUrl))
+ return ".../" + warUrl.substring(serverHomeUrl.length());
+ else
+ return warUrl;
+ }
+
+ /**
+ * Initialize the deployment using an instance specific configuration object.
+ * @param containerConfig
+ * @throws Exception
+ */
+ public abstract void init(Object containerConfig) throws Exception;
+
+ public MBeanServer getServer()
+ {
+ return server;
+ }
+
+ public void setServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ public MainDeployerStructure getMainDeployer()
+ {
+ return mainDeployer;
+ }
+
+ public void setMainDeployer(MainDeployerStructure mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
+
+ /**
+ * Get the flag indicating if the normal Java2 parent first class loading
+ * model should be used over the servlet 2.3 web container first model.
+ * @return true for parent first, false for the servlet 2.3 model
+ * @jmx.managed-attribute
+ */
+ public boolean getJava2ClassLoadingCompliance()
+ {
+ return java2ClassLoadingCompliance;
+ }
+
+ /**
+ * Set the flag indicating if the normal Java2 parent first class loading
+ * model should be used over the servlet 2.3 web container first model.
+ * @param flag true for parent first, false for the servlet 2.3 model
+ * @jmx.managed-attribute
+ */
+ public void setJava2ClassLoadingCompliance(boolean flag)
+ {
+ java2ClassLoadingCompliance = flag;
+ }
+
+ /**
+ * Get the flag indicating if war archives should be unpacked. This may need
+ * to be set to false as long extraction paths under deploy can show up as
+ * deployment failures on some platforms.
+ * @return true is war archives should be unpacked
+ * @jmx.managed-attribute
+ */
+ public boolean getUnpackWars()
+ {
+ return unpackWars;
+ }
+
+ /**
+ * Get the flag indicating if war archives should be unpacked. This may need
+ * to be set to false as long extraction paths under deploy can show up as
+ * deployment failures on some platforms.
+ * @param flag , true is war archives should be unpacked
+ * @jmx.managed-attribute
+ */
+ public void setUnpackWars(boolean flag)
+ {
+ this.unpackWars = flag;
+ }
+
+ /**
+ * Get the flag indicating if ejb-link errors should be ignored in favour of
+ * trying the jndi-name in jboss-web.xml
+ * @return a <code>boolean</code> value
+ * @jmx.managed-attribute
+ */
+ public boolean getLenientEjbLink()
+ {
+ return lenientEjbLink;
+ }
+
+ /**
+ * Set the flag indicating if ejb-link errors should be ignored in favour of
+ * trying the jndi-name in jboss-web.xml
+ * @jmx.managed-attribute
+ */
+ public void setLenientEjbLink(boolean flag)
+ {
+ lenientEjbLink = flag;
+ }
+
+ /**
+ * Get the default security domain implementation to use if a war does not
+ * declare a security-domain.
+ * @return jndi name of the security domain binding to use.
+ * @jmx.managed-attribute
+ */
+ public String getDefaultSecurityDomain()
+ {
+ if(defaultSecurityDomain == null)
+ throw new IllegalStateException("Default Security Domain is null");
+ return defaultSecurityDomain;
+ }
+
+ /**
+ * Set the default security domain implementation to use if a war does not
+ * declare a security-domain.
+ * @param defaultSecurityDomain - jndi name of the security domain binding to
+ * use.
+ * @jmx.managed-attribute
+ */
+ public void setDefaultSecurityDomain(String defaultSecurityDomain)
+ {
+ this.defaultSecurityDomain = defaultSecurityDomain;
+ }
+
+ protected PersistenceUnitDependencyResolver getPersistenceUnitDependencyResolver()
+ {
+ return persistenceUnitDependencyResolver;
+ }
+
+ @Inject
+ public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
+ {
+ this.persistenceUnitDependencyResolver = resolver;
+ }
+
+ /**
+ * Get the Policy Registration Name
+ * @return
+ */
+ public String getPolicyRegistrationName()
+ {
+ return policyRegistrationName;
+ }
+
+ /**
+ * Set the Policy Registration Name
+ * @param policyRegistrationName
+ */
+ public void setPolicyRegistrationName(String policyRegistrationName)
+ {
+ this.policyRegistrationName = policyRegistrationName;
+ }
+
+ /**
+ * Get the PolicyRegistration Bean
+ * @return
+ */
+ public PolicyRegistration getPolicyRegistration()
+ {
+ return policyRegistration;
+ }
+
+ /**
+ * Set the PolicyRegistration Bean
+ * @param policyRegistration
+ */
+ public void setPolicyRegistration(PolicyRegistration policyRegistration)
+ {
+ this.policyRegistration = policyRegistration;
+ }
+
+ /**
+ * Get the securityManagement.
+ *
+ * @return the securityManagement.
+ */
+ public String getSecurityManagementName()
+ {
+ return securityManagementName;
+ }
+
+ /**
+ * Set the securityManagement.
+ *
+ * @param securityManagement the securityManagement.
+ */
+ public void setSecurityManagementName(String securityManagement)
+ {
+ this.securityManagementName = securityManagement;
+ }
+
+ /**
+ * Get the securityManagement.
+ *
+ * @return the securityManagement.
+ */
+ public ISecurityManagement getSecurityManagement()
+ {
+ return securityManagement;
+ }
+
+ /**
+ * Set the securityManagement.
+ *
+ * @param securityManagement the securityManagement.
+ */
+ public void setSecurityManagement(ISecurityManagement securityManagement)
+ {
+ this.securityManagement = securityManagement;
+ }
+
+ /**
+ * A template pattern implementation of the deploy() method. This method
+ * calls the {@link #performDeploy(WebApplication, String,
+ * WebDescriptorParser) performDeploy()} method to perform the container
+ * specific deployment steps and registers the returned WebApplication in the
+ * deployment map. The steps performed are:
+ *
+ * ClassLoader appClassLoader = thread.getContextClassLoader();
+ * URLClassLoader warLoader = URLClassLoader.newInstance(empty,
+ * appClassLoader); thread.setContextClassLoader(warLoader);
+ * WebDescriptorParser webAppParser = ...; WebMetaData metaData =
+ * di.metaData; // Create JACC permissions, contextID, etc. ...
+ * WebApplication warInfo = new WebApplication(metaData);
+ * performDeploy(warInfo, warUrl, webAppParser); deploymentMap.put(warUrl,
+ * warInfo); thread.setContextClassLoader(appClassLoader);
+ *
+ * The subclass performDeploy() implementation needs to invoke
+ * processEnc(loader, warInfo) to have the JNDI
+ * java:comp/env namespace setup before any web app component can access this
+ * namespace.
+ *
+ * Also, an MBean for each servlet deployed should be created and its JMX
+ * ObjectName placed into the DeploymentInfo.mbeans list so that the JSR77
+ * layer can create the approriate model view. The servlet MBean needs to
+ * provide access to the min, max and total time in milliseconds. Expose this
+ * information via MinServiceTime, MaxServiceTime and TotalServiceTime
+ * attributes to integrate seemlessly with the JSR77 factory layer.
+ * @param unit The deployment info that contains the context-root element value
+ * from the J2EE application/module/web application.xml descriptor. This may
+ * be null if war was is not being deployed as part of an enterprise
+ * application. It also contains the URL of the web application war.
+ */
+ public synchronized WebApplication start(VFSDeploymentUnit unit, JBossWebMetaData metaData)
+ throws Exception
+ {
+ Thread thread = Thread.currentThread();
+ ClassLoader appClassLoader = thread.getContextClassLoader();
+ WebApplication webApp = null;
+ try
+ {
+ // Create a classloader for the war to ensure a unique ENC
+ // TODO: this should be handled by the WarClassLoaderDeployer
+ /*
+ VirtualFile root = unit.getRoot();
+ URL[] empty = {root.toURL()};
+ URLClassLoader warLoader = URLClassLoader.newInstance(empty, unit.getClassLoader());
+ */
+ ClassLoader warLoader = unit.getClassLoader();
+ thread.setContextClassLoader(warLoader);
+ String webContext = metaData.getContextRoot();
+
+ // Get the war URL
+ // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
+ URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+ if (warURL == null)
+ warURL = unit.getRoot().toURL();
+
+ // Strip any jar: url syntax. This should be be handled by the vfs
+ String warURLString = warURL.toString();
+ if( warURLString.startsWith("jar:") )
+ warURLString = warURLString.substring(4, warURLString.length()-2);
+
+ log.debug("webContext: " + webContext);
+ log.debug("warURL: " + warURLString);
+
+ // Register the permissions with the JACC layer
+ String contextID = metaData.getJaccContextID();
+ if( contextID == null )
+ contextID = unit.getSimpleName();
+ metaData.setJaccContextID(contextID);
+
+ webApp = new WebApplication(metaData);
+ webApp.setClassLoader(warLoader);
+ webApp.setDeploymentUnit(unit);
+ performDeploy(webApp, warURLString);
+ }
+ finally
+ {
+ thread.setContextClassLoader(appClassLoader);
+ }
+ return webApp;
+ }
+
+ /**
+ * A template pattern implementation of the undeploy() method. This method
+ * calls the {@link #performUndeploy(String, WebApplication)
+ * performUndeploy()} method to perform the container specific undeployment
+ * steps and unregisters the the warUrl from the deployment map.
+ */
+ public synchronized void stop(DeploymentUnit di, WebApplication webApp)
+ throws Exception
+ {
+ URL warURL = webApp.getURL();
+ String warUrl = warURL.toString();
+ performUndeploy(webApp, warUrl);
+ }
+
+ /**
+ * This method is called by the start() method template and must be
+ * overriden by subclasses to perform the web container specific deployment
+ * steps.
+ * @param webApp The web application information context. This contains the
+ * metadata such as the context-root element value from the J2EE
+ * application/module/web application.xml descriptor and virtual-host.
+ * @param warUrl The string for the URL of the web application war.
+ */
+ protected abstract void performDeploy(WebApplication webApp, String warUrl) throws Exception;
+ /**
+ * Called as part of the stop() method template to ask the subclass for
+ * perform the web container specific undeployment steps.
+ * @param webApp The web application information context. This contains the
+ * metadata such as the context-root element value from the J2EE
+ * application/module/web application.xml descriptor and virtual-host.
+ * @param warUrl The string for the URL of the web application war.
+ */
+ protected abstract void performUndeploy(WebApplication webApp, String warUrl)
+ throws Exception;
+
+ /**
+ * This method is invoked from within subclass performDeploy() method
+ * implementations when they invoke WebDescriptorParser.parseWebAppDescriptors().
+ * @param loader the ClassLoader for the web application. May not be null.
+ * @param metaData the WebMetaData from the WebApplication object passed to
+ * the performDeploy method.
+ */
+ protected void processEnc(ClassLoader loader, WebApplication webApp)
+ throws Exception
+ {
+ if(loader == null)
+ throw new IllegalArgumentException("Classloader passed to process ENC refs is null");
+ log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin");
+ InitialContext iniCtx = new InitialContext();
+ Context envCtx = null;
+ Thread currentThread = Thread.currentThread();
+ ClassLoader currentLoader = currentThread.getContextClassLoader();
+ JBossWebMetaData metaData = webApp.getMetaData();
+ try
+ {
+ // Create a java:comp/env environment unique for the web application
+ log.debug("Creating ENC using ClassLoader: " + loader);
+ ClassLoader parent = loader.getParent();
+ while (parent != null)
+ {
+ log.debug(".." + parent);
+ parent = parent.getParent();
+ }
+ // TODO: The enc should be an input?
+ currentThread.setContextClassLoader(loader);
+ //webApp.setENCLoader(loader);
+ envCtx = (Context) iniCtx.lookup("java:comp");
+
+ // TODO: inject the ORB
+ 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());
+ }
+
+ // TODO: injection, Add a link to the global transaction manager
+ envCtx.bind("UserTransaction", new LinkRef("UserTransaction"));
+ log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction");
+ envCtx = envCtx.createSubcontext("env");
+ processEncReferences(webApp, envCtx);
+ }
+ finally
+ {
+ currentThread.setContextClassLoader(currentLoader);
+ }
+
+ String securityDomain = metaData.getSecurityDomain();
+ log.debug("linkSecurityDomain");
+ linkSecurityDomain(securityDomain, envCtx);
+ log.debug("AbstractWebContainer.parseWebAppDescriptors, End");
+ }
+
+ protected void processEncReferences(WebApplication webApp, Context envCtx)
+ throws ClassNotFoundException, NamingException
+ {
+ VFSDeploymentUnit unit = webApp.getDeploymentUnit();
+ JBossWebMetaData metaData = webApp.getMetaData();
+ EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries();
+ log.debug("addEnvEntries");
+ addEnvEntries(envEntries, envCtx);
+ ResourceEnvironmentReferencesMetaData resourceEnvRefs = metaData.getResourceEnvironmentReferences();
+ log.debug("linkResourceEnvRefs");
+ linkResourceEnvRefs(resourceEnvRefs, envCtx);
+ ResourceReferencesMetaData resourceRefs = metaData.getResourceReferences();
+ log.debug("linkResourceRefs");
+ linkResourceRefs(resourceRefs, envCtx);
+ log.debug("linkMessageDestinationRefs");
+ MessageDestinationReferencesMetaData msgRefs = metaData.getMessageDestinationReferences();
+ linkMessageDestinationRefs(unit, msgRefs, envCtx);
+ EJBReferencesMetaData ejbRefs = metaData.getEjbReferences();
+ log.debug("linkEjbRefs");
+ linkEjbRefs(unit, ejbRefs, envCtx);
+ EJBLocalReferencesMetaData ejbLocalRefs = metaData.getEjbLocalReferences();
+ log.debug("linkEjbLocalRefs");
+ linkEjbLocalRefs(unit, ejbLocalRefs, envCtx);
+ log.debug("linkServiceRefs");
+ ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences();
+ linkServiceRefs(unit, serviceRefs, envCtx);
+ }
+
+ private void linkServiceRefs(VFSDeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException
+ {
+ ClassLoader loader = unit.getClassLoader();
+ UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
+ for(ServiceReferenceMetaData sref : serviceRefs)
+ {
+ String refName = sref.getServiceRefName();
+ new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
+ }
+ }
+
+ protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx)
+ throws ClassNotFoundException, NamingException
+ {
+ for (EnvironmentEntryMetaData entry : envEntries)
+ {
+ log.debug("Binding env-entry: " + entry.getName() + " of type: " +
+ entry.getType() + " to value:" + entry.getValue());
+ bindEnvEntry(envCtx, entry);
+ }
+ }
+
+ protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx)
+ throws NamingException
+ {
+ for(ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs)
+ {
+ String resourceName = ref.getJndiName();
+ String refName = ref.getResourceEnvRefName();
+ if (ref.getType().equals("java.net.URL"))
+ {
+ try
+ {
+ log.debug("Binding '" + refName + "' to URL: " + resourceName);
+ URL url = new URL(resourceName);
+ Util.bind(envCtx, refName, url);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new NamingException("Malformed URL:" + e.getMessage());
+ }
+ }
+ else if (resourceName != null)
+ {
+ log.debug("Linking '" + refName + "' to JNDI name: " + resourceName);
+ Util.bind(envCtx, refName, new LinkRef(resourceName));
+ }
+ else
+ {
+ throw new NamingException("resource-env-ref: " + refName
+ + " has no valid JNDI binding. Check the jboss-web/resource-env-ref.");
+ }
+ }
+ }
+
+ protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx)
+ throws NamingException
+ {
+ for(ResourceReferenceMetaData ref : resourceRefs)
+ {
+ String jndiName = ref.getJndiName();
+ String refName = ref.getResourceName();
+ if (ref.getType().equals("java.net.URL"))
+ {
+ try
+ {
+ String resURL = ref.getResUrl();
+ if (resURL != null)
+ {
+ log.debug("Binding '" + refName + "' to URL: " + resURL);
+ URL url = new URL(resURL);
+ Util.bind(envCtx, refName, url);
+ }
+ else
+ {
+ log.debug("Linking '" + refName + "' to URL: " + resURL);
+ LinkRef urlLink = new LinkRef(jndiName);
+ Util.bind(envCtx, refName, urlLink);
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ throw new NamingException("Malformed URL:" + e.getMessage());
+ }
+ }
+ else if (jndiName != null)
+ {
+ log.debug("Linking '" + refName + "' to JNDI name: " + jndiName);
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ else
+ {
+ throw new NamingException("resource-ref: " + refName
+ + " has no valid JNDI binding. Check the jboss-web/resource-ref.");
+ }
+ }
+ }
+
+ protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx)
+ throws NamingException
+ {
+ for(MessageDestinationReferenceMetaData ref : msgRefs)
+ {
+ String refName = ref.getName();
+ String jndiName = ref.getJndiName();
+ String link = ref.getLink();
+ if (link != null)
+ {
+ if (jndiName == null)
+ {
+ MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link);
+ if (messageDestination == null)
+ throw new NamingException("message-destination-ref '" + refName +
+ "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml");
+ else
+ {
+ String linkJNDIName = messageDestination.getJndiName();
+ if (linkJNDIName == null)
+ log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml");
+ else
+ jndiName = linkJNDIName;
+ }
+ }
+ else
+ log.warn("message-destination-ref '" + refName +
+ "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml");
+ }
+ else if (jndiName == null)
+ throw new NamingException("message-destination-ref '" + refName +
+ "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml");
+ Util.bind(envCtx, refName, new LinkRef(jndiName));
+ }
+ }
+
+ protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx)
+ throws NamingException
+ {
+ for(EJBReferenceMetaData ejb : ejbRefs)
+ {
+ String name = ejb.getName();
+ String linkName = ejb.getLink();
+ String jndiName = null;
+
+ //use ejb-link if it is specified
+ if (linkName != null)
+ {
+ jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName);
+
+ //if flag does not allow misconfigured ejb-links, it is an error
+ if ((jndiName == null) && !(getLenientEjbLink()))
+ throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
+ }
+
+
+ //fall through to the jndiName
+ if (jndiName == null)
+ {
+ jndiName = ejb.getJndiName();
+ if (jndiName == null)
+ throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml");
+ }
+
+ log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName);
+ Util.bind(envCtx, name, new LinkRef(jndiName));
+ }
+ }
+
+ protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx)
+ throws NamingException
+ {
+ for(EJBLocalReferenceMetaData ejb : ejbLocalRefs)
+ {
+ String name = ejb.getName();
+ String linkName = ejb.getLink();
+ String jndiName = null;
+
+ //use the ejb-link field if it is specified
+ if (linkName != null)
+ {
+ jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName);
+
+ //if flag does not allow misconfigured ejb-links, it is an error
+ if ((jndiName == null) && !(getLenientEjbLink()))
+ throw new NamingException("ejb-ref: " + name + ", no ejb-link match");
+ }
+
+
+ if (jndiName == null)
+ {
+ jndiName = ejb.getJndiName();
+ if (jndiName == null)
+ {
+ String msg = null;
+ if (linkName == null)
+ {
+ msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and "
+ + "no local-jndi-name in jboss-web.xml";
+ }
+ else
+ {
+ msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '"
+ + linkName + "' failed to resolve to an ejb with a LocalHome";
+ }
+ throw new NamingException(msg);
+ }
+ }
+
+ log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName);
+ Util.bind(envCtx, name, new LinkRef(jndiName));
+ }
+ }
+
+ /**
+ * This creates a java:comp/env/security context that contains a 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 security-domain
+ * element. If there was no security-domain element then the bindings are to
+ * NullSecurityManager instance which simply allows all access.
+ */
+ protected void linkSecurityDomain(String securityDomain, Context envCtx)
+ throws NamingException
+ {
+ if (securityDomain == null)
+ {
+ securityDomain = getDefaultSecurityDomain();
+ log.debug("No security-domain given, using default: " + securityDomain);
+ }
+
+ //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
+ if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
+ securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain;
+
+ log.debug("Linking security/securityMgr to JNDI name: " + securityDomain);
+ Util.bind(envCtx, "security/securityMgr", new LinkRef(securityDomain));
+ Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain+"/realmMapping"));
+ Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain+"/authorizationMgr"));
+ Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain));
+ Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
+ }
+
+ /**
+ * A utility method that searches the given loader for the resources:
+ * "javax/servlet/resources/web-app_2_3.dtd", "org/apache/jasper/resources/jsp12.dtd",
+ * and "javax/ejb/EJBHome.class" and returns an array of URL strings. Any
+ * jar: urls are reduced to the underlying <url> portion of the
+ * 'jar:<url>!/{entry}' construct.
+ */
+ public String[] getStandardCompileClasspath(ClassLoader loader)
+ {
+ String[] jspResources = {
+ "javax/servlet/resources/web-app_2_3.dtd",
+ "org/apache/jasper/resources/jsp12.dtd",
+ "javax/ejb/EJBHome.class"
+ };
+ ArrayList tmp = new ArrayList();
+ for (int j = 0; j < jspResources.length; j++)
+ {
+ URL rsrcURL = loader.getResource(jspResources[j]);
+ if (rsrcURL != null)
+ {
+ String url = rsrcURL.toExternalForm();
+ if (rsrcURL.getProtocol().equals("jar"))
+ {
+ // Parse the jar:<url>!/{entry} URL
+ url = url.substring(4);
+ int seperator = url.indexOf('!');
+ url = url.substring(0, seperator);
+ }
+ tmp.add(url);
+ }
+ else
+ {
+ log.warn("Failed to fin jsp rsrc: " + jspResources[j]);
+ }
+ }
+ log.trace("JSP StandardCompileClasspath: " + tmp);
+ String[] cp = new String[tmp.size()];
+ tmp.toArray(cp);
+ return cp;
+ }
+
+ /**
+ * A utility method that walks up the ClassLoader chain starting at the given
+ * loader and queries each ClassLoader for a 'URL[] getURLs()' method from
+ * which a complete classpath of URL strings is built.
+ */
+ public String[] getCompileClasspath(ClassLoader loader)
+ {
+ HashSet tmp = new HashSet();
+ ClassLoader cl = loader;
+ while (cl != null)
+ {
+ URL[] urls = AbstractWarDeployer.getClassLoaderURLs(cl);
+ addURLs(tmp, urls);
+ cl = cl.getParent();
+ }
+ try
+ {
+ URL[] globalUrls = (URL[]) server.getAttribute(LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY,
+ "URLs");
+ addURLs(tmp, globalUrls);
+ }
+ catch (Exception e)
+ {
+ log.warn("Could not get global URL[] from default loader repository!", e);
+ } // end of try-catch
+ log.trace("JSP CompileClasspath: " + tmp);
+ String[] cp = new String[tmp.size()];
+ tmp.toArray(cp);
+ return cp;
+ }
+
+ private void addURLs(Set urlSet, URL[] urls)
+ {
+ for (int u = 0; u < urls.length; u++)
+ {
+ URL url = urls[u];
+ urlSet.add(url.toExternalForm());
+ }
+ }
+
+ public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry)
+ throws ClassNotFoundException, NamingException
+ {
+ ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader();
+ Class type = loader.loadClass(entry.getType());
+ if (type == String.class)
+ {
+ Util.bind(ctx, entry.getName(), entry.getValue());
+ }
+ else if (type == Integer.class)
+ {
+ Util.bind(ctx, entry.getName(), new Integer(entry.getValue()));
+ }
+ else if (type == Long.class)
+ {
+ Util.bind(ctx, entry.getName(), new Long(entry.getValue()));
+ }
+ else if (type == Double.class)
+ {
+ Util.bind(ctx, entry.getName(), new Double(entry.getValue()));
+ }
+ else if (type == Float.class)
+ {
+ Util.bind(ctx, entry.getName(), new Float(entry.getValue()));
+ }
+ else if (type == Byte.class)
+ {
+ Util.bind(ctx, entry.getName(), new Byte(entry.getValue()));
+ }
+ else if (type == Character.class)
+ {
+ Object value = null;
+ String input = entry.getValue();
+ if (input == null || input.length() == 0)
+ {
+ value = new Character((char) 0);
+ }
+ else
+ {
+ value = new Character(input.charAt(0));
+ }
+ Util.bind(ctx, entry.getName(), value);
+ }
+ else if (type == Short.class)
+ {
+ Util.bind(ctx, entry.getName(), new Short(entry.getValue()));
+ }
+ else if (type == Boolean.class)
+ {
+ Util.bind(ctx, entry.getName(), new Boolean(entry.getValue()));
+ }
+ else
+ {
+ // Default to a String type
+ Util.bind(ctx, entry.getName(), entry.getValue());
+ }
+ }
+}
+
Property changes on: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/WARStructure.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WARStructure.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/WARStructure.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,228 +1,228 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployers;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.VisitorAttributes;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
-
-/**
- * WARStructure.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class WARStructure extends AbstractVFSStructureDeployer
-{
- /** The default filter which allows jars/jar directories */
- public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
-
- /** The web-inf/lib filter */
- private VirtualFileFilter webInfLibFilter = DEFAULT_WEB_INF_LIB_FILTER;
-
- /** The web-inf/lib/[some-archive]/META-INF filter */
- private VirtualFileFilter webInfLibMetaDataFilter;
-
- /**
- * Sets the default relative order 1000.
- *
- */
- public WARStructure()
- {
- setRelativeOrder(1000);
- }
-
- /**
- * Get the webInfLibFilter.
- *
- * @return the webInfLibFilter.
- */
- public VirtualFileFilter getWebInfLibFilter()
- {
- return webInfLibFilter;
- }
-
- /**
- * Set the webInfLibFilter.
- *
- * @param webInfLibFilter the webInfLibFilter.
- * @throws IllegalArgumentException for a null filter
- */
- public void setWebInfLibFilter(VirtualFileFilter webInfLibFilter)
- {
- if (webInfLibFilter == null)
- throw new IllegalArgumentException("Null filter");
- this.webInfLibFilter = webInfLibFilter;
- }
-
- /**
- * Get webInfLibMetaDataFilter
- *
- * @return the webInfLibMetaDataFilter
- */
- public VirtualFileFilter getWebInfLibMetaDataFilter()
- {
- return webInfLibMetaDataFilter;
- }
-
- /**
- * Set the webInfLibMetaDataFilter.
- *
- * @param webInfLibMetaDataFilter the webInfLibFilter.
- */
- public void setWebInfLibMetaDataFilter(VirtualFileFilter webInfLibMetaDataFilter)
- {
- this.webInfLibMetaDataFilter = webInfLibMetaDataFilter;
- }
-
- public boolean determineStructure(StructureContext structureContext) throws DeploymentException
- {
- ContextInfo context = null;
- VirtualFile file = structureContext.getFile();
- try
- {
- boolean trace = log.isTraceEnabled();
-
- if (isLeaf(file) == false)
- {
- // We require either a WEB-INF or the name ends in .war
- if (file.getName().endsWith(".war") == false)
- {
- try
- {
- VirtualFile child = file.getChild("WEB-INF");
- if (child != null)
- {
- if (trace)
- log.trace("... ok - directory has a WEB-INF subdirectory");
- }
- else
- {
- if (trace)
- log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
- return false;
- }
- }
- catch (IOException e)
- {
- log.warn("Exception while checking if file is a war: " + e);
- return false;
- }
- }
- else if (trace)
- {
- log.trace("... ok - name ends in .war.");
- }
-
- List<String> metaDataLocations = new ArrayList<String>();
- metaDataLocations.add("WEB-INF");
-
- // Check for WEB-INF/classes
- VirtualFile classes = null;
- try
- {
- // The classpath contains WEB-INF/classes
- classes = file.getChild("WEB-INF/classes");
-
- // Check for a META-INF for metadata
- if (classes != null)
- metaDataLocations.add("WEB-INF/classes/META-INF");
- }
- catch(IOException e)
- {
- log.warn("Exception while looking for classes, " + file.getPathName() + ", " + e);
- }
-
- // Check for jars in WEB-INF/lib
- List<VirtualFile> archives = null;
- try
- {
- VirtualFile webinfLib = file.getChild("WEB-INF/lib");
- if (webinfLib != null)
- {
- archives = webinfLib.getChildren(webInfLibFilter);
- // Add the jars' META-INF for metadata
- for (VirtualFile jar : archives)
- {
- // either same as plain lib filter, null or accepts the jar
- if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
- metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
- }
- }
- }
- catch (IOException e)
- {
- log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
- }
-
- // Create a context for this war file and all its metadata locations
- context = createContext(structureContext, metaDataLocations.toArray(new String[metaDataLocations.size()]));
-
- // Add the war manifest classpath entries
- addClassPath(structureContext, file, false, true, context);
-
- // Add WEB-INF/classes if present
- if (classes != null)
- addClassPath(structureContext, classes, true, false, context);
- else if (trace)
- log.trace("No WEB-INF/classes for: " + file.getPathName());
-
- // and the top level jars in WEB-INF/lib
- if (archives != null)
- {
- for (VirtualFile jar : archives)
- addClassPath(structureContext, jar, true, true, context);
- }
- else if (trace)
- {
- log.trace("No WEB-INF/lib for: " + file.getPathName());
- }
-
- // There are no subdeployments for wars
- return true;
- }
- else
- {
- if (trace)
- log.trace("... no - not a directory or an archive.");
- return false;
- }
- }
- catch (Exception e)
- {
- // Remove the invalid context
- if (context != null)
- structureContext.removeChild(context);
-
- throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployers;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
+
+/**
+ * WARStructure.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class WARStructure extends AbstractVFSStructureDeployer
+{
+ /** The default filter which allows jars/jar directories */
+ public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
+
+ /** The web-inf/lib filter */
+ private VirtualFileFilter webInfLibFilter = DEFAULT_WEB_INF_LIB_FILTER;
+
+ /** The web-inf/lib/[some-archive]/META-INF filter */
+ private VirtualFileFilter webInfLibMetaDataFilter;
+
+ /**
+ * Sets the default relative order 1000.
+ *
+ */
+ public WARStructure()
+ {
+ setRelativeOrder(1000);
+ }
+
+ /**
+ * Get the webInfLibFilter.
+ *
+ * @return the webInfLibFilter.
+ */
+ public VirtualFileFilter getWebInfLibFilter()
+ {
+ return webInfLibFilter;
+ }
+
+ /**
+ * Set the webInfLibFilter.
+ *
+ * @param webInfLibFilter the webInfLibFilter.
+ * @throws IllegalArgumentException for a null filter
+ */
+ public void setWebInfLibFilter(VirtualFileFilter webInfLibFilter)
+ {
+ if (webInfLibFilter == null)
+ throw new IllegalArgumentException("Null filter");
+ this.webInfLibFilter = webInfLibFilter;
+ }
+
+ /**
+ * Get webInfLibMetaDataFilter
+ *
+ * @return the webInfLibMetaDataFilter
+ */
+ public VirtualFileFilter getWebInfLibMetaDataFilter()
+ {
+ return webInfLibMetaDataFilter;
+ }
+
+ /**
+ * Set the webInfLibMetaDataFilter.
+ *
+ * @param webInfLibMetaDataFilter the webInfLibFilter.
+ */
+ public void setWebInfLibMetaDataFilter(VirtualFileFilter webInfLibMetaDataFilter)
+ {
+ this.webInfLibMetaDataFilter = webInfLibMetaDataFilter;
+ }
+
+ public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+ {
+ ContextInfo context = null;
+ VirtualFile file = structureContext.getFile();
+ try
+ {
+ boolean trace = log.isTraceEnabled();
+
+ if (isLeaf(file) == false)
+ {
+ // We require either a WEB-INF or the name ends in .war
+ if (file.getName().endsWith(".war") == false)
+ {
+ try
+ {
+ VirtualFile child = file.getChild("WEB-INF");
+ if (child != null)
+ {
+ if (trace)
+ log.trace("... ok - directory has a WEB-INF subdirectory");
+ }
+ else
+ {
+ if (trace)
+ log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
+ return false;
+ }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception while checking if file is a war: " + e);
+ return false;
+ }
+ }
+ else if (trace)
+ {
+ log.trace("... ok - name ends in .war.");
+ }
+
+ List<String> metaDataLocations = new ArrayList<String>();
+ metaDataLocations.add("WEB-INF");
+
+ // Check for WEB-INF/classes
+ VirtualFile classes = null;
+ try
+ {
+ // The classpath contains WEB-INF/classes
+ classes = file.getChild("WEB-INF/classes");
+
+ // Check for a META-INF for metadata
+ if (classes != null)
+ metaDataLocations.add("WEB-INF/classes/META-INF");
+ }
+ catch(IOException e)
+ {
+ log.warn("Exception while looking for classes, " + file.getPathName() + ", " + e);
+ }
+
+ // Check for jars in WEB-INF/lib
+ List<VirtualFile> archives = null;
+ try
+ {
+ VirtualFile webinfLib = file.getChild("WEB-INF/lib");
+ if (webinfLib != null)
+ {
+ archives = webinfLib.getChildren(webInfLibFilter);
+ // Add the jars' META-INF for metadata
+ for (VirtualFile jar : archives)
+ {
+ // either same as plain lib filter, null or accepts the jar
+ if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
+ metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
+ }
+
+ // Create a context for this war file and all its metadata locations
+ context = createContext(structureContext, metaDataLocations.toArray(new String[metaDataLocations.size()]));
+
+ // Add the war manifest classpath entries
+ addClassPath(structureContext, file, false, true, context);
+
+ // Add WEB-INF/classes if present
+ if (classes != null)
+ addClassPath(structureContext, classes, true, false, context);
+ else if (trace)
+ log.trace("No WEB-INF/classes for: " + file.getPathName());
+
+ // and the top level jars in WEB-INF/lib
+ if (archives != null)
+ {
+ for (VirtualFile jar : archives)
+ addClassPath(structureContext, jar, true, true, context);
+ }
+ else if (trace)
+ {
+ log.trace("No WEB-INF/lib for: " + file.getPathName());
+ }
+
+ // There are no subdeployments for wars
+ return true;
+ }
+ else
+ {
+ if (trace)
+ log.trace("... no - not a directory or an archive.");
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ // Remove the invalid context
+ if (context != null)
+ structureContext.removeChild(context);
+
+ throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
+ }
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/web/deployers/WARStructure.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/server/src/main/org/jboss/web/deployers/WarDeployment.java
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,59 +1,59 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployers;
-
-import org.jboss.deployment.security.AbstractSecurityDeployer;
-import org.jboss.deployment.security.WarJaccPolicy;
-import org.jboss.deployment.security.WarPolicyConfigurationFacade;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-
-//$Id$
-
-/**
- * Security Deployer for war
- * @author Anil.Saldhana at redhat.com
- * @since Feb 17, 2008
- * @version $Revision$
- */
-public class WarSecurityDeployer extends AbstractSecurityDeployer<JBossWebMetaData>
-{
- @Override
- protected ServiceMetaData getServiceMetaData()
- {
- ServiceMetaData serviceMetaData = new ServiceMetaData();
- serviceMetaData.setCode(WarPolicyConfigurationFacade.class.getName());
- return serviceMetaData;
- }
-
- @Override
- protected Class<JBossWebMetaData> getMetaDataClassType()
- {
- return JBossWebMetaData.class;
- }
-
- @Override
- protected String getJaccPolicyName()
- {
- return WarJaccPolicy.class.getName();
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployers;
+
+import org.jboss.deployment.security.AbstractSecurityDeployer;
+import org.jboss.deployment.security.WarJaccPolicy;
+import org.jboss.deployment.security.WarPolicyConfigurationFacade;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+//$Id$
+
+/**
+ * Security Deployer for war
+ * @author Anil.Saldhana at redhat.com
+ * @since Feb 17, 2008
+ * @version $Revision$
+ */
+public class WarSecurityDeployer extends AbstractSecurityDeployer<JBossWebMetaData>
+{
+ @Override
+ protected ServiceMetaData getServiceMetaData()
+ {
+ ServiceMetaData serviceMetaData = new ServiceMetaData();
+ serviceMetaData.setCode(WarPolicyConfigurationFacade.class.getName());
+ return serviceMetaData;
+ }
+
+ @Override
+ protected Class<JBossWebMetaData> getMetaDataClassType()
+ {
+ return JBossWebMetaData.class;
+ }
+
+ @Override
+ protected String getJaccPolicyName()
+ {
+ return WarJaccPolicy.class.getName();
+ }
}
\ No newline at end of file
Property changes on: trunk/server/src/main/org/jboss/web/deployers/WarSecurityDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/WebModule.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WebModule.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/WebModule.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,147 +1,147 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployers;
-
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployment.DeploymentException;
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.security.ISecurityManagement;
-import org.jboss.security.authorization.PolicyRegistration;
-import org.jboss.web.WebApplication;
-
-/** A container service used to introduce war dependencies. This service is
- created by the AbstractWebContainer during the create(DeploymentInfo) call
- and registered under the name "jboss.web.deployment:war="+di.shortName
- This name is stored in the di.context under the key AbstractWebContainer.WEB_MODULE
-
- When the jboss-web.xml dependencies are satisfied, this service is started
- and this triggers the AbstractWebDeployer.start. Likewise, a stop on this
- service triggers the AbstractWebDeployer.stop.
-
- @see AbstractWarDeployer
-
- @author Scott.Stark at jboss.org
- @author adrian at jboss.org
- @version $Revison:$
- */
-public class WebModule implements WebModuleMBean
-{
- private static Logger log = Logger.getLogger(WebModule.class);
-
- private VFSDeploymentUnit di;
- private AbstractWarDeployer container;
- private AbstractWarDeployment deployment;
-
- private ISecurityManagement securityManagement;
-
- public WebModule(VFSDeploymentUnit di, AbstractWarDeployer container, AbstractWarDeployment deployment)
- {
- this.di = di;
- this.container = container;
- this.deployment = deployment;
- this.deployment.setDeploymentUnit(di);
- }
-
- public void setKernel(Kernel kernel)
- {
- this.deployment.setKernel(kernel);
- }
-
- /**
- * Set the PolicyRegistration instance
- * @param policyRegistration the policy registration instance
- */
- public void setPolicyRegistration(PolicyRegistration policyRegistration)
- {
- deployment.setPolicyRegistration(policyRegistration);
- }
-
- /**
- * Set the securityManagement.
- *
- * @param securityManagement the securityManagement.
- */
- public void setSecurityManagement(ISecurityManagement securityManagement)
- {
- deployment.setSecurityManagement(securityManagement);
- }
-
- public void create()
- {
-
- }
- public void start() throws Exception
- {
- startModule();
- }
-
- public void stop() throws Exception
- {
- stopModule();
- }
-
- public void destroy()
- {
- this.di = null;
- this.container = null;
- this.deployment = null;
- }
-
- /** Invokes the deployer start
- */
- public synchronized void startModule()
- throws Exception
- {
- // Get the war URL
- JBossWebMetaData metaData = di.getAttachment(JBossWebMetaData.class);
- WebApplication webApp = deployment.start(di, metaData);
- String warURL = di.getName();
- container.addDeployedApp(warURL, webApp);
- }
-
- /** Invokes the deployer stop
- */
- public synchronized void stopModule()
- throws DeploymentException
- {
- String warURL = di.getName();
- try
- {
- WebApplication webApp = container.removeDeployedApp(warURL);
- if( deployment != null && webApp != null )
- {
- deployment.stop(di, webApp);
- }
- else
- {
- log.debug("Failed to find deployer/deployment for war: "+warURL);
- }
- }
- catch (Exception e)
- {
- throw new DeploymentException("Error during stop", e);
- }
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployers;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.DeploymentException;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.authorization.PolicyRegistration;
+import org.jboss.web.WebApplication;
+
+/** A container service used to introduce war dependencies. This service is
+ created by the AbstractWebContainer during the create(DeploymentInfo) call
+ and registered under the name "jboss.web.deployment:war="+di.shortName
+ This name is stored in the di.context under the key AbstractWebContainer.WEB_MODULE
+
+ When the jboss-web.xml dependencies are satisfied, this service is started
+ and this triggers the AbstractWebDeployer.start. Likewise, a stop on this
+ service triggers the AbstractWebDeployer.stop.
+
+ @see AbstractWarDeployer
+
+ @author Scott.Stark at jboss.org
+ @author adrian at jboss.org
+ @version $Revison:$
+ */
+public class WebModule implements WebModuleMBean
+{
+ private static Logger log = Logger.getLogger(WebModule.class);
+
+ private VFSDeploymentUnit di;
+ private AbstractWarDeployer container;
+ private AbstractWarDeployment deployment;
+
+ private ISecurityManagement securityManagement;
+
+ public WebModule(VFSDeploymentUnit di, AbstractWarDeployer container, AbstractWarDeployment deployment)
+ {
+ this.di = di;
+ this.container = container;
+ this.deployment = deployment;
+ this.deployment.setDeploymentUnit(di);
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.deployment.setKernel(kernel);
+ }
+
+ /**
+ * Set the PolicyRegistration instance
+ * @param policyRegistration the policy registration instance
+ */
+ public void setPolicyRegistration(PolicyRegistration policyRegistration)
+ {
+ deployment.setPolicyRegistration(policyRegistration);
+ }
+
+ /**
+ * Set the securityManagement.
+ *
+ * @param securityManagement the securityManagement.
+ */
+ public void setSecurityManagement(ISecurityManagement securityManagement)
+ {
+ deployment.setSecurityManagement(securityManagement);
+ }
+
+ public void create()
+ {
+
+ }
+ public void start() throws Exception
+ {
+ startModule();
+ }
+
+ public void stop() throws Exception
+ {
+ stopModule();
+ }
+
+ public void destroy()
+ {
+ this.di = null;
+ this.container = null;
+ this.deployment = null;
+ }
+
+ /** Invokes the deployer start
+ */
+ public synchronized void startModule()
+ throws Exception
+ {
+ // Get the war URL
+ JBossWebMetaData metaData = di.getAttachment(JBossWebMetaData.class);
+ WebApplication webApp = deployment.start(di, metaData);
+ String warURL = di.getName();
+ container.addDeployedApp(warURL, webApp);
+ }
+
+ /** Invokes the deployer stop
+ */
+ public synchronized void stopModule()
+ throws DeploymentException
+ {
+ String warURL = di.getName();
+ try
+ {
+ WebApplication webApp = container.removeDeployedApp(warURL);
+ if( deployment != null && webApp != null )
+ {
+ deployment.stop(di, webApp);
+ }
+ else
+ {
+ log.debug("Failed to find deployer/deployment for war: "+warURL);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Error during stop", e);
+ }
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/web/deployers/WebModule.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java 2008-11-14 15:11:50 UTC (rev 81067)
+++ trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java 2008-11-14 15:14:35 UTC (rev 81068)
@@ -1,44 +1,44 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.deployers;
-
-import org.jboss.kernel.Kernel;
-import org.jboss.security.ISecurityManagement;
-import org.jboss.security.authorization.PolicyRegistration;
-
-
-/** The standard mbean service interface for the WebModule
- * @author Scott.Stark at jboss.org
- * @author Anil.Saldhana at redhat.com
- * @version $Revison:$
- */
-public interface WebModuleMBean
-{
- public void create() throws Exception;
- public void start() throws Exception;
- public void stop() throws Exception;
- public void destroy() throws Exception;
-
- public void setKernel(Kernel kernel);
- public void setPolicyRegistration(PolicyRegistration policyRegistration);
- public void setSecurityManagement(ISecurityManagement securityManagement);
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployers;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.authorization.PolicyRegistration;
+
+
+/** The standard mbean service interface for the WebModule
+ * @author Scott.Stark at jboss.org
+ * @author Anil.Saldhana at redhat.com
+ * @version $Revison:$
+ */
+public interface WebModuleMBean
+{
+ public void create() throws Exception;
+ public void start() throws Exception;
+ public void stop() throws Exception;
+ public void destroy() throws Exception;
+
+ public void setKernel(Kernel kernel);
+ public void setPolicyRegistration(PolicyRegistration policyRegistration);
+ public void setSecurityManagement(ISecurityManagement securityManagement);
+}
Property changes on: trunk/server/src/main/org/jboss/web/deployers/WebModuleMBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list